LCOV - code coverage report
Current view: top level - libreoffice/svx/source/svdraw - charthelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 31 44 70.5 %
Date: 2012-12-27 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * This file is part of the LibreOffice project.
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * This file incorporates work covered by the following license notice:
       9             :  *
      10             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      11             :  *   contributor license agreements. See the NOTICE file distributed
      12             :  *   with this work for additional information regarding copyright
      13             :  *   ownership. The ASF licenses this file to you under the Apache
      14             :  *   License, Version 2.0 (the "License"); you may not use this file
      15             :  *   except in compliance with the License. You may obtain a copy of
      16             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      17             :  */
      18             : 
      19             : #include <svx/charthelper.hxx>
      20             : #include <svtools/embedhlp.hxx>
      21             : #include <tools/globname.hxx>
      22             : #include <sot/clsids.hxx>
      23             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      24             : #include <com/sun/star/util/XUpdatable.hpp>
      25             : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      26             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      27             : #include <comphelper/processfactory.hxx>
      28             : #include <com/sun/star/graphic/XPrimitiveFactory2D.hpp>
      29             : #include <drawinglayer/geometry/viewinformation2d.hxx>
      30             : 
      31             : //// header for function rtl_createUuid
      32             : //#include <rtl/uuid.h>
      33             : //#include <vcl/pdfextoutdevdata.hxx>
      34             : //
      35             : //#include <com/sun/star/lang/XUnoTunnel.hpp>
      36             : //#include <com/sun/star/lang/XMultiServiceFactory.hpp>
      37             : //#include <svtools/embedhlp.hxx>
      38             : 
      39             : //////////////////////////////////////////////////////////////////////////////
      40             : 
      41             : using namespace ::com::sun::star;
      42             : 
      43             : //////////////////////////////////////////////////////////////////////////////
      44             : 
      45         321 : bool ChartHelper::IsChart(const svt::EmbeddedObjectRef& xObjRef)
      46             : {
      47         321 :     if(!xObjRef.is())
      48             :     {
      49           0 :         return false;
      50             :     }
      51             : 
      52         321 :     const SvGlobalName aObjClsId(xObjRef->getClassID());
      53             : 
      54        2568 :     if(SvGlobalName(SO3_SCH_CLASSID_30) == aObjClsId
      55         963 :         || SvGlobalName(SO3_SCH_CLASSID_40) == aObjClsId
      56         963 :         || SvGlobalName(SO3_SCH_CLASSID_50) == aObjClsId
      57         963 :         || SvGlobalName(SO3_SCH_CLASSID_60) == aObjClsId)
      58             :     {
      59          41 :         return true;
      60             :     }
      61             : 
      62         280 :     return false;
      63             : }
      64             : 
      65          41 : drawinglayer::primitive2d::Primitive2DSequence ChartHelper::tryToGetChartContentAsPrimitive2DSequence(
      66             :     const uno::Reference< ::frame::XModel >& rXModel,
      67             :     basegfx::B2DRange& rRange)
      68             : {
      69          41 :     drawinglayer::primitive2d::Primitive2DSequence aRetval;
      70             : 
      71          41 :     if(rXModel.is())
      72             :     {
      73             :         try
      74             :         {
      75          41 :             const uno::Reference< lang::XMultiServiceFactory > xChartFact(rXModel, uno::UNO_QUERY_THROW);
      76          41 :             const uno::Reference< lang::XUnoTunnel > xChartView(xChartFact->createInstance(::rtl::OUString::createFromAscii("com.sun.star.chart2.ChartView")), uno::UNO_QUERY_THROW);
      77          41 :             const uno::Reference< util::XUpdatable > xUpdatable(xChartView, uno::UNO_QUERY_THROW);
      78             : 
      79          41 :             if(xUpdatable.is())
      80             :             {
      81          41 :                 xUpdatable->update();
      82             : 
      83          41 :                 const uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier(rXModel, uno::UNO_QUERY_THROW);
      84          41 :                 const uno::Reference< container::XIndexAccess > xShapeAccess(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW);
      85             : 
      86          41 :                 if(xShapeAccess.is() && xShapeAccess->getCount())
      87             :                 {
      88          41 :                     const sal_Int32 nShapeCount(xShapeAccess->getCount());
      89          41 :                     const uno::Reference< lang::XMultiServiceFactory > xMgr(::comphelper::getProcessServiceFactory());
      90             :                     const uno::Reference< graphic::XPrimitiveFactory2D > xPrimitiveFactory(
      91          41 :                         xMgr->createInstance(
      92          41 :                             String(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.graphic.PrimitiveFactory2D" ))),
      93          41 :                             uno::UNO_QUERY);
      94             : 
      95          41 :                     if(xPrimitiveFactory.is())
      96             :                     {
      97           0 :                         const uno::Sequence< beans::PropertyValue > aParams;
      98           0 :                         uno::Reference< drawing::XShape > xShape;
      99             : 
     100           0 :                         for(sal_Int32 a(0); a < nShapeCount; a++)
     101             :                         {
     102           0 :                             xShapeAccess->getByIndex(a) >>= xShape;
     103             : 
     104           0 :                             if(xShape.is())
     105             :                             {
     106             :                                 const drawinglayer::primitive2d::Primitive2DSequence aNew(
     107           0 :                                     xPrimitiveFactory->createPrimitivesFromXShape(
     108             :                                         xShape,
     109           0 :                                         aParams));
     110             : 
     111             :                                 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(
     112             :                                     aRetval,
     113           0 :                                     aNew);
     114             :                             }
     115           0 :                         }
     116          41 :                     }
     117          41 :                 }
     118          41 :             }
     119             :         }
     120           0 :         catch(uno::Exception&)
     121             :         {
     122             :             OSL_ENSURE(false, "Unexpected exception!");
     123             :         }
     124             : 
     125          41 :         if(aRetval.hasElements())
     126             :         {
     127           0 :             const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
     128             : 
     129           0 :             rRange = drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(aRetval, aViewInformation2D);
     130             :         }
     131             :     }
     132             : 
     133          41 :     return aRetval;
     134             : }
     135             : 
     136             : //////////////////////////////////////////////////////////////////////////////
     137             : // eof

Generated by: LCOV version 1.10