os/textandloc/textrendering/word/SRC/WPAPPUI.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#include <s32mem.h>
sl@0
    20
sl@0
    21
#include <txtrich.h>
sl@0
    22
sl@0
    23
#include <frmprint.h>
sl@0
    24
sl@0
    25
#include <badesca.h>
sl@0
    26
sl@0
    27
#include <coedef.h>
sl@0
    28
#include <coeinput.h>
sl@0
    29
sl@0
    30
#include <prnsetup.h>
sl@0
    31
sl@0
    32
#include <techview/eikprtdg.h>
sl@0
    33
#include <techview/eikmenup.h>
sl@0
    34
#include <techview/eiktbar.h>
sl@0
    35
#include <techview/eikbtgpc.h>
sl@0
    36
#include <techview/eikclb.h>
sl@0
    37
#include <techview/eikon.rsg>
sl@0
    38
#include <eikon.mbg>
sl@0
    39
#include <techview/eiktxlbm.h>
sl@0
    40
sl@0
    41
#include "WPAPPUI.H"
sl@0
    42
#include "WPDIALGS.H"
sl@0
    43
#include "WPDOC.H"
sl@0
    44
#include "WPLBOX.H"
sl@0
    45
#include "WPSTYLE.H"
sl@0
    46
#include "WPDEF.H"
sl@0
    47
#include "WPTEST.H"
sl@0
    48
#include <word.rsg>
sl@0
    49
sl@0
    50
#include "WORD.HRH"
sl@0
    51
sl@0
    52
sl@0
    53
const TUid KUidSheet={0x10003A7D};
sl@0
    54
const TUid KUidPaintApp={0x1000007D};
sl@0
    55
// the next four are strictly temporary items!
sl@0
    56
_LIT(KSketchDllName,"PAINT.APP");
sl@0
    57
_LIT(KSheetDllName,"SHEET.APP");
sl@0
    58
sl@0
    59
CWordAppUi::CWordAppUi()
sl@0
    60
   	:iAlignment(RTmParFormat::EAlignNormal)
sl@0
    61
	{
sl@0
    62
	}
sl@0
    63
sl@0
    64
CWordAppUi::~CWordAppUi()
sl@0
    65
    {
sl@0
    66
	if (iDoorObserver)
sl@0
    67
		{
sl@0
    68
		MApaEmbeddedDocObserver::TExitMode exitMode=MApaEmbeddedDocObserver::EKeepChanges;
sl@0
    69
		if (!DocHasChanged())
sl@0
    70
			exitMode=MApaEmbeddedDocObserver::ENoChanges;
sl@0
    71
		if (Document()->Model()->Text()->DocumentLength()==0)
sl@0
    72
			exitMode=MApaEmbeddedDocObserver::EEmpty;
sl@0
    73
		iDoorObserver->NotifyExit(exitMode);
sl@0
    74
		}
sl@0
    75
	if (iRichEd)
sl@0
    76
		RemoveFromStack(iRichEd);
sl@0
    77
	delete iBullet;
sl@0
    78
	delete iToolBarUpdate;
sl@0
    79
	delete iRichEd;
sl@0
    80
	delete iTwipsList;
sl@0
    81
	delete iPopoutListBox;
sl@0
    82
	delete iConfirmationText;
sl@0
    83
	delete iTest;
sl@0
    84
	}
sl@0
    85
sl@0
    86
void CWordAppUi::ConstructL()
sl@0
    87
    {
sl@0
    88
	Document()->SetChanged(FALSE);
sl@0
    89
	//
sl@0
    90
	BaseConstructL();
sl@0
    91
	//
sl@0
    92
	iModel=Document()->Model();
sl@0
    93
	ResetPrint();  // initialise print related components
sl@0
    94
	CreateEdwinL();  // create & initialise edwin components (may use print data if in wysiwyg)
sl@0
    95
	UpdateToolbarsL();  // set the remainder components of the word view
sl@0
    96
	//
sl@0
    97
	iToolBarUpdate=CWordToolBarUpdate::NewL(*this);
sl@0
    98
	//
sl@0
    99
	iEikonEnv->AppUiFactory()->ToolBand()->ActivateL();
sl@0
   100
	iEikonEnv->AppUiFactory()->ToolBar()->ActivateL();
sl@0
   101
	iEikonEnv->AppUiFactory()->ToolBand()->DrawNow();
sl@0
   102
	iEikonEnv->AppUiFactory()->ToolBar()->DrawNow();
sl@0
   103
	iCoeEnv->WsSession().Flush();
sl@0
   104
	iConfirmationText = iEikonEnv->AllocReadResourceAsDes8L(R_WORD_CONFIRMATION_TEXTS);
sl@0
   105
	SetPaginationOutOfDate(TRUE);
sl@0
   106
	iRichEd->SetBookmark();
sl@0
   107
    }
sl@0
   108
sl@0
   109
TKeyResponse CWordAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
sl@0
   110
	{
sl@0
   111
	if (iRichEd->IsReadOnly())
sl@0
   112
		{
sl@0
   113
		iRichEd->CEikRichTextEditor::OfferKeyEventL(aKeyEvent, aType);
sl@0
   114
		return EKeyWasConsumed;
sl@0
   115
		}
sl@0
   116
	const TBool eventKey(aType == EEventKey);
sl@0
   117
	const TBool isEnter(aKeyEvent.iCode == EKeyEnter || aKeyEvent.iCode == EKeyLineFeed);
sl@0
   118
	const TCursorSelection selection = iRichEd->Selection();
sl@0
   119
	if (eventKey && (aKeyEvent.iModifiers & EModifierCtrl) && (aKeyEvent.iModifiers & EModifierFunc))
sl@0
   120
		{// Paragraph style hot key
sl@0
   121
		TChar key = ((aKeyEvent.iCode >= 1) && (aKeyEvent.iCode <= 26))
sl@0
   122
			? aKeyEvent.iCode + 'A' - 1	// an alphabetic key was pressed.
sl@0
   123
			: aKeyEvent.iCode;			// a non-alphabetic key was pressed
sl@0
   124
		if (ProcessStyleHotKeyL(key) == EKeyWasConsumed)
sl@0
   125
			return EKeyWasConsumed;
sl@0
   126
		}
sl@0
   127
	if (eventKey && isEnter && (aKeyEvent.iModifiers & EModifierCtrl))
sl@0
   128
		{// Insert a breaking character
sl@0
   129
		InsertCharacterL(CEditableText::EPageBreak);
sl@0
   130
		return EKeyWasConsumed;
sl@0
   131
		}
sl@0
   132
sl@0
   133
	if ((aKeyEvent.iCode==EKeySpace || isEnter) && iRichEd->CheckForObjectL())
sl@0
   134
		{
sl@0
   135
		return EKeyWasConsumed;
sl@0
   136
		}
sl@0
   137
sl@0
   138
	// Allow the test harness to apply a custom keyboard map.
sl@0
   139
	TChar c;
sl@0
   140
	TKeyResponse r = iTest->OfferKeyEventL(aKeyEvent,aType,c);
sl@0
   141
	if (r == EKeyWasConsumed)
sl@0
   142
		{
sl@0
   143
		if (c != 0xFFFF)
sl@0
   144
			InsertCharacterL(c);
sl@0
   145
		return EKeyWasConsumed;
sl@0
   146
		}
sl@0
   147
sl@0
   148
	/*
sl@0
   149
	Handle all non-system keycodes via the unified editing interface, (except for space and enter
sl@0
   150
	on an embedded object, which allow it to be edited).
sl@0
   151
	*/
sl@0
   152
	if (eventKey && (aKeyEvent.iCode < 0xF700 || aKeyEvent.iCode >= 0xF900))
sl@0
   153
		{
sl@0
   154
		if (aKeyEvent.iCode == EKeyBackspace)
sl@0
   155
			iRichEd->DeleteLeftL();
sl@0
   156
		else if (aKeyEvent.iCode == EKeyDelete)
sl@0
   157
			iRichEd->DeleteRightL();
sl@0
   158
		else if (aKeyEvent.iCode == EKeySpace && (aKeyEvent.iModifiers & EModifierShift))
sl@0
   159
			InsertCharacterL(CEditableText::ENonBreakingSpace);
sl@0
   160
		else if (isEnter)
sl@0
   161
			{
sl@0
   162
			InsertCharacterL((aKeyEvent.iModifiers & EModifierShift)?
sl@0
   163
				CEditableText::ELineBreak : CEditableText::EParagraphDelimiter);
sl@0
   164
			}
sl@0
   165
		else
sl@0
   166
			InsertCharacterL(aKeyEvent.iCode);
sl@0
   167
		return EKeyWasConsumed;
sl@0
   168
		}
sl@0
   169
	iRichEd->CEikRichTextEditor::OfferKeyEventL(aKeyEvent, aType);
sl@0
   170
	if (eventKey && (iEikonEnv->AppUiFactory()->ToolBar()->IsVisible() || iEikonEnv->AppUiFactory()->ToolBand()->IsVisible()))
sl@0
   171
		{
sl@0
   172
		if ((aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode == EKeyDelete) && selection.Length())
sl@0
   173
			iToolBarUpdate->Start(CWordToolBarUpdate::EFullUpdate);
sl@0
   174
		else if (isEnter && !(aKeyEvent.iModifiers & EModifierShift))
sl@0
   175
			iToolBarUpdate->Start(CWordToolBarUpdate::EFullUpdate);
sl@0
   176
		}
sl@0
   177
	return EKeyWasConsumed;
sl@0
   178
	}
sl@0
   179
sl@0
   180
TKeyResponse CWordAppUi::ProcessStyleHotKeyL(const TChar& aKey)
sl@0
   181
// Look up the specified key in the style short cut list.
sl@0
   182
// Apply the relevant style if found.
sl@0
   183
//
sl@0
   184
	{
sl@0
   185
	const CParagraphStyle* styleToApply=NULL;
sl@0
   186
	if (aKey==iModel->NormalStyleShortCut())
sl@0
   187
		styleToApply=REINTERPRET_CAST(const CParagraphStyle*,Text()->GlobalParaFormatLayer());
sl@0
   188
	else
sl@0
   189
		{
sl@0
   190
		const CStyleShortCutList* shortCutList=iModel->StyleShortCutList();
sl@0
   191
		const TInt count=(shortCutList) ? shortCutList->Count() : 0;
sl@0
   192
		TInt index=0;
sl@0
   193
		TBool matched=FALSE;
sl@0
   194
		while (index<count && !matched)
sl@0
   195
			{
sl@0
   196
			TChar match=(*shortCutList)[index];
sl@0
   197
			if (match==aKey)
sl@0
   198
				break;
sl@0
   199
			index++;
sl@0
   200
			}
sl@0
   201
		if (index>=count)
sl@0
   202
			return EKeyWasNotConsumed;  // checked all hotkeys in the list and not matched any of them.
sl@0
   203
		//there could be a shortcut that hasnt a style
sl@0
   204
		if ( index > iModel->StyleList()->Count() )
sl@0
   205
			return EKeyWasNotConsumed; 
sl@0
   206
		styleToApply=iModel->StyleList()->At(index).iStyle;
sl@0
   207
		}
sl@0
   208
	TCursorSelection selection=iRichEd->Selection();
sl@0
   209
	Text()->ApplyParagraphStyleL(*styleToApply,selection.LowerPos(),selection.Length(),KApplyParaStyleMode);
sl@0
   210
	ReformatDueToStateChangeL();
sl@0
   211
	iRichEd->UpdateScrollBarsL();
sl@0
   212
	return EKeyWasConsumed;
sl@0
   213
	}
sl@0
   214
sl@0
   215
sl@0
   216
void CWordAppUi::SetAndDrawFocus(TBool aFocus)
sl@0
   217
	{
sl@0
   218
	if (iRichEd)
sl@0
   219
		iRichEd->SetFocus(aFocus,EDrawNow);
sl@0
   220
	}
sl@0
   221
sl@0
   222
sl@0
   223
TCoeInputCapabilities CWordAppUi::InputCapabilities() const
sl@0
   224
	{
sl@0
   225
	TCoeInputCapabilities inputCapabilities=CEikAppUi::InputCapabilities();
sl@0
   226
	if ((iRichEd!=NULL) && iRichEd->IsFocused() && !iRichEd->IsReadOnly())
sl@0
   227
		{
sl@0
   228
		inputCapabilities.MergeWith(iRichEd->InputCapabilities());
sl@0
   229
		}
sl@0
   230
	return inputCapabilities;
sl@0
   231
	}
sl@0
   232
sl@0
   233
TBool CWordAppUi::DocHasChanged() const
sl@0
   234
	{
sl@0
   235
	if (iDocument->HasChanged())
sl@0
   236
		return ETrue;
sl@0
   237
	if (iRichEd->IsAtBookmark())
sl@0
   238
		return EFalse;
sl@0
   239
	return ETrue;
sl@0
   240
	}
sl@0
   241
sl@0
   242
