svgdocumenthandler.cxx (e2bf1e9d) svgdocumenthandler.cxx (3aaca8a3)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 111 unchanged lines hidden (view full) ---

120//////////////////////////////////////////////////////////////////////////////
121
122namespace svgio
123{
124 namespace svgreader
125 {
126 SvgDocHdl::SvgDocHdl(const rtl::OUString& aAbsolutePath)
127 : maDocument(aAbsolutePath),
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 111 unchanged lines hidden (view full) ---

120//////////////////////////////////////////////////////////////////////////////
121
122namespace svgio
123{
124 namespace svgreader
125 {
126 SvgDocHdl::SvgDocHdl(const rtl::OUString& aAbsolutePath)
127 : maDocument(aAbsolutePath),
128 mpTarget(0)
128 mpTarget(0),
129 maCssContents()
129 {
130 }
131
132 SvgDocHdl::~SvgDocHdl()
133 {
134#ifdef DBG_UTIL
135 if(mpTarget)
136 {
137 OSL_ENSURE(false, "SvgDocHdl destructed with active target (!)");
138 delete mpTarget;
139 }
130 {
131 }
132
133 SvgDocHdl::~SvgDocHdl()
134 {
135#ifdef DBG_UTIL
136 if(mpTarget)
137 {
138 OSL_ENSURE(false, "SvgDocHdl destructed with active target (!)");
139 delete mpTarget;
140 }
141 OSL_ENSURE(!maCssContents.size(), "SvgDocHdl destructed with active css style stack entry (!)");
140#endif
141 }
142
143 void SvgDocHdl::startDocument( ) throw (xml::sax::SAXException, uno::RuntimeException)
144 {
145 OSL_ENSURE(!mpTarget, "Already a target at document start (!)");
142#endif
143 }
144
145 void SvgDocHdl::startDocument( ) throw (xml::sax::SAXException, uno::RuntimeException)
146 {
147 OSL_ENSURE(!mpTarget, "Already a target at document start (!)");
148 OSL_ENSURE(!maCssContents.size(), "SvgDocHdl startDocument with active css style stack entry (!)");
146 }
147
148 void SvgDocHdl::endDocument( ) throw (xml::sax::SAXException, uno::RuntimeException)
149 {
150 OSL_ENSURE(!mpTarget, "Still a target at document end (!)");
149 }
150
151 void SvgDocHdl::endDocument( ) throw (xml::sax::SAXException, uno::RuntimeException)
152 {
153 OSL_ENSURE(!mpTarget, "Still a target at document end (!)");
154 OSL_ENSURE(!maCssContents.size(), "SvgDocHdl endDocument with active css style stack entry (!)");
151 }
152
153 void SvgDocHdl::startElement( const ::rtl::OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs ) throw (xml::sax::SAXException, uno::RuntimeException)
154 {
155 if(aName.getLength())
156 {
157 const SVGToken aSVGToken(StrToSVGToken(aName));
158

--- 130 unchanged lines hidden (view full) ---

289 mpTarget = new SvgTextPathNode(maDocument, mpTarget);
290 mpTarget->parseAttributes(xAttribs);
291 break;
292 }
293
294 /// styles (as stylesheets)
295 case SVGTokenStyle:
296 {
155 }
156
157 void SvgDocHdl::startElement( const ::rtl::OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs ) throw (xml::sax::SAXException, uno::RuntimeException)
158 {
159 if(aName.getLength())
160 {
161 const SVGToken aSVGToken(StrToSVGToken(aName));
162

--- 130 unchanged lines hidden (view full) ---

293 mpTarget = new SvgTextPathNode(maDocument, mpTarget);
294 mpTarget->parseAttributes(xAttribs);
295 break;
296 }
297
298 /// styles (as stylesheets)
299 case SVGTokenStyle:
300 {
297 mpTarget = new SvgStyleNode(maDocument, mpTarget);
301 SvgStyleNode* pNew = new SvgStyleNode(maDocument, mpTarget);
302 mpTarget = pNew;
298 mpTarget->parseAttributes(xAttribs);
303 mpTarget->parseAttributes(xAttribs);
304
305 if(pNew->isTextCss())
306 {
307 maCssContents.push_back(rtl::OUString());
308 }
299 break;
300 }
301
302 /// structural elements clip-path and mask. Content gets scanned, but
303 /// will not be decomposed (see SvgNode::decomposeSvgNode and bReferenced)
304 case SVGTokenClipPathNode:
305 {
306 /// new node for ClipPath

--- 43 unchanged lines hidden (view full) ---

350 }
351
352 void SvgDocHdl::endElement( const ::rtl::OUString& aName ) throw (xml::sax::SAXException, uno::RuntimeException)
353 {
354 if(aName.getLength())
355 {
356 const SVGToken aSVGToken(StrToSVGToken(aName));
357 SvgNode* pWhitespaceCheck(SVGTokenText == aSVGToken ? mpTarget : 0);
309 break;
310 }
311
312 /// structural elements clip-path and mask. Content gets scanned, but
313 /// will not be decomposed (see SvgNode::decomposeSvgNode and bReferenced)
314 case SVGTokenClipPathNode:
315 {
316 /// new node for ClipPath

--- 43 unchanged lines hidden (view full) ---

360 }
361
362 void SvgDocHdl::endElement( const ::rtl::OUString& aName ) throw (xml::sax::SAXException, uno::RuntimeException)
363 {
364 if(aName.getLength())
365 {
366 const SVGToken aSVGToken(StrToSVGToken(aName));
367 SvgNode* pWhitespaceCheck(SVGTokenText == aSVGToken ? mpTarget : 0);
368 SvgStyleNode* pCssStyle(SVGTokenStyle == aSVGToken ? static_cast< SvgStyleNode* >(mpTarget) : 0);
358
359 switch(aSVGToken)
360 {
361 /// valid tokens for which a new one was created
362
363 /// structural elements
364 case SVGTokenDefs:
365 case SVGTokenG:

--- 56 unchanged lines hidden (view full) ---

422 break;
423 }
424 default:
425 {
426 /// invalid token, ignore
427 }
428 }
429
369
370 switch(aSVGToken)
371 {
372 /// valid tokens for which a new one was created
373
374 /// structural elements
375 case SVGTokenDefs:
376 case SVGTokenG:

--- 56 unchanged lines hidden (view full) ---

433 break;
434 }
435 default:
436 {
437 /// invalid token, ignore
438 }
439 }
440
441 if(pCssStyle && pCssStyle->isTextCss())
442 {
443 // css style parsing
444 if(maCssContents.size())
445 {
446 // need to interpret css styles and remember them as StyleSheets
447 pCssStyle->addCssStyleSheet(*(maCssContents.end() - 1));
448 maCssContents.pop_back();
449 }
450 else
451 {
452 OSL_ENSURE(false, "Closing CssStyle, but no collector string on stack (!)");
453 }
454 }
455
430 if(pWhitespaceCheck)
431 {
432 // cleanup read strings
433 whiteSpaceHandling(pWhitespaceCheck, 0);
434 }
435 }
436 }
437

--- 37 unchanged lines hidden (view full) ---

475 break;
476 }
477 case SVGTokenStyle:
478 {
479 SvgStyleNode& rSvgStyleNode = static_cast< SvgStyleNode& >(*mpTarget);
480
481 if(rSvgStyleNode.isTextCss())
482 {
456 if(pWhitespaceCheck)
457 {
458 // cleanup read strings
459 whiteSpaceHandling(pWhitespaceCheck, 0);
460 }
461 }
462 }
463

--- 37 unchanged lines hidden (view full) ---

501 break;
502 }
503 case SVGTokenStyle:
504 {
505 SvgStyleNode& rSvgStyleNode = static_cast< SvgStyleNode& >(*mpTarget);
506
507 if(rSvgStyleNode.isTextCss())
508 {
483 // need to interpret css styles and remember them as StyleSheets
484 const ::rtl::OUString aTrimmedChars(aChars.trim());
509 // collect characters for css style
510 if(maCssContents.size())
511 {
512 const ::rtl::OUString aTrimmedChars(aChars.trim());
485
513
486 if(aTrimmedChars.getLength())
514 if(aTrimmedChars.getLength())
515 {
516 std::vector< rtl::OUString >::iterator aString(maCssContents.end() - 1);
517 (*aString) += aTrimmedChars;
518 }
519 }
520 else
487 {
521 {
488 rSvgStyleNode.addCssStyleSheet(aTrimmedChars);
522 OSL_ENSURE(false, "Closing CssStyle, but no collector string on stack (!)");
489 }
490 }
491 break;
492 }
493 default:
494 {
495 // characters not used by a known node
496 break;

--- 22 unchanged lines hidden ---
523 }
524 }
525 break;
526 }
527 default:
528 {
529 // characters not used by a known node
530 break;

--- 22 unchanged lines hidden ---