svgsvgnode.cxx (e2bf1e9d) svgsvgnode.cxx (41923119)
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

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

24
25#include <svgio/svgreader/svgsvgnode.hxx>
26#include <drawinglayer/geometry/viewinformation2d.hxx>
27#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
28#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
29#include <basegfx/polygon/b2dpolygontools.hxx>
30#include <basegfx/polygon/b2dpolygon.hxx>
31#include <basegfx/matrix/b2dhommatrixtools.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

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

24
25#include <svgio/svgreader/svgsvgnode.hxx>
26#include <drawinglayer/geometry/viewinformation2d.hxx>
27#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
28#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
29#include <basegfx/polygon/b2dpolygontools.hxx>
30#include <basegfx/polygon/b2dpolygon.hxx>
31#include <basegfx/matrix/b2dhommatrixtools.hxx>
32#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
33#include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
32
33//////////////////////////////////////////////////////////////////////////////
34
35namespace svgio
36{
37 namespace svgreader
38 {
39 SvgSvgNode::SvgSvgNode(

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

327 // initially despite I found various examples of Svg files out there
328 // which have no correct values for this clipping. It's correct
329 // due to the Svg spec.
330 bool bDoCorrectCanvasClipping(true);
331
332 if(bDoCorrectCanvasClipping)
333 {
334 // different from Svg we have the possibility with primitives to get
34
35//////////////////////////////////////////////////////////////////////////////
36
37namespace svgio
38{
39 namespace svgreader
40 {
41 SvgSvgNode::SvgSvgNode(

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

329 // initially despite I found various examples of Svg files out there
330 // which have no correct values for this clipping. It's correct
331 // due to the Svg spec.
332 bool bDoCorrectCanvasClipping(true);
333
334 if(bDoCorrectCanvasClipping)
335 {
336 // different from Svg we have the possibility with primitives to get
335 // a correct bounding box for the geometry, thhus I will allow to
336 // only clip if necessary. This will make Svg images evtl. smaller
337 // than wanted from Svg (the free space which may be around it is
338 // conform to the Svg spec), but avoids an expensive and unneccessary
339 // clip.
337 // a correct bounding box for the geometry. Get it for evtl. taking action
340 const basegfx::B2DRange aContentRange(
341 drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(
342 aSequence,
343 drawinglayer::geometry::ViewInformation2D()));
344
338 const basegfx::B2DRange aContentRange(
339 drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(
340 aSequence,
341 drawinglayer::geometry::ViewInformation2D()));
342
345 if(!aSvgCanvasRange.isInside(aContentRange))
343 if(aSvgCanvasRange.isInside(aContentRange))
346 {
344 {
345 // no clip needed, but an invisible HiddenGeometryPrimitive2D
346 // to allow getting the full Svg range using the primitive mechanisms.
347 // This is needed since e.g. an SdrObject using this as graphic will
348 // create a mapping transformation to exactly map the content to it's
349 // real life size
350 const drawinglayer::primitive2d::Primitive2DReference xLine(
351 new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
352 basegfx::tools::createPolygonFromRect(
353 aSvgCanvasRange),
354 basegfx::BColor(0.0, 0.0, 0.0)));
355 const drawinglayer::primitive2d::Primitive2DReference xHidden(
356 new drawinglayer::primitive2d::HiddenGeometryPrimitive2D(
357 drawinglayer::primitive2d::Primitive2DSequence(&xLine, 1)));
358
359 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aSequence, xHidden);
360 }
361 else if(aSvgCanvasRange.overlaps(aContentRange))
362 {
363 // Clip is necessary. This will make Svg images evtl. smaller
364 // than wanted from Svg (the free space which may be around it is
365 // conform to the Svg spec), but avoids an expensive and unneccessary
366 // clip. Keep the full Svg range here to get the correct mappings
367 // to objects using this. Optimizations can be done in the processors
347 const drawinglayer::primitive2d::Primitive2DReference xMask(
348 new drawinglayer::primitive2d::MaskPrimitive2D(
349 basegfx::B2DPolyPolygon(
350 basegfx::tools::createPolygonFromRect(
351 aSvgCanvasRange)),
352 aSequence));
353
354 aSequence = drawinglayer::primitive2d::Primitive2DSequence(&xMask, 1);
355 }
368 const drawinglayer::primitive2d::Primitive2DReference xMask(
369 new drawinglayer::primitive2d::MaskPrimitive2D(
370 basegfx::B2DPolyPolygon(
371 basegfx::tools::createPolygonFromRect(
372 aSvgCanvasRange)),
373 aSequence));
374
375 aSequence = drawinglayer::primitive2d::Primitive2DSequence(&xMask, 1);
376 }
377 else
378 {
379 // not inside, no overlap. Empty Svg
380 aSequence.realloc(0);
381 }
356 }
357
382 }
383
384 if(aSequence.hasElements())
358 {
359 // embed in transform primitive to scale to 1/100th mm
360 // where 1 mm == 3.543307 px to get from Svg coordinates to
361 // drawinglayer ones
362 const double fScaleTo100thmm(100.0 / 3.543307);
363 const basegfx::B2DHomMatrix aTransform(
364 basegfx::tools::createScaleB2DHomMatrix(
365 fScaleTo100thmm,
366 fScaleTo100thmm));
367
368 const drawinglayer::primitive2d::Primitive2DReference xTransform(
369 new drawinglayer::primitive2d::TransformPrimitive2D(
370 aTransform,
371 aSequence));
372
373 aSequence = drawinglayer::primitive2d::Primitive2DSequence(&xTransform, 1);
385 {
386 // embed in transform primitive to scale to 1/100th mm
387 // where 1 mm == 3.543307 px to get from Svg coordinates to
388 // drawinglayer ones
389 const double fScaleTo100thmm(100.0 / 3.543307);
390 const basegfx::B2DHomMatrix aTransform(
391 basegfx::tools::createScaleB2DHomMatrix(
392 fScaleTo100thmm,
393 fScaleTo100thmm));
394
395 const drawinglayer::primitive2d::Primitive2DReference xTransform(
396 new drawinglayer::primitive2d::TransformPrimitive2D(
397 aTransform,
398 aSequence));
399
400 aSequence = drawinglayer::primitive2d::Primitive2DSequence(&xTransform, 1);
374 }
375
401
376 // append
377 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aSequence);
402 // append to result
403 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aSequence);
404 }
378 }
379 }
380 }
381 }
382
383 const basegfx::B2DRange* SvgSvgNode::getCurrentViewPort() const
384 {
385 if(getViewBox())

--- 14 unchanged lines hidden ---
405 }
406 }
407 }
408 }
409
410 const basegfx::B2DRange* SvgSvgNode::getCurrentViewPort() const
411 {
412 if(getViewBox())

--- 14 unchanged lines hidden ---