Exemplo n.º 1
0
void CWordAppUi::SetParaAlignmentL(TInt aIndex)
	{
	RTmParFormatLayer format;
	format.iMask.iFlags = 0;
	format.iMask.Set(TTmParFormatMask::EAlignment);
	switch(aIndex)
		{
		case 0:
		case EWordCmdAlignLeft:
			format.iFormat.iAlignment = RTmParFormat::EAlignNormal;
			break;
		case 1:
		case EWordCmdAlignCenter:	
			format.iFormat.iAlignment = RTmParFormat::EAlignCenter;
			break;
		case 2:
		case EWordCmdAlignRight:
			format.iFormat.iAlignment = RTmParFormat::EAlignReverse;
			break;
		case 3:
		case EWordCmdAlignJustify:
			format.iFormat.iAlignment = RTmParFormat::EAlignJustify;
			break;
		default:
			format.iFormat.iAlignment = RTmParFormat::EAlignNormal;
		}
	TCursorSelection sel = iRichEd->Selection();
	iRichEd->SetParFormatL(sel.LowerPos(),sel.Length(),format);
	UpdateAlignButtonL(format.iFormat.iAlignment);
	}
Exemplo n.º 2
0
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();
	}
Exemplo n.º 3
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();
	}
// ---------------------------------------------------------
// CMsgBodyControlEditor::InsertTextL
//
// Inserts text to the editor.
// ---------------------------------------------------------
//
void CMsgBodyControlEditor::InsertTextL( const TDesC& aText )
    {
    if ( iTextView )
        {
        TCursorSelection selection = iTextView->Selection();
        const TInt selLength = selection.Length();
        const TInt lower = selection.LowerPos();

        if ( selLength )
            {
            // 107-24185 : Emoticon support for SMS and MMS, symbian call
            InsertDeleteCharsL( lower, aText, selection );
            }
        else
            {
            InsertDeleteCharsL( selection.iCursorPos, aText, selection );
            }

        SetCursorPosL( lower + aText.Length(), EFalse );

        NotifyNewFormatL();
        }
    else
        {
        iText->InsertL( 0, aText );
        }
    }
Exemplo n.º 5
0
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);
	}
Exemplo n.º 6
0
void CWordTest::ToggleCaseL(CEikRichTextEditor* aEditor)
{
    TCursorSelection sel = aEditor->Selection();
    int start = sel.LowerPos();
    int end = start;
    TBool to_upper = TRUE;
    while (end < sel.HigherPos())
    {
        TPtrC text;
        TCharFormat f;
        aEditor->RichText()->GetChars(text,f,start);
        int length = text.Length();
        if (start + length > sel.HigherPos())
            length = sel.HigherPos() - start;
        end = start + length;
        if (start == sel.LowerPos() && end > start)
        {
            if (TChar(text[0]).IsUpper())
                to_upper = FALSE;
        }
        TText* p = (TText*)text.Ptr();
        TText* q = p + length;
        while (p < q)
        {
            if (to_upper)
                *p = (TText)(TChar(*p).GetUpperCase());
            else
                *p = (TText)(TChar(*p).GetLowerCase());
            p++;
        }

        start = end;
    }
    aEditor->TextView()->HandleRangeFormatChangeL(sel);
}
Exemplo n.º 7
0
TKeyResponse CWordAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
	{
	if (iRichEd->IsReadOnly())
		{
		iRichEd->CEikRichTextEditor::OfferKeyEventL(aKeyEvent, aType);
		return EKeyWasConsumed;
		}
	const TBool eventKey(aType == EEventKey);
	const TBool isEnter(aKeyEvent.iCode == EKeyEnter || aKeyEvent.iCode == EKeyLineFeed);
	const TCursorSelection selection = iRichEd->Selection();
	if (eventKey && (aKeyEvent.iModifiers & EModifierCtrl) && (aKeyEvent.iModifiers & EModifierFunc))
		{// Paragraph style hot key
		TChar key = ((aKeyEvent.iCode >= 1) && (aKeyEvent.iCode <= 26))
			? aKeyEvent.iCode + 'A' - 1	// an alphabetic key was pressed.
			: aKeyEvent.iCode;			// a non-alphabetic key was pressed
		if (ProcessStyleHotKeyL(key) == EKeyWasConsumed)
			return EKeyWasConsumed;
		}
	if (eventKey && isEnter && (aKeyEvent.iModifiers & EModifierCtrl))
		{// Insert a breaking character
		InsertCharacterL(CEditableText::EPageBreak);
		return EKeyWasConsumed;
		}

	if ((aKeyEvent.iCode==EKeySpace || isEnter) && iRichEd->CheckForObjectL())
		{
		return EKeyWasConsumed;
		}

	// Allow the test harness to apply a custom keyboard map.
	TChar c;
	TKeyResponse r = iTest->OfferKeyEventL(aKeyEvent,aType,c);
	if (r == EKeyWasConsumed)
		{
		if (c != 0xFFFF)
			InsertCharacterL(c);
		return EKeyWasConsumed;
		}

	/*
	Handle all non-system keycodes via the unified editing interface, (except for space and enter
	on an embedded object, which allow it to be edited).
	*/
	if (eventKey && (aKeyEvent.iCode < 0xF700 || aKeyEvent.iCode >= 0xF900))
		{
		if (aKeyEvent.iCode == EKeyBackspace)
			iRichEd->DeleteLeftL();
		else if (aKeyEvent.iCode == EKeyDelete)
			iRichEd->DeleteRightL();
		else if (aKeyEvent.iCode == EKeySpace && (aKeyEvent.iModifiers & EModifierShift))
			InsertCharacterL(CEditableText::ENonBreakingSpace);
		else if (isEnter)
			{
			InsertCharacterL((aKeyEvent.iModifiers & EModifierShift)?
				CEditableText::ELineBreak : CEditableText::EParagraphDelimiter);
			}
		else
			InsertCharacterL(aKeyEvent.iCode);
		return EKeyWasConsumed;
		}
	iRichEd->CEikRichTextEditor::OfferKeyEventL(aKeyEvent, aType);
	if (eventKey && (iEikonEnv->AppUiFactory()->ToolBar()->IsVisible() || iEikonEnv->AppUiFactory()->ToolBand()->IsVisible()))
		{
		if ((aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete) && selection.Length())
			iToolBarUpdate->Start(CWordToolBarUpdate::EFullUpdate);
		else if (isEnter && !(aKeyEvent.iModifiers & EModifierShift))
			iToolBarUpdate->Start(CWordToolBarUpdate::EFullUpdate);
		}
	return EKeyWasConsumed;
	}