⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 printer.cpp

📁 在手机操作系统symbina上使用的一个脚本扩展语言的代码实现,可以参考用于自己的开发
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		break;
	case ESendScaledBitmapToPrinter: 
		SendScaledBitmapToPrinterL();
		break;
	case EInsertScaledBitmap: 
		InsertScaledBitmapL();
		break;
	case EPrinterDocLength: 
		PrinterDocLength();
		break;
	case ESendRichTextToPrinter: 
		SendRichTextToPrinterL();
		break;
	case EResetPrinting: 
		ResetPrinting();
		break;
	case EPageSetupDialog: 
		PageSetupDialogL();
		break;
	case EPrintPreviewDialog: 
		PrintPreviewDialogL();
		break;
	case EPrintRangeDialog: 
		PrintRangeDialogL();
		break;
	case EPrintDialog:
		PrintDialogL();
		break;
	case ESendBufferToPrinter:
		SendBufferToPrinterL();
		break;
	default:
		User::Leave(KOplErrOpxProcNotFound);
		}
	}


//////////////////////////////////////////////////////////////////////////////
//																			//
//				User functions start here									//
//																			//
//////////////////////////////////////////////////////////////////////////////
void CPRINTEROpx::SendStringToPrinterL() 
	{
	TPtrC string = iOplAPI.PopString();
	iOplPrintEngine->InsertStringL(string,0, EAppend);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::InsertStringL()
	{
	TInt pos = iOplAPI.PopInt32();
	TPtrC string = iOplAPI.PopString();
	iOplPrintEngine->InsertStringL(string, pos);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SendNewParaToPrinterL()
	{
	iOplPrintEngine->InsertSpecialCharacterL(CEditableText::EParagraphDelimiter,0,EAppend);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::InsertNewParaL()
	{
	TInt pos = iOplAPI.PopInt32();
	iOplPrintEngine->InsertSpecialCharacterL(CEditableText::EParagraphDelimiter, pos);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SendSpecialCharToPrinterL()
	{
	TInt16 c = iOplAPI.PopInt16();
	iOplPrintEngine->InsertSpecialCharacterL(c,0,EAppend);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::InsertSpecialCharL()
	{
	TInt pos = iOplAPI.PopInt32();
	TInt16 c = iOplAPI.PopInt16();
	iOplPrintEngine->InsertSpecialCharacterL(c, pos);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SetAlignmentL()
	{
	TInt16 alignment = iOplAPI.PopInt16();
	iOplPrintEngine->SetAlignmentL((CParaFormat::TAlignment)alignment);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::InitialiseParaFormatL()
	{	
	TUint32 aDefaultTabWidthInTwips = iOplAPI.PopInt32();
	TInt32 aBorderMarginInTwips = iOplAPI.PopInt32();
	TBool aWrap = (iOplAPI.PopInt16() != 0);
	TBool aWidowOrphan = (iOplAPI.PopInt16() != 0);
	TBool aStartNewPage = (iOplAPI.PopInt16() != 0);
	TBool aKeepWithNext = (iOplAPI.PopInt16() != 0);
	TBool aKeepTogether = (iOplAPI.PopInt16() != 0);
	TInt32 aSpaceAfterInTwips = iOplAPI.PopInt32();
	TInt32 aSpaceBeforeInTwips = iOplAPI.PopInt32();
	CParaFormat::TLineSpacingControl aLineSpacingControl= (CParaFormat::TLineSpacingControl)iOplAPI.PopInt16();
	TInt32 aLineSpacingInTwips = iOplAPI.PopInt32();
	CParaFormat::TAlignment aVerticalAlignment = (CParaFormat::TAlignment)iOplAPI.PopInt16();
	CParaFormat::TAlignment aHorizontalAlignment = (CParaFormat::TAlignment)iOplAPI.PopInt16();
	TInt32 aIndentInTwips = iOplAPI.PopInt32();
	TInt32 aRightMarginInTwips = iOplAPI.PopInt32();
	TInt32 aLeftMarginInTwips = iOplAPI.PopInt32();
	TInt16 aBlue = iOplAPI.PopInt16();
	TInt16 aGreen = iOplAPI.PopInt16();
	TInt16 aRed = iOplAPI.PopInt16();
	iOplPrintEngine->InitialiseParaFormatL
		(
		aRed,
		aGreen,
		aBlue,
		aLeftMarginInTwips,
		aRightMarginInTwips,
		aIndentInTwips,
		aHorizontalAlignment,
		aVerticalAlignment,
		aLineSpacingInTwips,
		aLineSpacingControl,
		aSpaceBeforeInTwips,
		aSpaceAfterInTwips,
		aKeepTogether,
		aKeepWithNext,
		aStartNewPage,
		aWidowOrphan,
		aWrap,
		aBorderMarginInTwips,
		aDefaultTabWidthInTwips
		);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SetLocalParaFormatL()
	{
	iOplPrintEngine->SetLocalParaFormatL();
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SetGlobalParaFormatL()
	{
	iOplPrintEngine->SetGlobalParaFormatL();
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::RemoveSpecificParaFormatL()
	{
	iOplPrintEngine->RemoveSpecificParaFormatL();
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SetFontNameL()
	{
	TPtrC name = iOplAPI.PopString();
	iOplPrintEngine->SetFontNameL(name);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SetFontHeight()
	{
	TInt16 theHeight = iOplAPI.PopInt16();
	iOplPrintEngine->SetFontHeight(theHeight);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SetFontPosition()
	{
	TInt16 thePosition = iOplAPI.PopInt16();
	iOplPrintEngine->SetFontPosition(thePosition);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SetFontWeight()
	{
	TInt16 theWeight = iOplAPI.PopInt16();
	iOplPrintEngine->SetFontWeight(theWeight);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SetFontPosture()
	{
	TInt16 thePosture = iOplAPI.PopInt16();
	iOplPrintEngine->SetFontPosture(thePosture);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SetFontStrikethrough()
	{
	TInt16 theStrikethrough = iOplAPI.PopInt16();
	iOplPrintEngine->SetFontStrikethrough(theStrikethrough);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SetFontUnderline()
	{
	TInt16 theUnderline = iOplAPI.PopInt16();
	iOplPrintEngine->SetFontUnderline(theUnderline);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SetGlobalCharFormatL()
	{
	iOplPrintEngine->SetGlobalCharFormatL();
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::RemoveSpecificCharFormatL()
	{
	iOplPrintEngine->RemoveSpecificCharFormatL();
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SendBitmapToPrinterL() 
	{
	TInt32 OplHandle = iOplAPI.PopInt32();
	TInt32 PictureHandle = iOplAPI.BitmapHandleFromIdL(OplHandle);
	iOplPrintEngine->InsertBitmapL(0,PictureHandle,EAppend);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::InsertBitmapL() 
	{
	TInt pos = iOplAPI.PopInt32();
	TInt32 OplHandle = iOplAPI.PopInt32();
	TInt32 PictureHandle = iOplAPI.BitmapHandleFromIdL(OplHandle);
	iOplPrintEngine->InsertBitmapL(pos,PictureHandle);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SendScaledBitmapToPrinterL() 
	{
	TInt y = iOplAPI.PopInt32();
	TInt x = iOplAPI.PopInt32();
	TInt32 OplHandle = iOplAPI.PopInt32();
	TInt32 PictureHandle = iOplAPI.BitmapHandleFromIdL(OplHandle);
	iOplPrintEngine->InsertBitmapL(0,PictureHandle,EAppend, x, y);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::InsertScaledBitmapL() 
	{
	TInt y = iOplAPI.PopInt32();
	TInt x = iOplAPI.PopInt32();
	TInt pos = iOplAPI.PopInt32();
	TInt32 OplHandle = iOplAPI.PopInt32();
	TInt32 PictureHandle = iOplAPI.BitmapHandleFromIdL(OplHandle);
	iOplPrintEngine->InsertBitmapL(pos,PictureHandle, EInsert, x, y);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::PrinterDocLength()
	{
	TInt32 length = iOplPrintEngine->DocumentLength();
	iOplAPI.Push(length);
	}

void CPRINTEROpx::SendRichTextToPrinterL() 
	{
	TInt32 aRichTextPointer = iOplAPI.PopInt32();
	if((aRichTextPointer & 0x3) !=0) //	check its on a word boundary
		{
		User::Leave(KOplErrInvalidArgs);
		}
	iOplPrintEngine->SendRichTextToPrinterL((CRichText*)aRichTextPointer);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::SendBufferToPrinterL()
	{
	TInt32 offset = iOplAPI.PopInt32();
	TUint8* uintPtr = iOplAPI.OffsetToAddrL(offset, 1);
	TInt32* address = (TInt32*) uintPtr;
	TInt32 length = *address++;
	TPtr16 string((TUint16*)address, length, length);
	iOplPrintEngine->InsertStringL(string,0, EAppend);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::ResetPrinting()
	{
	iOplPrintEngine->ResetPrinting();
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::PageSetupDialogL()
	// Call standard Eikon page setup dialog. 
	{
	iOplPrintEngine->RunPageSetupDialogL();
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::PrintPreviewDialogL()
	{
	iOplPrintEngine->RunPrintPreviewDialogL();
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::PrintRangeDialogL()
	{
	TInt i = iOplPrintEngine->NumberOfPagesInDoc();
	iOplPrintEngine->RunPrintRangeDialogL(iOplPrintEngine->ReturnPrintSetup(), i);
	iOplAPI.Push(0.0);
	}

void CPRINTEROpx::PrintDialogL() 
	{
	iOplPrintEngine->RunPrintDialogL();
	iOplAPI.Push(0.0);
	}

TBool CPRINTEROpx::CheckVersion(TInt aVersion)
	// To check whether the OPX is a compatible version
	{
	if ((aVersion & 0xff00)>(KOpxPrinterVersion & 0xff00))	// major version must be <= OPX's version
		return EFalse;
	else
		return ETrue;
	}

EXPORT_C COpxBase* NewOpxL(OplAPI& aOplAPI)
	// Creates a COpxBase instance as required by the OPL runtime
	// This object is to be stored in the OPX's TLS as shown below
	{
	CPRINTEROpx* tls=((CPRINTEROpx*)Dll::Tls());
	if (tls==NULL)		// tls is NULL on loading an OPX DLL (also after unloading it)
		{
		tls=CPRINTEROpx::NewL(aOplAPI);
		Dll::SetTls(tls);
		}
	return (COpxBase *)tls;
	}

EXPORT_C TUint Version()
	{
	return KOpxPrinterVersion;
	}

GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
	//
	// DLL entry point
	//
	{
	return(KErrNone);
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -