os/textandloc/textrendering/word/SRC/WPSTYLE.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #include <e32math.h>
    20 
    21 #include <s32mem.h>
    22 
    23 #include <txtrich.h>
    24 #include <txtstyle.h>
    25 #include <txtfrmat.h>
    26 
    27 #include <badesca.h>
    28 #include <barsread.h>
    29 #include <prnsetup.h>
    30 #include <clock.h>  // RMessageWindow::EMaxTextLength
    31 
    32 #include <techview/eikmnbut.h>
    33 #include <techview/eikbtpan.h>
    34 #include <techview/eiklbbut.h>
    35 #include <techview/eikdlgtb.h>
    36 #include <techview/eiktxlbx.h>
    37 #include <techview/eiktxlbm.h>
    38 #include <eikenv.h>
    39 #include <techview/eikrted.h>
    40 #include <techview/eikchkbx.h>
    41 #include <techview/eikbutb.h>
    42 #include <techview/eikfontd.h>
    43 #include <techview/eikparad.h>
    44 #include <techview/eiktabdg.h>
    45 #include <eikfctry.h>
    46 #include <techview/eikon.rsg>
    47 #include <techview/eikclb.h>
    48 #include <techview/eikclbd.h>
    49 #include <techview/eikbtgpc.h>
    50 
    51 #include "WPSTYLE.H"
    52 #include "WORD.HRH"
    53 #include <word.rsg>
    54 #include "WPAPPUI.H"
    55 #include "WPDEF.H"
    56 #include "WPDIALGS.H"
    57 #include "WPPANIC.H"
    58 
    59 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    60 #include "txtfmlyr_internal.h"
    61 #endif
    62 
    63 const TInt KNormalIndex=1;
    64 const TInt KMaxStyleHotKeyDescription=20;
    65 const TInt KDescriptionGranularity=100;
    66 const TInt KStyleColumnSpacerWidth=5;
    67 const TUint KNoHotkey=0;
    68 
    69 enum TDescriptor
    70 	{	EDesLeftMargin=EAttLeftMargin,
    71 		EDesRightMargin,
    72 		EDesIndent,
    73 		EDesDummy0,
    74 		EDesDummy1,
    75 		EDesLineSpacing,
    76 		EDesDummy2,
    77 		EDesSpaceBefore,
    78 		EDesSpaceAfter,
    79 		EDesKeepTogether,
    80 		EDesKeepWithNext,
    81 		EDesStartNewPage,
    82 		EDesWidowOrphan,
    83 		EDesDummy3,
    84 		EDesBorderMargin,
    85 		EDesBorderTop,
    86 		EDesBorderBottom,
    87 		EDesBorderLeft,
    88 		EDesBorderRight,
    89 		EDesBullet,
    90 		EDesDummy4,
    91 		EDesTabStop,
    92 		//
    93 		EDesItalic,
    94 		EDesBold,
    95 		EDesSuperscript,
    96 		EDesSubscript,
    97 		EDesUnderline,
    98 		EDesStrikethrough,
    99 		EDesLeftAlign,
   100 		EDesCenterAlign,
   101 		EDesRightAlign,
   102 		EDesJustifiedAlign
   103 	};
   104 
   105 				
   106 
   107 TWordStyleGalleryData::TWordStyleGalleryData(CRichText& aText,CStyleList& aStyleList,CStyleShortCutList& aHotKeyList,
   108 		TChar& aNormalStyleHotKey,CPrintSetup& aPrintSetup,TBool& aApplyStyle,const TCursorSelection& aSelection,
   109 		MUnifiedEditor& aEditor):
   110 	iText(aText),
   111 	iStyleList(aStyleList),
   112 	iHotKeyList(aHotKeyList),
   113 	iNormalStyleHotKey(aNormalStyleHotKey),
   114 	iPrintSetup(aPrintSetup),
   115 	iApplyStyle(aApplyStyle),
   116 	iSelection(aSelection),
   117 	iEditor(aEditor)
   118 	{
   119 	}
   120 
   121 
   122 CWordStyleGallery::CWordStyleGallery(TWordStyleGalleryData& aData)
   123 	: iData(aData)
   124 	{
   125 	}
   126 
   127 CWordStyleGallery::~CWordStyleGallery()
   128 	{
   129 	delete iStyleNameKeyList;
   130 	delete iStyleNameList;
   131 	delete iStyleDescriptor;
   132 	}
   133 
   134 void CWordStyleGallery::ConstructL()
   135 	{
   136 	iStyleNameList=new(ELeave) CDesCArrayFlat(4);
   137 	iStyleNameKeyList=new(ELeave) CDesCArrayFlat(4);	
   138 	}
   139 
   140 CWordStyleGallery* CWordStyleGallery::NewLC(TWordStyleGalleryData& aData)
   141 	{
   142 	CWordStyleGallery* self = new (ELeave) CWordStyleGallery(aData);
   143 	CleanupStack::PushL(self);
   144 	self->ConstructL();
   145 	return self;	
   146 	}
   147 	
   148 CWordStyleGallery* CWordStyleGallery::NewL(TWordStyleGalleryData& aData)
   149 	{
   150 	CWordStyleGallery* self = CWordStyleGallery::NewLC(aData);
   151 	CleanupStack::Pop(self);
   152 	return self;
   153 	}
   154 
   155 void CWordStyleGallery::StyleDescriptionL(TInt aIndex)
   156 	{
   157 	TParagraphStyleName name=(*iStyleNameList)[aIndex];
   158 	TInt index=iData.iStyleList.IndexByName(name);
   159 	const CParaFormatLayer* layer=(index==KErrNotFound)
   160 		? iData.iText.GlobalParaFormatLayer()
   161 		: iData.iStyleList.At(index).iStyle;
   162 	FillBufferL(*layer);
   163 	}
   164 
   165 
   166 void CWordStyleGallery::FillBufferL(const CParaFormatLayer& aParaFormatLayer)
   167 	{
   168 	CEikGlobalTextEditor* edwin=(CEikGlobalTextEditor*)Control(EWordCidStyleInfo);
   169 	TCharFormat charFormat;
   170 	TCharFormatMask charMask;
   171 	CParaFormat* paraFormat=CParaFormat::NewLC();
   172 	TParaFormatMask paraMask;
   173 	//
   174 	//
   175 	iCurrentDescription=HBufC::NewL(KDescriptionGranularity);
   176 	TPtr buf=iCurrentDescription->Des();
   177 	TBool isNormalStyle=(aParaFormatLayer.Type()==KNormalParagraphStyleUid);
   178 	if (!isNormalStyle)
   179 		{
   180 		const CParagraphStyle* flayer=REINTERPRET_CAST(const CParagraphStyle*,aParaFormatLayer.SenseBase());
   181 		TUid type=flayer->Type();
   182 		if (type==KNormalParagraphStyleUid)
   183 			buf.Append(iNormalName);
   184 		else
   185 			buf.Append(flayer->iName);
   186 		buf.Append('+');
   187 		}
   188 	//
   189 	if (isNormalStyle)
   190 		iData.iText.GlobalCharFormatLayer()->Sense(charFormat,charMask);
   191 	else
   192 		REINTERPRET_CAST(const CParagraphStyle&,aParaFormatLayer).CharFormatLayer()->Sense(charFormat,charMask);
   193 	aParaFormatLayer.SenseL(paraFormat,paraMask);
   194 	//
   195 	if (!charMask.IsNull())
   196 		{
   197 		if (charMask.AttribIsSet(EAttFontTypeface))
   198 			DoAppendDescriptionL(charFormat.iFontSpec.iTypeface.iName);
   199 		if (charMask.AttribIsSet(EAttFontHeight))
   200 			{
   201 			TInt height=charFormat.iFontSpec.iHeight;
   202 			height=(height+10)/20;
   203 			TBuf<20> num;
   204 			num.Num(height);
   205 			TBuf<10> unit;
   206 			iCoeEnv->ReadResource(unit,R_WORD_FONT_UNITS);
   207 			num.Append(unit);
   208 			DoAppendDescriptionL(num);
   209 			}
   210 		if (charMask.AttribIsSet(EAttFontPosture))
   211 			{
   212 			if (charFormat.iFontSpec.iFontStyle.Posture()==EPostureItalic)
   213 				DoAppendDescriptionL((*iStyleDescriptor)[EDesItalic]);
   214 			}
   215 		if (charMask.AttribIsSet(EAttFontStrokeWeight))
   216 			{
   217 			if (charFormat.iFontSpec.iFontStyle.StrokeWeight()==EStrokeWeightBold)
   218 				DoAppendDescriptionL((*iStyleDescriptor)[EDesBold]);
   219 			}
   220 		if (charMask.AttribIsSet(EAttFontPrintPos))
   221 			{
   222 			TFontPrintPosition pos=charFormat.iFontSpec.iFontStyle.PrintPosition();
   223 			switch(pos)
   224 				{
   225 			case EPrintPosSuperscript:
   226 				DoAppendDescriptionL((*iStyleDescriptor)[EDesSuperscript]);
   227 				break;
   228 			case EPrintPosSubscript:
   229 				DoAppendDescriptionL((*iStyleDescriptor)[EDesSubscript]);
   230 				break;
   231 			default:
   232 				break;
   233 				}
   234 			}
   235 		if (charMask.AttribIsSet(EAttFontUnderline))
   236 			{
   237 			if (charFormat.iFontPresentation.iUnderline==EUnderlineOn)
   238 				DoAppendDescriptionL((*iStyleDescriptor)[EDesUnderline]);
   239 			}
   240 		if (charMask.AttribIsSet(EAttFontStrikethrough))
   241 			{
   242 			if (charFormat.iFontPresentation.iStrikethrough==EStrikethroughOn)
   243 				DoAppendDescriptionL((*iStyleDescriptor)[EDesStrikethrough]);
   244 			}
   245 		}
   246 	if (!paraMask.IsNull())
   247 		{
   248 		AppendDescriptionL(EAttLeftMargin,paraMask);
   249 		AppendDescriptionL(EAttRightMargin,paraMask);
   250 		AppendDescriptionL(EAttIndent,paraMask);
   251 		if (paraMask.AttribIsSet(EAttAlignment))
   252 			DoAppendDescriptionL((*iStyleDescriptor)[EDesLeftAlign+paraFormat->iHorizontalAlignment]);
   253 		AppendDescriptionL(EAttLineSpacing,paraMask);
   254 		AppendDescriptionL(EAttSpaceBefore,paraMask);
   255 		AppendDescriptionL(EAttSpaceAfter,paraMask);
   256 		AppendDescriptionL(EAttKeepTogether,paraMask);
   257 		AppendDescriptionL(EAttKeepWithNext,paraMask);
   258 		AppendDescriptionL(EAttStartNewPage,paraMask);
   259 		AppendDescriptionL(EAttWidowOrphan,paraMask);
   260 		AppendDescriptionL(EAttBorderMargin,paraMask);
   261 		AppendDescriptionL(EAttTopBorder,*paraFormat,paraMask);
   262 		AppendDescriptionL(EAttBottomBorder,*paraFormat,paraMask);
   263 		AppendDescriptionL(EAttLeftBorder,*paraFormat,paraMask);
   264 		AppendDescriptionL(EAttRightBorder,*paraFormat,paraMask);
   265 		AppendDescriptionL(EAttBullet,paraMask);
   266 		AppendDescriptionL(EAttTabStop,*paraFormat,paraMask);
   267 		}
   268 	CleanupStack::PopAndDestroy();  // paraFormat
   269 	edwin->SetTextL(iCurrentDescription);
   270 	delete iCurrentDescription;
   271 	iCurrentDescription=NULL;
   272 	DrawEdwinL();
   273 	}
   274 
   275 
   276 void CWordStyleGallery::AppendDescriptionL(TTextFormatAttribute aAttribute,const CParaFormat& aFormat,const TParaFormatMask& aMask)
   277 	{
   278 	if (aMask.AttribIsSet(aAttribute) && 
   279 	aFormat.ParaBorder((CParaFormat::TParaBorderSide)(aAttribute-EAttTopBorder)).iLineStyle!=TParaBorder::ENullLineStyle)
   280 		{
   281 		DoAppendDescriptionL((*iStyleDescriptor)[(TDescriptor)aAttribute]);
   282 		}
   283 	}
   284 
   285 
   286 void CWordStyleGallery::AppendDescriptionL(TTextFormatAttribute aAttribute,const TParaFormatMask& aMask)
   287 	{
   288 	if (aMask.AttribIsSet(aAttribute))
   289 		DoAppendDescriptionL((*iStyleDescriptor)[(TDescriptor)aAttribute]);
   290 	}
   291 
   292 
   293 void CWordStyleGallery::DoAppendDescriptionL(const TDesC& aText)
   294 	{
   295 	TInt newLength=iCurrentDescription->Length()+aText.Length();
   296 	if (iCurrentDescription->Length()>0)
   297 		newLength+=2;  // add 2 characters for the separator.
   298 	if (newLength>iCurrentDescription->Des().MaxLength())
   299 		{
   300 		TInt alloc=KDescriptionGranularity*((newLength+KDescriptionGranularity-1)/KDescriptionGranularity);
   301 		iCurrentDescription=iCurrentDescription->ReAllocL(alloc);
   302 		}
   303 	TPtr ptr=iCurrentDescription->Des();
   304 	if (ptr.Length()>0)
   305 		ptr.Append(_L(", "));
   306 	ptr.Append(aText);
   307 	}
   308 
   309 void CWordStyleGallery::DrawEdwinL()
   310 	{
   311 	CEikGlobalTextEditor* edwin=(CEikGlobalTextEditor*)Control(EWordCidStyleInfo);
   312 	TViewYPosQualifier yPosQualifier;
   313 	yPosQualifier.SetMakeLineFullyVisible();
   314 	edwin->TextView()->HandleGlobalChangeL(yPosQualifier); // !! Reconsider this
   315 	edwin->DrawNow();
   316 	}
   317 
   318 void CWordStyleGallery::PreLayoutDynInitL()					    
   319 	{
   320 	DoCalcColumnWidthsL();
   321 	}
   322 
   323 
   324 void CWordStyleGallery::PostLayoutDynInitL()					    
   325 	{
   326 	DoCalcColumnWidthsL();
   327 	iStyleDescriptor=iCoeEnv->ReadDesCArrayResourceL(R_WORD_STYLE_GALLERY_DESCRIPTIONS);
   328 	//
   329 	iCoeEnv->ReadResource(iNormalName , R_WORD_NORMAL);
   330 	iCoeEnv->ReadResource(iHotKey , R_WORD_HOTKEY);
   331 	TInt pos=0;
   332 	iStyleNameList->Reset();						  
   333 	iStyleNameList->AppendL(iNormalName);
   334 
   335 	TBool styleChange;
   336 	TInt keycount=iData.iHotKeyList.Count();
   337 
   338 	const CParaFormatLayer* style=iData.iText.ParagraphStyle(styleChange,iData.iSelection.LowerPos(),iData.iSelection.Length());
   339 	TInt count=iData.iStyleList.Count();
   340 	for (TInt i=0;i<count;i++)
   341 		iStyleNameList->AppendL(iData.iStyleList.At(i).iStyle->iName);
   342 	iStyleNameList->Sort();
   343 	TUid id=style->Type();
   344 	for (TInt k=0;k<iStyleNameList->Count();k++)
   345 		{
   346 		if (id==KNormalParagraphStyleUid)
   347 			{
   348 			if (iNormalName==(*iStyleNameList)[k])
   349 				{
   350 				pos=k;
   351 				break;
   352 				}
   353 			}
   354 		else if(((CParagraphStyle*)style)->iName==(*iStyleNameList)[k])
   355 			{
   356 			pos=k;
   357 			break;
   358 			}
   359 		}
   360 
   361 	// Make sure all styles have a hot key, even if it's not assigned
   362 	// since any pasted styles will be missing hot key info
   363 
   364 
   365 	if (keycount < count)
   366 		{
   367 			TInt idx;
   368 			TInt keysToAdd = count-keycount;
   369 
   370 			for (idx=0; idx<keysToAdd; idx++)
   371 				iData.iHotKeyList.AppendL(KNoHotkey);
   372 			
   373 		}
   374 	else if ( keycount > count )
   375 		{
   376 		//too many, they should be the same so remove extras
   377 			TInt idx;
   378 			for (idx=keycount-1; idx>=count; idx--)
   379 				iData.iHotKeyList.Delete(idx);
   380 
   381 		}
   382 	MergeArraysL();
   383 	ListBox()->CreateScrollBarFrameL();
   384 	ListBox()->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
   385 	ListBox()->Model()->SetItemTextArray(iStyleNameKeyList);
   386 	ListBox()->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);
   387 	ListBox()->HandleItemAdditionL();
   388 	SetListBoxCurrentItem(EWordCidStyleNameList,pos);
   389 	SetDeleteButton();
   390 
   391 	CEikGlobalTextEditor* edwin=(CEikGlobalTextEditor*)Control(EWordCidStyleInfo);
   392 	CCharFormatLayer* clayer=CONST_CAST(CCharFormatLayer*,(edwin->GlobalText())->GlobalCharFormatLayer());
   393 	CParaFormatLayer* player=CONST_CAST(CParaFormatLayer*,(edwin->GlobalText())->GlobalParaFormatLayer());
   394 
   395     TCharFormatMask defaultCharFormatMask;
   396     TCharFormat defaultCharFormat;
   397 	TInt fontAttributes=TTypeface::EProportional;
   398 	defaultCharFormat.iFontSpec.iTypeface.SetAttributes(fontAttributes);
   399 	defaultCharFormat.iFontSpec.iHeight=160;
   400 
   401 	defaultCharFormatMask.SetAttrib(EAttFontHeight);
   402 	defaultCharFormatMask.SetAttrib(EAttFontTypeface);
   403 	clayer->SetL(defaultCharFormat,defaultCharFormatMask);	   
   404 //
   405 	CParaFormat pFormat;
   406 	TParaFormatMask pMask;
   407 	pFormat.iLineSpacingInTwips=160;
   408 	pMask.SetAttrib(EAttLineSpacing);
   409 	player->SetL(&pFormat,pMask);
   410 //
   411 	StyleDescriptionL(pos);
   412 	SetLineNonFocusing(EWordCidStyleInfo);
   413 	//
   414 	}
   415 
   416 void CWordStyleGallery::MergeArraysL()
   417 	{
   418 	iStyleNameKeyList->Reset();
   419 	TInt count=iStyleNameList->Count();
   420 	//
   421 	for (TInt ii=0;ii<count;ii++)
   422 		AppendL(ii);
   423 	}
   424 
   425 CEikColumnListBox* CWordStyleGallery::ListBox() const
   426 	{
   427 	return STATIC_CAST(CEikColumnListBox*,Control(EWordCidStyleNameList));
   428 	}
   429 
   430 void CWordStyleGallery::DoCalcColumnWidthsL()
   431 	{
   432 	CColumnListBoxData* columnData = ListBox()->ItemDrawer()->ColumnData();
   433 	const CFont* font;
   434 	//
   435 	// column 0
   436 	font = iEikonEnv->NormalFont();
   437 	columnData->SetColumnFontL(0, font);
   438 	columnData->SetColumnAlignmentL(0, CGraphicsContext::ELeft);
   439 	//
   440 	// column 1
   441 	columnData->SetColumnWidthPixelL(1, KStyleColumnSpacerWidth);
   442 	//
   443 	// column 2
   444 	font = iEikonEnv->LegendFont();
   445 	columnData->SetColumnFontL(2, font);
   446 	TBuf<KMaxStyleHotKeyDescription> hotkey;
   447 	iCoeEnv->ReadResource(hotkey, R_WORD_HOTKEY);
   448 	TInt width2 = font->TextWidthInPixels(hotkey) + font->MaxCharWidthInPixels();
   449 	columnData->SetColumnWidthPixelL(2, width2);
   450 	columnData->SetColumnAlignmentL(2, CGraphicsContext::ELeft);
   451 	//
   452 	// more column 0
   453 	TInt width0 = ListBox()->View()->ViewRect().Width() - KStyleColumnSpacerWidth - width2 - CEikScrollBar::DefaultScrollBarBreadth(); // only works if called from PostLayout...
   454 	columnData->SetColumnWidthPixelL(0, width0);
   455 	}
   456 
   457 void CWordStyleGallery::SetDeleteButton()
   458 	{
   459 	TInt index = ListBoxCurrentItem(EWordCidStyleNameList);
   460 	TBool dimmed = EFalse;
   461 	if (iNormalName == (*iStyleNameList)[index])
   462 		dimmed = ETrue;
   463 	else
   464 		{
   465 		CParagraphStyle* paraStyle = iData.iStyleList.PtrByName((*iStyleNameList)[index])->iStyle;
   466 		TUid type = paraStyle->Type();
   467 		dimmed = (type == KSystemParagraphStyleUid);
   468 		}
   469 	ButtonGroupContainer().DimCommand(EEikBidDelete, dimmed);
   470 	}
   471 
   472 TBool CWordStyleGallery::OkToExitL(TInt aButtonId)
   473 	{
   474 	switch(aButtonId)
   475 		{
   476 		case EWordCidAddStyle:
   477 		case EWordCidModifyStyle:
   478 			StyleL(aButtonId);
   479 			return EFalse;
   480 		case EEikBidDelete:
   481 			{
   482 			if (ButtonGroupContainer().IsCommandDimmed(EEikBidDelete))
   483 				return EFalse;
   484 			TInt index = ListBoxCurrentItem(EWordCidStyleNameList);			   
   485 			TParagraphStyleName name = (*iStyleNameList)[index]; 
   486 			//			
   487 			TBuf<RMessageWindow::EMaxTextLength> title;
   488 			TBuf<RMessageWindow::EMaxTextLength> res;
   489 			iCoeEnv->ReadResource(res, R_WORD_DELETE_STYLE_TITLE);
   490 			title.Format(res, &name);
   491 			//
   492 			if (iEikonEnv->QueryWinL(title, _L("")))
   493 				{// Can never delete the normal style
   494 				CParagraphStyle* paraStyle = iData.iStyleList.PtrByName(name)->iStyle;
   495 				TInt offset = iData.iStyleList.IndexByPtr(paraStyle);
   496 				__ASSERT_ALWAYS(offset >= 0, Panic(EWordGalleryInvalidStyle));
   497 				iData.iText.NotifyStyleDeletedL(paraStyle);
   498 				iData.iStyleList.Remove(paraStyle);
   499 				iStyleNameList->Delete(index);
   500 				iStyleNameKeyList->Delete(index);
   501 				iData.iHotKeyList.Delete(offset);
   502 				ListBox()->Reset();
   503 				if (index == iStyleNameList->Count())
   504 					index = index-KNormalIndex;
   505 				ListBox()->SetCurrentItemIndex(index);
   506 				ListBox()->UpdateScrollBarsL();				  //don't have to this.listbox should provide Handledeleteitem method
   507 				ListBox()->ScrollToMakeItemVisible(index);
   508 				ListBox()->DrawNow();
   509 				SetTextForCancelButtonL();
   510 				iData.iApplyStyle = ETrue;
   511 				}
   512 			SetDeleteButton();
   513 			StyleDescriptionL(index);
   514 			return EFalse;
   515 			}
   516 		case EEikBidOk:
   517 			{
   518 			TInt index = ListBoxCurrentItem(EWordCidStyleNameList);
   519 			MUnifiedEditor::MStyleSupport* style_support = iData.iEditor.StyleSupport();
   520 			if (style_support)
   521 				{
   522 				TPtrC styleName = (*iStyleNameList)[index];
   523 				// normal style name will not be recognised by the editor object,
   524 				// as it is our own invention. A null descriptor should be used.
   525 				const TPtrC nullDes;
   526 				if (styleName == iNormalName)
   527 					styleName.Set(nullDes);
   528 				style_support->SetStyleL(iData.iSelection.LowerPos(), iData.iSelection.Length(), styleName);
   529 				}
   530 			iData.iApplyStyle=ETrue;
   531 			}
   532 		}
   533 	//
   534 	return ETrue;
   535 	}
   536 
   537 void CWordStyleGallery::HandleControlStateChangeL(TInt aControlId)  
   538 	{
   539 	if (aControlId==EWordCidStyleNameList)
   540 		{
   541 		TInt index=ListBoxCurrentItem(EWordCidStyleNameList);
   542 		StyleDescriptionL(index);
   543 		SetDeleteButton();
   544 		}
   545 	}
   546 
   547 void CWordStyleGallery::StyleL(TInt aControlId)
   548 	{	
   549 	TInt index=ListBoxCurrentItem(EWordCidStyleNameList);			   
   550 	CParagraphStyle* paraStyle=NULL;
   551 	CEikDialog* dialog=NULL;
   552 	TBool normal=EFalse;
   553 	TChar newHotkey=KNoHotkey;
   554 	if (aControlId==EWordCidAddStyle)
   555 		{
   556 		paraStyle=CParagraphStyle::NewL(*(iData.iText.GlobalParaFormatLayer()),*(iData.iText.GlobalCharFormatLayer()));
   557 		dialog=new(ELeave) CWordStyleFormatDialog(iNormalName,iData.iNormalStyleHotKey,iData.iStyleList,
   558 									aControlId,iData.iText,&iData.iPrintSetup,iData.iHotKeyList,newHotkey,paraStyle);
   559 		}
   560 	else
   561 		{
   562 		if ((*iStyleNameList)[index]==iNormalName)
   563 			{
   564 			normal=ETrue;
   565 			dialog=new(ELeave) CWordStyleFormatDialog(iNormalName,iData.iNormalStyleHotKey,iData.iStyleList,
   566 									aControlId,iData.iText,&iData.iPrintSetup,iData.iHotKeyList,newHotkey,NULL,normal);
   567 			}
   568 		else
   569 			{
   570 			paraStyle=iData.iStyleList.PtrByName((*iStyleNameList)[index])->iStyle;
   571 			dialog=new(ELeave) CWordStyleFormatDialog(iNormalName,iData.iNormalStyleHotKey,iData.iStyleList,
   572 									aControlId,iData.iText,&iData.iPrintSetup,iData.iHotKeyList,newHotkey,paraStyle);
   573 			}
   574 		if (normal)
   575 			newHotkey=iData.iNormalStyleHotKey;
   576 		else
   577 			{
   578 			TInt ii=iData.iStyleList.IndexByPtr(paraStyle);
   579 			__ASSERT_DEBUG(ii!=KErrNotFound,Panic(EStyleIntegrityError));
   580 			newHotkey=iData.iHotKeyList[ii];
   581 			}
   582 		}
   583 	//
   584 	if (dialog->ExecuteLD(R_WORD_DIALOG_STYLE_FORMAT))
   585 		{
   586 		SetTextForCancelButtonL();	
   587 		// remove the hotkey from any old style if it has been re-assigned
   588 		if (newHotkey==iData.iNormalStyleHotKey)
   589 			iData.iNormalStyleHotKey=0;
   590 		else
   591 			{
   592 			TInt hotkeyCount=iData.iHotKeyList.Count();
   593 			for (TInt ii=0;ii<hotkeyCount;ii++)
   594 				{
   595 				if (newHotkey==iData.iHotKeyList[ii] && newHotkey!=KNoHotkey)
   596 					{
   597 					iData.iHotKeyList[ii]=0;
   598 					break;
   599 					}					
   600 				}
   601 			}
   602 		//
   603 		if (aControlId==EWordCidAddStyle)
   604 			{
   605 			RParagraphStyleInfo styleSet(paraStyle);
   606 			iData.iStyleList.AppendL(&styleSet);
   607 			}
   608 		else
   609 			{
   610 			iStyleNameList->Delete(index);
   611 			iStyleNameKeyList->Delete(index);
   612 			}
   613 		if (normal)
   614 			iStyleNameList->AppendL(iNormalName);
   615 		else
   616 			iStyleNameList->AppendL(paraStyle->iName);
   617 		iStyleNameList->Sort();
   618 		//
   619 		TParagraphStyleName name=(normal) ? iNormalName : paraStyle->iName;
   620 		for (TInt ii=0;ii<iStyleNameList->Count();ii++)
   621 			{
   622 			if (name==(*iStyleNameList)[ii])
   623 				{
   624 				index=ii;
   625 				break;
   626 				}
   627 			}
   628 
   629 		if (aControlId==EWordCidAddStyle)
   630 			iData.iHotKeyList.AppendL(newHotkey);
   631 		else
   632 			{
   633 			if (normal)
   634 				iData.iNormalStyleHotKey=newHotkey;
   635 			else
   636 				{
   637 				CParagraphStyle* style=iData.iStyleList.PtrByName((*iStyleNameList)[index])->iStyle;
   638 				TInt offset=iData.iStyleList.IndexByPtr(style);
   639 				iData.iHotKeyList[offset]=newHotkey;
   640 				}
   641 			}
   642 		MergeArraysL();
   643 		ListBox()->HandleItemAdditionL();
   644 		ListBox()->SetCurrentItemIndexAndDraw(index);
   645 		StyleDescriptionL(index);
   646 		SetDeleteButton();
   647 		}
   648 	else
   649 		{
   650 		if (aControlId==EWordCidAddStyle)
   651 			delete paraStyle;
   652 		}
   653 	}
   654 
   655 void CWordStyleGallery::AppendL(TInt aIndex)
   656 	{
   657 	TBuf<100> name;
   658 	name = (*iStyleNameList)[aIndex];
   659 	//
   660 	// truncate name if necessary
   661 	CColumnListBoxData* columnData = ListBox()->ItemDrawer()->ColumnData();
   662 	TInt columnWidth = columnData->ColumnWidthPixel(0);
   663 	const CFont* columnFont = columnData->ColumnFont(0);
   664 	if (columnFont->TextWidthInPixels(name) > columnWidth)
   665 		TextUtils::ClipToFit(name, *columnFont, columnWidth);
   666 	//
   667 	TChar key = iData.iNormalStyleHotKey;
   668 	if (name != iNormalName)
   669 		{
   670 		CParagraphStyle* pp = iData.iStyleList.PtrByName(name)->iStyle;
   671 		TInt index = iData.iStyleList.IndexByPtr(pp);
   672 		key = iData.iHotKeyList[index];
   673 		}
   674 	if (key > 0)
   675 		{
   676 		name.Append(KColumnListSeparator);
   677 		name.Append(KColumnListSeparator); // one for empty spacer column
   678 		name.Append(iHotKey);
   679 		name.Append(key);		
   680 		name.Append(KColumnListSeparator);
   681 		}
   682 	iStyleNameKeyList->AppendL(name);
   683 	}
   684 
   685 void CWordStyleGallery::SetTextForCancelButtonL()
   686 	{
   687 	TBuf<20> buf;
   688 	iCoeEnv->ReadResource(buf, R_WORD_CLOSE);
   689 	const TInt pos = ButtonGroupContainer().PositionById(EEikBidCancel);	
   690 	ButtonGroupContainer().SetCommandL(pos, EEikBidCancel, buf);
   691 	iData.iApplyStyle = ETrue;
   692 	}
   693 
   694 ///////////////////Add Modify button dialogs//////////////////////
   695 
   696 CWordStyleFormatDialog::CWordStyleFormatDialog(const TParagraphStyleName& aNormalName,const TChar aNormalStyleHotkey,const CStyleList& aStyleList,const TInt aButton,CRichText& aText,CPrintSetup* aPrintSetup,CArrayFix<TChar>& aHotKeyList,TChar& aChar,CParagraphStyle* aParagraphStyle,TBool aNormalStyle)
   697 	:
   698 	iStyleList(aStyleList),
   699 	iText(&aText),
   700 	iButton(aButton),
   701 	iParagraphStyle(aParagraphStyle),
   702 	iNormalStyle(aNormalStyle),
   703 	iPrintSetup(aPrintSetup),
   704 	iHotKeyList(&aHotKeyList),
   705 	iNormalStyleHotkey(aNormalStyleHotkey),
   706 	iNormalName(aNormalName),
   707 	iChar(aChar)
   708 	{
   709 		if (aParagraphStyle) iOutline = aParagraphStyle->OutlineLevel();
   710 		else iOutline = 0;
   711 	}
   712 
   713 CWordStyleFormatDialog::~CWordStyleFormatDialog()
   714 	{
   715 	delete iBullet;
   716 	}
   717 
   718 void CWordStyleFormatDialog::PreLayoutDynInitL()
   719 	{
   720 	//
   721 	// Dynamically change the title of this dialog as appropriate
   722 	TInt id = (iButton == EWordCidAddStyle)?
   723 		R_WORD_STYLEFORMAT_TITLE_ADD : R_WORD_STYLEFORMAT_TITLE_MODIFY;
   724 	if (id == R_WORD_STYLEFORMAT_TITLE_ADD)
   725 		SetTitleL(id);
   726 	else
   727 		{
   728 		TBuf<24> buf;
   729 		iCoeEnv->ReadResource(buf,R_WORD_STYLEFORMAT_TITLE_MODIFY);
   730 		TBuf<24+KMaxParagraphStyleName> title; // 56
   731 		TParagraphStyleName name;
   732 		name = (iNormalStyle)? iNormalName : iParagraphStyle->iName;
   733 		title.Format(buf,&name);
   734 		SetTitleL(title);
   735 		}
   736 	//
   737 	TParaFormatMask paraMask;
   738 	CParaFormat* paraFormat=CParaFormat::NewLC();
   739 	ButtonGroupContainer().ButtonById(EWordCidFormatList)->
   740 		SetButtonLayout(CEikCommandButton::ETextLeftPictureRight);
   741 	if (iNormalStyle)
   742 		{
   743 		TParagraphStyleName name;
   744 		iCoeEnv->ReadResource(name , R_WORD_NORMAL);
   745 		SetEdwinTextL(EWordCidStyleName,&name);
   746 		SetLineDimmedNow(EWordCidStyleName,ETrue);
   747 		SetLineDimmedNow(EWordCidOutline,ETrue);
   748 		iText->GlobalParaFormatLayer()->SenseL(paraFormat,paraMask);
   749 		}
   750 	else
   751 		{
   752 		SetEdwinTextL(EWordCidStyleName,&iParagraphStyle->iName);
   753 		TUid type=iParagraphStyle->Type();
   754 		if (type==KSystemParagraphStyleUid)
   755 			SetLineDimmedNow(EWordCidStyleName,ETrue);
   756 		iParagraphStyle->SenseL(paraFormat,paraMask);
   757 		}
   758 	//hotkey
   759 	if (iButton==EWordCidModifyStyle)
   760 		{
   761 		CEikCharEditor* editor=(CEikCharEditor*)Control(EWordCidHotKey);
   762 		editor->SetChar(iChar);
   763 		}
   764 	//
   765 	CEikButtonBase::TState state;
   766 	state=(paraFormat->iBullet)? CEikButtonBase::ESet : CEikButtonBase::EClear ;
   767 	SetCheckBoxState(EWordCidBullet,state);
   768 
   769 	// Set values for Outline level
   770 
   771 	SetNumberEditorValue(EWordCidOutline,iOutline);
   772 
   773 	CleanupStack::PopAndDestroy();
   774 	}
   775 
   776 
   777 TBool CWordStyleFormatDialog::OkToExitL(TInt aButtonId)
   778 	{
   779 	if (aButtonId == EWordCidFormatList)
   780 		{
   781 		CEikLabeledButton* labelButton = STATIC_CAST(CEikLabeledButton*,ButtonGroupContainer().ControlOrNull(EWordCidFormatList));
   782 		if (labelButton != NULL)
   783 			{
   784 			CEikMenuButton* menuButton = STATIC_CAST(CEikMenuButton*, labelButton->Button());
   785 			menuButton->LaunchPopupMenuL(this);				
   786 			return EFalse;
   787 			}
   788 		}
   789 	if (aButtonId == EEikBidOk)
   790 		{	
   791 		TParagraphStyleName name;
   792 		GetEdwinText(name,EWordCidStyleName);
   793 		if (!name.Length())
   794 			{
   795 			iEikonEnv->InfoMsg(R_WORD_NOSTYLENAME);
   796 			return EFalse;
   797 			}
   798 
   799 		if (iParagraphStyle)
   800 		{
   801 		iOutline = NumberEditorValue(EWordCidOutline);
   802 		iParagraphStyle->SetOutlineLevel(iOutline);
   803 		}
   804 		
   805 		
   806 		// check for normal name as well
   807 		TParagraphStyleName normalName;
   808 		iCoeEnv->ReadResource(normalName , R_WORD_NORMAL);
   809 		 // you cannot modify names of the built in styles
   810 		if (iButton == EWordCidModifyStyle)
   811 			{
   812 			if (iNormalStyle)
   813 				return ETrue;
   814 			else
   815 				{
   816 				TUid type = iParagraphStyle->Type();
   817 				if (type == KSystemParagraphStyleUid)
   818 					return ETrue;
   819 				else   // userdefined style
   820 					{  	// now check the style list to see if the specified style already exists
   821 					CStyleList* styleList = iText->StyleList();
   822 					for (TInt i = 0; i < styleList->Count(); i++)
   823 						{
   824 						if ((name == (*styleList)[i].iStyle->iName) || (name == normalName))
   825 							{
   826 							if (name != iParagraphStyle->iName)
   827 								{
   828 								iEikonEnv->InfoMsg(R_WORD_STYLENAMEEXISTS);
   829 								return EFalse;
   830 								}
   831 							}
   832 						}
   833 					}
   834 				}
   835 			}
   836 		else
   837 			{
   838 			CStyleList* list = iText->StyleList();
   839 			for (TInt i = 0; i < list->Count(); i++)
   840 				if ((name == (*list)[i].iStyle->iName) || (name == normalName))
   841 					{
   842 					iEikonEnv->InfoMsg(R_WORD_STYLENAMEEXISTS);
   843 					return EFalse;
   844 					}
   845 			}
   846 		GetEdwinText(iParagraphStyle->iName, EWordCidStyleName);
   847 		}					   
   848 	return ETrue;
   849 	}	  						  
   850 
   851 SEikControlInfo CWordStyleFormatDialog::CreateCustomControlL(TInt aControlType)
   852 	{
   853 	SEikControlInfo info;
   854 	info.iTrailerTextId=0;
   855     info.iFlags=0;
   856 	if (aControlType==EWordCtStyleShortcutKeyEditor)
   857 		info.iControl=new(ELeave) CWordStyleHotKeyEditor(this);
   858 	else
   859 		info.iControl=NULL;
   860 	return info;
   861 	}
   862 
   863 void CWordStyleFormatDialog::HandleControlStateChangeL(TInt aControlId)
   864 	{
   865 	if (aControlId==EWordCidBullet)
   866 		SetBulletL();
   867 	if (aControlId==EWordCidHotKey)
   868 		iChar = ((CEikCharEditor*)Control(EWordCidHotKey))->GetChar();
   869 	}
   870 
   871 
   872 void CWordStyleFormatDialog::HandleInteractionRefused(TInt aControlId)
   873 	{	
   874 	if (aControlId==EWordCidOutline)
   875 		iEikonEnv->InfoMsg(R_WORD_NORMAL_OUTLINE);	
   876 	else
   877 		iEikonEnv->InfoMsg(R_EIK_TBUF_NOT_AVAILABLE);
   878 	}
   879 
   880 
   881 TBool CWordStyleFormatDialog::ValidateHotkey(TKeyEvent& aKeyEvent)
   882 // return false if the hotkey is invalid
   883 // otherwise set aKeyEvent to the hotkey I have validated (ie uppercase it)
   884 	{
   885 	// check that the key is a valid character
   886 	TChar hotkey=aKeyEvent.iCode;
   887 	if (!hotkey.IsAlphaDigit())
   888 		{
   889 		iEikonEnv->InfoMsg(R_WORD_HOTKEY_INVALID);
   890 		return EFalse;
   891 		}
   892 	//
   893 	// upper-case the key
   894 	hotkey.UpperCase();
   895 	//
   896 	// check that it isn't already in use
   897 	HotkeyConflict(hotkey);
   898 	//
   899 	// set the hotkey and return
   900 	aKeyEvent.iCode = hotkey;
   901 	return ETrue;
   902 	}
   903 
   904 
   905 TBool CWordStyleFormatDialog::HotkeyConflict(TChar aHotkey)
   906 	{
   907 	TBool hotkeyConflict=EFalse;
   908 	TInt index=-1;
   909 	if (aHotkey==iNormalStyleHotkey)
   910 		hotkeyConflict=ETrue;
   911 	else
   912 		{
   913 		TInt hotkeyCount=iHotKeyList->Count();
   914 		for (index=0;index<hotkeyCount;index++)
   915 			{
   916 			if (aHotkey==(*iHotKeyList)[index])
   917 				{
   918 				hotkeyConflict=ETrue;
   919 				break;
   920 				}
   921 			}
   922 		}
   923 	//
   924 	if (hotkeyConflict)
   925 		{
   926 		//there isnt an entry in the stylelist
   927 		if (index >iStyleList.Count() )
   928 			hotkeyConflict=EFalse;
   929 		else
   930 			{
   931 				TBuf<80> msg;
   932 				TBuf<48> fmtString;
   933 
   934 				iCoeEnv->ReadResource(fmtString,R_WORD_HOTKEYEXISTS);
   935 				TParagraphStyleName name=(index>=0)
   936 					? iStyleList.At(index).iStyle->iName
   937 					: iNormalName;
   938 				msg.Format(fmtString,&name);
   939 				iEikonEnv->InfoMsg(msg);
   940 			}
   941 		}
   942 	//
   943 	return hotkeyConflict;
   944 	}
   945 
   946 
   947 void CWordStyleFormatDialog::SetBulletL()
   948 	{
   949 	TParaFormatMask paraMask;
   950 	CParaFormat* paraFormat=CParaFormat::NewLC();
   951 	if (iNormalStyle)
   952 		iText->GlobalParaFormatLayer()->SenseL(paraFormat,paraMask);
   953 	else 
   954 		iParagraphStyle->SenseL(paraFormat,paraMask);
   955 	delete paraFormat->iBullet;
   956 
   957 	if(((CEikCheckBox*)Control(EWordCidBullet))->State()==CEikButtonBase::EClear)
   958 		{
   959 		paraFormat->iBullet=NULL;
   960 		paraFormat->iIndentInTwips=0;
   961 		paraMask.ClearAttrib(EAttBullet);
   962 		paraMask.ClearAttrib(EAttIndent);
   963 		}
   964 	else
   965 		{
   966 		paraMask.SetAttrib(EAttBullet);
   967 		paraMask.SetAttrib(EAttIndent);
   968 		TBullet* bullet=new(ELeave) TBullet;
   969 		if (!iBullet)
   970 			CreateDefaultBulletL();
   971 		*bullet=*iBullet;									 
   972 		paraFormat->iBullet=bullet;
   973 		if (iBullet->iHangingIndent)
   974 			paraFormat->iIndentInTwips=283; // about 1/2cm - completely arbitrary value !!
   975 		else
   976 			paraFormat->iIndentInTwips=0;
   977 		}
   978 	if (iNormalStyle)
   979 		((CParaFormatLayer*)iText->GlobalParaFormatLayer())->SetL(paraFormat,paraMask);
   980 	else
   981 		iParagraphStyle->SetL(paraFormat,paraMask);
   982 	TViewYPosQualifier yPosQ;
   983 	yPosQ.SetMakeLineFullyVisible();
   984 	CleanupStack::PopAndDestroy();
   985 	}
   986 
   987 void CWordStyleFormatDialog::CreateDefaultBulletL()
   988 	{
   989 	iBullet=new(ELeave) TBullet;
   990 	iBullet->iCharacterCode=0x2022;
   991 	iBullet->iHeightInTwips=iEikonEnv->NormalFont()->FontSpecInTwips().iHeight;
   992 	iBullet->iTypeface.iName=_L("Swiss");
   993 	}
   994 
   995 void CWordStyleFormatDialog::ProcessCommandL(TInt aCommand)
   996 	{
   997 	switch (aCommand)
   998 		{
   999 	case EEikCmdFontChange:	
  1000 		RunFontDialogL();
  1001 		break;
  1002 	case EEikCmdParaIndent:		
  1003 	case EEikCmdParaSpacing:	
  1004 	case EEikCmdParaBorder:			
  1005 	case EEikCmdParaTabs:		
  1006 	case EEikCmdParaAlign:		
  1007 		RunDialogL((TStyleFormatDialog)aCommand);					   
  1008 		break;
  1009 	case EWordCmdFormatBullet:
  1010 		RunSelectBulletDialogL();
  1011 		break;
  1012 		}
  1013 	}
  1014 		
  1015 CParaFormatLayer* CWordStyleFormatDialog::GetParaLayerAndFormattingL(CParaFormat& aFormat,TParaFormatMask& aMask)
  1016 //
  1017 	{
  1018 	CParaFormatLayer* layer=(iNormalStyle)
  1019 		? CONST_CAST(CParaFormatLayer*,iText->GlobalParaFormatLayer())
  1020 		: iParagraphStyle;
  1021 	DoGetParaFormatL(aFormat,aMask,*layer);
  1022 	return layer;
  1023 	}
  1024 
  1025 
  1026 void CWordStyleFormatDialog::DoGetParaFormatL(CParaFormat& aFormat,TParaFormatMask& aMask,const CParaFormatLayer& aLayer)
  1027 //
  1028 	{
  1029 	aLayer.SenseEffectiveL(&aFormat);
  1030 	aLayer.SenseL(&aFormat,aMask);
  1031 	}
  1032 
  1033 
  1034 void CWordStyleFormatDialog::RunSelectBulletDialogL()
  1035 	{
  1036 	if (!iBullet)
  1037 		CreateDefaultBulletL();
  1038 	CParaFormat* paraFormat=CParaFormat::NewLC();
  1039 	TParaFormatMask paraMask;
  1040 	TCharFormat charFormat;
  1041 	TCharFormatMask charMask;
  1042 //	TCharFormatMask charUndeterminedMask;
  1043 	if(iNormalStyle)
  1044 		{
  1045 		iText->GlobalParaFormatLayer()->SenseL(paraFormat,paraMask);
  1046 		iText->GlobalCharFormatLayer()->Sense(charFormat,charMask);
  1047 		}
  1048 	else
  1049 		{
  1050 		iParagraphStyle->SenseEffectiveL(paraFormat);
  1051 		iParagraphStyle->CharFormatLayer()->SenseEffective(charFormat);
  1052 		}
  1053 	TRgb backColor=paraFormat->iFillColor;
  1054 	if (paraMask.AttribIsSet(EAttFillColor))
  1055 		backColor=KRgbWhite; // what else could be done ???
  1056 	CEikDialog* dialog=new(ELeave) CWordBulletDialog(iBullet,backColor,NULL,charFormat.iFontSpec.iTypeface.iName);
  1057 	if (dialog->ExecuteLD(R_WORD_DIALOG_BULLET))
  1058 		{
  1059 		SetCheckBoxState(EWordCidBullet,CEikButtonBase::ESet);
  1060 		SetBulletL();
  1061 		}
  1062 	CleanupStack::PopAndDestroy();
  1063 	}
  1064 
  1065 
  1066 void CWordStyleFormatDialog::RunDialogL(TStyleFormatDialog aFunction)
  1067 	{
  1068 	TParaFormatMask mask;
  1069 	TParaFormatMask undeterminedMask;  // always NULL for these calls
  1070 	CParaFormat* format=CParaFormat::NewLC();  // !! could use 1 on the stack for some
  1071 	CParaFormatLayer* layer=GetParaLayerAndFormattingL(*format,mask);
  1072 //	CEikDialog* dialog=NULL;
  1073 	switch(aFunction)
  1074 		{
  1075 		case EIndentsDialog:
  1076 		case ETabsDialog:
  1077 			{
  1078 			TPageSpec pageSpec=iPrintSetup->PrinterDevice()->CurrentPageSpecInTwips();
  1079 			TInt width=pageSpec.iPortraitPageSize.iWidth;
  1080 			if (pageSpec.iOrientation==TPageSpec::ELandscape)
  1081 				width=pageSpec.iPortraitPageSize.iHeight;
  1082 			width-=(iPrintSetup->iPageMarginsInTwips.iMargins.iLeft+iPrintSetup->iPageMarginsInTwips.iMargins.iRight);
  1083 			if (aFunction==ETabsDialog)
  1084 				{
  1085 				(void)CEikTabsDialog::RunDlgLD(format, mask, undeterminedMask, width);
  1086 				}
  1087 			else
  1088 				{
  1089 				(void)CEikIndentDialog::RunDlgLD(format, mask, undeterminedMask, width);
  1090 				}
  1091 			break;
  1092 			}
  1093 		case EBordersDialog:
  1094 			(void)CEikBorderDialog::RunDlgLD(format, mask, undeterminedMask);
  1095 			break;
  1096 		case EAlignmentDialog:
  1097 			(void)CEikAlignDialog::RunDlgLD(format,mask,undeterminedMask);
  1098 			break;
  1099 		case ELineSpacingDialog:
  1100 			(void)CEikSpaceDialog::RunDlgLD(format,mask,undeterminedMask);
  1101 			break;
  1102 		}
  1103 	layer->SetL(format,mask);
  1104 	CleanupStack::PopAndDestroy();  // format
  1105 	}
  1106 
  1107 
  1108 void CWordStyleFormatDialog::RunFontDialogL()
  1109 	{
  1110 	TCharFormat charFormat;
  1111 	TCharFormatMask charMask;
  1112 	CCharFormatLayer* charLayer=NULL;
  1113 	if (iNormalStyle)
  1114 		{
  1115 		charLayer=CONST_CAST(CCharFormatLayer*,iText->GlobalCharFormatLayer());
  1116 		charLayer->SenseEffective(charFormat);  // used to seed the dialog
  1117 		charLayer->Sense(charFormat,charMask);  // gets the mask
  1118 		}
  1119 	else
  1120 		{
  1121 		charLayer=iParagraphStyle->CharFormatLayer();
  1122 		charLayer->SenseEffective(charFormat);
  1123 		charLayer->Sense(charFormat,charMask);
  1124 		}
  1125 	if (!CEikFontDialog::RunDlgLD(charFormat, charMask, EGulNoSymbolFonts, iCoeEnv->ScreenDevice()))
  1126 		return;
  1127 	charLayer->SetL(charFormat,charMask);
  1128 	}
  1129 
  1130 void CWordStyleFormatDialog::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/)
  1131 	{
  1132 	}
  1133 
  1134 
  1135 //
  1136 // class CWordStyleHotKeyEditor
  1137 //
  1138 
  1139 CWordStyleHotKeyEditor::CWordStyleHotKeyEditor(MWordHotkeyValidator* aValidator)
  1140 :iValidator(aValidator)
  1141 	{}
  1142 
  1143 
  1144 TKeyResponse CWordStyleHotKeyEditor::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
  1145 	{
  1146 	if (aType!=EEventKey)
  1147 		return EKeyWasNotConsumed;
  1148 	//
  1149 	TChar hotkey=aKeyEvent.iCode;
  1150 	if (hotkey==EKeyUpArrow || hotkey==EKeyDownArrow || hotkey==EKeyLeftArrow || hotkey==EKeyRightArrow)
  1151 		return EKeyWasNotConsumed;
  1152 	//
  1153 	TKeyEvent event=aKeyEvent;
  1154 	if (!iValidator->ValidateHotkey(event))
  1155 		return EKeyWasConsumed;
  1156 	//
  1157 	return CEikCharEditor::OfferKeyEventL(event,aType);
  1158 	}