void CWordAppUi::HandleCommandL(TInt aCommand)
sl@0
   243
	{
sl@0
   244
	switch (aCommand)
sl@0
   245
		{
sl@0
   246
	case EEikCmdExit:
sl@0
   247
		GetUiData(Document()->UiData());
sl@0
   248
		if (DocHasChanged() && !iContainerAppUi)
sl@0
   249
			CmdFileSaveL();
sl@0
   250
		Exit();
sl@0
   251
		break;
sl@0
   252
	case EEikCmdFileNew:
sl@0
   253
	case EEikCmdFileOpen:
sl@0
   254
	case EEikCmdFileSave:
sl@0
   255
	case EEikCmdFileSaveAs:
sl@0
   256
	case EEikCmdFileRevert:
sl@0
   257
	case EWordCmdFileSaveAsTemplate:
sl@0
   258
	case EWordCmdFileDeleteTemplate:
sl@0
   259
		if (iContainerAppUi)
sl@0
   260
			break;
sl@0
   261
		else
sl@0
   262
			{
sl@0
   263
			switch (aCommand)
sl@0
   264
				{
sl@0
   265
			case (EEikCmdFileNew):
sl@0
   266
				CmdFileNewL();
sl@0
   267
		        break;
sl@0
   268
			case (EEikCmdFileOpen):
sl@0
   269
				CmdFileOpenL();
sl@0
   270
				break;
sl@0
   271
			case (EEikCmdFileSave):
sl@0
   272
				CmdFileSaveL();
sl@0
   273
				break;
sl@0
   274
			case (EEikCmdFileSaveAs):
sl@0
   275
		        CmdFileSaveAsL();
sl@0
   276
			    break;
sl@0
   277
			case (EEikCmdFileRevert):
sl@0
   278
		        CmdFileRevertL();
sl@0
   279
			    break;
sl@0
   280
			case (EWordCmdFileSaveAsTemplate):
sl@0
   281
				CmdFileSaveAsTemplateL();
sl@0
   282
				break;
sl@0
   283
			case (EWordCmdFileDeleteTemplate):
sl@0
   284
				CmdFileDeleteTemplateL();
sl@0
   285
				break;
sl@0
   286
				}
sl@0
   287
			}
sl@0
   288
		break;
sl@0
   289
	case EEikCmdEditCopy:
sl@0
   290
		iRichEd->ClipboardCopyL();
sl@0
   291
		break;
sl@0
   292
	case EEikCmdFileExport:
sl@0
   293
		CmdFileTextExportL();
sl@0
   294
		break;
sl@0
   295
	case EWordCmdPageSetup:
sl@0
   296
		RunPageSetupDialogL();
sl@0
   297
		break;
sl@0
   298
	case EEikCmdPrintPaginate:
sl@0
   299
		RunPaginationDialogL();
sl@0
   300
		break;
sl@0
   301
	case EEikCmdPrintPrint:
sl@0
   302
	case EEikCmdPrintSetup:
sl@0
   303
	case EEikCmdPrintPreview:										    
sl@0
   304
	case EWordCmdGoTo:	
sl@0
   305
		{
sl@0
   306
		TBool cancel=FALSE;
sl@0
   307
 		if (PaginationOutOfDate())
sl@0
   308
			cancel=RunPaginationDialogL();
sl@0
   309
		if (cancel)
sl@0
   310
			break;
sl@0
   311
		switch (aCommand)
sl@0
   312
			{
sl@0
   313
			case EEikCmdPrintSetup:
sl@0
   314
				{
sl@0
   315
				TInt pages=iModel->PageTable()->Count();
sl@0
   316
				RunPrintRangeDialogL(iPrintSetup,pages);
sl@0
   317
				break;
sl@0
   318
				}
sl@0
   319
			case EEikCmdPrintPrint:
sl@0
   320
				RunPrintDialogL();
sl@0
   321
				break;
sl@0
   322
			case EEikCmdPrintPreview:
sl@0
   323
				RunPreviewDialogL();
sl@0
   324
				break;
sl@0
   325
			case EWordCmdGoTo:
sl@0
   326
				RunGoToDialogL();
sl@0
   327
				break;
sl@0
   328
			}
sl@0
   329
		break;
sl@0
   330
		}
sl@0
   331
	case EEikCmdSearchFind:
sl@0
   332
		iRichEd->RunFindDialogL();
sl@0
   333
		break;
sl@0
   334
	case EEikCmdSearchFindAgain:
sl@0
   335
		iRichEd->RunFindAgainDialogL();
sl@0
   336
		break;
sl@0
   337
	case EEikCmdEditSelectAll:
sl@0
   338
		{
sl@0
   339
		const TInt docLength=iRichEd->TextLength();
sl@0
   340
		if (docLength)
sl@0
   341
			iRichEd->SetSelectionL(docLength,0);
sl@0
   342
		break;
sl@0
   343
		}
sl@0
   344
	case EWordCmdReEditObject:
sl@0
   345
		iRichEd->ReEditObjectL();
sl@0
   346
		break;
sl@0
   347
	case EWordCmdToolbar:
sl@0
   348
	case EWordCmdToolband:
sl@0
   349
		UpdateToolBarAndBandL(aCommand);
sl@0
   350
		break;
sl@0
   351
	case EWordCmdWrapToScreen:
sl@0
   352
		CmdWrapToScreenL();
sl@0
   353
		break;
sl@0
   354
	case EWordCmdViewPreferences:
sl@0
   355
		RunViewPreferencesDialogL();
sl@0
   356
		break;
sl@0
   357
	case EWordCmdCount:
sl@0
   358
		iEikonEnv->InfoMsg(R_WORD_NO_WORDS,(iRichEd->CountWords()));	
sl@0
   359
		break;
sl@0
   360
	case EEikCmdZoomIn:
sl@0
   361
	case EEikCmdZoomOut:
sl@0
   362
		ZoomL(aCommand);
sl@0
   363
		break;
sl@0
   364
	case EWordCmdZoomSet:
sl@0
   365
		{
sl@0
   366
		TInt zoomFactor=iAppZoom.ZoomFactor();
sl@0
   367
		CEikDialog* dialog=new(ELeave) CWordTempManualZoomDialog(zoomFactor);
sl@0
   368
		if (dialog->ExecuteLD(R_WORD_DIALOG_ZOOM_SET))
sl@0
   369
			{
sl@0
   370
			iAppZoom.SetZoomFactor(zoomFactor);
sl@0
   371
			CFbsBitmap* lineCursor=iEikonEnv->CreateBitmapL(TPtrC(),EMbmEikonLncusr1);
sl@0
   372
			iRichEd->SetLineCursorBitmapL(lineCursor);
sl@0
   373
			iRichEd->NotifyNewFormatL();
sl@0
   374
			iRichEd->UpdateScrollBarsL();
sl@0
   375
			}
sl@0
   376
		break;
sl@0
   377
		}
sl@0
   378
	case EWordCmdOutline:
sl@0
   379
		RunOutlineDialogL();
sl@0
   380
		break;
sl@0
   381
	//
sl@0
   382
	// State changing commands
sl@0
   383
	// disallow when read-only
sl@0
   384
	//
sl@0
   385
	// FILE HANDLING
sl@0
   386
	case EEikCmdFileImport:
sl@0
   387
	case EWordCmdHtmlImport:
sl@0
   388
	//
sl@0
   389
	// CLIPBOARDING
sl@0
   390
	case EEikCmdEditCut:
sl@0
   391
	case EEikCmdEditPaste:
sl@0
   392
	//
sl@0
   393
	// CHARACTER FORMATTING
sl@0
   394
	case EEikCmdFontBold:
sl@0
   395
	case EEikCmdFontItalic:
sl@0
   396
	case EEikCmdFontUnderline:
sl@0
   397
	case EEikCmdFontChange:
sl@0
   398
	case EEikCmdInsertSymbol:
sl@0
   399
	//
sl@0
   400
	// PARAGRAPH FORMATTING
sl@0
   401
	case EEikCmdParaBorder:
sl@0
   402
	case EEikCmdParaSpacing:
sl@0
   403
	case EEikCmdParaIndent:
sl@0
   404
	case EEikCmdParaTabs:
sl@0
   405
	case EEikCmdParaAlign:
sl@0
   406
	case EWordCmdAlignLeft:
sl@0
   407
	case EWordCmdAlignRight:
sl@0
   408
	case EWordCmdAlignCenter:
sl@0
   409
	case EWordCmdAlignJustify:
sl@0
   410
	case EWordCmdFormatBullet:
sl@0
   411
	//
sl@0
   412
	// EDIT
sl@0
   413
	case EEikCmdSearchReplace:
sl@0
   414
	case EEikCmdEditPictureFormat:
sl@0
   415
	case EWordCmdInsertSketch:
sl@0
   416
	case EWordCmdInsertSheet:
sl@0
   417
	case EWordCmdInsertObject:
sl@0
   418
	case EWordCmdInsertPageBreak:
sl@0
   419
	case EWordCmdInsertLineBreak:
sl@0
   420
	case EEikCmdEditUndo:
sl@0
   421
	case EEikCmdEditRedo:
sl@0
   422
	//
sl@0
   423
	// TOOLS
sl@0
   424
	case EWordCmdObjectPreferences:
sl@0
   425
	//
sl@0
   426
	// TOP TOOLBAND
sl@0
   427
	case EWordButtonStyle:
sl@0
   428
	case EWordButtonFont:
sl@0
   429
	case EWordButtonFontSize:		
sl@0
   430
	case EWordButtonAlign:
sl@0
   431
	case EWordButtonBorders:
sl@0
   432
	case EWordCmdInsertBullet:
sl@0
   433
	case EWordButtonBullets:
sl@0
   434
	//
sl@0
   435
	// STYLES
sl@0
   436
	case EWordCmdRevertToStylePara:
sl@0
   437
	case EWordCmdRevertToStyleChar:
sl@0
   438
	case EWordCmdStyleGallery:
sl@0
   439
		{
sl@0
   440
		const TBool readOnly=(iContainerAppUi)? iEmbeddedAndReadOnly : !(iDocument->AppFileMode()&EFileWrite);
sl@0
   441
		if (readOnly)
sl@0
   442
			{
sl@0
   443
			iEikonEnv->InfoMsg(R_WORD_FILE_READ_ONLY);  // feedback this is a readonly file
sl@0
   444
			if (aCommand==EEikCmdFontBold || aCommand==EEikCmdFontItalic || aCommand==EEikCmdFontUnderline)
sl@0
   445
				UpdateCharFormatButtonsL();  // undo the pressing of the emphasis buttons.
sl@0
   446
			break;
sl@0
   447
			}
sl@0
   448
		switch (aCommand)
sl@0
   449
			{
sl@0
   450
		//
sl@0
   451
		// FILE HANDLING
sl@0
   452
			case EEikCmdFileImport:
sl@0
   453
				CmdFileTextImportL();
sl@0
   454
				break;
sl@0
   455
			case EWordCmdHtmlImport:
sl@0
   456
				CmdFileHtmlImportL();
sl@0
   457
				break;			
sl@0
   458
		//
sl@0
   459
		// CLIPBOARDING
sl@0
   460
			case EEikCmdEditCut:
sl@0
   461
				iRichEd->ClipboardCutL();
sl@0
   462
				UpdateToolbandButtonsL();
sl@0
   463
				break;
sl@0
   464
			case EEikCmdEditPaste:
sl@0
   465
				if (KErrNotFound == iRichEd->ClipboardPasteL())
sl@0
   466
					iEikonEnv->InfoMsg(R_WORD_NO_TEXT_TO_PASTE);
sl@0
   467
				else
sl@0
   468
					UpdateToolbandButtonsL();
sl@0
   469
				break;
sl@0
   470
		//
sl@0
   471
		// CHARACTER FORMATTING
sl@0
   472
			case EEikCmdFontBold:
sl@0
   473
				iRichEd->BoldItalicUnderlineEventL(CEikGlobalTextEditor::EBold); 
sl@0
   474
				break;
sl@0
   475
			case EEikCmdFontItalic:
sl@0
   476
				iRichEd->BoldItalicUnderlineEventL(CEikGlobalTextEditor::EItalic); 
sl@0
   477
				break;
sl@0
   478
			case EEikCmdFontUnderline:
sl@0
   479
				iRichEd->BoldItalicUnderlineEventL(CEikGlobalTextEditor::EUnderline); 
sl@0
   480
				break;
sl@0
   481
			case EEikCmdFontChange:
sl@0
   482
				iRichEd->RunFontDialogL(EGulNoSymbolFonts, iCoeEnv->ScreenDevice());
sl@0
   483
				UpdateCharFormatButtonsL();
sl@0
   484
				break;
sl@0
   485
			case EEikCmdInsertSymbol:
sl@0
   486
				iRichEd->RunCharMapDialogL();
sl@0
   487
				break;
sl@0
   488
		//
sl@0
   489
		// PARAGRAPH FORMATTING
sl@0
   490
			case EEikCmdParaBorder:
sl@0
   491
			case EEikCmdParaSpacing:
sl@0
   492
				iRichEd->RunParaDialogsL(aCommand);
sl@0
   493
				break;
sl@0
   494
			case EEikCmdParaIndent:
sl@0
   495
			case EEikCmdParaTabs:
sl@0
   496
				{
sl@0
   497
				TPageSpec pageSpec=iPrintSetup->PrinterDevice()->CurrentPageSpecInTwips();
sl@0
   498
				TInt width=pageSpec.iPortraitPageSize.iWidth;
sl@0
   499
				if (pageSpec.iOrientation==TPageSpec::ELandscape)
sl@0
   500
					width=pageSpec.iPortraitPageSize.iHeight;
sl@0
   501
				width-=(iPrintSetup->iPageMarginsInTwips.iMargins.iLeft+iPrintSetup->iPageMarginsInTwips.iMargins.iRight);
sl@0
   502
				if (aCommand==EEikCmdParaIndent)
sl@0
   503
					iRichEd->RunIndentsDialogL(width);
sl@0
   504
				else
sl@0
   505
					iRichEd->RunTabsDialogL(width);
sl@0
   506
				break;
sl@0
   507
				}
sl@0
   508
			case EEikCmdParaAlign:
sl@0
   509
				CmdChangeAlignmentL();
sl@0
   510
				break;
sl@0
   511
			case EWordCmdAlignLeft:
sl@0
   512
			case EWordCmdAlignRight:
sl@0
   513
			case EWordCmdAlignCenter:
sl@0
   514
			case EWordCmdAlignJustify:
sl@0
   515
				{
sl@0
   516
				SetParaAlignmentL(aCommand);	
sl@0
   517
				RTmParFormat::TAlignment alignment = RTmParFormat::EAlignNormal;
sl@0
   518
				switch (aCommand)
sl@0
   519
					{
sl@0
   520
					case EWordCmdAlignLeft:
sl@0
   521
						alignment = RTmParFormat::EAlignNormal;
sl@0
   522
						break;
sl@0
   523
					case EWordCmdAlignRight:
sl@0
   524
						alignment = RTmParFormat::EAlignReverse;
sl@0
   525
						break;
sl@0
   526
					case EWordCmdAlignCenter:
sl@0
   527
						alignment = RTmParFormat::EAlignCenter;
sl@0
   528
						break;
sl@0
   529
					case EWordCmdAlignJustify:
sl@0
   530
						alignment = RTmParFormat::EAlignJustify;
sl@0
   531
						break;
sl@0
   532
					}
sl@0
   533
				UpdateAlignButtonL(alignment);
sl@0
   534
				break;
sl@0
   535
				}
sl@0
   536
			case EWordCmdFormatBullet:
sl@0
   537
				RunSelectBulletDialogL();
sl@0
   538
				break;
sl@0
   539
		//
sl@0
   540
		// EDIT
sl@0
   541
			case EEikCmdSearchReplace:
sl@0
   542
				iRichEd->RunReplaceDialogL();
sl@0
   543
				break;
sl@0
   544
			case EEikCmdEditPictureFormat:
sl@0
   545
				iRichEd->EditPictureFormatL();
sl@0
   546
				break;
sl@0
   547
			case EWordCmdInsertSketch:
sl@0
   548
				iRichEd->InsertObjectL(KSketchDllName,KUidPaintApp,(SketchAsGlass())?CEikRichTextEditor::EGlassIfPossible : CEikRichTextEditor::EAlwaysIconic);
sl@0
   549
				break;
sl@0
   550
			case EWordCmdInsertSheet:
sl@0
   551
				iRichEd->InsertObjectL(KSheetDllName,KUidSheet,(GraphAsGlass())?CEikRichTextEditor::EGlassIfPossible : CEikRichTextEditor::EAlwaysIconic);
sl@0
   552
				break;
sl@0
   553
			case EWordCmdInsertObject:
sl@0
   554
				iRichEd->InsertObjectL(CEikRichTextEditor::EGlassIfPossible);
sl@0
   555
				break;
sl@0
   556
			case EWordCmdInsertPageBreak:
sl@0
   557
			case EWordCmdInsertLineBreak:
sl@0
   558
				InsertCharacterL((aCommand==EWordCmdInsertPageBreak)
sl@0
   559
					? CEditableText::EPageBreak
sl@0
   560
					: CEditableText::ELineBreak);
sl@0
   561
				break;
sl@0
   562
			case EEikCmdEditUndo:
sl@0
   563
				iRichEd->UndoL();
sl@0
   564
				break;
sl@0
   565
			case EEikCmdEditRedo:
sl@0
   566
				iRichEd->RedoL();
sl@0
   567
				break;
sl@0
   568
		//
sl@0
   569
		// TOOLS
sl@0
   570
			case EWordCmdObjectPreferences:
sl@0
   571
				RunObjectPreferencesDialogL();
sl@0
   572
				break;
sl@0
   573
		//
sl@0
   574
		// TOP TOOLBAND
sl@0
   575
			case EWordButtonStyle:
sl@0
   576
				LaunchStylesPopupL();
sl@0
   577
				break;
sl@0
   578
			case EWordButtonFont:
sl@0
   579
				LaunchFontsPopupL();
sl@0
   580
				break;
sl@0
   581
			case EWordButtonFontSize:		
sl@0
   582
				LaunchFontHeightsPopupL();
sl@0
   583
				break; 
sl@0
   584
			case EWordButtonAlign:
sl@0
   585
				LaunchAlignPopupL();
sl@0
   586
				break;
sl@0
   587
			case EWordButtonBorders:
sl@0
   588
				LaunchBordersPopupL();
sl@0
   589
				break;
sl@0
   590
			case EWordCmdInsertBullet:
sl@0
   591
				{
sl@0
   592
				if (REINTERPRET_CAST(CEikButtonBase*, iEikonEnv->AppUiFactory()->ToolBand()->ControlById(EWordButtonBullets))->State() == CEikButtonBase::EClear)
sl@0
   593
					UpdateToolBandButton(EWordButtonBullets,CEikButtonBase::ESet); 
sl@0
   594
				else
sl@0
   595
					UpdateToolBandButton(EWordButtonBullets,CEikButtonBase::EClear);
sl@0
   596
				}  // drops into next case with a purpose
sl@0
   597
			case EWordButtonBullets:
sl@0
   598
				SetBulletL();
sl@0
   599
				break;
sl@0
   600
		//
sl@0
   601
		// STYLES
sl@0
   602
			case EWordCmdRevertToStylePara:
sl@0
   603
				{
sl@0
   604
				TCursorSelection selection=iRichEd->Selection();
sl@0
   605
				Text()->RemoveSpecificParaFormatL(selection.LowerPos(),selection.Length());
sl@0
   606
				ReformatDueToStateChangeL();
sl@0
   607
				break;
sl@0
   608
				}
sl@0
   609
			case EWordCmdRevertToStyleChar:
sl@0
   610
				{
sl@0
   611
				TCursorSelection selection=iRichEd->Selection();
sl@0
   612
				Text()->RemoveSpecificCharFormatL(selection.LowerPos(),selection.Length());
sl@0
   613
				ReformatDueToStateChangeL();
sl@0
   614
				break;
sl@0
   615
				}
sl@0
   616
			case EWordCmdStyleGallery:
sl@0
   617
				{
sl@0
   618
				TBool close=FALSE;
sl@0
   619
				CRichText* originalText=Text();
sl@0
   620
				const TCursorSelection selection=iRichEd->Selection();
sl@0
   621
				TChar& normalStyleShortCut=iModel->NormalStyleShortCut();
sl@0
   622
				TWordStyleGalleryData data(*originalText,*iModel->StyleList(),*iModel->StyleShortCutList(),
sl@0
   623
					normalStyleShortCut,*iPrintSetup,close,selection,*iRichEd);
sl@0
   624
sl@0
   625
				CEikDialog* dialog=CWordStyleGallery::NewL(data);
sl@0
   626
				dialog->ExecuteLD(R_WORD_DIALOG_STYLE_GALLERY);
sl@0
   627
				if (!close)
sl@0
   628
					break;
sl@0
   629
				ReformatDueToStateChangeL();
sl@0
   630
				SetDocChanged();
sl@0
   631
				break;
sl@0
   632
				}
sl@0
   633
			}
sl@0
   634
sl@0
   635
		break;
sl@0
   636
		}
sl@0
   637
sl@0
   638
		// test commands
sl@0
   639
		case EWordCmdHighlight:
sl@0
   640
			iRichEd->ToggleHighlightL(TTmCharFormat::EBackground);
sl@0
   641
			break;
sl@0
   642
		case EWordCmdShadow:
sl@0
   643
			iRichEd->ToggleHighlightL(TTmCharFormat::EShadow);
sl@0
   644
			break;
sl@0
   645
		case EWordCmdCustomHighlight:
sl@0
   646
			iRichEd->ToggleHighlightL((TUint)TFontPresentation::EFontHighlightFirstCustomStyle << TTmCharFormat::EUserDefinedShift);
sl@0
   647
			break;
sl@0
   648
		case EWordCmdStandardKeyboard:
sl@0
   649
			iTest->SetKeyboardL(CWordTest::EStandardKeyboard);
sl@0
   650
			break;
sl@0
   651
		case EWordCmdArabicKeyboard:
sl@0
   652
			iTest->SetKeyboardL(CWordTest::EArabicKeyboard);
sl@0
   653
			break;
sl@0
   654
		case EWordCmdGreekKeyboard:
sl@0
   655
			iTest->SetKeyboardL(CWordTest::EGreekKeyboard);
sl@0
   656
			break;
sl@0
   657
		case EWordCmdRussianKeyboard:
sl@0
   658
			iTest->SetKeyboardL(CWordTest::ERussianKeyboard);
sl@0
   659
			break;
sl@0
   660
		case EWordCmdChineseOn:
sl@0
   661
		    {
sl@0
   662
			const TUid KUidTFepChinese = { 0x1028716D };
sl@0
   663
			iEikonEnv->InstallFepL(KUidTFepChinese);
sl@0
   664
		    }
sl@0
   665
		break;
sl@0
   666
		case EWordCmdChineseOff:
sl@0
   667
			iEikonEnv->InstallFepL(KNullUid);			
sl@0
   668
			break;	
sl@0
   669
		case EWordCmdRuledPaper:
sl@0
   670
			iTest->SetRuledPaperL(iRichEd,!iTest->RuledPaper());
sl@0
   671
			break;
sl@0
   672
		case EWordCmdBackgroundBitmap:
sl@0
   673
			iTest->SetBackgroundBitmapL(iRichEd,!iTest->BackgroundBitmap());
sl@0
   674
			break;
sl@0
   675
		case EWordCmdUpperCase:
sl@0
   676
			iTest->ToggleCaseL(iRichEd);
sl@0
   677
			break;
sl@0
   678
		case EWordCmdBenchmark:
sl@0
   679
			iTest->BenchmarkL();
sl@0
   680
			break;
sl@0
   681
		case EWordCmdTruncateWithEllipsis:
sl@0
   682
			iTest->SetTruncateWithEllipsisL(iRichEd,!iTest->TruncateWithEllipsis());
sl@0
   683
			break;
sl@0
   684
		case EWordCmdPictureAlignTop:
sl@0
   685
			iTest->SetPictureAlignmentL(iRichEd,TFontPresentation::EAlignTop);
sl@0
   686
			break;
sl@0
   687
		case EWordCmdPictureAlignBottom:
sl@0
   688
			iTest->SetPictureAlignmentL(iRichEd,TFontPresentation::EAlignBottom);
sl@0
   689
			break;
sl@0
   690
		case EWordCmdPictureAlignCenter:
sl@0
   691
			iTest->SetPictureAlignmentL(iRichEd,TFontPresentation::EAlignCentered);
sl@0
   692
			break;
sl@0
   693
		case EWordCmdPictureAlignBaseline:
sl@0
   694
			iTest->SetPictureAlignmentL(iRichEd,TFontPresentation::EAlignBaseLine);
sl@0
   695
			break;
sl@0
   696
		case EWordCmdWrapOn:
sl@0
   697
			iTest->SetWrapL(iRichEd,TRUE);
sl@0
   698
			break;
sl@0
   699
		case EWordCmdWrapOff:
sl@0
   700
			iTest->SetWrapL(iRichEd,FALSE);
sl@0
   701
			break;
sl@0
   702
		case EWordCmdInsertPicture:
sl@0
   703
			{
sl@0
   704
			iTest->InsertPictureL(iRichEd);
sl@0
   705
			Document()->SetChanged(ETrue);
sl@0
   706
			break;	
sl@0
   707
			}		
sl@0
   708
		case EWordCmdCursorStyleFlash:
sl@0
   709
			iTest->ToggleCursorFlash();
sl@0
   710
			break;
sl@0
   711
		case EWordCmdCursorStyleVertical:
sl@0
   712
			iTest->SetCursorPlacement(ECursorVertical);
sl@0
   713
			break;
sl@0
   714
		case EWordCmdCursorStyleUnderlineNext:
sl@0
   715
			iTest->SetCursorPlacement(ECursorUnderlineNext);
sl@0
   716
			break;
sl@0
   717
		case EWordCmdCursorStyleUnderlinePrev:
sl@0
   718
			iTest->SetCursorPlacement(ECursorUnderlinePrev);
sl@0
   719
			break;
sl@0
   720
		case EWordCmdCursorStyleHeavy:
sl@0
   721
			iTest->SetCursorWeight(iTest->CursorWeight() == 3 ? 1 : 3);
sl@0
   722
			break;
sl@0
   723
		case EWordCmdCursorStyleRed:
sl@0
   724
			iTest->SetCursorXorColor(iTest->CursorXorColor() == KRgbWhite ? KRgbCyan : KRgbWhite);
sl@0
   725
			break;
sl@0
   726
		case EWordCmdUndoTestNotUndoable:
sl@0
   727
			iRichEd->TestRunNotUndoableCommandL();
sl@0
   728
			break;
sl@0
   729
		case EWordCmdPositioningHintNeutral:
sl@0
   730
			iTest->SetCursorPositioningHintL(TCursorPosition::EPosHintUndefined);
sl@0
   731
			break;
sl@0
   732
		case EWordCmdPositioningHintInsertLeftToRight:
sl@0
   733
			iTest->SetCursorPositioningHintL(TCursorPosition::EInsertStrongL2R);
sl@0
   734
			break;
sl@0
   735
		case EWordCmdPositioningHintInsertRightToLeft:
sl@0
   736
			iTest->SetCursorPositioningHintL(TCursorPosition::EInsertStrongR2L);
sl@0
   737
			break;
sl@0
   738
		case EWordCmdSelectionHighlightNormal:
sl@0
   739
			iRichEd->TextView()->SetSelectionVisibilityL(EFalse);
sl@0
   740
			iTest->SetSelectionHighlightStyle(0);
sl@0
   741
			iRichEd->TextView()->SetSelectionVisibilityL(ETrue);
sl@0
   742
			break;
sl@0
   743
		case EWordCmdSelectionHighlightCustom1:
sl@0
   744
			iRichEd->TextView()->SetSelectionVisibilityL(EFalse);
sl@0
   745
			iTest->SetSelectionHighlightStyle(1);
sl@0
   746
			iRichEd->TextView()->SetSelectionVisibilityL(ETrue);
sl@0
   747
			break;
sl@0
   748
		case EWordCmdSelectionHighlightCustom2:
sl@0
   749
			iRichEd->TextView()->SetSelectionVisibilityL(EFalse);
sl@0
   750
			iTest->SetSelectionHighlightStyle(2);
sl@0
   751
			iRichEd->TextView()->SetSelectionVisibilityL(ETrue);
sl@0
   752
			break;
sl@0
   753
		}
sl@0
   754
	}
