diff options
Diffstat (limited to 'drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx')
-rw-r--r-- | drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx index 66b29591df7e..91f2ad89af3d 100644 --- a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx +++ b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx @@ -24,16 +24,16 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <cppuhelper/implbase2.hxx> #include <cppuhelper/supportsservice.hxx> -#include <comphelper/sequence.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <basegfx/numeric/ftools.hxx> -#include <vcl/bitmapex.hxx> +#include <vcl/bitmap.hxx> #include <vcl/canvastools.hxx> #include <com/sun/star/geometry/RealRectangle2D.hpp> #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> -#include <converters.hxx> +#include <drawinglayer/converters.hxx> +#include <comphelper/sequenceashashmap.hxx> using namespace ::com::sun::star; @@ -43,7 +43,7 @@ namespace drawinglayer::unorenderer namespace { class XPrimitive2DRenderer: - public cppu::WeakAggImplHelper2< + public cppu::WeakImplHelper< css::graphic::XPrimitive2DRenderer, css::lang::XServiceInfo> { public: @@ -81,6 +81,16 @@ namespace drawinglayer::unorenderer const css::geometry::RealRectangle2D& Range, ::sal_uInt32 MaximumQuadraticPixels) { + o3tl::Length eRangeUnit = o3tl::Length::mm100; + comphelper::SequenceAsHashMap aViewInformationMap(aViewInformationSequence); + auto it = aViewInformationMap.find(u"RangeUnit"_ustr); + if (it != aViewInformationMap.end()) + { + sal_Int32 nVal{}; + it->second >>= nVal; + eRangeUnit = static_cast<o3tl::Length>(nVal); + } + uno::Reference< rendering::XBitmap > XBitmap; if(aPrimitive2DSequence.hasElements()) @@ -89,7 +99,7 @@ namespace drawinglayer::unorenderer const double fWidth(aRange.getWidth()); const double fHeight(aRange.getHeight()); - if(basegfx::fTools::more(fWidth, 0.0) && basegfx::fTools::more(fHeight, 0.0)) + if(fWidth > 0.0 && fHeight > 0.0) { if(0 == DPI_X) { @@ -106,10 +116,17 @@ namespace drawinglayer::unorenderer MaximumQuadraticPixels = 500000; } - const geometry::ViewInformation2D aViewInformation2D(aViewInformationSequence); - const double fFactor100th_mmToInch(1.0 / (2.54 * 1000.0)); - const sal_uInt32 nDiscreteWidth(basegfx::fround((fWidth * fFactor100th_mmToInch) * DPI_X)); - const sal_uInt32 nDiscreteHeight(basegfx::fround((fHeight * fFactor100th_mmToInch) * DPI_Y)); + auto aViewInformation2D = geometry::createViewInformation2D(aViewInformationSequence); + + if(aViewInformation2D.getViewport().isEmpty()) + { + // we have a Viewport since we create a discrete pixel device, use it + // if none is given + aViewInformation2D.setViewport(aRange); + } + + const sal_uInt32 nDiscreteWidth(basegfx::fround(o3tl::convert(fWidth, eRangeUnit, o3tl::Length::in) * DPI_X)); + const sal_uInt32 nDiscreteHeight(basegfx::fround(o3tl::convert(fHeight, eRangeUnit, o3tl::Length::in) * DPI_Y)); basegfx::B2DHomMatrix aEmbedding( basegfx::utils::createTranslateB2DHomMatrix( @@ -123,22 +140,22 @@ namespace drawinglayer::unorenderer const primitive2d::Primitive2DReference xEmbedRef( new primitive2d::TransformPrimitive2D( aEmbedding, - comphelper::sequenceToContainer<primitive2d::Primitive2DContainer>(aPrimitive2DSequence))); - const primitive2d::Primitive2DContainer xEmbedSeq { xEmbedRef }; + aPrimitive2DSequence)); + primitive2d::Primitive2DContainer xEmbedSeq { xEmbedRef }; - BitmapEx aBitmapEx( - convertToBitmapEx( - xEmbedSeq, + Bitmap aBitmap( + convertToBitmap( + std::move(xEmbedSeq), aViewInformation2D, nDiscreteWidth, nDiscreteHeight, MaximumQuadraticPixels)); - if(!aBitmapEx.IsEmpty()) + if(!aBitmap.IsEmpty()) { - aBitmapEx.SetPrefMapMode(MapMode(MapUnit::Map100thMM)); - aBitmapEx.SetPrefSize(Size(basegfx::fround(fWidth), basegfx::fround(fHeight))); - XBitmap = vcl::unotools::xBitmapFromBitmapEx(aBitmapEx); + aBitmap.SetPrefMapMode(MapMode(MapUnit::Map100thMM)); + aBitmap.SetPrefSize(Size(basegfx::fround<tools::Long>(fWidth), basegfx::fround<tools::Long>(fHeight))); + XBitmap = vcl::unotools::xBitmapFromBitmap(aBitmap); } } } @@ -148,7 +165,7 @@ namespace drawinglayer::unorenderer OUString SAL_CALL XPrimitive2DRenderer::getImplementationName() { - return "drawinglayer::unorenderer::XPrimitive2DRenderer"; + return u"drawinglayer::unorenderer::XPrimitive2DRenderer"_ustr; } sal_Bool SAL_CALL XPrimitive2DRenderer::supportsService(const OUString& rServiceName) @@ -158,7 +175,7 @@ namespace drawinglayer::unorenderer uno::Sequence< OUString > SAL_CALL XPrimitive2DRenderer::getSupportedServiceNames() { - return { "com.sun.star.graphic.Primitive2DTools" }; + return { u"com.sun.star.graphic.Primitive2DTools"_ustr }; } } // end of namespace |