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 "SVGForeignObjectElementImpl.h"
|
|
23 |
#include "SVGElementImpl.h"
|
|
24 |
#include "SVGDocumentImpl.h"
|
|
25 |
#include "SVGSchemaData.h"
|
|
26 |
|
|
27 |
#include "GfxAffineTransform.h"
|
|
28 |
|
|
29 |
|
|
30 |
// ---------------------------------------------------------------------------
|
|
31 |
//
|
|
32 |
// ---------------------------------------------------------------------------
|
|
33 |
CSvgForeignObjectElementImpl* CSvgForeignObjectElementImpl::NewL( const TUint8 aElemID,
|
|
34 |
CSvgDocumentImpl* aDoc )
|
|
35 |
{
|
|
36 |
CSvgForeignObjectElementImpl* self = new ( ELeave )
|
|
37 |
CSvgForeignObjectElementImpl( aDoc );
|
|
38 |
CleanupStack::PushL( self );
|
|
39 |
self->ConstructL( aElemID );
|
|
40 |
CleanupStack::Pop();
|
|
41 |
|
|
42 |
return self;
|
|
43 |
}
|
|
44 |
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
CSvgForeignObjectElementImpl* CSvgForeignObjectElementImpl::NewLC( const TUint8 aElemID,
|
|
49 |
CSvgDocumentImpl* aDoc )
|
|
50 |
{
|
|
51 |
CSvgForeignObjectElementImpl* self = new ( ELeave )
|
|
52 |
CSvgForeignObjectElementImpl( aDoc );
|
|
53 |
CleanupStack::PushL( self );
|
|
54 |
self->ConstructL( aElemID );
|
|
55 |
|
|
56 |
return self;
|
|
57 |
}
|
|
58 |
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
CSvgForeignObjectElementImpl::CSvgForeignObjectElementImpl( CSvgDocumentImpl* aDoc )
|
|
63 |
{
|
|
64 |
SetOwnerDocument(aDoc);
|
|
65 |
iReqAttrFlag = KAtrSVGRec;
|
|
66 |
}
|
|
67 |
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
CSvgForeignObjectElementImpl::~CSvgForeignObjectElementImpl()
|
|
72 |
{
|
|
73 |
iReqAttrFlag = KAtrSVGRec;
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
TFloatFixPt CSvgForeignObjectElementImpl::X()
|
|
80 |
{
|
|
81 |
return iX;
|
|
82 |
}
|
|
83 |
|
|
84 |
// ---------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
TFloatFixPt CSvgForeignObjectElementImpl::Y()
|
|
88 |
{
|
|
89 |
return iY;
|
|
90 |
}
|
|
91 |
|
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
TFloatFixPt CSvgForeignObjectElementImpl::Width()
|
|
96 |
{
|
|
97 |
return iWidth;
|
|
98 |
}
|
|
99 |
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
//
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
TFloatFixPt CSvgForeignObjectElementImpl::Height()
|
|
104 |
{
|
|
105 |
return iHeight;
|
|
106 |
}
|
|
107 |
|
|
108 |
// ---------------------------------------------------------------------------
|
|
109 |
//
|
|
110 |
// ---------------------------------------------------------------------------
|
|
111 |
TInt CSvgForeignObjectElementImpl::SetAttributeFloatL( const TInt aNameId,
|
|
112 |
const TFloatFixPt aValue )
|
|
113 |
{
|
|
114 |
switch ( aNameId )
|
|
115 |
{
|
|
116 |
case KAtrX:
|
|
117 |
iX = aValue;
|
|
118 |
break;
|
|
119 |
case KAtrY:
|
|
120 |
iY = aValue;
|
|
121 |
break;
|
|
122 |
|
|
123 |
case KAtrWidth:
|
|
124 |
iWidth = aValue;
|
|
125 |
if(iReqAttrFlag == KAtrSVGRec)
|
|
126 |
{
|
|
127 |
iReqAttrFlag = KAtrHeight;
|
|
128 |
}
|
|
129 |
else
|
|
130 |
{
|
|
131 |
iReqAttrFlag = 0;
|
|
132 |
}
|
|
133 |
break;
|
|
134 |
case KAtrHeight:
|
|
135 |
iHeight = aValue;
|
|
136 |
if(iReqAttrFlag == KAtrSVGRec)
|
|
137 |
{
|
|
138 |
iReqAttrFlag = KAtrWidth;
|
|
139 |
}
|
|
140 |
else
|
|
141 |
{
|
|
142 |
iReqAttrFlag = 0;
|
|
143 |
}
|
|
144 |
break;
|
|
145 |
default:
|
|
146 |
return CSvgElementImpl::SetAttributeFloatL( aNameId, aValue );
|
|
147 |
}
|
|
148 |
return KErrNone;
|
|
149 |
}
|
|
150 |
|
|
151 |
// ---------------------------------------------------------------------------
|
|
152 |
//
|
|
153 |
// ---------------------------------------------------------------------------
|
|
154 |
TInt CSvgForeignObjectElementImpl::SetAttributeDesL( const TInt aNameId,
|
|
155 |
const TDesC& aValue )
|
|
156 |
{
|
|
157 |
switch ( aNameId )
|
|
158 |
{
|
|
159 |
case KAtrCdata:
|
|
160 |
SetCdataL( aValue );
|
|
161 |
break;
|
|
162 |
|
|
163 |
default:
|
|
164 |
return CSvgElementImpl::SetAttributeDesL( aNameId, aValue );
|
|
165 |
}
|
|
166 |
return KErrNone;
|
|
167 |
}
|
|
168 |
|
|
169 |
// ---------------------------------------------------------------------------
|
|
170 |
//
|
|
171 |
// ---------------------------------------------------------------------------
|
|
172 |
void CSvgForeignObjectElementImpl::SetCdataL( const TDesC& aCdata )
|
|
173 |
{
|
|
174 |
if ( iCdata )
|
|
175 |
{
|
|
176 |
delete iCdata;
|
|
177 |
iCdata = NULL;
|
|
178 |
}
|
|
179 |
|
|
180 |
iCdata = aCdata.AllocL();
|
|
181 |
|
|
182 |
}
|
|
183 |
|
|
184 |
// *******************************************************
|
|
185 |
// From MXmlElement
|
|
186 |
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
TInt CSvgForeignObjectElementImpl::SetAttributeL( const TDesC& aName,
|
|
191 |
const TDesC& aValue )
|
|
192 |
{
|
|
193 |
|
|
194 |
if ( this->SetLangSpaceAttributeL( aName, aValue ) )
|
|
195 |
{
|
|
196 |
return KErrNone;
|
|
197 |
}
|
|
198 |
if ( this->SetTransform( aName, aValue ) )
|
|
199 |
{
|
|
200 |
return KErrNone;
|
|
201 |
}
|
|
202 |
|
|
203 |
if ( this->SetTestAttributeL( aName, aValue ) )
|
|
204 |
{
|
|
205 |
return KErrNone;
|
|
206 |
}
|
|
207 |
|
|
208 |
if ( SetIdandXmlbaseL( aName, aValue ) )
|
|
209 |
{
|
|
210 |
return KErrNone;
|
|
211 |
}
|
|
212 |
|
|
213 |
return KErrNone;
|
|
214 |
}
|
|
215 |
|
|
216 |
// *******************************************************
|
|
217 |
// From CSvgElementImpl
|
|
218 |
|
|
219 |
// perform a deep clone of this object
|
|
220 |
// ---------------------------------------------------------------------------
|
|
221 |
//
|
|
222 |
// ---------------------------------------------------------------------------
|
|
223 |
MXmlElement* CSvgForeignObjectElementImpl::CloneL(MXmlElement*)
|
|
224 |
{
|
|
225 |
return NULL;
|
|
226 |
}
|
|
227 |
|
|
228 |
// ---------------------------------------------------------------------------
|
|
229 |
//
|
|
230 |
// ---------------------------------------------------------------------------
|
|
231 |
TBool CSvgForeignObjectElementImpl::DrawL( CGfx2dGc* /* aGc */,
|
|
232 |
CSvgElementImpl* /* aElement */ )
|
|
233 |
{
|
|
234 |
return EFalse;
|
|
235 |
}
|
|
236 |
|
|
237 |
|
|
238 |
// *******************************************************
|
|
239 |
// Private
|
|
240 |
|
|
241 |
// ---------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
// ---------------------------------------------------------------------------
|
|
244 |
void CSvgForeignObjectElementImpl::ConstructL( const TUint8 aElemID )
|
|
245 |
{
|
|
246 |
CSvgElementImpl::InitializeL( aElemID );
|
|
247 |
}
|
|
248 |
|
|
249 |
/*** FROM MSvgMouseListener ***/
|
|
250 |
// ---------------------------------------------------------------------------
|
|
251 |
// mouse entered
|
|
252 |
// ---------------------------------------------------------------------------
|
|
253 |
TBool CSvgForeignObjectElementImpl::MouseEntered( RPointerArray<CSvgElementImpl>& /*aElements*/,
|
|
254 |
TInt /*aX*/, TInt /*aY*/ )
|
|
255 |
{
|
|
256 |
/*CSvgEngineImpl* aEngine = ( ( CSvgDocumentImpl* ) OwnerDocument() )->Engine();
|
|
257 |
|
|
258 |
for (TInt i = 0; i < aElements.Count(); i++ )
|
|
259 |
{
|
|
260 |
if ( aElements[i] == this )
|
|
261 |
{
|
|
262 |
aEngine->NotifyHyperlinkEntered(this);
|
|
263 |
return ETrue;
|
|
264 |
}
|
|
265 |
}*/
|
|
266 |
|
|
267 |
return EFalse;
|
|
268 |
}
|
|
269 |
|
|
270 |
// ---------------------------------------------------------------------------
|
|
271 |
// Notified when the mouse pointer exits a visible svg element.
|
|
272 |
// ---------------------------------------------------------------------------
|
|
273 |
TBool CSvgForeignObjectElementImpl::MouseExited( RPointerArray<CSvgElementImpl>& /*aElements*/,
|
|
274 |
TInt /*aX*/, TInt /*aY*/ )
|
|
275 |
{
|
|
276 |
/*CSvgEngineImpl* aEngine = ( ( CSvgDocumentImpl* ) OwnerDocument() )->Engine();
|
|
277 |
|
|
278 |
for (TInt i = 0; i < aElements.Count(); i++ )
|
|
279 |
{
|
|
280 |
if ( aElements[i] == this )
|
|
281 |
{
|
|
282 |
aEngine->NotifyHyperlinkExited(this);
|
|
283 |
return ETrue;
|
|
284 |
}
|
|
285 |
}*/
|
|
286 |
|
|
287 |
return EFalse;
|
|
288 |
}
|
|
289 |
|
|
290 |
// ---------------------------------------------------------------------------
|
|
291 |
// Notified when the mouse pointer is pressed down on visible svg element.
|
|
292 |
// ---------------------------------------------------------------------------
|
|
293 |
TBool CSvgForeignObjectElementImpl::MouseMoved( RPointerArray<CSvgElementImpl>& /*aElements*/,
|
|
294 |
TInt /*aX*/, TInt /*aY*/ )
|
|
295 |
{
|
|
296 |
return EFalse;
|
|
297 |
}
|
|
298 |
|
|
299 |
// ---------------------------------------------------------------------------
|
|
300 |
// Notified when the mouse pointer is pressed down on visible svg element.
|
|
301 |
// ---------------------------------------------------------------------------
|
|
302 |
TBool CSvgForeignObjectElementImpl::MousePressed( RPointerArray<CSvgElementImpl>& /*aElements*/,
|
|
303 |
TInt /*aX*/, TInt /*aY*/ )
|
|
304 |
{
|
|
305 |
return EFalse;
|
|
306 |
}
|
|
307 |
|
|
308 |
// ---------------------------------------------------------------------------
|
|
309 |
// Notified when the mouse pointer is released on on visible svg element.
|
|
310 |
// ---------------------------------------------------------------------------
|
|
311 |
TBool CSvgForeignObjectElementImpl::MouseReleased( RPointerArray<CSvgElementImpl>& /*aElements*/,
|
|
312 |
TInt /*aX*/, TInt /*aY*/ )
|
|
313 |
{
|
|
314 |
/*CSvgEngineImpl* aEngine = ( ( CSvgDocumentImpl* ) OwnerDocument() )->Engine();
|
|
315 |
|
|
316 |
for (TInt i = 0; i < aElements.Count(); i++ )
|
|
317 |
{
|
|
318 |
if ( aElements[i] == this )
|
|
319 |
{
|
|
320 |
aEngine->NotifyHyperlinkActivated(this);
|
|
321 |
return ETrue;
|
|
322 |
}
|
|
323 |
}*/
|
|
324 |
|
|
325 |
return EFalse;
|
|
326 |
}
|
|
327 |
|
|
328 |
// ---------------------------------------------------------------------------
|
|
329 |
//
|
|
330 |
// ---------------------------------------------------------------------------
|
|
331 |
void CSvgForeignObjectElementImpl::Print( TBool aIsEncodeOn )
|
|
332 |
{
|
|
333 |
if (!aIsEncodeOn)
|
|
334 |
{
|
|
335 |
#ifdef _DEBUG
|
|
336 |
RDebug::Printf("<foreignObject x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\">", (int)X(), (int)Y(), (int)Width(), (int)Height());
|
|
337 |
RDebug::Printf("</foreignObject>");
|
|
338 |
#endif
|
|
339 |
}
|
|
340 |
}
|