1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/textrendering/texthandling/incp/T_PMLPAR.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,199 @@
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 +#ifndef __T_PMLPAR_H__
1.23 +#define __T_PMLPAR_H__
1.24 +
1.25 +#include <e32cons.h>
1.26 +#include <f32file.h>
1.27 +#include <txtrich.h>
1.28 +#include <txtfrmat.h>
1.29 +#include <txtfmlyr.h>
1.30 +
1.31 +#pragma warning ( disable : 4705 ) // turns off "statement has no effect" warning
1.32 +
1.33 +const TInt KCharLength = 2;
1.34 +
1.35 +// Clases defined in this file
1.36 +class CFileApp;
1.37 +class CParser;
1.38 +
1.39 +const TChar KTabChar=TChar(9);
1.40 +const TChar KLineFeed(10);
1.41 +const TChar KComma=TChar(44);
1.42 +const TInt KFileBufSize=128;
1.43 +
1.44 +const TBuf<1> NEWLINE(_L("\n"));
1.45 +
1.46 +class CFileApp : public CBase
1.47 + { // Reads a text file into a segmented buffer
1.48 +public:
1.49 + static CFileApp* NewL();
1.50 + ~CFileApp();
1.51 +
1.52 + CBufSeg* LoadFileL(CConsoleBase* aConsole);
1.53 + CBufSeg* LoadFileL(const TFileName &aFileName);
1.54 + TInt SaveFile(CBufSeg* aTextBuf, TFileName aFileName); // returns error level
1.55 + inline TFileName ReturnFileName() {return iFileName;}
1.56 +protected:
1.57 + CFileApp();
1.58 + void ConstructApplicationL();
1.59 +private:
1.60 + void OutputToScreen(const TDesC& aMessageBuffer);
1.61 + void FileHandlingL();
1.62 + void GetFileName();
1.63 + void ReadChunkOfFileContents(RFile &aTextFile);
1.64 + void WriteNewLine();
1.65 +private:
1.66 + CConsoleBase* iConsole; // Pointer to the console window
1.67 + TBool iConsoleExists;
1.68 + TFileName iFileName; // Hmmm...
1.69 + TUint iFilePos; // Current position within file
1.70 + CBufSeg * iTextBuf; // Buffer for text file to be read into
1.71 + TBuf<KFileBufSize> iFileBuf; // Buffer for reading file in
1.72 + };
1.73 +
1.74 +
1.75 +class CParser : public CBase
1.76 + { // Loads a segmented buffer full of text and parses it as PML, converting it into RichText
1.77 +public:
1.78 + static CParser* NewL();
1.79 + ~CParser();
1.80 +
1.81 + CRichText* ParseL(const TFileName &aFileName); // no GDI - Filename supplied
1.82 + CRichText* ParseL(CConsoleBase* aConsole); // with E32 console interface
1.83 +protected:
1.84 + CParser();
1.85 + void ConstructApplicationL();
1.86 +private:
1.87 + void ParseTextBufL();
1.88 + TBool Validate();
1.89 + TChar ReadChar();
1.90 + void ProcessTextL(TChar aChar);
1.91 + void AddCharToParaL(TChar aChar);
1.92 +
1.93 + TChar ReadTagChar(); // Tag methods
1.94 + void ProcessTagL(); //
1.95 + void ClassifyTagL(TChar aTagChar); //
1.96 + void AppendToArgBuf(TChar aTagChar); //
1.97 + void ProcessArgBufL(); //
1.98 + void ClassifyArgumentsL(); //
1.99 + void TranslateTagArgL(); //
1.100 + void TransGlobalArgL(); //
1.101 + void TransParagraphArgL(); //
1.102 + void TransCharArg(); //
1.103 + void TransControlArgL(); //
1.104 + TInt GetArgValue(); //
1.105 + TInt GetArgValue(const TDes &aBuf); //
1.106 + TBool BufIsNumeric(const TDes &aBuffer);//
1.107 +
1.108 + void TransParaDefault(); // Argument translators for paragraph
1.109 + void TransParaArgAlignment(); //
1.110 + void TransParaArgLeftMargin(); //
1.111 + void TransParaArgRightMargin(); //
1.112 + void TransParaArgIndent(); //
1.113 + void TransParaLineSpacing(); //
1.114 + void TransParaArgLineSpacingControl(); //
1.115 + void TransParaSpaceBefore(); //
1.116 + void TransParaSpaceAfter(); //
1.117 + void TransParaKeepTogether(); //
1.118 + void TransParaKeepWithNext(); //
1.119 + void TransParaStartNewPage(); //
1.120 + void TransParaWidowOrphan(); //
1.121 + void TransParaBorderMargin(); //
1.122 + void TransParaBorderL(); //
1.123 + void TransParaTabWidth(); //
1.124 + void TransParaTabStopL(); //
1.125 + void TransParaBullet(); //
1.126 + void TransCharDefault(); // ... and character
1.127 + void TransCharPosture(); //
1.128 + void TransCharStrokeWeight(); //
1.129 + void TransCharUnderline(); //
1.130 + void TransCharStrikethrough(); //
1.131 + void TransCharFontHeight(); //
1.132 + void TransCharPrintPos(); //
1.133 + void TransCharTypefaceName(); //
1.134 + void TransCharTypefaceFlags(); //
1.135 + void TransCharColor(); //
1.136 + void TransCharLanguage(); //
1.137 +
1.138 + void SetFormatLayerL(); // RT doc methods
1.139 +
1.140 + void EmptyBuffer(TDes &aBuf);
1.141 + void OutputToScreen(const TDesC& aMessageBuffer);
1.142 + void WriteNewLine() {OutputToScreen(NEWLINE);}
1.143 + void EmitErrorMessage();
1.144 +public:
1.145 + TFileName iFileName;
1.146 +private:
1.147 + TBuf8<512> SquashBuf(TDes aBuffer);
1.148 + //
1.149 + enum { // Error types
1.150 + ENoError,
1.151 + EUnparagraphedText,
1.152 + EUnknownTagType,
1.153 + EUnknownAttrib,
1.154 + ENoAttribValue,
1.155 + EIllegalAttribValue
1.156 + };
1.157 + enum { // Possible types of tag
1.158 + EGlobal,
1.159 + EParagraph,
1.160 + ECharacter,
1.161 + EControl,
1.162 + EComment,
1.163 + EError};
1.164 + TUint iErrorLevel;
1.165 + CConsoleBase* iConsole; // Pointer to the console window
1.166 + TBool iConsoleExists;
1.167 + CBufSeg * iTextBuf; // Buffer for the text file to be parsed
1.168 + TUint iReadPos; // Current read position in iTextBuf
1.169 + TUint iLineNo; // Current line no. in iTextBuf (for error messages)
1.170 + TBool iParagraphIsOpen; // Self explanatory?
1.171 + TBool iPhraseOpen; // Character formatting is being applied
1.172 + TBool iArgValueExpected; // Set if a tag argument requires a value eg =120
1.173 + TBool iArgStored; // Set if there is an argument in temp storage
1.174 + TBool iCancelArg; // Set if the arg has been canceled - ie turns formatting off
1.175 + TBool iBorderUsed;
1.176 + TBool iBulletUsed;
1.177 + TInt iTagType; // The type of tag: see enum above
1.178 + TBuf<32> iArgType; // Buffer for tag arguments. Whole arg if they have no value
1.179 + TBuf<32> iArgValue; // Buffer for arg values... (32 bytes) eg. <P ArgType=ArgValue>
1.180 +
1.181 + // Rich Text document variables
1.182 + CRichText* iRichTextDoc; // The RT doc
1.183 + TInt iDocInsertPos; // Cursor position in RT doc
1.184 + TUint iDocParaLength; // Length of current paragraph
1.185 + TUint iDocPhraseLength; // ...
1.186 + CParaFormatLayer* iGlobalParaFormatLayer;
1.187 + TParaFormatMask iGlobalParaFormatMask;
1.188 + CParaFormat* iGlobalParaFormat;
1.189 + CCharFormatLayer* iGlobalCharFormatLayer;
1.190 + TCharFormatMask iGlobalCharFormatMask;
1.191 + TCharFormat iGlobalCharFormat;
1.192 + CParaFormatLayer* iParaFormatLayer;
1.193 + TParaFormatMask iParaFormatMask;
1.194 + CParaFormat* iParaFormat;
1.195 + CCharFormatLayer* iCharFormatLayer;
1.196 + TCharFormatMask iCharFormatMask;
1.197 + TCharFormat iCharFormat;
1.198 + TParaBorder* iBorder;
1.199 + TBullet* iBullet;
1.200 + };
1.201 +
1.202 +#endif