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