|
1 /* |
|
2 * Copyright (c) 2007-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 * Needs the following libraries in the MMP: |
|
16 * euser.lib etext.lib fbscli.lib bitgdi.lib form.lib EFSRV.LIB imageconversion.lib ezip.lib |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <txtfrmat.h> |
|
24 #include <txtrich.h> |
|
25 #include <frmtview.h> |
|
26 #include <imageconversion.h> |
|
27 #include <zipfile.h> |
|
28 |
|
29 // Complete richtext document class that uses a file-based |
|
30 // bitmap instead of a screen device allowing the creation, |
|
31 // saving and comparing of what would normally be screen-shots |
|
32 class CTestBitmapFile : public CActive |
|
33 { |
|
34 public: |
|
35 // Construction |
|
36 // Optionally specify screen size and font/ fontsize |
|
37 IMPORT_C static CTestBitmapFile* NewLC(const TRect& aDisplayRect = TRect(0, 0, 252, 94), |
|
38 TCharFormat aCharFormat = TCharFormat(_L("NewTimes"),300)); |
|
39 IMPORT_C ~CTestBitmapFile(); |
|
40 |
|
41 // Load/save operations |
|
42 IMPORT_C TBool CompareL(const TDes8& aData); |
|
43 IMPORT_C void SaveFileL(const TDesC& aFileName); |
|
44 |
|
45 // Gets |
|
46 IMPORT_C CRichText* DocModel() {return iDocModel;} |
|
47 IMPORT_C CTextView* View() {return iView;} |
|
48 IMPORT_C CTextLayout* Layout() {return iLayout;} |
|
49 |
|
50 IMPORT_C void AppendL(const TDesC&); |
|
51 IMPORT_C void AppendL(CPicture* aPic); |
|
52 |
|
53 private: |
|
54 // Construction |
|
55 CTestBitmapFile(); |
|
56 void ConstructL(); |
|
57 |
|
58 // Destruction |
|
59 void Delete(void*); |
|
60 |
|
61 // Active object interface |
|
62 void RunL(); |
|
63 void DoCancel(); |
|
64 |
|
65 private: |
|
66 CFbsBitmap* iBitmap; |
|
67 CImageEncoder* iSaveUtil; |
|
68 RFs iFs; |
|
69 TRect iDisplayRect; |
|
70 CFbsBitmapDevice* iDevice; |
|
71 CParaFormat* iParaFormat; |
|
72 TParaFormatMask iParaFormatMask; |
|
73 CParaFormatLayer* iParaFormatLayer; |
|
74 TCharFormat iCharFormat; |
|
75 TCharFormatMask iCharFormatMask; |
|
76 CCharFormatLayer* iCharFormatLayer; |
|
77 CRichText* iDocModel; |
|
78 CTextLayout* iLayout; |
|
79 CTextView* iView; |
|
80 }; |
|
81 |
|
82 |
|
83 //Extracts zipped bitmap files into descriptors for convenient comparison |
|
84 class CTestBitmapZipFileExtractor : public CBase |
|
85 { |
|
86 public: |
|
87 // Construction |
|
88 IMPORT_C static CTestBitmapZipFileExtractor* NewLC(const TDesC& aZipFile); |
|
89 IMPORT_C ~CTestBitmapZipFileExtractor(); |
|
90 // Bitmap file extractor and descriptor converter |
|
91 IMPORT_C TPtr8 BitmapFileL(const TDesC& aFilename); |
|
92 |
|
93 private: |
|
94 // Construction |
|
95 CTestBitmapZipFileExtractor(); |
|
96 void ConstructL(const TDesC& aZipFile); |
|
97 |
|
98 private: |
|
99 RFs iFs; |
|
100 // Zip file object |
|
101 CZipFile* iZipFile; |
|
102 //temporary buffer for descriptor conversion |
|
103 HBufC8* iBuf; |
|
104 }; |