os/textandloc/textrendering/word/SRC/WPDIALGS.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 <frmvis.h>
sl@0
    20
sl@0
    21
#include <prninf.h>
sl@0
    22
#include <prnsetup.h>
sl@0
    23
sl@0
    24
#include <badesca.h>
sl@0
    25
#include <bamatch.h>
sl@0
    26
sl@0
    27
#include <e32std.h>
sl@0
    28
sl@0
    29
#include <coeutils.h>
sl@0
    30
sl@0
    31
#include <eikenv.h>
sl@0
    32
#include <eikfctry.h>
sl@0
    33
#include <techview/eikchlst.h>
sl@0
    34
#include <techview/eikfprev.h>
sl@0
    35
#include <techview/eikbtpan.h>
sl@0
    36
#include <techview/eikcmbut.h>
sl@0
    37
#include <techview/eikchkbx.h>
sl@0
    38
#include <techview/eikfpne.h>
sl@0
    39
#include <techview/eikcfdlg.h>
sl@0
    40
#include <techview/eikfsel.h>
sl@0
    41
#include <techview/eikprtdg.h>
sl@0
    42
#include <techview/eikinfo.h>
sl@0
    43
#include <techview/eikon.rsg>
sl@0
    44
#include <techview/eikfsel.h>
sl@0
    45
#include <eikfutil.h>
sl@0
    46
#include <techview/eikdclbm.h>
sl@0
    47
#include <techview/eikfbrow.h>
sl@0
    48
#include <techview/eikufsel.h>
sl@0
    49
#include <techview/eiklbbut.h>
sl@0
    50
#include <techview/eikchmap.h>
sl@0
    51
#include <techview/eikbtgpc.h>
sl@0
    52
sl@0
    53
#include "WPOUTLNE.H"
sl@0
    54
#include "WPDIALGS.H"
sl@0
    55
#include "WPPANIC.H"
sl@0
    56
#include "wpresources.h"
sl@0
    57
#include "WORD.HRH"
sl@0
    58
#include <word.rsg>
sl@0
    59
#include "WPMAIN.H"
sl@0
    60
sl@0
    61
const TInt KShortErrorMessageLength = 64;
sl@0
    62
const TInt KMaxDisplayedFullNameLen	= 35;
sl@0
    63
sl@0
    64
//
sl@0
    65
// class CWordBulletDialog
sl@0
    66
//
sl@0
    67
sl@0
    68
CWordBulletDialog::CWordBulletDialog(TBullet* aBullet,TRgb aBackColor, CPrinterDevice* ,const TDesC& aFontName)
sl@0
    69
	:iFontName(aFontName)
sl@0
    70
	{
sl@0
    71
	iWordBullet=aBullet;
sl@0
    72
	iBullet=*aBullet;
sl@0
    73
	iBackColor=aBackColor;
sl@0
    74
	}
sl@0
    75
sl@0
    76
CWordBulletDialog::~CWordBulletDialog()
sl@0
    77
	{
sl@0
    78
	}
sl@0
    79
sl@0
    80
void CWordBulletDialog::PreLayoutDynInitL()
sl@0
    81
	{
sl@0
    82
	CEikCharMap* charMap = STATIC_CAST(CEikCharMap*, Control(EWordCidBulletCharMap));
sl@0
    83
	charMap->SetChar(iBullet.iCharacterCode);
sl@0
    84
	charMap->DrawNow();
sl@0
    85
	}
sl@0
    86
sl@0
    87
void CWordBulletDialog::HandleControlStateChangeL(TInt aControlId)
sl@0
    88
	{
sl@0
    89
	if (aControlId == EWordCidBulletCharMap)
sl@0
    90
		{
sl@0
    91
		const TUint charCode = STATIC_CAST(CEikCharMap*, Control(EWordCidBulletCharMap))->GetChar();
sl@0
    92
		iBullet.iCharacterCode = (TText)charCode;
sl@0
    93
		}
sl@0
    94
	}
sl@0
    95
sl@0
    96
TBool CWordBulletDialog::OkToExitL(TInt aButtonId)
sl@0
    97
	{
sl@0
    98
	if (aButtonId==EWordCidFormatBullet)
sl@0
    99
		{
sl@0
   100
		CEikDialog* dialog=new(ELeave) CWordBulletFormatDialog(&iBullet,iBackColor,NULL,iFontName);
sl@0
   101
		dialog->ExecuteLD(R_WORD_DIALOG_FORMAT_BULLET);
sl@0
   102
		return EFalse;
sl@0
   103
		}
sl@0
   104
	*iWordBullet=iBullet;
sl@0
   105
	return ETrue;
sl@0
   106
	}
sl@0
   107
sl@0
   108
//
sl@0
   109
// class CWordBulletFormatDialog
sl@0
   110
//
sl@0
   111
sl@0
   112
CWordBulletFormatDialog::CWordBulletFormatDialog(TBullet* aBullet,TRgb aBackColor, CPrinterDevice* ,const TDesC& aFontName)
sl@0
   113
	:iFontName(aFontName)
sl@0
   114
	{
sl@0
   115
	iWordBullet=aBullet;
sl@0
   116
	iBullet=*aBullet;
sl@0
   117
	iBackColor=aBackColor;
sl@0
   118
	}
sl@0
   119
sl@0
   120
CWordBulletFormatDialog::~CWordBulletFormatDialog()
sl@0
   121
	{
sl@0
   122
	delete iTwipsList;
sl@0
   123
	}
sl@0
   124
sl@0
   125
