textrendering/word/SRC/WPTEST.CPP
changeset 0 1fb32624e06b
equal deleted inserted replaced
-1:000000000000 0:1fb32624e06b
       
     1 /*
       
     2 * Copyright (c) 1999-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 * Functions added to Word for test purposes now that Word is no longer a standard EPOC application.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <e32std.h>
       
    21 #include <techview/eikcfdlg.h>
       
    22 #include <techview/eikon.rsg>
       
    23 #include "WPAPPUI.H"
       
    24 #include "WPTEXTED.H"
       
    25 #include "WPTEST.H"
       
    26 #include "WPTESTPICTURE.H"
       
    27 
       
    28 
       
    29 struct TKeyAction
       
    30 	{
       
    31 	TInt Compare(TInt aKeyCode,TInt aState) const;
       
    32 
       
    33 	TInt iKeyCode;			// key pressed by user
       
    34 	TInt iState;			// state in which this action fires
       
    35 	TInt iCharToInsert;		// character to insert; if 0xFFFF, none
       
    36 	TInt iNewState;			// new state
       
    37 	};
       
    38 
       
    39 TInt TKeyAction::Compare(TInt aKeyCode,TInt aState) const
       
    40 	{
       
    41 	if (iKeyCode - aKeyCode)
       
    42 		return iKeyCode - aKeyCode;
       
    43 	return iState - aState;
       
    44 	}
       
    45 
       
    46 struct TKeyboardMap
       
    47 	{
       
    48 	const TKeyAction* Find(TInt aKeyCode,TInt aState) const;
       
    49 
       
    50 	const TKeyAction* iKeyAction;	// action table
       
    51 	TInt iKeyActions;				// number of entries in table
       
    52 	};
       
    53 
       
    54 const TKeyAction* TKeyboardMap::Find(TInt aKeyCode,TInt aState) const
       
    55 	{
       
    56 	const TKeyAction* base = iKeyAction;
       
    57 	const TKeyAction* end = iKeyAction + iKeyActions;
       
    58 	while (base < end)
       
    59 		{
       
    60 		int n = end - base;
       
    61 		const TKeyAction* a = &base[n / 2];
       
    62 		int diff = a->Compare(aKeyCode,aState);
       
    63 		if (diff > 0)
       
    64 			end = a;
       
    65 		else if (diff < 0)
       
    66 			base = a + 1;
       
    67 		else
       
    68 			return a;
       
    69 		}
       
    70 	return NULL;
       
    71 	}
       
    72 
       
    73 static const TKeyAction TheArabicKeyAction[] =
       
    74 	{
       
    75 	{ 'A', 0, 0x0649, 0 },
       
    76 	{ 'B', 0, 0xFFFF, 0 },
       
    77 	{ 'C', 0, 0xFFFF, 0 },
       
    78 	{ 'D', 0, 0x0636, 0 },
       
    79 	{ 'E', 0, 0xFFFF, 0 },
       
    80 	{ 'F', 0, 0xFFFF, 0 },
       
    81 	{ 'G', 0, 0x063A, 0 },
       
    82 	{ 'H', 0, 0x062D, 0 },
       
    83 	{ 'I', 0, 0xFFFF, 0 },
       
    84 	{ 'J', 0, 0xFFFF, 0 },
       
    85 	{ 'K', 0, 0xFFFF, 0 },
       
    86 	{ 'L', 0, 0xFFFF, 0 },
       
    87 	{ 'M', 0, 0xFFFF, 0 },
       
    88 	{ 'N', 0, 0xFFFF, 0 },
       
    89 	{ 'O', 0, 0xFFFF, 0 },
       
    90 	{ 'P', 0, 0xFFFF, 0 },
       
    91 	{ 'Q', 0, 0xFFFF, 0 },
       
    92 	{ 'R', 0, 0xFFFF, 0 },
       
    93 	{ 'S', 0, 0x0635, 0 },
       
    94 	{ 'T', 0, 0x0637, 0 },
       
    95 	{ 'U', 0, 0xFFFF, 0 },
       
    96 	{ 'V', 0, 0xFFFF, 0 },
       
    97 	{ 'W', 0, 0xFFFF, 0 },
       
    98 	{ 'X', 0, 0xFFFF, 0 },
       
    99 	{ 'Y', 0, 0xFFFF, 0 },
       
   100 	{ 'Z', 0, 0x0638, 0 },
       
   101 	{ 'a', 0, 0x0627, 0 },
       
   102 	{ 'b', 0, 0x0628, 0 },
       
   103 	{ 'c', 0, 0xFFFF, 0 },
       
   104 	{ 'd', 0, 0x062F, 0 },
       
   105 	{ 'e', 0, 0xFFFF, 0 },
       
   106 	{ 'f', 0, 0x0641, 0 },
       
   107 	{ 'g', 0, 0x0639, 0 },
       
   108 	{ 'h', 0, 0x0647, 0 },
       
   109 	{ 'i', 0, 0xFFFF, 0 },
       
   110 	{ 'j', 0, 0x062C, 0 },
       
   111 	{ 'k', 0, 0x0643, 0 },
       
   112 	{ 'l', 0, 0x0644, 0 },
       
   113 	{ 'm', 0, 0x0645, 0 },
       
   114 	{ 'n', 0, 0x0646, 0 },
       
   115 	{ 'o', 0, 0xFFFF, 0 },
       
   116 	{ 'p', 0, 0x067E, 0 },
       
   117 	{ 'q', 0, 0x0642, 0 },
       
   118 	{ 'r', 0, 0x0631, 0 },
       
   119 	{ 's', 0, 0x0633, 0 },
       
   120 	{ 't', 0, 0x062A, 0 },
       
   121 	{ 'u', 0, 0xFFFF, 0 },
       
   122 	{ 'v', 0, 0xFFFF, 0 },
       
   123 	{ 'w', 0, 0x0648, 0 },
       
   124 	{ 'x', 0, 0x062E, 0 },
       
   125 	{ 'y', 0, 0x064A, 0 },
       
   126 	{ 'z', 0, 0x0632, 0 },
       
   127 	};
       
   128 static const TKeyboardMap TheArabicKeyboardMap =
       
   129 	{
       
   130 	TheArabicKeyAction,
       
   131 	sizeof(TheArabicKeyAction) / sizeof(TKeyAction)
       
   132 	};
       
   133 
       
   134 static const TKeyAction TheGreekKeyAction[] =
       
   135 	{
       
   136 	{ 'A', 0, 0x0391, 0 },
       
   137 	{ 'B', 0, 0x0392, 0 },
       
   138 	{ 'C', 0, 0xFFFF, 0 },
       
   139 	{ 'D', 0, 0x0394, 0 },
       
   140 	{ 'E', 0, 0x0395, 0 },
       
   141 	{ 'F', 0, 0x03A6, 0 },
       
   142 	{ 'G', 0, 0x0393, 0 },
       
   143 	{ 'H', 0, 0x03A7, 0 },
       
   144 	{ 'I', 0, 0x0399, 0 },
       
   145 	{ 'J', 0, 0x0397, 0 },
       
   146 	{ 'K', 0, 0x039A, 0 },
       
   147 	{ 'L', 0, 0x039B, 0 },
       
   148 	{ 'M', 0, 0x039C, 0 },
       
   149 	{ 'N', 0, 0x039D, 0 },
       
   150 	{ 'O', 0, 0x039F, 0 },
       
   151 	{ 'P', 0, 0x03A0, 0 },
       
   152 	{ 'Q', 0, 0x0398, 0 },
       
   153 	{ 'R', 0, 0x03A1, 0 },
       
   154 	{ 'S', 0, 0x03A3, 0 },
       
   155 	{ 'T', 0, 0x03A4, 0 },
       
   156 	{ 'U', 0, 0x03A5, 0 },
       
   157 	{ 'V', 0, 0x03A8, 0 },
       
   158 	{ 'W', 0, 0x03A9, 0 },
       
   159 	{ 'X', 0, 0x039E, 0 },
       
   160 	{ 'Y', 0, 0xFFFF, 0 },
       
   161 	{ 'Z', 0, 0x0396, 0 },
       
   162 	{ 'a', 0, 0x03B1, 0 },
       
   163 	{ 'b', 0, 0x03B2, 0 },
       
   164 	{ 'c', 0, 0x03C2, 0 },
       
   165 	{ 'd', 0, 0x03B4, 0 },
       
   166 	{ 'e', 0, 0x03B5, 0 },
       
   167 	{ 'f', 0, 0x03C6, 0 },
       
   168 	{ 'g', 0, 0x03B3, 0 },
       
   169 	{ 'h', 0, 0x03C7, 0 },
       
   170 	{ 'i', 0, 0x03B9, 0 },
       
   171 	{ 'j', 0, 0x03B7, 0 },
       
   172 	{ 'k', 0, 0x03BA, 0 },
       
   173 	{ 'l', 0, 0x03BB, 0 },
       
   174 	{ 'm', 0, 0x03BC, 0 },
       
   175 	{ 'n', 0, 0x03BD, 0 },
       
   176 	{ 'o', 0, 0x03BF, 0 },
       
   177 	{ 'p', 0, 0x03C0, 0 },
       
   178 	{ 'q', 0, 0x03B8, 0 },
       
   179 	{ 'r', 0, 0x03C1, 0 },
       
   180 	{ 's', 0, 0x03C3, 0 },
       
   181 	{ 't', 0, 0x03C4, 0 },
       
   182 	{ 'u', 0, 0x03C5, 0 },
       
   183 	{ 'v', 0, 0x03C8, 0 },
       
   184 	{ 'w', 0, 0x03C9, 0 },
       
   185 	{ 'x', 0, 0x03BE, 0 },
       
   186 	{ 'y', 0, 0xFFFF, 0 },
       
   187 	{ 'z', 0, 0x03B6, 0 },
       
   188 	};
       
   189 static const TKeyboardMap TheGreekKeyboardMap =
       
   190 	{
       
   191 	TheGreekKeyAction,
       
   192 	sizeof(TheGreekKeyAction) / sizeof(TKeyAction)
       
   193 	};
       
   194 
       
   195 static const TKeyAction TheRussianKeyAction[] =
       
   196 	{
       
   197 	{ 'A', 0, 0x0410, 0 },
       
   198 	{ 'B', 0, 0x0411, 0 },
       
   199 	{ 'C', 0, 0x0426, 0 },
       
   200 	{ 'D', 0, 0x0414, 0 },
       
   201 	{ 'E', 0, 0x0415, 0 },
       
   202 	{ 'F', 0, 0x0424, 0 },
       
   203 	{ 'G', 0, 0x0413, 0 },
       
   204 	{ 'H', 0, 0x0425, 0 },
       
   205 	{ 'I', 0, 0x0418, 0 },
       
   206 	{ 'J', 0, 0xFFFF, 0 },
       
   207 	{ 'K', 0, 0x041A, 0 },
       
   208 	{ 'L', 0, 0x041B, 0 },
       
   209 	{ 'M', 0, 0x041C, 0 },
       
   210 	{ 'N', 0, 0x041D, 0 },
       
   211 	{ 'O', 0, 0x041E, 0 },
       
   212 	{ 'P', 0, 0x041F, 0 },
       
   213 	{ 'Q', 0, 0xFFFF, 0 },
       
   214 	{ 'R', 0, 0x0420, 0 },
       
   215 	{ 'S', 0, 0x0421, 0 },
       
   216 	{ 'T', 0, 0x0422, 0 },
       
   217 	{ 'U', 0, 0x0423, 0 },
       
   218 	{ 'V', 0, 0x0412, 0 },
       
   219 	{ 'W', 0, 0xFFFF, 0 },
       
   220 	{ 'X', 0, 0xFFFF, 0 },
       
   221 	{ 'Y', 0, 0x0419, 0 },
       
   222 	{ 'Z', 0, 0x0417, 0 },
       
   223 	{ 'a', 0, 0x0430, 0 },
       
   224 	{ 'b', 0, 0x0431, 0 },
       
   225 	{ 'c', 0, 0x0446, 0 },
       
   226 	{ 'd', 0, 0x0434, 0 },
       
   227 	{ 'e', 0, 0x0435, 0 },
       
   228 	{ 'f', 0, 0x0444, 0 },
       
   229 	{ 'g', 0, 0x0433, 0 },
       
   230 	{ 'h', 0, 0x0445, 0 },
       
   231 	{ 'i', 0, 0x0438, 0 },
       
   232 	{ 'j', 0, 0xFFFF, 0 },
       
   233 	{ 'k', 0, 0x043A, 0 },
       
   234 	{ 'l', 0, 0x043B, 0 },
       
   235 	{ 'm', 0, 0x043C, 0 },
       
   236 	{ 'n', 0, 0x043D, 0 },
       
   237 	{ 'o', 0, 0x043E, 0 },
       
   238 	{ 'p', 0, 0x043F, 0 },
       
   239 	{ 'q', 0, 0xFFFF, 0 },
       
   240 	{ 'r', 0, 0x0440, 0 },
       
   241 	{ 's', 0, 0x0441, 0 },
       
   242 	{ 't', 0, 0x0442, 0 },
       
   243 	{ 'u', 0, 0x0443, 0 },
       
   244 	{ 'v', 0, 0x0432, 0 },
       
   245 	{ 'w', 0, 0xFFFF, 0 },
       
   246 	{ 'x', 0, 0xFFFF, 0 },
       
   247 	{ 'y', 0, 0x0439, 0 },
       
   248 	{ 'z', 0, 0x0437, 0 },
       
   249 	};
       
   250 static const TKeyboardMap TheRussianKeyboardMap =
       
   251 	{
       
   252 	TheRussianKeyAction,
       
   253 	sizeof(TheRussianKeyAction) / sizeof(TKeyAction)
       
   254 	};
       
   255 
       
   256 CWordTest* CWordTest::NewL(CTextView* aTextView)
       
   257 	{
       
   258 	return new(ELeave) CWordTest(aTextView);
       
   259 	}
       
   260 
       
   261 CWordTest::CWordTest(CTextView* aTextView):
       
   262 	iTextView(aTextView),
       
   263 	iKeyboard(EStandardKeyboard),
       
   264 	iKeyboardState(0),
       
   265 	iRuledPaper(FALSE),
       
   266 	iBackgroundBitmap(NULL),
       
   267 	iTruncateWithEllipsis(FALSE),
       
   268 	iCursorFlashing(TRUE),
       
   269 	iCursorPlacement(ECursorVertical),
       
   270 	iCursorWeight(3),
       
   271 	iCursorXorColor(KRgbWhite),
       
   272 	iStyleIndex(0),
       
   273 	iPositioningHint(TCursorPosition::EPosHintUndefined)
       
   274 	{
       
   275 	}
       
   276 
       
   277 CWordTest::~CWordTest()
       
   278 	{
       
   279 	delete iBackgroundBitmap;
       
   280 	}
       
   281 
       
   282 TKeyResponse CWordTest::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aEventCode,TChar& aCharToInsert)
       
   283 	{
       
   284 	if (iKeyboard == EStandardKeyboard)
       
   285 		return EKeyWasNotConsumed;
       
   286 	if (aEventCode != EEventKey)
       
   287 		return EKeyWasNotConsumed;
       
   288 	if (aKeyEvent.iCode >= ESpecialKeyBase && aKeyEvent.iCode < ESpecialKeyBase + ESpecialKeyCount)
       
   289 		return EKeyWasNotConsumed;
       
   290 	if (aKeyEvent.iCode >= ENonCharacterKeyBase && aKeyEvent.iCode < ENonCharacterKeyBase + ENonCharacterKeyCount)
       
   291 		return EKeyWasNotConsumed;
       
   292 	aCharToInsert = 0xFFFF;
       
   293 		
       
   294 	const TKeyboardMap* map = NULL;
       
   295 	switch (iKeyboard)
       
   296 		{
       
   297 	case EArabicKeyboard:
       
   298 		map = &TheArabicKeyboardMap;
       
   299 		break;
       
   300 	case EGreekKeyboard:
       
   301 		map = &TheGreekKeyboardMap;
       
   302 		break;
       
   303 	case ERussianKeyboard:
       
   304 		map = &TheRussianKeyboardMap;
       
   305 		break;
       
   306 	default:
       
   307 		break;
       
   308 		}
       
   309 	if (map)
       
   310 		{
       
   311 		const TKeyAction* action = map->Find(aKeyEvent.iCode,iKeyboardState);
       
   312 		if (action)
       
   313 			{
       
   314 			aCharToInsert = action->iCharToInsert;
       
   315 			iKeyboardState = action->iNewState;
       
   316 			return EKeyWasConsumed;
       
   317 			}
       
   318 		}
       
   319 	return EKeyWasNotConsumed;
       
   320 	}
       
   321 
       
   322 void CWordTest::SetKeyboardL(TKeyboardCode aKeyboard)
       
   323 	{
       
   324 	switch (aKeyboard)
       
   325 		{
       
   326 	case EArabicKeyboard:
       
   327 		SetCursorPositioningHintL(TCursorPosition::EInsertStrongR2L);
       
   328 		break;
       
   329 	default:
       
   330 		SetCursorPositioningHintL(TCursorPosition::EInsertStrongL2R);
       
   331 		break;
       
   332 		}
       
   333 	iKeyboard = aKeyboard;
       
   334 	}
       
   335 
       
   336 void CWordTest::SetPictureAlignmentL(CEikRichTextEditor* aEditor,TFontPresentation::TAlignment aAlignment)
       
   337 	{
       
   338 	TCharFormat format;
       
   339 	format.iFontPresentation.iPictureAlignment = aAlignment;
       
   340 	TCharFormatMask mask;
       
   341 	mask.SetAttrib(EAttFontPictureAlignment);
       
   342 	aEditor->ApplyCharFormatL(format,mask);
       
   343 	}
       
   344 
       
   345 void CWordTest::SetWrapL(CEikRichTextEditor* aEditor,TBool aWrap)
       
   346 	{
       
   347 	CParaFormat format;
       
   348 	format.iWrap = aWrap;
       
   349 	TParaFormatMask mask;
       
   350 	mask.SetAttrib(EAttWrap);
       
   351 	aEditor->ApplyParaFormatL(&format,mask);
       
   352 	}
       
   353 	
       
   354 void CWordTest::InsertPictureL(CEikRichTextEditor* aEditor)
       
   355 	{
       
   356 	CWordTestPicture* pic=CWordTestPicture::NewLC();
       
   357 	TPictureHeader header;
       
   358    	header.iPictureType = KUidWordTestPictureType;
       
   359    	header.iPicture=pic;
       
   360  		
       
   361  	TInt pos = aEditor->CursorPos();
       
   362  	aEditor->RichText()->InsertL(pos, header); 
       
   363 //CRichText::InsertL takes ownership of the picture via TPictureHeader 	
       
   364  	CleanupStack::Pop(pic); 
       
   365  	
       
   366  	aEditor->HandleTextChangedL();
       
   367  	aEditor->SetCursorPosL(pos+1, EFalse);	
       
   368 	}
       
   369 
       
   370 void CWordTest::ToggleCaseL(CEikRichTextEditor* aEditor)
       
   371 	{
       
   372 	TCursorSelection sel = aEditor->Selection();
       
   373 	int start = sel.LowerPos();
       
   374 	int end = start;
       
   375 	TBool to_upper = TRUE;
       
   376 	while (end < sel.HigherPos())
       
   377 		{
       
   378 		TPtrC text;
       
   379 		TCharFormat f;
       
   380 		aEditor->RichText()->GetChars(text,f,start);
       
   381 		int length = text.Length();
       
   382 		if (start + length > sel.HigherPos())
       
   383 			length = sel.HigherPos() - start;
       
   384 		end = start + length;
       
   385 		if (start == sel.LowerPos() && end > start)
       
   386 			{
       
   387 			if (TChar(text[0]).IsUpper())
       
   388 				to_upper = FALSE;
       
   389 			}
       
   390 		TText* p = (TText*)text.Ptr();
       
   391 		TText* q = p + length;
       
   392 		while (p < q)
       
   393 			{
       
   394 			if (to_upper)
       
   395 				*p = (TText)(TChar(*p).GetUpperCase());
       
   396 			else
       
   397 				*p = (TText)(TChar(*p).GetLowerCase());
       
   398 			p++;
       
   399 			}
       
   400 
       
   401 		start = end;
       
   402 		}
       
   403 	aEditor->TextView()->HandleRangeFormatChangeL(sel);
       
   404 	}
       
   405 
       
   406 void CWordTest::BenchmarkL()
       
   407 	{
       
   408 	TTime start, end;
       
   409 	start.HomeTime();
       
   410 	const int n = 100;
       
   411 	for (int i = 0; i < n; i++)
       
   412 		iTextView->FormatTextL();
       
   413 	end.HomeTime();
       
   414 	int ms = (I64LOW(end.Int64()) - I64LOW(start.Int64())) / 1000;
       
   415 	TBuf<128> message;
       
   416 #ifdef _DEBUG
       
   417 	_LIT(build,"debug");
       
   418 #else
       
   419 	_LIT(build,"release");
       
   420 #endif
       
   421 	message.Format(_L("form%d %S: reformatting %d times took %d milliseconds"),
       
   422 		iTextView->Layout()->MajorVersion(),&build,n,ms);
       
   423 	User::InfoPrint(message);
       
   424 	}
       
   425 
       
   426 void CWordTest::SetTruncateWithEllipsisL(CEikRichTextEditor* aEditor,TBool aOn)
       
   427 	{
       
   428 	iTruncateWithEllipsis = aOn;
       
   429 	aEditor->TextLayout()->SetTruncating(aOn);
       
   430 	aEditor->NotifyNewFormatL();
       
   431 	}
       
   432 
       
   433 void CWordTest::ToggleCursorFlash()
       
   434 	{
       
   435 	iCursorFlashing = !iCursorFlashing;
       
   436 	iTextView->SetCursorFlash(iCursorFlashing);
       
   437 	}
       
   438 
       
   439 void CWordTest::SetCursorPlacement(TTmCursorPlacement aPlacement)
       
   440 	{
       
   441 	iCursorPlacement = aPlacement;
       
   442 	iTextView->SetCursorPlacement(aPlacement);
       
   443 	}
       
   444 
       
   445 void CWordTest::SetCursorWeight(TInt aWeight)
       
   446 	{
       
   447 	iCursorWeight = aWeight;
       
   448 	iTextView->SetCursorWeight(aWeight);
       
   449 	}
       
   450 
       
   451 void CWordTest::SetCursorXorColor(TRgb aColor)
       
   452 	{
       
   453 	iCursorXorColor = aColor;
       
   454 	iTextView->SetCursorXorColor(aColor);
       
   455 	}
       
   456 
       
   457 void CWordTest::TurnOnCustomDrawing(CTextLayout* aLayout)
       
   458 	{
       
   459 	if (aLayout->MajorVersion() == 2) // custom drawing is not supported in FORM1
       
   460 		aLayout->SetCustomDraw(this);
       
   461 	}
       
   462 
       
   463 void CWordTest::SetSelectionHighlightStyle(TInt aStyleIndex)
       
   464 	{
       
   465 	iStyleIndex = aStyleIndex;
       
   466 	}
       
   467 
       
   468 TInt CWordTest::SelectionHighlightStyle() const
       
   469 	{
       
   470 	return iStyleIndex;
       
   471 	}
       
   472 
       
   473 void CWordTest::DrawLineGraphics(const TParam& aParam,const TLineInfo& aLineInfo) const
       
   474 	{
       
   475 	if (iRuledPaper)
       
   476 		{
       
   477 		aParam.iGc.SetPenColor(KRgbRed);
       
   478 		TPoint p(aLineInfo.iOuterRect.iTl.iX,aLineInfo.iInnerRect.iBr.iY - 1);
       
   479 		TPoint q(aLineInfo.iOuterRect.iBr.iX,aLineInfo.iInnerRect.iBr.iY - 1);
       
   480 		aParam.iGc.DrawLine(p,q);
       
   481 		}
       
   482 	}
       
   483 
       
   484 void CWordTest::DrawText(const TParam& aParam,const TLineInfo& aLineInfo,const TCharFormat& aFormat,const TDesC& aText,
       
   485 						 const TPoint& aTextOrigin,TInt aExtraPixels) const
       
   486 	{
       
   487 	/*
       
   488 	Draw outlined text by drawing the text nine times: eight times in the background colour, moving the origin
       
   489 	one pixel up, down, right, and left to make a box, and once in the foreground colour, not offset.
       
   490 	*/
       
   491 	if (aFormat.iFontPresentation.iHighlightStyle == TFontPresentation::EFontHighlightFirstCustomStyle)
       
   492 		{
       
   493 		aParam.iGc.SetPenColor(aFormat.iFontPresentation.iTextColor);
       
   494 		for (int x = -1; x <= 1; x++)
       
   495 			for (int y = -1; y <= 1; y++)
       
   496 				if (x || y)
       
   497 					{
       
   498 					if (aExtraPixels)
       
   499 						aParam.iGc.SetCharJustification(aExtraPixels,aText.Length());
       
   500 					TPoint p(aTextOrigin);
       
   501 					p.iX += x;
       
   502 					p.iY += y;
       
   503 					aParam.iGc.DrawText(aText,p);
       
   504 					}
       
   505 		aParam.iGc.SetPenColor(aFormat.iFontPresentation.iHighlightColor);
       
   506 		}
       
   507 	MFormCustomDraw::DrawText(aParam,aLineInfo,aFormat,aText,aTextOrigin,aExtraPixels);
       
   508 	}
       
   509 
       
   510 void CWordTest::DrawBackground(const TParam& aParam,const TRgb& aBackground,TRect& aDrawn) const
       
   511 	{
       
   512 	if (iBackgroundBitmap)
       
   513 		{
       
   514 		aParam.iGc.SetClippingRect(aParam.iDrawRect);
       
   515 		aDrawn.SetRect(aParam.iTextLayoutTopLeft,iBackgroundBitmap->SizeInPixels());
       
   516 		aParam.iGc.DrawBitmap(aDrawn,iBackgroundBitmap);
       
   517 		}
       
   518 	else
       
   519 		MFormCustomDraw::DrawBackground(aParam,aBackground,aDrawn);
       
   520 	}
       
   521 
       
   522 TRgb CWordTest::SystemColor(TUint aColorIndex, TRgb aDefaultColor) const
       
   523 	{
       
   524 	if (aColorIndex == TLogicalRgb::ESystemSelectionForegroundIndex)
       
   525 		{
       
   526 		switch (iStyleIndex)
       
   527 			{
       
   528 		case 1:
       
   529 			return KRgbBlue;
       
   530 		case 2:
       
   531 			return KRgbWhite;
       
   532 		default:
       
   533 			break;
       
   534 			}
       
   535 		}
       
   536 	else if (aColorIndex == TLogicalRgb::ESystemSelectionBackgroundIndex)
       
   537 		{
       
   538 		switch (iStyleIndex)
       
   539 			{
       
   540 		case 1:
       
   541 			return KRgbBlue;
       
   542 		case 2:
       
   543 			return KRgbRed;
       
   544 		default:
       
   545 			break;
       
   546 			}
       
   547 		}
       
   548 	return aDefaultColor;
       
   549 	}
       
   550 
       
   551 void CWordTest::SetRuledPaperL(CEikRichTextEditor* aEditor,TBool aOn)
       
   552 	{
       
   553 	iRuledPaper = aOn;
       
   554 	aEditor->NotifyNewFormatL();
       
   555 	}
       
   556 
       
   557 void CWordTest::SetBackgroundBitmapL(CEikRichTextEditor* aEditor,TBool aOn)
       
   558 	{
       
   559 	if (iBackgroundBitmap)
       
   560 		delete iBackgroundBitmap;
       
   561 	iBackgroundBitmap = NULL;
       
   562 	if (aOn)
       
   563 		{
       
   564 		_LIT(KPathMask, "_:\\");
       
   565 		TFileName filename(KPathMask);
       
   566 		filename[0] = 'A' + static_cast<TInt>(RFs::GetSystemDrive());
       
   567 		
       
   568 		CEikFileOpenDialog* dialog = new(ELeave) CEikFileOpenDialog(&filename);
       
   569 		if (dialog->ExecuteLD(R_EIK_DIALOG_FILE_OPEN))
       
   570 			{
       
   571 			iBackgroundBitmap = new(ELeave) CFbsBitmap;
       
   572 			if (iBackgroundBitmap->Load(filename))
       
   573 				User::InfoPrint(_L("cannot load this file as a bitmap"));
       
   574 			}
       
   575 		}
       
   576 	aEditor->NotifyNewFormatL();
       
   577 	}
       
   578 
       
   579 void CWordTest::SetCursorPositioningHintL(
       
   580 	TCursorPosition::TPosHint aHint)
       
   581 	{
       
   582 	iTextView->SetCursorPositioningHintL(aHint);
       
   583 	iPositioningHint = aHint;
       
   584 	}
       
   585 
       
   586 TCursorPosition::TPosHint CWordTest::CursorPositioningHint() const
       
   587 	{
       
   588 	return iPositioningHint;
       
   589 	}