46
|
1 |
/*
|
|
2 |
* Copyright (c) 2003 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: SVG Implementation source file
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#if !defined(__E32BASE_H__)
|
|
20 |
#include <e32base.h>
|
|
21 |
#endif
|
|
22 |
#include "SVGFontElementImpl.h"
|
|
23 |
#include "SVGDocumentImpl.h"
|
|
24 |
#include "SVGSchemaData.h"
|
|
25 |
|
|
26 |
#include "GfxAffineTransform.h"
|
|
27 |
|
|
28 |
#ifdef SVG_FONTS_INCLUDE
|
|
29 |
|
|
30 |
|
|
31 |
// ---------------------------------------------------------------------------
|
|
32 |
//
|
|
33 |
// ---------------------------------------------------------------------------
|
|
34 |
CSvgFontElementImpl* CSvgFontElementImpl::NewL( const TUint8 aElemID,
|
|
35 |
CSvgDocumentImpl* aDoc )
|
|
36 |
{
|
|
37 |
CSvgFontElementImpl*self = new ( ELeave ) CSvgFontElementImpl( aDoc );
|
|
38 |
CleanupStack::PushL( self );
|
|
39 |
self->ConstructL(aElemID);
|
|
40 |
CleanupStack::Pop();
|
|
41 |
|
|
42 |
return self;
|
|
43 |
}
|
|
44 |
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
CSvgFontElementImpl* CSvgFontElementImpl::NewLC( const TUint8 aElemID,
|
|
49 |
CSvgDocumentImpl* aDoc )
|
|
50 |
{
|
|
51 |
CSvgFontElementImpl*self = new ( ELeave ) CSvgFontElementImpl( aDoc );
|
|
52 |
CleanupStack::PushL( self );
|
|
53 |
self->ConstructL(aElemID);
|
|
54 |
|
|
55 |
return self;
|
|
56 |
}
|
|
57 |
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
// ---------------------------------------------------------------------------
|
|
61 |
void CSvgFontElementImpl::ConstructL( const TUint8 aElemID )
|
|
62 |
{
|
|
63 |
CSvgElementImpl::InitializeL( aElemID );
|
|
64 |
|
|
65 |
|
|
66 |
#ifdef SVG_FLOAT_BUILD
|
|
67 |
iHorzAdvX = TFloatFixPt(0);
|
|
68 |
iHorzOrgX = TFloatFixPt(0);
|
|
69 |
iHorzOrgY = TFloatFixPt(0);
|
|
70 |
#else
|
|
71 |
iHorzAdvX = TFloatFixPt( 0 ,ETrue);
|
|
72 |
iHorzOrgX = TFloatFixPt( 0 ,ETrue);
|
|
73 |
iHorzOrgY = TFloatFixPt( 0 ,ETrue);
|
|
74 |
#endif
|
|
75 |
|
|
76 |
iSvgStyleProperties = new(ELeave) RPointerArray<CCssValue>(KCSS_MAX_ATTR);
|
|
77 |
|
|
78 |
// This is required to allocate buffer up to granularity so that the
|
|
79 |
// following Insert calls cannot leave.
|
|
80 |
|
|
81 |
User::LeaveIfError( iSvgStyleProperties->Append( NULL ) );
|
|
82 |
iSvgStyleProperties->Remove( 0 );
|
|
83 |
|
|
84 |
}
|
|
85 |
|
|
86 |
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
CSvgFontElementImpl::CSvgFontElementImpl( CSvgDocumentImpl* aDoc )
|
|
91 |
{
|
|
92 |
SetOwnerDocument(aDoc);
|
|
93 |
}
|
|
94 |
|
|
95 |
// ---------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
CSvgFontElementImpl::~CSvgFontElementImpl()
|
|
99 |
{
|
|
100 |
if(iSvgStyleProperties)
|
|
101 |
{
|
|
102 |
iSvgStyleProperties->Close();
|
|
103 |
delete iSvgStyleProperties;
|
|
104 |
iSvgStyleProperties = NULL;
|
|
105 |
}
|
|
106 |
}
|
|
107 |
|
|
108 |
// *******************************************************
|
|
109 |
// From SVG DOM
|
|
110 |
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
TFloatFixPt CSvgFontElementImpl::GetHorzOrgX()
|
|
115 |
{
|
|
116 |
return iHorzOrgX;
|
|
117 |
}
|
|
118 |
|
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
//
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
TFloatFixPt CSvgFontElementImpl::GetHorzOrgY()
|
|
123 |
{
|
|
124 |
return iHorzOrgY;
|
|
125 |
}
|
|
126 |
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
TFloatFixPt CSvgFontElementImpl::GetHorzAdvX()
|
|
131 |
{
|
|
132 |
return iHorzAdvX;
|
|
133 |
}
|
|
134 |
|
|
135 |
// *******************************************************
|
|
136 |
// From MXmlElement
|
|
137 |
|
|
138 |
// ---------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
// ---------------------------------------------------------------------------
|
|
141 |
TInt CSvgFontElementImpl::SetAttributeL( const TDesC& aName,
|
|
142 |
const TDesC& aValue )
|
|
143 |
{
|
|
144 |
|
|
145 |
CSvgElementImpl::SetAttributeL(aName,aValue);
|
|
146 |
|
|
147 |
return KErrNone;
|
|
148 |
}
|
|
149 |
|
|
150 |
|
|
151 |
// From MXmlElementOpt
|
|
152 |
|
|
153 |
// ---------------------------------------------------------------------------
|
|
154 |
//
|
|
155 |
// ---------------------------------------------------------------------------
|
|
156 |
TInt CSvgFontElementImpl::SetAttributeFloatL( const TInt aNameId,
|
|
157 |
const TFloatFixPt aValue )
|
|
158 |
|
|
159 |
{
|
|
160 |
|
|
161 |
switch ( aNameId )
|
|
162 |
{
|
|
163 |
case KAtrHorizAdvX:
|
|
164 |
iHorzAdvX = aValue;
|
|
165 |
break;
|
|
166 |
case KAtrHorizOriginX:
|
|
167 |
iHorzOrgX = aValue;
|
|
168 |
break;
|
|
169 |
case KAtrHorizOriginY:
|
|
170 |
iHorzOrgY = aValue;
|
|
171 |
break;
|
|
172 |
default:
|
|
173 |
return CSvgElementImpl::SetAttributeFloatL( aNameId, aValue );
|
|
174 |
}
|
|
175 |
return KErrNone;
|
|
176 |
|
|
177 |
}
|
|
178 |
|
|
179 |
// ---------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
// ---------------------------------------------------------------------------
|
|
182 |
TInt CSvgFontElementImpl::GetAttributeFloat( const TInt aNameId,
|
|
183 |
TFloatFixPt& aValue )
|
|
184 |
{
|
|
185 |
switch ( aNameId )
|
|
186 |
{
|
|
187 |
case KAtrHorizOriginX:
|
|
188 |
aValue = GetHorzOrgX();
|
|
189 |
break;
|
|
190 |
case KAtrHorizAdvX:
|
|
191 |
aValue = GetHorzAdvX();
|
|
192 |
break;
|
|
193 |
default:
|
|
194 |
return CSvgElementImpl::GetAttributeFloat( aNameId, aValue );
|
|
195 |
}
|
|
196 |
|
|
197 |
return KErrNone;
|
|
198 |
}
|
|
199 |
|
|
200 |
// *******************************************************
|
|
201 |
// From CSvgElementImpl
|
|
202 |
|
|
203 |
// perform a deep clone of this object
|
|
204 |
// ---------------------------------------------------------------------------
|
|
205 |
//
|
|
206 |
// ---------------------------------------------------------------------------
|
|
207 |
MXmlElement* CSvgFontElementImpl::CloneL(MXmlElement*)
|
|
208 |
{
|
|
209 |
return NULL;
|
|
210 |
}
|
|
211 |
|
|
212 |
// ---------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
// ---------------------------------------------------------------------------
|
|
215 |
TBool CSvgFontElementImpl::DrawL( CGfx2dGc* /* aGc */,
|
|
216 |
CSvgElementImpl* /* aElement */ )
|
|
217 |
{
|
|
218 |
return EFalse;
|
|
219 |
}
|
|
220 |
|
|
221 |
void CSvgFontElementImpl::Print( TBool aIsEncodeOn )
|
|
222 |
{
|
|
223 |
if (!aIsEncodeOn)
|
|
224 |
{
|
|
225 |
#ifdef _DEBUG
|
|
226 |
RDebug::Printf("<font horiz-origin-x=\"%d\" horiz-origin-y=\"%d\" horiz-adv-x=\"%d\">", (int)iHorzOrgX, (int)iHorzOrgY, (int)iHorzAdvX);
|
|
227 |
#endif
|
|
228 |
|
|
229 |
/*vert-origin-x
|
|
230 |
vert-origin-y
|
|
231 |
vert-adv-y*/
|
|
232 |
}
|
|
233 |
}
|
|
234 |
|
|
235 |
#endif //ifdef SVG_FONTS_INCLUDE
|