svgdocumenthandler.cxx (3aaca8a3) svgdocumenthandler.cxx (025b0597)
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

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

44#include <svgio/svgreader/svgtrefnode.hxx>
45#include <svgio/svgreader/svgtextpathnode.hxx>
46#include <svgio/svgreader/svgstylenode.hxx>
47#include <svgio/svgreader/svgimagenode.hxx>
48#include <svgio/svgreader/svgclippathnode.hxx>
49#include <svgio/svgreader/svgmasknode.hxx>
50#include <svgio/svgreader/svgmarkernode.hxx>
51#include <svgio/svgreader/svgpatternnode.hxx>
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

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

44#include <svgio/svgreader/svgtrefnode.hxx>
45#include <svgio/svgreader/svgtextpathnode.hxx>
46#include <svgio/svgreader/svgstylenode.hxx>
47#include <svgio/svgreader/svgimagenode.hxx>
48#include <svgio/svgreader/svgclippathnode.hxx>
49#include <svgio/svgreader/svgmasknode.hxx>
50#include <svgio/svgreader/svgmarkernode.hxx>
51#include <svgio/svgreader/svgpatternnode.hxx>
52#include <svgio/svgreader/svgtitledescnode.hxx>
52
53//////////////////////////////////////////////////////////////////////////////
54
55using namespace com::sun::star;
56
57//////////////////////////////////////////////////////////////////////////////
58
59namespace

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

247 case SVGTokenImage:
248 {
249 /// new node for Image
250 mpTarget = new SvgImageNode(maDocument, mpTarget);
251 mpTarget->parseAttributes(xAttribs);
252 break;
253 }
254
53
54//////////////////////////////////////////////////////////////////////////////
55
56using namespace com::sun::star;
57
58//////////////////////////////////////////////////////////////////////////////
59
60namespace

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

248 case SVGTokenImage:
249 {
250 /// new node for Image
251 mpTarget = new SvgImageNode(maDocument, mpTarget);
252 mpTarget->parseAttributes(xAttribs);
253 break;
254 }
255
256 /// title and description
257 case SVGTokenTitle:
258 case SVGTokenDesc:
259 {
260 /// new node for Title and/or Desc
261 mpTarget = new SvgTitleDescNode(aSVGToken, maDocument, mpTarget);
262 break;
263 }
264
255 /// gradients
256 case SVGTokenLinearGradient:
257 case SVGTokenRadialGradient:
258 {
259 mpTarget = new SvgGradientNode(aSVGToken, maDocument, mpTarget);
260 mpTarget->parseAttributes(xAttribs);
261 break;
262 }

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

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);
265 /// gradients
266 case SVGTokenLinearGradient:
267 case SVGTokenRadialGradient:
268 {
269 mpTarget = new SvgGradientNode(aSVGToken, maDocument, mpTarget);
270 mpTarget->parseAttributes(xAttribs);
271 break;
272 }

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

371
372 void SvgDocHdl::endElement( const ::rtl::OUString& aName ) throw (xml::sax::SAXException, uno::RuntimeException)
373 {
374 if(aName.getLength())
375 {
376 const SVGToken aSVGToken(StrToSVGToken(aName));
377 SvgNode* pWhitespaceCheck(SVGTokenText == aSVGToken ? mpTarget : 0);
378 SvgStyleNode* pCssStyle(SVGTokenStyle == aSVGToken ? static_cast< SvgStyleNode* >(mpTarget) : 0);
379 SvgTitleDescNode* pSvgTitleDescNode(SVGTokenTitle == aSVGToken || SVGTokenDesc == aSVGToken ? static_cast< SvgTitleDescNode* >(mpTarget) : 0);
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:

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

383 case SVGTokenEllipse:
384 case SVGTokenLine:
385 case SVGTokenPath:
386 case SVGTokenPolygon:
387 case SVGTokenPolyline:
388 case SVGTokenRect:
389 case SVGTokenImage:
390
380
381 switch(aSVGToken)
382 {
383 /// valid tokens for which a new one was created
384
385 /// structural elements
386 case SVGTokenDefs:
387 case SVGTokenG:

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

394 case SVGTokenEllipse:
395 case SVGTokenLine:
396 case SVGTokenPath:
397 case SVGTokenPolygon:
398 case SVGTokenPolyline:
399 case SVGTokenRect:
400 case SVGTokenImage:
401
402 /// title and description
403 case SVGTokenTitle:
404 case SVGTokenDesc:
405
391 /// gradients
392 case SVGTokenLinearGradient:
393 case SVGTokenRadialGradient:
394
395 /// gradient stops
396 case SVGTokenStop:
397
398 /// text

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

433 break;
434 }
435 default:
436 {
437 /// invalid token, ignore
438 }
439 }
440
406 /// gradients
407 case SVGTokenLinearGradient:
408 case SVGTokenRadialGradient:
409
410 /// gradient stops
411 case SVGTokenStop:
412
413 /// text

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

448 break;
449 }
450 default:
451 {
452 /// invalid token, ignore
453 }
454 }
455
456 if(pSvgTitleDescNode && mpTarget)
457 {
458 const rtl::OUString aText(pSvgTitleDescNode->getText());
459
460 if(aText.getLength())
461 {
462 if(SVGTokenTitle == aSVGToken)
463 {
464 mpTarget->parseAttribute(getStrTitle(), aSVGToken, aText);
465 }
466 else // if(SVGTokenDesc == aSVGToken)
467 {
468 mpTarget->parseAttribute(getStrDesc(), aSVGToken, aText);
469 }
470 }
471 }
472
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();

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