sl@0
   755
sl@0
   756
void CWordAppUi::DynInitMenuPaneL(TInt aMenuId,CEikMenuPane* aMenuPane)
sl@0
   757
	{
sl@0
   758
	TBool readOnly=iRichEd->IsReadOnly();
sl@0
   759
	switch (aMenuId)
sl@0
   760
		{
sl@0
   761
	//
sl@0
   762
	//
sl@0
   763
	case R_WORD_FILE_MENU:
sl@0
   764
		{
sl@0
   765
		if (iContainerAppUi)
sl@0
   766
			{
sl@0
   767
			aMenuPane->DeleteMenuItem(EEikCmdFileNew);
sl@0
   768
			aMenuPane->DeleteMenuItem(EEikCmdFileOpen);
sl@0
   769
			}
sl@0
   770
		break;
sl@0
   771
		}
sl@0
   772
	//
sl@0
   773
	//
sl@0
   774
	case R_WORD_FILEOPTIONS_MENU:
sl@0
   775
		{
sl@0
   776
		if (iContainerAppUi)
sl@0
   777
			{
sl@0
   778
			aMenuPane->DeleteMenuItem(EEikCmdFileSave);
sl@0
   779
			aMenuPane->DeleteMenuItem(EEikCmdFileSaveAs);
sl@0
   780
			aMenuPane->DeleteMenuItem(EEikCmdFileRevert);
sl@0
   781
			aMenuPane->DeleteMenuItem(EWordCmdFileSaveAsTemplate);
sl@0
   782
			aMenuPane->DeleteMenuItem(EWordCmdFileDeleteTemplate);
sl@0
   783
			}
sl@0
   784
		else if (readOnly)
sl@0
   785
			{
sl@0
   786
			aMenuPane->SetItemDimmed(EEikCmdFileSave,TRUE);
sl@0
   787
			aMenuPane->SetItemDimmed(EEikCmdFileRevert,TRUE);
sl@0
   788
			}
sl@0
   789
		if (readOnly)
sl@0
   790
			{
sl@0
   791
			aMenuPane->SetItemDimmed(EEikCmdFileImport,TRUE);
sl@0
   792
			aMenuPane->SetItemDimmed(EWordCmdHtmlImport,ETrue);
sl@0
   793
			}
sl@0
   794
		break;
sl@0
   795
		}
sl@0
   796
	//
sl@0
   797
	//
sl@0
   798
	case R_WORD_EDIT_MENU:
sl@0
   799
		{// read-only dependancies
sl@0
   800
		if (readOnly || (!iRichEd->CanUndo()) )
sl@0
   801
			aMenuPane->SetItemDimmed(EEikCmdEditUndo,TRUE);
sl@0
   802
		if (readOnly || (!iRichEd->CanRedo()) )
sl@0
   803
			aMenuPane->SetItemDimmed(EEikCmdEditRedo,TRUE);
sl@0
   804
		TInt selection=iRichEd->Selection().Length();
sl@0
   805
		if (selection==0)
sl@0
   806
			aMenuPane->SetItemDimmed(EEikCmdEditCopy,TRUE);
sl@0
   807
		if (readOnly || selection==0)
sl@0
   808
			aMenuPane->SetItemDimmed(EEikCmdEditCut,TRUE);
sl@0
   809
		if (readOnly)
sl@0
   810
			aMenuPane->SetItemDimmed(EEikCmdEditPaste,TRUE);
sl@0
   811
		break;
sl@0
   812
		}
sl@0
   813
	//
sl@0
   814
	//
sl@0
   815
	case R_WORD_EDITFIND_MENU:
sl@0
   816
		{
sl@0
   817
		TInt documentLength=iRichEd->TextLength();
sl@0
   818
		if (documentLength==0)
sl@0
   819
			{
sl@0
   820
			aMenuPane->SetItemDimmed(EEikCmdSearchFind,TRUE);
sl@0
   821
			aMenuPane->SetItemDimmed(EEikCmdSearchFindAgain,TRUE);
sl@0
   822
			aMenuPane->SetItemDimmed(EWordCmdGoTo,TRUE);
sl@0
   823
			}
sl@0
   824
		if (documentLength==0 || readOnly)
sl@0
   825
			aMenuPane->SetItemDimmed(EEikCmdSearchReplace,TRUE);
sl@0
   826
		break;
sl@0
   827
		}
sl@0
   828
	//
sl@0
   829
	//
sl@0
   830
	case R_WORD_EDITOPTIONS_MENU:
sl@0
   831
		if (readOnly)
sl@0
   832
			aMenuPane->SetItemDimmed(EEikCmdEditPictureFormat,TRUE);
sl@0
   833
		break;
sl@0
   834
	//
sl@0
   835
	//
sl@0
   836
	case R_WORD_VIEW_MENU:
sl@0
   837
		{// No read-only dependant menu options here
sl@0
   838
		if (!WysiwygModeIsSet())
sl@0
   839
			aMenuPane->SetItemButtonState(EWordCmdWrapToScreen, EEikMenuItemSymbolOn);
sl@0
   840
		if (iEikonEnv->AppUiFactory()->ToolBand()->IsVisible())
sl@0
   841
			aMenuPane->SetItemButtonState(EWordCmdToolband, EEikMenuItemSymbolOn);
sl@0
   842
		if (iEikonEnv->AppUiFactory()->ToolBar()->IsVisible())
sl@0
   843
			aMenuPane->SetItemButtonState(EWordCmdToolbar, EEikMenuItemSymbolOn);
sl@0
   844
		break;
sl@0
   845
		}
sl@0
   846
	//
sl@0
   847
	//
sl@0
   848
	case R_WORD_INSERT_MENU:
sl@0
   849
		if (readOnly)
sl@0
   850
			{
sl@0
   851
			aMenuPane->SetItemDimmed(EWordCmdInsertSketch,TRUE);
sl@0
   852
			aMenuPane->SetItemDimmed(EWordCmdInsertSheet,TRUE);
sl@0
   853
			aMenuPane->SetItemDimmed(EWordCmdInsertObject,TRUE);
sl@0
   854
			aMenuPane->SetItemDimmed(EWordCmdInsertPageBreak,TRUE);
sl@0
   855
			aMenuPane->SetItemDimmed(EWordCmdInsertLineBreak,TRUE);
sl@0
   856
			aMenuPane->SetItemDimmed(EEikCmdInsertSymbol,TRUE);
sl@0
   857
			}
sl@0
   858
		break;
sl@0
   859
	//
sl@0
   860
	//
sl@0
   861
	case R_WORD_TEXT_MENU:
sl@0
   862
		{
sl@0
   863
		TCharFormat charFormat;
sl@0
   864
		TCharFormatMask charUndeterminedMask;
sl@0
   865
		((CRichText*)iRichEd->Text())->GetCharFormat(charFormat,charUndeterminedMask,iRichEd->CursorPos(),0);
sl@0
   866
sl@0
   867
		if (charFormat.iFontSpec.iFontStyle.StrokeWeight()==EStrokeWeightBold)
sl@0
   868
			aMenuPane->SetItemButtonState(EEikCmdFontBold,EEikMenuItemSymbolOn);
sl@0
   869
		if (charFormat.iFontSpec.iFontStyle.Posture()==EPostureItalic)
sl@0
   870
			aMenuPane->SetItemButtonState(EEikCmdFontItalic,EEikMenuItemSymbolOn);
sl@0
   871
		if (charFormat.iFontPresentation.iUnderline==EUnderlineOn)
sl@0
   872
			aMenuPane->SetItemButtonState(EEikCmdFontUnderline,EEikMenuItemSymbolOn);
sl@0
   873
		if (readOnly)
sl@0
   874
			{
sl@0
   875
			aMenuPane->SetItemDimmed(EEikCmdFontBold,TRUE);
sl@0
   876
			aMenuPane->SetItemDimmed(EEikCmdFontItalic,TRUE);
sl@0
   877
			aMenuPane->SetItemDimmed(EEikCmdFontUnderline,TRUE);
sl@0
   878
			aMenuPane->SetItemDimmed(EEikCmdFontChange,TRUE);
sl@0
   879
			aMenuPane->SetItemDimmed(EWordCmdRevertToStyleChar,TRUE);
sl@0
   880
			}
sl@0
   881
		break;
sl@0
   882
		}
sl@0
   883
	//
sl@0
   884
	//
sl@0
   885
	case R_WORD_PARAGRAPH_MENU:
sl@0
   886
		{
sl@0
   887
		if (readOnly)
sl@0
   888
			{
sl@0
   889
			aMenuPane->SetItemDimmed(EWordCmdRevertToStylePara,TRUE);
sl@0
   890
			aMenuPane->SetItemDimmed(EEikCmdParaIndent,TRUE);
sl@0
   891
			aMenuPane->SetItemDimmed(EEikCmdParaTabs,TRUE);
sl@0
   892
			aMenuPane->SetItemDimmed(EEikCmdParaSpacing,TRUE);
sl@0
   893
			aMenuPane->SetItemDimmed(EEikCmdParaBorder,TRUE);
sl@0
   894
			aMenuPane->SetItemDimmed(EWordCmdStyleGallery,TRUE);
sl@0
   895
			}
sl@0
   896
		break;
sl@0
   897
		}
sl@0
   898
	//
sl@0
   899
	//
sl@0
   900
	case R_WORD_PARA_ALIGNMENT_MENU:
sl@0
   901
		{
sl@0
   902
		CParaFormat* paraFormat=CParaFormat::NewLC();
sl@0
   903
		TParaFormatMask paraUndeterminedMask;
sl@0
   904
		const TCursorSelection selection=iRichEd->Selection();
sl@0
   905
		Text()->GetParaFormatL(paraFormat,paraUndeterminedMask,selection.LowerPos(),selection.Length());
sl@0
   906
		if (!paraUndeterminedMask.AttribIsSet(EAttAlignment))
sl@0
   907
			{
sl@0
   908
			switch (paraFormat->iHorizontalAlignment)
sl@0
   909
				{
sl@0
   910
			case CParaFormat::ELeftAlign:
sl@0
   911
				aMenuPane->SetItemButtonState(EWordCmdAlignLeft,EEikMenuItemSymbolOn);
sl@0
   912
				aMenuPane->SetSelectedItem(0);
sl@0
   913
				break;
sl@0
   914
			case CParaFormat::ERightAlign:
sl@0
   915
				aMenuPane->SetItemButtonState(EWordCmdAlignRight,EEikMenuItemSymbolOn);
sl@0
   916
				aMenuPane->SetSelectedItem(1);
sl@0
   917
				break;
sl@0
   918
			case CParaFormat::ECenterAlign:	
sl@0
   919
				aMenuPane->SetItemButtonState(EWordCmdAlignCenter,EEikMenuItemSymbolOn);
sl@0
   920
				aMenuPane->SetSelectedItem(2);
sl@0
   921
				break;
sl@0
   922
			case CParaFormat::EJustifiedAlign:
sl@0
   923
				aMenuPane->SetItemButtonState(EWordCmdAlignJustify,EEikMenuItemSymbolOn);
sl@0
   924
				aMenuPane->SetSelectedItem(3);
sl@0
   925
				break;
sl@0
   926
			default:
sl@0
   927
				break;
sl@0
   928
				}
sl@0
   929
			}
sl@0
   930
		CleanupStack::PopAndDestroy();
sl@0
   931
		if (readOnly)
sl@0
   932
			{
sl@0
   933
			aMenuPane->SetItemDimmed(EWordCmdAlignLeft,TRUE);
sl@0
   934
			aMenuPane->SetItemDimmed(EWordCmdAlignRight,TRUE);
sl@0
   935
			aMenuPane->SetItemDimmed(EWordCmdAlignCenter,TRUE);
sl@0
   936
			aMenuPane->SetItemDimmed(EWordCmdAlignJustify,TRUE);
sl@0
   937
			}
sl@0
   938
		break;
sl@0
   939
		}
sl@0
   940
	//
sl@0
   941
	//
sl@0
   942
	case R_WORD_PARA_BULLETS_MENU:
sl@0
   943
		if (readOnly)
sl@0
   944
			{
sl@0
   945
			aMenuPane->SetItemDimmed(EWordCmdInsertBullet,TRUE);
sl@0
   946
			aMenuPane->SetItemDimmed(EWordCmdFormatBullet,TRUE);
sl@0
   947
			}
sl@0
   948
		break;
sl@0
   949
	//
sl@0
   950
	//
sl@0
   951
	case R_WORD_TOOLS_MENU:
sl@0
   952
		if (readOnly)
sl@0
   953
			{
sl@0
   954
			aMenuPane->SetItemDimmed(EWordCmdObjectPreferences,TRUE);
sl@0
   955
			}
sl@0
   956
		break;
sl@0
   957
	//
sl@0
   958
	//
sl@0
   959
	case R_EIK_SIDEBAR_IRDA_MENU:
sl@0
   960
	case R_WORD_TOOLS_INFRARED:
sl@0
   961
		aMenuPane->SetItemDimmed(EEikCmdIrdaReceive, TRUE);
sl@0
   962
		aMenuPane->SetItemDimmed(EEikCmdIrdaSend, TRUE);
sl@0
   963
		break;
sl@0
   964
	//
sl@0
   965
	//
sl@0
   966
	case R_EIK_SIDEBAR_EDIT_MENU:
sl@0
   967
		{
sl@0
   968
		TInt selection=iRichEd->Selection().Length();
sl@0
   969
		if (selection==0)
sl@0
   970
			aMenuPane->SetItemDimmed(EEikCmdEditCopy,TRUE);
sl@0
   971
		if (readOnly || selection==0)
sl@0
   972
			aMenuPane->SetItemDimmed(EEikCmdEditCut,TRUE);
sl@0
   973
		if (readOnly)
sl@0
   974
			aMenuPane->SetItemDimmed(EEikCmdEditPaste,TRUE);
sl@0
   975
		}
sl@0
   976
		break;
sl@0
   977
sl@0
   978
	case R_WORD_TEST_MENU:
sl@0
   979
		{
sl@0
   980
		TPtrC text;
sl@0
   981
		TCharFormat format;
sl@0
   982
		iRichEd->RichText()->GetChars(text,format,iRichEd->Selection().LowerPos());
sl@0
   983
		TFontPresentation::TFontHighlightStyle highlight = format.iFontPresentation.iHighlightStyle;
sl@0
   984
		if (highlight == TFontPresentation::EFontHighlightNormal)
sl@0
   985
			aMenuPane->SetItemButtonState(EWordCmdHighlight,EEikMenuItemSymbolOn);
sl@0
   986
		else if (highlight == TFontPresentation::EFontHighlightShadow)
sl@0
   987
			aMenuPane->SetItemButtonState(EWordCmdShadow,EEikMenuItemSymbolOn);
sl@0
   988
		else if (highlight == TFontPresentation::EFontHighlightFirstCustomStyle)
sl@0
   989
			aMenuPane->SetItemButtonState(EWordCmdCustomHighlight,EEikMenuItemSymbolOn);
sl@0
   990
		if (iTest->RuledPaper())
sl@0
   991
			aMenuPane->SetItemButtonState(EWordCmdRuledPaper,EEikMenuItemSymbolOn);
sl@0
   992
		if (iTest->BackgroundBitmap())
sl@0
   993
			aMenuPane->SetItemButtonState(EWordCmdBackgroundBitmap,EEikMenuItemSymbolOn);
sl@0
   994
		if (text.Length() && TChar(text[0]).IsUpper())
sl@0
   995
			aMenuPane->SetItemButtonState(EWordCmdUpperCase,EEikMenuItemSymbolOn);
sl@0
   996
		if (iTest->TruncateWithEllipsis())
sl@0
   997
			aMenuPane->SetItemButtonState(EWordCmdTruncateWithEllipsis,EEikMenuItemSymbolOn);
sl@0
   998
		}
sl@0
   999
		break;
sl@0
  1000
sl@0
  1001
	case R_WORD_PICTURE_ALIGNMENT_MENU:
sl@0
  1002
		{
sl@0
  1003
		TCharFormat format;
sl@0
  1004
		TCursorSelection sel = iRichEd->Selection();
sl@0
  1005
		TCharFormatMask varies;
sl@0
  1006
		Text()->GetCharFormat(format,varies,sel.LowerPos(),sel.Length());
sl@0
  1007
		if (!varies.AttribIsSet(EAttFontPictureAlignment))
sl@0
  1008
			{
sl@0
  1009
			switch (format.iFontPresentation.iPictureAlignment)
sl@0
  1010
				{
sl@0
  1011
				case TFontPresentation::EAlignTop:
sl@0
  1012
					aMenuPane->SetItemButtonState(EWordCmdPictureAlignTop,EEikMenuItemSymbolOn);
sl@0
  1013
					aMenuPane->SetSelectedItem(0);
sl@0
  1014
					break;
sl@0
  1015
				case TFontPresentation::EAlignBottom:
sl@0
  1016
					aMenuPane->SetItemButtonState(EWordCmdPictureAlignBottom,EEikMenuItemSymbolOn);
sl@0
  1017
					aMenuPane->SetSelectedItem(1);
sl@0
  1018
					break;
sl@0
  1019
				case TFontPresentation::EAlignCentered:	
sl@0
  1020
					aMenuPane->SetItemButtonState(EWordCmdPictureAlignCenter,EEikMenuItemSymbolOn);
sl@0
  1021
					aMenuPane->SetSelectedItem(2);
sl@0
  1022
					break;
sl@0
  1023
				case TFontPresentation::EAlignBaseLine:
sl@0
  1024
					aMenuPane->SetItemButtonState(EWordCmdPictureAlignBaseline,EEikMenuItemSymbolOn);
sl@0
  1025
					aMenuPane->SetSelectedItem(3);
sl@0
  1026
					break;
sl@0
  1027
				default:
sl@0
  1028
					break;
sl@0
  1029
				}
sl@0
  1030
			}
sl@0
  1031
		if (readOnly)
sl@0
  1032
			{
sl@0
  1033
			aMenuPane->SetItemDimmed(EWordCmdPictureAlignTop,TRUE);
sl@0
  1034
			aMenuPane->SetItemDimmed(EWordCmdPictureAlignBottom,TRUE);
sl@0
  1035
			aMenuPane->SetItemDimmed(EWordCmdPictureAlignCenter,TRUE);
sl@0
  1036
			aMenuPane->SetItemDimmed(EWordCmdPictureAlignBaseline,TRUE);
sl@0
  1037
			}
sl@0
  1038
		break;
sl@0
  1039
		}
sl@0
  1040
sl@0
  1041
	case R_WORD_KEYBOARD_MENU:
sl@0
  1042
		switch (iTest->Keyboard())
sl@0
  1043
			{
sl@0
  1044
			case CWordTest::EStandardKeyboard:
sl@0
  1045
				aMenuPane->SetItemButtonState(EWordCmdStandardKeyboard,EEikMenuItemSymbolOn);
sl@0
  1046
				aMenuPane->SetSelectedItem(0);
sl@0
  1047
				break;
sl@0
  1048
			case CWordTest::EGreekKeyboard:
sl@0
  1049
				aMenuPane->SetItemButtonState(EWordCmdGreekKeyboard,EEikMenuItemSymbolOn);
sl@0
  1050
				aMenuPane->SetSelectedItem(1);
sl@0
  1051
				break;
sl@0
  1052
			case CWordTest::ERussianKeyboard:
sl@0
  1053
				aMenuPane->SetItemButtonState(EWordCmdRussianKeyboard,EEikMenuItemSymbolOn);
sl@0
  1054
				aMenuPane->SetSelectedItem(2);
sl@0
  1055
				break;
sl@0
  1056
			case CWordTest::EArabicKeyboard:
sl@0
  1057
				aMenuPane->SetItemButtonState(EWordCmdArabicKeyboard,EEikMenuItemSymbolOn);
sl@0
  1058
				aMenuPane->SetSelectedItem(3);
sl@0
  1059
				break;
sl@0
  1060
			}
sl@0
  1061
		break;
sl@0
  1062
sl@0
  1063
	case R_WORD_CURSOR_STYLE_MENU:
sl@0
  1064
		if (iTest->CursorFlashing())
sl@0
  1065
			aMenuPane->SetItemButtonState(EWordCmdCursorStyleFlash,EEikMenuItemSymbolOn);
sl@0
  1066
		if (iTest->CursorWeight() >= 3)
sl@0
  1067
			aMenuPane->SetItemButtonState(EWordCmdCursorStyleHeavy,EEikMenuItemSymbolOn);
sl@0
  1068
		if (iTest->CursorXorColor() == KRgbCyan)
sl@0
  1069
			aMenuPane->SetItemButtonState(EWordCmdCursorStyleRed,EEikMenuItemSymbolOn);
sl@0
  1070
		switch (iTest->CursorPlacement())
sl@0
  1071
			{
sl@0
  1072
			case ECursorVertical:
sl@0
  1073
				aMenuPane->SetItemButtonState(EWordCmdCursorStyleVertical,EEikMenuItemSymbolOn);
sl@0
  1074
				aMenuPane->SetSelectedItem(1);
sl@0
  1075
				break;
sl@0
  1076
			case ECursorUnderlineNext:
sl@0
  1077
				aMenuPane->SetItemButtonState(EWordCmdCursorStyleUnderlineNext,EEikMenuItemSymbolOn);
sl@0
  1078
				aMenuPane->SetSelectedItem(2);
sl@0
  1079
				break;
sl@0
  1080
			case ECursorUnderlinePrev:
sl@0
  1081
				aMenuPane->SetItemButtonState(EWordCmdCursorStyleUnderlinePrev,EEikMenuItemSymbolOn);
sl@0
  1082
				aMenuPane->SetSelectedItem(3);
sl@0
  1083
				break;
sl@0
  1084
			}
sl@0
  1085
		break;
sl@0
  1086
	case R_WORD_SELECTION_HIGHLIGHT_MENU:
sl@0
  1087
		aMenuPane->SetItemButtonState(
sl@0
  1088
			aMenuPane->MenuItemCommandId(iTest->SelectionHighlightStyle()),
sl@0
  1089
			EEikMenuItemSymbolOn);
sl@0
  1090
		break;
sl@0
  1091
sl@0
  1092
	case R_WORD_POSITIONING_HINT_TEST_MENU:
sl@0
  1093
		switch(iTest->CursorPositioningHint())
sl@0
  1094
			{
sl@0
  1095
		case TCursorPosition::EPosHintUndefined:
sl@0
  1096
			aMenuPane->SetItemButtonState(
sl@0
  1097
				EWordCmdPositioningHintNeutral,
sl@0
  1098
				EEikMenuItemSymbolOn);
sl@0
  1099
			aMenuPane->SetSelectedItem(1);
sl@0
  1100
			break;
sl@0
  1101
		case TCursorPosition::EInsertStrongL2R:
sl@0
  1102
			aMenuPane->SetItemButtonState(
sl@0
  1103
				EWordCmdPositioningHintInsertLeftToRight,
sl@0
  1104
				EEikMenuItemSymbolOn);
sl@0
  1105
			aMenuPane->SetSelectedItem(2);
sl@0
  1106
			break;
sl@0
  1107
		case TCursorPosition::EInsertStrongR2L:
sl@0
  1108
			aMenuPane->SetItemButtonState(
sl@0
  1109
				EWordCmdPositioningHintInsertRightToLeft,
sl@0
  1110
				EEikMenuItemSymbolOn);
sl@0
  1111
			aMenuPane->SetSelectedItem(3);
sl@0
  1112
			break;
sl@0
  1113
			}
sl@0
  1114
		break;
sl@0
  1115
	default:
sl@0
  1116
		break;
sl@0
  1117
		}
sl@0
  1118
	}
