os/textandloc/textrendering/texthandling/spml/T_RTPAR.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/textrendering/texthandling/spml/T_RTPAR.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,932 @@
     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 "T_RTPAR.H"
    1.23 +
    1.24 +////////////////////////////////////////////
    1.25 +// CRichTextReader
    1.26 +////////////////////////////////////////////
    1.27 +
    1.28 +CRichTextReader* CRichTextReader::NewL()
    1.29 +	{
    1.30 +	CRichTextReader* self=new(ELeave) CRichTextReader;
    1.31 +	CleanupStack::PushL(self);
    1.32 +	self->ConstructL();
    1.33 +	CleanupStack::Pop();
    1.34 +	return self;
    1.35 +	}
    1.36 +
    1.37 +
    1.38 +CRichTextReader::CRichTextReader()
    1.39 +	{
    1.40 +	// init variables
    1.41 +	iParaStart = 0;
    1.42 +	iConsoleExists = EFalse;
    1.43 +	}
    1.44 +	 
    1.45 +
    1.46 +void CRichTextReader::ConstructL()
    1.47 +	{ 
    1.48 +	// construct PML writer
    1.49 +	iPMLWriter = CPMLWriter::NewL();
    1.50 +	
    1.51 +	// construct RichText bits
    1.52 +	iThisParaFormat = CParaFormat::NewL();
    1.53 +	iPrevParaFormat = CParaFormat::NewL();
    1.54 +	}
    1.55 +
    1.56 +
    1.57 +void CRichTextReader::Destruct()
    1.58 +	{
    1.59 +	// iConsole.Destroy();
    1.60 +	Adt::Destroy(iPMLWriter);
    1.61 +	Adt::Destroy(iThisParaFormat);
    1.62 +	Adt::Destroy(iPrevParaFormat);
    1.63 +	if (iBorder)
    1.64 +		delete(iBorder);	// only delete if it hasn't been used (if it has RT destroys it automatically)
    1.65 +	}
    1.66 +
    1.67 +
    1.68 +CBufSeg* CRichTextReader::ConvertRichText(CRichText* aRichTextDoc)
    1.69 +// Quiet version of the RichText->PML parser
    1.70 +// Takes RT doc passed in, reads its global format,
    1.71 +// then reads the character and paragraph formats phrase by phrase
    1.72 +	{
    1.73 +	iRichTextDoc = aRichTextDoc;
    1.74 +	iDocLength = iRichTextDoc->DocumentLength();
    1.75 +	SenseGlobalFormat();
    1.76 +
    1.77 +	TInt nextPhrase;
    1.78 +	TInt readPos = 0;
    1.79 +	 while (readPos < iDocLength)
    1.80 +	 	{
    1.81 +		nextPhrase = TranslatePhrase(readPos);
    1.82 +		readPos += nextPhrase;
    1.83 +		}
    1.84 +	iPMLWriter->Delete(1);		// remove end-of-document paragraph delimiter
    1.85 +	return iPMLWriter->ReturnPmlDoc();
    1.86 +	}
    1.87 +
    1.88 +
    1.89 +CBufSeg* CRichTextReader::ConvertRichText(CRichText* aRichTextDoc, RConsole aConsole)
    1.90 +// Version of the RichText->PML parser with console output (primarily for debugging)
    1.91 +// Takes RT doc passed in, reads its global format,
    1.92 +// then reads the character and paragraph formats phrase by phrase
    1.93 +	{
    1.94 +	iConsoleExists = ETrue;
    1.95 +	iRichTextDoc = aRichTextDoc;
    1.96 +	iConsole = aConsole;
    1.97 +	iDocLength = iRichTextDoc->DocumentLength();
    1.98 +	SenseGlobalFormat();
    1.99 +
   1.100 +	TInt nextPhrase;
   1.101 +	TInt readPos = 0;
   1.102 +	while (readPos <= iDocLength)
   1.103 +	 	{
   1.104 +		nextPhrase = TranslatePhrase(readPos);
   1.105 +		readPos += nextPhrase;
   1.106 +		}
   1.107 +	iPMLWriter->Delete(1);
   1.108 +	iPMLWriter->Output(iConsole);	// output PML doc to screen
   1.109 +	return iPMLWriter->ReturnPmlDoc();
   1.110 +	}
   1.111 +
   1.112 +
   1.113 +void CRichTextReader::SenseGlobalFormat()
   1.114 +// Senses global format & writes it to PML
   1.115 +	{  
   1.116 +	// construct rich text bits
   1.117 +	const CParaFormatLayer* globalParaFormatLayer;	   	// initialised with factory settings
   1.118 +	const CCharFormatLayer* globalCharFormatLayer;
   1.119 +	CParaFormat* globalParaFormat = CParaFormat::NewL();
   1.120 +	TCharFormat globalCharFormat;
   1.121 +
   1.122 +	// Sense global format
   1.123 +	globalParaFormatLayer = iRichTextDoc->SenseGlobalParaFormatLayer();
   1.124 +	globalParaFormatLayer->SenseEffectiveL(globalParaFormat);
   1.125 +	globalCharFormatLayer = iRichTextDoc->SenseGlobalCharFormatLayer();
   1.126 +	globalCharFormatLayer->SenseEffective(globalCharFormat);
   1.127 +
   1.128 +	// now set it
   1.129 +	iPMLWriter->SetTag(EGlobal, ETagStart);		// output <G
   1.130 + 	CompareParaToFactory(globalParaFormat);	// step through format, adding all != factory settings
   1.131 +	CompareCharToFactory(globalCharFormat);	// ...
   1.132 +	iPMLWriter->SetTag(EGlobal, ETagEnd);		// output >\n
   1.133 +
   1.134 +	// initialise iPrevXxxxFormat
   1.135 +	globalParaFormatLayer->SenseEffectiveL(iPrevParaFormat);
   1.136 +	globalCharFormatLayer->SenseEffective(iPrevCharFormat);
   1.137 +
   1.138 +	// destroy rich text bits
   1.139 +	Adt::Destroy(globalParaFormat);
   1.140 +	} 
   1.141 +
   1.142 +
   1.143 +TInt CRichTextReader::TranslatePhrase(TInt aReadPos)
   1.144 +// Output any new formatting being applied to this phrase
   1.145 +// First check whether this phrase is the start of a new paragraph
   1.146 +// If so check the paragraph format
   1.147 +// Next check the character formatting of the phrase
   1.148 +	{
   1.149 +	CPicture* pic; // dummy pointer for senseChars
   1.150 +	TPtrC currentPhrase;
   1.151 +	TUint pmlWritePos;
   1.152 +
   1.153 +	TInt currentParaStart = aReadPos;		
   1.154 +
   1.155 +	// paragraph formatting
   1.156 +	if (currentParaStart != 0)			  // doesn't work for position=0 -- Duncan!!
   1.157 +		iRichTextDoc->ParagraphStart(currentParaStart);
   1.158 +	if ((currentParaStart > iParaStart)||(aReadPos == 0)) // is it a new paragraph?
   1.159 +		{
   1.160 +		iParaStart = currentParaStart;
   1.161 +		// delete para delimiter
   1.162 +		if (aReadPos > 0)
   1.163 +			iPMLWriter->Delete(1); // deletes 1 chars previous to the current insert pos
   1.164 +		// add para tag
   1.165 +		iPMLWriter->SetTag(EParagraph, ETagStart);
   1.166 +		iRichTextDoc->SenseParagraphFormatL(aReadPos,iThisParaFormat); // get para format
   1.167 +		CompareParaFormats(); // compare to previous paragraph to get changes
   1.168 +		iRichTextDoc->SenseParagraphFormatL(aReadPos,iPrevParaFormat); // set prevParaFormat to current & copy compound attributes
   1.169 +		iPrevParaFormat->iTopBorder=CopyBorderL(iThisParaFormat->iTopBorder,iPrevParaFormat->iTopBorder);
   1.170 +		iPrevParaFormat->iBottomBorder=CopyBorderL(iThisParaFormat->iBottomBorder,iPrevParaFormat->iBottomBorder);
   1.171 +		iPrevParaFormat->iLeftBorder=CopyBorderL(iThisParaFormat->iLeftBorder,iPrevParaFormat->iLeftBorder);
   1.172 +		iPrevParaFormat->iRightBorder=CopyBorderL(iThisParaFormat->iRightBorder,iPrevParaFormat->iRightBorder);
   1.173 +		iPrevParaFormat->iBullet=CopyBulletL(iThisParaFormat->iBullet,iPrevParaFormat->iBullet);
   1.174 +		iPMLWriter->SetTag(EParagraph, ETagEnd);
   1.175 +
   1.176 +		}
   1.177 +
   1.178 +	// character formatting
   1.179 +	iPMLWriter->SetTag(ECharacter, ETagStart);
   1.180 +	pmlWritePos = iPMLWriter->WritePos();
   1.181 +	iRichTextDoc->SenseChars(aReadPos,currentPhrase,iThisCharFormat,pic);	// get char format
   1.182 +	CompareCharFormats();	// compare to previous
   1.183 +	iRichTextDoc->SenseChars(aReadPos,currentPhrase,iPrevCharFormat,pic);	// get char format
   1.184 +	if (pmlWritePos == iPMLWriter->WritePos())
   1.185 +		iPMLWriter->Delete(3);		// delete tag start if tag is empty
   1.186 +	else
   1.187 +		iPMLWriter->SetTag(ECharacter, ETagEnd); // else close tag
   1.188 +
   1.189 +	iPMLWriter->Insert(currentPhrase);	// output text of phrase to PML
   1.190 +	return currentPhrase.Length();		// return relative pos of start of next phrase
   1.191 +	}
   1.192 +
   1.193 +
   1.194 +TParaBorder* CRichTextReader::CopyBorderL(const TParaBorder* aFrom,TParaBorder* aTo)
   1.195 +// copies one paragraph border to another, creating or destroying where necessary
   1.196 +	{
   1.197 +	if (!aFrom)
   1.198 +		{
   1.199 +		if (aTo)
   1.200 +			delete(aTo);
   1.201 +		return NULL;  // No border cell in the original
   1.202 +		}
   1.203 +	else
   1.204 +		{
   1.205 +		if (!aTo)
   1.206 +			aTo = new(ELeave) TParaBorder;
   1.207 +		*aTo = *aFrom;
   1.208 +		return aTo;
   1.209 +		}
   1.210 +	}
   1.211 +	
   1.212 +
   1.213 +TBullet* CRichTextReader::CopyBulletL(const TBullet* aFrom,TBullet* aTo)
   1.214 +// copies one bullet to another, creating or destroying where necessary
   1.215 +	{
   1.216 +	if (!aFrom)
   1.217 +		{
   1.218 +		if (aTo)
   1.219 +			delete(aTo);
   1.220 +		return NULL;  // No bullet cell in the original
   1.221 +		}
   1.222 +	else
   1.223 +		{
   1.224 +		if (!aTo)
   1.225 +			aTo = new(ELeave) TBullet;
   1.226 +		*aTo = *aFrom;
   1.227 +		return aTo;
   1.228 +		}
   1.229 +	}
   1.230 +	
   1.231 +
   1.232 +void CRichTextReader::CompareParaToFactory(CParaFormat* aSensedParaFormat)
   1.233 +// Compares the supplied paragraph format to the factory defaults and acts on any differences
   1.234 +	{
   1.235 +	// create a new reference format with factory settings
   1.236 +	CParaFormat* refParaFormat = CParaFormat::NewL();
   1.237 +	// step through, comparing aSensedParaFormat to the reference
   1.238 +	// if any attributes differ, set the differences in the PML doc
   1.239 +	if (aSensedParaFormat->iLanguage != refParaFormat->iLanguage)
   1.240 +		iPMLWriter->SetFormat(EAttParaLanguage, aSensedParaFormat->iLanguage);
   1.241 +	if (aSensedParaFormat->iLeftMargin != refParaFormat->iLeftMargin)
   1.242 +		iPMLWriter->SetFormat(EAttLeftMargin, aSensedParaFormat->iLeftMargin);
   1.243 +	if (aSensedParaFormat->iRightMargin != refParaFormat->iRightMargin)
   1.244 +		iPMLWriter->SetFormat(EAttRightMargin, aSensedParaFormat->iRightMargin);
   1.245 +	if (aSensedParaFormat->iIndent != refParaFormat->iIndent)
   1.246 +		iPMLWriter->SetFormat(EAttIndent, aSensedParaFormat->iIndent);
   1.247 +	if (aSensedParaFormat->iAlignment != refParaFormat->iAlignment)
   1.248 +		iPMLWriter->SetFormat(EAttAlignment, aSensedParaFormat->iAlignment);
   1.249 +	if (aSensedParaFormat->iLineSpacing != refParaFormat->iLineSpacing)
   1.250 +		iPMLWriter->SetFormat(EAttLineSpacing, aSensedParaFormat->iLineSpacing);
   1.251 +	if (aSensedParaFormat->iLineSpacingControl != refParaFormat->iLineSpacingControl)
   1.252 +		iPMLWriter->SetFormat(EAttLineSpacingControl, aSensedParaFormat->iLineSpacingControl);
   1.253 +	if (aSensedParaFormat->iSpaceBefore != refParaFormat->iSpaceBefore)
   1.254 +		iPMLWriter->SetFormat(EAttSpaceBefore, aSensedParaFormat->iSpaceBefore);
   1.255 +	if (aSensedParaFormat->iSpaceAfter != refParaFormat->iSpaceAfter)
   1.256 +		iPMLWriter->SetFormat(EAttSpaceAfter, aSensedParaFormat->iSpaceAfter);
   1.257 +	if (aSensedParaFormat->iKeepTogether != refParaFormat->iKeepTogether)
   1.258 +		iPMLWriter->SetFormat(EAttKeepTogether, aSensedParaFormat->iKeepTogether);
   1.259 +	if (aSensedParaFormat->iKeepWithNext != refParaFormat->iKeepWithNext)
   1.260 +		iPMLWriter->SetFormat(EAttKeepWithNext, aSensedParaFormat->iKeepWithNext);
   1.261 +	if (aSensedParaFormat->iStartNewPage != refParaFormat->iStartNewPage)
   1.262 +		iPMLWriter->SetFormat(EAttStartNewPage, aSensedParaFormat->iStartNewPage);
   1.263 +	if (aSensedParaFormat->iWidowOrphan != refParaFormat->iWidowOrphan)
   1.264 +		iPMLWriter->SetFormat(EAttWidowOrphan, aSensedParaFormat->iWidowOrphan);
   1.265 +	if (aSensedParaFormat->iBorderMargin != refParaFormat->iBorderMargin)
   1.266 +		iPMLWriter->SetFormat(EAttBorderMargin, aSensedParaFormat->iBorderMargin);
   1.267 +	if (aSensedParaFormat->iTopBorder)
   1.268 +		{
   1.269 +		if (refParaFormat->iTopBorder == NULL)
   1.270 +			iPMLWriter->SetFormat(EAttTopBorder, aSensedParaFormat->iTopBorder);
   1.271 +		else if ((aSensedParaFormat->iTopBorder->iLineStyle != refParaFormat->iTopBorder->iLineStyle)
   1.272 +		||(aSensedParaFormat->iTopBorder->iAutoColor != refParaFormat->iTopBorder->iAutoColor)
   1.273 +		||(aSensedParaFormat->iTopBorder->iColor != refParaFormat->iTopBorder->iColor))
   1.274 +			{
   1.275 +			iPMLWriter->SetFormat(EAttTopBorder, aSensedParaFormat->iTopBorder);
   1.276 +			}
   1.277 +		}
   1.278 +	if (aSensedParaFormat->iBottomBorder)
   1.279 +		{  
   1.280 +		if (refParaFormat->iTopBorder == NULL)
   1.281 +			iPMLWriter->SetFormat(EAttBottomBorder, aSensedParaFormat->iBottomBorder);
   1.282 +		else if ((aSensedParaFormat->iBottomBorder->iLineStyle != refParaFormat->iBottomBorder->iLineStyle)
   1.283 +		||(aSensedParaFormat->iBottomBorder->iAutoColor != refParaFormat->iBottomBorder->iAutoColor)
   1.284 +		||(aSensedParaFormat->iBottomBorder->iColor != refParaFormat->iBottomBorder->iColor))
   1.285 +			{
   1.286 +			iPMLWriter->SetFormat(EAttBottomBorder, aSensedParaFormat->iBottomBorder);
   1.287 +			}
   1.288 +		}
   1.289 +	if (aSensedParaFormat->iLeftBorder)
   1.290 +		{  
   1.291 +		if (refParaFormat->iTopBorder == NULL)
   1.292 +			iPMLWriter->SetFormat(EAttLeftBorder, aSensedParaFormat->iLeftBorder);
   1.293 +		else if ((aSensedParaFormat->iLeftBorder->iLineStyle != refParaFormat->iLeftBorder->iLineStyle)
   1.294 +		||(aSensedParaFormat->iLeftBorder->iAutoColor != refParaFormat->iLeftBorder->iAutoColor)
   1.295 +		||(aSensedParaFormat->iLeftBorder->iColor != refParaFormat->iLeftBorder->iColor))
   1.296 +			{
   1.297 +			iPMLWriter->SetFormat(EAttLeftBorder, aSensedParaFormat->iLeftBorder);
   1.298 +			}
   1.299 +		}
   1.300 +	if (aSensedParaFormat->iRightBorder)
   1.301 +		{  
   1.302 +		if (refParaFormat->iTopBorder == NULL)
   1.303 +			iPMLWriter->SetFormat(EAttRightBorder, aSensedParaFormat->iRightBorder);
   1.304 +		else if ((aSensedParaFormat->iRightBorder->iLineStyle != refParaFormat->iRightBorder->iLineStyle)
   1.305 +		||(aSensedParaFormat->iRightBorder->iAutoColor != refParaFormat->iRightBorder->iAutoColor)
   1.306 +		||(aSensedParaFormat->iRightBorder->iColor != refParaFormat->iRightBorder->iColor))
   1.307 +			{
   1.308 +			iPMLWriter->SetFormat(EAttRightBorder, aSensedParaFormat->iRightBorder);
   1.309 +			}
   1.310 +		}
   1.311 +	if (aSensedParaFormat->iBullet)
   1.312 +		{  
   1.313 +		if (refParaFormat->iBullet == NULL)
   1.314 +			iPMLWriter->SetFormat(EAttBullet, aSensedParaFormat->iBullet);
   1.315 +		if ((aSensedParaFormat->iBullet->iCharacterCode != refParaFormat->iBullet->iCharacterCode)
   1.316 +		||(aSensedParaFormat->iBullet->iHeight != refParaFormat->iBullet->iHeight)
   1.317 +		||(aSensedParaFormat->iBullet->iTypeface.iName != refParaFormat->iBullet->iTypeface.iName)
   1.318 +		||(aSensedParaFormat->iBullet->iTypeface.iFlags != refParaFormat->iBullet->iTypeface.iFlags))
   1.319 +			{	
   1.320 +			iPMLWriter->SetFormat(EAttBullet, aSensedParaFormat->iBullet);
   1.321 +			}
   1.322 +		}
   1.323 +	if (aSensedParaFormat->iDefaultTabWidth != refParaFormat->iDefaultTabWidth)
   1.324 +		iPMLWriter->SetFormat(EAttDefaultTabWidth, aSensedParaFormat->iDefaultTabWidth);
   1.325 +	CheckTabList(aSensedParaFormat, refParaFormat);	// tabs are sensed separately
   1.326 +
   1.327 +	// Destroy ref format
   1.328 +	Adt::Destroy(refParaFormat);
   1.329 +	}
   1.330 +
   1.331 +void CRichTextReader::CompareCharToFactory(TCharFormat aSensedCharFormat)
   1.332 +// Compares the supplied character format to the factory defaults and acts on any differences
   1.333 +	{
   1.334 +	// create a new reference format with factory settings
   1.335 +	TCharFormat refCharFormat;
   1.336 +	// step through, comparing aSensedCharFormat to the reference
   1.337 +	// if any attributes differ, set the differences in the PML doc
   1.338 +	if (aSensedCharFormat.iLanguage != refCharFormat.iLanguage)
   1.339 +		iPMLWriter->SetFormat(EAttCharLanguage, aSensedCharFormat.iLanguage);
   1.340 +	if (aSensedCharFormat.iColor != refCharFormat.iColor)
   1.341 +		iPMLWriter->SetFormat(EAttColor, aSensedCharFormat.iColor.RgbToUint());
   1.342 +	if (aSensedCharFormat.iFontSpec.iTypeface.iName != refCharFormat.iFontSpec.iTypeface.iName)
   1.343 +		iPMLWriter->SetFormat(EAttFontTypefaceName, aSensedCharFormat.iFontSpec.iTypeface);
   1.344 +	if (aSensedCharFormat.iFontSpec.iTypeface.iFlags != refCharFormat.iFontSpec.iTypeface.iFlags)
   1.345 +		iPMLWriter->SetFormat(EAttFontTypefaceFlags, aSensedCharFormat.iFontSpec.iTypeface);
   1.346 +	if (aSensedCharFormat.iFontSpec.iHeight != refCharFormat.iFontSpec.iHeight)
   1.347 +		iPMLWriter->SetFormat(EAttFontHeight, aSensedCharFormat.iFontSpec.iHeight);
   1.348 +	if (aSensedCharFormat.iFontSpec.iPosture != refCharFormat.iFontSpec.iPosture)
   1.349 +		iPMLWriter->SetFormat(EAttFontPosture, aSensedCharFormat.iFontSpec.iPosture);
   1.350 +	if (aSensedCharFormat.iFontSpec.iStrokeWeight != refCharFormat.iFontSpec.iStrokeWeight)
   1.351 +		iPMLWriter->SetFormat(EAttFontStrokeWeight, aSensedCharFormat.iFontSpec.iStrokeWeight);
   1.352 +	if (aSensedCharFormat.iFontSpec.iPos != refCharFormat.iFontSpec.iPos)
   1.353 +		iPMLWriter->SetFormat(EAttFontPrintPos, aSensedCharFormat.iFontSpec.iPos);
   1.354 +	if (aSensedCharFormat.iFontSpec.iUnderline != refCharFormat.iFontSpec.iUnderline)
   1.355 +		iPMLWriter->SetFormat((TTextFormatAttribute)EAttFontUnderline, aSensedCharFormat.iFontSpec.iUnderline);
   1.356 +	if (aSensedCharFormat.iFontSpec.iStrikethrough != refCharFormat.iFontSpec.iStrikethrough)
   1.357 +		iPMLWriter->SetFormat(EAttFontStrikethrough, aSensedCharFormat.iFontSpec.iStrikethrough);
   1.358 +	}
   1.359 +
   1.360 +
   1.361 +void CRichTextReader::CompareParaFormats()
   1.362 +// compares the current para format with the format of the previous para
   1.363 +// any differences are output to PML
   1.364 +	{
   1.365 +	if (iThisParaFormat->iLanguage != iPrevParaFormat->iLanguage)
   1.366 +		iPMLWriter->SetFormat(EAttParaLanguage, iThisParaFormat->iLanguage);
   1.367 +	if (iThisParaFormat->iLeftMargin != iPrevParaFormat->iLeftMargin)
   1.368 +		iPMLWriter->SetFormat(EAttLeftMargin, iThisParaFormat->iLeftMargin);
   1.369 +	if (iThisParaFormat->iRightMargin != iPrevParaFormat->iRightMargin)
   1.370 +		iPMLWriter->SetFormat(EAttRightMargin, iThisParaFormat->iRightMargin);
   1.371 +	if (iThisParaFormat->iIndent != iPrevParaFormat->iIndent)
   1.372 +		iPMLWriter->SetFormat(EAttIndent, iThisParaFormat->iIndent);
   1.373 +	if (iThisParaFormat->iAlignment != iPrevParaFormat->iAlignment)
   1.374 +		iPMLWriter->SetFormat(EAttAlignment, iThisParaFormat->iAlignment);
   1.375 +	if (iThisParaFormat->iLineSpacing != iPrevParaFormat->iLineSpacing)
   1.376 +		iPMLWriter->SetFormat(EAttLineSpacing, iThisParaFormat->iLineSpacing);
   1.377 +	if (iThisParaFormat->iLineSpacingControl != iPrevParaFormat->iLineSpacingControl)
   1.378 +		iPMLWriter->SetFormat(EAttLineSpacingControl, iThisParaFormat->iLineSpacingControl);
   1.379 +	if (iThisParaFormat->iSpaceBefore != iPrevParaFormat->iSpaceBefore)
   1.380 +		iPMLWriter->SetFormat(EAttSpaceBefore, iThisParaFormat->iSpaceBefore);
   1.381 +	if (iThisParaFormat->iSpaceAfter != iPrevParaFormat->iSpaceAfter)
   1.382 +		iPMLWriter->SetFormat(EAttSpaceAfter, iThisParaFormat->iSpaceAfter);
   1.383 +	if (iThisParaFormat->iKeepTogether != iPrevParaFormat->iKeepTogether)
   1.384 +		iPMLWriter->SetFormat(EAttKeepTogether, iThisParaFormat->iKeepTogether);
   1.385 +	if (iThisParaFormat->iKeepWithNext != iPrevParaFormat->iKeepWithNext)
   1.386 +		iPMLWriter->SetFormat(EAttKeepWithNext, iThisParaFormat->iKeepWithNext);
   1.387 +	if (iThisParaFormat->iStartNewPage != iPrevParaFormat->iStartNewPage)
   1.388 +		iPMLWriter->SetFormat(EAttStartNewPage, iThisParaFormat->iStartNewPage);
   1.389 +	if (iThisParaFormat->iWidowOrphan != iPrevParaFormat->iWidowOrphan)
   1.390 +		iPMLWriter->SetFormat(EAttWidowOrphan, iThisParaFormat->iWidowOrphan);
   1.391 +	if (iThisParaFormat->iBorderMargin != iPrevParaFormat->iBorderMargin)
   1.392 +		iPMLWriter->SetFormat(EAttBorderMargin, iThisParaFormat->iBorderMargin);
   1.393 +	if (iThisParaFormat->iTopBorder)
   1.394 +		{
   1.395 +		if (iPrevParaFormat->iTopBorder == NULL)  
   1.396 +			iPMLWriter->SetFormat(EAttTopBorder, iThisParaFormat->iTopBorder);
   1.397 +		else if ((iThisParaFormat->iTopBorder->iLineStyle != iPrevParaFormat->iTopBorder->iLineStyle)
   1.398 +		||(iThisParaFormat->iTopBorder->iAutoColor != iPrevParaFormat->iTopBorder->iAutoColor)
   1.399 +		||(iThisParaFormat->iTopBorder->iColor != iPrevParaFormat->iTopBorder->iColor))
   1.400 +			{
   1.401 +			iPMLWriter->SetFormat(EAttTopBorder, iThisParaFormat->iTopBorder);
   1.402 +			}
   1.403 +		}
   1.404 +	if (iThisParaFormat->iBottomBorder)
   1.405 +		{  
   1.406 +		if (iPrevParaFormat->iBottomBorder == NULL)  
   1.407 +			iPMLWriter->SetFormat(EAttBottomBorder, iThisParaFormat->iBottomBorder);
   1.408 +		else if ((iThisParaFormat->iBottomBorder->iLineStyle != iPrevParaFormat->iBottomBorder->iLineStyle)
   1.409 +		||(iThisParaFormat->iBottomBorder->iAutoColor != iPrevParaFormat->iBottomBorder->iAutoColor)
   1.410 +		||(iThisParaFormat->iBottomBorder->iColor != iPrevParaFormat->iBottomBorder->iColor))
   1.411 +			{
   1.412 +			iPMLWriter->SetFormat(EAttBottomBorder, iThisParaFormat->iBottomBorder);
   1.413 +			}
   1.414 +		}
   1.415 +	if (iThisParaFormat->iLeftBorder)
   1.416 +		{  
   1.417 +		if (iPrevParaFormat->iLeftBorder == NULL)  
   1.418 +			iPMLWriter->SetFormat(EAttLeftBorder, iThisParaFormat->iLeftBorder);
   1.419 +		if ((iThisParaFormat->iLeftBorder->iLineStyle != iPrevParaFormat->iLeftBorder->iLineStyle)
   1.420 +		||(iThisParaFormat->iLeftBorder->iAutoColor != iPrevParaFormat->iLeftBorder->iAutoColor)
   1.421 +		||(iThisParaFormat->iLeftBorder->iColor != iPrevParaFormat->iLeftBorder->iColor))
   1.422 +			{
   1.423 +			iPMLWriter->SetFormat(EAttLeftBorder, iThisParaFormat->iLeftBorder);
   1.424 +			}
   1.425 +		}
   1.426 +	if (iThisParaFormat->iRightBorder)
   1.427 +		{  
   1.428 +		if (iPrevParaFormat->iRightBorder == NULL)  
   1.429 +			iPMLWriter->SetFormat(EAttRightBorder, iThisParaFormat->iRightBorder);
   1.430 +		if ((iThisParaFormat->iRightBorder->iLineStyle != iPrevParaFormat->iRightBorder->iLineStyle)
   1.431 +		||(iThisParaFormat->iRightBorder->iAutoColor != iPrevParaFormat->iRightBorder->iAutoColor)
   1.432 +		||(iThisParaFormat->iRightBorder->iColor != iPrevParaFormat->iRightBorder->iColor))
   1.433 +			{
   1.434 +			iPMLWriter->SetFormat(EAttRightBorder, iThisParaFormat->iRightBorder);
   1.435 +			}
   1.436 +		}
   1.437 + 	if (iThisParaFormat->iBullet)
   1.438 +		{  
   1.439 +		if (iPrevParaFormat->iBullet == NULL)  
   1.440 +			iPMLWriter->SetFormat(EAttBullet, iThisParaFormat->iBullet);
   1.441 +		else if ((iThisParaFormat->iBullet->iCharacterCode != iPrevParaFormat->iBullet->iCharacterCode)
   1.442 +		||(iThisParaFormat->iBullet->iHeight != iPrevParaFormat->iBullet->iHeight)
   1.443 +		||(iThisParaFormat->iBullet->iTypeface.iName != iPrevParaFormat->iBullet->iTypeface.iName)
   1.444 +		||(iThisParaFormat->iBullet->iTypeface.iFlags != iPrevParaFormat->iBullet->iTypeface.iFlags))
   1.445 +			{	
   1.446 +			iPMLWriter->SetFormat(EAttBullet, iThisParaFormat->iBullet);
   1.447 +			}
   1.448 +		}
   1.449 +	if (iThisParaFormat->iDefaultTabWidth != iPrevParaFormat->iDefaultTabWidth)
   1.450 +		iPMLWriter->SetFormat(EAttDefaultTabWidth, iThisParaFormat->iDefaultTabWidth);
   1.451 +	CheckTabList(iThisParaFormat, iPrevParaFormat);	// tabs are sensed separately
   1.452 +	}
   1.453 +
   1.454 +
   1.455 +void CRichTextReader::CheckTabList(CParaFormat* aFormatOne, CParaFormat* aFormatTwo)
   1.456 +// Check whether the first (current) and second formats' tablists differ
   1.457 +// If they do, output whole of first list to PML
   1.458 +	{
   1.459 +	TBool output = EFalse;
   1.460 +	if (aFormatOne->TabCount() != aFormatTwo->TabCount())
   1.461 +		output = ETrue;	// output to PML
   1.462 +	else 
   1.463 +		{
   1.464 +		// lists are same length: check that all members are the same
   1.465 +		TInt index = 0;
   1.466 +		TBool dif = EFalse;
   1.467 +		while ((index < aFormatOne->TabCount())&&(!dif))
   1.468 +			{
   1.469 +			if (aFormatOne->TabStop(index) != aFormatTwo->TabStop(index))
   1.470 +				output = ETrue;	// output to PML
   1.471 +			index++;
   1.472 +			}
   1.473 +		}
   1.474 +	if (output)
   1.475 +		{
   1.476 +		for (TInt i=0; i < aFormatOne->TabCount(); i++)
   1.477 +			iPMLWriter->SetFormat(EAttTabStop, aFormatOne->TabStop(i));
   1.478 +		}
   1.479 +	}
   1.480 +
   1.481 +
   1.482 +void CRichTextReader::CompareCharFormats()
   1.483 +	{
   1.484 +	if (iThisCharFormat.iLanguage != iPrevCharFormat.iLanguage)
   1.485 +		iPMLWriter->SetFormat(EAttCharLanguage, iThisCharFormat.iLanguage);
   1.486 +	if (iThisCharFormat.iColor != iPrevCharFormat.iColor)
   1.487 +		iPMLWriter->SetFormat(EAttColor, iThisCharFormat.iColor.RgbToUint());
   1.488 +	if (iThisCharFormat.iFontSpec.iTypeface.iName != iPrevCharFormat.iFontSpec.iTypeface.iName)
   1.489 +		iPMLWriter->SetFormat(EAttFontTypefaceName, iThisCharFormat.iFontSpec.iTypeface);
   1.490 +	if (iThisCharFormat.iFontSpec.iTypeface.iFlags != iPrevCharFormat.iFontSpec.iTypeface.iFlags)
   1.491 +		iPMLWriter->SetFormat(EAttFontTypefaceFlags, iThisCharFormat.iFontSpec.iTypeface);
   1.492 +	if (iThisCharFormat.iFontSpec.iHeight != iPrevCharFormat.iFontSpec.iHeight)
   1.493 +		iPMLWriter->SetFormat(EAttFontHeight, iThisCharFormat.iFontSpec.iHeight);
   1.494 +	if (iThisCharFormat.iFontSpec.iPosture != iPrevCharFormat.iFontSpec.iPosture)
   1.495 +		iPMLWriter->SetFormat(EAttFontPosture, iThisCharFormat.iFontSpec.iPosture);
   1.496 +	if (iThisCharFormat.iFontSpec.iStrokeWeight != iPrevCharFormat.iFontSpec.iStrokeWeight)
   1.497 +		iPMLWriter->SetFormat(EAttFontStrokeWeight, iThisCharFormat.iFontSpec.iStrokeWeight);
   1.498 +	if (iThisCharFormat.iFontSpec.iPos != iPrevCharFormat.iFontSpec.iPos)
   1.499 +		iPMLWriter->SetFormat(EAttFontPrintPos, iThisCharFormat.iFontSpec.iPos);
   1.500 +	if (iThisCharFormat.iFontSpec.iUnderline != iPrevCharFormat.iFontSpec.iUnderline)
   1.501 +		iPMLWriter->SetFormat(EAttFontUnderline, iThisCharFormat.iFontSpec.iUnderline);
   1.502 +	if (iThisCharFormat.iFontSpec.iStrikethrough != iPrevCharFormat.iFontSpec.iStrikethrough)
   1.503 +		iPMLWriter->SetFormat(EAttFontStrikethrough, iThisCharFormat.iFontSpec.iStrikethrough);
   1.504 +	}
   1.505 +
   1.506 +
   1.507 +
   1.508 +
   1.509 +//////////////////////////////////////////////////////
   1.510 +// CPMLWriter
   1.511 +//////////////////////////////////////////////////////
   1.512 +
   1.513 +CPMLWriter* CPMLWriter::NewL()
   1.514 +	{
   1.515 +	CPMLWriter* self=new(ELeave) CPMLWriter;
   1.516 +	self->Construct();
   1.517 +	return self;
   1.518 +	}
   1.519 +
   1.520 +
   1.521 +CPMLWriter::CPMLWriter()
   1.522 +	{
   1.523 +	// init variables
   1.524 +	}
   1.525 +	 
   1.526 +
   1.527 +void CPMLWriter::Construct()
   1.528 +	{
   1.529 +	iTextBuf = CBufSeg::New(64);  // create buffer with granularity 64
   1.530 +	}
   1.531 +
   1.532 +
   1.533 +void CPMLWriter::Destruct()
   1.534 +	{
   1.535 +	Adt::Destroy(iTextBuf);
   1.536 +	}
   1.537 +
   1.538 +
   1.539 +void CPMLWriter::ExpandBuf(const TDes8& aBuffer, TDes& aTarget)
   1.540 +	//
   1.541 +	// Input 8 bit buffer to be returned by ref. as an 8/16-bit version
   1.542 +	// Used for unicode compatability
   1.543 +	//
   1.544 +	{
   1.545 +	TText textPointer;
   1.546 +	for (TInt pos=0 ; pos<aBuffer.Length() ; pos++ )
   1.547 +		{
   1.548 +		textPointer = aBuffer[pos];
   1.549 +		aTarget.Append(textPointer);
   1.550 +		}
   1.551 +	}
   1.552 +
   1.553 +
   1.554 +void CPMLWriter::SquashBuf(const TDesC& aBuffer, TDes8& aTarget)
   1.555 +	//
   1.556 +	// Input 8/16 bit buffer and an 8-bit target to be copied into.
   1.557 +	// Used for unicode compatability
   1.558 +	//
   1.559 +	{
   1.560 +	TText textPointer;
   1.561 +	for (TInt pos=0; pos<aBuffer.Length(); pos++)
   1.562 +		{
   1.563 +		textPointer = aBuffer[pos];
   1.564 +		aTarget.Append(textPointer);
   1.565 +		}
   1.566 +	}
   1.567 +
   1.568 +
   1.569 +void CPMLWriter::Insert(const TDesC& aBuf)
   1.570 +// insert aBuf into PML doc
   1.571 +	{
   1.572 +	TUint bufLength = aBuf.Length();
   1.573 +	TBuf8<128> temp;
   1.574 +	SquashBuf(aBuf,temp);
   1.575 +	iTextBuf->InsertL(iInsertPos, temp, bufLength);
   1.576 +	iInsertPos += bufLength; 
   1.577 +	}
   1.578 +
   1.579 +
   1.580 +void CPMLWriter::Delete(TUint aLength)
   1.581 +// delete back from current insert pos aLength (characters)
   1.582 +	{ 
   1.583 +	iTextBuf->Delete(iInsertPos-aLength, aLength);
   1.584 +	iInsertPos -= aLength;
   1.585 +	}
   1.586 +
   1.587 +
   1.588 +void CPMLWriter::Output(RConsole aConsole)
   1.589 +// output buffer to screen
   1.590 +	{ 
   1.591 +	TBuf8<1> tempBuf;
   1.592 +	TInt readPos = 0;
   1.593 +	while (readPos < iTextBuf->Size())
   1.594 +		{
   1.595 +		iTextBuf->Read(readPos, tempBuf, 1);
   1.596 +		TBuf<1> wideTemp;
   1.597 +		ExpandBuf(tempBuf,wideTemp);
   1.598 +		aConsole.Write(wideTemp);
   1.599 +		readPos++;
   1.600 +		}
   1.601 +	}
   1.602 +
   1.603 +
   1.604 +void CPMLWriter::SetTag(TTagType aTagType, TTagStatus aStatus)
   1.605 +// insert a tag-open or tag-close into the PML doc
   1.606 +	{
   1.607 +	if (aStatus == ETagStart)
   1.608 +		{
   1.609 +		switch (aTagType)
   1.610 +			{
   1.611 +			case EGlobal:
   1.612 +				Insert(_L("\n<G "));
   1.613 +				break;
   1.614 +			case EParagraph:
   1.615 +				Insert(_L("\n<P "));
   1.616 +				break;
   1.617 +			case ECharacter:
   1.618 +				Insert(_L("<C "));
   1.619 +				break;
   1.620 +			case EControl:
   1.621 +				Insert(_L("<X "));
   1.622 +				break;
   1.623 +			}
   1.624 +		}
   1.625 +	if (aStatus == ETagEnd)
   1.626 +		{
   1.627 +		switch (aTagType)
   1.628 +			{
   1.629 +			case EGlobal:
   1.630 +				Insert(_L(">\n"));
   1.631 +				break;
   1.632 +			case EParagraph:
   1.633 +				Insert(_L(">\n"));
   1.634 +				break;
   1.635 +			case ECharacter:
   1.636 +				Insert(_L(">"));
   1.637 +				break;
   1.638 +			case EControl:
   1.639 +				Insert(_L(">"));
   1.640 +				break;
   1.641 +			}
   1.642 +		}
   1.643 +	}
   1.644 +
   1.645 +
   1.646 +void CPMLWriter::SetTab(TTabStop aTabStop)
   1.647 +// insert a tab into the PML doc
   1.648 +	{
   1.649 +	TBuf<80> tagBuf;
   1.650 +	tagBuf.Format(_L("Tab=,%d"),aTabStop.iPosition);	// put 2nd paramater in first
   1.651 +	switch (aTabStop.iType)								// insert 1st paramater after "="
   1.652 +		{
   1.653 +		case ENullTab:
   1.654 +			tagBuf.Insert(4,_L("Null"));				
   1.655 +			break;
   1.656 +		case ELeftTab:
   1.657 +			tagBuf.Insert(4,_L("Left"));
   1.658 +			break;
   1.659 +		case ECenteredTab:
   1.660 +			tagBuf.Insert(4,_L("Centered"));
   1.661 +			break;
   1.662 +		case ERightTab:
   1.663 +			tagBuf.Insert(4,_L("Right"));
   1.664 +			break;
   1.665 +		}
   1.666 +	Insert(tagBuf);
   1.667 +	}
   1.668 +
   1.669 +/* The setFormat functions add the stipulated formatting to the PML doc */
   1.670 +
   1.671 +void CPMLWriter::SetFormat(TTextFormatAttribute aAttribute, TInt aValue)
   1.672 +	{
   1.673 +	TBuf<80> outputBuf;
   1.674 +	switch (aAttribute)
   1.675 +		{
   1.676 +		// Para Formats
   1.677 +		case EAttParaLanguage:
   1.678 +			outputBuf.Format(_L("ParaLanguage=%d "),aValue);
   1.679 +			Insert(outputBuf);
   1.680 +			break;
   1.681 +		case EAttLeftMargin:
   1.682 +			outputBuf.Format(_L("LeftMargin=%d "),aValue);
   1.683 +			Insert(outputBuf);
   1.684 +			break;
   1.685 +		case EAttRightMargin:
   1.686 +			outputBuf.Format(_L("RightMargin=%d "),aValue);
   1.687 +			Insert(outputBuf);
   1.688 +			break;
   1.689 +		case EAttIndent:
   1.690 +			outputBuf.Format(_L("Indent=%d "),aValue);
   1.691 +			Insert(outputBuf);
   1.692 +			break;
   1.693 +		case EAttAlignment:
   1.694 +			ProcessAlignment(aValue);
   1.695 +			break;
   1.696 +		case EAttLineSpacing:
   1.697 +			outputBuf.Format(_L("LineSpacing=%d "),aValue);
   1.698 +			Insert(outputBuf);
   1.699 +			break;
   1.700 +		case EAttLineSpacingControl:
   1.701 +			ProcessLineSpacingControl(aValue);
   1.702 +			break;
   1.703 +		case EAttSpaceBefore:
   1.704 +			outputBuf.Format(_L("SpaceBefore=%d "),aValue);
   1.705 +			Insert(outputBuf);
   1.706 +			break;
   1.707 +		case EAttSpaceAfter:
   1.708 +			outputBuf.Format(_L("SpaceAfter=%d "),aValue);
   1.709 +			Insert(outputBuf);
   1.710 +			break;
   1.711 +		case EAttKeepTogether:
   1.712 +			ProcessBooleanAtt(aAttribute, aValue);
   1.713 +			break;
   1.714 +		case EAttKeepWithNext:
   1.715 +			ProcessBooleanAtt(aAttribute, aValue);
   1.716 +			break;
   1.717 +		case EAttStartNewPage:
   1.718 +			ProcessBooleanAtt(aAttribute, aValue);
   1.719 +			break;
   1.720 +		case EAttWidowOrphan:
   1.721 +			ProcessBooleanAtt(aAttribute, aValue);
   1.722 +			break;
   1.723 +		case EAttBorderMargin:
   1.724 +			outputBuf.Format(_L("BorderMargin=%d "),aValue);
   1.725 +			Insert(outputBuf);
   1.726 +			break;
   1.727 +		case EAttDefaultTabWidth:
   1.728 +			outputBuf.Format(_L("DefaultTabWidth=%d "),aValue);
   1.729 +			Insert(outputBuf);
   1.730 +			break;
   1.731 +
   1.732 +	// Char formats
   1.733 +		case EAttCharLanguage:
   1.734 +			outputBuf.Format(_L("Language=%d "),aValue);
   1.735 +			Insert(outputBuf);
   1.736 +			break;
   1.737 +		case EAttColor:
   1.738 +			outputBuf.Format(_L("Color=%d "),aValue);
   1.739 +			Insert(outputBuf);
   1.740 +			break;
   1.741 +		case EAttFontHeight:
   1.742 +			outputBuf.Format(_L("FontHeight=%d "),aValue);
   1.743 +			Insert(outputBuf);
   1.744 +			break;
   1.745 +		case EAttFontPosture:
   1.746 +			ProcessBooleanAtt(aAttribute, aValue);
   1.747 +			break;
   1.748 +		case EAttFontStrokeWeight:
   1.749 +			ProcessBooleanAtt(aAttribute, aValue);
   1.750 +			break;
   1.751 +		case EAttFontPrintPos:
   1.752 +			ProcessFontPrintPos(aValue);
   1.753 +			break;
   1.754 +		case EAttFontUnderline:
   1.755 +			ProcessBooleanAtt(aAttribute, aValue);
   1.756 +			break;
   1.757 +		case EAttFontStrikethrough:
   1.758 +			ProcessBooleanAtt(aAttribute, aValue);
   1.759 +			break;
   1.760 +		case EAttFontTypefaceFlags:
   1.761 +			outputBuf.Format(_L("TypefaceFlags=%d "),aValue);
   1.762 +			Insert(outputBuf);
   1.763 +			break;
   1.764 +		}
   1.765 +	}
   1.766 +
   1.767 +
   1.768 +void CPMLWriter::SetFormat(TTextFormatAttribute aAttribute, const TTypeface &aTypeface)
   1.769 +	{
   1.770 +	TBuf<80> outputBuf;
   1.771 +	switch (aAttribute)
   1.772 +		{
   1.773 +		case EAttFontTypefaceName:
   1.774 +			outputBuf.Format(_L("TypefaceName=%S "),&aTypeface.iName);
   1.775 +			break;
   1.776 +		case EAttFontTypefaceFlags:
   1.777 +			outputBuf.Format(_L("TypefaceFlags=%u "),aTypeface.iFlags);
   1.778 +			break;
   1.779 +		}
   1.780 +	Insert(outputBuf);
   1.781 +	}
   1.782 +
   1.783 +void CPMLWriter::SetFormat(TTextFormatAttribute aAttribute, TParaBorder* aParaBorder)
   1.784 +	{
   1.785 +	TBuf<80> outputBuf;
   1.786 +	TBuf<80> values;
   1.787 +	values.Format(_L("%d,%d,%d"),aParaBorder->iLineStyle,aParaBorder->iAutoColor,aParaBorder->iColor.RgbToUint());
   1.788 +	outputBuf.Insert(0,values);
   1.789 +	switch (aAttribute)
   1.790 +		{
   1.791 +		case EAttTopBorder:
   1.792 +			outputBuf.Insert(0,_L("TopBorder="));
   1.793 +			break;
   1.794 +		case EAttBottomBorder:
   1.795 +			outputBuf.Insert(0,_L("BottomBorder="));
   1.796 +			break;
   1.797 +		case EAttLeftBorder:
   1.798 +			outputBuf.Insert(0,_L("LeftBorder="));
   1.799 +			break;
   1.800 +		case EAttRightBorder:
   1.801 +			outputBuf.Insert(0,_L("RightBorder="));
   1.802 +			break;
   1.803 +		}
   1.804 +	Insert(outputBuf);
   1.805 +	}
   1.806 +
   1.807 +
   1.808 +void CPMLWriter::SetFormat(TTextFormatAttribute /*aAttribute*/, TBullet* aBullet)
   1.809 +	{
   1.810 +	TBuf<80> outputBuf;
   1.811 +	outputBuf.Format(_L("%d,%u,%u,"),aBullet->iCharacterCode,aBullet->iHeight,
   1.812 +															aBullet->iTypeface.iFlags);
   1.813 +	TBuf<128> wideTemp; // long enough??
   1.814 +	ExpandBuf(aBullet->iTypeface.iName,wideTemp);
   1.815 +	outputBuf.Append(wideTemp);
   1.816 +	outputBuf.Append(_L(" "));
   1.817 +	outputBuf.Insert(0,_L("Bullet="));
   1.818 +	Insert(outputBuf);
   1.819 +	}
   1.820 +
   1.821 +
   1.822 +void CPMLWriter::SetFormat(TTextFormatAttribute /*aAttribute*/, TTabStop aTabStop)
   1.823 +	{
   1.824 +	TBuf<80> outputBuf;
   1.825 +	outputBuf.Format(_L("Tabstop=%u,"),aTabStop.iPosition);
   1.826 +	switch (aTabStop.iType)
   1.827 +		{
   1.828 +		case ENullTab:
   1.829 +			outputBuf.Append(_L("Null "));
   1.830 +			break;
   1.831 +		case ELeftTab:
   1.832 +			outputBuf.Append(_L("Left "));
   1.833 +			break;
   1.834 +		case ERightTab:
   1.835 +			outputBuf.Append(_L("Right "));
   1.836 +			break;
   1.837 +		case ECenteredTab:
   1.838 +			outputBuf.Append(_L("Centered "));
   1.839 +			break;
   1.840 +		}
   1.841 +	Insert(outputBuf);
   1.842 +	}
   1.843 +
   1.844 +
   1.845 +void CPMLWriter::ProcessAlignment(TInt aValue)
   1.846 +	{
   1.847 +	TBuf<80> outputBuf;
   1.848 +	switch (aValue)
   1.849 +		{
   1.850 +		case 0:
   1.851 +			outputBuf.Insert(0,_L("Alignment=Left "));
   1.852 +			break;
   1.853 +		case 1:
   1.854 +			outputBuf.Insert(0,_L("Alignment=Center "));
   1.855 +			break;
   1.856 +		case 2:
   1.857 +			outputBuf.Insert(0,_L("Alignment=Right "));
   1.858 +			break;
   1.859 +		case 3:
   1.860 +			outputBuf.Insert(0,_L("Alignment=Justified "));
   1.861 +			break;
   1.862 +		}
   1.863 +	Insert(outputBuf);
   1.864 +	}
   1.865 +
   1.866 +
   1.867 +void CPMLWriter::ProcessLineSpacingControl(TInt aValue)
   1.868 +	{
   1.869 +	TBuf<80> outputBuf;
   1.870 +	switch (aValue)
   1.871 +		{
   1.872 +		case 0:
   1.873 +			outputBuf.Insert(0,_L("LineSpacingControl=Atleast "));
   1.874 +			break;
   1.875 +		case 1:
   1.876 +			outputBuf.Insert(0,_L("LineSpacingControl=Exactly "));
   1.877 +			break;
   1.878 +		}
   1.879 +	Insert(outputBuf);
   1.880 +	}
   1.881 +
   1.882 +
   1.883 +void CPMLWriter::ProcessFontPrintPos(TInt aValue)
   1.884 +	{
   1.885 +	TBuf<80> outputBuf;
   1.886 +	switch (aValue)
   1.887 +		{
   1.888 +		case 0:
   1.889 +			outputBuf.Insert(0,_L("PrintPos=Normal "));
   1.890 +			break;
   1.891 +		case 1:
   1.892 +			outputBuf.Insert(0,_L("PrintPos=SuperScript "));
   1.893 +			break;
   1.894 +		case 2:
   1.895 +			outputBuf.Insert(0,_L("PrintPos=SubScript "));
   1.896 +			break;
   1.897 +		}
   1.898 +	Insert(outputBuf);
   1.899 +	}
   1.900 +
   1.901 +
   1.902 + void CPMLWriter::ProcessBooleanAtt(TTextFormatAttribute aAttribute, TInt aValue)
   1.903 +	{
   1.904 +	TBuf<80> outputBuf;
   1.905 +	switch (aAttribute)
   1.906 +		{
   1.907 +		case EAttKeepTogether:
   1.908 +			outputBuf.Insert(0,_L("KeepTogether "));
   1.909 +			break;
   1.910 +		case EAttKeepWithNext:
   1.911 +			outputBuf.Insert(0,_L("KeepWithNext "));
   1.912 +			break;
   1.913 +		case EAttStartNewPage:
   1.914 +			outputBuf.Insert(0,_L("StartNewPage "));
   1.915 +			break;
   1.916 +		case EAttWidowOrphan:
   1.917 +			outputBuf.Insert(0,_L("WidowOrphan "));
   1.918 +			break;
   1.919 +		case EAttFontPosture:
   1.920 +			outputBuf.Insert(0,_L("Italic "));
   1.921 +			break;
   1.922 +		case EAttFontStrokeWeight:
   1.923 +			outputBuf.Insert(0,_L("Bold "));
   1.924 +			break;
   1.925 +		case EAttFontUnderline:
   1.926 +			outputBuf.Insert(0,_L("Underline "));
   1.927 +			break;
   1.928 +		case EAttFontStrikethrough:
   1.929 +			outputBuf.Insert(0,_L("Strikethrough "));
   1.930 +			break;
   1.931 +		}
   1.932 +	if (aValue == 0)	// Boolean NOT
   1.933 +		outputBuf.Insert(0,_L("!"));
   1.934 +	Insert(outputBuf);
   1.935 +	}