LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WrappedGL3DProperties.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 25 45 55.6 %
Date: 2015-06-13 12:38:46 Functions: 8 11 72.7 %
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         538 :     uno::Reference<chart2::XChartType> getChartType() const
      38             :     {
      39         538 :         uno::Reference<chart2::XDiagram> xDiagram = mpModelContact->getChart2Diagram();
      40             :         uno::Sequence<uno::Reference<chart2::XChartType> > aCTs =
      41        1076 :             DiagramHelper::getChartTypesFromDiagram(xDiagram);
      42             : 
      43        1122 :         for (sal_Int32 i = 0; i < aCTs.getLength(); ++i)
      44             :         {
      45         584 :             uno::Reference<chart2::XChartType> xThisCT = aCTs[i];
      46         584 :             if (xThisCT->getChartType() == "com.sun.star.chart2.GL3DBarChartType")
      47             :                 // Found the right chart type.
      48           0 :                 return xThisCT;
      49         584 :         }
      50             : 
      51        1076 :         return uno::Reference<chart2::XChartType>();
      52             :     }
      53             : 
      54             : public:
      55         307 :     WrappedGL3DProperty( const OUString& rInName, const OUString& rOutName, const uno::Any& rDefault, const boost::shared_ptr<Chart2ModelContact>& pContact ) :
      56         307 :         WrappedProperty(rInName, rOutName), maDefault(rDefault), mpModelContact(pContact) {}
      57             : 
      58         614 :     virtual ~WrappedGL3DProperty() {}
      59             : 
      60         538 :     virtual uno::Any getPropertyValue( const uno::Reference<beans::XPropertySet>& /*xInnerPS*/ ) const
      61             :         throw (beans::UnknownPropertyException, lang::WrappedTargetException,
      62             :                uno::RuntimeException) SAL_OVERRIDE
      63             :     {
      64         538 :         uno::Reference<chart2::XChartType> xCT = getChartType();
      65         538 :         if (!xCT.is())
      66         538 :             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         538 :         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         536 :     virtual beans::PropertyState getPropertyState( const uno::Reference<beans::XPropertyState>& /*xInnerPS*/ ) const
     119             :         throw (beans::UnknownPropertyException, uno::RuntimeException) SAL_OVERRIDE
     120             :     {
     121         536 :         return beans::PropertyState_DIRECT_VALUE;
     122             :     }
     123             : };
     124             : 
     125             : }
     126             : 
     127          14 : 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          14 :             cppu::UnoType<bool>::get(),
     134             :             beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT
     135             :         )
     136          28 :     );
     137          14 : }
     138             : 
     139         307 : void WrappedGL3DProperties::addWrappedProperties(
     140             :     std::vector<WrappedProperty*>& rList, const boost::shared_ptr<Chart2ModelContact>& pChart2ModelContact )
     141             : {
     142             :     rList.push_back(
     143             :         new WrappedGL3DProperty(
     144         307 :             CHART_UNONAME_ROUNDED_EDGE, CHART_UNONAME_ROUNDED_EDGE, uno::makeAny(false), pChart2ModelContact));
     145         307 : }
     146             : 
     147             : }}
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11