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