Example #1
0
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();
	}
Example #2
0
void CWordTest::SetWrapL(CEikRichTextEditor* aEditor,TBool aWrap)
{
    CParaFormat format;
    format.iWrap = aWrap;
    TParaFormatMask mask;
    mask.SetAttrib(EAttWrap);
    aEditor->ApplyParaFormatL(&format,mask);
}
Example #3
0
/**
@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;
	}
void CHelpContainer::SetAlignment(CParaFormat::TAlignment aAlignment)
	{
	CParaFormat paraFormat;
	TParaFormatMask paraFormatMask;

	paraFormatMask.SetAttrib(EAttAlignment); // set the mask
	paraFormat.iHorizontalAlignment = aAlignment;

	iRtEd->ApplyParaFormatL(&paraFormat, 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
	}
/**
 * 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();
        }
    }
Example #7
0
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);
	//
	}