SEikControlInfo CWordBulletFormatDialog::CreateCustomControlL(TInt aControlType)
sl@0
   126
	{
sl@0
   127
	SEikControlInfo info;
sl@0
   128
    info.iControl=NULL;
sl@0
   129
	info.iTrailerTextId=0;
sl@0
   130
	info.iFlags=EEikControlIsNonFocusing;
sl@0
   131
	if (aControlType==EWordCtBulletPreviewLabel)
sl@0
   132
		info.iControl=new(ELeave) CWordBulletPreviewLabel;
sl@0
   133
	return info;
sl@0
   134
	}
sl@0
   135
sl@0
   136
void CWordBulletFormatDialog::PreLayoutDynInitL()
sl@0
   137
	{
sl@0
   138
	CWordBulletPreviewLabel* label=(CWordBulletPreviewLabel*)Control(EWordCidBulletCharacter);
sl@0
   139
	label->iBrushColor=iBackColor;
sl@0
   140
	label->iTextColor=iBullet.iColor;
sl@0
   141
	TFontSpec fontSpec;
sl@0
   142
	fontSpec.iHeight=iBullet.iHeightInTwips;
sl@0
   143
	fontSpec.iTypeface.iName=_L("Swiss");
sl@0
   144
	label->SetFontSpecL(fontSpec);
sl@0
   145
	SetPreviewLabelL(iBullet.iCharacterCode);
sl@0
   146
	SetGraySelectorColor(EWordCidBulletColor,iBullet.iColor);
sl@0
   147
	iTwipsList=new(ELeave) CArrayFixFlat<TInt>(4);
sl@0
   148
	iPointsList=new(ELeave) CDesCArrayFlat(4);
sl@0
   149
	FontUtils::GetAvailableHeightsInTwipsAndPointsL(*iCoeEnv->ScreenDevice(),iFontName,*iTwipsList,*iPointsList);
sl@0
   150
	CEikChoiceList* chlst=(CEikChoiceList*)Control(EWordCidBulletHeight);
sl@0
   151
	chlst->SetArrayL(iPointsList);
sl@0
   152
	chlst->SetArrayExternalOwnership(EFalse);
sl@0
   153
	const TInt index = FontUtils::IndexOfNearestHeight(*iTwipsList, iBullet.iHeightInTwips);
sl@0
   154
	chlst->SetCurrentItem(index);
sl@0
   155
	CEikButtonBase::TState state=(iBullet.iHangingIndent? CEikButtonBase::ESet : CEikButtonBase::EClear);
sl@0
   156
	SetCheckBoxState(EWordCidBulletIndent,state);
sl@0
   157
	}
sl@0
   158
sl@0
   159
void CWordBulletFormatDialog::SetPreviewLabelL(TUint aCharCode)
sl@0
   160
	{
sl@0
   161
	TChar bullet(aCharCode);
sl@0
   162
	TBuf<1> buf;
sl@0
   163
	buf.Append(bullet);
sl@0
   164
	SetLabelL(EWordCidBulletCharacter,buf);
sl@0
   165
	}
sl@0
   166
sl@0
   167
void CWordBulletFormatDialog::HandleControlStateChangeL(TInt aControlId)
sl@0
   168
	{
sl@0
   169
	switch (aControlId)
sl@0
   170
		{
sl@0
   171
	case EWordCidBulletColor:
sl@0
   172
		{
sl@0
   173
		const TRgb color=GraySelectorColor(EWordCidBulletColor);
sl@0
   174
		CWordBulletPreviewLabel* label=(CWordBulletPreviewLabel*)Control(EWordCidBulletCharacter);
sl@0
   175
		label->iTextColor=color;
sl@0
   176
		label->DrawNow();
sl@0
   177
		iBullet.iColor=color;
sl@0
   178
		break;
sl@0
   179
		}
sl@0
   180
	case EWordCidBulletHeight:
sl@0
   181
		{
sl@0
   182
		const TInt height=(*iTwipsList)[ChoiceListCurrentItem(EWordCidBulletHeight)];
sl@0
   183
		iBullet.iHeightInTwips=height;
sl@0
   184
		TFontSpec fontSpec;
sl@0
   185
		CWordBulletPreviewLabel* label=(CWordBulletPreviewLabel*)Control(EWordCidBulletCharacter);
sl@0
   186
		fontSpec.iHeight=height;
sl@0
   187
		fontSpec.iTypeface.iName=_L("Swiss");
sl@0
   188
		label->SetFontSpecL(fontSpec);
sl@0
   189
		label->DrawNow();
sl@0
   190
		break;
sl@0
   191
		}
sl@0
   192
	case EWordCidBulletIndent:
sl@0
   193
		iBullet.iHangingIndent=(CheckBoxState(EWordCidBulletIndent)==CEikButtonBase::ESet);
sl@0
   194
		break;
sl@0
   195
	default:
sl@0
   196
		;
sl@0
   197
		}
sl@0
   198
	}
sl@0
   199
sl@0
   200
TBool CWordBulletFormatDialog::OkToExitL(TInt /*aButtonId*/)
sl@0
   201
	{
sl@0
   202
	*iWordBullet=iBullet;
sl@0
   203
	return ETrue;
sl@0
   204
	}
sl@0
   205
sl@0
   206
//
sl@0
   207
// class CWordBulletPreviewLabel
sl@0
   208
//
sl@0
   209
sl@0
   210
CWordBulletPreviewLabel::CWordBulletPreviewLabel()
sl@0
   211
	{}
sl@0
   212
sl@0
   213
