void CWordAppUi::SetBulletL() { TParaFormatMask mask; CParaFormat* paraFormat = CParaFormat::NewLC(); const TCursorSelection cursorSelection = iRichEd->TextView()->Selection(); const TInt lower = cursorSelection.LowerPos(); const TInt selectionLength = cursorSelection.Length(); CRichText* text = Text(); text->GetParaFormatL(paraFormat, mask, lower, selectionLength); delete paraFormat->iBullet; mask.ClearAll(); mask.SetAttrib(EAttBullet); mask.SetAttrib(EAttIndent); if (((CEikButtonBase*)iEikonEnv->AppUiFactory()->ToolBand()->ControlById(EWordButtonBullets))->State() == CEikButtonBase::EClear) { paraFormat->iBullet = NULL; paraFormat->iIndentInTwips = 0; } else { TBullet* bullet = new(ELeave) TBullet; if (!iBullet) CreateDefaultBulletL(); *bullet = *iBullet; paraFormat->iBullet = bullet; if (iBullet->iHangingIndent) paraFormat->iIndentInTwips = 283; // about 1/2cm - completely arbitrary value !! else paraFormat->iIndentInTwips = 0; } iRichEd->ApplyParaFormatL(paraFormat, mask); CleanupStack::PopAndDestroy(); }
void CWordAppUi::RunSelectBulletDialogL() { if (!iBullet) CreateDefaultBulletL(); CParaFormat* paraFormat=CParaFormat::NewLC(); TParaFormatMask paraUndeterminedMask; TCharFormat charFormat; TCharFormatMask charFormatMask; const TCursorSelection selection=iRichEd->TextView()->Selection(); Text()->GetParaFormatL(paraFormat,paraUndeterminedMask,selection.LowerPos(),selection.Length()); Text()->GetCharFormat(charFormat,charFormatMask,selection.LowerPos(),selection.Length()); TRgb backColor=paraFormat->iFillColor; if (paraUndeterminedMask.AttribIsSet(EAttFillColor)) backColor=KRgbWhite; // what else could be done ??? if (paraFormat->iBullet) *iBullet=*paraFormat->iBullet; CEikDialog* dialog=new(ELeave) CWordBulletDialog(iBullet,backColor,NULL,charFormat.iFontSpec.iTypeface.iName); if (dialog->ExecuteLD(R_WORD_DIALOG_BULLET)) { CEikButtonBase* but = (CEikButtonBase*)iEikonEnv->AppUiFactory()->ToolBand()->ControlById(EWordButtonBullets); but->SetState(CEikButtonBase::ESet); SetBulletL(); but->DrawNow(); } CleanupStack::PopAndDestroy(); }
void CWordTest::SetWrapL(CEikRichTextEditor* aEditor,TBool aWrap) { CParaFormat format; format.iWrap = aWrap; TParaFormatMask mask; mask.SetAttrib(EAttWrap); aEditor->ApplyParaFormatL(&format,mask); }
void CHelpContainer::SetAlignment(CParaFormat::TAlignment aAlignment) { CParaFormat paraFormat; TParaFormatMask paraFormatMask; paraFormatMask.SetAttrib(EAttAlignment); // set the mask paraFormat.iHorizontalAlignment = aAlignment; iRtEd->ApplyParaFormatL(¶Format, paraFormatMask); }
void CFormCursorModifier::InitialiseCursorPositionL(CEikEdwin* aEdwin) { CRichText* rT = static_cast<CRichText*>(aEdwin->Text()); CParaFormat* paraF = CParaFormat::NewLC(); paraF->iLanguage = (iDirectionality == ELeftToRight) ? ELangEnglish : ELangArabic; TParaFormatMask langMask; langMask.SetAttrib(EAttParaLanguage); rT->ApplyParaFormatL(paraF, langMask, 0, 1); if (iTextView) iTextView->HandleRangeFormatChangeL(TCursorSelection(0, iTextLayout->DocumentLength()), ETrue); CleanupStack::PopAndDestroy(); // paraF }
void CWordAppUi::CmdChangeAlignmentL() { CParaFormat format; TParaFormatMask undeterminedMask; const TCursorSelection selection=iRichEd->Selection(); Text()->GetParaFormatL(&format,undeterminedMask,selection.LowerPos(),selection.Length()); // TInt index=format.iHorizontalAlignment+1; // toggle the alignment // if (undeterminedMask.AttribIsSet(EAttAlignment)) index=4; // ...to force default case // if (index>=4) index=0; // where alignment > justifed, make it left aligned. SetParaAlignmentL(index); }
void CWordStyleGallery::AppendDescriptionL(TTextFormatAttribute aAttribute,const CParaFormat& aFormat,const TParaFormatMask& aMask) { if (aMask.AttribIsSet(aAttribute) && aFormat.ParaBorder((CParaFormat::TParaBorderSide)(aAttribute-EAttTopBorder)).iLineStyle!=TParaBorder::ENullLineStyle) { DoAppendDescriptionL((*iStyleDescriptor)[(TDescriptor)aAttribute]); } }
/** @SYMTestCaseID SYSLIB-ETEXT-CT-4001 @SYMTestCaseDesc Pasted final paragraph formatting should match copied final paragraph formatting. @SYMTestPriority High @SYMTestActions Enter three paragraphs into an empty document with the last paragraph *not* terminated by a paragraph delimiter. Apply some custom formatting to the last paragraph then copy and paste all of the text into a new empty document. @SYMTestExpectedResults The formatting in the pasted final paragraph should match the copied. @SYMDEF INC115783 */ LOCAL_C void testRichTextCutPaste2() { INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-CT-4001 Pasted final paragraph format should match copied final paragraph format ")); TheReadBoard=NULL; TheWriteBoard=NULL; TheFileName=_L("z:\\test\\app-framework\\etext\\rtclipb2.pml"); // dummy - just to get global layers ParseRichTextDocumentLC(); TheText->Reset(); TheText->InsertL(0,_L("\x2029\x2029SomeData")); //3 paras, last has no ending para delimiter); //create paragraph formatting (yellow bkg, indent & bullets) CParaFormat* paraFormatIn = CParaFormat::NewLC(); paraFormatIn->iBullet=new(ELeave)TBullet; paraFormatIn->iBullet->iHeightInTwips=240; paraFormatIn->iFillColor = 0xffffff00; paraFormatIn->iIndentInTwips = 600; TParaFormatMask paraFormatMask; paraFormatMask.SetAttrib(EAttBullet); paraFormatMask.SetAttrib(EAttFillColor); paraFormatMask.SetAttrib(EAttIndent); TheText->ApplyParaFormatL(paraFormatIn,paraFormatMask,3,0); //Apply format to last para only OpenWriteClipboardLC(); TheText->CopyToStoreL(TheWriteBoard->Store(),TheWriteBoard->StreamDictionary(),0,TheText->DocumentLength()); TheText->Reset(); test(TheText->DocumentLength()==0); OpenReadClipboardLC(); TheText->PasteFromStoreL(TheReadBoard->Store(),TheReadBoard->StreamDictionary(),TheText->DocumentLength()); test(TheText->DocumentLength()==_L("\x2029\x2029SomeData").Length()); test(TheText->ParagraphCount()==3); CParaFormat* paraFormatOut = CParaFormat::NewLC(); TheText->GetParagraphFormatL(paraFormatOut,3); test(paraFormatOut->IsEqual(*paraFormatIn,paraFormatMask));// in and out should match CleanupStack::PopAndDestroy(4); delete TheGlobalParaLayer; delete TheGlobalCharLayer; }
EXPORT_C void CGlobalText::GetParaFormatL(CParaFormat* aFormat,TParaFormatMask& aVaries,TInt /*aPos*/,TInt /*aLength*/, CParaFormat::TParaFormatGetMode aMode) const /** Gets the the global text object's effective paragraph formatting. Note that the position and length arguments are only used in the rich text implementation of this function. @param aFormat Must not be NULL or a panic occurs. On return, contains the effective paragraph formatting for the global text object. @param aVaries On return, a bitmask indicating which paragraph format attributes vary over the range of characters selected. This is only relevant for rich text, so for global text returns a value of zero for all attributes. @param aPos This argument is not used for global text. @param aLength This argument is not used for global text. @param aMode The default, EAllAttributes indicates that values for all paragraph format attributes are written to aFormat. EFixedAttributes indicates that tabs, bullets and borders are not written to aFormat. */ { iGlobalParaFormatLayer->SenseEffectiveL(aFormat,aMode); aVaries.ClearAll(); }
/** * Constructs the text control with the complex fonts. */ void CComplexFontsControl::ConstructL(const CCoeControl* aParent) { User::LeaveIfError(iSemaphore.OpenGlobal(KSemaphore)); if (aParent) { SetContainerWindowL(*aParent); } else { CreateWindowL(); } // Create text object, text view and layout. iParaFormatLayer = CParaFormatLayer::NewL(); iCharFormatLayer = CCharFormatLayer::NewL(); // Create an empty rich text object iRichText = CRichText::NewL(iParaFormatLayer, iCharFormatLayer); iScreen = new(ELeave) CWsScreenDevice(ControlEnv()->WsSession()); User::LeaveIfError(iScreen->Construct()); // default screen used TPixelsAndRotation pixelsAndRotation; iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); // Create the text layout, (required by text view), // with the text object and a wrap width (=width of view rect) iLayout = CTextLayout::NewL(iRichText,pixelsAndRotation.iPixelSize.iWidth); // Create text view iTextView = CTextView::NewL(iLayout, pixelsAndRotation.iPixelSize, iScreen, iScreen, &Window(), 0, // no window group &iCoeEnv->WsSession()); // new view SetRect(TRect(TPoint(0, 0), pixelsAndRotation.iPixelSize)); // load up text iRichText->InsertL(0, KComplexFontsText); // break up into paragraphs for CRichText by replacing \n characters in original text // with CEditableText::EParagraphDelimiter TPtrC complexFontsTextPtr(KComplexFontsText); TInt eos = complexFontsTextPtr.Length(); for (TInt paragraphBreakLocation = 0; paragraphBreakLocation < eos; paragraphBreakLocation++) { if (complexFontsTextPtr[paragraphBreakLocation] == '\n') { iRichText->DeleteL(paragraphBreakLocation, 1); iRichText->InsertL(paragraphBreakLocation, CEditableText::EParagraphDelimiter); } } TCharFormat charFormat; TCharFormatMask charFormatMask; // format the first paragraph "Class RWindow" as orange and a bit bigger than the body charFormat.iFontPresentation.iTextColor= TLogicalRgb(TRgb(0x0099ff)); charFormatMask.SetAttrib(EAttColor); charFormat.iFontSpec.iHeight = KHeaderFontSize; charFormatMask.SetAttrib(EAttFontHeight); TInt headerLength = 0; TInt headerStart = iRichText->CharPosOfParagraph(headerLength, KHeadingParagraph); iRichText->ApplyCharFormatL(charFormat, charFormatMask, headerStart, headerLength); charFormatMask.ClearAll(); // format "Class" as Sans Serif charFormat.iFontSpec.iTypeface.iName = KNokiaSeries60Font; charFormatMask.SetAttrib(EAttFontTypeface); iRichText->ApplyCharFormatL(charFormat, charFormatMask, headerStart, 5); charFormatMask.ClearAll(); // make the rest of the text smaller charFormat.iFontSpec.iHeight = KBodyFontSize; charFormatMask.SetAttrib(EAttFontHeight); TInt textLength = iRichText->DocumentLength(); iRichText->ApplyCharFormatL(charFormat, charFormatMask, headerLength, textLength - headerLength); charFormatMask.ClearAll(); TParaFormatMask paraFormatMask; // crunch main body a bit closer together to show more on the little screen // and indent left margin iParaFormat.iLineSpacingInTwips = KBodyLineSpacing; paraFormatMask.SetAttrib(EAttLineSpacing); iParaFormat.iLineSpacingControl = CParaFormat::ELineSpacingExactlyInPixels; paraFormatMask.SetAttrib(EAttLineSpacingControl); iParaFormat.iLeftMarginInTwips = KBodyIndent; paraFormatMask.SetAttrib(EAttLeftMargin); iRichText->ApplyParaFormatL(&iParaFormat, paraFormatMask, headerLength, textLength - headerLength); paraFormatMask.ClearAll(); TInt length = 0; TInt start = 0; // put a grey background on "class RWindow : public RDrawableWindow;" start = iRichText->CharPosOfParagraph(length, KClassParagraph); iParaFormat.iFillColor = TLogicalRgb(TRgb(0xdddddd)); paraFormatMask.SetAttrib(EAttFillColor); iRichText->ApplyParaFormatL(&iParaFormat, paraFormatMask, start, length); paraFormatMask.ClearAll(); // make "Description" and "Derivation" subheadings bold charFormat.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); charFormatMask.SetAttrib(EAttFontStrokeWeight); start = iRichText->CharPosOfParagraph(length, KDescriptionHeading); iRichText->ApplyCharFormatL(charFormat, charFormatMask, start, length); start = iRichText->CharPosOfParagraph(length, KDerivationHeading); iRichText->ApplyCharFormatL(charFormat, charFormatMask, start, length); charFormatMask.ClearAll(); // all the paragraphs between and including "Description" and "Derivation" are in sans serif // (the default CRichText font is serif) TInt paragraphNumber = 0; charFormat.iFontSpec.iTypeface.iName = KNokiaSeries60Font; charFormatMask.SetAttrib(EAttFontTypeface); for (paragraphNumber = KDescriptionHeading; paragraphNumber <= KDerivationHeading; paragraphNumber++) { start = iRichText->CharPosOfParagraph(length, paragraphNumber); iRichText->ApplyCharFormatL(charFormat, charFormatMask, start, length); } charFormatMask.ClearAll(); // for each line in the "Derivation" section // progressively indent left margin // make class name blue underlined (it starts two characters after the // beginning of each paragraph and goes to the space before the '-') // make descriptive text sans serif (from the '-' to the end of the paragraph) paraFormatMask.SetAttrib(EAttLeftMargin); charFormat.iFontPresentation.iTextColor= TLogicalRgb(TRgb(0xA27316)); charFormat.iFontPresentation.iUnderline = EUnderlineOn; for (paragraphNumber = KFirstDerivation; paragraphNumber <= KLastDerivation; paragraphNumber++) { iParaFormat.iLeftMarginInTwips = (paragraphNumber - KFirstDerivation + 2)*KBodyIndent; start = iRichText->CharPosOfParagraph(length, paragraphNumber); iRichText->ApplyParaFormatL(&iParaFormat, paraFormatMask, start, length); TInt dash = 0; for (dash = start; dash < start + length; dash++) { if (complexFontsTextPtr[dash] == '-') { break; } } charFormatMask.SetAttrib(EAttColor); charFormatMask.SetAttrib(EAttFontUnderline); TInt classNameLength = (dash - 1) - (start + 2); iRichText->ApplyCharFormatL(charFormat, charFormatMask, start + 2, classNameLength); charFormatMask.ClearAll(); charFormatMask.SetAttrib(EAttFontTypeface); TInt descriptionLength = length - classNameLength - 4; iRichText->ApplyCharFormatL(charFormat, charFormatMask, dash, descriptionLength); charFormatMask.ClearAll(); } paraFormatMask.ClearAll(); if (!aParent) { ActivateL(); } }
void CWordStyleGallery::PostLayoutDynInitL() { DoCalcColumnWidthsL(); iStyleDescriptor=iCoeEnv->ReadDesCArrayResourceL(R_WORD_STYLE_GALLERY_DESCRIPTIONS); // iCoeEnv->ReadResource(iNormalName , R_WORD_NORMAL); iCoeEnv->ReadResource(iHotKey , R_WORD_HOTKEY); TInt pos=0; iStyleNameList->Reset(); iStyleNameList->AppendL(iNormalName); TBool styleChange; TInt keycount=iData.iHotKeyList.Count(); const CParaFormatLayer* style=iData.iText.ParagraphStyle(styleChange,iData.iSelection.LowerPos(),iData.iSelection.Length()); TInt count=iData.iStyleList.Count(); for (TInt i=0;i<count;i++) iStyleNameList->AppendL(iData.iStyleList.At(i).iStyle->iName); iStyleNameList->Sort(); TUid id=style->Type(); for (TInt k=0;k<iStyleNameList->Count();k++) { if (id==KNormalParagraphStyleUid) { if (iNormalName==(*iStyleNameList)[k]) { pos=k; break; } } else if(((CParagraphStyle*)style)->iName==(*iStyleNameList)[k]) { pos=k; break; } } // Make sure all styles have a hot key, even if it's not assigned // since any pasted styles will be missing hot key info if (keycount < count) { TInt idx; TInt keysToAdd = count-keycount; for (idx=0; idx<keysToAdd; idx++) iData.iHotKeyList.AppendL(KNoHotkey); } else if ( keycount > count ) { //too many, they should be the same so remove extras TInt idx; for (idx=keycount-1; idx>=count; idx--) iData.iHotKeyList.Delete(idx); } MergeArraysL(); ListBox()->CreateScrollBarFrameL(); ListBox()->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); ListBox()->Model()->SetItemTextArray(iStyleNameKeyList); ListBox()->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); ListBox()->HandleItemAdditionL(); SetListBoxCurrentItem(EWordCidStyleNameList,pos); SetDeleteButton(); CEikGlobalTextEditor* edwin=(CEikGlobalTextEditor*)Control(EWordCidStyleInfo); CCharFormatLayer* clayer=CONST_CAST(CCharFormatLayer*,(edwin->GlobalText())->GlobalCharFormatLayer()); CParaFormatLayer* player=CONST_CAST(CParaFormatLayer*,(edwin->GlobalText())->GlobalParaFormatLayer()); TCharFormatMask defaultCharFormatMask; TCharFormat defaultCharFormat; TInt fontAttributes=TTypeface::EProportional; defaultCharFormat.iFontSpec.iTypeface.SetAttributes(fontAttributes); defaultCharFormat.iFontSpec.iHeight=160; defaultCharFormatMask.SetAttrib(EAttFontHeight); defaultCharFormatMask.SetAttrib(EAttFontTypeface); clayer->SetL(defaultCharFormat,defaultCharFormatMask); // CParaFormat pFormat; TParaFormatMask pMask; pFormat.iLineSpacingInTwips=160; pMask.SetAttrib(EAttLineSpacing); player->SetL(&pFormat,pMask); // StyleDescriptionL(pos); SetLineNonFocusing(EWordCidStyleInfo); // }
void CWordStyleGallery::AppendDescriptionL(TTextFormatAttribute aAttribute,const TParaFormatMask& aMask) { if (aMask.AttribIsSet(aAttribute)) DoAppendDescriptionL((*iStyleDescriptor)[(TDescriptor)aAttribute]); }
void CWordStyleGallery::FillBufferL(const CParaFormatLayer& aParaFormatLayer) { CEikGlobalTextEditor* edwin=(CEikGlobalTextEditor*)Control(EWordCidStyleInfo); TCharFormat charFormat; TCharFormatMask charMask; CParaFormat* paraFormat=CParaFormat::NewLC(); TParaFormatMask paraMask; // // iCurrentDescription=HBufC::NewL(KDescriptionGranularity); TPtr buf=iCurrentDescription->Des(); TBool isNormalStyle=(aParaFormatLayer.Type()==KNormalParagraphStyleUid); if (!isNormalStyle) { const CParagraphStyle* flayer=REINTERPRET_CAST(const CParagraphStyle*,aParaFormatLayer.SenseBase()); TUid type=flayer->Type(); if (type==KNormalParagraphStyleUid) buf.Append(iNormalName); else buf.Append(flayer->iName); buf.Append('+'); } // if (isNormalStyle) iData.iText.GlobalCharFormatLayer()->Sense(charFormat,charMask); else REINTERPRET_CAST(const CParagraphStyle&,aParaFormatLayer).CharFormatLayer()->Sense(charFormat,charMask); aParaFormatLayer.SenseL(paraFormat,paraMask); // if (!charMask.IsNull()) { if (charMask.AttribIsSet(EAttFontTypeface)) DoAppendDescriptionL(charFormat.iFontSpec.iTypeface.iName); if (charMask.AttribIsSet(EAttFontHeight)) { TInt height=charFormat.iFontSpec.iHeight; height=(height+10)/20; TBuf<20> num; num.Num(height); TBuf<10> unit; iCoeEnv->ReadResource(unit,R_WORD_FONT_UNITS); num.Append(unit); DoAppendDescriptionL(num); } if (charMask.AttribIsSet(EAttFontPosture)) { if (charFormat.iFontSpec.iFontStyle.Posture()==EPostureItalic) DoAppendDescriptionL((*iStyleDescriptor)[EDesItalic]); } if (charMask.AttribIsSet(EAttFontStrokeWeight)) { if (charFormat.iFontSpec.iFontStyle.StrokeWeight()==EStrokeWeightBold) DoAppendDescriptionL((*iStyleDescriptor)[EDesBold]); } if (charMask.AttribIsSet(EAttFontPrintPos)) { TFontPrintPosition pos=charFormat.iFontSpec.iFontStyle.PrintPosition(); switch(pos) { case EPrintPosSuperscript: DoAppendDescriptionL((*iStyleDescriptor)[EDesSuperscript]); break; case EPrintPosSubscript: DoAppendDescriptionL((*iStyleDescriptor)[EDesSubscript]); break; default: break; } } if (charMask.AttribIsSet(EAttFontUnderline)) { if (charFormat.iFontPresentation.iUnderline==EUnderlineOn) DoAppendDescriptionL((*iStyleDescriptor)[EDesUnderline]); } if (charMask.AttribIsSet(EAttFontStrikethrough)) { if (charFormat.iFontPresentation.iStrikethrough==EStrikethroughOn) DoAppendDescriptionL((*iStyleDescriptor)[EDesStrikethrough]); } } if (!paraMask.IsNull()) { AppendDescriptionL(EAttLeftMargin,paraMask); AppendDescriptionL(EAttRightMargin,paraMask); AppendDescriptionL(EAttIndent,paraMask); if (paraMask.AttribIsSet(EAttAlignment)) DoAppendDescriptionL((*iStyleDescriptor)[EDesLeftAlign+paraFormat->iHorizontalAlignment]); AppendDescriptionL(EAttLineSpacing,paraMask); AppendDescriptionL(EAttSpaceBefore,paraMask); AppendDescriptionL(EAttSpaceAfter,paraMask); AppendDescriptionL(EAttKeepTogether,paraMask); AppendDescriptionL(EAttKeepWithNext,paraMask); AppendDescriptionL(EAttStartNewPage,paraMask); AppendDescriptionL(EAttWidowOrphan,paraMask); AppendDescriptionL(EAttBorderMargin,paraMask); AppendDescriptionL(EAttTopBorder,*paraFormat,paraMask); AppendDescriptionL(EAttBottomBorder,*paraFormat,paraMask); AppendDescriptionL(EAttLeftBorder,*paraFormat,paraMask); AppendDescriptionL(EAttRightBorder,*paraFormat,paraMask); AppendDescriptionL(EAttBullet,paraMask); AppendDescriptionL(EAttTabStop,*paraFormat,paraMask); } CleanupStack::PopAndDestroy(); // paraFormat edwin->SetTextL(iCurrentDescription); delete iCurrentDescription; iCurrentDescription=NULL; DrawEdwinL(); }