LCOV - code coverage report
Current view: top level - libreoffice/drawinglayer/source/drawinglayeruno - xprimitive2drenderer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 52 0.0 %
Date: 2012-12-27 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/graphic/XPrimitive2DRenderer.hpp>
      21             : #include <com/sun/star/lang/XServiceInfo.hpp>
      22             : #include <cppuhelper/implbase2.hxx>
      23             : #include <com/sun/star/xml/sax/XParser.hpp>
      24             : #include <com/sun/star/xml/sax/InputSource.hpp>
      25             : #include <comphelper/processfactory.hxx>
      26             : #include <drawinglayer/geometry/viewinformation2d.hxx>
      27             : #include <basegfx/numeric/ftools.hxx>
      28             : #include <vcl/bitmapex.hxx>
      29             : #include <drawinglayer/tools/converters.hxx>
      30             : #include <vcl/canvastools.hxx>
      31             : #include <com/sun/star/geometry/RealRectangle2D.hpp>
      32             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      33             : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
      34             : 
      35             : //////////////////////////////////////////////////////////////////////////////
      36             : 
      37             : using namespace ::com::sun::star;
      38             : 
      39             : //////////////////////////////////////////////////////////////////////////////
      40             : 
      41             : namespace drawinglayer
      42             : {
      43             :     namespace unorenderer
      44             :     {
      45             :         class XPrimitive2DRenderer : public ::cppu::WeakAggImplHelper2< graphic::XPrimitive2DRenderer, lang::XServiceInfo >
      46             :         {
      47             :         private:
      48             :             XPrimitive2DRenderer(const XPrimitive2DRenderer&);
      49             :             XPrimitive2DRenderer& operator=(const XPrimitive2DRenderer&);
      50             : 
      51             :         protected:
      52             :         public:
      53             :             XPrimitive2DRenderer();
      54             :             virtual ~XPrimitive2DRenderer();
      55             : 
      56             :             // XPrimitive2DRenderer
      57             :             virtual uno::Reference< rendering::XBitmap > SAL_CALL rasterize(
      58             :                 const uno::Sequence< uno::Reference< graphic::XPrimitive2D > >& Primitive2DSequence,
      59             :                 const uno::Sequence< beans::PropertyValue >& aViewInformationSequence,
      60             :                 ::sal_uInt32 DPI_X,
      61             :                 ::sal_uInt32 DPI_Y,
      62             :                 const ::com::sun::star::geometry::RealRectangle2D& Range,
      63             :                 ::sal_uInt32 MaximumQuadraticPixels) throw (uno::RuntimeException);
      64             : 
      65             :             // XServiceInfo
      66             :             virtual rtl::OUString SAL_CALL getImplementationName() throw(uno::RuntimeException);
      67             :             virtual ::sal_Bool SAL_CALL supportsService(const rtl::OUString&) throw(uno::RuntimeException);
      68             :             virtual uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw(uno::RuntimeException);
      69             :         };
      70             :     } // end of namespace unorenderer
      71             : } // end of namespace drawinglayer
      72             : 
      73             : //////////////////////////////////////////////////////////////////////////////
      74             : // uno functions
      75             : 
      76             : namespace drawinglayer
      77             : {
      78             :     namespace unorenderer
      79             :     {
      80           0 :         uno::Sequence< rtl::OUString > XPrimitive2DRenderer_getSupportedServiceNames()
      81             :         {
      82           0 :             static rtl::OUString aServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.Primitive2DTools" ) );
      83           0 :             static uno::Sequence< rtl::OUString > aServiceNames( &aServiceName, 1 );
      84             : 
      85           0 :             return( aServiceNames );
      86             :         }
      87             : 
      88           0 :         rtl::OUString XPrimitive2DRenderer_getImplementationName()
      89             :         {
      90           0 :             return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "drawinglayer::unorenderer::XPrimitive2DRenderer" ) );
      91             :         }
      92             : 
      93           0 :         uno::Reference< uno::XInterface > SAL_CALL XPrimitive2DRenderer_createInstance(const uno::Reference< lang::XMultiServiceFactory >&)
      94             :         {
      95           0 :             return static_cast< ::cppu::OWeakObject* >(new XPrimitive2DRenderer);
      96             :         }
      97             :     } // end of namespace unorenderer
      98             : } // end of namespace drawinglayer
      99             : 
     100             : //////////////////////////////////////////////////////////////////////////////
     101             : 
     102             : namespace drawinglayer
     103             : {
     104             :     namespace unorenderer
     105             :     {
     106           0 :         XPrimitive2DRenderer::XPrimitive2DRenderer()
     107             :         {
     108           0 :         }
     109             : 
     110           0 :         XPrimitive2DRenderer::~XPrimitive2DRenderer()
     111             :         {
     112           0 :         }
     113             : 
     114           0 :         uno::Reference< rendering::XBitmap > XPrimitive2DRenderer::rasterize(
     115             :             const uno::Sequence< uno::Reference< graphic::XPrimitive2D > >& Primitive2DSequence,
     116             :             const uno::Sequence< beans::PropertyValue >& aViewInformationSequence,
     117             :             ::sal_uInt32 DPI_X,
     118             :             ::sal_uInt32 DPI_Y,
     119             :             const ::com::sun::star::geometry::RealRectangle2D& Range,
     120             :             ::sal_uInt32 MaximumQuadraticPixels) throw (uno::RuntimeException)
     121             :         {
     122           0 :             uno::Reference< rendering::XBitmap > XBitmap;
     123             : 
     124           0 :             if(Primitive2DSequence.hasElements())
     125             :             {
     126           0 :                 const basegfx::B2DRange aRange(Range.X1, Range.Y1, Range.X2, Range.Y2);
     127           0 :                 const double fWidth(aRange.getWidth());
     128           0 :                 const double fHeight(aRange.getHeight());
     129             : 
     130           0 :                 if(basegfx::fTools::more(fWidth, 0.0) && basegfx::fTools::more(fHeight, 0.0))
     131             :                 {
     132           0 :                     if(0 == DPI_X)
     133             :                     {
     134           0 :                         DPI_X = 75;
     135             :                     }
     136             : 
     137           0 :                     if(0 == DPI_Y)
     138             :                     {
     139           0 :                         DPI_Y = 75;
     140             :                     }
     141             : 
     142           0 :                     if(0 == MaximumQuadraticPixels)
     143             :                     {
     144           0 :                         MaximumQuadraticPixels = 500000;
     145             :                     }
     146             : 
     147           0 :                     const geometry::ViewInformation2D aViewInformation2D(aViewInformationSequence);
     148           0 :                     const double fFactor100th_mmToInch(2.54/1000.0);
     149           0 :                     const sal_uInt32 nDiscreteWidth(basegfx::fround((fWidth * fFactor100th_mmToInch) * DPI_X));
     150           0 :                     const sal_uInt32 nDiscreteHeight(basegfx::fround((fHeight * fFactor100th_mmToInch) * DPI_Y));
     151             : 
     152             :                     basegfx::B2DHomMatrix aEmbedding(
     153             :                         basegfx::tools::createTranslateB2DHomMatrix(
     154           0 :                             -aRange.getMinX(),
     155           0 :                             -aRange.getMinY()));
     156             : 
     157             :                     aEmbedding.scale(
     158             :                         nDiscreteWidth / fWidth,
     159           0 :                         nDiscreteHeight / fHeight);
     160             : 
     161             :                     const primitive2d::Primitive2DReference xEmbedRef(
     162             :                         new primitive2d::TransformPrimitive2D(
     163             :                             aEmbedding,
     164           0 :                             Primitive2DSequence));
     165           0 :                     const primitive2d::Primitive2DSequence xEmbedSeq(&xEmbedRef, 1);
     166             : 
     167             :                     BitmapEx aBitmapEx(
     168             :                         tools::convertToBitmapEx(
     169             :                             xEmbedSeq,
     170             :                             aViewInformation2D,
     171             :                             nDiscreteWidth,
     172             :                             nDiscreteHeight,
     173           0 :                             MaximumQuadraticPixels));
     174             : 
     175           0 :                     if(!aBitmapEx.IsEmpty())
     176             :                     {
     177           0 :                         const uno::Reference< rendering::XGraphicDevice > xGraphicDevice;
     178             : 
     179           0 :                         aBitmapEx.SetPrefMapMode(MapMode(MAP_100TH_MM));
     180           0 :                         aBitmapEx.SetPrefSize(Size(basegfx::fround(fWidth), basegfx::fround(fHeight)));
     181           0 :                         XBitmap = vcl::unotools::xBitmapFromBitmapEx(xGraphicDevice, aBitmapEx);
     182           0 :                     }
     183             :                 }
     184             :             }
     185             : 
     186           0 :             return XBitmap;
     187             :         }
     188             : 
     189           0 :         rtl::OUString SAL_CALL XPrimitive2DRenderer::getImplementationName() throw(uno::RuntimeException)
     190             :         {
     191           0 :             return(XPrimitive2DRenderer_getImplementationName());
     192             :         }
     193             : 
     194           0 :         sal_Bool SAL_CALL XPrimitive2DRenderer::supportsService(const rtl::OUString& rServiceName) throw(uno::RuntimeException)
     195             :         {
     196           0 :             const uno::Sequence< rtl::OUString > aServices(XPrimitive2DRenderer_getSupportedServiceNames());
     197             : 
     198           0 :             for(sal_Int32 nService(0); nService < aServices.getLength(); nService++)
     199             :             {
     200           0 :                 if(rServiceName == aServices[nService])
     201             :                 {
     202           0 :                     return sal_True;
     203             :                 }
     204             :             }
     205             : 
     206           0 :             return sal_False;
     207             :         }
     208             : 
     209           0 :         uno::Sequence< rtl::OUString > SAL_CALL XPrimitive2DRenderer::getSupportedServiceNames() throw(uno::RuntimeException)
     210             :         {
     211           0 :             return XPrimitive2DRenderer_getSupportedServiceNames();
     212             :         }
     213             : 
     214             :     } // end of namespace unorenderer
     215             : } // end of namespace drawinglayer
     216             : 
     217             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10