CWordBulletPreviewLabel::~CWordBulletPreviewLabel()
sl@0
   214
	{
sl@0
   215
	iCoeEnv->ReleaseScreenFont(CONST_CAST(CFont*,iPrevFont));
sl@0
   216
	}
sl@0
   217
sl@0
   218
void CWordBulletPreviewLabel::SetFontSpecL(TFontSpec& aFontSpec)
sl@0
   219
	{
sl@0
   220
	iCoeEnv->ReleaseScreenFont(CONST_CAST(CFont*,iPrevFont));
sl@0
   221
	iPrevFont=iCoeEnv->CreateScreenFontL(aFontSpec);
sl@0
   222
	}
sl@0
   223
sl@0
   224
TSize CWordBulletPreviewLabel::MinimumSize()
sl@0
   225
	{
sl@0
   226
	return TSize(40,40); // an attempt to make label big enough for most font heights
sl@0
   227
	}
sl@0
   228
sl@0
   229
void CWordBulletPreviewLabel::Draw(const TRect& /*aRect*/) const
sl@0
   230
	{
sl@0
   231
	CWindowGc& gc=SystemGc();
sl@0
   232
	gc.UseFont(iPrevFont);
sl@0
   233
	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   234
	gc.SetBrushColor(iBrushColor);
sl@0
   235
	gc.SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   236
	gc.SetPenColor(iTextColor);
sl@0
   237
	const TInt ascent=iPrevFont->AscentInPixels();
sl@0
   238
	const TRect rect(Rect());
sl@0
   239
	const TInt baselineOffset=ascent+((rect.Height()-ascent)/2);
sl@0
   240
	gc.DrawText(*iText,rect,baselineOffset,CGraphicsContext::ECenter);
sl@0
   241
	}
sl@0
   242
sl@0
   243
//
sl@0
   244
// class CWordGoToDialog
sl@0
   245
//
sl@0
   246
sl@0
   247
CWordGoToDialog::CWordGoToDialog(TInt aMaxPages, TInt* aCurrentPage)
sl@0
   248
    {
sl@0
   249
	iMaxPages=aMaxPages;
sl@0
   250
	iCurrentPage=aCurrentPage;
sl@0
   251
    }
sl@0
   252
    
sl@0
   253
void CWordGoToDialog::PreLayoutDynInitL()
sl@0
   254
	{
sl@0
   255
	SetNumberEditorMinAndMax(EWordCidPageNumber,1,iMaxPages);
sl@0
   256
	SetNumberEditorValue(EWordCidPageNumber,*iCurrentPage);
sl@0
   257
sl@0
   258
	TBuf<10> buf;
sl@0
   259
	buf.Num(iMaxPages);
sl@0
   260
    SetLabelL(EWordCidPages, buf);
sl@0
   261
	}
sl@0
   262
sl@0
   263
TBool CWordGoToDialog::OkToExitL(TInt /*aButtonId*/)
sl@0
   264
	{
sl@0
   265
	*iCurrentPage=NumberEditorValue(EWordCidPageNumber);
sl@0
   266
	return(ETrue);
sl@0
   267
	}
sl@0
   268
sl@0
   269
//
sl@0
   270
//	CWordViewPreferencesDialog
sl@0
   271
//
sl@0
   272
sl@0
   273
CWordViewPreferencesDialog::CWordViewPreferencesDialog(TNonPrintingCharVisibility& aVisibility)
sl@0
   274
	: iVisibility(aVisibility)
sl@0
   275
	{}
sl@0
   276
sl@0
   277
void CWordViewPreferencesDialog::PreLayoutDynInitL()
sl@0
   278
	{
sl@0
   279
	CEikButtonBase::TState button=CEikButtonBase::EClear;
sl@0
   280
	//tabs
sl@0
   281
	button=(iVisibility.TabsVisible())?CEikButtonBase::ESet : CEikButtonBase::EClear;	
sl@0
   282
	SetCheckBoxState(EWordCidTab,button);
sl@0
   283
	//spaces
sl@0
   284
	button=(iVisibility.SpacesVisible())?CEikButtonBase::ESet : CEikButtonBase::EClear;		
sl@0
   285
	SetCheckBoxState(EWordCidSpaces,button);
sl@0
   286
	//paragraph ends
sl@0
   287
	button=(iVisibility.ParagraphDelimitersVisible())?CEikButtonBase::ESet : CEikButtonBase::EClear;		
sl@0
   288
	SetCheckBoxState(EWordCidParaEnds,button);
sl@0
   289
	//hyphens
sl@0
   290
	button=(iVisibility.NonBreakingHyphensVisible())?CEikButtonBase::ESet : CEikButtonBase::EClear;		
sl@0
   291
	SetCheckBoxState(EWordCidHardHyphens,button);
sl@0
   292
	//line breaks
sl@0
   293
	button=(iVisibility.LineBreaksVisible())?CEikButtonBase::ESet : CEikButtonBase::EClear;		
sl@0
   294
	SetCheckBoxState(EWordCidForcedLineBreaks,button);
sl@0
   295
	//nonbreaking spaces
sl@0
   296
	button=(iVisibility.NonBreakingSpacesVisible())?CEikButtonBase::ESet : CEikButtonBase::EClear;		
sl@0
   297
	SetCheckBoxState(EWordCidNonBreakingSpace,button);
sl@0
   298
	}
sl@0
   299
sl@0
   300
