os/textandloc/textrendering/texthandling/spml/T_PMAIN2.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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_PARS06.H>
    21 #include <T_RTP01.H>
    22 #include <E32TWIN.H>
    23 
    24 
    25 TInt E32Main()
    26 	{
    27 	__UHEAP_MARK;
    28 	CTrapCleanup* cleanup=CTrapCleanup::New();
    29  
    30  	// set filename
    31 	TFileName theFileName = _L("c:\\etext\\incp\\dunk.pml");
    32 
    33 	// Parse PML
    34 	CParser* myParser;
    35 	CRichText* richTextDoc;
    36 	TRAPD(ret, myParser=CParser::NewL());
    37 	TRAP(ret, richTextDoc = myParser->ParseL(theFileName));
    38 
    39 // *********** insert test code here ****************
    40 
    41 
    42 /*	TInt para=richTextDoc->CountParas();
    43 	TInt length=richTextDoc->DocumentLength();
    44 	CParaFormat* myformat;
    45 	TRAP(ret,myformat=CParaFormat::NewL());
    46 	TCharFormat charFormat; CPicture* picture; TPtrC view;
    47 	TRAP(ret,richTextDoc->SenseParaFormatL(length,myformat));
    48 	TRAP(ret,richTextDoc->SenseChars(0,view,charFormat,picture));
    49 	TRAP(ret,richTextDoc->SenseChars(10,view,charFormat,picture));
    50 	richTextDoc->Delete(4,6);
    51 	//TRAP(ret,richTextDoc->InsertL(richTextDoc->DocumentLength(),EParagraphDelimiter));
    52 */
    53 
    54 	// make rich text reader & read rich text doc & parse back to PML
    55 	CRichTextReader* myRTReader;
    56 	CBufSeg* returnedPmlDoc; 
    57 	TRAP(ret, myRTReader = CRichTextReader::NewL());
    58 	TRAP(ret, returnedPmlDoc = myRTReader->ConvertRichText(richTextDoc));
    59 
    60 	// save to disc
    61 	CFileApp* myFileApp;
    62 	TRAP(ret, myFileApp = CFileApp::NewL());
    63 	TInt errorLevel = myFileApp->SaveFile(returnedPmlDoc,theFileName);
    64 
    65 	// finish up
    66 	Adt::Destroy(myFileApp);
    67 	Adt::Destroy(myRTReader);
    68 	Adt::Destroy(myParser);
    69 	Adt::Destroy(cleanup);
    70 	__UHEAP_MARKEND;
    71 	return 0;
    72 	}
    73