|
1 /* |
|
2 * Copyright (c) 1997-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 * Main |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <T_PMLPAR.H> |
|
21 #include <T_RTPAR.H> |
|
22 #include <E32TWIN.H> |
|
23 |
|
24 |
|
25 TInt E32Main() |
|
26 { |
|
27 __UHEAP_MARK; |
|
28 CTrapCleanup* cleanup=CTrapCleanup::New(); |
|
29 |
|
30 // create console |
|
31 RConsole theConsole; |
|
32 TSize consSize(KConsFullScreen, KConsFullScreen); |
|
33 TInt err; |
|
34 err = theConsole.Create(); |
|
35 err = theConsole.Control(_L("-Visibility")); |
|
36 err = theConsole.Set(_L("The Epoc RichText Parser (c)"), consSize); |
|
37 err = theConsole.Control(_L("Visibility Newline Max_win_size")); |
|
38 |
|
39 // Parse PML |
|
40 CParser* myParser; |
|
41 CRichText* richTextDoc; |
|
42 TRAPD(ret, myParser=CParser::NewL()); |
|
43 TRAP(ret, richTextDoc = myParser->ParseL(theConsole)); |
|
44 TInt dum=ret; |
|
45 |
|
46 /* //enable this bit for a pause before executing test code |
|
47 // wait for keypress |
|
48 theConsole.Write(_L("\n\nPress space to execute test code & parse back to PML\n")); |
|
49 TConsoleKey keystroke; |
|
50 while (keystroke.Code() != EKeySpace) |
|
51 theConsole.Read(keystroke); |
|
52 */ |
|
53 |
|
54 // *********** insert test code here **************** |
|
55 |
|
56 |
|
57 /* TInt para=richTextDoc->CountParas(); |
|
58 TInt length=richTextDoc->DocumentLength(); |
|
59 CParaFormat* myformat; |
|
60 TRAP(ret,myformat=CParaFormat::NewL()); |
|
61 TCharFormat charFormat; CPicture* picture; TPtrC view; |
|
62 TRAP(ret,richTextDoc->SenseParaFormatL(length,myformat)); |
|
63 TRAP(ret,richTextDoc->SenseChars(0,view,charFormat,picture)); |
|
64 TRAP(ret,richTextDoc->SenseChars(10,view,charFormat,picture)); |
|
65 richTextDoc->Delete(4,6); |
|
66 //TRAP(ret,richTextDoc->InsertL(richTextDoc->DocumentLength(),EParagraphDelimiter)); |
|
67 */ |
|
68 |
|
69 // make rich text reader & read rich text doc & parse back to PML |
|
70 CRichTextReader* myRTReader; |
|
71 CBufSeg* returnedPmlDoc; |
|
72 TRAP(ret, myRTReader = CRichTextReader::NewL()); |
|
73 TRAP(ret, returnedPmlDoc = myRTReader->ConvertRichText(richTextDoc,theConsole)); |
|
74 |
|
75 // save to disc |
|
76 CFileApp* myFileApp; |
|
77 TRAP(ret, myFileApp = CFileApp::NewL()); |
|
78 TInt errorLevel = myFileApp->SaveFile(returnedPmlDoc,myParser->iFileName); |
|
79 if (errorLevel == 0) |
|
80 theConsole.Write(_L("\n\nFile Saved")); |
|
81 else |
|
82 theConsole.Write(_L("\n\nFile Save unsuccessful!!")); |
|
83 |
|
84 // wait for keypress |
|
85 theConsole.Write(_L("\n\nPress space to quit\n")); |
|
86 TConsoleKey keystroke; |
|
87 while (keystroke.Code() != EKeySpace) |
|
88 theConsole.Read(keystroke); |
|
89 |
|
90 // finish up |
|
91 Adt::Destroy(myFileApp); |
|
92 Adt::Destroy(myRTReader); |
|
93 Adt::Destroy(myParser); |
|
94 theConsole.Destroy(); |
|
95 Adt::Destroy(cleanup); |
|
96 __UHEAP_MARKEND; |
|
97 return 0; |
|
98 } |
|
99 |