void CWordViewPreferencesDialog::WordSetCheckBoxState(CEikButtonBase::TState aState)
sl@0
   301
	{
sl@0
   302
	SetCheckBoxState(EWordCidTab,aState);
sl@0
   303
	SetCheckBoxState(EWordCidSpaces,aState);
sl@0
   304
	SetCheckBoxState(EWordCidParaEnds,aState);
sl@0
   305
	SetCheckBoxState(EWordCidHardHyphens,aState);
sl@0
   306
	SetCheckBoxState(EWordCidForcedLineBreaks,aState);
sl@0
   307
	SetCheckBoxState(EWordCidNonBreakingSpace,aState);
sl@0
   308
	} 												  
sl@0
   309
sl@0
   310
TBool CWordViewPreferencesDialog::OkToExitL(TInt /*aButtonId*/)
sl@0
   311
	{
sl@0
   312
	TBool visible;
sl@0
   313
	CEikButtonBase::TState button=CEikButtonBase::EClear;
sl@0
   314
	//tabs
sl@0
   315
	button=CheckBoxState(EWordCidTab);
sl@0
   316
	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
sl@0
   317
	iVisibility.SetTabsVisible(visible);
sl@0
   318
	//spaces
sl@0
   319
	button=CheckBoxState(EWordCidSpaces);
sl@0
   320
	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
sl@0
   321
	iVisibility.SetSpacesVisible(visible);
sl@0
   322
	//paragraph ends
sl@0
   323
	button=CheckBoxState(EWordCidParaEnds);
sl@0
   324
	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
sl@0
   325
	iVisibility.SetParagraphDelimitersVisible(visible);
sl@0
   326
	//hyphens
sl@0
   327
	button=CheckBoxState(EWordCidHardHyphens);
sl@0
   328
	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
sl@0
   329
	iVisibility.SetNonBreakingHyphensVisible(visible);
sl@0
   330
	//line breaks
sl@0
   331
	button=CheckBoxState(EWordCidForcedLineBreaks);
sl@0
   332
	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
sl@0
   333
	iVisibility.SetLineBreaksVisible(visible);
sl@0
   334
	//nonbreaking spaces
sl@0
   335
	button=CheckBoxState(EWordCidNonBreakingSpace);
sl@0
   336
	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
sl@0
   337
	iVisibility.SetNonBreakingSpacesVisible(visible);
sl@0
   338
	//
sl@0
   339
	return ETrue;
sl@0
   340
	}
sl@0
   341
sl@0
   342
sl@0
   343
sl@0
   344
//
sl@0
   345
//	CWordObjectPreferencesDialog & Revert To Style dialog
sl@0
   346
//
sl@0
   347
sl@0
   348
CWordObjectPreferencesDialog::CWordObjectPreferencesDialog(TBool& aSketchAsGlass,TBool& aGraphAsGlass/*,TInt aButton*/)
sl@0
   349
	: iSketchAsGlass(aSketchAsGlass),iGraphAsGlass(aGraphAsGlass)/*,iButton(aButton)*/
sl@0
   350
	{}
sl@0
   351
sl@0
   352
void CWordObjectPreferencesDialog::PreLayoutDynInitL()
sl@0
   353
	{
sl@0
   354
//	//
sl@0
   355
//	// Change the dialog text as appropriate
sl@0
   356
//	if (!iObjectPreferenceDialog)
sl@0
   357
//		{
sl@0
   358
///		SetTitleL(R_WORD_STYLE_REVERT_TITLE);
sl@0
   359
//
sl@0
   360
///		}
sl@0
   361
sl@0
   362
	CEikButtonBase::TState button=CEikButtonBase::EClear;
sl@0
   363
	//
sl@0
   364
	// Sketch as glass
sl@0
   365
	button=(iSketchAsGlass) ? CEikButtonBase::EClear : CEikButtonBase::ESet;
sl@0
   366
	SetCheckBoxState(EWordCidShowSketch,button);
sl@0
   367
	// graph as glass
sl@0
   368
	button=(iGraphAsGlass) ? CEikButtonBase::EClear : CEikButtonBase::ESet;
sl@0
   369
	SetCheckBoxState(EWordCidShowGraph,button);
sl@0
   370
	}
sl@0
   371
sl@0
   372
void CWordObjectPreferencesDialog::WordSetCheckBoxState(CEikButtonBase::TState aState)
sl@0
   373
	{
sl@0
   374
	SetCheckBoxState(EWordCidShowSketch,aState);
sl@0
   375
	SetCheckBoxState(EWordCidShowGraph,aState);
sl@0
   376
	} 												  
sl@0
   377
sl@0
   378
TBool CWordObjectPreferencesDialog::OkToExitL(TInt /*aButtonId*/)
sl@0
   379
	{
sl@0
   380
	TBool visible;
sl@0
   381
	CEikButtonBase::TState button=CEikButtonBase::EClear;
sl@0
   382
	//
sl@0
   383
	// sketch as glass
sl@0
   384
	button=CheckBoxState(EWordCidShowSketch);
sl@0
   385
	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
sl@0
   386
	iSketchAsGlass=!visible;
sl@0
   387
	// graph as glass
sl@0
   388
	button=CheckBoxState(EWordCidShowGraph);
sl@0
   389
	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
sl@0
   390
	iGraphAsGlass=!visible;
sl@0
   391
	//
sl@0
   392
	return ETrue;
sl@0
   393
	}
sl@0
   394
sl@0
   395
//
sl@0
   396
//	CWordObjectPreferencesDialog & Revert To Style dialog
sl@0
   397
//
sl@0
   398
sl@0
   399
