1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "WrappedGL3DProperties.hxx"
#include "Chart2ModelContact.hxx"
#include "FastPropertyIdRanges.hxx"
#include <unonames.hxx>
#include <WrappedProperty.hxx>
#include <DiagramHelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/chart2/XDiagram.hpp>
using namespace com::sun::star;
namespace chart { namespace wrapper {
namespace {
enum
{
PROP_GL3DCHARTTYPE_ROUNDED_EDGE = FAST_PROPERTY_ID_START_GL_3D
};
class WrappedGL3DProperty : public WrappedProperty
{
uno::Any maDefault;
std::shared_ptr<Chart2ModelContact> mpModelContact;
private:
uno::Reference<chart2::XChartType> getChartType() const
{
uno::Reference<chart2::XDiagram> xDiagram = mpModelContact->getChart2Diagram();
uno::Sequence<uno::Reference<chart2::XChartType> > aCTs =
DiagramHelper::getChartTypesFromDiagram(xDiagram);
for (sal_Int32 i = 0; i < aCTs.getLength(); ++i)
{
uno::Reference<chart2::XChartType> xThisCT = aCTs[i];
if (xThisCT->getChartType() == "com.sun.star.chart2.GL3DBarChartType")
// Found the right chart type.
return xThisCT;
}
return uno::Reference<chart2::XChartType>();
}
public:
WrappedGL3DProperty( const OUString& rInName, const OUString& rOutName, const uno::Any& rDefault, const std::shared_ptr<Chart2ModelContact>& pContact ) :
WrappedProperty(rInName, rOutName), maDefault(rDefault), mpModelContact(pContact) {}
virtual ~WrappedGL3DProperty() {}
virtual uno::Any getPropertyValue( const uno::Reference<beans::XPropertySet>& /*xInnerPS*/ ) const
throw (beans::UnknownPropertyException, lang::WrappedTargetException,
uno::RuntimeException) override
{
uno::Reference<chart2::XChartType> xCT = getChartType();
if (!xCT.is())
return uno::Any();
try
{
uno::Reference<beans::XPropertySet> xPS(xCT, uno::UNO_QUERY_THROW);
return xPS->getPropertyValue(CHART_UNONAME_ROUNDED_EDGE);
}
catch ( const uno::Exception& ) {}
return uno::Any();
};
virtual void setPropertyValue(
const uno::Any& rOutValue, const uno::Reference<beans::XPropertySet>& /*xInnerPS*/ ) const
throw (beans::UnknownPropertyException, beans::PropertyVetoException,
lang::IllegalArgumentException, lang::WrappedTargetException,
uno::RuntimeException) override
{
uno::Reference<chart2::XChartType> xCT = getChartType();
if (!xCT.is())
return;
try
{
uno::Reference<beans::XPropertySet> xPS(xCT, uno::UNO_QUERY_THROW);
return xPS->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE, rOutValue);
}
catch ( const uno::Exception& ) {}
}
virtual void setPropertyToDefault( const uno::Reference<beans::XPropertyState>& /*xInnerPropState*/ ) const
throw (beans::UnknownPropertyException, uno::RuntimeException) override
{
uno::Reference<chart2::XChartType> xCT = getChartType();
if (!xCT.is())
return;
try
{
uno::Reference<beans::XPropertySet> xPS(xCT, uno::UNO_QUERY_THROW);
return xPS->setPropertyValue(CHART_UNONAME_ROUNDED_EDGE, maDefault);
}
catch ( const uno::Exception& ) {}
}
virtual uno::Any getPropertyDefault( const uno::Reference<beans::XPropertyState>& /*xInnerPS*/ ) const
throw (beans::UnknownPropertyException, lang::WrappedTargetException,
uno::RuntimeException) override
{
return maDefault;
}
virtual beans::PropertyState getPropertyState( const uno::Reference<beans::XPropertyState>& /*xInnerPS*/ ) const
throw (beans::UnknownPropertyException, uno::RuntimeException) override
{
return beans::PropertyState_DIRECT_VALUE;
}
};
}
void WrappedGL3DProperties::addProperties( std::vector<css::beans::Property> & rOutProps )
{
rOutProps.push_back(
beans::Property(
CHART_UNONAME_ROUNDED_EDGE,
PROP_GL3DCHARTTYPE_ROUNDED_EDGE,
cppu::UnoType<bool>::get(),
beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT
)
);
}
void WrappedGL3DProperties::addWrappedProperties(
std::vector<WrappedProperty*>& rList, const std::shared_ptr<Chart2ModelContact>& pChart2ModelContact )
{
rList.push_back(
new WrappedGL3DProperty(
CHART_UNONAME_ROUNDED_EDGE, CHART_UNONAME_ROUNDED_EDGE, uno::makeAny(false), pChart2ModelContact));
}
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|