📄 prntst.cpp
字号:
delete paraFormat;
}
void COplPrintTestEngine::SetGlobalParaFormatL()
// Set the paragraph format created by InitialiseParaFormat or SetAlignment as the global paragraph format
{
iFormatChanged = ETrue;
CParaFormat* paraFormat = CParaFormat::NewL();
TParaFormatMask paraFormatMask;
iRichText->CGlobalText::GetParaFormatL(paraFormat, paraFormatMask, 0,0);
if(!(iParaFormat->IsEqual(*paraFormat, paraFormatMask) && paraFormatMask == iParaFormatMask))
iRichText->CGlobalText::ApplyParaFormatL(iParaFormat, iParaFormatMask, 0,0);
delete paraFormat;
}
void COplPrintTestEngine::RemoveSpecificParaFormatL()
// Get rid of the local paragraph format, so the global takes effect
{
iRichText->RemoveSpecificParaFormatL(iRichText->DocumentLength(),0);
}
void COplPrintTestEngine::SetGlobalCharFormatL()
// Set the current character format to be the global default
{
TCharFormatMask mask;
mask.SetAll();
iRichText->CGlobalText::ApplyCharFormatL(iCharFormat, mask, 0,0);
}
void COplPrintTestEngine::RemoveSpecificCharFormatL()
// Make the character format take on global attributes
{
const CCharFormatLayer *pLay = iRichText->GlobalCharFormatLayer();
iCharFormatMask.ClearAll();
pLay->Sense(iCharFormat,iCharFormatMask );
iFormatChanged = ETrue;
}
void COplPrintTestEngine::InsertSpecialCharacterL(TInt16 aSpecialChar, const TInt aPos, TTextInsertPosition aTIP)
// Insert a special character (as defined by CEditableText) at aPos if aTIP == EInsert. Append otherwise
{
iFormatChanged = ETrue;
TInt pos;
pos = SetInsertPositon(aPos, aTIP);
iRichText->InsertL(pos, aSpecialChar);
}
TInt COplPrintTestEngine::DocumentLength()
// Return number of chars (including special chars, bitmaps count as 1).
// This is called when appending characters for example
{
return iRichText->DocumentLength();
}
// The following 4 functions are based on ones by Gareth Richards.
//Some changes had to be made
TBool COplPrintTestEngine::RemoveUnnessaryParaSettings(const CParaFormat *pParaFormat,TParaFormatMask *pParaMask,long pos)
{
CParaFormat ParaFormat;
TParaFormatMask Mask;
if(pos != 0 )
{ // Make sure we get the Format for the previous position, but don't go -ve.
pos--;
}
TRAPD(res,iRichText->GetParaFormatL(&ParaFormat,Mask,pos,0));
if (res!=0)
return 0;
return RemoveUnnessaryParaSettings2(&ParaFormat,pParaFormat,pParaMask);
}
TBool COplPrintTestEngine::RemoveUnnessaryCharSettings(const TCharFormat *pCharFormat,TCharFormatMask *pCharMask,long Pos)
{
TCharFormat CharFormat;
TCharFormatMask Mask;
iRichText->GetCharFormat(CharFormat,Mask, Pos, 0);
return RemoveUnnessaryCharSettings2(&CharFormat,pCharFormat,pCharMask);
}
TBool COplPrintTestEngine::RemoveUnnessaryParaSettings2(const CParaFormat *pBaseParaFormat,const CParaFormat *pParaFormat,TParaFormatMask *pParaMask)
{
TParaFormatMask Mask;
TBool SetSomething=EFalse;
for (int ii=EAttParaLanguage; ii<EAttTabStop; ii++)
{
if (pParaMask->AttribIsSet((TTextFormatAttribute)ii))
{
Mask.ClearAll();
Mask.SetAttrib((TTextFormatAttribute)ii);
if (pParaFormat->IsEqual(*pBaseParaFormat,Mask))
pParaMask->ClearAttrib((TTextFormatAttribute)ii);
else
SetSomething=ETrue;
}
}
return SetSomething;
}
TBool COplPrintTestEngine::RemoveUnnessaryCharSettings2(const TCharFormat *pBaseCharFormat,const TCharFormat *pCharFormat,TCharFormatMask *pCharMask)
{
TCharFormatMask Mask;
TBool SetSomething=EFalse;
for (int ii=EAttCharLanguage; ii<ETextFormatAttributeCount; ii++)
{
if (pCharMask->AttribIsSet((TTextFormatAttribute)ii))
{
Mask.ClearAll();
Mask.SetAttrib((TTextFormatAttribute)ii);
if (pCharFormat->IsEqual(*pBaseCharFormat,Mask))
pCharMask->ClearAttrib((TTextFormatAttribute)ii);
else
SetSomething=ETrue;
}
}
return SetSomething;
}
TInt32 COplPrintTestEngine::GetRichText()
{
return (TInt32) iRichText;
}
//////////////////////////////////////////////////////////////////////////////////////////
// //
// CPRNTSTOpx, a proxy class to provide a opx interface to COplPrintTestEngine //
// //
//////////////////////////////////////////////////////////////////////////////////////////
CPRNTSTOpx::CPRNTSTOpx(OplAPI& aOplAPI)
:COpxBase(aOplAPI)
{
}
CPRNTSTOpx* CPRNTSTOpx::NewL(OplAPI& aOplAPI)
{
CPRNTSTOpx* This=new(ELeave) CPRNTSTOpx(aOplAPI);
CleanupStack::PushL(This);
This->ConstructL();
CleanupStack::Pop();
return This;
}
void CPRNTSTOpx::ConstructL()
{
iOplPrintTestEngine = COplPrintTestEngine::NewL(iOplAPI);
}
CPRNTSTOpx::~CPRNTSTOpx()
{
delete iOplPrintTestEngine;
Dll::FreeTls(); // Required so that Tls is set to zero on unloading the OPX in UNLOADM
}
// Get the function by ordinal.
//
void CPRNTSTOpx::RunL(TInt aProcNum)
{
switch(aProcNum)
{
case EGetRichText:
GetRichText();
break;
default:
User::Leave(KOplErrOpxProcNotFound);
}
}
//////////////////////////////////////////////////////////////////////////////
// //
// User functions start here //
// //
// //
// //
//////////////////////////////////////////////////////////////////////////////
void CPRNTSTOpx::GetRichText()
{
TInt32 pointer;
_LIT(KRichText,"This is some hard-coded rich text.");
iOplPrintTestEngine->InsertStringL(KRichText, 0, EAppend);
iOplPrintTestEngine->InsertSpecialCharacterL(CEditableText::EParagraphDelimiter,0,EAppend);
iOplPrintTestEngine->InsertSpecialCharacterL(CEditableText::EParagraphDelimiter,0,EAppend);
iOplPrintTestEngine->InsertSpecialCharacterL(CEditableText::EParagraphDelimiter,0,EAppend);
iOplPrintTestEngine->InsertSpecialCharacterL(CEditableText::EParagraphDelimiter,0,EAppend);
iOplPrintTestEngine->SetAlignmentL(CParaFormat::ECenterAlign);
iOplPrintTestEngine->SetFontHeight(1000);
iOplPrintTestEngine->SetLocalParaFormatL();
iOplPrintTestEngine->InsertStringL(_L("This paragraph is centered!"), 0, EAppend);
iOplPrintTestEngine->InsertSpecialCharacterL(CEditableText::EParagraphDelimiter,0,EAppend);
iOplPrintTestEngine->RemoveSpecificParaFormatL();
iOplPrintTestEngine->InsertSpecialCharacterL(CEditableText::EParagraphDelimiter,0,EAppend);
iOplPrintTestEngine->InsertSpecialCharacterL(CEditableText::EParagraphDelimiter,0,EAppend);
iOplPrintTestEngine->SetFontNameL(_L("Times New Roman"));
iOplPrintTestEngine->InsertStringL(_L("This paragraph is in Times font."), 0, EAppend);
pointer = iOplPrintTestEngine->GetRichText();
iOplAPI.Push(pointer);
}
TBool CPRNTSTOpx::CheckVersion(TInt aVersion)
// To check whether the opx is a compatible version
{
if ((aVersion & 0x0f00)>(KOpxPrintTestVersion & 0xf00)) // 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
{
CPRNTSTOpx* tls=((CPRNTSTOpx*)Dll::Tls());
if (tls==NULL) // tls is NULL on loading an OPX DLL (also after unloading it)
{
tls=CPRNTSTOpx::NewL(aOplAPI);
Dll::SetTls(tls);
}
return (COpxBase *)tls;
}
EXPORT_C TUint Version()
{
return KOpxPrintTestVersion;
}
GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
//
// DLL entry point
//
{
return(KErrNone);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -