sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: sl@0: sl@0: sl@0: TInt E32Main() sl@0: { sl@0: __UHEAP_MARK; sl@0: CTrapCleanup* cleanup=CTrapCleanup::New(); sl@0: // create console sl@0: RConsole theConsole; sl@0: TSize consSize(KConsFullScreen, KConsFullScreen); sl@0: TInt err; sl@0: err = theConsole.Create(); sl@0: err = theConsole.Control(_L("-Visibility")); sl@0: err = theConsole.Set(_L("The Epoc RichText Parser (c)"), consSize); sl@0: err = theConsole.Control(_L("Visibility Newline Max_win_size")); sl@0: sl@0: // Parse PML sl@0: CParser* myParser; sl@0: CRichText* richTextDoc; sl@0: TRAPD(ret, myParser=CParser::NewL()); sl@0: TRAP(ret, richTextDoc = myParser->ParseL(theConsole)); sl@0: sl@0: /* enable this bit for a pause before executing test code sl@0: // wait for keypress sl@0: theConsole.Write(_L("\n\nPress space to execute test code & parse back to PML\n")); sl@0: TConsoleKey keystroke; sl@0: while (keystroke.Code() != EKeySpace) sl@0: theConsole.Read(keystroke); sl@0: sl@0: // *********** insert test code here **************** sl@0: TInt para=richTextDoc->CountParas(); sl@0: TInt length=richTextDoc->DocumentLength(); sl@0: CParaFormat* myformat; sl@0: TRAP(ret,myformat=CParaFormat::NewL()); sl@0: TCharFormat charFormat; CPicture* picture; TPtrC view; sl@0: TRAP(ret,richTextDoc->SenseParaFormatL(length,myformat)); sl@0: TRAP(ret,richTextDoc->SenseChars(0,view,charFormat,picture)); sl@0: TRAP(ret,richTextDoc->SenseChars(10,view,charFormat,picture)); sl@0: richTextDoc->Delete(4,6); sl@0: // TRAP(ret,richTextDoc->InsertL(richTextDoc->DocumentLength(),EParagraphDelimiter)); sl@0: */ sl@0: sl@0: // make rich text reader & read rich text doc & parse back to PML sl@0: CRichTextReader* myRTReader; sl@0: CBufSeg* returnedPmlDoc; sl@0: TRAP(ret, myRTReader = CRichTextReader::NewL()); sl@0: TRAP(ret, returnedPmlDoc = myRTReader->ConvertRichText(richTextDoc,theConsole)); sl@0: sl@0: // save to disc sl@0: CFileApp* myFileApp; sl@0: TRAP(ret, myFileApp = CFileApp::NewL()); sl@0: TInt errorLevel = myFileApp->SaveFile(returnedPmlDoc,myParser->iFileName); sl@0: if (errorLevel == 0) sl@0: theConsole.Write(_L("\n\nFile Saved")); sl@0: else sl@0: theConsole.Write(_L("\n\nFile Save unsuccessful!!")); sl@0: sl@0: // wait for keypress sl@0: theConsole.Write(_L("\n\nPress space to quit\n")); sl@0: TConsoleKey keystroke; sl@0: while (keystroke.Code() != EKeySpace) sl@0: theConsole.Read(keystroke); sl@0: sl@0: // finish up sl@0: Adt::Destroy(myFileApp); sl@0: Adt::Destroy(myRTReader); sl@0: Adt::Destroy(myParser); sl@0: theConsole.Destroy(); sl@0: Adt::Destroy(cleanup); sl@0: __UHEAP_MARKEND; sl@0: return 0; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: