|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Converter Architecture wrappers for CRT -> HTML conversion |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __HTML_2_CRT_CONV_H__ |
|
19 #define __HTML_2_CRT_CONV_H__ |
|
20 |
|
21 const TUid KCrt2HTMLConverterUid = {0x1000071c}; |
|
22 |
|
23 #include <txtmrtsr.h> |
|
24 |
|
25 //------------------------------------------------------------------------------------------------- |
|
26 // Fwd Decl. |
|
27 class TOutputSink; |
|
28 |
|
29 //------------------------------------------------------------------------------------------------- |
|
30 // Class CCrtToHTMLConverter. |
|
31 // The CConverterBase2 derived class which is responsable for performing the conversion operation. |
|
32 // 1. Only supports File->File conversions |
|
33 // 2. Does not support embedded objects (ConArc has no mechanism to request a filename to convert the |
|
34 // embedded object into) |
|
35 // 3. The conversion is performed on a paragraph by paragraph basis |
|
36 |
|
37 class CCrtToHTMLConverter : public CConverterBase2, MRichTextStoreResolver |
|
38 { |
|
39 public: // from CConverterBase2 |
|
40 void ConvertL(const TFileName& aSourceFile, const TFileName& aTargetFile, MConverterUiObserver* aObserver = NULL); |
|
41 void ConvertObjectL(RReadStream& aReadStream, RWriteStream& aWriteStream, MConverterUiObserver* aObserver=NULL); // Leaves with KErrNotSupported |
|
42 void ConvertAL(const TFileName& aSourceFile, const TFileName& aTargetFile, MConverterUiObserver* aObserver=NULL); // Leaves with KErrNotSupported |
|
43 void ConvertObjectAL(RReadStream& aReadStream, RWriteStream& aWriteStream, MConverterUiObserver* aObserver=NULL); // Leaves with KErrNotSupported |
|
44 |
|
45 TBool DoConvertL(); |
|
46 TUid Uid(); |
|
47 TInt Capabilities(); |
|
48 void CancelConvert(); |
|
49 |
|
50 CCrtToHTMLConverter(); |
|
51 ~CCrtToHTMLConverter(); |
|
52 |
|
53 // From MRichTextStoreResolver |
|
54 const CStreamStore& StreamStoreL(TInt /*aPos*/)const { return *iStore; }; |
|
55 static CConverterBase2* NewL(); |
|
56 private: |
|
57 void ResetMembers(); |
|
58 void RestoreInputTextL(const TFileName& aSourceFile); |
|
59 void PrepForConversionL(const TFileName& aSourceFile, const TFileName& aTargetFile); |
|
60 void PrepForConversionL(RReadStream& aReadStream, RWriteStream& aWriteStream); |
|
61 |
|
62 // Output |
|
63 void StartDocumentL(); |
|
64 void EndDocumentL(); |
|
65 void TranslateL (const TDesC& aBuf); |
|
66 void WriteTagL(const TDesC8& aTagText); |
|
67 void WriteContentL(const TDesC& aText); |
|
68 // Processing |
|
69 void ProcessParagraphFormatL(const CParaFormat* aParaFormat, TBool aClosePara = ETrue); |
|
70 void ProcessParagraphTextL(TInt aPos, TInt aLength); |
|
71 |
|
72 void OpenCharFormatL (const TCharFormatMask& aMask, const TCharFormat& aFormat); |
|
73 void CloseCharFormatL(const TCharFormatMask& aMask, const TCharFormat& aFormat); |
|
74 void DiffCharFormats(const TCharFormat& aFormatA, const TCharFormat& aFormatB, TCharFormatMask& aMask); |
|
75 |
|
76 private: |
|
77 CParaFormatLayer* iParaLayer; // The global paragraph format layer |
|
78 CCharFormatLayer* iCharLayer; // The global character format layer |
|
79 CRichText* iInputText; // The input rich text |
|
80 HBufC* iInternalFile; // Interanl file copy for the input text |
|
81 |
|
82 CDirectFileStore* iStore; // The Root stream from which we are reading |
|
83 |
|
84 RFs iFs; // Our file server session |
|
85 RFileWriteStream iFileStream; |
|
86 RWriteStream& iHTMLOut; // Somewhere to write our output to |
|
87 |
|
88 TBullet* iBullet; // Pointer to any current bullet object. Null if we're not processing a list. |
|
89 TInt iIndent; // Indent level (Number of <BLOCKQUOTE> tags to insert) |
|
90 |
|
91 TInt iParaRemain; // How many paragraphs remain to be processed |
|
92 TInt iParaCount; // How many paragraphs are there |
|
93 TInt iParaNum; // Which paragraph are we processing now (-1 if we haven't started processing yet) |
|
94 TInt iParaLen; // How long is the current paragraph |
|
95 TInt iParaPos; // What is the offset of the start of the curent paragraph from the start of the input text |
|
96 |
|
97 TBool iInsertBlankDivClose; // Flag indicates if the current paragraph was blank |
|
98 TInt iStyleIndex; // Index into the RichText style list, or -1 |
|
99 TInt iOldFmtCount; // Checks if this loop has previously been entered |
|
100 |
|
101 MConverterUiObserver* iObserver; // Our observer object (or NULL if no-one is watching) |
|
102 }; |
|
103 |
|
104 enum TTextToHTMLPanic |
|
105 { |
|
106 EHTMLTagTooSmall, |
|
107 EHTMLBeyondLastPara, |
|
108 EHTMLNotAPicture |
|
109 }; |
|
110 |
|
111 void Panic(TTextToHTMLPanic aPanic); |
|
112 |
|
113 #endif |