sl@0
  1119
	
sl@0
  1120
void CWordAppUi::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
sl@0
  1121
	{
sl@0
  1122
	if (iWordFlags&EFNameBoxPopped && (aEventType==EEventRequestCancel ||aEventType==EEventRequestExit))
sl@0
  1123
		{
sl@0
  1124
		if (aEventType==EEventRequestExit)
sl@0
  1125
			{
sl@0
  1126
			TCharFormatMask charFormatMask;
sl@0
  1127
			TCharFormat charFormat;
sl@0
  1128
			const TCursorSelection selection=iRichEd->Selection();
sl@0
  1129
			Text()->GetCharFormat(charFormat,charFormatMask,selection.LowerPos(),selection.Length());
sl@0
  1130
			TInt index=iPopoutListBox->CurrentItemIndex();
sl@0
  1131
			charFormat.iFontSpec.iTypeface.iName=iPopoutListBox->Model()->ItemText(index);
sl@0
  1132
sl@0
  1133
			charFormat.iFontSpec.iTypeface.SetAttributes(FontUtils::TypefaceAttributes(*iCoeEnv->ScreenDevice(),charFormat.iFontSpec.iTypeface.iName));
sl@0
  1134
sl@0
  1135
			iTwipsList=new(ELeave) CArrayFixFlat<TInt>(4);
sl@0
  1136
			FontUtils::GetAvailableHeightsInTwipsL(*iCoeEnv->ScreenDevice(),charFormat.iFontSpec.iTypeface.iName,*iTwipsList);
sl@0
  1137
			index=FontUtils::IndexOfNearestHeight(*iTwipsList,charFormat.iFontSpec.iHeight);
sl@0
  1138
			charFormat.iFontSpec.iHeight=(*iTwipsList)[index];
sl@0
  1139
			charFormatMask.ClearAll();
sl@0
  1140
			charFormatMask.SetAttrib(EAttFontTypeface);	 
sl@0
  1141
			iRichEd->ApplyCharFormatL(charFormat,charFormatMask);
sl@0
  1142
			//
sl@0
  1143
			// Sense format of lower pos of selection to display appropriate info on toolband button labels
sl@0
  1144
			Text()->GetCharFormat(charFormat,charFormatMask,selection.LowerPos(),selection.Length());
sl@0
  1145
			UpdateToolBandFontNameButtonL(charFormat.iFontSpec.iTypeface.iName);
sl@0
  1146
			UpdateToolBandFontHeightButtonL(charFormat.iFontSpec.iHeight);
sl@0
  1147
			SetPaginationOutOfDate(TRUE);
sl@0
  1148
			}
sl@0
  1149
		iWordFlags&=~EFNameBoxPopped;
sl@0
  1150
		DestroyPopoutLBox();
sl@0
  1151
		return;
sl@0
  1152
		}
sl@0
  1153
	else if (iWordFlags&EStyleBoxPopped && (aEventType==EEventRequestCancel ||aEventType==EEventRequestExit))
sl@0
  1154
		{
sl@0
  1155
		if (aEventType==EEventRequestExit)
sl@0
  1156
			{
sl@0
  1157
			const TCursorSelection selection=iRichEd->Selection();
sl@0
  1158
			TInt index=iPopoutListBox->CurrentItemIndex();
sl@0
  1159
			TParagraphStyleName name;
sl@0
  1160
			iCoeEnv->ReadResource(name, R_WORD_NORMAL);
sl@0
  1161
			CDesCArray* array=(CDesCArray*)(iPopoutListBox->Model()->ItemTextArray());
sl@0
  1162
			if (name==(*array)[index])
sl@0
  1163
				Text()->ApplyParagraphStyleL(*(CParagraphStyle*)Text()->GlobalParaFormatLayer(),selection.LowerPos(),selection.Length(),KApplyParaStyleMode);
sl@0
  1164
			else
sl@0
  1165
				{
sl@0
  1166
				const CParagraphStyle& paraStyle=*(Text()->StyleList()->PtrByName((*array)[index])->iStyle);
sl@0
  1167
		   		Text()->ApplyParagraphStyleL(paraStyle,selection.LowerPos(),selection.Length(),KApplyParaStyleMode);
sl@0
  1168
				}
sl@0
  1169
			ReformatDueToStateChangeL();
sl@0
  1170
			}
sl@0
  1171
		iWordFlags&=~EStyleBoxPopped;
sl@0
  1172
		DestroyPopoutLBox();
sl@0
  1173
		return;
sl@0
  1174
		}
sl@0
  1175
	else if (iWordFlags&EAlignBoxPopped && (aEventType==EEventRequestCancel ||aEventType==EEventRequestExit))
sl@0
  1176
		{
sl@0
  1177
		if (aEventType==EEventRequestExit)
sl@0
  1178
			{
sl@0
  1179
			const TInt index = iBitmapPopout->CurrentItemIndex();
sl@0
  1180
			SetParaAlignmentL(index);
sl@0
  1181
			ReformatDueToStateChangeL();
sl@0
  1182
			}
sl@0
  1183
		iWordFlags&=~EAlignBoxPopped;
sl@0
  1184
		DestroyPopoutLBox();
sl@0
  1185
		return;
sl@0
  1186
		}
sl@0
  1187
	else if (iWordFlags&EFHeightBoxPopped && (aEventType==EEventRequestCancel ||aEventType==EEventRequestExit))
sl@0
  1188
		{
sl@0
  1189
		if (aEventType==EEventRequestExit)
sl@0
  1190
			{
sl@0
  1191
			TCharFormatMask charFormatMask;
sl@0
  1192
			TCharFormat charFormat;
sl@0
  1193
			TInt index=iPopoutListBox->CurrentItemIndex();
sl@0
  1194
			charFormatMask.SetAttrib(EAttFontHeight);	 
sl@0
  1195
			charFormat.iFontSpec.iHeight=(*iTwipsList)[index];
sl@0
  1196
			iRichEd->ApplyCharFormatL(charFormat,charFormatMask);
sl@0
  1197
			UpdateToolBandFontHeightButtonL(charFormat.iFontSpec.iHeight);
sl@0
  1198
			}
sl@0
  1199
		iWordFlags&=~EFHeightBoxPopped;
sl@0
  1200
		DestroyPopoutLBox();
sl@0
  1201
		return;
sl@0
  1202
		}
sl@0
  1203
	else if (iWordFlags&EBordersPopped && (aEventType==EEventRequestCancel ||aEventType==EEventRequestExit))
sl@0
  1204
		{
sl@0
  1205
		if (aEventType==EEventRequestExit)
sl@0
  1206
			{
sl@0
  1207
			TParaBorder top;
sl@0
  1208
			TParaBorder bottom;
sl@0
  1209
			TParaBorder left;
sl@0
  1210
			TParaBorder right;
sl@0
  1211
			const TInt index=iMcBitmapPopout->CurrentItemIndex();
sl@0
  1212
			switch (index)
sl@0
  1213
				{
sl@0
  1214
			case (ESingleFull-ESingleFull):
sl@0
  1215
				top.iThickness=KThinBorderThicknessInTwips;
sl@0
  1216
				bottom.iThickness=KThinBorderThicknessInTwips;
sl@0
  1217
				left.iThickness=KThinBorderThicknessInTwips;
sl@0
  1218
				right.iThickness=KThinBorderThicknessInTwips;
sl@0
  1219
				break;
sl@0
  1220
			case (ESingleTop-ESingleFull):
sl@0
  1221
				top.iThickness=KThinBorderThicknessInTwips;
sl@0
  1222
				break;
sl@0
  1223
			case (ESingleBottom-ESingleFull):
sl@0
  1224
				bottom.iThickness=KThinBorderThicknessInTwips;
sl@0
  1225
				break;
sl@0
  1226
			case (ESingleTopAndBottom-ESingleFull):
sl@0
  1227
				top.iThickness=KThinBorderThicknessInTwips;
sl@0
  1228
				bottom.iThickness=KThinBorderThicknessInTwips;
sl@0
  1229
				break;
sl@0
  1230
			case (EDoubleFull-ESingleFull):
sl@0
  1231
				top.iThickness=KThickBorderThicknessInTwips;
sl@0
  1232
				bottom.iThickness=KThickBorderThicknessInTwips;
sl@0
  1233
				left.iThickness=KThickBorderThicknessInTwips;
sl@0
  1234
				right.iThickness=KThickBorderThicknessInTwips;
sl@0
  1235
				break;
sl@0
  1236
			case (EDoubleTop-ESingleFull):
sl@0
  1237
				top.iThickness=KThickBorderThicknessInTwips;
sl@0
  1238
				break;
sl@0
  1239
			case (EDoubleBottom-ESingleFull):
sl@0
  1240
				bottom.iThickness=KThickBorderThicknessInTwips;
sl@0
  1241
				break;
sl@0
  1242
				}
sl@0
  1243
			switch (index)
sl@0
  1244
				{
sl@0
  1245
			case (ESingleFull-ESingleFull):
sl@0
  1246
			case (EDoubleFull-ESingleFull):
sl@0
  1247
				top.iLineStyle=TParaBorder::ESolid;
sl@0
  1248
				bottom.iLineStyle=TParaBorder::ESolid;
sl@0
  1249
				left.iLineStyle=TParaBorder::ESolid;
sl@0
  1250
				right.iLineStyle=TParaBorder::ESolid;
sl@0
  1251
				break;
sl@0
  1252
			case (ESingleTop-ESingleFull):
sl@0
  1253
			case (EDoubleTop-ESingleFull):
sl@0
  1254
				top.iLineStyle=TParaBorder::ESolid;
sl@0
  1255
				break;
sl@0
  1256
			case (ESingleBottom-ESingleFull):
sl@0
  1257
			case (EDoubleBottom-ESingleFull):
sl@0
  1258
				bottom.iLineStyle=TParaBorder::ESolid;
sl@0
  1259
				break;
sl@0
  1260
			case (ESingleTopAndBottom-ESingleFull):
sl@0
  1261
				top.iLineStyle=TParaBorder::ESolid;
sl@0
  1262
				bottom.iLineStyle=TParaBorder::ESolid;
sl@0
  1263
				break;
sl@0
  1264
				}
sl@0
  1265
			TParaFormatMask mask;
sl@0
  1266
			mask.SetAttrib(EAttTopBorder);
sl@0
  1267
			mask.SetAttrib(EAttBottomBorder);
sl@0
  1268
			mask.SetAttrib(EAttLeftBorder);
sl@0
  1269
			mask.SetAttrib(EAttRightBorder);
sl@0
  1270
			CParaFormat* paraFormat=CParaFormat::NewLC();
sl@0
  1271
			paraFormat->SetParaBorderL(CParaFormat::EParaBorderTop,top);
sl@0
  1272
			paraFormat->SetParaBorderL(CParaFormat::EParaBorderBottom,bottom);
sl@0
  1273
			paraFormat->SetParaBorderL(CParaFormat::EParaBorderLeft,left);
sl@0
  1274
			paraFormat->SetParaBorderL(CParaFormat::EParaBorderRight,right);
sl@0
  1275
			iRichEd->ApplyParaFormatL(paraFormat,mask);
sl@0
  1276
			CleanupStack::PopAndDestroy(); // paraFormat
sl@0
  1277
			}
sl@0
  1278
		iWordFlags&=~EBordersPopped;
sl@0
  1279
		DestroyPopoutLBox();
sl@0
  1280
		return;
sl@0
  1281
		}
sl@0
  1282
    if (aEventType==EEventStateChanged)
sl@0
  1283
		{
sl@0
  1284
		SetPaginationOutOfDate(TRUE);
sl@0
  1285
		if (aControl==iRichEd)
sl@0
  1286
			iToolBarUpdate->Start(CWordToolBarUpdate::ECharFormatUpdate);
sl@0
  1287
		}
sl@0
  1288
	if (iPaginateDialogCalled && aEventType==EEventRequestExit)
sl@0
  1289
		{ // !! possibly better - the dialog should define its own observer class
sl@0
  1290
		delete aControl;
sl@0
  1291
		SetPaginationOutOfDate(FALSE);
sl@0
  1292
		iPaginateDialogCalled=FALSE;
sl@0
  1293
		return;
sl@0
  1294
		}  
sl@0
  1295
	}
