sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32test.h>
|
sl@0
|
20 |
#include <richtext.h>
|
sl@0
|
21 |
#include <t_pmlpar.h>
|
sl@0
|
22 |
#include <t_rtpar.h>
|
sl@0
|
23 |
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
TInt E32Main()
|
sl@0
|
28 |
{
|
sl@0
|
29 |
__UHEAP_MARK;
|
sl@0
|
30 |
CTrapCleanup* cleanup=CTrapCleanup::New();
|
sl@0
|
31 |
// create console
|
sl@0
|
32 |
RConsole theConsole;
|
sl@0
|
33 |
TSize consSize(KConsFullScreen, KConsFullScreen);
|
sl@0
|
34 |
TInt err;
|
sl@0
|
35 |
err = theConsole.Create();
|
sl@0
|
36 |
err = theConsole.Control(_L("-Visibility"));
|
sl@0
|
37 |
err = theConsole.Set(_L("The Epoc RichText Parser (c)"), consSize);
|
sl@0
|
38 |
err = theConsole.Control(_L("Visibility Newline Max_win_size"));
|
sl@0
|
39 |
|
sl@0
|
40 |
// Parse PML
|
sl@0
|
41 |
CParser* myParser;
|
sl@0
|
42 |
CRichText* richTextDoc;
|
sl@0
|
43 |
TRAPD(ret, myParser=CParser::NewL());
|
sl@0
|
44 |
TRAP(ret, richTextDoc = myParser->ParseL(theConsole));
|
sl@0
|
45 |
|
sl@0
|
46 |
/* enable this bit for a pause before executing test code
|
sl@0
|
47 |
// wait for keypress
|
sl@0
|
48 |
theConsole.Write(_L("\n\nPress space to execute test code & parse back to PML\n"));
|
sl@0
|
49 |
TConsoleKey keystroke;
|
sl@0
|
50 |
while (keystroke.Code() != EKeySpace)
|
sl@0
|
51 |
theConsole.Read(keystroke);
|
sl@0
|
52 |
|
sl@0
|
53 |
// *********** insert test code here ****************
|
sl@0
|
54 |
TInt para=richTextDoc->CountParas();
|
sl@0
|
55 |
TInt length=richTextDoc->DocumentLength();
|
sl@0
|
56 |
CParaFormat* myformat;
|
sl@0
|
57 |
TRAP(ret,myformat=CParaFormat::NewL());
|
sl@0
|
58 |
TCharFormat charFormat; CPicture* picture; TPtrC view;
|
sl@0
|
59 |
TRAP(ret,richTextDoc->SenseParaFormatL(length,myformat));
|
sl@0
|
60 |
TRAP(ret,richTextDoc->SenseChars(0,view,charFormat,picture));
|
sl@0
|
61 |
TRAP(ret,richTextDoc->SenseChars(10,view,charFormat,picture));
|
sl@0
|
62 |
richTextDoc->Delete(4,6);
|
sl@0
|
63 |
// TRAP(ret,richTextDoc->InsertL(richTextDoc->DocumentLength(),EParagraphDelimiter));
|
sl@0
|
64 |
*/
|
sl@0
|
65 |
|
sl@0
|
66 |
// make rich text reader & read rich text doc & parse back to PML
|
sl@0
|
67 |
CRichTextReader* myRTReader;
|
sl@0
|
68 |
CBufSeg* returnedPmlDoc;
|
sl@0
|
69 |
TRAP(ret, myRTReader = CRichTextReader::NewL());
|
sl@0
|
70 |
TRAP(ret, returnedPmlDoc = myRTReader->ConvertRichText(richTextDoc,theConsole));
|
sl@0
|
71 |
|
sl@0
|
72 |
// save to disc
|
sl@0
|
73 |
CFileApp* myFileApp;
|
sl@0
|
74 |
TRAP(ret, myFileApp = CFileApp::NewL());
|
sl@0
|
75 |
TInt errorLevel = myFileApp->SaveFile(returnedPmlDoc,myParser->iFileName);
|
sl@0
|
76 |
if (errorLevel == 0)
|
sl@0
|
77 |
theConsole.Write(_L("\n\nFile Saved"));
|
sl@0
|
78 |
else
|
sl@0
|
79 |
theConsole.Write(_L("\n\nFile Save unsuccessful!!"));
|
sl@0
|
80 |
|
sl@0
|
81 |
// wait for keypress
|
sl@0
|
82 |
theConsole.Write(_L("\n\nPress space to quit\n"));
|
sl@0
|
83 |
TConsoleKey keystroke;
|
sl@0
|
84 |
while (keystroke.Code() != EKeySpace)
|
sl@0
|
85 |
theConsole.Read(keystroke);
|
sl@0
|
86 |
|
sl@0
|
87 |
// finish up
|
sl@0
|
88 |
Adt::Destroy(myFileApp);
|
sl@0
|
89 |
Adt::Destroy(myRTReader);
|
sl@0
|
90 |
Adt::Destroy(myParser);
|
sl@0
|
91 |
theConsole.Destroy();
|
sl@0
|
92 |
Adt::Destroy(cleanup);
|
sl@0
|
93 |
__UHEAP_MARKEND;
|
sl@0
|
94 |
return 0;
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
|
sl@0
|
98 |
|
sl@0
|
99 |
|
sl@0
|
100 |
|