textrendering/texthandling/ttext/TRTCOPY.CPP
changeset 32 8b9155204a54
parent 0 1fb32624e06b
child 51 a7c938434754
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 <txtrich.h>
       
    21 #include <txtstyle.h>
       
    22 #include <flddef.h>
       
    23 #include <fldbltin.h>
       
    24 #include <gdi.h>
       
    25 #include <conpics.h>											   						 
       
    26 #include <s32mem.h>
       
    27 #include <s32file.h>
       
    28 #include "../incp/T_PMLPAR.H"
       
    29 
       
    30 GLDEF_C RTest test(_L("TRTCOPY"));
       
    31 LOCAL_D RFs theFs;
       
    32 LOCAL_D CRichText* ComponentText;
       
    33 LOCAL_D CParaFormatLayer* GlobalParaFormatLayer;
       
    34 LOCAL_D CCharFormatLayer* GlobalCharFormatLayer;
       
    35 LOCAL_D CTrapCleanup* TheTrapCleanup;
       
    36 LOCAL_D CParser* TheParser;
       
    37 
       
    38 const TInt KTestCleanupStack=0x500;
       
    39 
       
    40 
       
    41 LOCAL_C CRichText* LoadIntoTextL(TFileName& aFileName)
       
    42 //
       
    43 	{
       
    44 	TRAPD(ret,
       
    45 	TheParser=CParser::NewL());
       
    46 	CRichText* text=NULL;
       
    47 	TRAP(ret,
       
    48 	text=TheParser->ParseL(aFileName));
       
    49 	GlobalParaFormatLayer=(CParaFormatLayer*)text->GlobalParaFormatLayer();
       
    50 	GlobalCharFormatLayer=(CCharFormatLayer*)text->GlobalCharFormatLayer();
       
    51 	delete TheParser;
       
    52 	TheParser=NULL;
       
    53 	return text;
       
    54 	}
       
    55 
       
    56 /*
       
    57 LOCAL_C CStyleList* CreatePopulatedStyleList()
       
    58 //
       
    59 	{
       
    60 	//
       
    61 	// Create style aswell.
       
    62 	CStyleList* list=CStyleList::NewL();
       
    63 	CParagraphStyle* style1=CParagraphStyle::NewL(*GlobalParaFormatLayer,*GlobalCharFormatLayer);
       
    64 	CParagraphStyle* style2=CParagraphStyle::NewL(*GlobalParaFormatLayer,*GlobalCharFormatLayer);
       
    65 	CParagraphStyle* style3=CParagraphStyle::NewL(*GlobalParaFormatLayer,*GlobalCharFormatLayer);
       
    66 	list->AppendL(*style1);
       
    67 	list->AppendL(*style2);
       
    68 	list->AppendL(*style3);
       
    69 	return list;
       
    70 	}
       
    71 */
       
    72 
       
    73 LOCAL_C void CreateAggregateTextL()
       
    74 //
       
    75 	{
       
    76 	TFileName theFileName=_L("z:\\test\\app-framework\\etext\\aggregat.pml");
       
    77 //	AggregateText=LoadIntoTextL(theFileName);
       
    78 	//
       
    79 	theFileName=_L("z:\\test\\app-framework\\etext\\componnt.pml");
       
    80 	ComponentText=LoadIntoTextL(theFileName);
       
    81 	// Insert a picture or two
       
    82 	CXzePicture* pic1=CXzePicture::NewL('x');
       
    83 	CleanupStack::PushL(pic1);
       
    84 	CXzePicture* pic2=CXzePicture::NewL('z');
       
    85 	CleanupStack::PushL(pic2);
       
    86 	// Create the picture headers
       
    87 	TPictureHeader hdr1;
       
    88 	TPictureHeader hdr2;
       
    89 	hdr1.iPictureType=KUidXzePictureType;
       
    90 	hdr1.iPicture=pic1;
       
    91 	hdr2.iPictureType=KUidXzePictureType;
       
    92 	hdr2.iPicture=pic2;
       
    93 	ComponentText->InsertL(0,hdr1);
       
    94 	ComponentText->InsertL(ComponentText->DocumentLength(),hdr2);
       
    95 	CleanupStack::Pop(2);  // pic1,pic2
       
    96 	//
       
    97 	// Now do the insert.
       
    98 //	AggregateText->InsertL(10,ComponentText);
       
    99 //	delete AggregateText;
       
   100 	delete ComponentText;
       
   101 	delete GlobalParaFormatLayer;
       
   102 	delete GlobalCharFormatLayer;
       
   103 	}
       
   104 
       
   105 
       
   106 LOCAL_C void doMainL()
       
   107 	{
       
   108 	CreateAggregateTextL();
       
   109 
       
   110 	
       
   111 	}
       
   112 
       
   113 
       
   114 LOCAL_C void setupCleanup()
       
   115 //
       
   116 // Initialise the cleanup stack.
       
   117 //
       
   118     {
       
   119 	TheTrapCleanup=CTrapCleanup::New();
       
   120 	test(TheTrapCleanup!=NULL);
       
   121 	TRAPD(r,\
       
   122 		{\
       
   123 		for (TInt i=KTestCleanupStack;i>0;i--)\
       
   124 			CleanupStack::PushL((TAny*)0);\
       
   125 		CleanupStack::Pop(KTestCleanupStack);\
       
   126 		});
       
   127 	test(r==KErrNone);
       
   128 	}
       
   129 
       
   130 
       
   131 GLDEF_C TInt E32Main()
       
   132 //
       
   133 // Test permanent file store.
       
   134 //
       
   135     {
       
   136 	test.Title();	
       
   137 	setupCleanup();
       
   138 	__UHEAP_MARK;
       
   139 //
       
   140 	test.Start(_L(" @SYMTestCaseID:SYSLIB-TTEXT-LEGACY-T_TRTCOPY-0001 RichText Copy Testing "));
       
   141 	TRAPD(ret,doMainL());	
       
   142 	test(ret==KErrNone);
       
   143 	test.End();
       
   144 //
       
   145 	__UHEAP_MARKEND;
       
   146 	delete TheTrapCleanup;
       
   147 	test.Close();
       
   148 	return KErrNone;
       
   149     }
       
   150