os/textandloc/textrendering/word/SRC/WPTEST.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/textrendering/word/SRC/WPTEST.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,589 @@
     1.4 +/*
     1.5 +* Copyright (c) 1999-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 +* Functions added to Word for test purposes now that Word is no longer a standard EPOC application.
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +#include <e32std.h>
    1.24 +#include <techview/eikcfdlg.h>
    1.25 +#include <techview/eikon.rsg>
    1.26 +#include "WPAPPUI.H"
    1.27 +#include "WPTEXTED.H"
    1.28 +#include "WPTEST.H"
    1.29 +#include "WPTESTPICTURE.H"
    1.30 +
    1.31 +
    1.32 +struct TKeyAction
    1.33 +	{
    1.34 +	TInt Compare(TInt aKeyCode,TInt aState) const;
    1.35 +
    1.36 +	TInt iKeyCode;			// key pressed by user
    1.37 +	TInt iState;			// state in which this action fires
    1.38 +	TInt iCharToInsert;		// character to insert; if 0xFFFF, none
    1.39 +	TInt iNewState;			// new state
    1.40 +	};
    1.41 +
    1.42 +TInt TKeyAction::Compare(TInt aKeyCode,TInt aState) const
    1.43 +	{
    1.44 +	if (iKeyCode - aKeyCode)
    1.45 +		return iKeyCode - aKeyCode;
    1.46 +	return iState - aState;
    1.47 +	}
    1.48 +
    1.49 +struct TKeyboardMap
    1.50 +	{
    1.51 +	const TKeyAction* Find(TInt aKeyCode,TInt aState) const;
    1.52 +
    1.53 +	const TKeyAction* iKeyAction;	// action table
    1.54 +	TInt iKeyActions;				// number of entries in table
    1.55 +	};
    1.56 +
    1.57 +const TKeyAction* TKeyboardMap::Find(TInt aKeyCode,TInt aState) const
    1.58 +	{
    1.59 +	const TKeyAction* base = iKeyAction;
    1.60 +	const TKeyAction* end = iKeyAction + iKeyActions;
    1.61 +	while (base < end)
    1.62 +		{
    1.63 +		int n = end - base;
    1.64 +		const TKeyAction* a = &base[n / 2];
    1.65 +		int diff = a->Compare(aKeyCode,aState);
    1.66 +		if (diff > 0)
    1.67 +			end = a;
    1.68 +		else if (diff < 0)
    1.69 +			base = a + 1;
    1.70 +		else
    1.71 +			return a;
    1.72 +		}
    1.73 +	return NULL;
    1.74 +	}
    1.75 +
    1.76 +static const TKeyAction TheArabicKeyAction[] =
    1.77 +	{
    1.78 +	{ 'A', 0, 0x0649, 0 },
    1.79 +	{ 'B', 0, 0xFFFF, 0 },
    1.80 +	{ 'C', 0, 0xFFFF, 0 },
    1.81 +	{ 'D', 0, 0x0636, 0 },
    1.82 +	{ 'E', 0, 0xFFFF, 0 },
    1.83 +	{ 'F', 0, 0xFFFF, 0 },
    1.84 +	{ 'G', 0, 0x063A, 0 },
    1.85 +	{ 'H', 0, 0x062D, 0 },
    1.86 +	{ 'I', 0, 0xFFFF, 0 },
    1.87 +	{ 'J', 0, 0xFFFF, 0 },
    1.88 +	{ 'K', 0, 0xFFFF, 0 },
    1.89 +	{ 'L', 0, 0xFFFF, 0 },
    1.90 +	{ 'M', 0, 0xFFFF, 0 },
    1.91 +	{ 'N', 0, 0xFFFF, 0 },
    1.92 +	{ 'O', 0, 0xFFFF, 0 },
    1.93 +	{ 'P', 0, 0xFFFF, 0 },
    1.94 +	{ 'Q', 0, 0xFFFF, 0 },
    1.95 +	{ 'R', 0, 0xFFFF, 0 },
    1.96 +	{ 'S', 0, 0x0635, 0 },
    1.97 +	{ 'T', 0, 0x0637, 0 },
    1.98 +	{ 'U', 0, 0xFFFF, 0 },
    1.99 +	{ 'V', 0, 0xFFFF, 0 },
   1.100 +	{ 'W', 0, 0xFFFF, 0 },
   1.101 +	{ 'X', 0, 0xFFFF, 0 },
   1.102 +	{ 'Y', 0, 0xFFFF, 0 },
   1.103 +	{ 'Z', 0, 0x0638, 0 },
   1.104 +	{ 'a', 0, 0x0627, 0 },
   1.105 +	{ 'b', 0, 0x0628, 0 },
   1.106 +	{ 'c', 0, 0xFFFF, 0 },
   1.107 +	{ 'd', 0, 0x062F, 0 },
   1.108 +	{ 'e', 0, 0xFFFF, 0 },
   1.109 +	{ 'f', 0, 0x0641, 0 },
   1.110 +	{ 'g', 0, 0x0639, 0 },
   1.111 +	{ 'h', 0, 0x0647, 0 },
   1.112 +	{ 'i', 0, 0xFFFF, 0 },
   1.113 +	{ 'j', 0, 0x062C, 0 },
   1.114 +	{ 'k', 0, 0x0643, 0 },
   1.115 +	{ 'l', 0, 0x0644, 0 },
   1.116 +	{ 'm', 0, 0x0645, 0 },
   1.117 +	{ 'n', 0, 0x0646, 0 },
   1.118 +	{ 'o', 0, 0xFFFF, 0 },
   1.119 +	{ 'p', 0, 0x067E, 0 },
   1.120 +	{ 'q', 0, 0x0642, 0 },
   1.121 +	{ 'r', 0, 0x0631, 0 },
   1.122 +	{ 's', 0, 0x0633, 0 },
   1.123 +	{ 't', 0, 0x062A, 0 },
   1.124 +	{ 'u', 0, 0xFFFF, 0 },
   1.125 +	{ 'v', 0, 0xFFFF, 0 },
   1.126 +	{ 'w', 0, 0x0648, 0 },
   1.127 +	{ 'x', 0, 0x062E, 0 },
   1.128 +	{ 'y', 0, 0x064A, 0 },
   1.129 +	{ 'z', 0, 0x0632, 0 },
   1.130 +	};
   1.131 +static const TKeyboardMap TheArabicKeyboardMap =
   1.132 +	{
   1.133 +	TheArabicKeyAction,
   1.134 +	sizeof(TheArabicKeyAction) / sizeof(TKeyAction)
   1.135 +	};
   1.136 +
   1.137 +static const TKeyAction TheGreekKeyAction[] =
   1.138 +	{
   1.139 +	{ 'A', 0, 0x0391, 0 },
   1.140 +	{ 'B', 0, 0x0392, 0 },
   1.141 +	{ 'C', 0, 0xFFFF, 0 },
   1.142 +	{ 'D', 0, 0x0394, 0 },
   1.143 +	{ 'E', 0, 0x0395, 0 },
   1.144 +	{ 'F', 0, 0x03A6, 0 },
   1.145 +	{ 'G', 0, 0x0393, 0 },
   1.146 +	{ 'H', 0, 0x03A7, 0 },
   1.147 +	{ 'I', 0, 0x0399, 0 },
   1.148 +	{ 'J', 0, 0x0397, 0 },
   1.149 +	{ 'K', 0, 0x039A, 0 },
   1.150 +	{ 'L', 0, 0x039B, 0 },
   1.151 +	{ 'M', 0, 0x039C, 0 },
   1.152 +	{ 'N', 0, 0x039D, 0 },
   1.153 +	{ 'O', 0, 0x039F, 0 },
   1.154 +	{ 'P', 0, 0x03A0, 0 },
   1.155 +	{ 'Q', 0, 0x0398, 0 },
   1.156 +	{ 'R', 0, 0x03A1, 0 },
   1.157 +	{ 'S', 0, 0x03A3, 0 },
   1.158 +	{ 'T', 0, 0x03A4, 0 },
   1.159 +	{ 'U', 0, 0x03A5, 0 },
   1.160 +	{ 'V', 0, 0x03A8, 0 },
   1.161 +	{ 'W', 0, 0x03A9, 0 },
   1.162 +	{ 'X', 0, 0x039E, 0 },
   1.163 +	{ 'Y', 0, 0xFFFF, 0 },
   1.164 +	{ 'Z', 0, 0x0396, 0 },
   1.165 +	{ 'a', 0, 0x03B1, 0 },
   1.166 +	{ 'b', 0, 0x03B2, 0 },
   1.167 +	{ 'c', 0, 0x03C2, 0 },
   1.168 +	{ 'd', 0, 0x03B4, 0 },
   1.169 +	{ 'e', 0, 0x03B5, 0 },
   1.170 +	{ 'f', 0, 0x03C6, 0 },
   1.171 +	{ 'g', 0, 0x03B3, 0 },
   1.172 +	{ 'h', 0, 0x03C7, 0 },
   1.173 +	{ 'i', 0, 0x03B9, 0 },
   1.174 +	{ 'j', 0, 0x03B7, 0 },
   1.175 +	{ 'k', 0, 0x03BA, 0 },
   1.176 +	{ 'l', 0, 0x03BB, 0 },
   1.177 +	{ 'm', 0, 0x03BC, 0 },
   1.178 +	{ 'n', 0, 0x03BD, 0 },
   1.179 +	{ 'o', 0, 0x03BF, 0 },
   1.180 +	{ 'p', 0, 0x03C0, 0 },
   1.181 +	{ 'q', 0, 0x03B8, 0 },
   1.182 +	{ 'r', 0, 0x03C1, 0 },
   1.183 +	{ 's', 0, 0x03C3, 0 },
   1.184 +	{ 't', 0, 0x03C4, 0 },
   1.185 +	{ 'u', 0, 0x03C5, 0 },
   1.186 +	{ 'v', 0, 0x03C8, 0 },
   1.187 +	{ 'w', 0, 0x03C9, 0 },
   1.188 +	{ 'x', 0, 0x03BE, 0 },
   1.189 +	{ 'y', 0, 0xFFFF, 0 },
   1.190 +	{ 'z', 0, 0x03B6, 0 },
   1.191 +	};
   1.192 +static const TKeyboardMap TheGreekKeyboardMap =
   1.193 +	{
   1.194 +	TheGreekKeyAction,
   1.195 +	sizeof(TheGreekKeyAction) / sizeof(TKeyAction)
   1.196 +	};
   1.197 +
   1.198 +static const TKeyAction TheRussianKeyAction[] =
   1.199 +	{
   1.200 +	{ 'A', 0, 0x0410, 0 },
   1.201 +	{ 'B', 0, 0x0411, 0 },
   1.202 +	{ 'C', 0, 0x0426, 0 },
   1.203 +	{ 'D', 0, 0x0414, 0 },
   1.204 +	{ 'E', 0, 0x0415, 0 },
   1.205 +	{ 'F', 0, 0x0424, 0 },
   1.206 +	{ 'G', 0, 0x0413, 0 },
   1.207 +	{ 'H', 0, 0x0425, 0 },
   1.208 +	{ 'I', 0, 0x0418, 0 },
   1.209 +	{ 'J', 0, 0xFFFF, 0 },
   1.210 +	{ 'K', 0, 0x041A, 0 },
   1.211 +	{ 'L', 0, 0x041B, 0 },
   1.212 +	{ 'M', 0, 0x041C, 0 },
   1.213 +	{ 'N', 0, 0x041D, 0 },
   1.214 +	{ 'O', 0, 0x041E, 0 },
   1.215 +	{ 'P', 0, 0x041F, 0 },
   1.216 +	{ 'Q', 0, 0xFFFF, 0 },
   1.217 +	{ 'R', 0, 0x0420, 0 },
   1.218 +	{ 'S', 0, 0x0421, 0 },
   1.219 +	{ 'T', 0, 0x0422, 0 },
   1.220 +	{ 'U', 0, 0x0423, 0 },
   1.221 +	{ 'V', 0, 0x0412, 0 },
   1.222 +	{ 'W', 0, 0xFFFF, 0 },
   1.223 +	{ 'X', 0, 0xFFFF, 0 },
   1.224 +	{ 'Y', 0, 0x0419, 0 },
   1.225 +	{ 'Z', 0, 0x0417, 0 },
   1.226 +	{ 'a', 0, 0x0430, 0 },
   1.227 +	{ 'b', 0, 0x0431, 0 },
   1.228 +	{ 'c', 0, 0x0446, 0 },
   1.229 +	{ 'd', 0, 0x0434, 0 },
   1.230 +	{ 'e', 0, 0x0435, 0 },
   1.231 +	{ 'f', 0, 0x0444, 0 },
   1.232 +	{ 'g', 0, 0x0433, 0 },
   1.233 +	{ 'h', 0, 0x0445, 0 },
   1.234 +	{ 'i', 0, 0x0438, 0 },
   1.235 +	{ 'j', 0, 0xFFFF, 0 },
   1.236 +	{ 'k', 0, 0x043A, 0 },
   1.237 +	{ 'l', 0, 0x043B, 0 },
   1.238 +	{ 'm', 0, 0x043C, 0 },
   1.239 +	{ 'n', 0, 0x043D, 0 },
   1.240 +	{ 'o', 0, 0x043E, 0 },
   1.241 +	{ 'p', 0, 0x043F, 0 },
   1.242 +	{ 'q', 0, 0xFFFF, 0 },
   1.243 +	{ 'r', 0, 0x0440, 0 },
   1.244 +	{ 's', 0, 0x0441, 0 },
   1.245 +	{ 't', 0, 0x0442, 0 },
   1.246 +	{ 'u', 0, 0x0443, 0 },
   1.247 +	{ 'v', 0, 0x0432, 0 },
   1.248 +	{ 'w', 0, 0xFFFF, 0 },
   1.249 +	{ 'x', 0, 0xFFFF, 0 },
   1.250 +	{ 'y', 0, 0x0439, 0 },
   1.251 +	{ 'z', 0, 0x0437, 0 },
   1.252 +	};
   1.253 +static const TKeyboardMap TheRussianKeyboardMap =
   1.254 +	{
   1.255 +	TheRussianKeyAction,
   1.256 +	sizeof(TheRussianKeyAction) / sizeof(TKeyAction)
   1.257 +	};
   1.258 +
   1.259 +CWordTest* CWordTest::NewL(CTextView* aTextView)
   1.260 +	{
   1.261 +	return new(ELeave) CWordTest(aTextView);
   1.262 +	}
   1.263 +
   1.264 +CWordTest::CWordTest(CTextView* aTextView):
   1.265 +	iTextView(aTextView),
   1.266 +	iKeyboard(EStandardKeyboard),
   1.267 +	iKeyboardState(0),
   1.268 +	iRuledPaper(FALSE),
   1.269 +	iBackgroundBitmap(NULL),
   1.270 +	iTruncateWithEllipsis(FALSE),
   1.271 +	iCursorFlashing(TRUE),
   1.272 +	iCursorPlacement(ECursorVertical),
   1.273 +	iCursorWeight(3),
   1.274 +	iCursorXorColor(KRgbWhite),
   1.275 +	iStyleIndex(0),
   1.276 +	iPositioningHint(TCursorPosition::EPosHintUndefined)
   1.277 +	{
   1.278 +	}
   1.279 +
   1.280 +CWordTest::~CWordTest()
   1.281 +	{
   1.282 +	delete iBackgroundBitmap;
   1.283 +	}
   1.284 +
   1.285 +TKeyResponse CWordTest::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aEventCode,TChar& aCharToInsert)
   1.286 +	{
   1.287 +	if (iKeyboard == EStandardKeyboard)
   1.288 +		return EKeyWasNotConsumed;
   1.289 +	if (aEventCode != EEventKey)
   1.290 +		return EKeyWasNotConsumed;
   1.291 +	if (aKeyEvent.iCode >= ESpecialKeyBase && aKeyEvent.iCode < ESpecialKeyBase + ESpecialKeyCount)
   1.292 +		return EKeyWasNotConsumed;
   1.293 +	if (aKeyEvent.iCode >= ENonCharacterKeyBase && aKeyEvent.iCode < ENonCharacterKeyBase + ENonCharacterKeyCount)
   1.294 +		return EKeyWasNotConsumed;
   1.295 +	aCharToInsert = 0xFFFF;
   1.296 +		
   1.297 +	const TKeyboardMap* map = NULL;
   1.298 +	switch (iKeyboard)
   1.299 +		{
   1.300 +	case EArabicKeyboard:
   1.301 +		map = &TheArabicKeyboardMap;
   1.302 +		break;
   1.303 +	case EGreekKeyboard:
   1.304 +		map = &TheGreekKeyboardMap;
   1.305 +		break;
   1.306 +	case ERussianKeyboard:
   1.307 +		map = &TheRussianKeyboardMap;
   1.308 +		break;
   1.309 +	default:
   1.310 +		break;
   1.311 +		}
   1.312 +	if (map)
   1.313 +		{
   1.314 +		const TKeyAction* action = map->Find(aKeyEvent.iCode,iKeyboardState);
   1.315 +		if (action)
   1.316 +			{
   1.317 +			aCharToInsert = action->iCharToInsert;
   1.318 +			iKeyboardState = action->iNewState;
   1.319 +			return EKeyWasConsumed;
   1.320 +			}
   1.321 +		}
   1.322 +	return EKeyWasNotConsumed;
   1.323 +	}
   1.324 +
   1.325 +void CWordTest::SetKeyboardL(TKeyboardCode aKeyboard)
   1.326 +	{
   1.327 +	switch (aKeyboard)
   1.328 +		{
   1.329 +	case EArabicKeyboard:
   1.330 +		SetCursorPositioningHintL(TCursorPosition::EInsertStrongR2L);
   1.331 +		break;
   1.332 +	default:
   1.333 +		SetCursorPositioningHintL(TCursorPosition::EInsertStrongL2R);
   1.334 +		break;
   1.335 +		}
   1.336 +	iKeyboard = aKeyboard;
   1.337 +	}
   1.338 +
   1.339 +void CWordTest::SetPictureAlignmentL(CEikRichTextEditor* aEditor,TFontPresentation::TAlignment aAlignment)
   1.340 +	{
   1.341 +	TCharFormat format;
   1.342 +	format.iFontPresentation.iPictureAlignment = aAlignment;
   1.343 +	TCharFormatMask mask;
   1.344 +	mask.SetAttrib(EAttFontPictureAlignment);
   1.345 +	aEditor->ApplyCharFormatL(format,mask);
   1.346 +	}
   1.347 +
   1.348 +void CWordTest::SetWrapL(CEikRichTextEditor* aEditor,TBool aWrap)
   1.349 +	{
   1.350 +	CParaFormat format;
   1.351 +	format.iWrap = aWrap;
   1.352 +	TParaFormatMask mask;
   1.353 +	mask.SetAttrib(EAttWrap);
   1.354 +	aEditor->ApplyParaFormatL(&format,mask);
   1.355 +	}
   1.356 +	
   1.357 +void CWordTest::InsertPictureL(CEikRichTextEditor* aEditor)
   1.358 +	{
   1.359 +	CWordTestPicture* pic=CWordTestPicture::NewLC();
   1.360 +	TPictureHeader header;
   1.361 +   	header.iPictureType = KUidWordTestPictureType;
   1.362 +   	header.iPicture=pic;
   1.363 + 		
   1.364 + 	TInt pos = aEditor->CursorPos();
   1.365 + 	aEditor->RichText()->InsertL(pos, header); 
   1.366 +//CRichText::InsertL takes ownership of the picture via TPictureHeader 	
   1.367 + 	CleanupStack::Pop(pic); 
   1.368 + 	
   1.369 + 	aEditor->HandleTextChangedL();
   1.370 + 	aEditor->SetCursorPosL(pos+1, EFalse);	
   1.371 +	}
   1.372 +
   1.373 +void CWordTest::ToggleCaseL(CEikRichTextEditor* aEditor)
   1.374 +	{
   1.375 +	TCursorSelection sel = aEditor->Selection();
   1.376 +	int start = sel.LowerPos();
   1.377 +	int end = start;
   1.378 +	TBool to_upper = TRUE;
   1.379 +	while (end < sel.HigherPos())
   1.380 +		{
   1.381 +		TPtrC text;
   1.382 +		TCharFormat f;
   1.383 +		aEditor->RichText()->GetChars(text,f,start);
   1.384 +		int length = text.Length();
   1.385 +		if (start + length > sel.HigherPos())
   1.386 +			length = sel.HigherPos() - start;
   1.387 +		end = start + length;
   1.388 +		if (start == sel.LowerPos() && end > start)
   1.389 +			{
   1.390 +			if (TChar(text[0]).IsUpper())
   1.391 +				to_upper = FALSE;
   1.392 +			}
   1.393 +		TText* p = (TText*)text.Ptr();
   1.394 +		TText* q = p + length;
   1.395 +		while (p < q)
   1.396 +			{
   1.397 +			if (to_upper)
   1.398 +				*p = (TText)(TChar(*p).GetUpperCase());
   1.399 +			else
   1.400 +				*p = (TText)(TChar(*p).GetLowerCase());
   1.401 +			p++;
   1.402 +			}
   1.403 +
   1.404 +		start = end;
   1.405 +		}
   1.406 +	aEditor->TextView()->HandleRangeFormatChangeL(sel);
   1.407 +	}
   1.408 +
   1.409 +void CWordTest::BenchmarkL()
   1.410 +	{
   1.411 +	TTime start, end;
   1.412 +	start.HomeTime();
   1.413 +	const int n = 100;
   1.414 +	for (int i = 0; i < n; i++)
   1.415 +		iTextView->FormatTextL();
   1.416 +	end.HomeTime();
   1.417 +	int ms = (I64LOW(end.Int64()) - I64LOW(start.Int64())) / 1000;
   1.418 +	TBuf<128> message;
   1.419 +#ifdef _DEBUG
   1.420 +	_LIT(build,"debug");
   1.421 +#else
   1.422 +	_LIT(build,"release");
   1.423 +#endif
   1.424 +	message.Format(_L("form%d %S: reformatting %d times took %d milliseconds"),
   1.425 +		iTextView->Layout()->MajorVersion(),&build,n,ms);
   1.426 +	User::InfoPrint(message);
   1.427 +	}
   1.428 +
   1.429 +void CWordTest::SetTruncateWithEllipsisL(CEikRichTextEditor* aEditor,TBool aOn)
   1.430 +	{
   1.431 +	iTruncateWithEllipsis = aOn;
   1.432 +	aEditor->TextLayout()->SetTruncating(aOn);
   1.433 +	aEditor->NotifyNewFormatL();
   1.434 +	}
   1.435 +
   1.436 +void CWordTest::ToggleCursorFlash()
   1.437 +	{
   1.438 +	iCursorFlashing = !iCursorFlashing;
   1.439 +	iTextView->SetCursorFlash(iCursorFlashing);
   1.440 +	}
   1.441 +
   1.442 +void CWordTest::SetCursorPlacement(TTmCursorPlacement aPlacement)
   1.443 +	{
   1.444 +	iCursorPlacement = aPlacement;
   1.445 +	iTextView->SetCursorPlacement(aPlacement);
   1.446 +	}
   1.447 +
   1.448 +void CWordTest::SetCursorWeight(TInt aWeight)
   1.449 +	{
   1.450 +	iCursorWeight = aWeight;
   1.451 +	iTextView->SetCursorWeight(aWeight);
   1.452 +	}
   1.453 +
   1.454 +void CWordTest::SetCursorXorColor(TRgb aColor)
   1.455 +	{
   1.456 +	iCursorXorColor = aColor;
   1.457 +	iTextView->SetCursorXorColor(aColor);
   1.458 +	}
   1.459 +
   1.460 +void CWordTest::TurnOnCustomDrawing(CTextLayout* aLayout)
   1.461 +	{
   1.462 +	if (aLayout->MajorVersion() == 2) // custom drawing is not supported in FORM1
   1.463 +		aLayout->SetCustomDraw(this);
   1.464 +	}
   1.465 +
   1.466 +void CWordTest::SetSelectionHighlightStyle(TInt aStyleIndex)
   1.467 +	{
   1.468 +	iStyleIndex = aStyleIndex;
   1.469 +	}
   1.470 +
   1.471 +TInt CWordTest::SelectionHighlightStyle() const
   1.472 +	{
   1.473 +	return iStyleIndex;
   1.474 +	}
   1.475 +
   1.476 +void CWordTest::DrawLineGraphics(const TParam& aParam,const TLineInfo& aLineInfo) const
   1.477 +	{
   1.478 +	if (iRuledPaper)
   1.479 +		{
   1.480 +		aParam.iGc.SetPenColor(KRgbRed);
   1.481 +		TPoint p(aLineInfo.iOuterRect.iTl.iX,aLineInfo.iInnerRect.iBr.iY - 1);
   1.482 +		TPoint q(aLineInfo.iOuterRect.iBr.iX,aLineInfo.iInnerRect.iBr.iY - 1);
   1.483 +		aParam.iGc.DrawLine(p,q);
   1.484 +		}
   1.485 +	}
   1.486 +
   1.487 +void CWordTest::DrawText(const TParam& aParam,const TLineInfo& aLineInfo,const TCharFormat& aFormat,const TDesC& aText,
   1.488 +						 const TPoint& aTextOrigin,TInt aExtraPixels) const
   1.489 +	{
   1.490 +	/*
   1.491 +	Draw outlined text by drawing the text nine times: eight times in the background colour, moving the origin
   1.492 +	one pixel up, down, right, and left to make a box, and once in the foreground colour, not offset.
   1.493 +	*/
   1.494 +	if (aFormat.iFontPresentation.iHighlightStyle == TFontPresentation::EFontHighlightFirstCustomStyle)
   1.495 +		{
   1.496 +		aParam.iGc.SetPenColor(aFormat.iFontPresentation.iTextColor);
   1.497 +		for (int x = -1; x <= 1; x++)
   1.498 +			for (int y = -1; y <= 1; y++)
   1.499 +				if (x || y)
   1.500 +					{
   1.501 +					if (aExtraPixels)
   1.502 +						aParam.iGc.SetCharJustification(aExtraPixels,aText.Length());
   1.503 +					TPoint p(aTextOrigin);
   1.504 +					p.iX += x;
   1.505 +					p.iY += y;
   1.506 +					aParam.iGc.DrawText(aText,p);
   1.507 +					}
   1.508 +		aParam.iGc.SetPenColor(aFormat.iFontPresentation.iHighlightColor);
   1.509 +		}
   1.510 +	MFormCustomDraw::DrawText(aParam,aLineInfo,aFormat,aText,aTextOrigin,aExtraPixels);
   1.511 +	}
   1.512 +
   1.513 +void CWordTest::DrawBackground(const TParam& aParam,const TRgb& aBackground,TRect& aDrawn) const
   1.514 +	{
   1.515 +	if (iBackgroundBitmap)
   1.516 +		{
   1.517 +		aParam.iGc.SetClippingRect(aParam.iDrawRect);
   1.518 +		aDrawn.SetRect(aParam.iTextLayoutTopLeft,iBackgroundBitmap->SizeInPixels());
   1.519 +		aParam.iGc.DrawBitmap(aDrawn,iBackgroundBitmap);
   1.520 +		}
   1.521 +	else
   1.522 +		MFormCustomDraw::DrawBackground(aParam,aBackground,aDrawn);
   1.523 +	}
   1.524 +
   1.525 +TRgb CWordTest::SystemColor(TUint aColorIndex, TRgb aDefaultColor) const
   1.526 +	{
   1.527 +	if (aColorIndex == TLogicalRgb::ESystemSelectionForegroundIndex)
   1.528 +		{
   1.529 +		switch (iStyleIndex)
   1.530 +			{
   1.531 +		case 1:
   1.532 +			return KRgbBlue;
   1.533 +		case 2:
   1.534 +			return KRgbWhite;
   1.535 +		default:
   1.536 +			break;
   1.537 +			}
   1.538 +		}
   1.539 +	else if (aColorIndex == TLogicalRgb::ESystemSelectionBackgroundIndex)
   1.540 +		{
   1.541 +		switch (iStyleIndex)
   1.542 +			{
   1.543 +		case 1:
   1.544 +			return KRgbBlue;
   1.545 +		case 2:
   1.546 +			return KRgbRed;
   1.547 +		default:
   1.548 +			break;
   1.549 +			}
   1.550 +		}
   1.551 +	return aDefaultColor;
   1.552 +	}
   1.553 +
   1.554 +void CWordTest::SetRuledPaperL(CEikRichTextEditor* aEditor,TBool aOn)
   1.555 +	{
   1.556 +	iRuledPaper = aOn;
   1.557 +	aEditor->NotifyNewFormatL();
   1.558 +	}
   1.559 +
   1.560 +void CWordTest::SetBackgroundBitmapL(CEikRichTextEditor* aEditor,TBool aOn)
   1.561 +	{
   1.562 +	if (iBackgroundBitmap)
   1.563 +		delete iBackgroundBitmap;
   1.564 +	iBackgroundBitmap = NULL;
   1.565 +	if (aOn)
   1.566 +		{
   1.567 +		_LIT(KPathMask, "_:\\");
   1.568 +		TFileName filename(KPathMask);
   1.569 +		filename[0] = 'A' + static_cast<TInt>(RFs::GetSystemDrive());
   1.570 +		
   1.571 +		CEikFileOpenDialog* dialog = new(ELeave) CEikFileOpenDialog(&filename);
   1.572 +		if (dialog->ExecuteLD(R_EIK_DIALOG_FILE_OPEN))
   1.573 +			{
   1.574 +			iBackgroundBitmap = new(ELeave) CFbsBitmap;
   1.575 +			if (iBackgroundBitmap->Load(filename))
   1.576 +				User::InfoPrint(_L("cannot load this file as a bitmap"));
   1.577 +			}
   1.578 +		}
   1.579 +	aEditor->NotifyNewFormatL();
   1.580 +	}
   1.581 +
   1.582 +void CWordTest::SetCursorPositioningHintL(
   1.583 +	TCursorPosition::TPosHint aHint)
   1.584 +	{
   1.585 +	iTextView->SetCursorPositioningHintL(aHint);
   1.586 +	iPositioningHint = aHint;
   1.587 +	}
   1.588 +
   1.589 +TCursorPosition::TPosHint CWordTest::CursorPositioningHint() const
   1.590 +	{
   1.591 +	return iPositioningHint;
   1.592 +	}