LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WrappedGL3DProperties.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 26 46 56.5 %
Date: 2014-11-03 Functions: 10 13 76.9 %
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             : 
      10             : #include "WrappedGL3DProperties.hxx"
      11             : #include "Chart2ModelContact.hxx"
      12             : #include "FastPropertyIdRanges.hxx"
      13             : #include <unonames.hxx>
      14             : #include <WrappedProperty.hxx>
      15             : #include <DiagramHelper.hxx>
      16             : 
      17             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      18             : #include <com/sun/star/chart2/XDiagram.hpp>
      19             : 
      20             : using namespace com::sun::star;
      21             : 
      22             : namespace chart { namespace wrapper {
      23             : 
      24             : namespace {
      25             : 
      26             : enum
      27             : {
      28             :     PROP_GL3DCHARTTYPE_ROUNDED_EDGE = FAST_PROPERTY_ID_START_GL_3D
      29             : };
      30             : 
      31             : class WrappedGL3DProperty : public WrappedProperty
      32             : {
      33             :     uno::Any maDefault;
      34             :     boost::shared_ptr<Chart2ModelContact> mpModelContact;
      35             : 
      36             : private:
      37        1088 :     uno::Reference<chart2::XChartType> getChartType() const
      38             :     {
      39        1088 :         uno::Reference<chart2::XDiagram> xDiagram = mpModelContact->getChart2Diagram();
      40             :         uno::Sequence<uno::Reference<chart2::XChartType> > aCTs =
      41        2176 :             DiagramHelper::getChartTypesFromDiagram(xDiagram);
      42             : 
      43        2256 :         for (sal_Int32 i = 0; i < aCTs.getLength(); ++i)
      44             :         {
      45        1168 :             uno::Reference<chart2::XChartType> xThisCT = aCTs[i];
      46        1168 :             if (xThisCT->getChartType() == "com.sun.star.chart2.GL3DBarChartType")
      47             :                 // Found the right chart type.
      48           0 :                 return xThisCT;
      49        1168 :         }
      50             : 
      51        2176 :         return uno::Reference<chart2::XChartType>();
      52             :     }
      53             : 
      54             : public:
      55         580 :     WrappedGL3DProperty( const OUString& rInName, const OUString& rOutName, const uno::Any& rDefault, const boost::shared_ptr<Chart2ModelContact>& pContact ) :
      56         580 :         WrappedProperty(rInName, rOutName), maDefault(rDefault), mpModelContact(pContact) {}
      57             : 
      58        1160 :     virtual ~WrappedGL3DProperty() {}
      59             : 
      60        1088 :     virtual uno::Any getPropertyValue( const uno::Reference<beans::XPropertySet>& /*xInnerPS*/ ) const
      61             :         throw (beans::UnknownPropertyException, lang::WrappedTargetException,
      62             :                uno::RuntimeException) SAL_OVERRIDE
      63             :     {
      64        1088 :         uno::Reference<chart2::XChartType> xCT = getChartType();
      65        1088 :         if (!xCT.is())
      66        1088 :             return uno::Any();
      67             : 
      68             :         try
      69             :         {
      70           0 :             uno::Reference<beans::XPropertySet> xPS(xCT, uno::UNO_QUERY_THROW);
      71           0 :             return xPS->getPropertyValue(CHART_UNONAME_ROUNDED_EDGE);
      72             :         }
      73           0 :         catch ( const uno::Exception& )  {}
      74             : 
      75        1088 :         return uno::Any();
      76             :     };
      77             : 
      78           0 :     virtual void setPropertyValue(
      79             :         const uno::Any& rOutValue, const uno::Reference<beans::XPropertySet>& /*xInnerPS*/ ) const
      80             :             throw (beans::UnknownPropertyException, beans::PropertyVetoException,
      81             :                    lang::IllegalArgumentException, lang::WrappedTargetException,
      82             :                    uno::RuntimeException) SAL_OVERRIDE
      83             :     {
      84           0 :         uno::Reference<chart2::XChartType> xCT = getChartType();
      85           0 :         if (!xCT.is())
      86           0 :             return;
      87             : 
      88             :         try
      89             :         {
      90           0 :             uno::Reference<beans::XPropertySet> xPS(xCT, uno::UNO_QUERY_THROW);
      91           0 :             return xPS->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE, rOutValue);
      92             :         }
      93           0 :         catch ( const uno::Exception& )  {}
      94             :     }
      95             : 
      96           0 :     virtual void setPropertyToDefault( const uno::Reference<beans::XPropertyState>& /*xInnerPropState*/ ) const
      97             :         throw (beans::UnknownPropertyException, uno::RuntimeException) SAL_OVERRIDE
      98             :     {
      99           0 :         uno::Reference<chart2::XChartType> xCT = getChartType();
     100           0 :         if (!xCT.is())
     101           0 :             return;
     102             : 
     103             :         try
     104             :         {
     105           0 :             uno::Reference<beans::XPropertySet> xPS(xCT, uno::UNO_QUERY_THROW);
     106           0 :             return xPS->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE, maDefault);
     107             :         }
     108           0 :         catch ( const uno::Exception& )  {}
     109             :     }
     110             : 
     111           0 :     virtual uno::Any getPropertyDefault( const uno::Reference<beans::XPropertyState>& /*xInnerPS*/ ) const
     112             :         throw (beans::UnknownPropertyException, lang::WrappedTargetException,
     113             :                uno::RuntimeException) SAL_OVERRIDE
     114             :     {
     115           0 :         return maDefault;
     116             :     }
     117             : 
     118        1072 :     virtual beans::PropertyState getPropertyState( const uno::Reference<beans::XPropertyState>& /*xInnerPS*/ ) const
     119             :         throw (beans::UnknownPropertyException, uno::RuntimeException) SAL_OVERRIDE
     120             :     {
     121        1072 :         return beans::PropertyState_DIRECT_VALUE;
     122             :     }
     123             : };
     124             : 
     125             : }
     126             : 
     127          28 : void WrappedGL3DProperties::addProperties( std::vector<css::beans::Property> & rOutProps )
     128             : {
     129             :     rOutProps.push_back(
     130             :         beans::Property(
     131             :             CHART_UNONAME_ROUNDED_EDGE,
     132             :             PROP_GL3DCHARTTYPE_ROUNDED_EDGE,
     133          28 :             ::getCppuBooleanType(),
     134             :             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT
     135             :         )
     136          56 :     );
     137          28 : }
     138             : 
     139         580 : void WrappedGL3DProperties::addWrappedProperties(
     140             :     std::vector<WrappedProperty*>& rList, const boost::shared_ptr<Chart2ModelContact>& pChart2ModelContact )
     141             : {
     142             :     rList.push_back(
     143             :         new WrappedGL3DProperty(
     144         580 :             CHART_UNONAME_ROUNDED_EDGE, CHART_UNONAME_ROUNDED_EDGE, uno::makeAny(false), pChart2ModelContact));
     145         580 : }
     146             : 
     147         102 : }}
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10