CWordRevertToStyleDialog::CWordRevertToStyleDialog(TBool& aSketchAsGlass,TBool& aGraphAsGlass)
sl@0
   400
	: iSketchAsGlass(aSketchAsGlass),iGraphAsGlass(aGraphAsGlass)
sl@0
   401
	{}
sl@0
   402
sl@0
   403
void CWordRevertToStyleDialog::PreLayoutDynInitL()
sl@0
   404
	{
sl@0
   405
//	//
sl@0
   406
//	// Change the dialog text as appropriate
sl@0
   407
//	if (!iObjectPreferenceDialog)
sl@0
   408
//		{
sl@0
   409
///		SetTitleL(R_WORD_STYLE_REVERT_TITLE);
sl@0
   410
//
sl@0
   411
///		}
sl@0
   412
sl@0
   413
	CEikButtonBase::TState button=CEikButtonBase::EClear;
sl@0
   414
	//
sl@0
   415
	// Sketch as glass
sl@0
   416
	button=(iSketchAsGlass) ? CEikButtonBase::ESet : CEikButtonBase::EClear;
sl@0
   417
	SetCheckBoxState(EWordCidRemoveChar,button);
sl@0
   418
	// graph as glass
sl@0
   419
	button=(iGraphAsGlass) ? CEikButtonBase::ESet : CEikButtonBase::EClear;
sl@0
   420
	SetCheckBoxState(EWordCidRemovePara,button);
sl@0
   421
	}
sl@0
   422
sl@0
   423
void CWordRevertToStyleDialog::WordSetCheckBoxState(CEikButtonBase::TState aState)
sl@0
   424
	{
sl@0
   425
	SetCheckBoxState(EWordCidRemoveChar,aState);
sl@0
   426
	SetCheckBoxState(EWordCidRemovePara,aState);
sl@0
   427
	} 												  
sl@0
   428
sl@0
   429
TBool CWordRevertToStyleDialog::OkToExitL(TInt /*aButtonId*/)
sl@0
   430
	{
sl@0
   431
	TBool visible;
sl@0
   432
	CEikButtonBase::TState button=CEikButtonBase::EClear;
sl@0
   433
	//
sl@0
   434
	// sketch as glass
sl@0
   435
	button=CheckBoxState(EWordCidRemoveChar);
sl@0
   436
	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
sl@0
   437
	iSketchAsGlass=visible;
sl@0
   438
	// graph as glass
sl@0
   439
	button=CheckBoxState(EWordCidRemovePara);
sl@0
   440
	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
sl@0
   441
	iGraphAsGlass=visible;
sl@0
   442
	//
sl@0
   443
	return ETrue;
sl@0
   444
	}
sl@0
   445
sl@0
   446
//
sl@0
   447
// Manual zoom setting dialog
sl@0
   448
// 
sl@0
   449
sl@0
   450
CWordTempManualZoomDialog::CWordTempManualZoomDialog(TInt& aOrigZoomFactor)
sl@0
   451
	: iOrigZoomFactor(aOrigZoomFactor)
sl@0
   452
	{__ASSERT_DEBUG(iOrigZoomFactor>0,Panic(EWordZeroZoomFactor));}
sl@0
   453
sl@0
   454
sl@0
   455
void CWordTempManualZoomDialog::PreLayoutDynInitL()
sl@0
   456
	{
sl@0
   457
	// set the control with the current zoom factor
sl@0
   458
	__ASSERT_DEBUG(iOrigZoomFactor>0,Panic(EWordZeroZoomFactor));
sl@0
   459
	SetNumberEditorValue(EWordCidZoomSet,iOrigZoomFactor/10);
sl@0
   460
	}
sl@0
   461
sl@0
   462
sl@0
   463
TBool CWordTempManualZoomDialog::OkToExitL(TInt /*aButtonId*/)
sl@0
   464
	{
sl@0
   465
	iOrigZoomFactor=(NumberEditorValue(EWordCidZoomSet))*10;
sl@0
   466
	return ETrue;
sl@0
   467
	}
sl@0
   468
sl@0
   469
sl@0
   470
//
sl@0
   471
// Custom File Open dialog
sl@0
   472
//
sl@0
   473
sl@0
   474
sl@0
   475
CWordFileOpenDialog::CWordFileOpenDialog(TDes* aFileName,TBool& aReadOnly,TInt aTitleId)
sl@0
   476
	: CEikFileOpenDialog(aFileName,aTitleId),
sl@0
   477
	  iReadOnly(aReadOnly)
sl@0
   478
    {
sl@0
   479
	__DECLARE_NAME(_S("CWordFileOpenDialog"));
sl@0
   480
    }
sl@0
   481
sl@0
   482
sl@0
   483
void CWordFileOpenDialog::HandleControlStateChangeL(TInt)
sl@0
   484
	{
sl@0
   485
	}
sl@0
   486
sl@0
   487
TBool CWordFileOpenDialog::OkToExitL(TInt aButtonId)
sl@0
   488
    {
sl@0
   489
	if (CEikFileOpenDialog::OkToExitL(aButtonId))
sl@0
   490
		{
sl@0
   491
		iReadOnly=CheckBoxState(EWordCidReadOnly)==CEikButtonBase::ESet;
sl@0
   492
		return ETrue;
sl@0
   493
		}
sl@0
   494
	else return EFalse;
sl@0
   495
    }
sl@0
   496
sl@0
   497
//
sl@0
   498
// Custom File New dialog with templates
sl@0
   499
//
sl@0
   500
sl@0
   501