sl@0
  1296
sl@0
  1297
sl@0
  1298
void CWordAppUi::HandleEdwinEventL(CEikEdwin* aEdwin,TEdwinEvent aEventType)
sl@0
  1299
	{
sl@0
  1300
	if (aEdwin==iRichEd && (aEventType==MEikEdwinObserver::EEventFormatChanged || 
sl@0
  1301
							aEventType==MEikEdwinObserver::EEventNavigation))
sl@0
  1302
		{
sl@0
  1303
		if (aEventType==MEikEdwinObserver::EEventFormatChanged)
sl@0
  1304
			{
sl@0
  1305
			SetPaginationOutOfDate(TRUE);
sl@0
  1306
			SetDocChanged();
sl@0
  1307
			}
sl@0
  1308
		if (iEikonEnv->AppUiFactory()->ToolBar()->IsVisible() || iEikonEnv->AppUiFactory()->ToolBand()->IsVisible())
sl@0
  1309
			iToolBarUpdate->Start(CWordToolBarUpdate::EFullUpdate);
sl@0
  1310
		}
sl@0
  1311
	}
sl@0
  1312
sl@0
  1313
void CWordAppUi::RunPageSetupDialogL()
sl@0
  1314
	{
sl@0
  1315
	if (CEikPageSetupDialog::RunDlgLD(iPrintSetup))
sl@0
  1316
		{
sl@0
  1317
		CTextPageRegionPrinter& printer=PageRegionPrinter();
sl@0
  1318
		printer.SetPageMarginsInTwips(iPrintSetup->iPageMarginsInTwips.iMargins);
sl@0
  1319
		printer.SetPageSpecInTwips(iPrintSetup->PrinterDevice()->CurrentPageSpecInTwips());
sl@0
  1320
		SetPaginationOutOfDate(TRUE);
sl@0
  1321
		SetDocChanged();
sl@0
  1322
		UpdatePageLayoutL();
sl@0
  1323
		iRichEd->DrawNow();  // need to display any page breaks immediatley.
sl@0
  1324
		}
sl@0
  1325
	}