458 // cleanup read strings
459 whiteSpaceHandling(pWhitespaceCheck, 0);
460 }
461 }
462 }
463
464 void SvgDocHdl::characters( const ::rtl::OUString& aChars ) throw (xml::sax::SAXException, uno::RuntimeException)
465 {
473 if(pCssStyle && pCssStyle->isTextCss())
474 {
475 // css style parsing
476 if(maCssContents.size())
477 {
478 // need to interpret css styles and remember them as StyleSheets
479 pCssStyle->addCssStyleSheet(*(maCssContents.end() - 1));
480 maCssContents.pop_back();

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

490 // cleanup read strings
491 whiteSpaceHandling(pWhitespaceCheck, 0);
492 }
493 }
494 }
495
496 void SvgDocHdl::characters( const ::rtl::OUString& aChars ) throw (xml::sax::SAXException, uno::RuntimeException)
497 {
466 if(mpTarget)
467 {
468 const sal_uInt32 nLength(aChars.getLength());
498 const sal_uInt32 nLength(aChars.getLength());
469
499
470 if(nLength &&
471 (SVGTokenText == mpTarget->getType() ||
472 SVGTokenTspan == mpTarget->getType() ||
473 SVGTokenTextPath == mpTarget->getType() ||
474 SVGTokenStyle == mpTarget->getType()))
500 if(mpTarget && nLength)
501 {
502 switch(mpTarget->getType())
475 {
503 {
476 switch(mpTarget->getType())
504 case SVGTokenText:
505 case SVGTokenTspan:
506 case SVGTokenTextPath:
477 {
507 {
478 case SVGTokenText:
479 case SVGTokenTspan:
480 case SVGTokenTextPath:
508 const SvgNodeVector& rChilds = mpTarget->getChildren();
509 SvgCharacterNode* pTarget = 0;
510
511 if(rChilds.size())
481 {
512 {
482 const SvgNodeVector& rChilds = mpTarget->getChildren();
483 SvgCharacterNode* pTarget = 0;
513 pTarget = dynamic_cast< SvgCharacterNode* >(rChilds[rChilds.size() - 1]);
514 }
484
515
485 if(rChilds.size())
486 {
487 pTarget = dynamic_cast< SvgCharacterNode* >(rChilds[rChilds.size() - 1]);
488 }
489
490 if(pTarget)
491 {
492 // concatenate to current character span
493 pTarget->concatenate(aChars);
494 }
495 else
496 {
497 // add character span as simplified tspan (no arguments)
498 // as direct child of SvgTextNode/SvgTspanNode/SvgTextPathNode
499 new SvgCharacterNode(maDocument, mpTarget, aChars);
500 }
501 break;
516 if(pTarget)
517 {
518 // concatenate to current character span
519 pTarget->concatenate(aChars);
502 }
520 }
503 case SVGTokenStyle:
521 else
504 {
522 {
505 SvgStyleNode& rSvgStyleNode = static_cast< SvgStyleNode& >(*mpTarget);
523 // add character span as simplified tspan (no arguments)
524 // as direct child of SvgTextNode/SvgTspanNode/SvgTextPathNode
525 new SvgCharacterNode(maDocument, mpTarget, aChars);
526 }
527 break;
528 }
529 case SVGTokenStyle:
530 {
531 SvgStyleNode& rSvgStyleNode = static_cast< SvgStyleNode& >(*mpTarget);
506
532
507 if(rSvgStyleNode.isTextCss())
533 if(rSvgStyleNode.isTextCss())
534 {
535 // collect characters for css style
536 if(maCssContents.size())
508 {
537 {
509 // collect characters for css style
510 if(maCssContents.size())
511 {
512 const ::rtl::OUString aTrimmedChars(aChars.trim());
538 const ::rtl::OUString aTrimmedChars(aChars.trim());
513
539
514 if(aTrimmedChars.getLength())
515 {
516 std::vector< rtl::OUString >::iterator aString(maCssContents.end() - 1);
517 (*aString) += aTrimmedChars;
518 }
519 }
520 else
540 if(aTrimmedChars.getLength())
521 {
541 {
522 OSL_ENSURE(false, "Closing CssStyle, but no collector string on stack (!)");
542 std::vector< rtl::OUString >::iterator aString(maCssContents.end() - 1);
543 (*aString) += aTrimmedChars;
523 }
524 }
544 }
545 }
525 break;
546 else
547 {
548 OSL_ENSURE(false, "Closing CssStyle, but no collector string on stack (!)");
549 }
526 }
550 }
527 default:
528 {
529 // characters not used by a known node
530 break;
531 }
551 break;
532 }
552 }
553 case SVGTokenTitle:
554 case SVGTokenDesc:
555 {
556 SvgTitleDescNode& rSvgTitleDescNode = static_cast< SvgTitleDescNode& >(*mpTarget);
557
558 // add text directly to SvgTitleDescNode
559 rSvgTitleDescNode.concatenate(aChars);
560 break;
561 }
562 default:
563 {
564 // characters not used by a known node
565 break;
566 }
533 }
534 }
535 }
536
537 void SvgDocHdl::ignorableWhitespace(const ::rtl::OUString& /*aWhitespaces*/) throw (xml::sax::SAXException, uno::RuntimeException)
538 {
539 }
540

--- 12 unchanged lines hidden ---
567 }
568 }
569 }
570
571 void SvgDocHdl::ignorableWhitespace(const ::rtl::OUString& /*aWhitespaces*/) throw (xml::sax::SAXException, uno::RuntimeException)
572 {
573 }
574

--- 12 unchanged lines hidden ---