os/textandloc/textrendering/word/SRC/WPDIALGS.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/textrendering/word/SRC/WPDIALGS.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,767 @@
     1.4 +/*
     1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include <frmvis.h>
    1.23 +
    1.24 +#include <prninf.h>
    1.25 +#include <prnsetup.h>
    1.26 +
    1.27 +#include <badesca.h>
    1.28 +#include <bamatch.h>
    1.29 +
    1.30 +#include <e32std.h>
    1.31 +
    1.32 +#include <coeutils.h>
    1.33 +
    1.34 +#include <eikenv.h>
    1.35 +#include <eikfctry.h>
    1.36 +#include <techview/eikchlst.h>
    1.37 +#include <techview/eikfprev.h>
    1.38 +#include <techview/eikbtpan.h>
    1.39 +#include <techview/eikcmbut.h>
    1.40 +#include <techview/eikchkbx.h>
    1.41 +#include <techview/eikfpne.h>
    1.42 +#include <techview/eikcfdlg.h>
    1.43 +#include <techview/eikfsel.h>
    1.44 +#include <techview/eikprtdg.h>
    1.45 +#include <techview/eikinfo.h>
    1.46 +#include <techview/eikon.rsg>
    1.47 +#include <techview/eikfsel.h>
    1.48 +#include <eikfutil.h>
    1.49 +#include <techview/eikdclbm.h>
    1.50 +#include <techview/eikfbrow.h>
    1.51 +#include <techview/eikufsel.h>
    1.52 +#include <techview/eiklbbut.h>
    1.53 +#include <techview/eikchmap.h>
    1.54 +#include <techview/eikbtgpc.h>
    1.55 +
    1.56 +#include "WPOUTLNE.H"
    1.57 +#include "WPDIALGS.H"
    1.58 +#include "WPPANIC.H"
    1.59 +#include "wpresources.h"
    1.60 +#include "WORD.HRH"
    1.61 +#include <word.rsg>
    1.62 +#include "WPMAIN.H"
    1.63 +
    1.64 +const TInt KShortErrorMessageLength = 64;
    1.65 +const TInt KMaxDisplayedFullNameLen	= 35;
    1.66 +
    1.67 +//
    1.68 +// class CWordBulletDialog
    1.69 +//
    1.70 +
    1.71 +CWordBulletDialog::CWordBulletDialog(TBullet* aBullet,TRgb aBackColor, CPrinterDevice* ,const TDesC& aFontName)
    1.72 +	:iFontName(aFontName)
    1.73 +	{
    1.74 +	iWordBullet=aBullet;
    1.75 +	iBullet=*aBullet;
    1.76 +	iBackColor=aBackColor;
    1.77 +	}
    1.78 +
    1.79 +CWordBulletDialog::~CWordBulletDialog()
    1.80 +	{
    1.81 +	}
    1.82 +
    1.83 +void CWordBulletDialog::PreLayoutDynInitL()
    1.84 +	{
    1.85 +	CEikCharMap* charMap = STATIC_CAST(CEikCharMap*, Control(EWordCidBulletCharMap));
    1.86 +	charMap->SetChar(iBullet.iCharacterCode);
    1.87 +	charMap->DrawNow();
    1.88 +	}
    1.89 +
    1.90 +void CWordBulletDialog::HandleControlStateChangeL(TInt aControlId)
    1.91 +	{
    1.92 +	if (aControlId == EWordCidBulletCharMap)
    1.93 +		{
    1.94 +		const TUint charCode = STATIC_CAST(CEikCharMap*, Control(EWordCidBulletCharMap))->GetChar();
    1.95 +		iBullet.iCharacterCode = (TText)charCode;
    1.96 +		}
    1.97 +	}
    1.98 +
    1.99 +TBool CWordBulletDialog::OkToExitL(TInt aButtonId)
   1.100 +	{
   1.101 +	if (aButtonId==EWordCidFormatBullet)
   1.102 +		{
   1.103 +		CEikDialog* dialog=new(ELeave) CWordBulletFormatDialog(&iBullet,iBackColor,NULL,iFontName);
   1.104 +		dialog->ExecuteLD(R_WORD_DIALOG_FORMAT_BULLET);
   1.105 +		return EFalse;
   1.106 +		}
   1.107 +	*iWordBullet=iBullet;
   1.108 +	return ETrue;
   1.109 +	}
   1.110 +
   1.111 +//
   1.112 +// class CWordBulletFormatDialog
   1.113 +//
   1.114 +
   1.115 +CWordBulletFormatDialog::CWordBulletFormatDialog(TBullet* aBullet,TRgb aBackColor, CPrinterDevice* ,const TDesC& aFontName)
   1.116 +	:iFontName(aFontName)
   1.117 +	{
   1.118 +	iWordBullet=aBullet;
   1.119 +	iBullet=*aBullet;
   1.120 +	iBackColor=aBackColor;
   1.121 +	}
   1.122 +
   1.123 +CWordBulletFormatDialog::~CWordBulletFormatDialog()
   1.124 +	{
   1.125 +	delete iTwipsList;
   1.126 +	}
   1.127 +
   1.128 +SEikControlInfo CWordBulletFormatDialog::CreateCustomControlL(TInt aControlType)
   1.129 +	{
   1.130 +	SEikControlInfo info;
   1.131 +    info.iControl=NULL;
   1.132 +	info.iTrailerTextId=0;
   1.133 +	info.iFlags=EEikControlIsNonFocusing;
   1.134 +	if (aControlType==EWordCtBulletPreviewLabel)
   1.135 +		info.iControl=new(ELeave) CWordBulletPreviewLabel;
   1.136 +	return info;
   1.137 +	}
   1.138 +
   1.139 +void CWordBulletFormatDialog::PreLayoutDynInitL()
   1.140 +	{
   1.141 +	CWordBulletPreviewLabel* label=(CWordBulletPreviewLabel*)Control(EWordCidBulletCharacter);
   1.142 +	label->iBrushColor=iBackColor;
   1.143 +	label->iTextColor=iBullet.iColor;
   1.144 +	TFontSpec fontSpec;
   1.145 +	fontSpec.iHeight=iBullet.iHeightInTwips;
   1.146 +	fontSpec.iTypeface.iName=_L("Swiss");
   1.147 +	label->SetFontSpecL(fontSpec);
   1.148 +	SetPreviewLabelL(iBullet.iCharacterCode);
   1.149 +	SetGraySelectorColor(EWordCidBulletColor,iBullet.iColor);
   1.150 +	iTwipsList=new(ELeave) CArrayFixFlat<TInt>(4);
   1.151 +	iPointsList=new(ELeave) CDesCArrayFlat(4);
   1.152 +	FontUtils::GetAvailableHeightsInTwipsAndPointsL(*iCoeEnv->ScreenDevice(),iFontName,*iTwipsList,*iPointsList);
   1.153 +	CEikChoiceList* chlst=(CEikChoiceList*)Control(EWordCidBulletHeight);
   1.154 +	chlst->SetArrayL(iPointsList);
   1.155 +	chlst->SetArrayExternalOwnership(EFalse);
   1.156 +	const TInt index = FontUtils::IndexOfNearestHeight(*iTwipsList, iBullet.iHeightInTwips);
   1.157 +	chlst->SetCurrentItem(index);
   1.158 +	CEikButtonBase::TState state=(iBullet.iHangingIndent? CEikButtonBase::ESet : CEikButtonBase::EClear);
   1.159 +	SetCheckBoxState(EWordCidBulletIndent,state);
   1.160 +	}
   1.161 +
   1.162 +void CWordBulletFormatDialog::SetPreviewLabelL(TUint aCharCode)
   1.163 +	{
   1.164 +	TChar bullet(aCharCode);
   1.165 +	TBuf<1> buf;
   1.166 +	buf.Append(bullet);
   1.167 +	SetLabelL(EWordCidBulletCharacter,buf);
   1.168 +	}
   1.169 +
   1.170 +void CWordBulletFormatDialog::HandleControlStateChangeL(TInt aControlId)
   1.171 +	{
   1.172 +	switch (aControlId)
   1.173 +		{
   1.174 +	case EWordCidBulletColor:
   1.175 +		{
   1.176 +		const TRgb color=GraySelectorColor(EWordCidBulletColor);
   1.177 +		CWordBulletPreviewLabel* label=(CWordBulletPreviewLabel*)Control(EWordCidBulletCharacter);
   1.178 +		label->iTextColor=color;
   1.179 +		label->DrawNow();
   1.180 +		iBullet.iColor=color;
   1.181 +		break;
   1.182 +		}
   1.183 +	case EWordCidBulletHeight:
   1.184 +		{
   1.185 +		const TInt height=(*iTwipsList)[ChoiceListCurrentItem(EWordCidBulletHeight)];
   1.186 +		iBullet.iHeightInTwips=height;
   1.187 +		TFontSpec fontSpec;
   1.188 +		CWordBulletPreviewLabel* label=(CWordBulletPreviewLabel*)Control(EWordCidBulletCharacter);
   1.189 +		fontSpec.iHeight=height;
   1.190 +		fontSpec.iTypeface.iName=_L("Swiss");
   1.191 +		label->SetFontSpecL(fontSpec);
   1.192 +		label->DrawNow();
   1.193 +		break;
   1.194 +		}
   1.195 +	case EWordCidBulletIndent:
   1.196 +		iBullet.iHangingIndent=(CheckBoxState(EWordCidBulletIndent)==CEikButtonBase::ESet);
   1.197 +		break;
   1.198 +	default:
   1.199 +		;
   1.200 +		}
   1.201 +	}
   1.202 +
   1.203 +TBool CWordBulletFormatDialog::OkToExitL(TInt /*aButtonId*/)
   1.204 +	{
   1.205 +	*iWordBullet=iBullet;
   1.206 +	return ETrue;
   1.207 +	}
   1.208 +
   1.209 +//
   1.210 +// class CWordBulletPreviewLabel
   1.211 +//
   1.212 +
   1.213 +CWordBulletPreviewLabel::CWordBulletPreviewLabel()
   1.214 +	{}
   1.215 +
   1.216 +CWordBulletPreviewLabel::~CWordBulletPreviewLabel()
   1.217 +	{
   1.218 +	iCoeEnv->ReleaseScreenFont(CONST_CAST(CFont*,iPrevFont));
   1.219 +	}
   1.220 +
   1.221 +void CWordBulletPreviewLabel::SetFontSpecL(TFontSpec& aFontSpec)
   1.222 +	{
   1.223 +	iCoeEnv->ReleaseScreenFont(CONST_CAST(CFont*,iPrevFont));
   1.224 +	iPrevFont=iCoeEnv->CreateScreenFontL(aFontSpec);
   1.225 +	}
   1.226 +
   1.227 +TSize CWordBulletPreviewLabel::MinimumSize()
   1.228 +	{
   1.229 +	return TSize(40,40); // an attempt to make label big enough for most font heights
   1.230 +	}
   1.231 +
   1.232 +void CWordBulletPreviewLabel::Draw(const TRect& /*aRect*/) const
   1.233 +	{
   1.234 +	CWindowGc& gc=SystemGc();
   1.235 +	gc.UseFont(iPrevFont);
   1.236 +	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.237 +	gc.SetBrushColor(iBrushColor);
   1.238 +	gc.SetPenStyle(CGraphicsContext::ESolidPen);
   1.239 +	gc.SetPenColor(iTextColor);
   1.240 +	const TInt ascent=iPrevFont->AscentInPixels();
   1.241 +	const TRect rect(Rect());
   1.242 +	const TInt baselineOffset=ascent+((rect.Height()-ascent)/2);
   1.243 +	gc.DrawText(*iText,rect,baselineOffset,CGraphicsContext::ECenter);
   1.244 +	}
   1.245 +
   1.246 +//
   1.247 +// class CWordGoToDialog
   1.248 +//
   1.249 +
   1.250 +CWordGoToDialog::CWordGoToDialog(TInt aMaxPages, TInt* aCurrentPage)
   1.251 +    {
   1.252 +	iMaxPages=aMaxPages;
   1.253 +	iCurrentPage=aCurrentPage;
   1.254 +    }
   1.255 +    
   1.256 +void CWordGoToDialog::PreLayoutDynInitL()
   1.257 +	{
   1.258 +	SetNumberEditorMinAndMax(EWordCidPageNumber,1,iMaxPages);
   1.259 +	SetNumberEditorValue(EWordCidPageNumber,*iCurrentPage);
   1.260 +
   1.261 +	TBuf<10> buf;
   1.262 +	buf.Num(iMaxPages);
   1.263 +    SetLabelL(EWordCidPages, buf);
   1.264 +	}
   1.265 +
   1.266 +TBool CWordGoToDialog::OkToExitL(TInt /*aButtonId*/)
   1.267 +	{
   1.268 +	*iCurrentPage=NumberEditorValue(EWordCidPageNumber);
   1.269 +	return(ETrue);
   1.270 +	}
   1.271 +
   1.272 +//
   1.273 +//	CWordViewPreferencesDialog
   1.274 +//
   1.275 +
   1.276 +CWordViewPreferencesDialog::CWordViewPreferencesDialog(TNonPrintingCharVisibility& aVisibility)
   1.277 +	: iVisibility(aVisibility)
   1.278 +	{}
   1.279 +
   1.280 +void CWordViewPreferencesDialog::PreLayoutDynInitL()
   1.281 +	{
   1.282 +	CEikButtonBase::TState button=CEikButtonBase::EClear;
   1.283 +	//tabs
   1.284 +	button=(iVisibility.TabsVisible())?CEikButtonBase::ESet : CEikButtonBase::EClear;	
   1.285 +	SetCheckBoxState(EWordCidTab,button);
   1.286 +	//spaces
   1.287 +	button=(iVisibility.SpacesVisible())?CEikButtonBase::ESet : CEikButtonBase::EClear;		
   1.288 +	SetCheckBoxState(EWordCidSpaces,button);
   1.289 +	//paragraph ends
   1.290 +	button=(iVisibility.ParagraphDelimitersVisible())?CEikButtonBase::ESet : CEikButtonBase::EClear;		
   1.291 +	SetCheckBoxState(EWordCidParaEnds,button);
   1.292 +	//hyphens
   1.293 +	button=(iVisibility.NonBreakingHyphensVisible())?CEikButtonBase::ESet : CEikButtonBase::EClear;		
   1.294 +	SetCheckBoxState(EWordCidHardHyphens,button);
   1.295 +	//line breaks
   1.296 +	button=(iVisibility.LineBreaksVisible())?CEikButtonBase::ESet : CEikButtonBase::EClear;		
   1.297 +	SetCheckBoxState(EWordCidForcedLineBreaks,button);
   1.298 +	//nonbreaking spaces
   1.299 +	button=(iVisibility.NonBreakingSpacesVisible())?CEikButtonBase::ESet : CEikButtonBase::EClear;		
   1.300 +	SetCheckBoxState(EWordCidNonBreakingSpace,button);
   1.301 +	}
   1.302 +
   1.303 +void CWordViewPreferencesDialog::WordSetCheckBoxState(CEikButtonBase::TState aState)
   1.304 +	{
   1.305 +	SetCheckBoxState(EWordCidTab,aState);
   1.306 +	SetCheckBoxState(EWordCidSpaces,aState);
   1.307 +	SetCheckBoxState(EWordCidParaEnds,aState);
   1.308 +	SetCheckBoxState(EWordCidHardHyphens,aState);
   1.309 +	SetCheckBoxState(EWordCidForcedLineBreaks,aState);
   1.310 +	SetCheckBoxState(EWordCidNonBreakingSpace,aState);
   1.311 +	} 												  
   1.312 +
   1.313 +TBool CWordViewPreferencesDialog::OkToExitL(TInt /*aButtonId*/)
   1.314 +	{
   1.315 +	TBool visible;
   1.316 +	CEikButtonBase::TState button=CEikButtonBase::EClear;
   1.317 +	//tabs
   1.318 +	button=CheckBoxState(EWordCidTab);
   1.319 +	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
   1.320 +	iVisibility.SetTabsVisible(visible);
   1.321 +	//spaces
   1.322 +	button=CheckBoxState(EWordCidSpaces);
   1.323 +	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
   1.324 +	iVisibility.SetSpacesVisible(visible);
   1.325 +	//paragraph ends
   1.326 +	button=CheckBoxState(EWordCidParaEnds);
   1.327 +	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
   1.328 +	iVisibility.SetParagraphDelimitersVisible(visible);
   1.329 +	//hyphens
   1.330 +	button=CheckBoxState(EWordCidHardHyphens);
   1.331 +	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
   1.332 +	iVisibility.SetNonBreakingHyphensVisible(visible);
   1.333 +	//line breaks
   1.334 +	button=CheckBoxState(EWordCidForcedLineBreaks);
   1.335 +	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
   1.336 +	iVisibility.SetLineBreaksVisible(visible);
   1.337 +	//nonbreaking spaces
   1.338 +	button=CheckBoxState(EWordCidNonBreakingSpace);
   1.339 +	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
   1.340 +	iVisibility.SetNonBreakingSpacesVisible(visible);
   1.341 +	//
   1.342 +	return ETrue;
   1.343 +	}
   1.344 +
   1.345 +
   1.346 +
   1.347 +//
   1.348 +//	CWordObjectPreferencesDialog & Revert To Style dialog
   1.349 +//
   1.350 +
   1.351 +CWordObjectPreferencesDialog::CWordObjectPreferencesDialog(TBool& aSketchAsGlass,TBool& aGraphAsGlass/*,TInt aButton*/)
   1.352 +	: iSketchAsGlass(aSketchAsGlass),iGraphAsGlass(aGraphAsGlass)/*,iButton(aButton)*/
   1.353 +	{}
   1.354 +
   1.355 +void CWordObjectPreferencesDialog::PreLayoutDynInitL()
   1.356 +	{
   1.357 +//	//
   1.358 +//	// Change the dialog text as appropriate
   1.359 +//	if (!iObjectPreferenceDialog)
   1.360 +//		{
   1.361 +///		SetTitleL(R_WORD_STYLE_REVERT_TITLE);
   1.362 +//
   1.363 +///		}
   1.364 +
   1.365 +	CEikButtonBase::TState button=CEikButtonBase::EClear;
   1.366 +	//
   1.367 +	// Sketch as glass
   1.368 +	button=(iSketchAsGlass) ? CEikButtonBase::EClear : CEikButtonBase::ESet;
   1.369 +	SetCheckBoxState(EWordCidShowSketch,button);
   1.370 +	// graph as glass
   1.371 +	button=(iGraphAsGlass) ? CEikButtonBase::EClear : CEikButtonBase::ESet;
   1.372 +	SetCheckBoxState(EWordCidShowGraph,button);
   1.373 +	}
   1.374 +
   1.375 +void CWordObjectPreferencesDialog::WordSetCheckBoxState(CEikButtonBase::TState aState)
   1.376 +	{
   1.377 +	SetCheckBoxState(EWordCidShowSketch,aState);
   1.378 +	SetCheckBoxState(EWordCidShowGraph,aState);
   1.379 +	} 												  
   1.380 +
   1.381 +TBool CWordObjectPreferencesDialog::OkToExitL(TInt /*aButtonId*/)
   1.382 +	{
   1.383 +	TBool visible;
   1.384 +	CEikButtonBase::TState button=CEikButtonBase::EClear;
   1.385 +	//
   1.386 +	// sketch as glass
   1.387 +	button=CheckBoxState(EWordCidShowSketch);
   1.388 +	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
   1.389 +	iSketchAsGlass=!visible;
   1.390 +	// graph as glass
   1.391 +	button=CheckBoxState(EWordCidShowGraph);
   1.392 +	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
   1.393 +	iGraphAsGlass=!visible;
   1.394 +	//
   1.395 +	return ETrue;
   1.396 +	}
   1.397 +
   1.398 +//
   1.399 +//	CWordObjectPreferencesDialog & Revert To Style dialog
   1.400 +//
   1.401 +
   1.402 +CWordRevertToStyleDialog::CWordRevertToStyleDialog(TBool& aSketchAsGlass,TBool& aGraphAsGlass)
   1.403 +	: iSketchAsGlass(aSketchAsGlass),iGraphAsGlass(aGraphAsGlass)
   1.404 +	{}
   1.405 +
   1.406 +void CWordRevertToStyleDialog::PreLayoutDynInitL()
   1.407 +	{
   1.408 +//	//
   1.409 +//	// Change the dialog text as appropriate
   1.410 +//	if (!iObjectPreferenceDialog)
   1.411 +//		{
   1.412 +///		SetTitleL(R_WORD_STYLE_REVERT_TITLE);
   1.413 +//
   1.414 +///		}
   1.415 +
   1.416 +	CEikButtonBase::TState button=CEikButtonBase::EClear;
   1.417 +	//
   1.418 +	// Sketch as glass
   1.419 +	button=(iSketchAsGlass) ? CEikButtonBase::ESet : CEikButtonBase::EClear;
   1.420 +	SetCheckBoxState(EWordCidRemoveChar,button);
   1.421 +	// graph as glass
   1.422 +	button=(iGraphAsGlass) ? CEikButtonBase::ESet : CEikButtonBase::EClear;
   1.423 +	SetCheckBoxState(EWordCidRemovePara,button);
   1.424 +	}
   1.425 +
   1.426 +void CWordRevertToStyleDialog::WordSetCheckBoxState(CEikButtonBase::TState aState)
   1.427 +	{
   1.428 +	SetCheckBoxState(EWordCidRemoveChar,aState);
   1.429 +	SetCheckBoxState(EWordCidRemovePara,aState);
   1.430 +	} 												  
   1.431 +
   1.432 +TBool CWordRevertToStyleDialog::OkToExitL(TInt /*aButtonId*/)
   1.433 +	{
   1.434 +	TBool visible;
   1.435 +	CEikButtonBase::TState button=CEikButtonBase::EClear;
   1.436 +	//
   1.437 +	// sketch as glass
   1.438 +	button=CheckBoxState(EWordCidRemoveChar);
   1.439 +	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
   1.440 +	iSketchAsGlass=visible;
   1.441 +	// graph as glass
   1.442 +	button=CheckBoxState(EWordCidRemovePara);
   1.443 +	visible=button? CEikButtonBase::ESet : CEikButtonBase::EClear; 
   1.444 +	iGraphAsGlass=visible;
   1.445 +	//
   1.446 +	return ETrue;
   1.447 +	}
   1.448 +
   1.449 +//
   1.450 +// Manual zoom setting dialog
   1.451 +// 
   1.452 +
   1.453 +CWordTempManualZoomDialog::CWordTempManualZoomDialog(TInt& aOrigZoomFactor)
   1.454 +	: iOrigZoomFactor(aOrigZoomFactor)
   1.455 +	{__ASSERT_DEBUG(iOrigZoomFactor>0,Panic(EWordZeroZoomFactor));}
   1.456 +
   1.457 +
   1.458 +void CWordTempManualZoomDialog::PreLayoutDynInitL()
   1.459 +	{
   1.460 +	// set the control with the current zoom factor
   1.461 +	__ASSERT_DEBUG(iOrigZoomFactor>0,Panic(EWordZeroZoomFactor));
   1.462 +	SetNumberEditorValue(EWordCidZoomSet,iOrigZoomFactor/10);
   1.463 +	}
   1.464 +
   1.465 +
   1.466 +TBool CWordTempManualZoomDialog::OkToExitL(TInt /*aButtonId*/)
   1.467 +	{
   1.468 +	iOrigZoomFactor=(NumberEditorValue(EWordCidZoomSet))*10;
   1.469 +	return ETrue;
   1.470 +	}
   1.471 +
   1.472 +
   1.473 +//
   1.474 +// Custom File Open dialog
   1.475 +//
   1.476 +
   1.477 +
   1.478 +CWordFileOpenDialog::CWordFileOpenDialog(TDes* aFileName,TBool& aReadOnly,TInt aTitleId)
   1.479 +	: CEikFileOpenDialog(aFileName,aTitleId),
   1.480 +	  iReadOnly(aReadOnly)
   1.481 +    {
   1.482 +	__DECLARE_NAME(_S("CWordFileOpenDialog"));
   1.483 +    }
   1.484 +
   1.485 +
   1.486 +void CWordFileOpenDialog::HandleControlStateChangeL(TInt)
   1.487 +	{
   1.488 +	}
   1.489 +
   1.490 +TBool CWordFileOpenDialog::OkToExitL(TInt aButtonId)
   1.491 +    {
   1.492 +	if (CEikFileOpenDialog::OkToExitL(aButtonId))
   1.493 +		{
   1.494 +		iReadOnly=CheckBoxState(EWordCidReadOnly)==CEikButtonBase::ESet;
   1.495 +		return ETrue;
   1.496 +		}
   1.497 +	else return EFalse;
   1.498 +    }
   1.499 +
   1.500 +//
   1.501 +// Custom File New dialog with templates
   1.502 +//
   1.503 +
   1.504 +CWordTemplateNewFileDialog::CWordTemplateNewFileDialog(TDes* aFileName, TFileName& aTemplateFileName, TUidType aUid)
   1.505 +	: CEikFileSaveAsDialog(aFileName,NULL,R_EIK_TBUF_CREATE_NEW_FILE), iTemplateFileName(aTemplateFileName),
   1.506 +		iUid(aUid)
   1.507 +	{
   1.508 +	}
   1.509 +
   1.510 +TBool CWordTemplateNewFileDialog::OkToExitL(TInt aButtonId)
   1.511 +	{
   1.512 +	if(!CEikFileSaveAsDialog::OkToExitL(aButtonId))
   1.513 +		return EFalse;
   1.514 +	// Check to see if the template is still there
   1.515 +	CEikUnifiedFileNameSelector* templateFileNameSel = (CEikUnifiedFileNameSelector*) (Control(EEikCtUnifiedFileSel));
   1.516 +	iTemplateFileName = templateFileNameSel->FullName();
   1.517 +	if(ConeUtils::FileExists(iTemplateFileName))
   1.518 +		return ETrue;
   1.519 +	else
   1.520 +		{
   1.521 +		iEikonEnv->InfoMsg(R_WORD_TEMPLATE_NOT_AVAILABLE);
   1.522 +		return EFalse;
   1.523 +		}
   1.524 +	}
   1.525 +
   1.526 +void CWordTemplateNewFileDialog::PreLayoutDynInitL()
   1.527 +	{
   1.528 +	CEikFileSaveAsDialog::PreLayoutDynInitL();
   1.529 +	TFileName templateFileName;
   1.530 +	TWordFilePath::GetNormalTemplateFolderName(templateFileName);
   1.531 +	TFileName tempFileName;
   1.532 +	TFindFile ff(iEikonEnv->FsSession());
   1.533 +
   1.534 +	iEikonEnv->ReadResource(tempFileName, R_WORD_NORMAL_TEMPLATE_FILE_NAME);
   1.535 +	templateFileName.Append(tempFileName);
   1.536 +	templateFileName[0] = 'Y';
   1.537 +	TParsePtr parse(templateFileName);
   1.538 +	TInt err = ff.FindByDir(parse.NameAndExt(),parse.DriveAndPath());
   1.539 +	if(err)
   1.540 +		{
   1.541 +		// no normal template, search ROM for blank
   1.542 +		TWordFilePath::GetNormalTemplateFolderName(templateFileName);
   1.543 +		iEikonEnv->ReadResource(tempFileName, R_WORD_BLANK_TEMPLATE_FILE_NAME);
   1.544 +		templateFileName.Append(tempFileName);
   1.545 +		templateFileName[0] = 'Z';
   1.546 +		TParsePtr blankParse(templateFileName);
   1.547 +		User::LeaveIfError(ff.FindByDir(blankParse.NameAndExt(),blankParse.DriveAndPath()));
   1.548 +		}
   1.549 +	templateFileName = ff.File();
   1.550 +	
   1.551 +	CEikUnifiedFileNameSelector* templateFileNameSel = (CEikUnifiedFileNameSelector*) (Control(EEikCtUnifiedFileSel));
   1.552 +	templateFileNameSel->SetUidType(iUid);
   1.553 +	templateFileNameSel->SetROMIncluded(ETrue);
   1.554 +	templateFileNameSel->SetFullNameL(templateFileName);	
   1.555 +	}
   1.556 +
   1.557 +SEikControlInfo CWordTemplateNewFileDialog::CreateCustomControlL(TInt aControlType)
   1.558 +	{
   1.559 +	SEikControlInfo controlInfo;
   1.560 +	controlInfo.iControl=NULL;
   1.561 +	controlInfo.iTrailerTextId=0;
   1.562 +	controlInfo.iFlags=0;
   1.563 +
   1.564 +	switch(aControlType)
   1.565 +		{
   1.566 +	case EWordUnifiedFileNameSelector:
   1.567 +		{
   1.568 +		CWordUnifiedFileSelector* newControl = new(ELeave) CWordUnifiedFileSelector();
   1.569 +		controlInfo.iControl = newControl;
   1.570 +		controlInfo.iFlags = EEikControlHasEars;
   1.571 +		break;
   1.572 +		}
   1.573 +	default:
   1.574 +		break;
   1.575 +		}
   1.576 +	return controlInfo;
   1.577 +	}
   1.578 +
   1.579 +//
   1.580 +// class CWordUnifiedFileSelector file selector with sorting
   1.581 +// 
   1.582 +
   1.583 +void CWordUnifiedFileSelector::SortArray(MDesCArray* aFileNames)
   1.584 +	{
   1.585 +	TFileName blank;
   1.586 +	iEikonEnv->ReadResource(blank, R_WORD_BLANK_TEMPLATE_FILE_NAME);
   1.587 +	TInt count = aFileNames->MdcaCount();
   1.588 +	for (TInt i = 0 ; i < count; i++)
   1.589 +		{
   1.590 +		if (aFileNames->MdcaPoint(i) == blank)
   1.591 +			{
   1.592 +			if (i == 0)
   1.593 +				break;
   1.594 +			CDesCArray* array = STATIC_CAST(CDesCArray*,aFileNames);
   1.595 +			TRAPD(err,array->InsertL(0, blank)); // top
   1.596 +			if (err == KErrNone)
   1.597 +				{
   1.598 +				array->Delete(++i);
   1.599 +				}
   1.600 +			break;
   1.601 +			}
   1.602 +		}
   1.603 +	}
   1.604 +
   1.605 +void CWordUnifiedFileSelector::BuildFileNameArrayL(const TParse& aParse, MDesCArray* aFileNames)
   1.606 +	{
   1.607 +	CEikUnifiedFileNameSelector::BuildFileNameArrayL(aParse, aFileNames);
   1.608 +	SortArray(aFileNames);
   1.609 +	}
   1.610 +
   1.611 +//
   1.612 +// class CWordDeleteTemplateDialog
   1.613 +//
   1.614 +
   1.615 +CWordDeleteTemplateDialog::CWordDeleteTemplateDialog(TFileName& aTemplateFileName, TUidType aUid)
   1.616 +	: iTemplateFileName(aTemplateFileName), iUid(aUid)
   1.617 +	{
   1.618 +	}
   1.619 +
   1.620 +TBool CWordDeleteTemplateDialog::OkToExitL(TInt /*aButtonId*/)
   1.621 +	{
   1.622 +	CEikUnifiedFileNameSelector* templateFileNameSel = STATIC_CAST(CEikUnifiedFileNameSelector*,(Control(EEikCtUnifiedFileSel)));
   1.623 +	iTemplateFileName = templateFileNameSel->FullName();
   1.624 +	
   1.625 +	if (!iTemplateFileName.Length())
   1.626 +		return ETrue;
   1.627 +
   1.628 +	// Confirm this is what the user really wants
   1.629 +	TParsePtrC parse(iTemplateFileName);
   1.630 +	TFileName confirmPre;
   1.631 +	TBuf<30> confirmPost;
   1.632 +	iEikonEnv->ReadResource(confirmPre, R_WORD_TEMPLATE_DELETE_CONFIRMATION_PRE);
   1.633 +	iEikonEnv->ReadResource(confirmPost, R_WORD_TEMPLATE_DELETE_CONFIRMATION_POST);
   1.634 +	TInt gap = 60 - confirmPre.Length() - confirmPost.Length();
   1.635 +	if (parse.NameAndExt().Length() > gap)
   1.636 +		{
   1.637 +		TFileName name = parse.NameAndExt();
   1.638 +		confirmPre.Append(name.Left(gap - 1));
   1.639 +		confirmPre.Append((TChar)KEllipsis);
   1.640 +		}
   1.641 +	else
   1.642 +		confirmPre.Append(parse.NameAndExt());
   1.643 +	confirmPre.Append(confirmPost);
   1.644 +	confirmPost = _L("");
   1.645 +		
   1.646 +	if (!iEikonEnv->QueryWinL(confirmPre, confirmPost))
   1.647 +		iTemplateFileName = TFileName();
   1.648 +	return ETrue;
   1.649 +	}
   1.650 +
   1.651 +void CWordDeleteTemplateDialog::PreLayoutDynInitL()
   1.652 +	{
   1.653 +	CEikUnifiedFileNameSelector* templateFileNameSel = STATIC_CAST(CEikUnifiedFileNameSelector*,(Control(EEikCtUnifiedFileSel)));
   1.654 +	templateFileNameSel->SetUidType(iUid);
   1.655 +	templateFileNameSel->SetROMIncluded(EFalse);
   1.656 +	templateFileNameSel->SetFullNameL(iTemplateFileName);
   1.657 +	}
   1.658 +
   1.659 +//
   1.660 +// class CWordSaveAsTemplateDialog
   1.661 +//
   1.662 +
   1.663 +CWordSaveAsTemplateDialog::CWordSaveAsTemplateDialog(TFileName& aTemplateFileName, TUidType aUid)
   1.664 +	: iTemplateFileName(aTemplateFileName), iUid(aUid)
   1.665 +	{
   1.666 +	}
   1.667 +
   1.668 +TBool CWordSaveAsTemplateDialog::OkToExitL(TInt /*aButtonId*/)
   1.669 +	{
   1.670 +	CEikFileNameEditor* templateFileNameEd = STATIC_CAST(CEikFileNameEditor*,(Control(EEikCidFileNameEd)));
   1.671 +	CEikDriveNameSelector *driveNameSelector = STATIC_CAST(CEikDriveNameSelector*,(Control(EEikCidDriveNameSel)));
   1.672 +	templateFileNameEd->GetFullNameL(iTemplateFileName);
   1.673 +
   1.674 +	TFileName drivename = driveNameSelector->FullName();
   1.675 +	TParse parse;
   1.676 +	User::LeaveIfError(parse.Set(drivename, &iTemplateFileName,NULL));
   1.677 +	iTemplateFileName = parse.FullName();
   1.678 +	TBool doNotReplaceExistingFile = EFalse;
   1.679 +	TUint attributes = 0;
   1.680 +	if (ConeUtils::FileExists(iTemplateFileName))
   1.681 +		{
   1.682 +		TBuf<32> infoDialogTitle;
   1.683 +		iEikonEnv->ReadResource(infoDialogTitle, R_EIK_TBUF_DIALOG_TITLE_CONFIRM_FILE_REPLACE);
   1.684 +		TBuf<KShortErrorMessageLength> formatStr;
   1.685 +		User::LeaveIfError(iEikonEnv->FsSession().Att(iTemplateFileName, attributes));
   1.686 +		if (attributes & KEntryAttReadOnly)
   1.687 +			iEikonEnv->LeaveWithInfoMsg(R_EIK_TBUF_CANNOT_REPLACE_READONLY_FILE);
   1.688 +		else
   1.689 +			iEikonEnv->ReadResource(formatStr, R_EIK_TBUF_FILE_REPLACE_CONFIRM1);
   1.690 +		TBuf<KMaxDisplayedFullNameLen> abbrevName;
   1.691 +		User::LeaveIfError(EikFileUtils::Parse(iTemplateFileName));
   1.692 +		TParsePtr parse(iTemplateFileName);
   1.693 +		EikFileUtils::AbbreviateFileName(parse.NameAndExt(), abbrevName);
   1.694 +		TBuf<KShortErrorMessageLength + KMaxDisplayedFullNameLen> textMsg;
   1.695 +		textMsg.Format(formatStr, &abbrevName);
   1.696 +		CEikDialog* infoDialog = new(ELeave) CEikInfoDialog(infoDialogTitle, textMsg,CEikInfoDialog::EIgnoreEnter);
   1.697 +		if (!(infoDialog->ExecuteLD(R_EIK_DIALOG_SINGLE_FILE_REPLACE)))
   1.698 +			doNotReplaceExistingFile = ETrue;
   1.699 +		}
   1.700 +	return !doNotReplaceExistingFile;
   1.701 +	}
   1.702 +
   1.703 +void CWordSaveAsTemplateDialog::PreLayoutDynInitL()
   1.704 +	{
   1.705 +	TFileName templateFileName;
   1.706 +	TWordFilePath::GetNormalTemplateFolderName(templateFileName);
   1.707 +
   1.708 +	CEikFileNameEditor* templateFileNameEd = STATIC_CAST(CEikFileNameEditor*,(Control(EEikCidFileNameEd)));
   1.709 +	CEikDriveNameSelector *driveNameSelector = STATIC_CAST(CEikDriveNameSelector*,(Control(EEikCidDriveNameSel)));
   1.710 +	
   1.711 +	templateFileNameEd->SetFullNameL(templateFileName);
   1.712 +	
   1.713 +	// set drive to be system drive
   1.714 +	templateFileName[0] = 'A' + static_cast<TInt>(RFs::GetSystemDrive());
   1.715 +	
   1.716 +	driveNameSelector->ShowRom(EFalse);
   1.717 +	driveNameSelector->SetFullNameL(templateFileName);
   1.718 +	}
   1.719 +
   1.720 +// Outline Dialog
   1.721 +
   1.722 +CWordOutlineDialog::CWordOutlineDialog(CRichText* aText, CEikEdwin* aEdWin, TInt& aNewCursorPosition)
   1.723 +	:iText(aText), 
   1.724 +	iEdWin(aEdWin),
   1.725 +	iNewCursorPosition(aNewCursorPosition)
   1.726 +{
   1.727 +}
   1.728 +
   1.729 +
   1.730 +
   1.731 +TBool CWordOutlineDialog::OkToExitL(TInt aButtonId)
   1.732 +	{
   1.733 +	switch(aButtonId)
   1.734 +		{
   1.735 +	case EEikBidOk:
   1.736 +		iNewCursorPosition = iOutlineNav->OutlineModel()->CurrentCharPosition();
   1.737 +		return ETrue;
   1.738 +	case EWordBidOpenAll:
   1.739 +		iOutlineNav->ExpandAllItemsL();
   1.740 +		return EFalse;
   1.741 +	case EWordBidCloseAll:
   1.742 +		iOutlineNav->CollapseAllItemsL();
   1.743 +		return EFalse;
   1.744 +	default:
   1.745 +		return EFalse;
   1.746 +		}
   1.747 +	}
   1.748 +
   1.749 +
   1.750 +SEikControlInfo CWordOutlineDialog::CreateCustomControlL(TInt aControlType)
   1.751 +	{
   1.752 +	SEikControlInfo controlInfo;
   1.753 +	controlInfo.iControl=NULL;
   1.754 +	controlInfo.iTrailerTextId=0;
   1.755 +	controlInfo.iFlags=0;
   1.756 +
   1.757 +	COutlineHListBox* newControl;
   1.758 +
   1.759 +	switch(aControlType)
   1.760 +		{
   1.761 +	case EWordCtOutlineNav:
   1.762 +		newControl = new(ELeave)COutlineHListBox(iText,iEdWin->CursorPos());
   1.763 +		controlInfo.iControl = newControl;
   1.764 +		iOutlineNav = newControl;
   1.765 +		break;
   1.766 +	default:
   1.767 +		break;
   1.768 +		}
   1.769 +	return controlInfo;
   1.770 +	}