CWordTemplateNewFileDialog::CWordTemplateNewFileDialog(TDes* aFileName, TFileName& aTemplateFileName, TUidType aUid)
sl@0
   502
	: CEikFileSaveAsDialog(aFileName,NULL,R_EIK_TBUF_CREATE_NEW_FILE), iTemplateFileName(aTemplateFileName),
sl@0
   503
		iUid(aUid)
sl@0
   504
	{
sl@0
   505
	}
sl@0
   506
sl@0
   507
TBool CWordTemplateNewFileDialog::OkToExitL(TInt aButtonId)
sl@0
   508
	{
sl@0
   509
	if(!CEikFileSaveAsDialog::OkToExitL(aButtonId))
sl@0
   510
		return EFalse;
sl@0
   511
	// Check to see if the template is still there
sl@0
   512
	CEikUnifiedFileNameSelector* templateFileNameSel = (CEikUnifiedFileNameSelector*) (Control(EEikCtUnifiedFileSel));
sl@0
   513
	iTemplateFileName = templateFileNameSel->FullName();
sl@0
   514
	if(ConeUtils::FileExists(iTemplateFileName))
sl@0
   515
		return ETrue;
sl@0
   516
	else
sl@0
   517
		{
sl@0
   518
		iEikonEnv->InfoMsg(R_WORD_TEMPLATE_NOT_AVAILABLE);
sl@0
   519
		return EFalse;
sl@0
   520
		}
sl@0
   521
	}
sl@0
   522
sl@0
   523
void CWordTemplateNewFileDialog::PreLayoutDynInitL()
sl@0
   524
	{
sl@0
   525
	CEikFileSaveAsDialog::PreLayoutDynInitL();
sl@0
   526
	TFileName templateFileName;
sl@0
   527
	TWordFilePath::GetNormalTemplateFolderName(templateFileName);
sl@0
   528
	TFileName tempFileName;
sl@0
   529
	TFindFile ff(iEikonEnv->FsSession());
sl@0
   530
sl@0
   531
	iEikonEnv->ReadResource(tempFileName, R_WORD_NORMAL_TEMPLATE_FILE_NAME);
sl@0
   532
	templateFileName.Append(tempFileName);
sl@0
   533
	templateFileName[0] = 'Y';
sl@0
   534
	TParsePtr parse(templateFileName);
sl@0
   535
	TInt err = ff.FindByDir(parse.NameAndExt(),parse.DriveAndPath());
sl@0
   536
	if(err)
sl@0
   537
		{
sl@0
   538
		// no normal template, search ROM for blank
sl@0
   539
		TWordFilePath::GetNormalTemplateFolderName(templateFileName);
sl@0
   540
		iEikonEnv->ReadResource(tempFileName, R_WORD_BLANK_TEMPLATE_FILE_NAME);
sl@0
   541
		templateFileName.Append(tempFileName);
sl@0
   542
		templateFileName[0] = 'Z';
sl@0
   543
		TParsePtr blankParse(templateFileName);
sl@0
   544
		User::LeaveIfError(ff.FindByDir(blankParse.NameAndExt(),blankParse.DriveAndPath()));
sl@0
   545
		}
sl@0
   546
	templateFileName = ff.File();
sl@0
   547
	
sl@0
   548
	CEikUnifiedFileNameSelector* templateFileNameSel = (CEikUnifiedFileNameSelector*) (Control(EEikCtUnifiedFileSel));
sl@0
   549
	templateFileNameSel->SetUidType(iUid);
sl@0
   550
	templateFileNameSel->SetROMIncluded(ETrue);
sl@0
   551
	templateFileNameSel->SetFullNameL(templateFileName);	
sl@0
   552
	}
sl@0
   553
sl@0
   554
SEikControlInfo CWordTemplateNewFileDialog::CreateCustomControlL(TInt aControlType)
sl@0
   555
	{
sl@0
   556
	SEikControlInfo controlInfo;
sl@0
   557
	controlInfo.iControl=NULL;
sl@0
   558
	controlInfo.iTrailerTextId=0;
sl@0
   559
	controlInfo.iFlags=0;
sl@0
   560
sl@0
   561
	switch(aControlType)
sl@0
   562
		{
sl@0
   563
	case EWordUnifiedFileNameSelector:
sl@0
   564
		{
sl@0
   565
		CWordUnifiedFileSelector* newControl = new(ELeave) CWordUnifiedFileSelector();
sl@0
   566
		controlInfo.iControl = newControl;
sl@0
   567
		controlInfo.iFlags = EEikControlHasEars;
sl@0
   568
		break;
sl@0
   569
		}
sl@0
   570
	default:
sl@0
   571
		break;
sl@0
   572
		}
sl@0
   573
	return controlInfo;
sl@0
   574
	}
sl@0
   575
sl@0
   576
//
sl@0
   577
// class CWordUnifiedFileSelector file selector with sorting
sl@0
   578
// 
sl@0
   579
sl@0
   580
void CWordUnifiedFileSelector::SortArray(MDesCArray* aFileNames)
sl@0
   581
	{
sl@0
   582
	TFileName blank;
sl@0
   583
	iEikonEnv->ReadResource(blank, R_WORD_BLANK_TEMPLATE_FILE_NAME);
sl@0
   584
	TInt count = aFileNames->MdcaCount();
sl@0
   585
	for (TInt i = 0 ; i < count; i++)
sl@0
   586
		{
sl@0
   587
		if (aFileNames->MdcaPoint(i) == blank)
sl@0
   588
			{
sl@0
   589
			if (i == 0)
sl@0
   590
				break;
sl@0
   591
			CDesCArray* array = STATIC_CAST(CDesCArray*,aFileNames);
sl@0
   592
			TRAPD(err,array->InsertL(0, blank)); // top
sl@0
   593
			if (err == KErrNone)
sl@0
   594
				{
sl@0
   595
				array->Delete(++i);
sl@0
   596
				}
sl@0
   597
			break;
sl@0
   598
			}
sl@0
   599
		}
sl@0
   600
	}
