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

Generated by: LCOV version 1.10