|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // apadbase.cpp |
|
15 // |
|
16 |
|
17 #include <apadbase.h> |
|
18 #include "APASTD.H" // Panics etc. |
|
19 |
|
20 const TUid KUidApaDoorBaseStream = {0x10003A36}; |
|
21 |
|
22 // |
|
23 // CApaDoorBase |
|
24 // |
|
25 |
|
26 EXPORT_C CApaDoorBase::CApaDoorBase() |
|
27 { |
|
28 } |
|
29 |
|
30 EXPORT_C void CApaDoorBase::ExternalizeBaseStreamL(CStreamStore& aStore,CStreamDictionary& aStreamDict)const |
|
31 /** Externalises the information contained in this base class to a stream in the |
|
32 specified store. |
|
33 |
|
34 The resulting stream ID is associated with an internal UID, and placed in |
|
35 the specified stream dictionary. |
|
36 |
|
37 @publishedAll |
|
38 @released |
|
39 @param aStore The store to contain the stream. |
|
40 @param aStreamDict The stream dictionary to contain the stream ID (and an associated |
|
41 internal UID). */ |
|
42 { |
|
43 RStoreWriteStream stream; |
|
44 TStreamId id=stream.CreateLC(aStore); |
|
45 // |
|
46 // write the format |
|
47 if (iFormat==ETemporarilyIconic) |
|
48 stream.WriteInt8L(EGlassDoor); |
|
49 else |
|
50 stream.WriteInt8L(iFormat); |
|
51 // |
|
52 // write the size |
|
53 TSize size; |
|
54 if (iFormat==ETemporarilyIconic) |
|
55 size = GlassDoorSize(); |
|
56 else |
|
57 GetSizeInTwips(size); |
|
58 stream<< size; |
|
59 // |
|
60 // write the source and close |
|
61 stream<< iSource; |
|
62 stream.CommitL(); |
|
63 CleanupStack::PopAndDestroy(); // stream |
|
64 aStreamDict.AssignL(KUidApaDoorBaseStream,id); |
|
65 } |
|
66 |
|
67 |
|
68 |
|
69 EXPORT_C TSize CApaDoorBase::InternalizeBaseStreamL(const CStreamStore& aStore,const CStreamDictionary& aStreamDict) |
|
70 /** Internalises the information for this base class from a stream in the specified |
|
71 store, and returns the size of the icon or glass door. |
|
72 |
|
73 The stream ID is extracted from the specified stream dictionary. The UID associated |
|
74 with the stream ID is the same as that used when externalising. |
|
75 |
|
76 @publishedAll |
|
77 @released |
|
78 @param aStore The store containing the stream. |
|
79 @param aStreamDict The steam dictionary containing the stream ID. |
|
80 @return The size of the icon or glass door, in twips. */ |
|
81 { |
|
82 TStreamId id=aStreamDict.At(KUidApaDoorBaseStream); |
|
83 if (id==KNullStreamId) |
|
84 User::Leave(KErrCorrupt); // there is no base stream - the file is not valid (used to panic EPanicNoBaseDoorStream) |
|
85 RStoreReadStream stream; |
|
86 stream.OpenLC(aStore,id); |
|
87 iFormat = (TFormat)stream.ReadInt8L(); |
|
88 __ASSERT_DEBUG(iFormat==EIconic || iFormat==EGlassDoor,Panic(EDPanicIllegalDoorFormat)); |
|
89 TSize size; |
|
90 stream>> size; |
|
91 stream>> iSource; |
|
92 CleanupStack::PopAndDestroy(); // stream |
|
93 return size; |
|
94 } |
|
95 |
|
96 // Virtual functions from CPicture |
|
97 |
|
98 EXPORT_C TStreamId CApaDoorBase::StoreL(CStreamStore& aStore) const |
|
99 /** Stores the Embedded Document to the specified store. |
|
100 |
|
101 @publishedAll |
|
102 @released |
|
103 @param aStore The store containing the stream. |
|
104 @return The ID of the (head) stream used to store the Embedded Document */ |
|
105 { |
|
106 return CPicture::StoreL(aStore); |
|
107 } |
|
108 |
|
109 EXPORT_C void CApaDoorBase::SetScaleFactor(TInt aScaleFactorWidth,TInt aScaleFactorHeight) |
|
110 /** Sets the Embedded Document's scale factors |
|
111 |
|
112 @publishedAll |
|
113 @released |
|
114 @param aScaleFactorWidth The width scale factor, in percent |
|
115 @param aScaleFactorHeight The height scale factor, in percent |
|
116 */ |
|
117 { |
|
118 CPicture::SetScaleFactor(aScaleFactorWidth, aScaleFactorHeight); |
|
119 } |
|
120 |
|
121 EXPORT_C void CApaDoorBase::SetCropInTwips(const TMargins& aMargins) |
|
122 /** Sets the cropping margins of a Embedded Document in twips. |
|
123 These are relative to the original unscaled size of the Embedded Document. |
|
124 |
|
125 @publishedAll |
|
126 @released |
|
127 @param aMargins The cropping margins of the Embedded Document, in twips |
|
128 */ |
|
129 { |
|
130 CPicture::SetCropInTwips(aMargins); |
|
131 } |
|
132 |
|
133 EXPORT_C TPictureCapability CApaDoorBase::Capability() const |
|
134 /** Gets the Embedded Document's capabilities. |
|
135 These include whether it is scalable and croppable. |
|
136 |
|
137 @publishedAll |
|
138 @released |
|
139 @return The capabilities of the Embedded Document |
|
140 */ |
|
141 { |
|
142 return CPicture::Capability(); |
|
143 } |
|
144 |
|
145 EXPORT_C void CApaDoorBase::GetCropInTwips(TMargins& aMargins) const |
|
146 /** Gets the cropping margins of a Embedded Document in twips. |
|
147 These margins are relative to the original unscaled size of the Embedded Document. |
|
148 |
|
149 @publishedAll |
|
150 @released |
|
151 @param aMargins The cropping margins of the Embedded Document, in twips |
|
152 */ |
|
153 { |
|
154 CPicture::GetCropInTwips(aMargins); |
|
155 } |
|
156 |
|
157 EXPORT_C TInt CApaDoorBase::ScaleFactorWidth() const |
|
158 /** Gets the Embedded Document's width scale factor. |
|
159 |
|
160 @publishedAll |
|
161 @released |
|
162 @return The width scale factor, in percent |
|
163 */ |
|
164 { |
|
165 return CPicture::ScaleFactorWidth(); |
|
166 } |
|
167 |
|
168 EXPORT_C TInt CApaDoorBase::ScaleFactorHeight() const |
|
169 /** Gets the Embedded Document height scale factor. |
|
170 |
|
171 @publishedAll |
|
172 @released |
|
173 @return The height scale factor, in percent |
|
174 */ |
|
175 { |
|
176 return CPicture::ScaleFactorHeight(); |
|
177 } |
|
178 |
|
179 EXPORT_C TBool CApaDoorBase::LineBreakPossible(TUint aClass,TBool aBeforePicture,TBool aHaveSpaces) const |
|
180 /** States whether a line break is possible, either before or after an Embedded Document. |
|
181 The default implementation returns ETrue, implying that there is a break opportunity both before and after the Embedded Document, whether or not a space is present. |
|
182 This may be overridden for special types of Embedded Documents. |
|
183 |
|
184 @publishedAll |
|
185 @released |
|
186 @param aClass The line breaking class of the adjacent character |
|
187 @param aBeforePicture ETrue, if the adjacent character is before the Embedded Document; EFalse, if the adjacent character is afterwards |
|
188 @param aHaveSpaces ETrue, if spaces occur between the adjacent character and the Embedded Document; EFalse, otherwise |
|
189 @return ETrue, if a line break is possible; EFalse, otherwise. |
|
190 */ |
|
191 { |
|
192 return CPicture::LineBreakPossible(aClass, aBeforePicture, aHaveSpaces); |
|
193 } |
|
194 |
|
195 EXPORT_C TBool CApaDoorBase::NativePixelSize(TSize& aPixelSize) |
|
196 /** Returns the native pixel size of the bitmap. |
|
197 |
|
198 Derived classes might be implemented as bitmaps, in that case it might be interesting to know this. |
|
199 @publishedAll |
|
200 @released |
|
201 @param aPixelSize The pixel size |
|
202 @return TBool ETrue, if the derived classes are implemented as bitmaps; EFalse, otherwise. |
|
203 */ |
|
204 { |
|
205 return const_cast<CApaDoorBase*>(this)->CPicture::NativePixelSize(aPixelSize); // CPicture::NativePixelSize() is logical const |
|
206 } |
|
207 |
|
208 /** Reserved for future use */ |
|
209 EXPORT_C void CApaDoorBase::CApaDoorBase_Reserved1() |
|
210 { |
|
211 } |
|
212 |
|
213 /** Reserved for future use */ |
|
214 EXPORT_C void CApaDoorBase::CApaDoorBase_Reserved2() |
|
215 { |
|
216 } |
|
217 |
|
218 |
|
219 |