svgdata.cxx (2b45cf47) svgdata.cxx (8718d260)
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

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

34#include <vcl/outdev.hxx>
35
36//////////////////////////////////////////////////////////////////////////////
37
38using namespace ::com::sun::star;
39
40//////////////////////////////////////////////////////////////////////////////
41
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

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

34#include <vcl/outdev.hxx>
35
36//////////////////////////////////////////////////////////////////////////////
37
38using namespace ::com::sun::star;
39
40//////////////////////////////////////////////////////////////////////////////
41
42void SvgData::ensureReplacement()
42BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(
43 const Primitive2DSequence& rSequence,
44 const basegfx::B2DRange& rTargetRange)
43{
45{
44 ensureSequenceAndRange();
46 BitmapEx aRetval;
45
47
46 if(maReplacement.IsEmpty() && maSequence.hasElements())
48 if(rSequence.hasElements())
47 {
48 // create replacement graphic from maSequence
49 // create XPrimitive2DRenderer
50 uno::Reference< lang::XMultiServiceFactory > xFactory(::comphelper::getProcessServiceFactory());
51 const rtl::OUString aServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.Primitive2DTools"));
52
53 try
54 {
55 const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer(xFactory->createInstance(aServiceName), uno::UNO_QUERY_THROW);
56
57 if(xPrimitive2DRenderer.is())
58 {
59 uno::Sequence< beans::PropertyValue > aViewParameters;
49 {
50 // create replacement graphic from maSequence
51 // create XPrimitive2DRenderer
52 uno::Reference< lang::XMultiServiceFactory > xFactory(::comphelper::getProcessServiceFactory());
53 const rtl::OUString aServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.Primitive2DTools"));
54
55 try
56 {
57 const uno::Reference< graphic::XPrimitive2DRenderer > xPrimitive2DRenderer(xFactory->createInstance(aServiceName), uno::UNO_QUERY_THROW);
58
59 if(xPrimitive2DRenderer.is())
60 {
61 uno::Sequence< beans::PropertyValue > aViewParameters;
60 const basegfx::B2DRange& rRange(getRange());
61 geometry::RealRectangle2D aRealRect;
62
62 geometry::RealRectangle2D aRealRect;
63
63 aRealRect.X1 = rRange.getMinX();
64 aRealRect.Y1 = rRange.getMinY();
65 aRealRect.X2 = rRange.getMaxX();
66 aRealRect.Y2 = rRange.getMaxY();
64 aRealRect.X1 = rTargetRange.getMinX();
65 aRealRect.Y1 = rTargetRange.getMinY();
66 aRealRect.X2 = rTargetRange.getMaxX();
67 aRealRect.Y2 = rTargetRange.getMaxY();
67
68 // get system DPI
69 const Size aDPI(Application::GetDefaultDevice()->LogicToPixel(Size(1, 1), MAP_INCH));
70
71 const uno::Reference< rendering::XBitmap > xBitmap(
72 xPrimitive2DRenderer->rasterize(
68
69 // get system DPI
70 const Size aDPI(Application::GetDefaultDevice()->LogicToPixel(Size(1, 1), MAP_INCH));
71
72 const uno::Reference< rendering::XBitmap > xBitmap(
73 xPrimitive2DRenderer->rasterize(
73 maSequence,
74 rSequence,
74 aViewParameters,
75 aDPI.getWidth(),
76 aDPI.getHeight(),
77 aRealRect,
78 500000));
79
80 if(xBitmap.is())
81 {
82 const uno::Reference< rendering::XIntegerReadOnlyBitmap> xIntBmp(xBitmap, uno::UNO_QUERY_THROW);
83
84 if(xIntBmp.is())
85 {
75 aViewParameters,
76 aDPI.getWidth(),
77 aDPI.getHeight(),
78 aRealRect,
79 500000));
80
81 if(xBitmap.is())
82 {
83 const uno::Reference< rendering::XIntegerReadOnlyBitmap> xIntBmp(xBitmap, uno::UNO_QUERY_THROW);
84
85 if(xIntBmp.is())
86 {
86 maReplacement = vcl::unotools::bitmapExFromXBitmap(xIntBmp);
87 aRetval = vcl::unotools::bitmapExFromXBitmap(xIntBmp);
87 }
88 }
89 }
90 }
91 catch(const uno::Exception&)
92 {
93 OSL_ENSURE(sal_False, "Got no graphic::XPrimitive2DRenderer (!)" );
94 }
95 }
88 }
89 }
90 }
91 }
92 catch(const uno::Exception&)
93 {
94 OSL_ENSURE(sal_False, "Got no graphic::XPrimitive2DRenderer (!)" );
95 }
96 }
97
98 return aRetval;
96}
97
98//////////////////////////////////////////////////////////////////////////////
99
99}
100
101//////////////////////////////////////////////////////////////////////////////
102
103void SvgData::ensureReplacement()
104{
105 ensureSequenceAndRange();
106
107 if(maReplacement.IsEmpty() && maSequence.hasElements())
108 {
109 maReplacement = convertPrimitive2DSequenceToBitmapEx(maSequence, getRange());
110 }
111}
112
113//////////////////////////////////////////////////////////////////////////////
114
100void SvgData::ensureSequenceAndRange()
101{
102 if(!maSequence.hasElements() && mnSvgDataArrayLength)
103 {
104 // import SVG to maSequence, also set maRange
105 maRange.reset();
106
107 // create stream

--- 92 unchanged lines hidden ---
115void SvgData::ensureSequenceAndRange()
116{
117 if(!maSequence.hasElements() && mnSvgDataArrayLength)
118 {
119 // import SVG to maSequence, also set maRange
120 maRange.reset();
121
122 // create stream

--- 92 unchanged lines hidden ---