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 |
|
|
23 |
#include "SVGMpathElementImpl.h"
|
|
24 |
#include "GfxGeneralPath.h"
|
|
25 |
#include "SVGDocumentImpl.h"
|
|
26 |
#include "SVGSchemaData.h"
|
|
27 |
|
|
28 |
_LIT( XLINKHREF, "xlink:href" );
|
|
29 |
|
|
30 |
// ---------------------------------------------------------------------------
|
|
31 |
// Two phase construction
|
|
32 |
// ---------------------------------------------------------------------------
|
|
33 |
|
|
34 |
|
|
35 |
CSvgMpathElementImpl* CSvgMpathElementImpl::NewL( const TUint8 aElemID,
|
|
36 |
CSvgDocumentImpl* aDoc )
|
|
37 |
{
|
|
38 |
CSvgMpathElementImpl* self = new ( ELeave )
|
|
39 |
CSvgMpathElementImpl( aDoc );
|
|
40 |
CleanupStack::PushL( self );
|
|
41 |
self->ConstructL( aElemID );
|
|
42 |
CleanupStack::Pop();
|
|
43 |
|
|
44 |
return self;
|
|
45 |
}
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
CSvgMpathElementImpl* CSvgMpathElementImpl::NewLC( const TUint8 aElemID,
|
|
51 |
CSvgDocumentImpl* aDoc )
|
|
52 |
{
|
|
53 |
CSvgMpathElementImpl* self = new ( ELeave )
|
|
54 |
CSvgMpathElementImpl( aDoc );
|
|
55 |
CleanupStack::PushL( self );
|
|
56 |
self->ConstructL( aElemID );
|
|
57 |
|
|
58 |
return self;
|
|
59 |
}
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
//
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
CSvgMpathElementImpl::~CSvgMpathElementImpl()
|
|
67 |
{
|
|
68 |
if ( iSvgUriReferenceImpl )
|
|
69 |
{
|
|
70 |
delete iSvgUriReferenceImpl;
|
|
71 |
iSvgUriReferenceImpl = NULL;
|
|
72 |
}
|
|
73 |
if ( iParsedHref )
|
|
74 |
{
|
|
75 |
delete iParsedHref;
|
|
76 |
iParsedHref = NULL;
|
|
77 |
}
|
|
78 |
|
|
79 |
}
|
|
80 |
|
|
81 |
// *******************************************************
|
|
82 |
// From MXmlElement
|
|
83 |
|
|
84 |
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
TInt CSvgMpathElementImpl::SetAttributeL( const TDesC& aName,
|
|
89 |
const TDesC& aValue )
|
|
90 |
{
|
|
91 |
if ( this->SetXlinkAttributeL( aName, aValue ) )
|
|
92 |
{
|
|
93 |
// Get the path from the xlink
|
|
94 |
TBuf<10> lTmpXlink( XLINKHREF );
|
|
95 |
if ( aName == lTmpXlink )
|
|
96 |
{
|
|
97 |
if( iReqAttrFlag == KAtrXlinkhref)
|
|
98 |
{
|
|
99 |
iReqAttrFlag =0;
|
|
100 |
}
|
|
101 |
CSvgElementImpl*targetEl = NULL;
|
|
102 |
TInt pos = KErrNotFound;
|
|
103 |
// If the first char is '#' then remove it
|
|
104 |
// This is possible if coming from cXML parser and not CVG Decoder
|
|
105 |
|
|
106 |
pos = aValue.Locate( '#' );
|
|
107 |
if ( pos != KErrNotFound && pos == 0 )
|
|
108 |
{
|
|
109 |
iParsedHref = HBufC::NewL( aValue.Length() );
|
|
110 |
TPtr tPtr = iParsedHref->Des();
|
|
111 |
tPtr.Copy( aValue );
|
|
112 |
tPtr.Delete( pos, 1 );
|
|
113 |
targetEl = ( CSvgElementImpl * ) ((CSvgDocumentImpl*)iOwnerDocument)->GetElementById( tPtr );
|
|
114 |
}
|
|
115 |
else
|
|
116 |
{
|
|
117 |
return pos;
|
|
118 |
}
|
|
119 |
|
|
120 |
if (targetEl)
|
|
121 |
{
|
|
122 |
targetEl->GetAttributePath( KAtrData, iShape );
|
|
123 |
}
|
|
124 |
else
|
|
125 |
{
|
|
126 |
iNeedTarget = ETrue;
|
|
127 |
}
|
|
128 |
|
|
129 |
if ( iShape )
|
|
130 |
{
|
|
131 |
CSvgElementImpl*parentEl = ( CSvgElementImpl* )
|
|
132 |
ParentNode();
|
|
133 |
if ( parentEl )
|
|
134 |
{
|
|
135 |
parentEl->SetAttributePathL( KAtrData, iShape );
|
|
136 |
}
|
|
137 |
}
|
|
138 |
}
|
|
139 |
|
|
140 |
return KErrNone;
|
|
141 |
}
|
|
142 |
|
|
143 |
|
|
144 |
CSvgElementImpl::SetAttributeL(aName,aValue);
|
|
145 |
|
|
146 |
return KErrNone;
|
|
147 |
}
|
|
148 |
|
|
149 |
// From MXmlElementOpt
|
|
150 |
|
|
151 |
// ---------------------------------------------------------------------------
|
|
152 |
//
|
|
153 |
// ---------------------------------------------------------------------------
|
|
154 |
TInt CSvgMpathElementImpl::GetAttributePath( const TInt aNameId,
|
|
155 |
CGfxGeneralPath*& aValue )
|
|
156 |
{
|
|
157 |
if ( aNameId == KAtrData )
|
|
158 |
{
|
|
159 |
aValue = iShape;
|
|
160 |
}
|
|
161 |
else
|
|
162 |
{
|
|
163 |
aValue = NULL;
|
|
164 |
return KErrNoAttribute;
|
|
165 |
}
|
|
166 |
|
|
167 |
return KErrNone;
|
|
168 |
}
|
|
169 |
|
|
170 |
// ---------------------------------------------------------------------------
|
|
171 |
//
|
|
172 |
// ---------------------------------------------------------------------------
|
|
173 |
TInt CSvgMpathElementImpl::SetAttributePathL( const TInt aNameId,
|
|
174 |
CGfxGeneralPath* /* aValue */ )
|
|
175 |
{
|
|
176 |
if ( aNameId == KAtrData )
|
|
177 |
{
|
|
178 |
}
|
|
179 |
else
|
|
180 |
{
|
|
181 |
return KErrNoAttribute;
|
|
182 |
}
|
|
183 |
|
|
184 |
return KErrNone;
|
|
185 |
}
|
|
186 |
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
TBool CSvgMpathElementImpl::DrawL( CGfx2dGc* /*aGc*/, CSvgElementImpl* /*aElement*/ )
|
|
191 |
{
|
|
192 |
|
|
193 |
return EFalse;
|
|
194 |
|
|
195 |
/*
|
|
196 |
if (iNeedTarget)
|
|
197 |
{
|
|
198 |
CSvgElementImpl* targetEl = NULL;
|
|
199 |
|
|
200 |
iNeedTarget = EFalse;
|
|
201 |
|
|
202 |
if ( iParsedHref && iParsedHref->Length() > 0)
|
|
203 |
{
|
|
204 |
TPtr tPtr = iParsedHref->Des();
|
|
205 |
targetEl = ( CSvgElementImpl * ) ((CSvgDocumentImpl*)iOwnerDocument)->GetElementById( tPtr );
|
|
206 |
|
|
207 |
if (targetEl)
|
|
208 |
{
|
|
209 |
targetEl->GetAttributePath( KAtrData, iShape );
|
|
210 |
}
|
|
211 |
else
|
|
212 |
{
|
|
213 |
iNeedTarget = ETrue;
|
|
214 |
}
|
|
215 |
}
|
|
216 |
}
|
|
217 |
|
|
218 |
this->DrawShapeL( aGc, *iShape, aElement );
|
|
219 |
return EFalse;
|
|
220 |
*/
|
|
221 |
}
|
|
222 |
|
|
223 |
// ---------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
// ---------------------------------------------------------------------------
|
|
226 |
|
|
227 |
void CSvgMpathElementImpl::ConstructL( const TUint8 aElemID )
|
|
228 |
{
|
|
229 |
CSvgElementImpl::InitializeL( aElemID );
|
|
230 |
iReqAttrFlag = KAtrXlinkhref;
|
|
231 |
|
|
232 |
iSvgUriReferenceImpl = CSvgUriReferenceImpl::NewL();
|
|
233 |
iParsedHref = NULL;
|
|
234 |
iNeedTarget = EFalse;
|
|
235 |
}
|
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
// ---------------------------------------------------------------------------
|
|
240 |
//
|
|
241 |
// ---------------------------------------------------------------------------
|
|
242 |
|
|
243 |
CSvgMpathElementImpl::CSvgMpathElementImpl( CSvgDocumentImpl* aDoc )
|
|
244 |
{
|
|
245 |
SetOwnerDocument(aDoc);
|
|
246 |
}
|
|
247 |
|
|
248 |
|
|
249 |
// ---------------------------------------------------------------------------
|
|
250 |
// perform a deep clone of this object
|
|
251 |
// ---------------------------------------------------------------------------
|
|
252 |
MXmlElement* CSvgMpathElementImpl::CloneL(MXmlElement* aParentElement)
|
|
253 |
{
|
|
254 |
// create new polyline
|
|
255 |
CSvgMpathElementImpl* newElement = CSvgMpathElementImpl::NewL( this->ElemID(), ((CSvgDocumentImpl*)iOwnerDocument) );
|
|
256 |
CleanupStack::PushL(newElement);
|
|
257 |
newElement->iParentNode = aParentElement;
|
|
258 |
// copy everything over
|
|
259 |
this->CopyL(newElement);
|
|
260 |
CleanupStack::Pop();
|
|
261 |
return newElement;
|
|
262 |
}
|
|
263 |
|
|
264 |
|
|
265 |
// ---------------------------------------------------------------------------
|
|
266 |
// perform a deep copy of this object
|
|
267 |
// ---------------------------------------------------------------------------
|
|
268 |
void CSvgMpathElementImpl::CopyL( CSvgMpathElementImpl* aDestElement )
|
|
269 |
{
|
|
270 |
if(aDestElement)
|
|
271 |
{
|
|
272 |
// copy stuff from superclass
|
|
273 |
this->CSvgElementImpl::CopyL(aDestElement);
|
|
274 |
// copy iShape
|
|
275 |
aDestElement->iShape->SetPointTypeArrayL( iShape->PointTypeArray() );
|
|
276 |
aDestElement->iShape->SetPointCoordsArrayL( iShape->PointCoordsArrayAll() );
|
|
277 |
// copy the reference to idoc (CSvgDocumentImpl)
|
|
278 |
aDestElement->iOwnerDocument = this->iOwnerDocument;
|
|
279 |
}
|
|
280 |
}
|
|
281 |
|
|
282 |
// ---------------------------------------------------------------------------
|
|
283 |
// perform a deep copy of this object
|
|
284 |
// ---------------------------------------------------------------------------
|
|
285 |
void CSvgMpathElementImpl::SetAttributePathByIdL(const TDesC& aId)
|
|
286 |
{
|
|
287 |
CSvgElementImpl*targetEl = NULL;
|
|
288 |
targetEl = ( CSvgElementImpl * ) ((CSvgDocumentImpl*)iOwnerDocument)->GetElementById( aId );
|
|
289 |
targetEl->GetAttributePath( KAtrData, iShape );
|
|
290 |
|
|
291 |
if ( iShape )
|
|
292 |
{
|
|
293 |
CSvgElementImpl*parentEl = ( CSvgElementImpl* )
|
|
294 |
ParentNode();
|
|
295 |
if ( parentEl )
|
|
296 |
{
|
|
297 |
parentEl->SetAttributePathL( KAtrData, iShape );
|
|
298 |
}
|
|
299 |
}
|
|
300 |
}
|
|
301 |
|
|
302 |
void CSvgMpathElementImpl::Print( TBool aIsEncodeOn )
|
|
303 |
{
|
|
304 |
if (!aIsEncodeOn)
|
|
305 |
{
|
|
306 |
#ifdef _DEBUG
|
|
307 |
RDebug::Printf("<mpath xlink:href=\"hmm\">"/*, Href()*/);
|
|
308 |
#endif
|
|
309 |
}
|
|
310 |
}
|