sl@0
   601
sl@0
   602
void CWordUnifiedFileSelector::BuildFileNameArrayL(const TParse& aParse, MDesCArray* aFileNames)
sl@0
   603
	{
sl@0
   604
	CEikUnifiedFileNameSelector::BuildFileNameArrayL(aParse, aFileNames);
sl@0
   605
	SortArray(aFileNames);
sl@0
   606
	}
sl@0
   607
sl@0
   608
//
sl@0
   609
// class CWordDeleteTemplateDialog
sl@0
   610
//
sl@0
   611
sl@0
   612
CWordDeleteTemplateDialog::CWordDeleteTemplateDialog(TFileName& aTemplateFileName, TUidType aUid)
sl@0
   613
	: iTemplateFileName(aTemplateFileName), iUid(aUid)
sl@0
   614
	{
sl@0
   615
	}
sl@0
   616
sl@0
   617
TBool CWordDeleteTemplateDialog::OkToExitL(TInt /*aButtonId*/)
sl@0
   618
	{
sl@0
   619
	CEikUnifiedFileNameSelector* templateFileNameSel = STATIC_CAST(CEikUnifiedFileNameSelector*,(Control(EEikCtUnifiedFileSel)));
sl@0
   620
	iTemplateFileName = templateFileNameSel->FullName();
sl@0
   621
	
sl@0
   622
	if (!iTemplateFileName.Length())
sl@0
   623
		return ETrue;
sl@0
   624
sl@0
   625
	// Confirm this is what the user really wants
sl@0
   626
	TParsePtrC parse(iTemplateFileName);
sl@0
   627
	TFileName confirmPre;
sl@0
   628
	TBuf<30> confirmPost;
sl@0
   629
	iEikonEnv->ReadResource(confirmPre, R_WORD_TEMPLATE_DELETE_CONFIRMATION_PRE);
sl@0
   630
	iEikonEnv->ReadResource(confirmPost, R_WORD_TEMPLATE_DELETE_CONFIRMATION_POST);
sl@0
   631
	TInt gap = 60 - confirmPre.Length() - confirmPost.Length();
sl@0
   632
	if (parse.NameAndExt().Length() > gap)
sl@0
   633
		{
sl@0
   634
		TFileName name = parse.NameAndExt();
sl@0
   635
		confirmPre.Append(name.Left(gap - 1));
sl@0
   636
		confirmPre.Append((TChar)KEllipsis);
sl@0
   637
		}
sl@0
   638
	else
sl@0
   639
		confirmPre.Append(parse.NameAndExt());
sl@0
   640
	confirmPre.Append(confirmPost);
sl@0
   641
	confirmPost = _L("");
sl@0
   642
		
sl@0
   643
	if (!iEikonEnv->QueryWinL(confirmPre, confirmPost))
sl@0
   644
		iTemplateFileName = TFileName();
sl@0
   645
	return ETrue;
sl@0
   646
	}
sl@0
   647
sl@0
   648
void CWordDeleteTemplateDialog::PreLayoutDynInitL()
sl@0
   649
	{
sl@0
   650
	CEikUnifiedFileNameSelector* templateFileNameSel = STATIC_CAST(CEikUnifiedFileNameSelector*,(Control(EEikCtUnifiedFileSel)));
sl@0
   651
	templateFileNameSel->SetUidType(iUid);
sl@0
   652
	templateFileNameSel->SetROMIncluded(EFalse);
sl@0
   653
	templateFileNameSel->SetFullNameL(iTemplateFileName);
sl@0
   654
	}
sl@0
   655
sl@0
   656
//
sl@0
   657
// class CWordSaveAsTemplateDialog
sl@0
   658
//
sl@0
   659
sl@0
   660
CWordSaveAsTemplateDialog::CWordSaveAsTemplateDialog(TFileName& aTemplateFileName, TUidType aUid)
sl@0
   661
	: iTemplateFileName(aTemplateFileName), iUid(aUid)
sl@0
   662
	{
sl@0
   663
	}
sl@0
   664
sl@0
   665
TBool CWordSaveAsTemplateDialog::OkToExitL(TInt /*aButtonId*/)
sl@0
   666
	{
sl@0
   667
	CEikFileNameEditor* templateFileNameEd = STATIC_CAST(CEikFileNameEditor*,(Control(EEikCidFileNameEd)));
sl@0
   668
	CEikDriveNameSelector *driveNameSelector = STATIC_CAST(CEikDriveNameSelector*,(Control(EEikCidDriveNameSel)));
sl@0
   669
	templateFileNameEd->GetFullNameL(iTemplateFileName);
sl@0
   670
sl@0
   671
	TFileName drivename = driveNameSelector->FullName();
sl@0
   672
	TParse parse;
sl@0
   673
	User::LeaveIfError(parse.Set(drivename, &iTemplateFileName,NULL));
sl@0
   674
	iTemplateFileName = parse.FullName();
sl@0
   675
	TBool doNotReplaceExistingFile = EFalse;
sl@0
   676
	TUint attributes = 0;
sl@0
   677
	if (ConeUtils::FileExists(iTemplateFileName))
sl@0
   678
		{
sl@0
   679
		TBuf<32> infoDialogTitle;
sl@0
   680
		iEikonEnv->ReadResource(infoDialogTitle, R_EIK_TBUF_DIALOG_TITLE_CONFIRM_FILE_REPLACE);
sl@0
   681
		TBuf<KShortErrorMessageLength> formatStr;
sl@0
   682
		User::LeaveIfError(iEikonEnv->FsSession().Att(iTemplateFileName, attributes));
sl@0
   683
		if (attributes & KEntryAttReadOnly)
sl@0
   684
			iEikonEnv->LeaveWithInfoMsg(R_EIK_TBUF_CANNOT_REPLACE_READONLY_FILE);
sl@0
   685
		else
sl@0
   686
			iEikonEnv->ReadResource(formatStr, R_EIK_TBUF_FILE_REPLACE_CONFIRM1);
sl@0
   687
		TBuf<KMaxDisplayedFullNameLen> abbrevName;
sl@0
   688
		User::LeaveIfError(EikFileUtils::Parse(iTemplateFileName));
sl@0
   689
		TParsePtr parse(iTemplateFileName);
sl@0
   690
		EikFileUtils::AbbreviateFileName(parse.NameAndExt(), abbrevName);
sl@0
   691
		TBuf<KShortErrorMessageLength + KMaxDisplayedFullNameLen> textMsg;
sl@0
   692
		textMsg.Format(formatStr, &abbrevName);
sl@0
   693
		CEikDialog* infoDialog = new(ELeave) CEikInfoDialog(infoDialogTitle, textMsg,CEikInfoDialog::EIgnoreEnter);
sl@0
   694
		if (!(infoDialog->ExecuteLD(R_EIK_DIALOG_SINGLE_FILE_REPLACE)))
sl@0
   695
			doNotReplaceExistingFile = ETrue;
sl@0
   696
		}
sl@0
   697
	return !doNotReplaceExistingFile;
sl@0
   698
	}
sl@0
   699
sl@0
   700
void CWordSaveAsTemplateDialog::PreLayoutDynInitL()
sl@0
   701
	{
sl@0
   702
	TFileName templateFileName;
sl@0
   703
	TWordFilePath::GetNormalTemplateFolderName(templateFileName);
sl@0
   704
sl@0
   705
	CEikFileNameEditor* templateFileNameEd = STATIC_CAST(CEikFileNameEditor*,(Control(EEikCidFileNameEd)));
sl@0
   706
	CEikDriveNameSelector *driveNameSelector = STATIC_CAST(CEikDriveNameSelector*,(Control(EEikCidDriveNameSel)));
sl@0
   707
	
sl@0
   708
	templateFileNameEd->SetFullNameL(templateFileName);
sl@0
   709
	
sl@0
   710
	// set drive to be system drive
sl@0
   711
	templateFileName[0] = 'A' + static_cast<TInt>(RFs::GetSystemDrive());
sl@0
   712
	
sl@0
   713
	driveNameSelector->ShowRom(EFalse);
sl@0
   714
	driveNameSelector->SetFullNameL(templateFileName);
sl@0
   715
	}
sl@0
   716
sl@0
   717
// Outline Dialog
sl@0
   718
sl@0
   719
CWordOutlineDialog::CWordOutlineDialog(CRichText* aText, CEikEdwin* aEdWin, TInt& aNewCursorPosition)
sl@0
   720
	:iText(aText), 
sl@0
   721
	iEdWin(aEdWin),
sl@0
   722
	iNewCursorPosition(aNewCursorPosition)
sl@0
   723
{
sl@0
   724
}
sl@0
   725
sl@0
   726
sl@0
   727
sl@0
   728
TBool CWordOutlineDialog::OkToExitL(TInt aButtonId)
sl@0
   729
	{
sl@0
   730
	switch(aButtonId)
sl@0
   731
		{
sl@0
   732
	case EEikBidOk:
sl@0
   733
		iNewCursorPosition = iOutlineNav->OutlineModel()->CurrentCharPosition();
sl@0
   734
		return ETrue;
sl@0
   735
	case EWordBidOpenAll:
sl@0
   736
		iOutlineNav->ExpandAllItemsL();
sl@0
   737
		return EFalse;
sl@0
   738
	case EWordBidCloseAll:
sl@0
   739
		iOutlineNav->CollapseAllItemsL();
sl@0
   740
		return EFalse;
sl@0
   741
	default:
sl@0
   742
		return EFalse;
sl@0
   743
		}
sl@0
   744
	}
sl@0
   745
sl@0
   746
sl@0
   747
SEikControlInfo CWordOutlineDialog::CreateCustomControlL(TInt aControlType)
sl@0
   748
	{
sl@0
   749
	SEikControlInfo controlInfo;
sl@0
   750
	controlInfo.iControl=NULL;
sl@0
   751
	controlInfo.iTrailerTextId=0;
sl@0
   752
	controlInfo.iFlags=0;
sl@0
   753
sl@0
   754
	COutlineHListBox* newControl;
sl@0
   755
sl@0
   756
	switch(aControlType)
sl@0
   757
		{
sl@0
   758
	case EWordCtOutlineNav:
sl@0
   759
		newControl = new(ELeave)COutlineHListBox(iText,iEdWin->CursorPos());
sl@0
   760
		controlInfo.iControl = newControl;
sl@0
   761
		iOutlineNav = newControl;
sl@0
   762
		break;
sl@0
   763
	default:
sl@0
   764
		break;
sl@0
   765
		}
sl@0
   766
	return controlInfo;
sl@0
   767
	}