summaryrefslogtreecommitdiffstats
path: root/chart2/source/controller/chartapiwrapper
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller/chartapiwrapper')
-rw-r--r--chart2/source/controller/chartapiwrapper/AreaWrapper.cxx177
-rw-r--r--chart2/source/controller/chartapiwrapper/AreaWrapper.hxx88
-rw-r--r--chart2/source/controller/chartapiwrapper/AxisWrapper.cxx674
-rw-r--r--chart2/source/controller/chartapiwrapper/AxisWrapper.hxx130
-rw-r--r--chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx295
-rw-r--r--chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx155
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx695
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx125
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx1454
-rw-r--r--chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx885
-rw-r--r--chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx131
-rw-r--r--chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx1930
-rw-r--r--chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx224
-rw-r--r--chart2/source/controller/chartapiwrapper/GridWrapper.cxx187
-rw-r--r--chart2/source/controller/chartapiwrapper/GridWrapper.hxx88
-rw-r--r--chart2/source/controller/chartapiwrapper/LegendWrapper.cxx423
-rw-r--r--chart2/source/controller/chartapiwrapper/LegendWrapper.hxx95
-rw-r--r--chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx393
-rw-r--r--chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx112
-rw-r--r--chart2/source/controller/chartapiwrapper/ReferenceSizePropertyProvider.hxx45
-rw-r--r--chart2/source/controller/chartapiwrapper/TitleWrapper.cxx512
-rw-r--r--chart2/source/controller/chartapiwrapper/TitleWrapper.hxx117
-rw-r--r--chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx361
-rw-r--r--chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx113
-rw-r--r--chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx169
-rw-r--r--chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx77
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedAddInProperty.cxx121
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedAddInProperty.hxx94
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx123
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.hxx46
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx403
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.hxx60
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx138
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx84
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx150
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.hxx51
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx171
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx80
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx121
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx71
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx584
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx90
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx138
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.hxx46
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx101
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx62
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx51
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx52
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx173
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx291
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedSplineProperties.hxx49
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx1072
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.hxx51
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx281
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedStockProperties.hxx49
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx530
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.hxx51
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.cxx71
-rw-r--r--chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.hxx47
59 files changed, 15157 insertions, 0 deletions
diff --git a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx
new file mode 100644
index 000000000..8920b1eda
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx
@@ -0,0 +1,177 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "AreaWrapper.hxx"
+#include "Chart2ModelContact.hxx"
+#include <WrappedDirectStateProperty.hxx>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <UserDefinedProperties.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::beans::Property;
+using ::osl::MutexGuard;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+namespace
+{
+
+struct StaticAreaWrapperPropertyArray_Initializer
+{
+ Sequence< Property >* operator()()
+ {
+ static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
+ return &aPropSeq;
+ }
+
+private:
+ static Sequence< Property > lcl_GetPropertySequence()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+};
+
+struct StaticAreaWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAreaWrapperPropertyArray_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart::wrapper
+{
+
+AreaWrapper::AreaWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : m_spChart2ModelContact(spChart2ModelContact)
+ , m_aEventListenerContainer(m_aMutex)
+{
+}
+
+AreaWrapper::~AreaWrapper()
+{}
+
+// ____ XShape ____
+awt::Point SAL_CALL AreaWrapper::getPosition()
+{
+ return awt::Point(0,0);
+}
+
+void SAL_CALL AreaWrapper::setPosition( const awt::Point& /*aPosition*/ )
+{
+ OSL_FAIL( "trying to set position of chart area" );
+}
+
+awt::Size SAL_CALL AreaWrapper::getSize()
+{
+ return m_spChart2ModelContact->GetPageSize();
+}
+
+void SAL_CALL AreaWrapper::setSize( const awt::Size& /*aSize*/ )
+{
+ OSL_FAIL( "trying to set size of chart area" );
+}
+
+// ____ XShapeDescriptor (base of XShape) ____
+OUString SAL_CALL AreaWrapper::getShapeType()
+{
+ return "com.sun.star.chart.ChartArea";
+}
+
+// ____ XComponent ____
+void SAL_CALL AreaWrapper::dispose()
+{
+ Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+
+ MutexGuard aGuard( m_aMutex);
+ clearWrappedPropertySet();
+}
+
+void SAL_CALL AreaWrapper::addEventListener(
+ const Reference< lang::XEventListener >& xListener )
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL AreaWrapper::removeEventListener(
+ const Reference< lang::XEventListener >& aListener )
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+// WrappedPropertySet
+Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet()
+{
+ Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ if( xChartDoc.is() )
+ return xChartDoc->getPageBackground();
+ OSL_FAIL("AreaWrapper::getInnerPropertySet() is NULL");
+ return nullptr;
+}
+
+const Sequence< beans::Property >& AreaWrapper::getPropertySequence()
+{
+ return *StaticAreaWrapperPropertyArray::get();
+}
+
+std::vector< std::unique_ptr<WrappedProperty> > AreaWrapper::createWrappedProperties()
+{
+ std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
+
+ aWrappedProperties.emplace_back( new WrappedDirectStateProperty("LineStyle","LineStyle") );
+
+ return aWrappedProperties;
+}
+
+OUString SAL_CALL AreaWrapper::getImplementationName()
+{
+ return "com.sun.star.comp.chart.Area";
+}
+
+sal_Bool SAL_CALL AreaWrapper::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL AreaWrapper::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.xml.UserDefinedAttributesSupplier",
+ "com.sun.star.beans.PropertySet",
+ "com.sun.star.drawing.FillProperties",
+ "com.sun.star.drawing.LineProperties" };
+}
+
+} // namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx b/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx
new file mode 100644
index 000000000..a0ea50f67
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx
@@ -0,0 +1,88 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_AREAWRAPPER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_AREAWRAPPER_HXX
+
+#include <WrappedPropertySet.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <comphelper/interfacecontainer2.hxx>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <memory>
+
+namespace chart
+{
+
+namespace wrapper
+{
+
+class Chart2ModelContact;
+
+class AreaWrapper : public ::cppu::ImplInheritanceHelper<
+ WrappedPropertySet
+ , css::drawing::XShape
+ , css::lang::XComponent
+ , css::lang::XServiceInfo
+ >
+{
+public:
+ explicit AreaWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ virtual ~AreaWrapper() override;
+
+ /// XServiceInfo declarations
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ // ____ XShape ____
+ virtual css::awt::Point SAL_CALL getPosition() override;
+ virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
+ virtual css::awt::Size SAL_CALL getSize() override;
+ virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
+
+ // ____ XShapeDescriptor (base of XShape) ____
+ virtual OUString SAL_CALL getShapeType() override;
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose() override;
+ virtual void SAL_CALL addEventListener( const css::uno::Reference<
+ css::lang::XEventListener >& xListener ) override;
+ virtual void SAL_CALL removeEventListener( const css::uno::Reference<
+ css::lang::XEventListener >& aListener ) override;
+
+protected:
+ // ____ WrappedPropertySet ____
+ virtual const css::uno::Sequence< css::beans::Property >& getPropertySequence() override;
+ virtual std::vector< std::unique_ptr<WrappedProperty> > createWrappedProperties() override;
+ virtual css::uno::Reference< css::beans::XPropertySet > getInnerPropertySet() override;
+
+private:
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_AREAWRAPPER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx
new file mode 100644
index 000000000..b15f33f18
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx
@@ -0,0 +1,674 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "AxisWrapper.hxx"
+#include <AxisHelper.hxx>
+#include <TitleHelper.hxx>
+#include "Chart2ModelContact.hxx"
+#include <WrappedDirectStateProperty.hxx>
+#include "GridWrapper.hxx"
+#include "TitleWrapper.hxx"
+#include <DisposeHelper.hxx>
+#include <unonames.hxx>
+
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
+#include <com/sun/star/chart/ChartAxisPosition.hpp>
+#include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
+#include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
+#include <com/sun/star/chart2/XAxis.hpp>
+#include <com/sun/star/chart2/XDiagram.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+
+#include <CharacterProperties.hxx>
+#include <LinePropertiesHelper.hxx>
+#include <UserDefinedProperties.hxx>
+#include "WrappedCharacterHeightProperty.hxx"
+#include "WrappedTextRotationProperty.hxx"
+#include "WrappedGapwidthProperty.hxx"
+#include "WrappedScaleProperty.hxx"
+#include "WrappedNumberFormatProperty.hxx"
+#include "WrappedScaleTextProperties.hxx"
+
+#include <algorithm>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Any;
+
+namespace
+{
+
+enum
+{
+ PROP_AXIS_MAX,
+ PROP_AXIS_MIN,
+ PROP_AXIS_STEPMAIN,
+ PROP_AXIS_STEPHELP, //deprecated property use 'StepHelpCount' instead
+ PROP_AXIS_STEPHELP_COUNT,
+ PROP_AXIS_AUTO_MAX,
+ PROP_AXIS_AUTO_MIN,
+ PROP_AXIS_AUTO_STEPMAIN,
+ PROP_AXIS_AUTO_STEPHELP,
+ PROP_AXIS_TYPE,
+ PROP_AXIS_TIME_INCREMENT,
+ PROP_AXIS_EXPLICIT_TIME_INCREMENT,
+ PROP_AXIS_LOGARITHMIC,
+ PROP_AXIS_REVERSEDIRECTION,
+ PROP_AXIS_VISIBLE,
+ PROP_AXIS_CROSSOVER_POSITION,
+ PROP_AXIS_CROSSOVER_VALUE,
+ PROP_AXIS_ORIGIN,
+ PROP_AXIS_AUTO_ORIGIN,
+ PROP_AXIS_MARKS,
+ PROP_AXIS_HELPMARKS,
+ PROP_AXIS_MARK_POSITION,
+ PROP_AXIS_DISPLAY_LABELS,
+ PROP_AXIS_NUMBERFORMAT,
+ PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
+ PROP_AXIS_LABEL_POSITION,
+ PROP_AXIS_TEXT_ROTATION,
+ PROP_AXIS_ARRANGE_ORDER,
+ PROP_AXIS_TEXTBREAK,
+ PROP_AXIS_CAN_OVERLAP,
+ PROP_AXIS_STACKEDTEXT,
+ PROP_AXIS_OVERLAP,
+ PROP_AXIS_GAP_WIDTH,
+ PROP_AXIS_DISPLAY_UNITS,
+ PROP_AXIS_BUILTINUNIT,
+ PROP_AXIS_TRY_STAGGERING_FIRST,
+ PROP_AXIS_MAJOR_ORIGIN
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ //Properties for scaling:
+ rOutProperties.emplace_back( "Max",
+ PROP_AXIS_MAX,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "Min",
+ PROP_AXIS_MIN,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "StepMain",
+ PROP_AXIS_STEPMAIN,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "StepHelpCount",
+ PROP_AXIS_STEPHELP_COUNT,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ //deprecated property use 'StepHelpCount' instead
+ rOutProperties.emplace_back( "StepHelp",
+ PROP_AXIS_STEPHELP,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "AutoMax",
+ PROP_AXIS_AUTO_MAX,
+ cppu::UnoType<bool>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "AutoMin",
+ PROP_AXIS_AUTO_MIN,
+ cppu::UnoType<bool>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "AutoStepMain",
+ PROP_AXIS_AUTO_STEPMAIN,
+ cppu::UnoType<bool>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "AutoStepHelp",
+ PROP_AXIS_AUTO_STEPHELP,
+ cppu::UnoType<bool>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "AxisType",
+ PROP_AXIS_TYPE,
+ cppu::UnoType<sal_Int32>::get(), //type css::chart::ChartAxisType
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "TimeIncrement",
+ PROP_AXIS_TIME_INCREMENT,
+ cppu::UnoType<css::chart::TimeIncrement>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "ExplicitTimeIncrement",
+ PROP_AXIS_EXPLICIT_TIME_INCREMENT,
+ cppu::UnoType<css::chart::TimeIncrement>::get(),
+ beans::PropertyAttribute::READONLY |
+ beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "Logarithmic",
+ PROP_AXIS_LOGARITHMIC,
+ cppu::UnoType<bool>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "ReverseDirection",
+ PROP_AXIS_REVERSEDIRECTION,
+ cppu::UnoType<bool>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ //todo: this property is missing in the API
+ rOutProperties.emplace_back( "Visible",
+ PROP_AXIS_VISIBLE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "CrossoverPosition",
+ PROP_AXIS_CROSSOVER_POSITION,
+ cppu::UnoType<css::chart::ChartAxisPosition>::get(),
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "CrossoverValue",
+ PROP_AXIS_CROSSOVER_VALUE,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "Origin",
+ PROP_AXIS_ORIGIN,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "AutoOrigin",
+ PROP_AXIS_AUTO_ORIGIN,
+ cppu::UnoType<bool>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ //Properties for interval marks:
+ rOutProperties.emplace_back( "Marks",
+ PROP_AXIS_MARKS,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "HelpMarks",
+ PROP_AXIS_HELPMARKS,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "MarkPosition",
+ PROP_AXIS_MARK_POSITION,
+ cppu::UnoType<css::chart::ChartAxisMarkPosition>::get(),
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ //Properties for labels:
+ rOutProperties.emplace_back( "DisplayLabels",
+ PROP_AXIS_DISPLAY_LABELS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_NUMFMT,
+ PROP_AXIS_NUMBERFORMAT,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_LINK_TO_SRC_NUMFMT,
+ PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "LabelPosition",
+ PROP_AXIS_LABEL_POSITION,
+ cppu::UnoType<css::chart::ChartAxisLabelPosition>::get(),
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "TextRotation",
+ PROP_AXIS_TEXT_ROTATION,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "ArrangeOrder",
+ PROP_AXIS_ARRANGE_ORDER,
+ cppu::UnoType<css::chart::ChartAxisArrangeOrderType>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "TextBreak",
+ PROP_AXIS_TEXTBREAK,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "TextCanOverlap",
+ PROP_AXIS_CAN_OVERLAP,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "StackedText",
+ PROP_AXIS_STACKEDTEXT,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // Properties related to bar charts:
+ rOutProperties.emplace_back( "Overlap",
+ PROP_AXIS_OVERLAP,
+ cppu::UnoType<sal_Int32>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "GapWidth",
+ PROP_AXIS_GAP_WIDTH,
+ cppu::UnoType<sal_Int32>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ //Properties for display units:
+ rOutProperties.emplace_back( "DisplayUnits",
+ PROP_AXIS_DISPLAY_UNITS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ //Properties for labels:
+ rOutProperties.emplace_back( "BuiltInUnit",
+ PROP_AXIS_BUILTINUNIT,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // Compatibility option: starting from LibreOffice 5.1 the rotated
+ // layout is preferred to staggering for axis labels.
+ rOutProperties.emplace_back( "TryStaggeringFirst",
+ PROP_AXIS_TRY_STAGGERING_FIRST,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "MajorOrigin",
+ PROP_AXIS_MAJOR_ORIGIN,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+}
+
+struct StaticAxisWrapperPropertyArray_Initializer
+{
+ Sequence< Property >* operator()()
+ {
+ static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
+ return &aPropSeq;
+ }
+
+private:
+ static Sequence< Property > lcl_GetPropertySequence()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+ ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+};
+
+struct StaticAxisWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAxisWrapperPropertyArray_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart::wrapper
+{
+
+AxisWrapper::AxisWrapper(
+ tAxisType eType, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) :
+ m_spChart2ModelContact( spChart2ModelContact ),
+ m_aEventListenerContainer( m_aMutex ),
+ m_eType( eType )
+{
+}
+
+AxisWrapper::~AxisWrapper()
+{
+}
+
+// ____ chart::XAxis ____
+Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getAxisTitle()
+{
+ if( !m_xAxisTitle.is() )
+ {
+ TitleHelper::eTitleType eTitleType( TitleHelper::X_AXIS_TITLE );
+ switch( m_eType )
+ {
+ case X_AXIS:
+ eTitleType = TitleHelper::X_AXIS_TITLE;
+ break;
+ case Y_AXIS:
+ eTitleType = TitleHelper::Y_AXIS_TITLE;
+ break;
+ case Z_AXIS:
+ eTitleType = TitleHelper::Z_AXIS_TITLE;
+ break;
+ case SECOND_X_AXIS:
+ eTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE;
+ break;
+ case SECOND_Y_AXIS:
+ eTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE;
+ break;
+ default:
+ return nullptr;
+ }
+ m_xAxisTitle = new TitleWrapper( eTitleType, m_spChart2ModelContact );
+ }
+ return m_xAxisTitle;
+}
+Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMajorGrid()
+{
+ if( !m_xMajorGrid.is() )
+ {
+ GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID );
+ switch( m_eType )
+ {
+ case X_AXIS:
+ eGridType = GridWrapper::X_MAJOR_GRID;
+ break;
+ case Y_AXIS:
+ eGridType = GridWrapper::Y_MAJOR_GRID;
+ break;
+ case Z_AXIS:
+ eGridType = GridWrapper::Z_MAJOR_GRID;
+ break;
+ default:
+ return nullptr;
+ }
+ m_xMajorGrid = new GridWrapper( eGridType, m_spChart2ModelContact );
+ }
+ return m_xMajorGrid;
+}
+Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMinorGrid()
+{
+ if( !m_xMinorGrid.is() )
+ {
+ GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID );
+ switch( m_eType )
+ {
+ case X_AXIS:
+ eGridType = GridWrapper::X_MINOR_GRID;
+ break;
+ case Y_AXIS:
+ eGridType = GridWrapper::Y_MINOR_GRID;
+ break;
+ case Z_AXIS:
+ eGridType = GridWrapper::Z_MINOR_GRID;
+ break;
+ default:
+ return nullptr;
+ }
+ m_xMinorGrid = new GridWrapper( eGridType, m_spChart2ModelContact );
+ }
+ return m_xMinorGrid;
+}
+
+// ____ XShape ____
+awt::Point SAL_CALL AxisWrapper::getPosition()
+{
+ awt::Point aResult( m_spChart2ModelContact->GetAxisPosition( getAxis() ) );
+ return aResult;
+}
+
+void SAL_CALL AxisWrapper::setPosition( const awt::Point& /*aPosition*/ )
+{
+ OSL_FAIL( "trying to set position of Axis" );
+}
+
+awt::Size SAL_CALL AxisWrapper::getSize()
+{
+ awt::Size aSize( m_spChart2ModelContact->GetAxisSize( getAxis() ) );
+ return aSize;
+}
+
+void SAL_CALL AxisWrapper::setSize( const awt::Size& /*aSize*/ )
+{
+ OSL_FAIL( "trying to set size of Axis" );
+}
+
+// ____ XShapeDescriptor (base of XShape) ____
+OUString SAL_CALL AxisWrapper::getShapeType()
+{
+ return "com.sun.star.chart.ChartAxis";
+}
+
+// ____ XNumberFormatsSupplier ____
+uno::Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getNumberFormatSettings()
+{
+ Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY );
+ if( xNumSuppl.is() )
+ return xNumSuppl->getNumberFormatSettings();
+
+ return uno::Reference< beans::XPropertySet >();
+}
+
+uno::Reference< util::XNumberFormats > SAL_CALL AxisWrapper::getNumberFormats()
+{
+ Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY );
+ if( xNumSuppl.is() )
+ return xNumSuppl->getNumberFormats();
+
+ return uno::Reference< util::XNumberFormats >();
+}
+
+void AxisWrapper::getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, bool& rbMainAxis )
+{
+ switch( eType )
+ {
+ case X_AXIS:
+ rnDimensionIndex = 0; rbMainAxis = true; break;
+ case Y_AXIS:
+ rnDimensionIndex = 1; rbMainAxis = true; break;
+ case Z_AXIS:
+ rnDimensionIndex = 2; rbMainAxis = true; break;
+ case SECOND_X_AXIS:
+ rnDimensionIndex = 0; rbMainAxis = false; break;
+ case SECOND_Y_AXIS:
+ rnDimensionIndex = 1; rbMainAxis = false; break;
+ }
+}
+
+// ____ XComponent ____
+void SAL_CALL AxisWrapper::dispose()
+{
+ Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+
+ DisposeHelper::DisposeAndClear( m_xAxisTitle );
+ DisposeHelper::DisposeAndClear( m_xMajorGrid );
+ DisposeHelper::DisposeAndClear( m_xMinorGrid );
+
+ clearWrappedPropertySet();
+}
+
+void SAL_CALL AxisWrapper::addEventListener(
+ const Reference< lang::XEventListener >& xListener )
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL AxisWrapper::removeEventListener(
+ const Reference< lang::XEventListener >& aListener )
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+//ReferenceSizePropertyProvider
+void AxisWrapper::updateReferenceSize()
+{
+ Reference< beans::XPropertySet > xProp( getAxis(), uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ if( xProp->getPropertyValue("ReferencePageSize").hasValue() )
+ xProp->setPropertyValue("ReferencePageSize", uno::Any(
+ m_spChart2ModelContact->GetPageSize() ));
+ }
+}
+Any AxisWrapper::getReferenceSize()
+{
+ Any aRet;
+ Reference< beans::XPropertySet > xProp( getAxis(), uno::UNO_QUERY );
+ if( xProp.is() )
+ aRet = xProp->getPropertyValue("ReferencePageSize");
+ return aRet;
+}
+awt::Size AxisWrapper::getCurrentSizeForReference()
+{
+ return m_spChart2ModelContact->GetPageSize();
+}
+
+Reference< chart2::XAxis > AxisWrapper::getAxis()
+{
+ Reference< chart2::XAxis > xAxis;
+ try
+ {
+ sal_Int32 nDimensionIndex = 0;
+ bool bMainAxis = true;
+ AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis );
+
+ Reference< XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ xAxis = AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram );
+ if( !xAxis.is() )
+ {
+ xAxis = AxisHelper::createAxis( nDimensionIndex, bMainAxis, xDiagram, m_spChart2ModelContact->m_xContext );
+ Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY );
+ if( xProp.is() )
+ xProp->setPropertyValue("Show", uno::Any( false ) );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return xAxis;
+}
+
+// WrappedPropertySet
+Reference< beans::XPropertySet > AxisWrapper::getInnerPropertySet()
+{
+ return Reference< beans::XPropertySet >( getAxis(), uno::UNO_QUERY );
+}
+
+const Sequence< beans::Property >& AxisWrapper::getPropertySequence()
+{
+ return *StaticAxisWrapperPropertyArray::get();
+}
+
+std::vector< std::unique_ptr<WrappedProperty> > AxisWrapper::createWrappedProperties()
+{
+ std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
+
+ aWrappedProperties.emplace_back( new WrappedTextRotationProperty() );
+ aWrappedProperties.emplace_back( new WrappedProperty("Marks","MajorTickmarks") );
+ aWrappedProperties.emplace_back( new WrappedProperty("HelpMarks","MinorTickmarks") );
+ aWrappedProperties.emplace_back( new WrappedProperty("TextCanOverlap","TextOverlap") );
+ aWrappedProperties.emplace_back( new WrappedProperty("ArrangeOrder","ArrangeOrder") );
+ aWrappedProperties.emplace_back( new WrappedProperty("Visible","Show") );
+ aWrappedProperties.emplace_back( new WrappedDirectStateProperty("DisplayLabels","DisplayLabels") );
+ aWrappedProperties.emplace_back( new WrappedDirectStateProperty("TryStaggeringFirst","TryStaggeringFirst") );
+ aWrappedProperties.emplace_back( new WrappedDirectStateProperty("TextBreak","TextBreak") );
+ aWrappedProperties.emplace_back( new WrappedNumberFormatProperty(m_spChart2ModelContact) );
+ aWrappedProperties.emplace_back( new WrappedLinkNumberFormatProperty );
+ aWrappedProperties.emplace_back( new WrappedProperty("StackedText","StackCharacters") );
+ aWrappedProperties.emplace_back( new WrappedDirectStateProperty("CrossoverPosition","CrossoverPosition") );
+ aWrappedProperties.emplace_back( new WrappedDirectStateProperty("MajorOrigin","MajorOrigin") );
+ {
+ WrappedGapwidthProperty* pWrappedGapwidthProperty( new WrappedGapwidthProperty( m_spChart2ModelContact ) );
+ WrappedBarOverlapProperty* pWrappedBarOverlapProperty( new WrappedBarOverlapProperty( m_spChart2ModelContact ) );
+ sal_Int32 nDimensionIndex = 0;
+ bool bMainAxis = true;
+ sal_Int32 nAxisIndex = 0;
+ AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis );
+ if( !bMainAxis )
+ nAxisIndex = 1;
+ pWrappedGapwidthProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex );
+ pWrappedBarOverlapProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex );
+ aWrappedProperties.emplace_back( pWrappedGapwidthProperty );
+ aWrappedProperties.emplace_back( pWrappedBarOverlapProperty );
+ }
+
+ WrappedScaleProperty::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
+
+ WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this );
+ WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
+
+ return aWrappedProperties;
+}
+
+OUString SAL_CALL AxisWrapper::getImplementationName()
+{
+ return "com.sun.star.comp.chart.Axis";
+}
+
+sal_Bool SAL_CALL AxisWrapper::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL AxisWrapper::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart.ChartAxis",
+ "com.sun.star.xml.UserDefinedAttributesSupplier",
+ "com.sun.star.style.CharacterProperties"
+ };
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx
new file mode 100644
index 000000000..b6770a5a2
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx
@@ -0,0 +1,130 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_AXISWRAPPER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_AXISWRAPPER_HXX
+
+#include <WrappedPropertySet.hxx>
+#include "ReferenceSizePropertyProvider.hxx"
+#include <cppuhelper/implbase.hxx>
+#include <comphelper/interfacecontainer2.hxx>
+#include <com/sun/star/chart/XAxis.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+
+#include <memory>
+
+namespace com::sun::star::chart2 { class XAxis; }
+
+namespace chart
+{
+namespace wrapper
+{
+class Chart2ModelContact;
+
+class AxisWrapper : public ::cppu::ImplInheritanceHelper<
+ WrappedPropertySet
+ , css::chart::XAxis
+ , css::drawing::XShape
+ , css::lang::XComponent
+ , css::lang::XServiceInfo
+ , css::util::XNumberFormatsSupplier
+ >
+ , public ReferenceSizePropertyProvider
+{
+public:
+ enum tAxisType
+ {
+ X_AXIS,
+ Y_AXIS,
+ Z_AXIS,
+ SECOND_X_AXIS,
+ SECOND_Y_AXIS
+ };
+
+ AxisWrapper(tAxisType eType, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ virtual ~AxisWrapper() override;
+
+ static void getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, bool& rbMainAxis );
+
+ /// XServiceInfo declarations
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ //ReferenceSizePropertyProvider
+ virtual void updateReferenceSize() override;
+ virtual css::uno::Any getReferenceSize() override;
+ virtual css::awt::Size getCurrentSizeForReference() override;
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose() override;
+ virtual void SAL_CALL addEventListener( const css::uno::Reference<
+ css::lang::XEventListener >& xListener ) override;
+ virtual void SAL_CALL removeEventListener( const css::uno::Reference<
+ css::lang::XEventListener >& aListener ) override;
+
+ // ____ chart::XAxis ____
+ virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getAxisTitle( ) override;
+ virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getMajorGrid( ) override;
+ virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getMinorGrid( ) override;
+
+ // ____ XShape ____
+ virtual css::awt::Point SAL_CALL getPosition() override;
+ virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
+ virtual css::awt::Size SAL_CALL getSize() override;
+ virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
+
+ // ____ XShapeDescriptor (base of XShape) ____
+ virtual OUString SAL_CALL getShapeType() override;
+
+ // ____ XNumberFormatsSupplier ____
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getNumberFormatSettings() override;
+ virtual css::uno::Reference<
+ css::util::XNumberFormats > SAL_CALL getNumberFormats() override;
+
+protected:
+ // ____ WrappedPropertySet ____
+ virtual const css::uno::Sequence< css::beans::Property >& getPropertySequence() override;
+ virtual std::vector< std::unique_ptr<WrappedProperty> > createWrappedProperties() override;
+ virtual css::uno::Reference< css::beans::XPropertySet > getInnerPropertySet() override;
+
+private: //methods
+ css::uno::Reference< css::chart2::XAxis > getAxis();
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer;
+
+ tAxisType m_eType;
+
+ css::uno::Reference< css::beans::XPropertySet > m_xAxisTitle;
+ css::uno::Reference< css::beans::XPropertySet > m_xMajorGrid;
+ css::uno::Reference< css::beans::XPropertySet > m_xMinorGrid;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_AXISWRAPPER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
new file mode 100644
index 000000000..e0cd9e031
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx
@@ -0,0 +1,295 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "Chart2ModelContact.hxx"
+#include <ChartModelHelper.hxx>
+#include <LegendHelper.hxx>
+#include <CommonConverters.hxx>
+#include <servicenames.hxx>
+#include <ObjectIdentifier.hxx>
+#include <chartview/ExplicitValueProvider.hxx>
+#include <chartview/DrawModelWrapper.hxx>
+#include <AxisHelper.hxx>
+#include <DiagramHelper.hxx>
+
+#include <ChartModel.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+
+using ::com::sun::star::uno::Reference;
+
+namespace chart::wrapper
+{
+
+Chart2ModelContact::Chart2ModelContact(
+ const Reference< uno::XComponentContext > & xContext ) :
+ m_xContext( xContext ),
+ m_xChartModel( nullptr ),
+ mpModel( nullptr )
+{
+}
+
+Chart2ModelContact::~Chart2ModelContact()
+{
+ clear();
+}
+
+void Chart2ModelContact::setModel( const css::uno::Reference< css::frame::XModel >& xChartModel )
+{
+ clear();
+ m_xChartModel = xChartModel;
+ mpModel = dynamic_cast<ChartModel*>(xChartModel.get());
+ uno::Reference< lang::XMultiServiceFactory > xTableFactory( xChartModel, uno::UNO_QUERY );
+ if( !xTableFactory.is() )
+ return;
+
+ uno::Reference< container::XNameContainer > xDashTable( xTableFactory->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY );
+ uno::Reference< container::XNameContainer > xGradientTable( xTableFactory->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY );
+ uno::Reference< container::XNameContainer > xHatchTable( xTableFactory->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY );
+ uno::Reference< container::XNameContainer > xBitmapTable( xTableFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY );
+ uno::Reference< container::XNameContainer > xTransparencyGradientTable( xTableFactory->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY );
+ m_aTableMap["LineDashName"] = xDashTable;
+ m_aTableMap["FillGradientName"] = xGradientTable;
+ m_aTableMap["FillHatchName"] = xHatchTable;
+ m_aTableMap["FillBitmapName"] = xBitmapTable;
+ m_aTableMap["FillTransparenceGradientName"] = xTransparencyGradientTable;
+}
+
+void Chart2ModelContact::clear()
+{
+ m_xChartModel.clear();
+ m_xChartView.clear();
+ mpModel = nullptr;
+}
+
+Reference< frame::XModel > Chart2ModelContact::getChartModel() const
+{
+ return Reference< frame::XModel >( m_xChartModel.get(), uno::UNO_QUERY );
+}
+
+Reference< chart2::XChartDocument > Chart2ModelContact::getChart2Document() const
+{
+ return Reference< chart2::XChartDocument >( m_xChartModel.get(), uno::UNO_QUERY );
+}
+
+Reference< chart2::XDiagram > Chart2ModelContact::getChart2Diagram() const
+{
+ return ChartModelHelper::findDiagram( getChartModel() );
+}
+
+uno::Reference< lang::XUnoTunnel > const & Chart2ModelContact::getChartView() const
+{
+ if(!m_xChartView.is())
+ {
+ // get the chart view
+ Reference<frame::XModel> xModel(m_xChartModel);
+ uno::Reference< lang::XMultiServiceFactory > xFact( xModel, uno::UNO_QUERY );
+ if( xFact.is() )
+ m_xChartView.set( xFact->createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
+ }
+ return m_xChartView;
+}
+
+ExplicitValueProvider* Chart2ModelContact::getExplicitValueProvider() const
+{
+ getChartView();
+ if(!m_xChartView.is())
+ return nullptr;
+
+ //obtain the ExplicitValueProvider from the chart view
+ ExplicitValueProvider* pProvider = reinterpret_cast<ExplicitValueProvider*>(m_xChartView->getSomething(
+ ExplicitValueProvider::getUnoTunnelId() ));
+ return pProvider;
+}
+
+uno::Reference< drawing::XDrawPage > Chart2ModelContact::getDrawPage() const
+{
+ uno::Reference< drawing::XDrawPage > xResult;
+ ExplicitValueProvider* pProvider( getExplicitValueProvider() );
+ if( pProvider )
+ {
+ xResult.set( pProvider->getDrawModelWrapper()->getMainDrawPage() );
+ }
+ return xResult;
+}
+
+void Chart2ModelContact::getExplicitValuesForAxis(
+ const Reference< XAxis > & xAxis,
+ ExplicitScaleData & rOutExplicitScale,
+ ExplicitIncrementData & rOutExplicitIncrement )
+{
+ ExplicitValueProvider* pProvider( getExplicitValueProvider() );
+ if( pProvider )
+ {
+ pProvider->getExplicitValuesForAxis(
+ xAxis, rOutExplicitScale, rOutExplicitIncrement );
+ }
+}
+
+sal_Int32 Chart2ModelContact::getExplicitNumberFormatKeyForAxis(
+ const Reference< chart2::XAxis >& xAxis )
+{
+ Reference< chart2::XCoordinateSystem > xCooSys(
+ AxisHelper::getCoordinateSystemOfAxis(
+ xAxis, ChartModelHelper::findDiagram( m_xChartModel ) ) );
+
+ return ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( xAxis, xCooSys
+ , getChart2Document());
+}
+
+sal_Int32 Chart2ModelContact::getExplicitNumberFormatKeyForSeries(
+ const Reference< chart2::XDataSeries >& xSeries )
+{
+ return ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(
+ uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ));
+}
+
+awt::Size Chart2ModelContact::GetPageSize() const
+{
+ return ChartModelHelper::getPageSize(m_xChartModel);
+}
+
+awt::Rectangle Chart2ModelContact::SubstractAxisTitleSizes( const awt::Rectangle& rPositionRect )
+{
+ awt::Rectangle aRect = ExplicitValueProvider::AddSubtractAxisTitleSizes(
+ *mpModel, getChartView(), rPositionRect, true );
+ return aRect;
+}
+
+awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingTitle() const
+{
+ awt::Rectangle aRect( GetDiagramRectangleIncludingAxes() );
+
+ //add axis title sizes to the diagram size
+ aRect = ExplicitValueProvider::AddSubtractAxisTitleSizes(
+ *mpModel, getChartView(), aRect, false );
+
+ return aRect;
+}
+
+awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingAxes() const
+{
+ awt::Rectangle aRect(0,0,0,0);
+ uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) );
+
+ if( DiagramHelper::getDiagramPositioningMode( xDiagram ) == DiagramPositioningMode_INCLUDING )
+ aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel);
+ else
+ {
+ ExplicitValueProvider* pProvider( getExplicitValueProvider() );
+ if( pProvider )
+ aRect = pProvider->getRectangleOfObject("PlotAreaIncludingAxes");
+ }
+ return aRect;
+}
+
+awt::Rectangle Chart2ModelContact::GetDiagramRectangleExcludingAxes() const
+{
+ awt::Rectangle aRect(0,0,0,0);
+ uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) );
+
+ if( DiagramHelper::getDiagramPositioningMode( xDiagram ) == DiagramPositioningMode_EXCLUDING )
+ aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel);
+ else
+ {
+ ExplicitValueProvider* pProvider( getExplicitValueProvider() );
+ if( pProvider )
+ aRect = pProvider->getDiagramRectangleExcludingAxes();
+ }
+ return aRect;
+}
+
+awt::Size Chart2ModelContact::GetLegendSize() const
+{
+ awt::Size aSize;
+ ExplicitValueProvider* pProvider( getExplicitValueProvider() );
+ if( pProvider )
+ {
+ uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *mpModel ) );
+ OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, *mpModel ) );
+ aSize = ToSize( pProvider->getRectangleOfObject( aCID ) );
+ }
+ return aSize;
+}
+
+awt::Point Chart2ModelContact::GetLegendPosition() const
+{
+ awt::Point aPoint;
+ ExplicitValueProvider* pProvider( getExplicitValueProvider() );
+ if( pProvider )
+ {
+ uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *mpModel ) );
+ OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, *mpModel ) );
+ aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) );
+ }
+ return aPoint;
+}
+
+awt::Size Chart2ModelContact::GetTitleSize( const uno::Reference< css::chart2::XTitle > & xTitle ) const
+{
+ awt::Size aSize;
+ ExplicitValueProvider* pProvider( getExplicitValueProvider() );
+ if( pProvider && xTitle.is() )
+ {
+ OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_xChartModel ) );
+ aSize = ToSize( pProvider->getRectangleOfObject( aCID ) );
+ }
+ return aSize;
+}
+
+awt::Point Chart2ModelContact::GetTitlePosition( const uno::Reference< css::chart2::XTitle > & xTitle ) const
+{
+ awt::Point aPoint;
+ ExplicitValueProvider* pProvider( getExplicitValueProvider() );
+ if( pProvider && xTitle.is() )
+ {
+ OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_xChartModel ) );
+ aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) );
+ }
+ return aPoint;
+}
+
+awt::Size Chart2ModelContact::GetAxisSize( const uno::Reference< css::chart2::XAxis > & xAxis ) const
+{
+ awt::Size aSize;
+ ExplicitValueProvider* pProvider( getExplicitValueProvider() );
+ if( pProvider && xAxis.is() )
+ {
+ OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, m_xChartModel ) );
+ aSize = ToSize( pProvider->getRectangleOfObject( aCID ) );
+ }
+ return aSize;
+}
+
+awt::Point Chart2ModelContact::GetAxisPosition( const uno::Reference< css::chart2::XAxis > & xAxis ) const
+{
+ awt::Point aPoint;
+ ExplicitValueProvider* pProvider( getExplicitValueProvider() );
+ if( pProvider && xAxis.is() )
+ {
+ OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, m_xChartModel ) );
+ aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) );
+ }
+ return aPoint;
+}
+
+} // namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx
new file mode 100644
index 000000000..5f3448edc
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx
@@ -0,0 +1,155 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_CHART2MODELCONTACT_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_CHART2MODELCONTACT_HXX
+
+#include <cppuhelper/weakref.hxx>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+
+#include <map>
+
+namespace chart { struct ExplicitIncrementData; }
+namespace chart { struct ExplicitScaleData; }
+namespace com::sun::star::chart2 { class XAxis; }
+namespace com::sun::star::chart2 { class XChartDocument; }
+namespace com::sun::star::chart2 { class XDataSeries; }
+namespace com::sun::star::chart2 { class XDiagram; }
+namespace com::sun::star::chart2 { class XTitle; }
+namespace com::sun::star::container { class XNameContainer; }
+namespace com::sun::star::drawing { class XDrawPage; }
+namespace com::sun::star::frame { class XModel; }
+namespace com::sun::star::lang { class XUnoTunnel; }
+namespace com::sun::star::uno { class XComponentContext; }
+
+
+namespace chart
+{
+class ExplicitValueProvider;
+class ChartModel;
+
+namespace wrapper
+{
+
+class Chart2ModelContact final
+{
+public:
+ explicit Chart2ModelContact( const css::uno::Reference< css::uno::XComponentContext >& xContext );
+ ~Chart2ModelContact();
+
+public:
+ void setModel( const css::uno::Reference< css::frame::XModel >& xChartModel );
+ void clear();
+
+ css::uno::Reference< css::frame::XModel > getChartModel() const;
+
+ ChartModel* getModel() const { return mpModel;}
+
+ css::uno::Reference< css::chart2::XChartDocument > getChart2Document() const;
+ css::uno::Reference< css::chart2::XDiagram > getChart2Diagram() const;
+
+ css::uno::Reference< css::drawing::XDrawPage > getDrawPage() const;
+
+ /** get the current values calculated for an axis in the current view in
+ case properties are 'auto'.
+ */
+ void getExplicitValuesForAxis(
+ const css::uno::Reference< css::chart2::XAxis > & xAxis,
+ ExplicitScaleData & rOutExplicitScale,
+ ExplicitIncrementData & rOutExplicitIncrement );
+
+ sal_Int32 getExplicitNumberFormatKeyForAxis(
+ const css::uno::Reference< css::chart2::XAxis >& xAxis );
+
+ static sal_Int32 getExplicitNumberFormatKeyForSeries(
+ const css::uno::Reference< css::chart2::XDataSeries >& xSeries );
+
+ /** Returns the size of the page in logic coordinates. This value is used
+ for setting an appropriate "ReferencePageSize" for FontHeights.
+ */
+ css::awt::Size GetPageSize() const;
+
+ /** calculates the current axes title sizes and subtract that space them from the given rectangle
+ */
+ css::awt::Rectangle SubstractAxisTitleSizes( const css::awt::Rectangle& rPositionRect );
+
+ /** Returns the position and size of the diagram in logic coordinates (100th mm) including
+ the space used for axes including axes titles.
+ */
+ css::awt::Rectangle GetDiagramRectangleIncludingTitle() const;
+
+ /** Returns the position and size of the diagram in logic coordinates (100th mm) including
+ the space used for axes excluding axes titles.
+ */
+ css::awt::Rectangle GetDiagramRectangleIncludingAxes() const;
+
+ /** Returns the position and size of the diagram in logic coordinates (100th mm) excluding
+ the space used for axes (inner plot area).
+ */
+ css::awt::Rectangle GetDiagramRectangleExcludingAxes() const;
+
+ /** Returns the size of the object in logic coordinates.
+ */
+ css::awt::Size GetLegendSize() const;
+
+ /** Returns the position of the object in logic coordinates.
+ */
+ css::awt::Point GetLegendPosition() const;
+
+ /** Returns the size of the object in logic coordinates.
+ */
+ css::awt::Size GetTitleSize( const css::uno::Reference< css::chart2::XTitle > & xTitle ) const;
+
+ /** Returns the position of the object in logic coordinates.
+ */
+ css::awt::Point GetTitlePosition( const css::uno::Reference< css::chart2::XTitle > & xTitle ) const;
+
+ /** Returns the size of the object in logic coordinates.
+ */
+ css::awt::Size GetAxisSize( const css::uno::Reference< css::chart2::XAxis > & xAxis ) const;
+
+ /** Returns the position of the object in logic coordinates.
+ */
+ css::awt::Point GetAxisPosition( const css::uno::Reference< css::chart2::XAxis > & xAxis ) const;
+
+private: //methods
+ ExplicitValueProvider* getExplicitValueProvider() const;
+ css::uno::Reference< css::lang::XUnoTunnel > const & getChartView() const;
+
+public: //member
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+
+private: //member
+ css::uno::WeakReference< css::frame::XModel > m_xChartModel;
+
+ ChartModel* mpModel;
+
+ mutable css::uno::Reference< css::lang::XUnoTunnel > m_xChartView;
+
+ std::map< OUString, css::uno::Reference< css::container::XNameContainer > > m_aTableMap;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_CHART2MODELCONTACT_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
new file mode 100644
index 000000000..48a448edf
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
@@ -0,0 +1,695 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "ChartDataWrapper.hxx"
+#include <DiagramHelper.hxx>
+#include <DataSourceHelper.hxx>
+#include <ChartModelHelper.hxx>
+#include <ControllerLockGuard.hxx>
+#include "Chart2ModelContact.hxx"
+#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart/XChartDocument.hpp>
+
+#include <float.h>
+#include <rtl/math.hxx>
+#include <osl/diagnose.h>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::chart2::XAnyDescriptionAccess;
+using ::com::sun::star::chart::XComplexDescriptionAccess;
+using ::com::sun::star::chart::XChartData;
+using ::com::sun::star::chart::XChartDataArray;
+using ::com::sun::star::chart::XDateCategories;
+
+namespace
+{
+
+uno::Sequence< uno::Sequence< double > > lcl_getNANInsteadDBL_MIN( const uno::Sequence< uno::Sequence< double > >& rData )
+{
+ uno::Sequence< uno::Sequence< double > > aRet;
+ const sal_Int32 nOuterSize = rData.getLength();
+ aRet.realloc( nOuterSize );
+ for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter )
+ {
+ sal_Int32 nInnerSize = rData[nOuter].getLength();
+ aRet[nOuter].realloc( nInnerSize );
+ for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner )
+ {
+ aRet[nOuter][nInner] = rData[nOuter][nInner];
+ double& rValue = aRet[nOuter][nInner];
+ if( rValue == DBL_MIN )
+ ::rtl::math::setNan( &rValue );
+ }
+ }
+ return aRet;
+}
+
+uno::Sequence< uno::Sequence< double > > lcl_getDBL_MINInsteadNAN( const uno::Sequence< uno::Sequence< double > >& rData )
+{
+ uno::Sequence< uno::Sequence< double > > aRet;
+ const sal_Int32 nOuterSize = rData.getLength();
+ aRet.realloc( nOuterSize );
+ for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter )
+ {
+ sal_Int32 nInnerSize = rData[nOuter].getLength();
+ aRet[nOuter].realloc( nInnerSize );
+ for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner )
+ {
+ aRet[nOuter][nInner] = rData[nOuter][nInner];
+ double& rValue = aRet[nOuter][nInner];
+ if( std::isnan( rValue ) )
+ rValue = DBL_MIN;
+ }
+ }
+ return aRet;
+}
+
+} // anonymous namespace
+
+namespace chart::wrapper
+{
+
+struct lcl_Operator
+{
+ lcl_Operator()
+ {
+ }
+ virtual ~lcl_Operator()
+ {
+ }
+ virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) = 0;
+
+ virtual bool setsCategories( bool /*bDataInColumns*/ )
+ {
+ return false;
+ }
+};
+
+namespace {
+
+struct lcl_AllOperator : public lcl_Operator
+{
+ explicit lcl_AllOperator( const Reference< XChartData >& xDataToApply )
+ : lcl_Operator()
+ , m_xDataToApply( xDataToApply )
+ {
+ }
+
+ virtual bool setsCategories( bool /*bDataInColumns*/ ) override
+ {
+ return true;
+ }
+
+ virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
+ {
+ if( !xDataAccess.is() )
+ return;
+
+ Reference< XAnyDescriptionAccess > xNewAny( m_xDataToApply, uno::UNO_QUERY );
+ Reference< XComplexDescriptionAccess > xNewComplex( m_xDataToApply, uno::UNO_QUERY );
+ if( xNewAny.is() )
+ {
+ xDataAccess->setData( xNewAny->getData() );
+ xDataAccess->setComplexRowDescriptions( xNewAny->getComplexRowDescriptions() );
+ xDataAccess->setComplexColumnDescriptions( xNewAny->getComplexColumnDescriptions() );
+ }
+ else if( xNewComplex.is() )
+ {
+ xDataAccess->setData( xNewComplex->getData() );
+ xDataAccess->setComplexRowDescriptions( xNewComplex->getComplexRowDescriptions() );
+ xDataAccess->setComplexColumnDescriptions( xNewComplex->getComplexColumnDescriptions() );
+ }
+ else
+ {
+ Reference< XChartDataArray > xNew( m_xDataToApply, uno::UNO_QUERY );
+ if( xNew.is() )
+ {
+ xDataAccess->setData( xNew->getData() );
+ xDataAccess->setRowDescriptions( xNew->getRowDescriptions() );
+ xDataAccess->setColumnDescriptions( xNew->getColumnDescriptions() );
+ }
+ }
+ }
+
+ Reference< XChartData > m_xDataToApply;
+};
+
+struct lcl_DataOperator : public lcl_Operator
+{
+ explicit lcl_DataOperator( const Sequence< Sequence< double > >& rData )
+ : lcl_Operator()
+ , m_rData( rData )
+ {
+ }
+
+ virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
+ {
+ if( xDataAccess.is() )
+ xDataAccess->setData( lcl_getNANInsteadDBL_MIN( m_rData ) );
+ }
+
+ const Sequence< Sequence< double > >& m_rData;
+};
+
+struct lcl_RowDescriptionsOperator : public lcl_Operator
+{
+ lcl_RowDescriptionsOperator( const Sequence< OUString >& rRowDescriptions
+ , const Reference< chart2::XChartDocument >& xChartDoc )
+ : lcl_Operator()
+ , m_rRowDescriptions( rRowDescriptions )
+ , m_xChartDoc(xChartDoc)
+ , m_bDataInColumns(true)
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns ) override
+ {
+ m_bDataInColumns = bDataInColumns;
+ return bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
+ {
+ if( xDataAccess.is() )
+ {
+ xDataAccess->setRowDescriptions( m_rRowDescriptions );
+ if( m_bDataInColumns )
+ DiagramHelper::switchToTextCategories( m_xChartDoc );
+ }
+ }
+
+ const Sequence< OUString >& m_rRowDescriptions;
+ Reference< chart2::XChartDocument > m_xChartDoc;
+ bool m_bDataInColumns;
+};
+
+struct lcl_ComplexRowDescriptionsOperator : public lcl_Operator
+{
+ lcl_ComplexRowDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexRowDescriptions
+ , const Reference< chart2::XChartDocument >& xChartDoc )
+ : lcl_Operator()
+ , m_rComplexRowDescriptions( rComplexRowDescriptions )
+ , m_xChartDoc(xChartDoc)
+ , m_bDataInColumns(true)
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns ) override
+ {
+ m_bDataInColumns = bDataInColumns;
+ return bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
+ {
+ if( xDataAccess.is() )
+ {
+ xDataAccess->setComplexRowDescriptions( m_rComplexRowDescriptions );
+ if( m_bDataInColumns )
+ DiagramHelper::switchToTextCategories( m_xChartDoc );
+ }
+ }
+
+ const Sequence< Sequence< OUString > >& m_rComplexRowDescriptions;
+ Reference< chart2::XChartDocument > m_xChartDoc;
+ bool m_bDataInColumns;
+};
+
+struct lcl_AnyRowDescriptionsOperator : public lcl_Operator
+{
+ explicit lcl_AnyRowDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyRowDescriptions )
+ : lcl_Operator()
+ , m_rAnyRowDescriptions( rAnyRowDescriptions )
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns ) override
+ {
+ return bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
+ {
+ if( xDataAccess.is() )
+ xDataAccess->setAnyRowDescriptions( m_rAnyRowDescriptions );
+ }
+
+ const Sequence< Sequence< uno::Any > >& m_rAnyRowDescriptions;
+};
+
+struct lcl_ColumnDescriptionsOperator : public lcl_Operator
+{
+ lcl_ColumnDescriptionsOperator( const Sequence< OUString >& rColumnDescriptions
+ , const Reference< chart2::XChartDocument >& xChartDoc )
+ : lcl_Operator()
+ , m_rColumnDescriptions( rColumnDescriptions )
+ , m_xChartDoc(xChartDoc)
+ , m_bDataInColumns(true)
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns ) override
+ {
+ m_bDataInColumns = bDataInColumns;
+ return !bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
+ {
+ if( xDataAccess.is() )
+ {
+ xDataAccess->setColumnDescriptions( m_rColumnDescriptions );
+ if( !m_bDataInColumns )
+ DiagramHelper::switchToTextCategories( m_xChartDoc );
+ }
+ }
+
+ const Sequence< OUString >& m_rColumnDescriptions;
+ Reference< chart2::XChartDocument > m_xChartDoc;
+ bool m_bDataInColumns;
+};
+
+struct lcl_ComplexColumnDescriptionsOperator : public lcl_Operator
+{
+ lcl_ComplexColumnDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexColumnDescriptions
+ , const Reference< chart2::XChartDocument >& xChartDoc )
+ : lcl_Operator()
+ , m_rComplexColumnDescriptions( rComplexColumnDescriptions )
+ , m_xChartDoc(xChartDoc)
+ , m_bDataInColumns(true)
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns ) override
+ {
+ m_bDataInColumns = bDataInColumns;
+ return !bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
+ {
+ if( xDataAccess.is() )
+ {
+ xDataAccess->setComplexColumnDescriptions( m_rComplexColumnDescriptions );
+ if( !m_bDataInColumns )
+ DiagramHelper::switchToTextCategories( m_xChartDoc );
+ }
+ }
+
+ const Sequence< Sequence< OUString > >& m_rComplexColumnDescriptions;
+ Reference< chart2::XChartDocument > m_xChartDoc;
+ bool m_bDataInColumns;
+};
+
+struct lcl_AnyColumnDescriptionsOperator : public lcl_Operator
+{
+ explicit lcl_AnyColumnDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyColumnDescriptions )
+ : lcl_Operator()
+ , m_rAnyColumnDescriptions( rAnyColumnDescriptions )
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns ) override
+ {
+ return bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
+ {
+ if( xDataAccess.is() )
+ xDataAccess->setAnyColumnDescriptions( m_rAnyColumnDescriptions );
+ }
+
+ const Sequence< Sequence< uno::Any > >& m_rAnyColumnDescriptions;
+};
+
+struct lcl_DateCategoriesOperator : public lcl_Operator
+{
+ explicit lcl_DateCategoriesOperator( const Sequence< double >& rDates )
+ : lcl_Operator()
+ , m_rDates( rDates )
+ {
+ }
+
+ virtual bool setsCategories( bool /*bDataInColumns*/ ) override
+ {
+ return true;
+ }
+
+ virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) override
+ {
+ Reference< XDateCategories > xDateCategories( xDataAccess, uno::UNO_QUERY );
+ if( xDateCategories.is() )
+ xDateCategories->setDateCategories( m_rDates );
+ }
+
+ const Sequence< double >& m_rDates;
+};
+
+}
+
+ChartDataWrapper::ChartDataWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : m_spChart2ModelContact(spChart2ModelContact)
+ , m_aEventListenerContainer(m_aMutex)
+{
+ osl_atomic_increment( &m_refCount );
+ initDataAccess();
+ osl_atomic_decrement( &m_refCount );
+}
+
+ChartDataWrapper::ChartDataWrapper( const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
+ const Reference< XChartData >& xNewData ) :
+ m_spChart2ModelContact( spChart2ModelContact ),
+ m_aEventListenerContainer( m_aMutex )
+{
+ osl_atomic_increment( &m_refCount );
+ lcl_AllOperator aOperator( xNewData );
+ applyData( aOperator );
+ osl_atomic_decrement( &m_refCount );
+}
+
+ChartDataWrapper::~ChartDataWrapper()
+{
+ // @todo: implement XComponent and call this in dispose(). In the DTOR the
+ // ref-count is 0, thus creating a stack reference to this calls the DTOR at
+ // the end of the block recursively
+// uno::Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+// m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+}
+
+// ____ XChartDataArray (read)____
+Sequence< Sequence< double > > SAL_CALL ChartDataWrapper::getData()
+{
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return lcl_getDBL_MINInsteadNAN( m_xDataAccess->getData() );
+ return Sequence< Sequence< double > >();
+}
+Sequence< OUString > SAL_CALL ChartDataWrapper::getRowDescriptions()
+{
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getRowDescriptions();
+ return Sequence< OUString >();
+}
+Sequence< OUString > SAL_CALL ChartDataWrapper::getColumnDescriptions()
+{
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getColumnDescriptions();
+ return Sequence< OUString > ();
+}
+
+// ____ XComplexDescriptionAccess (read) ____
+Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexRowDescriptions()
+{
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getComplexRowDescriptions();
+ return Sequence< Sequence< OUString > >();
+}
+Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexColumnDescriptions()
+{
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getComplexColumnDescriptions();
+ return Sequence< Sequence< OUString > >();
+}
+
+// ____ XAnyDescriptionAccess (read) ____
+Sequence< Sequence< uno::Any > > SAL_CALL ChartDataWrapper::getAnyRowDescriptions()
+{
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getAnyRowDescriptions();
+ return Sequence< Sequence< uno::Any > >();
+}
+Sequence< Sequence< uno::Any > > SAL_CALL ChartDataWrapper::getAnyColumnDescriptions()
+{
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getAnyColumnDescriptions();
+ return Sequence< Sequence< uno::Any > >();
+}
+
+// ____ XDateCategories (read) ____
+Sequence< double > SAL_CALL ChartDataWrapper::getDateCategories()
+{
+ initDataAccess();
+ Reference< XDateCategories > xDateCategories( m_xDataAccess, uno::UNO_QUERY );
+ if( xDateCategories.is() )
+ return xDateCategories->getDateCategories();
+ return Sequence< double >();
+}
+
+// ____ XChartDataArray (write)____
+void SAL_CALL ChartDataWrapper::setData( const Sequence< Sequence< double > >& rData )
+{
+ lcl_DataOperator aOperator( rData );
+ applyData( aOperator );
+}
+void SAL_CALL ChartDataWrapper::setRowDescriptions( const Sequence< OUString >& rRowDescriptions )
+{
+ lcl_RowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getChart2Document() );
+ applyData( aOperator );
+}
+void SAL_CALL ChartDataWrapper::setColumnDescriptions( const Sequence< OUString >& rColumnDescriptions )
+{
+ lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getChart2Document() );
+ applyData( aOperator );
+}
+
+// ____ XComplexDescriptionAccess (write) ____
+void SAL_CALL ChartDataWrapper::setComplexRowDescriptions( const Sequence< Sequence< OUString > >& rRowDescriptions )
+{
+ lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getChart2Document() );
+ applyData( aOperator );
+}
+void SAL_CALL ChartDataWrapper::setComplexColumnDescriptions( const Sequence< Sequence< OUString > >& rColumnDescriptions )
+{
+ lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getChart2Document() );
+ applyData( aOperator );
+}
+
+// ____ XAnyDescriptionAccess (write) ____
+void SAL_CALL ChartDataWrapper::setAnyRowDescriptions( const Sequence< Sequence< uno::Any > >& rRowDescriptions )
+{
+ lcl_AnyRowDescriptionsOperator aOperator( rRowDescriptions );
+ applyData( aOperator );
+}
+void SAL_CALL ChartDataWrapper::setAnyColumnDescriptions( const Sequence< Sequence< uno::Any > >& rColumnDescriptions )
+{
+ lcl_AnyColumnDescriptionsOperator aOperator( rColumnDescriptions );
+ applyData( aOperator );
+}
+
+// ____ XDateCategories (write) ____
+void SAL_CALL ChartDataWrapper::setDateCategories( const Sequence< double >& rDates )
+{
+ Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ ControllerLockGuardUNO aCtrlLockGuard( xChartDoc );
+ lcl_DateCategoriesOperator aOperator( rDates );
+ applyData( aOperator );
+ DiagramHelper::switchToDateCategories( xChartDoc );
+}
+
+// ____ XChartData (base of XChartDataArray) ____
+void SAL_CALL ChartDataWrapper::addChartDataChangeEventListener(
+ const uno::Reference< css::chart::XChartDataChangeEventListener >& aListener )
+{
+ m_aEventListenerContainer.addInterface( aListener );
+}
+
+void SAL_CALL ChartDataWrapper::removeChartDataChangeEventListener(
+ const uno::Reference< css::chart::XChartDataChangeEventListener >& aListener )
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+double SAL_CALL ChartDataWrapper::getNotANumber()
+{
+ return DBL_MIN;
+}
+
+sal_Bool SAL_CALL ChartDataWrapper::isNotANumber( double nNumber )
+{
+ return nNumber == DBL_MIN
+ || std::isnan( nNumber )
+ || std::isinf( nNumber );
+}
+
+// ____ XComponent ____
+void SAL_CALL ChartDataWrapper::dispose()
+{
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( static_cast< ::cppu::OWeakObject* >( this )));
+ m_xDataAccess=nullptr;
+}
+
+void SAL_CALL ChartDataWrapper::addEventListener(
+ const uno::Reference< lang::XEventListener > & xListener )
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL ChartDataWrapper::removeEventListener(
+ const uno::Reference< lang::XEventListener >& aListener )
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+// ____ XEventListener ____
+void SAL_CALL ChartDataWrapper::disposing( const lang::EventObject& /* Source */ )
+{
+}
+
+void ChartDataWrapper::fireChartDataChangeEvent( css::chart::ChartDataChangeEvent& aEvent )
+{
+ if( ! m_aEventListenerContainer.getLength() )
+ return;
+
+ uno::Reference< uno::XInterface > xSrc( static_cast< cppu::OWeakObject* >( this ));
+ OSL_ASSERT( xSrc.is());
+ if( xSrc.is() )
+ aEvent.Source = xSrc;
+
+ m_aEventListenerContainer.notifyEach( &css::chart::XChartDataChangeEventListener::chartDataChanged, aEvent );
+}
+
+void ChartDataWrapper::switchToInternalDataProvider()
+{
+ //create an internal data provider that is connected to the model
+ Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ if( xChartDoc.is() )
+ xChartDoc->createInternalDataProvider( true /*bCloneExistingData*/ );
+ initDataAccess();
+}
+
+void ChartDataWrapper::initDataAccess()
+{
+ Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ if( !xChartDoc.is() )
+ return;
+ if( xChartDoc->hasInternalDataProvider() )
+ m_xDataAccess.set( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
+ else
+ {
+ //create a separate "internal data provider" that is not connected to the model
+ m_xDataAccess.set( ChartModelHelper::createInternalDataProvider(
+ xChartDoc, false /*bConnectToModel*/ ), uno::UNO_QUERY_THROW );
+ }
+}
+
+void ChartDataWrapper::applyData( lcl_Operator& rDataOperator )
+{
+ //bool bSetValues, bool bSetRowDescriptions, bool bSetColumnDescriptions
+ Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ if( !xChartDoc.is() )
+ return;
+
+ // remember some diagram properties to reset later
+ bool bStacked = false;
+ bool bPercent = false;
+ bool bDeep = false;
+ uno::Reference< css::chart::XChartDocument > xOldDoc( xChartDoc, uno::UNO_QUERY );
+ OSL_ASSERT( xOldDoc.is());
+ uno::Reference< beans::XPropertySet > xDiaProp( xOldDoc->getDiagram(), uno::UNO_QUERY );
+ if( xDiaProp.is())
+ {
+ xDiaProp->getPropertyValue("Stacked") >>= bStacked;
+ xDiaProp->getPropertyValue("Percent") >>= bPercent;
+ xDiaProp->getPropertyValue("Deep") >>= bDeep;
+ }
+
+ //detect arguments for the new data source
+ OUString aRangeString;
+ bool bUseColumns = true;
+ bool bFirstCellAsLabel = true;
+ bool bHasCategories = true;
+ uno::Sequence< sal_Int32 > aSequenceMapping;
+
+ DataSourceHelper::detectRangeSegmentation(
+ xChartDoc,
+ aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories );
+
+ if( !bHasCategories && rDataOperator.setsCategories( bUseColumns ) )
+ bHasCategories = true;
+
+ aRangeString = "all";
+ uno::Sequence< beans::PropertyValue > aArguments( DataSourceHelper::createArguments(
+ aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories ) );
+
+ // -- locked controllers
+ ControllerLockGuardUNO aCtrlLockGuard( xChartDoc );
+
+ // create and attach new data source
+ switchToInternalDataProvider();
+ rDataOperator.apply(m_xDataAccess);
+ uno::Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
+ OSL_ASSERT( xDataProvider.is() );
+ if( !xDataProvider.is() )
+ return;
+ uno::Reference< chart2::data::XDataSource > xSource( xDataProvider->createDataSource( aArguments ) );
+
+ uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram() );
+ if( xDia.is() )
+ xDia->setDiagramData( xSource, aArguments );
+
+ //correct stacking mode
+ if( bStacked || bPercent || bDeep )
+ {
+ StackMode eStackMode = StackMode::YStacked;
+ if( bDeep )
+ eStackMode = StackMode::ZStacked;
+ else if( bPercent )
+ eStackMode = StackMode::YStackedPercent;
+ DiagramHelper::setStackMode( xDia, eStackMode );
+ }
+
+ // notify listeners
+ css::chart::ChartDataChangeEvent aEvent(
+ static_cast< ::cppu::OWeakObject* >( this ),
+ css::chart::ChartDataChangeType_ALL, 0, 0, 0, 0 );
+ fireChartDataChangeEvent( aEvent );
+ // \-- locked controllers
+}
+
+OUString SAL_CALL ChartDataWrapper::getImplementationName()
+{
+ return "com.sun.star.comp.chart.ChartData";
+}
+
+sal_Bool SAL_CALL ChartDataWrapper::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL ChartDataWrapper::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart.ChartDataArray",
+ "com.sun.star.chart.ChartData"
+ };
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx
new file mode 100644
index 000000000..55bb8c63b
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx
@@ -0,0 +1,125 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_CHARTDATAWRAPPER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_CHARTDATAWRAPPER_HXX
+
+#include <MutexContainer.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <comphelper/interfacecontainer2.hxx>
+#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
+#include <com/sun/star/chart/XDateCategories.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/EventObject.hpp>
+
+#include <memory>
+
+namespace chart
+{
+namespace wrapper
+{
+
+class Chart2ModelContact;
+struct lcl_Operator;
+
+class ChartDataWrapper final : public MutexContainer, public
+ ::cppu::WeakImplHelper<
+ css::chart2::XAnyDescriptionAccess,
+ css::chart::XDateCategories,
+ css::lang::XServiceInfo,
+ css::lang::XEventListener,
+ css::lang::XComponent >
+{
+public:
+ explicit ChartDataWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ ChartDataWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact
+ , const css::uno::Reference< css::chart::XChartData >& xNewData );
+ virtual ~ChartDataWrapper() override;
+
+ /// XServiceInfo declarations
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+private:
+ // ____ XDateCategories ____
+ virtual css::uno::Sequence< double > SAL_CALL getDateCategories() override;
+ virtual void SAL_CALL setDateCategories( const css::uno::Sequence< double >& rDates ) override;
+
+ // ____ XAnyDescriptionAccess ____
+ virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL
+ getAnyRowDescriptions() override;
+ virtual void SAL_CALL setAnyRowDescriptions(
+ const css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& aRowDescriptions ) override;
+ virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL
+ getAnyColumnDescriptions() override;
+ virtual void SAL_CALL setAnyColumnDescriptions(
+ const css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& aColumnDescriptions ) override;
+
+ // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____
+ virtual css::uno::Sequence< css::uno::Sequence< OUString > > SAL_CALL
+ getComplexRowDescriptions() override;
+ virtual void SAL_CALL setComplexRowDescriptions(
+ const css::uno::Sequence< css::uno::Sequence< OUString > >& aRowDescriptions ) override;
+ virtual css::uno::Sequence< css::uno::Sequence< OUString > > SAL_CALL
+ getComplexColumnDescriptions() override;
+ virtual void SAL_CALL setComplexColumnDescriptions(
+ const css::uno::Sequence< css::uno::Sequence< OUString > >& aColumnDescriptions ) override;
+
+ // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
+ virtual css::uno::Sequence< css::uno::Sequence< double > > SAL_CALL getData() override;
+ virtual void SAL_CALL setData( const css::uno::Sequence< css::uno::Sequence< double > >& aData ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getRowDescriptions() override;
+ virtual void SAL_CALL setRowDescriptions( const css::uno::Sequence< OUString >& aRowDescriptions ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getColumnDescriptions() override;
+ virtual void SAL_CALL setColumnDescriptions( const css::uno::Sequence< OUString >& aColumnDescriptions ) override;
+
+ // ____ XChartData (base of XChartDataArray) ____
+ virtual void SAL_CALL addChartDataChangeEventListener( const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override;
+ virtual void SAL_CALL removeChartDataChangeEventListener( const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override;
+ virtual double SAL_CALL getNotANumber() override;
+ virtual sal_Bool SAL_CALL isNotANumber( double nNumber ) override;
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose() override;
+ virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
+ virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
+
+ // ____ XEventListener ____
+ virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
+
+ void fireChartDataChangeEvent( css::chart::ChartDataChangeEvent& aEvent );
+
+ void switchToInternalDataProvider();
+ void initDataAccess();
+ void applyData( lcl_Operator& rDataOperator );
+
+ css::uno::Reference< css::chart2::XAnyDescriptionAccess > m_xDataAccess;
+
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_CHARTDATAWRAPPER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
new file mode 100644
index 000000000..f385c399c
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -0,0 +1,1454 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <ChartDocumentWrapper.hxx>
+#include <servicenames.hxx>
+#include <PropertyHelper.hxx>
+#include <TitleHelper.hxx>
+#include <LegendHelper.hxx>
+#include <ControllerLockGuard.hxx>
+#include <DisposeHelper.hxx>
+#include "DataSeriesPointWrapper.hxx"
+#include <chartview/ExplicitValueProvider.hxx>
+#include <chartview/DrawModelWrapper.hxx>
+#include "Chart2ModelContact.hxx"
+
+#include <ChartModel.hxx>
+
+#include <DiagramHelper.hxx>
+#include <DataSourceHelper.hxx>
+#include <ChartModelHelper.hxx>
+#include <AxisHelper.hxx>
+#include <ThreeDHelper.hxx>
+
+#include "TitleWrapper.hxx"
+#include "ChartDataWrapper.hxx"
+#include "DiagramWrapper.hxx"
+#include "LegendWrapper.hxx"
+#include "AreaWrapper.hxx"
+#include "WrappedAddInProperty.hxx"
+#include <WrappedIgnoreProperty.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <vcl/settings.hxx>
+
+#include <com/sun/star/drawing/ShapeCollection.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/util/XRefreshable.hpp>
+#include <tools/diagnose_ex.h>
+
+#include <vector>
+#include <algorithm>
+#include <map>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart;
+
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::Property;
+
+namespace
+{
+enum eServiceType
+{
+ SERVICE_NAME_AREA_DIAGRAM = 0,
+ SERVICE_NAME_BAR_DIAGRAM,
+ SERVICE_NAME_DONUT_DIAGRAM,
+ SERVICE_NAME_LINE_DIAGRAM,
+ SERVICE_NAME_NET_DIAGRAM,
+ SERVICE_NAME_FILLED_NET_DIAGRAM,
+ SERVICE_NAME_PIE_DIAGRAM,
+ SERVICE_NAME_STOCK_DIAGRAM,
+ SERVICE_NAME_XY_DIAGRAM,
+ SERVICE_NAME_BUBBLE_DIAGRAM,
+
+ SERVICE_NAME_DASH_TABLE,
+ SERVICE_NAME_GRADIENT_TABLE,
+ SERVICE_NAME_HATCH_TABLE,
+ SERVICE_NAME_BITMAP_TABLE,
+ SERVICE_NAME_TRANSP_GRADIENT_TABLE,
+ SERVICE_NAME_MARKER_TABLE,
+
+ SERVICE_NAME_NAMESPACE_MAP,
+ SERVICE_NAME_EXPORT_GRAPHIC_STORAGE_RESOLVER,
+ SERVICE_NAME_IMPORT_GRAPHIC_STORAGE_RESOLVER
+};
+
+typedef std::map< OUString, enum eServiceType > tServiceNameMap;
+
+tServiceNameMap & lcl_getStaticServiceNameMap()
+{
+ static tServiceNameMap aServiceNameMap {
+ {"com.sun.star.chart.AreaDiagram", SERVICE_NAME_AREA_DIAGRAM},
+ {"com.sun.star.chart.BarDiagram", SERVICE_NAME_BAR_DIAGRAM},
+ {"com.sun.star.chart.DonutDiagram", SERVICE_NAME_DONUT_DIAGRAM},
+ {"com.sun.star.chart.LineDiagram", SERVICE_NAME_LINE_DIAGRAM},
+ {"com.sun.star.chart.NetDiagram", SERVICE_NAME_NET_DIAGRAM},
+ {"com.sun.star.chart.FilledNetDiagram", SERVICE_NAME_FILLED_NET_DIAGRAM},
+ {"com.sun.star.chart.PieDiagram", SERVICE_NAME_PIE_DIAGRAM},
+ {"com.sun.star.chart.StockDiagram", SERVICE_NAME_STOCK_DIAGRAM},
+ {"com.sun.star.chart.XYDiagram", SERVICE_NAME_XY_DIAGRAM},
+ {"com.sun.star.chart.BubbleDiagram", SERVICE_NAME_BUBBLE_DIAGRAM},
+
+ {"com.sun.star.drawing.DashTable", SERVICE_NAME_DASH_TABLE},
+ {"com.sun.star.drawing.GradientTable", SERVICE_NAME_GRADIENT_TABLE},
+ {"com.sun.star.drawing.HatchTable", SERVICE_NAME_HATCH_TABLE},
+ {"com.sun.star.drawing.BitmapTable", SERVICE_NAME_BITMAP_TABLE},
+ {"com.sun.star.drawing.TransparencyGradientTable", SERVICE_NAME_TRANSP_GRADIENT_TABLE},
+ {"com.sun.star.drawing.MarkerTable", SERVICE_NAME_MARKER_TABLE},
+
+ {"com.sun.star.xml.NamespaceMap", SERVICE_NAME_NAMESPACE_MAP},
+ {"com.sun.star.document.ExportGraphicStoreageHandler", SERVICE_NAME_EXPORT_GRAPHIC_STORAGE_RESOLVER},
+ {"com.sun.star.document.ImportGraphicStoreageHandler", SERVICE_NAME_IMPORT_GRAPHIC_STORAGE_RESOLVER}
+ };
+
+ return aServiceNameMap;
+}
+
+enum
+{
+ PROP_DOCUMENT_HAS_MAIN_TITLE,
+ PROP_DOCUMENT_HAS_SUB_TITLE,
+ PROP_DOCUMENT_HAS_LEGEND,
+ PROP_DOCUMENT_LABELS_IN_FIRST_ROW,
+ PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN,
+ PROP_DOCUMENT_ADDIN,
+ PROP_DOCUMENT_BASEDIAGRAM,
+ PROP_DOCUMENT_ADDITIONAL_SHAPES,
+ PROP_DOCUMENT_UPDATE_ADDIN,
+ PROP_DOCUMENT_NULL_DATE,
+ PROP_DOCUMENT_ENABLE_COMPLEX_CHARTTYPES,
+ PROP_DOCUMENT_ENABLE_DATATABLE_DIALOG
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "HasMainTitle",
+ PROP_DOCUMENT_HAS_MAIN_TITLE,
+ cppu::UnoType<bool>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasSubTitle",
+ PROP_DOCUMENT_HAS_SUB_TITLE,
+ cppu::UnoType<bool>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasLegend",
+ PROP_DOCUMENT_HAS_LEGEND,
+ cppu::UnoType<bool>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // really needed?
+ rOutProperties.emplace_back( "DataSourceLabelsInFirstRow",
+ PROP_DOCUMENT_LABELS_IN_FIRST_ROW,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "DataSourceLabelsInFirstColumn",
+ PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN,
+ cppu::UnoType<bool>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ //add-in
+ rOutProperties.emplace_back( "AddIn",
+ PROP_DOCUMENT_ADDIN,
+ cppu::UnoType<util::XRefreshable>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( "BaseDiagram",
+ PROP_DOCUMENT_BASEDIAGRAM,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( "AdditionalShapes",
+ PROP_DOCUMENT_ADDITIONAL_SHAPES,
+ cppu::UnoType<drawing::XShapes>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID
+ | beans::PropertyAttribute::READONLY );
+ rOutProperties.emplace_back( "RefreshAddInAllowed",
+ PROP_DOCUMENT_UPDATE_ADDIN,
+ cppu::UnoType<bool>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::TRANSIENT );
+
+ // table:null-date // i99104
+ rOutProperties.emplace_back( "NullDate",
+ PROP_DOCUMENT_NULL_DATE,
+ ::cppu::UnoType<css::util::DateTime>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "EnableComplexChartTypes",
+ PROP_DOCUMENT_ENABLE_COMPLEX_CHARTTYPES,
+ cppu::UnoType<bool>::get(),
+ //#i112666# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "EnableDataTableDialog",
+ PROP_DOCUMENT_ENABLE_DATATABLE_DIALOG,
+ cppu::UnoType<bool>::get(),
+ //#i112666# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+struct StaticChartDocumentWrapperPropertyArray_Initializer
+{
+ Sequence< Property >* operator()()
+ {
+ static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
+ return &aPropSeq;
+ }
+
+private:
+ static uno::Sequence< Property > lcl_GetPropertySequence()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+};
+
+struct StaticChartDocumentWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticChartDocumentWrapperPropertyArray_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart::wrapper
+{
+
+namespace {
+
+//PROP_DOCUMENT_LABELS_IN_FIRST_ROW
+class WrappedDataSourceLabelsInFirstRowProperty : public WrappedProperty
+{
+public:
+ explicit WrappedDataSourceLabelsInFirstRowProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ mutable Any m_aOuterValue;
+};
+
+}
+
+WrappedDataSourceLabelsInFirstRowProperty::WrappedDataSourceLabelsInFirstRowProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty("DataSourceLabelsInFirstRow",OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_aOuterValue()
+{
+ m_aOuterValue = WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( nullptr );
+}
+
+void WrappedDataSourceLabelsInFirstRowProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ bool bLabelsInFirstRow = true;
+ if( ! (rOuterValue >>= bLabelsInFirstRow) )
+ throw lang::IllegalArgumentException("Property DataSourceLabelsInFirstRow requires value of type boolean", nullptr, 0 );
+
+ m_aOuterValue = rOuterValue;
+ bool bNewValue = bLabelsInFirstRow;
+
+ OUString aRangeString;
+ bool bUseColumns = true;
+ bool bFirstCellAsLabel = true;
+ bool bHasCategories = true;
+ uno::Sequence< sal_Int32 > aSequenceMapping;
+
+ if( !DataSourceHelper::detectRangeSegmentation(
+ m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
+ , bFirstCellAsLabel, bHasCategories ) )
+ return;
+
+ if( bUseColumns && bNewValue != bFirstCellAsLabel )
+ {
+ DataSourceHelper::setRangeSegmentation(
+ m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns ,bNewValue, bHasCategories );
+ }
+ else if( !bUseColumns && bNewValue != bHasCategories )
+ {
+ DataSourceHelper::setRangeSegmentation(
+ m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns , bFirstCellAsLabel, bNewValue );
+ }
+}
+
+Any WrappedDataSourceLabelsInFirstRowProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ OUString aRangeString;
+ bool bUseColumns = true;
+ bool bFirstCellAsLabel = true;
+ bool bHasCategories = true;
+ uno::Sequence< sal_Int32 > aSequenceMapping;
+
+ if( DataSourceHelper::detectRangeSegmentation(
+ m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
+ , bFirstCellAsLabel, bHasCategories ) )
+ {
+ bool bLabelsInFirstRow = true;
+ if( bUseColumns )
+ bLabelsInFirstRow = bFirstCellAsLabel;
+ else
+ bLabelsInFirstRow = bHasCategories;
+
+ m_aOuterValue <<= bLabelsInFirstRow;
+ }
+ return m_aOuterValue;
+}
+
+Any WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= true;
+ return aRet;
+}
+
+namespace {
+
+//PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN
+class WrappedDataSourceLabelsInFirstColumnProperty : public WrappedProperty
+{
+public:
+ explicit WrappedDataSourceLabelsInFirstColumnProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ mutable Any m_aOuterValue;
+};
+
+}
+
+WrappedDataSourceLabelsInFirstColumnProperty::WrappedDataSourceLabelsInFirstColumnProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty("DataSourceLabelsInFirstColumn",OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_aOuterValue()
+{
+ m_aOuterValue = WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( nullptr );
+}
+
+void WrappedDataSourceLabelsInFirstColumnProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ bool bLabelsInFirstRow = true;
+ if( ! (rOuterValue >>= bLabelsInFirstRow) )
+ throw lang::IllegalArgumentException("Property DataSourceLabelsInFirstRow requires value of type boolean", nullptr, 0 );
+
+ m_aOuterValue = rOuterValue;
+ bool bNewValue = bLabelsInFirstRow;
+
+ OUString aRangeString;
+ bool bUseColumns = true;
+ bool bFirstCellAsLabel = true;
+ bool bHasCategories = true;
+ uno::Sequence< sal_Int32 > aSequenceMapping;
+
+ if( !DataSourceHelper::detectRangeSegmentation(
+ m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
+ , bFirstCellAsLabel, bHasCategories ) )
+ return;
+
+ if( bUseColumns && bNewValue != bHasCategories )
+ {
+ DataSourceHelper::setRangeSegmentation(
+ m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns, bFirstCellAsLabel, bNewValue );
+ }
+ else if( !bUseColumns && bNewValue != bFirstCellAsLabel )
+ {
+ DataSourceHelper::setRangeSegmentation(
+ m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns , bNewValue, bHasCategories );
+ }
+}
+
+Any WrappedDataSourceLabelsInFirstColumnProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ OUString aRangeString;
+ bool bUseColumns = true;
+ bool bFirstCellAsLabel = true;
+ bool bHasCategories = true;
+ uno::Sequence< sal_Int32 > aSequenceMapping;
+
+ if( DataSourceHelper::detectRangeSegmentation(
+ m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
+ , bFirstCellAsLabel, bHasCategories ) )
+ {
+ bool bLabelsInFirstColumn = true;
+ if( bUseColumns )
+ bLabelsInFirstColumn = bHasCategories;
+ else
+ bLabelsInFirstColumn = bFirstCellAsLabel;
+
+ m_aOuterValue <<= bLabelsInFirstColumn;
+ }
+ return m_aOuterValue;
+}
+
+Any WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= true;
+ return aRet;
+}
+
+namespace {
+
+//PROP_DOCUMENT_HAS_LEGEND
+class WrappedHasLegendProperty : public WrappedProperty
+{
+public:
+ explicit WrappedHasLegendProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+};
+
+}
+
+WrappedHasLegendProperty::WrappedHasLegendProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty("HasLegend",OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+{
+}
+
+void WrappedHasLegendProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ bool bNewValue = true;
+ if( ! (rOuterValue >>= bNewValue) )
+ throw lang::IllegalArgumentException("Property HasLegend requires value of type boolean", nullptr, 0 );
+
+ try
+ {
+ Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *m_spChart2ModelContact->getModel(), m_spChart2ModelContact->m_xContext,bNewValue ));
+ if(xLegend.is())
+ {
+ Reference< beans::XPropertySet > xLegendProp( xLegend, uno::UNO_QUERY_THROW );
+ bool bOldValue = true;
+ Any aAOld = xLegendProp->getPropertyValue("Show");
+ aAOld >>= bOldValue;
+ if( bOldValue != bNewValue )
+ xLegendProp->setPropertyValue("Show", uno::Any( bNewValue ));
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+Any WrappedHasLegendProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ Any aRet;
+ try
+ {
+ Reference< beans::XPropertySet > xLegendProp(
+ LegendHelper::getLegend( *m_spChart2ModelContact->getModel() ), uno::UNO_QUERY );
+ if( xLegendProp.is())
+ aRet = xLegendProp->getPropertyValue("Show");
+ else
+ aRet <<= false;
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return aRet;
+}
+
+Any WrappedHasLegendProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= false;
+ return aRet;
+}
+
+namespace {
+
+//PROP_DOCUMENT_HAS_MAIN_TITLE
+class WrappedHasMainTitleProperty : public WrappedProperty
+{
+public:
+ explicit WrappedHasMainTitleProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+};
+
+}
+
+WrappedHasMainTitleProperty::WrappedHasMainTitleProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty("HasMainTitle",OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+{
+}
+
+void WrappedHasMainTitleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ bool bNewValue = true;
+ if( ! (rOuterValue >>= bNewValue) )
+ throw lang::IllegalArgumentException("Property HasMainTitle requires value of type boolean", nullptr, 0 );
+
+ try
+ {
+ if( bNewValue )
+ TitleHelper::createTitle( TitleHelper::MAIN_TITLE, "main-title", m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
+ else
+ TitleHelper::removeTitle( TitleHelper::MAIN_TITLE, m_spChart2ModelContact->getChartModel() );
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+Any WrappedHasMainTitleProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ Any aRet;
+ try
+ {
+ aRet <<= TitleHelper::getTitle( TitleHelper::MAIN_TITLE, m_spChart2ModelContact->getChartModel() ).is();
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return aRet;
+}
+
+Any WrappedHasMainTitleProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= false;
+ return aRet;
+}
+
+namespace {
+
+//PROP_DOCUMENT_HAS_SUB_TITLE
+class WrappedHasSubTitleProperty : public WrappedProperty
+{
+public:
+ explicit WrappedHasSubTitleProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+};
+
+}
+
+WrappedHasSubTitleProperty::WrappedHasSubTitleProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty("HasSubTitle",OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+{
+}
+
+void WrappedHasSubTitleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ bool bNewValue = true;
+ if( ! (rOuterValue >>= bNewValue) )
+ throw lang::IllegalArgumentException("Property HasSubTitle requires value of type boolean", nullptr, 0 );
+
+ try
+ {
+ if( bNewValue )
+ TitleHelper::createTitle( TitleHelper::SUB_TITLE, "", m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
+ else
+ TitleHelper::removeTitle( TitleHelper::SUB_TITLE, m_spChart2ModelContact->getChartModel() );
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+Any WrappedHasSubTitleProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ Any aRet;
+ try
+ {
+ aRet <<= TitleHelper::getTitle( TitleHelper::SUB_TITLE, m_spChart2ModelContact->getChartModel() ).is();
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return aRet;
+}
+
+Any WrappedHasSubTitleProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= false;
+ return aRet;
+}
+
+ChartDocumentWrapper::ChartDocumentWrapper(
+ const Reference< uno::XComponentContext > & xContext ) :
+ m_spChart2ModelContact( std::make_shared<Chart2ModelContact>( xContext ) ),
+ m_bUpdateAddIn( true ),
+ m_bIsDisposed( false )
+{
+}
+
+ChartDocumentWrapper::~ChartDocumentWrapper()
+{
+ stopAllComponentListening();
+}
+
+// ____ XInterface (for new interfaces) ____
+uno::Any SAL_CALL ChartDocumentWrapper::queryInterface( const uno::Type& aType )
+{
+ if( m_xDelegator.is())
+ // calls queryAggregation if the delegator doesn't know aType
+ return m_xDelegator->queryInterface( aType );
+ else
+ return queryAggregation( aType );
+}
+
+// ____ chart::XChartDocument (old API wrapper) ____
+Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getTitle()
+{
+ if( !m_xTitle.is() )
+ {
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChart2Document() );
+ m_xTitle = new TitleWrapper( TitleHelper::MAIN_TITLE, m_spChart2ModelContact );
+ }
+ return m_xTitle;
+}
+
+Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getSubTitle()
+{
+ if( !m_xSubTitle.is() )
+ {
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChart2Document() );
+ m_xSubTitle = new TitleWrapper( TitleHelper::SUB_TITLE, m_spChart2ModelContact );
+ }
+ return m_xSubTitle;
+}
+
+Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getLegend()
+{
+ if( ! m_xLegend.is())
+ {
+ m_xLegend = new LegendWrapper( m_spChart2ModelContact );
+ }
+
+ return m_xLegend;
+}
+
+Reference< beans::XPropertySet > SAL_CALL ChartDocumentWrapper::getArea()
+{
+ if( ! m_xArea.is())
+ {
+ m_xArea.set( new AreaWrapper( m_spChart2ModelContact ) );
+ }
+
+ return m_xArea;
+}
+
+Reference< XDiagram > SAL_CALL ChartDocumentWrapper::getDiagram()
+{
+ if( !m_xDiagram.is() )
+ {
+ try
+ {
+ m_xDiagram = new DiagramWrapper( m_spChart2ModelContact );
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return m_xDiagram;
+}
+
+void SAL_CALL ChartDocumentWrapper::setDiagram( const Reference< XDiagram >& xDiagram )
+{
+ uno::Reference< util::XRefreshable > xAddIn( xDiagram, uno::UNO_QUERY );
+ if( xAddIn.is() )
+ {
+ setAddIn( xAddIn );
+ }
+ else if( xDiagram.is() && xDiagram != m_xDiagram )
+ {
+ // set new wrapped diagram at new chart. This requires the old
+ // diagram given as parameter to implement the new interface. If
+ // this is not possible throw an exception
+ Reference< chart2::XDiagramProvider > xNewDiaProvider( xDiagram, uno::UNO_QUERY_THROW );
+ Reference< chart2::XDiagram > xNewDia( xNewDiaProvider->getDiagram());
+
+ try
+ {
+ Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ if( xChartDoc.is() )
+ {
+ // set the new diagram
+ xChartDoc->setFirstDiagram( xNewDia );
+ m_xDiagram = xDiagram;
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+}
+
+Reference< XChartData > SAL_CALL ChartDocumentWrapper::getData()
+{
+ if( !m_xChartData.is() )
+ {
+ m_xChartData.set( new ChartDataWrapper( m_spChart2ModelContact ) );
+ }
+ //@todo: check hasInternalDataProvider also in else?
+
+ return m_xChartData;
+}
+
+void SAL_CALL ChartDocumentWrapper::attachData( const Reference< XChartData >& xNewData )
+{
+ if( !xNewData.is() )
+ return;
+
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChart2Document() );
+ m_xChartData.set( new ChartDataWrapper( m_spChart2ModelContact, xNewData ) );
+}
+
+// ____ XModel ____
+sal_Bool SAL_CALL ChartDocumentWrapper::attachResource(
+ const OUString& URL,
+ const Sequence< beans::PropertyValue >& Arguments )
+{
+ Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
+ if( xModel.is() )
+ return xModel->attachResource( URL, Arguments );
+ return false;
+}
+
+OUString SAL_CALL ChartDocumentWrapper::getURL()
+{
+ Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
+ if( xModel.is() )
+ return xModel->getURL();
+ return OUString();
+}
+
+Sequence< beans::PropertyValue > SAL_CALL ChartDocumentWrapper::getArgs()
+{
+ Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
+ if( xModel.is() )
+ return xModel->getArgs();
+ return Sequence< beans::PropertyValue >();
+}
+
+void SAL_CALL ChartDocumentWrapper::connectController( const Reference< frame::XController >& Controller )
+{
+ Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
+ if( xModel.is() )
+ xModel->connectController( Controller );
+}
+
+void SAL_CALL ChartDocumentWrapper::disconnectController(
+ const Reference< frame::XController >& Controller )
+{
+ Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
+ if( xModel.is() )
+ xModel->disconnectController( Controller );
+}
+
+void SAL_CALL ChartDocumentWrapper::lockControllers()
+{
+ Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
+ if( xModel.is() )
+ xModel->lockControllers();
+}
+
+void SAL_CALL ChartDocumentWrapper::unlockControllers()
+{
+ Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
+ if( xModel.is() )
+ xModel->unlockControllers();
+}
+
+sal_Bool SAL_CALL ChartDocumentWrapper::hasControllersLocked()
+{
+ Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
+ if( xModel.is() )
+ return xModel->hasControllersLocked();
+ return false;
+}
+
+Reference< frame::XController > SAL_CALL ChartDocumentWrapper::getCurrentController()
+{
+ Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
+ if( xModel.is() )
+ return xModel->getCurrentController();
+ return nullptr;
+}
+
+void SAL_CALL ChartDocumentWrapper::setCurrentController(
+ const Reference< frame::XController >& Controller )
+{
+ Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
+ if( xModel.is() )
+ xModel->setCurrentController( Controller );
+}
+
+Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::getCurrentSelection()
+{
+ Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
+ if( xModel.is() )
+ return xModel->getCurrentSelection();
+ return nullptr;
+}
+
+// ____ XComponent ____
+void SAL_CALL ChartDocumentWrapper::dispose()
+{
+ if( m_bIsDisposed )
+ throw lang::DisposedException("ChartDocumentWrapper is disposed",
+ static_cast< ::cppu::OWeakObject* >( this ));
+
+ m_bIsDisposed = true;
+
+ try
+ {
+ Reference< lang::XComponent > xFormerDelegator( m_xDelegator, uno::UNO_QUERY );
+ DisposeHelper::DisposeAndClear( m_xTitle );
+ DisposeHelper::DisposeAndClear( m_xSubTitle );
+ DisposeHelper::DisposeAndClear( m_xLegend );
+ DisposeHelper::DisposeAndClear( m_xChartData );
+ DisposeHelper::DisposeAndClear( m_xDiagram );
+ DisposeHelper::DisposeAndClear( m_xArea );
+ m_xChartView.set( nullptr );
+ m_xShapeFactory.set( nullptr );
+ m_xDelegator.set( nullptr );
+
+ clearWrappedPropertySet();
+ m_spChart2ModelContact->clear();
+ impl_resetAddIn();
+
+ stopAllComponentListening();
+
+ try
+ {
+ if( xFormerDelegator.is())
+ xFormerDelegator->dispose();
+ }
+ catch (const lang::DisposedException&)
+ {
+ // this is ok, don't panic
+ }
+ }
+ catch (const uno::Exception &)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+void ChartDocumentWrapper::impl_resetAddIn()
+{
+ Reference< util::XRefreshable > xAddIn( m_xAddIn );
+ m_xAddIn.set( nullptr );
+
+ if( !xAddIn.is() )
+ return;
+
+ try
+ {
+ //make sure that the add-in does not hold a references to us anymore:
+ Reference< lang::XComponent > xComp( xAddIn, uno::UNO_QUERY );
+ if( xComp.is())
+ xComp->dispose();
+ else
+ {
+ uno::Reference< lang::XInitialization > xInit( xAddIn, uno::UNO_QUERY );
+ if( xInit.is() )
+ {
+ uno::Any aParam;
+ uno::Reference< css::chart::XChartDocument > xDoc;
+ aParam <<= xDoc;
+ uno::Sequence< uno::Any > aSeq( &aParam, 1 );
+ xInit->initialize( aSeq );
+ }
+ }
+ }
+ catch (const uno::RuntimeException&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+void ChartDocumentWrapper::setBaseDiagram( const OUString& rBaseDiagram )
+{
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+ m_aBaseDiagram = rBaseDiagram;
+
+ uno::Reference< XDiagram > xDiagram( ChartDocumentWrapper::createInstance( rBaseDiagram ), uno::UNO_QUERY );
+ if( xDiagram.is() )
+ setDiagram( xDiagram );
+}
+
+void ChartDocumentWrapper::setAddIn( const Reference< util::XRefreshable >& xAddIn )
+{
+ if( m_xAddIn == xAddIn )
+ return;
+
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+ impl_resetAddIn();
+ m_xAddIn = xAddIn;
+ // initialize AddIn with this as chart document
+ uno::Reference< lang::XInitialization > xInit( m_xAddIn, uno::UNO_QUERY );
+ if( xInit.is() )
+ {
+ uno::Any aParam;
+ uno::Reference< XChartDocument > xDoc( static_cast<XChartDocument*>(this), uno::UNO_QUERY );
+ aParam <<= xDoc;
+ uno::Sequence< uno::Any > aSeq( &aParam, 1 );
+ xInit->initialize( aSeq );
+ }
+}
+
+void ChartDocumentWrapper::setUpdateAddIn( bool bUpdateAddIn )
+{
+ m_bUpdateAddIn = bUpdateAddIn;
+}
+
+Reference< drawing::XShapes > ChartDocumentWrapper::getAdditionalShapes() const
+{
+ // get additional non-chart shapes for XML export
+ uno::Reference< drawing::XShapes > xFoundShapes;
+ uno::Reference< drawing::XDrawPage > xDrawPage( impl_getDrawPage() );
+
+ if( !xDrawPage.is() )
+ return xFoundShapes;
+
+ uno::Reference<drawing::XShapes> xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) );
+
+ // iterate 'flat' over all top-level objects
+ // and determine all that are no chart objects
+ std::vector< uno::Reference< drawing::XShape > > aShapeVector;
+ sal_Int32 nSubCount = xDrawPage->getCount();
+ uno::Reference< drawing::XShape > xShape;
+ for( sal_Int32 nS = 0; nS < nSubCount; nS++ )
+ {
+ if( xDrawPage->getByIndex( nS ) >>= xShape )
+ {
+ if( xShape.is() && xChartRoot!=xShape )
+ aShapeVector.push_back( xShape );
+ }
+ }
+
+ if( !aShapeVector.empty() )
+ {
+ // create a shape collection
+ xFoundShapes = drawing::ShapeCollection::create(
+ comphelper::getProcessComponentContext());
+
+ OSL_ENSURE( xFoundShapes.is(), "Couldn't create a shape collection!" );
+ if( xFoundShapes.is())
+ {
+ for (auto const& shape : aShapeVector)
+ xFoundShapes->add(shape);
+ }
+ }
+
+ return xFoundShapes;
+}
+
+void SAL_CALL ChartDocumentWrapper::addEventListener( const Reference< lang::XEventListener >& xListener )
+{
+ Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
+ if( xModel.is() )
+ xModel->addEventListener( xListener );
+}
+
+void SAL_CALL ChartDocumentWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener )
+{
+ Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() );
+ if( xModel.is() )
+ xModel->removeEventListener( aListener );
+}
+
+// ____ XDrawPageSupplier ____
+uno::Reference< drawing::XDrawPage > SAL_CALL ChartDocumentWrapper::getDrawPage()
+{
+ return impl_getDrawPage();
+}
+
+uno::Reference< drawing::XDrawPage > ChartDocumentWrapper::impl_getDrawPage() const
+{
+ return m_spChart2ModelContact->getDrawPage();
+}
+
+namespace {
+
+uno::Reference< lang::XMultiServiceFactory > getShapeFactory(const uno::Reference<uno::XInterface>& xChartView)
+{
+ auto pProvider = comphelper::getUnoTunnelImplementation<ExplicitValueProvider>(xChartView);
+ if( pProvider )
+ return pProvider->getDrawModelWrapper()->getShapeFactory();
+
+ return uno::Reference< lang::XMultiServiceFactory >();
+}
+
+}
+
+// ____ XMultiServiceFactory ____
+uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance(
+ const OUString& aServiceSpecifier )
+{
+ uno::Reference< uno::XInterface > xResult;
+
+ Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ if( !xChartDoc.is() )
+ return xResult;
+
+ bool bServiceFound = false;
+ tServiceNameMap & rMap = lcl_getStaticServiceNameMap();
+
+ tServiceNameMap::const_iterator aIt( rMap.find( aServiceSpecifier ));
+ if( aIt != rMap.end())
+ {
+ bool bCreateDiagram = false;
+ uno::Reference< lang::XMultiServiceFactory > xManagerFact(
+ xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+ uno::Reference< chart2::XChartTypeTemplate > xTemplate;
+
+ switch( (*aIt).second )
+ {
+ case SERVICE_NAME_AREA_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance("com.sun.star.chart2.template.Area"),
+ uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_BAR_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ // this is for bar and column (the latter is the default if
+ // no "Vertical=false" property was set)
+ xTemplate.set(
+ xManagerFact->createInstance("com.sun.star.chart2.template.Column"),
+ uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_DONUT_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance("com.sun.star.chart2.template.Donut"),
+ uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_LINE_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance("com.sun.star.chart2.template.Line"),
+ uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_NET_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance("com.sun.star.chart2.template.Net"),
+ uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_FILLED_NET_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance("com.sun.star.chart2.template.FilledNet"),
+ uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_PIE_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance("com.sun.star.chart2.template.Pie"),
+ uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_STOCK_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance("com.sun.star.chart2.template.StockLowHighClose"),
+ uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+ case SERVICE_NAME_XY_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance("com.sun.star.chart2.template.ScatterLineSymbol"),
+ uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+
+ case SERVICE_NAME_BUBBLE_DIAGRAM:
+ if( xManagerFact.is())
+ {
+ xTemplate.set(
+ xManagerFact->createInstance("com.sun.star.chart2.template.Bubble"),
+ uno::UNO_QUERY );
+ bCreateDiagram = true;
+ }
+ break;
+
+ case SERVICE_NAME_DASH_TABLE:
+ case SERVICE_NAME_GRADIENT_TABLE:
+ case SERVICE_NAME_HATCH_TABLE:
+ case SERVICE_NAME_BITMAP_TABLE:
+ case SERVICE_NAME_TRANSP_GRADIENT_TABLE:
+ case SERVICE_NAME_MARKER_TABLE:
+ {
+ uno::Reference< lang::XMultiServiceFactory > xTableFactory( xChartDoc, uno::UNO_QUERY );
+ OSL_ENSURE( xTableFactory.get() != this, "new model is expected to implement service factory for gradient table etc" );
+ if( xTableFactory.is() && xTableFactory.get() != this )
+ xResult.set( xTableFactory->createInstance( aIt->first ), uno::UNO_QUERY );
+ }
+ break;
+
+ case SERVICE_NAME_NAMESPACE_MAP:
+ break;
+ case SERVICE_NAME_EXPORT_GRAPHIC_STORAGE_RESOLVER:
+ break;
+ case SERVICE_NAME_IMPORT_GRAPHIC_STORAGE_RESOLVER:
+ break;
+ }
+
+ if( bCreateDiagram && xTemplate.is() )
+ {
+ try
+ {
+ uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram());
+ if( xDia.is())
+ {
+ // locked controllers
+ ControllerLockGuardUNO aCtrlLockGuard( xChartDoc );
+ Reference< chart2::XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartDoc );
+ ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram );
+ Reference< lang::XMultiServiceFactory > xTemplateManager( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+ DiagramHelper::tTemplateWithServiceName aTemplateWithService(
+ DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager ));
+ if( aTemplateWithService.first.is())
+ aTemplateWithService.first->resetStyles( xDiagram );//#i109371#
+ xTemplate->changeDiagram( xDiagram );
+ if( AllSettings::GetMathLayoutRTL() )
+ AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
+ ThreeDHelper::setScheme( xDiagram, e3DScheme );
+ }
+ else
+ {
+ // locked controllers
+ ControllerLockGuardUNO aCtrlLockGuard( xChartDoc );
+ xDia.set( xTemplate->createDiagramByDataSource(
+ uno::Reference< chart2::data::XDataSource >(),
+ uno::Sequence< beans::PropertyValue >()));
+ xChartDoc->setFirstDiagram( xDia );
+ }
+
+ xResult = static_cast< ::cppu::OWeakObject* >( new DiagramWrapper( m_spChart2ModelContact ));
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ bServiceFound = true;
+ }
+ else if( aServiceSpecifier == "com.sun.star.comp.chart2.DataSeriesWrapper" )
+ {
+ Reference< beans::XPropertySet > xDataSeries( new DataSeriesPointWrapper( m_spChart2ModelContact ) );
+ xResult.set( xDataSeries );
+ bServiceFound = true;
+ }
+ else if( aServiceSpecifier == CHART_VIEW_SERVICE_NAME )
+ {
+ if( !m_xChartView.is() )
+ {
+ Reference< lang::XMultiServiceFactory > xFact(
+ m_spChart2ModelContact->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ Reference< lang::XInitialization > xViewInit( xFact->createInstance(
+ CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
+ if(xViewInit.is())
+ {
+ try
+ {
+ m_xChartView = xViewInit;
+
+ Sequence< Any > aArguments(2);
+ aArguments[0] <<= Reference<frame::XModel>(this);
+ aArguments[1] <<= true; // bRefreshAddIn
+ xViewInit->initialize(aArguments);
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+ }
+ xResult.set( m_xChartView );
+ bServiceFound = true;
+ }
+ else
+ {
+ // try to create a shape
+ try
+ {
+ if( !m_xShapeFactory.is() && m_xChartView.is() )
+ {
+ m_xShapeFactory = getShapeFactory( m_xChartView );
+ }
+ else
+ {
+ ChartModel* pModel = m_spChart2ModelContact->getModel();
+ if(pModel)
+ {
+ m_xChartView = pModel->getChartView();
+ m_xShapeFactory = getShapeFactory( m_xChartView );
+ }
+ }
+
+ if( m_xShapeFactory.is() )
+ {
+ xResult = m_xShapeFactory->createInstance( aServiceSpecifier );
+ bServiceFound = true;
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ // couldn't create shape
+ }
+ }
+
+ // finally, try to create an addin
+ if( !bServiceFound )
+ {
+ try
+ {
+ Reference< lang::XMultiServiceFactory > xFact(
+ m_spChart2ModelContact->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ uno::Reference< util::XRefreshable > xAddIn(
+ xFact->createInstance( aServiceSpecifier ), uno::UNO_QUERY );
+ if( xAddIn.is() )
+ {
+ xResult = xAddIn;
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ // couldn't create service
+ }
+ }
+
+ return xResult;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstanceWithArguments(
+ const OUString& ServiceSpecifier,
+ const uno::Sequence< uno::Any >& Arguments )
+{
+ OSL_ENSURE( Arguments.hasElements(), "createInstanceWithArguments: Warning: Arguments are ignored" );
+
+ return createInstance( ServiceSpecifier );
+}
+
+uno::Sequence< OUString > SAL_CALL ChartDocumentWrapper::getAvailableServiceNames()
+{
+ return comphelper::mapKeysToSequence( lcl_getStaticServiceNameMap() );
+}
+
+// ____ XAggregation ____
+void SAL_CALL ChartDocumentWrapper::setDelegator(
+ const uno::Reference< uno::XInterface >& rDelegator )
+{
+ if( m_bIsDisposed )
+ {
+ if( rDelegator.is() )
+ throw lang::DisposedException("ChartDocumentWrapper is disposed",
+ static_cast< ::cppu::OWeakObject* >( this ));
+ return;
+ }
+
+ if( rDelegator.is())
+ {
+ m_xDelegator = rDelegator;
+ m_spChart2ModelContact->setModel( uno::Reference< frame::XModel >(m_xDelegator, uno::UNO_QUERY) );
+ }
+ else
+ {
+ // this is a sort of dispose() from the new model,so release resources here
+ try
+ {
+ dispose();
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+}
+
+uno::Any SAL_CALL ChartDocumentWrapper::queryAggregation( const uno::Type& rType )
+{
+ return ChartDocumentWrapper_Base::queryInterface( rType );
+}
+
+// ____ ::utl::OEventListenerAdapter ____
+void ChartDocumentWrapper::_disposing( const lang::EventObject& rSource )
+{
+ if( rSource.Source == m_xTitle )
+ m_xTitle.set( nullptr );
+ else if( rSource.Source == m_xSubTitle )
+ m_xSubTitle.set( nullptr );
+ else if( rSource.Source == m_xLegend )
+ m_xLegend.set( nullptr );
+ else if( rSource.Source == m_xChartData )
+ m_xChartData.set( nullptr );
+ else if( rSource.Source == m_xDiagram )
+ m_xDiagram.set( nullptr );
+ else if( rSource.Source == m_xArea )
+ m_xArea.set( nullptr );
+ else if( rSource.Source == m_xAddIn )
+ m_xAddIn.set( nullptr );
+ else if( rSource.Source == m_xChartView )
+ m_xChartView.set( nullptr );
+}
+
+// WrappedPropertySet
+Reference< beans::XPropertySet > ChartDocumentWrapper::getInnerPropertySet()
+{
+ return nullptr;
+}
+const Sequence< beans::Property >& ChartDocumentWrapper::getPropertySequence()
+{
+ return *StaticChartDocumentWrapperPropertyArray::get();
+}
+
+std::vector< std::unique_ptr<WrappedProperty> > ChartDocumentWrapper::createWrappedProperties()
+{
+ std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
+ aWrappedProperties.emplace_back( new WrappedDataSourceLabelsInFirstRowProperty( m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedDataSourceLabelsInFirstColumnProperty( m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedHasLegendProperty( m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedHasMainTitleProperty( m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedHasSubTitleProperty( m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedAddInProperty( *this ) );
+ aWrappedProperties.emplace_back( new WrappedBaseDiagramProperty( *this ) );
+ aWrappedProperties.emplace_back( new WrappedAdditionalShapesProperty( *this ) );
+ aWrappedProperties.emplace_back( new WrappedRefreshAddInAllowedProperty( *this ) );
+ aWrappedProperties.emplace_back( new WrappedIgnoreProperty("NullDate",Any() ) ); // i99104
+ aWrappedProperties.emplace_back( new WrappedIgnoreProperty("EnableComplexChartTypes", uno::Any(true) ) );
+ aWrappedProperties.emplace_back( new WrappedIgnoreProperty("EnableDataTableDialog", uno::Any(true) ) );
+
+ return aWrappedProperties;
+}
+
+OUString SAL_CALL ChartDocumentWrapper::getImplementationName()
+{
+ return CHART_CHARTAPIWRAPPER_IMPLEMENTATION_NAME;
+}
+
+sal_Bool SAL_CALL ChartDocumentWrapper::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL ChartDocumentWrapper::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart.ChartDocument",
+ CHART_CHARTAPIWRAPPER_SERVICE_NAME,
+ "com.sun.star.xml.UserDefinedAttributesSupplier",
+ "com.sun.star.beans.PropertySet"
+ };
+}
+
+} // namespace chart::wrapper
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_ChartDocumentWrapper_get_implementation(css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::wrapper::ChartDocumentWrapper(context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
new file mode 100644
index 000000000..a6d45ddda
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
@@ -0,0 +1,885 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "DataSeriesPointWrapper.hxx"
+#include "Chart2ModelContact.hxx"
+#include <ChartTypeHelper.hxx>
+#include <DiagramHelper.hxx>
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <CharacterProperties.hxx>
+#include <UserDefinedProperties.hxx>
+#include "WrappedCharacterHeightProperty.hxx"
+#include <WrappedProperty.hxx>
+#include <WrappedIgnoreProperty.hxx>
+#include "WrappedStatisticProperties.hxx"
+#include "WrappedSymbolProperties.hxx"
+#include "WrappedDataCaptionProperties.hxx"
+#include "WrappedSeriesAreaOrLineProperty.hxx"
+#include "WrappedScaleTextProperties.hxx"
+#include "WrappedNumberFormatProperty.hxx"
+#include "WrappedTextRotationProperty.hxx"
+#include <unonames.hxx>
+
+#include <rtl/math.hxx>
+
+#include <algorithm>
+#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/chart/ChartAxisAssign.hpp>
+#include <com/sun/star/chart/ChartErrorCategory.hpp>
+#include <com/sun/star/chart/ChartSymbolType.hpp>
+#include <com/sun/star/drawing/LineJoint.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/Hatch.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <cppuhelper/propshlp.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::chart::wrapper;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Any;
+
+namespace
+{
+
+enum
+{
+ //data point properties
+ PROP_SERIES_DATAPOINT_SOLIDTYPE,
+ PROP_SERIES_DATAPOINT_SEGMENT_OFFSET,
+ PROP_SERIES_DATAPOINT_PERCENT_DIAGONAL,
+ PROP_SERIES_DATAPOINT_LABEL_SEPARATOR,
+ PROP_SERIES_NUMBERFORMAT,
+ PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE,
+ PROP_SERIES_PERCENTAGE_NUMBERFORMAT,
+ PROP_SERIES_DATAPOINT_TEXT_WORD_WRAP,
+ PROP_SERIES_DATAPOINT_LABEL_PLACEMENT,
+ //other series properties
+ PROP_SERIES_ATTACHED_AXIS,
+ PROP_SERIES_DATAPOINT_TEXT_ROTATION,
+ PROP_SERIES_DATAPOINT_LABEL_BORDER_STYLE,
+ PROP_SERIES_DATAPOINT_LABEL_BORDER_WIDTH,
+ PROP_SERIES_DATAPOINT_LABEL_BORDER_COLOR,
+ PROP_SERIES_DATAPOINT_LABEL_BORDER_TRANS,
+ PROP_SERIES_DATAPOINT_LABEL_FILL_STYLE,
+ PROP_SERIES_DATAPOINT_LABEL_FILL_COLOR,
+ PROP_SERIES_DATAPOINT_LABEL_FILL_BACKGROUND,
+ PROP_SERIES_DATAPOINT_LABEL_FILL_HATCH_NAME
+};
+
+void lcl_AddPropertiesToVector_PointProperties(
+ std::vector< Property > & rOutProperties )
+{
+ //service chart::Chart3DBarProperties
+ rOutProperties.emplace_back( "SolidType",
+ PROP_SERIES_DATAPOINT_SOLIDTYPE,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "SegmentOffset",
+ PROP_SERIES_DATAPOINT_SEGMENT_OFFSET,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "D3DPercentDiagonal",
+ PROP_SERIES_DATAPOINT_PERCENT_DIAGONAL,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "LabelSeparator",
+ PROP_SERIES_DATAPOINT_LABEL_SEPARATOR,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_NUMFMT,
+ PROP_SERIES_NUMBERFORMAT,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( CHART_UNONAME_LINK_TO_SRC_NUMFMT,
+ PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "PercentageNumberFormat",
+ PROP_SERIES_PERCENTAGE_NUMBERFORMAT,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "TextWordWrap",
+ PROP_SERIES_DATAPOINT_TEXT_WORD_WRAP,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "LabelPlacement",
+ PROP_SERIES_DATAPOINT_LABEL_PLACEMENT,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "TextRotation",
+ PROP_SERIES_DATAPOINT_TEXT_ROTATION,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_STYLE,
+ PROP_SERIES_DATAPOINT_LABEL_BORDER_STYLE,
+ cppu::UnoType<drawing::LineStyle>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_FILL_STYLE,
+ PROP_SERIES_DATAPOINT_LABEL_FILL_STYLE,
+ cppu::UnoType<drawing::FillStyle>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_FILL_COLOR,
+ PROP_SERIES_DATAPOINT_LABEL_FILL_COLOR,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_FILL_BACKGROUND,
+ PROP_SERIES_DATAPOINT_LABEL_FILL_BACKGROUND,
+ cppu::UnoType<sal_Bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_FILL_HATCH_NAME,
+ PROP_SERIES_DATAPOINT_LABEL_FILL_HATCH_NAME,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_WIDTH,
+ PROP_SERIES_DATAPOINT_LABEL_BORDER_WIDTH,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_COLOR,
+ PROP_SERIES_DATAPOINT_LABEL_BORDER_COLOR,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID // "maybe auto"
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_TRANS,
+ PROP_SERIES_DATAPOINT_LABEL_BORDER_TRANS,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+void lcl_AddPropertiesToVector_SeriesOnly(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "Axis",
+ PROP_SERIES_ATTACHED_AXIS,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+uno::Sequence< Property > lcl_GetPropertySequence( DataSeriesPointWrapper::eType _eType )
+{
+ std::vector< css::beans::Property > aProperties;
+
+ lcl_AddPropertiesToVector_PointProperties( aProperties );
+ if( _eType == DataSeriesPointWrapper::DATA_SERIES )
+ {
+ lcl_AddPropertiesToVector_SeriesOnly( aProperties );
+ WrappedStatisticProperties::addProperties( aProperties );
+ }
+ WrappedSymbolProperties::addProperties( aProperties ); //for series and points
+ WrappedDataCaptionProperties::addProperties( aProperties ); //for series and points
+
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+ ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+}
+
+struct StaticSeriesWrapperPropertyArray_Initializer
+{
+ Sequence< Property >* operator()()
+ {
+ static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_SERIES ) );
+ return &aPropSeq;
+ }
+};
+
+struct StaticSeriesWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticSeriesWrapperPropertyArray_Initializer >
+{
+};
+
+struct StaticPointWrapperPropertyArray_Initializer
+{
+ Sequence< Property >* operator()()
+ {
+ static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_POINT ) );
+ return &aPropSeq;
+ }
+};
+
+struct StaticPointWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticPointWrapperPropertyArray_Initializer >
+{
+};
+
+//PROP_SERIES_ATTACHED_AXIS
+class WrappedAttachedAxisProperty : public ::chart::WrappedProperty
+{
+public:
+ explicit WrappedAttachedAxisProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+protected:
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+};
+
+WrappedAttachedAxisProperty::WrappedAttachedAxisProperty(
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact )
+ : WrappedProperty("Axis",OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+{
+}
+
+Any WrappedAttachedAxisProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= css::chart::ChartAxisAssign::PRIMARY_Y;
+ return aRet;
+}
+
+Any WrappedAttachedAxisProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ Any aRet;
+
+ uno::Reference< chart2::XDataSeries > xDataSeries( xInnerPropertySet, uno::UNO_QUERY );
+ bool bAttachedToMainAxis = ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries );
+ if( bAttachedToMainAxis )
+ aRet <<= css::chart::ChartAxisAssign::PRIMARY_Y;
+ else
+ aRet <<= css::chart::ChartAxisAssign::SECONDARY_Y;
+ return aRet;
+}
+
+void WrappedAttachedAxisProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ uno::Reference< chart2::XDataSeries > xDataSeries( xInnerPropertySet, uno::UNO_QUERY );
+
+ sal_Int32 nChartAxisAssign = css::chart::ChartAxisAssign::PRIMARY_Y;
+ if( ! (rOuterValue >>= nChartAxisAssign) )
+ throw lang::IllegalArgumentException("Property Axis requires value of type sal_Int32", nullptr, 0 );
+
+ bool bNewAttachedToMainAxis = nChartAxisAssign == css::chart::ChartAxisAssign::PRIMARY_Y;
+ bool bOldAttachedToMainAxis = ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries );
+
+ if( bNewAttachedToMainAxis != bOldAttachedToMainAxis)
+ {
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( xDiagram.is() )
+ ::chart::DiagramHelper::attachSeriesToAxis( bNewAttachedToMainAxis, xDataSeries, xDiagram, m_spChart2ModelContact->m_xContext, false );
+ }
+}
+
+class WrappedSegmentOffsetProperty : public ::chart::WrappedProperty
+{
+public:
+ WrappedSegmentOffsetProperty();
+
+protected:
+ virtual Any convertInnerToOuterValue( const Any& rInnerValue ) const override;
+ virtual Any convertOuterToInnerValue( const Any& rOuterValue ) const override;
+};
+
+WrappedSegmentOffsetProperty::WrappedSegmentOffsetProperty() :
+ WrappedProperty("SegmentOffset","Offset")
+{}
+
+Any WrappedSegmentOffsetProperty::convertInnerToOuterValue( const Any& rInnerValue ) const
+{
+ // convert new double offset to former integer segment-offset
+ double fOffset = 0;
+ Any aResult( rInnerValue );
+
+ if( rInnerValue >>= fOffset )
+ aResult <<= static_cast< sal_Int32 >( ::rtl::math::round( fOffset * 100.0 ));
+
+ return aResult;
+}
+
+Any WrappedSegmentOffsetProperty::convertOuterToInnerValue( const Any& rOuterValue ) const
+{
+ // convert former integer segment-offset to new double offset
+ sal_Int32 nOffset = 0;
+ Any aResult( rOuterValue );
+
+ if( rOuterValue >>= nOffset )
+ aResult <<= static_cast< double >( nOffset ) / 100.0;
+
+ return aResult;
+}
+
+class WrappedLineColorProperty : public WrappedSeriesAreaOrLineProperty
+{
+public:
+ explicit WrappedLineColorProperty( DataSeriesPointWrapper* pDataSeriesPointWrapper );
+
+ virtual void setPropertyValue( const Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual void setPropertyToDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+protected:
+ DataSeriesPointWrapper* m_pDataSeriesPointWrapper;
+ mutable Any m_aDefaultValue;
+};
+
+WrappedLineColorProperty::WrappedLineColorProperty(
+ DataSeriesPointWrapper* pDataSeriesPointWrapper )
+ : WrappedSeriesAreaOrLineProperty("LineColor","BorderColor","Color", pDataSeriesPointWrapper )
+ , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper )
+ , m_aDefaultValue(uno::Any(sal_Int32( 0x0099ccff ))) // blue 8
+{
+}
+
+void WrappedLineColorProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ if( !m_pDataSeriesPointWrapper || !m_pDataSeriesPointWrapper->isLinesForbidden() )
+ WrappedSeriesAreaOrLineProperty::setPropertyValue( rOuterValue, xInnerPropertySet );
+}
+
+void WrappedLineColorProperty::setPropertyToDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
+{
+ if( !m_pDataSeriesPointWrapper || !m_pDataSeriesPointWrapper->isLinesForbidden() )
+ WrappedSeriesAreaOrLineProperty::setPropertyToDefault( xInnerPropertyState );
+}
+
+Any WrappedLineColorProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
+{
+ if( m_pDataSeriesPointWrapper && !m_pDataSeriesPointWrapper->isSupportingAreaProperties() )
+ return m_aDefaultValue;
+ else
+ return WrappedSeriesAreaOrLineProperty::getPropertyDefault( xInnerPropertyState );
+}
+
+class WrappedLineStyleProperty : public WrappedSeriesAreaOrLineProperty
+{
+public:
+ explicit WrappedLineStyleProperty( DataSeriesPointWrapper* pDataSeriesPointWrapper );
+
+ virtual void setPropertyValue( const Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual void setPropertyToDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+protected:
+ DataSeriesPointWrapper* m_pDataSeriesPointWrapper;
+};
+
+WrappedLineStyleProperty::WrappedLineStyleProperty(
+ DataSeriesPointWrapper* pDataSeriesPointWrapper )
+ : WrappedSeriesAreaOrLineProperty("LineStyle","BorderStyle", "LineStyle", pDataSeriesPointWrapper )
+ , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper )
+{
+}
+
+void WrappedLineStyleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ Any aNewValue(rOuterValue);
+ if( m_pDataSeriesPointWrapper && m_pDataSeriesPointWrapper->isLinesForbidden() )
+ {
+ aNewValue <<= drawing::LineStyle_NONE;
+ }
+ WrappedSeriesAreaOrLineProperty::setPropertyValue( aNewValue, xInnerPropertySet );
+}
+
+void WrappedLineStyleProperty::setPropertyToDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
+{
+ if( !m_pDataSeriesPointWrapper || !m_pDataSeriesPointWrapper->isLinesForbidden() )
+ WrappedSeriesAreaOrLineProperty::setPropertyToDefault( xInnerPropertyState );
+}
+
+} // anonymous namespace
+
+namespace chart::wrapper
+{
+
+DataSeriesPointWrapper::DataSeriesPointWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : m_spChart2ModelContact( spChart2ModelContact )
+ , m_aEventListenerContainer( m_aMutex )
+ , m_eType( DATA_SERIES )
+ , m_nSeriesIndexInNewAPI( -1 )
+ , m_nPointIndex( -1 )
+ , m_bLinesAllowed(true)
+{
+ //need initialize call afterwards
+}
+
+void SAL_CALL DataSeriesPointWrapper::initialize( const uno::Sequence< uno::Any >& aArguments )
+{
+ OSL_PRECOND(aArguments.hasElements(),"need at least 1 argument to initialize the DataSeriesPointWrapper: series reference + optional datapoint index");
+
+ m_nSeriesIndexInNewAPI = -1;//ignored in this case
+ m_nPointIndex = -1;
+ if( aArguments.hasElements() )
+ {
+ aArguments[0] >>= m_xDataSeries;
+ if( aArguments.getLength() >= 2 )
+ aArguments[1] >>= m_nPointIndex;
+ }
+
+ if( !m_xDataSeries.is() )
+ throw uno::Exception(
+ "DataSeries index invalid", static_cast< ::cppu::OWeakObject * >( this ));
+
+ //todo: check upper border of point index
+
+ if( m_nPointIndex >= 0 )
+ m_eType = DATA_POINT;
+ else
+ m_eType = DATA_SERIES;
+}
+
+DataSeriesPointWrapper::DataSeriesPointWrapper(eType _eType,
+ sal_Int32 nSeriesIndexInNewAPI ,
+ sal_Int32 nPointIndex, //ignored for series
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : m_spChart2ModelContact( spChart2ModelContact )
+ , m_aEventListenerContainer( m_aMutex )
+ , m_eType( _eType )
+ , m_nSeriesIndexInNewAPI( nSeriesIndexInNewAPI )
+ , m_nPointIndex( (_eType == DATA_POINT) ? nPointIndex : -1 )
+ , m_bLinesAllowed( false )
+{
+}
+
+DataSeriesPointWrapper::~DataSeriesPointWrapper()
+{
+}
+
+// ____ XComponent ____
+void SAL_CALL DataSeriesPointWrapper::dispose()
+{
+ uno::Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+
+ m_xDataSeries.clear();
+ clearWrappedPropertySet();
+}
+
+void SAL_CALL DataSeriesPointWrapper::addEventListener(
+ const uno::Reference< lang::XEventListener >& xListener )
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL DataSeriesPointWrapper::removeEventListener(
+ const uno::Reference< lang::XEventListener >& aListener )
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+// ____ XEventListener ____
+void SAL_CALL DataSeriesPointWrapper::disposing( const lang::EventObject& /*Source*/ )
+{
+}
+
+bool DataSeriesPointWrapper::isSupportingAreaProperties()
+{
+ Reference< chart2::XDataSeries > xSeries( getDataSeries() );
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
+ sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
+
+ return ChartTypeHelper::isSupportingAreaProperties( xChartType, nDimensionCount );
+}
+
+Reference< chart2::XDataSeries > DataSeriesPointWrapper::getDataSeries()
+{
+ Reference< chart2::XDataSeries > xSeries( m_xDataSeries );
+ if( !xSeries.is() )
+ {
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
+ ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+
+ if( m_nSeriesIndexInNewAPI >= 0 && m_nSeriesIndexInNewAPI < static_cast<sal_Int32>(aSeriesList.size()) )
+ xSeries = aSeriesList[m_nSeriesIndexInNewAPI];
+ }
+
+ return xSeries;
+}
+
+Reference< beans::XPropertySet > DataSeriesPointWrapper::getDataPointProperties()
+{
+ Reference< beans::XPropertySet > xPointProp;
+
+ Reference< chart2::XDataSeries > xSeries( getDataSeries() );
+
+ // may throw an IllegalArgumentException
+ if( xSeries.is() )
+ xPointProp = xSeries->getDataPointByIndex( m_nPointIndex );
+
+ return xPointProp;
+}
+
+//ReferenceSizePropertyProvider
+void DataSeriesPointWrapper::updateReferenceSize()
+{
+ Reference< beans::XPropertySet > xProp = getInnerPropertySet();
+ if( xProp.is() )
+ {
+ if( xProp->getPropertyValue("ReferencePageSize").hasValue() )
+ xProp->setPropertyValue("ReferencePageSize", uno::Any(
+ m_spChart2ModelContact->GetPageSize() ));
+ }
+}
+Any DataSeriesPointWrapper::getReferenceSize()
+{
+ Any aRet;
+ Reference< beans::XPropertySet > xProp = getInnerPropertySet();
+ if( xProp.is() )
+ aRet = xProp->getPropertyValue("ReferencePageSize");
+ return aRet;
+}
+awt::Size DataSeriesPointWrapper::getCurrentSizeForReference()
+{
+ return m_spChart2ModelContact->GetPageSize();
+}
+
+// WrappedPropertySet
+
+//XPropertyState
+beans::PropertyState SAL_CALL DataSeriesPointWrapper::getPropertyState( const OUString& rPropertyName )
+{
+ beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE );
+ try
+ {
+ if (rPropertyName == "SymbolBitmap" || rPropertyName == "SymbolBitmapURL")
+ {
+ uno::Any aAny = WrappedPropertySet::getPropertyValue("SymbolType");
+ sal_Int32 nVal = css::chart::ChartSymbolType::NONE;
+ if (aAny >>= nVal)
+ {
+ if (nVal != css::chart::ChartSymbolType::BITMAPURL)
+ return beans::PropertyState::PropertyState_DEFAULT_VALUE;
+ }
+ }
+
+ if( m_eType == DATA_SERIES )
+ aState = WrappedPropertySet::getPropertyState( rPropertyName );
+ else
+ {
+ if( rPropertyName == "FillColor")
+ {
+ Reference< beans::XPropertySet > xSeriesProp( getDataSeries(), uno::UNO_QUERY );
+ bool bVaryColorsByPoint = false;
+ if( xSeriesProp.is() && (xSeriesProp->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint)
+ && bVaryColorsByPoint )
+ return beans::PropertyState_DIRECT_VALUE;
+ }
+ else if( rPropertyName == "Lines"
+ || rPropertyName == "SymbolType"
+ || rPropertyName == "SymbolSize" )
+ return WrappedPropertySet::getPropertyState( rPropertyName );
+
+ uno::Any aDefault( getPropertyDefault( rPropertyName ) );
+ uno::Any aValue( getPropertyValue( rPropertyName ) );
+ if( aDefault==aValue )
+ aState = beans::PropertyState_DEFAULT_VALUE;
+ }
+ }
+ catch( const beans::UnknownPropertyException& )
+ {
+ throw;
+ }
+ catch( const uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch( const lang::WrappedTargetException& e )
+ {
+ css::uno::Any a(e.TargetException);
+ throw css::lang::WrappedTargetRuntimeException(
+ "wrapped Exception " + e.Message,
+ css::uno::Reference<css::uno::XInterface>(), a);
+ }
+ catch( const uno::Exception& e )
+ {
+ css::uno::Any a(cppu::getCaughtException());
+ throw css::lang::WrappedTargetRuntimeException(
+ "wrapped Exception " + e.Message,
+ css::uno::Reference<css::uno::XInterface>(), a);
+ }
+ return aState;
+}
+
+void SAL_CALL DataSeriesPointWrapper::setPropertyToDefault( const OUString& rPropertyName )
+{
+ if( m_eType == DATA_SERIES )
+ WrappedPropertySet::setPropertyToDefault( rPropertyName );
+ else
+ {
+ //for data points the default is given by the series
+ setPropertyValue( rPropertyName, getPropertyDefault( rPropertyName ) );
+ }
+}
+Any SAL_CALL DataSeriesPointWrapper::getPropertyDefault( const OUString& rPropertyName )
+{
+ Any aRet;
+ try
+ {
+ sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
+ if( nHandle > 0 )
+ {
+ //always take the series current value as default for points
+ Reference< beans::XPropertySet > xInnerPropertySet( getDataSeries(), uno::UNO_QUERY );
+ if( xInnerPropertySet.is() )
+ {
+ const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
+ if( pWrappedProperty )
+ aRet = pWrappedProperty->getPropertyValue(xInnerPropertySet);
+ else
+ aRet = xInnerPropertySet->getPropertyValue( rPropertyName );
+ }
+ }
+ }
+ catch( const beans::UnknownPropertyException& )
+ {
+ aRet = WrappedPropertySet::getPropertyDefault( rPropertyName );
+ }
+ return aRet;
+}
+
+Reference< beans::XPropertySet > DataSeriesPointWrapper::getInnerPropertySet()
+{
+ if( m_eType == DATA_SERIES )
+ return Reference< beans::XPropertySet >( getDataSeries(), uno::UNO_QUERY );
+ return getDataPointProperties();
+}
+
+const Sequence< beans::Property >& DataSeriesPointWrapper::getPropertySequence()
+{
+ if( m_eType == DATA_SERIES )
+ return *StaticSeriesWrapperPropertyArray::get();
+ else
+ return *StaticPointWrapperPropertyArray::get();
+}
+
+std::vector< std::unique_ptr<WrappedProperty> > DataSeriesPointWrapper::createWrappedProperties()
+{
+ std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
+
+ WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this );
+
+ if( m_eType == DATA_SERIES )
+ {
+ WrappedStatisticProperties::addWrappedPropertiesForSeries( aWrappedProperties, m_spChart2ModelContact );
+ aWrappedProperties.emplace_back( new WrappedAttachedAxisProperty( m_spChart2ModelContact ) );
+
+ aWrappedProperties.emplace_back( new WrappedNumberFormatProperty(m_spChart2ModelContact) );
+ aWrappedProperties.emplace_back( new WrappedLinkNumberFormatProperty );
+ }
+
+ WrappedSymbolProperties::addWrappedPropertiesForSeries( aWrappedProperties, m_spChart2ModelContact );
+ WrappedDataCaptionProperties::addWrappedPropertiesForSeries( aWrappedProperties, m_spChart2ModelContact );
+ WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
+
+ //add unnamed line properties (different inner names here)
+
+ aWrappedProperties.emplace_back( new WrappedProperty("FillColor","Color") );
+ aWrappedProperties.emplace_back( new WrappedLineStyleProperty( this ) );
+ aWrappedProperties.emplace_back( new WrappedLineColorProperty( this ) );
+ aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty("LineDashName","BorderDashName","LineDashName", this ) );
+ aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty("LineTransparence","BorderTransparency","Transparency", this ) );
+ aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty("LineWidth","BorderWidth","LineWidth", this ) );
+ aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty("LineCap","LineCap","LineCap", this ) );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillStyle","FillStyle" ) );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillTransparence","Transparency") );
+
+ aWrappedProperties.emplace_back( new WrappedIgnoreProperty("LineJoint", uno::Any( drawing::LineJoint_ROUND ) ) );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillTransparenceGradientName","TransparencyGradientName") );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillGradientName","GradientName") );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillGradientStepCount","GradientStepCount") );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillHatchName","HatchName") );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapName","FillBitmapName") );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillBackground","FillBackground") );
+
+ //bitmap properties
+ aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapMode","FillBitmapMode") );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapSizeX","FillBitmapSizeX") );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapSizeY","FillBitmapSizeY") );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapLogicalSize","FillBitmapLogicalSize") );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapOffsetX","FillBitmapOffsetX") );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapOffsetY","FillBitmapOffsetY") );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapRectanglePoint","FillBitmapRectanglePoint") );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapPositionOffsetX","FillBitmapPositionOffsetX") );
+ aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapPositionOffsetY","FillBitmapPositionOffsetY") );
+
+ aWrappedProperties.emplace_back( new WrappedProperty("SolidType","Geometry3D") );
+ aWrappedProperties.emplace_back( new WrappedSegmentOffsetProperty() );
+ aWrappedProperties.emplace_back( new WrappedProperty("D3DPercentDiagonal","PercentDiagonal") );
+
+ aWrappedProperties.emplace_back( new WrappedTextRotationProperty() );
+
+ return aWrappedProperties;
+}
+
+void SAL_CALL DataSeriesPointWrapper::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
+{
+ if(rPropertyName == "Lines")
+ {
+ if( ! (rValue >>= m_bLinesAllowed) )
+ throw lang::IllegalArgumentException("Property Lines requires value of type sal_Bool", nullptr, 0 );
+ }
+
+ sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
+ static const sal_Int32 nErrorCategoryHandle = getInfoHelper().getHandleByName("ErrorCategory");
+ if( nErrorCategoryHandle == nHandle )
+ {
+ css::chart::ChartErrorCategory aNewValue = css::chart::ChartErrorCategory_NONE;
+ rValue >>= aNewValue;
+ Any aLow, aHigh;
+ bool bSetHighAndLowValues = false;
+ switch(aNewValue)
+ {
+ case css::chart::ChartErrorCategory_CONSTANT_VALUE:
+ aHigh = getPropertyValue("ConstantErrorHigh");
+ aLow = getPropertyValue("ConstantErrorLow");
+ bSetHighAndLowValues = true;
+ break;
+ case css::chart::ChartErrorCategory_PERCENT:
+ aHigh = aLow = getPropertyValue("PercentageError");
+ bSetHighAndLowValues = true;
+ break;
+ case css::chart::ChartErrorCategory_ERROR_MARGIN:
+ aHigh = aLow = getPropertyValue("ErrorMargin");
+ bSetHighAndLowValues = true;
+ break;
+ default:
+ break;
+ }
+
+ WrappedPropertySet::setPropertyValue( rPropertyName, rValue );
+
+ if(bSetHighAndLowValues)
+ {
+ switch(aNewValue)
+ {
+ case css::chart::ChartErrorCategory_CONSTANT_VALUE:
+ setPropertyValue("ConstantErrorHigh",aHigh);
+ setPropertyValue("ConstantErrorLow",aLow);
+ break;
+ case css::chart::ChartErrorCategory_PERCENT:
+ setPropertyValue("PercentageError",aHigh);
+ break;
+ case css::chart::ChartErrorCategory_ERROR_MARGIN:
+ setPropertyValue("ErrorMargin",aHigh);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ else
+ WrappedPropertySet::setPropertyValue( rPropertyName, rValue );
+}
+
+Any SAL_CALL DataSeriesPointWrapper::getPropertyValue( const OUString& rPropertyName )
+{
+ if( m_eType == DATA_POINT )
+ {
+ if( rPropertyName == "FillColor" )
+ {
+ Reference< beans::XPropertySet > xSeriesProp( getDataSeries(), uno::UNO_QUERY );
+ bool bVaryColorsByPoint = false;
+ if( xSeriesProp.is() && (xSeriesProp->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint)
+ && bVaryColorsByPoint )
+ {
+ uno::Reference< beans::XPropertyState > xPointState( DataSeriesPointWrapper::getDataPointProperties(), uno::UNO_QUERY );
+ if( xPointState.is() && xPointState->getPropertyState("Color") == beans::PropertyState_DEFAULT_VALUE )
+ {
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( xDiagram.is() )
+ {
+ Reference< chart2::XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme() );
+ if( xColorScheme.is() )
+ return uno::Any( xColorScheme->getColorByIndex( m_nPointIndex ) );
+ }
+ }
+ }
+ }
+ }
+ return WrappedPropertySet::getPropertyValue( rPropertyName );
+}
+
+OUString SAL_CALL DataSeriesPointWrapper::getImplementationName()
+{
+ return "com.sun.star.comp.chart.DataSeries";
+}
+
+sal_Bool SAL_CALL DataSeriesPointWrapper::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL DataSeriesPointWrapper::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart.ChartDataRowProperties",
+ "com.sun.star.chart.ChartDataPointProperties",
+ "com.sun.star.xml.UserDefinedAttributesSupplier",
+ "com.sun.star.beans.PropertySet",
+ "com.sun.star.drawing.FillProperties",
+ "com.sun.star.drawing.LineProperties",
+ "com.sun.star.style.CharacterProperties"
+ };
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx
new file mode 100644
index 000000000..98317470c
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx
@@ -0,0 +1,131 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_DATASERIESPOINTWRAPPER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_DATASERIESPOINTWRAPPER_HXX
+
+#include <WrappedPropertySet.hxx>
+#include "ReferenceSizePropertyProvider.hxx"
+#include <cppuhelper/implbase.hxx>
+#include <comphelper/interfacecontainer2.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <memory>
+
+namespace com::sun::star::chart2 { class XDataSeries; }
+
+namespace chart
+{
+
+namespace wrapper
+{
+
+class Chart2ModelContact;
+
+class DataSeriesPointWrapper final : public ::cppu::ImplInheritanceHelper<
+ WrappedPropertySet
+ , css::lang::XServiceInfo
+ , css::lang::XInitialization
+ , css::lang::XComponent
+ , css::lang::XEventListener
+ >
+ , public ReferenceSizePropertyProvider
+
+{
+public:
+ enum eType
+ {
+ DATA_SERIES,
+ DATA_POINT
+ };
+
+ //this constructor needs an initialize call afterwards
+ explicit DataSeriesPointWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ DataSeriesPointWrapper(eType eType
+ , sal_Int32 nSeriesIndexInNewAPI
+ , sal_Int32 nPointIndex //ignored for series
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual ~DataSeriesPointWrapper() override;
+
+ bool isSupportingAreaProperties();
+ bool isLinesForbidden() const { return !m_bLinesAllowed;}
+
+ /// XServiceInfo declarations
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ // ___lang::XInitialization___
+ virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
+
+ //ReferenceSizePropertyProvider
+ virtual void updateReferenceSize() override;
+ virtual css::uno::Any getReferenceSize() override;
+ virtual css::awt::Size getCurrentSizeForReference() override;
+
+private:
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose() override;
+ virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
+ virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
+
+ // ____ XEventListener ____
+ virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
+
+ // ____ WrappedPropertySet ____
+ virtual const css::uno::Sequence< css::beans::Property >& getPropertySequence() override;
+ virtual std::vector< std::unique_ptr<WrappedProperty> > createWrappedProperties() override;
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
+ virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
+ virtual css::uno::Reference< css::beans::XPropertySet > getInnerPropertySet() override;
+
+ virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
+ virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
+ virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
+
+ //own methods
+ css::uno::Reference< css::chart2::XDataSeries > getDataSeries();
+ css::uno::Reference< css::beans::XPropertySet > getDataPointProperties();
+
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer;
+
+ eType m_eType;
+ sal_Int32 m_nSeriesIndexInNewAPI;
+ sal_Int32 m_nPointIndex;
+
+ bool m_bLinesAllowed;
+
+ //this should only be used, if the DataSeriesPointWrapper is initialized via the XInitialize interface
+ //because a big change in the chartmodel may lead to a dataseriespointer that is not connected to the model anymore
+ //with the indices instead we can always get the new dataseries
+ css::uno::Reference< css::chart2::XDataSeries > m_xDataSeries;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_DATASERIESPOINTWRAPPER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
new file mode 100644
index 000000000..aa12dbc27
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx
@@ -0,0 +1,1930 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "DiagramWrapper.hxx"
+#include <servicenames_charttypes.hxx>
+#include "DataSeriesPointWrapper.hxx"
+#include "AxisWrapper.hxx"
+#include "Chart2ModelContact.hxx"
+#include "WallFloorWrapper.hxx"
+#include "MinMaxLineWrapper.hxx"
+#include "UpDownBarWrapper.hxx"
+#include <DiagramHelper.hxx>
+#include <DataSourceHelper.hxx>
+#include <ChartModelHelper.hxx>
+#include <WrappedIgnoreProperty.hxx>
+#include "WrappedAxisAndGridExistenceProperties.hxx"
+#include "WrappedStatisticProperties.hxx"
+#include "WrappedSymbolProperties.hxx"
+#include "WrappedDataCaptionProperties.hxx"
+#include "WrappedSplineProperties.hxx"
+#include "WrappedStockProperties.hxx"
+#include "WrappedSceneProperty.hxx"
+#include <ControllerLockGuard.hxx>
+#include <DisposeHelper.hxx>
+#include "WrappedAutomaticPositionProperties.hxx"
+#include <CommonConverters.hxx>
+#include <unonames.hxx>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/chart2/RelativeSize.hpp>
+#include <com/sun/star/chart2/RelativePosition.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart/ChartSolidType.hpp>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <UserDefinedProperties.hxx>
+#include <SceneProperties.hxx>
+
+#include <algorithm>
+#include <map>
+#include <com/sun/star/lang/XServiceName.hpp>
+#include <com/sun/star/util/XRefreshable.hpp>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using namespace ::chart::wrapper;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::chart::XAxis;
+using ::osl::MutexGuard;
+
+namespace
+{
+
+enum
+{
+ PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS,
+ PROP_DIAGRAM_PERCENT_STACKED,
+ PROP_DIAGRAM_STACKED,
+ PROP_DIAGRAM_THREE_D,
+ PROP_DIAGRAM_SOLIDTYPE,
+ PROP_DIAGRAM_DEEP,
+ PROP_DIAGRAM_VERTICAL,
+ PROP_DIAGRAM_NUMBER_OF_LINES,
+ PROP_DIAGRAM_STACKED_BARS_CONNECTED,
+ PROP_DIAGRAM_DATAROW_SOURCE,
+
+ PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
+ PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS,
+
+ PROP_DIAGRAM_SORT_BY_X_VALUES,
+
+ PROP_DIAGRAM_STARTING_ANGLE,
+
+ PROP_DIAGRAM_RIGHT_ANGLED_AXES,
+ PROP_DIAGRAM_PERSPECTIVE,
+ PROP_DIAGRAM_ROTATION_HORIZONTAL,
+ PROP_DIAGRAM_ROTATION_VERTICAL,
+
+ PROP_DIAGRAM_MISSING_VALUE_TREATMENT,
+
+ PROP_DIAGRAM_HAS_X_AXIS,
+ PROP_DIAGRAM_HAS_X_AXIS_DESCR,
+ PROP_DIAGRAM_HAS_X_AXIS_TITLE,
+ PROP_DIAGRAM_HAS_X_AXIS_GRID,
+ PROP_DIAGRAM_HAS_X_AXIS_HELP_GRID,
+
+ PROP_DIAGRAM_HAS_Y_AXIS,
+ PROP_DIAGRAM_HAS_Y_AXIS_DESCR,
+ PROP_DIAGRAM_HAS_Y_AXIS_TITLE,
+ PROP_DIAGRAM_HAS_Y_AXIS_GRID,
+ PROP_DIAGRAM_HAS_Y_AXIS_HELP_GRID,
+
+ PROP_DIAGRAM_HAS_Z_AXIS,
+ PROP_DIAGRAM_HAS_Z_AXIS_DESCR,
+ PROP_DIAGRAM_HAS_Z_AXIS_TITLE,
+ PROP_DIAGRAM_HAS_Z_AXIS_GRID,
+ PROP_DIAGRAM_HAS_Z_AXIS_HELP_GRID,
+
+ PROP_DIAGRAM_HAS_SECOND_X_AXIS,
+ PROP_DIAGRAM_HAS_SECOND_X_AXIS_DESCR,
+
+ PROP_DIAGRAM_HAS_SECOND_Y_AXIS,
+ PROP_DIAGRAM_HAS_SECOND_Y_AXIS_DESCR,
+
+ PROP_DIAGRAM_HAS_SECOND_X_AXIS_TITLE,
+ PROP_DIAGRAM_HAS_SECOND_Y_AXIS_TITLE,
+
+ PROP_DIAGRAM_AUTOMATIC_SIZE,
+ PROP_DIAGRAM_DATATABLEHBORDER,
+ PROP_DIAGRAM_DATATABLEVBORDER,
+ PROP_DIAGRAM_DATATABLEOUTLINE,
+ PROP_DIAGRAM_EXTERNALDATA
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "AttributedDataPoints",
+ PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS,
+ cppu::UnoType<uno::Sequence< uno::Sequence< sal_Int32 > >>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ // see com.sun.star.chart.StackableDiagram
+ rOutProperties.emplace_back( "Percent",
+ PROP_DIAGRAM_PERCENT_STACKED,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "Stacked",
+ PROP_DIAGRAM_STACKED,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "Dim3D",
+ PROP_DIAGRAM_THREE_D,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // see com.sun.star.chart.Chart3DBarProperties
+ rOutProperties.emplace_back( "SolidType",
+ PROP_DIAGRAM_SOLIDTYPE,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // see com.sun.star.chart.BarDiagram
+ rOutProperties.emplace_back( "Deep",
+ PROP_DIAGRAM_DEEP,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "Vertical",
+ PROP_DIAGRAM_VERTICAL,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "NumberOfLines",
+ PROP_DIAGRAM_NUMBER_OF_LINES,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "StackedBarsConnected",
+ PROP_DIAGRAM_STACKED_BARS_CONNECTED,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "DataRowSource",
+ PROP_DIAGRAM_DATAROW_SOURCE,
+ cppu::UnoType<css::chart::ChartDataRowSource>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "GroupBarsPerAxis",
+ PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "IncludeHiddenCells",
+ PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ //new for XY charts
+ rOutProperties.emplace_back( CHART_UNONAME_SORT_BY_XVALUES,
+ PROP_DIAGRAM_SORT_BY_X_VALUES,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ //for pie and donut charts
+ rOutProperties.emplace_back( "StartingAngle",
+ PROP_DIAGRAM_STARTING_ANGLE,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ //new for 3D charts
+ rOutProperties.emplace_back( "RightAngledAxes",
+ PROP_DIAGRAM_RIGHT_ANGLED_AXES,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "Perspective",
+ PROP_DIAGRAM_PERSPECTIVE,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "RotationHorizontal",
+ PROP_DIAGRAM_ROTATION_HORIZONTAL,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "RotationVertical",
+ PROP_DIAGRAM_ROTATION_VERTICAL,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
+
+ // XAxisXSupplier
+ rOutProperties.emplace_back( "HasXAxis",
+ PROP_DIAGRAM_HAS_X_AXIS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasXAxisDescription",
+ PROP_DIAGRAM_HAS_X_AXIS_DESCR,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasXAxisTitle",
+ PROP_DIAGRAM_HAS_X_AXIS_TITLE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasXAxisGrid",
+ PROP_DIAGRAM_HAS_X_AXIS_GRID,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasXAxisHelpGrid",
+ PROP_DIAGRAM_HAS_X_AXIS_HELP_GRID,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // XAxisYSupplier
+ rOutProperties.emplace_back( "HasYAxis",
+ PROP_DIAGRAM_HAS_Y_AXIS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasYAxisDescription",
+ PROP_DIAGRAM_HAS_Y_AXIS_DESCR,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasYAxisTitle",
+ PROP_DIAGRAM_HAS_Y_AXIS_TITLE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasYAxisGrid",
+ PROP_DIAGRAM_HAS_Y_AXIS_GRID,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasYAxisHelpGrid",
+ PROP_DIAGRAM_HAS_Y_AXIS_HELP_GRID,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // XAxisZSupplier
+ rOutProperties.emplace_back( "HasZAxis",
+ PROP_DIAGRAM_HAS_Z_AXIS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasZAxisDescription",
+ PROP_DIAGRAM_HAS_Z_AXIS_DESCR,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasZAxisTitle",
+ PROP_DIAGRAM_HAS_Z_AXIS_TITLE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasZAxisGrid",
+ PROP_DIAGRAM_HAS_Z_AXIS_GRID,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasZAxisHelpGrid",
+ PROP_DIAGRAM_HAS_Z_AXIS_HELP_GRID,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // XTwoAxisXSupplier
+ rOutProperties.emplace_back( "HasSecondaryXAxis",
+ PROP_DIAGRAM_HAS_SECOND_X_AXIS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasSecondaryXAxisDescription",
+ PROP_DIAGRAM_HAS_SECOND_X_AXIS_DESCR,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // XTwoAxisYSupplier
+ rOutProperties.emplace_back( "HasSecondaryYAxis",
+ PROP_DIAGRAM_HAS_SECOND_Y_AXIS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasSecondaryYAxisDescription",
+ PROP_DIAGRAM_HAS_SECOND_Y_AXIS_DESCR,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // XSecondAxisTitleSupplier
+ rOutProperties.emplace_back( "HasSecondaryXAxisTitle",
+ PROP_DIAGRAM_HAS_SECOND_X_AXIS_TITLE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "HasSecondaryYAxisTitle",
+ PROP_DIAGRAM_HAS_SECOND_Y_AXIS_TITLE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "MissingValueTreatment",
+ PROP_DIAGRAM_MISSING_VALUE_TREATMENT,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "AutomaticSize",
+ PROP_DIAGRAM_AUTOMATIC_SIZE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "DataTableHBorder",
+ PROP_DIAGRAM_DATATABLEHBORDER,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "DataTableVBorder",
+ PROP_DIAGRAM_DATATABLEVBORDER,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "DataTableOutline",
+ PROP_DIAGRAM_DATATABLEOUTLINE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "ExternalData",
+ PROP_DIAGRAM_EXTERNALDATA,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+}
+
+struct StaticDiagramWrapperPropertyArray_Initializer
+{
+ Sequence< Property >* operator()()
+ {
+ static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
+ return &aPropSeq;
+ }
+
+private:
+ static uno::Sequence< Property > lcl_GetPropertySequence()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+ ::chart::SceneProperties::AddPropertiesToVector( aProperties );
+ WrappedStatisticProperties::addProperties( aProperties );
+ WrappedSymbolProperties::addProperties( aProperties );
+ WrappedDataCaptionProperties::addProperties( aProperties );
+ WrappedSplineProperties::addProperties( aProperties );
+ WrappedStockProperties::addProperties( aProperties );
+ WrappedAutomaticPositionProperties::addProperties( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+};
+
+struct StaticDiagramWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticDiagramWrapperPropertyArray_Initializer >
+{
+};
+
+bool lcl_isXYChart( const Reference< chart2::XDiagram >& rDiagram )
+{
+ bool bRet = false;
+ Reference< chart2::XChartType > xChartType( ::chart::DiagramHelper::getChartTypeByIndex( rDiagram, 0 ) );
+ if( xChartType.is() )
+ {
+ OUString aChartType( xChartType->getChartType() );
+ if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) )
+ bRet = true;
+ }
+ return bRet;
+}
+
+sal_Int32 lcl_getNewAPIIndexForOldAPIIndex(
+ sal_Int32 nOldAPIIndex
+ , const Reference< chart2::XDiagram >& xDiagram )
+{
+ sal_Int32 nNewAPIIndex = nOldAPIIndex;
+
+ if( lcl_isXYChart( xDiagram ) )
+ {
+ if( nNewAPIIndex >= 1 )
+ nNewAPIIndex -= 1;
+ }
+
+ std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList(
+ ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+ if( nNewAPIIndex >= static_cast<sal_Int32>(aSeriesList.size()) )
+ nNewAPIIndex = -1;
+
+ return nNewAPIIndex;
+}
+
+OUString lcl_getDiagramType( const OUString & rTemplateServiceName )
+{
+ const OUString aPrefix("com.sun.star.chart2.template.");
+
+ if( rTemplateServiceName.match( aPrefix ))
+ {
+ const OUString aName( rTemplateServiceName.copy( aPrefix.getLength()));
+
+ // "Area" "StackedArea" "PercentStackedArea" "ThreeDArea"
+ // "StackedThreeDArea" "PercentStackedThreeDArea"
+ if( aName.indexOf( "Area" ) != -1 )
+ return "com.sun.star.chart.AreaDiagram";
+
+ // "Pie" "PieAllExploded" "ThreeDPie" "ThreeDPieAllExploded"
+ if( aName.indexOf( "Pie" ) != -1 )
+ return "com.sun.star.chart.PieDiagram";
+
+ // "Column" "StackedColumn" "PercentStackedColumn" "ThreeDColumnDeep"
+ // "ThreeDColumnFlat" "StackedThreeDColumnFlat"
+ // "PercentStackedThreeDColumnFlat" "Bar" "StackedBar"
+ // "PercentStackedBar" "ThreeDBarDeep" "ThreeDBarFlat"
+ // "StackedThreeDBarFlat" "PercentStackedThreeDBarFlat" "ColumnWithLine"
+ // "StackedColumnWithLine"
+ if( aName.indexOf( "Column" ) != -1 || aName.indexOf( "Bar" ) != -1 )
+ return "com.sun.star.chart.BarDiagram";
+
+ // "Donut" "DonutAllExploded" "ThreeDDonut" "ThreeDDonutAllExploded"
+ if( aName.indexOf( "Donut" ) != -1 )
+ return "com.sun.star.chart.DonutDiagram";
+
+ // "ScatterLineSymbol" "ScatterLine" "ScatterSymbol" "ThreeDScatter"
+ if( aName.indexOf( "Scatter" ) != -1 )
+ return "com.sun.star.chart.XYDiagram";
+
+ // "FilledNet" "StackedFilledNet" "PercentStackedFilledNet"
+ if( aName.indexOf( "FilledNet" ) != -1 )
+ return "com.sun.star.chart.FilledNetDiagram";
+
+ // "Net" "NetSymbol" "NetLine" "StackedNet" "StackedNetSymbol"
+ // "StackedNetLine" "PercentStackedNet" "PercentStackedNetSymbol"
+ // "PercentStackedNetLine"
+ if( aName.indexOf( "Net" ) != -1 )
+ return "com.sun.star.chart.NetDiagram";
+
+ // "StockLowHighClose" "StockOpenLowHighClose" "StockVolumeLowHighClose"
+ // "StockVolumeOpenLowHighClose"
+ if( aName.indexOf( "Stock" ) != -1 )
+ return "com.sun.star.chart.StockDiagram";
+
+ if( aName.indexOf( "Bubble" ) != -1 )
+ return "com.sun.star.chart.BubbleDiagram";
+
+ // Note: this must be checked after Bar, Net and Scatter
+
+ // "Symbol" "StackedSymbol" "PercentStackedSymbol" "Line" "StackedLine"
+ // "PercentStackedLine" "LineSymbol" "StackedLineSymbol"
+ // "PercentStackedLineSymbol" "ThreeDLine" "StackedThreeDLine"
+ // "PercentStackedThreeDLine" "ThreeDLineDeep"
+ if( aName.indexOf( "Line" ) != -1 || aName.indexOf( "Symbol" ) != -1 )
+ return "com.sun.star.chart.LineDiagram";
+
+ OSL_FAIL( "unknown template" );
+ }
+
+ return OUString();
+}
+
+typedef std::map< OUString, OUString > tMakeStringStringMap;
+
+const tMakeStringStringMap& lcl_getChartTypeNameMap()
+{
+ static tMakeStringStringMap g_aChartTypeNameMap{
+ {"com.sun.star.chart2.LineChartType", "com.sun.star.chart.LineDiagram"},
+ {"com.sun.star.chart2.AreaChartType", "com.sun.star.chart.AreaDiagram"},
+ {"com.sun.star.chart2.ColumnChartType", "com.sun.star.chart.BarDiagram"},
+ {"com.sun.star.chart2.PieChartType", "com.sun.star.chart.PieDiagram"},
+ {"com.sun.star.chart2.DonutChartType", "com.sun.star.chart.DonutDiagram"},
+ {"com.sun.star.chart2.ScatterChartType", "com.sun.star.chart.XYDiagram"},
+ {"com.sun.star.chart2.FilledNetChartType", "com.sun.star.chart.FilledNetDiagram"},
+ {"com.sun.star.chart2.NetChartType", "com.sun.star.chart.NetDiagram"},
+ {"com.sun.star.chart2.CandleStickChartType", "com.sun.star.chart.StockDiagram"},
+ {"com.sun.star.chart2.BubbleChartType", "com.sun.star.chart.BubbleDiagram"}
+ };
+ return g_aChartTypeNameMap;
+}
+
+OUString lcl_getOldChartTypeName( const OUString & rNewChartTypeName )
+{
+ OUString aOld(rNewChartTypeName);
+
+ const tMakeStringStringMap& rMap = lcl_getChartTypeNameMap();
+ tMakeStringStringMap::const_iterator aIt( rMap.find( rNewChartTypeName ));
+ if( aIt != rMap.end())
+ {
+ aOld = aIt->second;
+ }
+ return aOld;
+}
+
+} // anonymous namespace
+
+namespace chart::wrapper
+{
+
+DiagramWrapper::DiagramWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : m_spChart2ModelContact(spChart2ModelContact)
+ , m_aEventListenerContainer(m_aMutex)
+{
+}
+
+DiagramWrapper::~DiagramWrapper()
+{}
+
+// ____ XDiagram ____
+OUString SAL_CALL DiagramWrapper::getDiagramType()
+{
+ OUString aRet;
+
+ Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( xChartDoc.is() && xDiagram.is() )
+ {
+ Reference< beans::XPropertySet > xChartDocProp( xChartDoc, uno::UNO_QUERY );
+ if( xChartDocProp.is() )
+ {
+ uno::Reference< util::XRefreshable > xAddIn;
+ if( xChartDocProp->getPropertyValue( "AddIn" ) >>= xAddIn )
+ {
+ uno::Reference< lang::XServiceName > xServiceName( xAddIn, uno::UNO_QUERY );
+ if( xServiceName.is())
+ return xServiceName->getServiceName();
+ }
+ }
+
+ Reference< lang::XMultiServiceFactory > xChartTypeManager( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+ DiagramHelper::tTemplateWithServiceName aTemplateAndService =
+ DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager );
+
+ aRet = lcl_getDiagramType( aTemplateAndService.second );
+ }
+
+ if( aRet.isEmpty())
+ {
+ // none of the standard templates matched
+ // use first chart type
+ Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
+ if( xChartType.is() )
+ {
+ aRet = xChartType->getChartType();
+ if( !aRet.isEmpty() )
+ aRet = lcl_getOldChartTypeName( aRet );
+ }
+ if( aRet.isEmpty())
+ aRet = "com.sun.star.chart.BarDiagram";
+ }
+
+ return aRet;
+}
+
+Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getDataRowProperties( sal_Int32 nRow )
+{
+ if( nRow < 0 )
+ throw lang::IndexOutOfBoundsException("DataSeries index invalid",
+ static_cast< ::cppu::OWeakObject * >( this ));
+
+ sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getChart2Diagram() );
+ if( nNewAPIIndex < 0 )
+ throw lang::IndexOutOfBoundsException("DataSeries index invalid",
+ static_cast< ::cppu::OWeakObject * >( this ));
+
+ Reference< beans::XPropertySet > xRet( new DataSeriesPointWrapper(
+ DataSeriesPointWrapper::DATA_SERIES, nNewAPIIndex, 0, m_spChart2ModelContact ) );
+ return xRet;
+}
+
+Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getDataPointProperties( sal_Int32 nCol, sal_Int32 nRow )
+{
+ if( nCol < 0 || nRow < 0 )
+ throw lang::IndexOutOfBoundsException("DataSeries index invalid",
+ static_cast< ::cppu::OWeakObject * >( this ));
+
+ sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getChart2Diagram() );
+ if( nNewAPIIndex < 0 )
+ throw lang::IndexOutOfBoundsException("DataSeries index invalid",
+ static_cast< ::cppu::OWeakObject * >( this ));
+
+ //todo: check borders of point index
+
+ Reference< beans::XPropertySet > xRet( new DataSeriesPointWrapper(
+ DataSeriesPointWrapper::DATA_POINT, nNewAPIIndex, nCol, m_spChart2ModelContact ) );
+
+ return xRet;
+}
+
+// ____ XShape (base of XDiagram) ____
+awt::Point SAL_CALL DiagramWrapper::getPosition()
+{
+ awt::Point aPosition = ToPoint( m_spChart2ModelContact->GetDiagramRectangleIncludingAxes() );
+ return aPosition;
+}
+
+void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition )
+{
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+ Reference< beans::XPropertySet > xProp( getInnerPropertySet() );
+ if( !xProp.is() )
+ return;
+
+ awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() );
+
+ chart2::RelativePosition aRelativePosition;
+ aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT;
+ aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width);
+ aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height);
+ if( aRelativePosition.Primary < 0 || aRelativePosition.Secondary < 0 || aRelativePosition.Primary > 1 || aRelativePosition.Secondary > 1 )
+ {
+ OSL_FAIL("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" );
+ uno::Any aEmpty;
+ xProp->setPropertyValue( "RelativePosition", aEmpty );
+ return;
+ }
+ xProp->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition) );
+ xProp->setPropertyValue( "PosSizeExcludeAxes", uno::Any(false) );
+}
+
+awt::Size SAL_CALL DiagramWrapper::getSize()
+{
+ awt::Size aSize = ToSize( m_spChart2ModelContact->GetDiagramRectangleIncludingAxes() );
+ return aSize;
+}
+
+void SAL_CALL DiagramWrapper::setSize( const awt::Size& aSize )
+{
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+ Reference< beans::XPropertySet > xProp( getInnerPropertySet() );
+ if( !xProp.is() )
+ return;
+
+ awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() );
+
+ chart2::RelativeSize aRelativeSize;
+ aRelativeSize.Primary = double(aSize.Width)/double(aPageSize.Width);
+ aRelativeSize.Secondary = double(aSize.Height)/double(aPageSize.Height);
+
+ if( aRelativeSize.Primary > 1 || aRelativeSize.Secondary > 1 )
+ {
+ OSL_FAIL("DiagramWrapper::setSize called with sizes bigger than page -> automatic values are taken instead" );
+ uno::Any aEmpty;
+ xProp->setPropertyValue( "RelativeSize", aEmpty );
+ return;
+ }
+
+ xProp->setPropertyValue( "RelativeSize", uno::Any(aRelativeSize) );
+ xProp->setPropertyValue( "PosSizeExcludeAxes", uno::Any(false) );
+}
+
+// ____ XShapeDescriptor (base of XShape) ____
+OUString SAL_CALL DiagramWrapper::getShapeType()
+{
+ return "com.sun.star.chart.Diagram";
+}
+
+// ____ XDiagramPositioning ____
+
+void SAL_CALL DiagramWrapper::setAutomaticDiagramPositioning()
+{
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+ uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY );
+ if( xDiaProps.is() )
+ {
+ xDiaProps->setPropertyValue( "RelativeSize", Any() );
+ xDiaProps->setPropertyValue( "RelativePosition", Any() );
+ }
+}
+sal_Bool SAL_CALL DiagramWrapper::isAutomaticDiagramPositioning( )
+{
+ uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY );
+ if( xDiaProps.is() )
+ {
+ Any aRelativeSize( xDiaProps->getPropertyValue( "RelativeSize" ) );
+ Any aRelativePosition( xDiaProps->getPropertyValue( "RelativePosition" ) );
+ if( aRelativeSize.hasValue() && aRelativePosition.hasValue() )
+ return false;
+ }
+ return true;
+}
+void SAL_CALL DiagramWrapper::setDiagramPositionExcludingAxes( const awt::Rectangle& rPositionRect )
+{
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+ DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getChartModel(), rPositionRect );
+ uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY );
+ if( xDiaProps.is() )
+ xDiaProps->setPropertyValue("PosSizeExcludeAxes", uno::Any(true) );
+}
+sal_Bool SAL_CALL DiagramWrapper::isExcludingDiagramPositioning()
+{
+ uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY );
+ if( xDiaProps.is() )
+ {
+ Any aRelativeSize( xDiaProps->getPropertyValue( "RelativeSize" ) );
+ Any aRelativePosition( xDiaProps->getPropertyValue( "RelativePosition" ) );
+ if( aRelativeSize.hasValue() && aRelativePosition.hasValue() )
+ {
+ bool bPosSizeExcludeAxes = false;
+ xDiaProps->getPropertyValue( "PosSizeExcludeAxes" ) >>= bPosSizeExcludeAxes;
+ return bPosSizeExcludeAxes;
+ }
+ }
+ return false;
+}
+awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionExcludingAxes( )
+{
+ return m_spChart2ModelContact->GetDiagramRectangleExcludingAxes();
+}
+void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxes( const awt::Rectangle& rPositionRect )
+{
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+ DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getChartModel(), rPositionRect );
+ uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY );
+ if( xDiaProps.is() )
+ xDiaProps->setPropertyValue("PosSizeExcludeAxes", uno::Any(false) );
+}
+awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxes( )
+{
+ return m_spChart2ModelContact->GetDiagramRectangleIncludingAxes();
+}
+void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxisTitles( const awt::Rectangle& rPositionRect )
+{
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+ awt::Rectangle aRect( m_spChart2ModelContact->SubstractAxisTitleSizes(rPositionRect) );
+ DiagramWrapper::setDiagramPositionIncludingAxes( aRect );
+}
+css::awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxesAndAxisTitles( )
+{
+ return m_spChart2ModelContact->GetDiagramRectangleIncludingTitle();
+}
+
+// ____ XAxisSupplier ____
+Reference< XAxis > SAL_CALL DiagramWrapper::getAxis( sal_Int32 nDimensionIndex )
+{
+ Reference< XAxis > xAxis;
+ if(!nDimensionIndex)
+ {
+ if( !m_xXAxis.is() )
+ m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, m_spChart2ModelContact );
+ xAxis = m_xXAxis;
+ }
+ else if(nDimensionIndex==1)
+ {
+ if( !m_xYAxis.is() )
+ m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, m_spChart2ModelContact );
+ xAxis = m_xYAxis;
+ }
+ else if(nDimensionIndex==2)
+ {
+ if( !m_xZAxis.is() )
+ m_xZAxis = new AxisWrapper( AxisWrapper::Z_AXIS, m_spChart2ModelContact );
+ xAxis = m_xZAxis;
+ }
+ return xAxis;
+}
+
+Reference< XAxis > SAL_CALL DiagramWrapper::getSecondaryAxis( sal_Int32 nDimensionIndex )
+{
+ Reference< XAxis > xAxis;
+ if(!nDimensionIndex)
+ {
+ if( !m_xSecondXAxis.is() )
+ m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, m_spChart2ModelContact );
+ xAxis = m_xSecondXAxis;
+ }
+ else if(nDimensionIndex==1)
+ {
+ if( !m_xSecondYAxis.is() )
+ m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, m_spChart2ModelContact );
+ xAxis = m_xSecondYAxis;
+ }
+ return xAxis;
+}
+
+// ____ XAxisZSupplier ____
+Reference< drawing::XShape > SAL_CALL DiagramWrapper::getZAxisTitle()
+{
+ Reference< drawing::XShape > xRet;
+ Reference< XAxis > xAxis( getAxis(2) );
+ if( xAxis.is() )
+ xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY );
+ return xRet;
+}
+
+Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZMainGrid()
+{
+ Reference< beans::XPropertySet > xRet;
+ Reference< XAxis > xAxis( getAxis(2) );
+ if( xAxis.is() )
+ xRet = xAxis->getMajorGrid();
+ return xRet;
+}
+
+Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZHelpGrid()
+{
+ Reference< beans::XPropertySet > xRet;
+ Reference< XAxis > xAxis( getAxis(2) );
+ if( xAxis.is() )
+ xRet = xAxis->getMinorGrid();
+ return xRet;
+}
+
+Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZAxis()
+{
+ if( ! m_xZAxis.is())
+ m_xZAxis = new AxisWrapper( AxisWrapper::Z_AXIS, m_spChart2ModelContact );
+ return Reference< beans::XPropertySet >( m_xZAxis, uno::UNO_QUERY );
+}
+
+// ____ XTwoAxisXSupplier ____
+Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryXAxis()
+{
+ if( ! m_xSecondXAxis.is())
+ m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, m_spChart2ModelContact );
+ return Reference< beans::XPropertySet >( m_xSecondXAxis, uno::UNO_QUERY );
+}
+
+// ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____
+Reference< drawing::XShape > SAL_CALL DiagramWrapper::getXAxisTitle()
+{
+ Reference< drawing::XShape > xRet;
+ Reference< XAxis > xAxis( getAxis(0) );
+ if( xAxis.is() )
+ xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY );
+ return xRet;
+}
+
+Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXAxis()
+{
+ if( ! m_xXAxis.is())
+ m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, m_spChart2ModelContact );
+ return Reference< beans::XPropertySet >( m_xXAxis, uno::UNO_QUERY );
+}
+
+Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXMainGrid()
+{
+ Reference< beans::XPropertySet > xRet;
+ Reference< XAxis > xAxis( getAxis(0) );
+ if( xAxis.is() )
+ xRet = xAxis->getMajorGrid();
+ return xRet;
+}
+
+Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXHelpGrid()
+{
+ Reference< beans::XPropertySet > xRet;
+ Reference< XAxis > xAxis( getAxis(0) );
+ if( xAxis.is() )
+ xRet = xAxis->getMinorGrid();
+ return xRet;
+}
+
+// ____ XTwoAxisYSupplier ____
+Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryYAxis()
+{
+ if( ! m_xSecondYAxis.is())
+ m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, m_spChart2ModelContact );
+ return Reference< beans::XPropertySet >( m_xSecondYAxis, uno::UNO_QUERY );
+}
+
+// ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____
+Reference< drawing::XShape > SAL_CALL DiagramWrapper::getYAxisTitle()
+{
+ Reference< drawing::XShape > xRet;
+ Reference< XAxis > xAxis( getAxis(1) );
+ if( xAxis.is() )
+ xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY );
+ return xRet;
+}
+
+Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYAxis()
+{
+ if( ! m_xYAxis.is())
+ m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, m_spChart2ModelContact );
+ return Reference< beans::XPropertySet >( m_xYAxis, uno::UNO_QUERY );
+}
+
+Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYMainGrid()
+{
+ Reference< beans::XPropertySet > xRet;
+ Reference< XAxis > xAxis( getAxis(1) );
+ if( xAxis.is() )
+ xRet = xAxis->getMajorGrid();
+ return xRet;
+}
+
+Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYHelpGrid()
+{
+ Reference< beans::XPropertySet > xRet;
+ Reference< XAxis > xAxis( getAxis(1) );
+ if( xAxis.is() )
+ xRet = xAxis->getMinorGrid();
+ return xRet;
+}
+
+// ____ XSecondAxisTitleSupplier ____
+Reference< drawing::XShape > SAL_CALL DiagramWrapper::getSecondXAxisTitle()
+{
+ Reference< drawing::XShape > xRet;
+ Reference< XAxis > xAxis( getSecondaryAxis(0) );
+ if( xAxis.is() )
+ xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY );
+ return xRet;
+}
+
+Reference< drawing::XShape > SAL_CALL DiagramWrapper::getSecondYAxisTitle()
+{
+ Reference< drawing::XShape > xRet;
+ Reference< XAxis > xAxis( getSecondaryAxis(1) );
+ if( xAxis.is() )
+ xRet.set( xAxis->getAxisTitle(), uno::UNO_QUERY );
+ return xRet;
+}
+
+// ____ XStatisticDisplay ____
+Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getUpBar()
+{
+ if( !m_xUpBarWrapper.is() )
+ {
+ m_xUpBarWrapper = new UpDownBarWrapper( true, m_spChart2ModelContact );
+ }
+ return m_xUpBarWrapper;
+}
+
+Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getDownBar()
+{
+ if( !m_xDownBarWrapper.is() )
+ {
+ m_xDownBarWrapper = new UpDownBarWrapper( false, m_spChart2ModelContact );
+ }
+ return m_xDownBarWrapper;
+}
+
+Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getMinMaxLine()
+{
+ if( !m_xMinMaxLineWrapper.is() )
+ {
+ m_xMinMaxLineWrapper = new MinMaxLineWrapper( m_spChart2ModelContact );
+ }
+ return m_xMinMaxLineWrapper;
+}
+
+// ____ X3DDisplay ____
+Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getWall()
+{
+ if( !m_xWall.is() )
+ {
+ m_xWall = new WallFloorWrapper( true, m_spChart2ModelContact );
+ }
+ return m_xWall;
+}
+
+Reference<
+ beans::XPropertySet > SAL_CALL DiagramWrapper::getFloor()
+{
+ if( !m_xFloor.is() )
+ {
+ m_xFloor = new WallFloorWrapper( false, m_spChart2ModelContact );
+ }
+ return m_xFloor;
+}
+
+// ____ X3DDefaultSetter ____
+void SAL_CALL DiagramWrapper::set3DSettingsToDefault()
+{
+ Reference< X3DDefaultSetter > x3DDefaultSetter( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY );
+ if( x3DDefaultSetter.is() )
+ x3DDefaultSetter->set3DSettingsToDefault();
+}
+
+void SAL_CALL DiagramWrapper::setDefaultRotation()
+{
+ Reference< X3DDefaultSetter > x3DDefaultSetter( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY );
+ if( x3DDefaultSetter.is() )
+ x3DDefaultSetter->setDefaultRotation();
+}
+
+void SAL_CALL DiagramWrapper::setDefaultIllumination()
+{
+ Reference< X3DDefaultSetter > x3DDefaultSetter( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY );
+ if( x3DDefaultSetter.is() )
+ x3DDefaultSetter->setDefaultIllumination();
+}
+
+// ____ XComponent ____
+void SAL_CALL DiagramWrapper::dispose()
+{
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( static_cast< ::cppu::OWeakObject* >( this )));
+
+ MutexGuard aGuard( m_aMutex);
+
+ DisposeHelper::DisposeAndClear( m_xXAxis );
+ DisposeHelper::DisposeAndClear( m_xYAxis );
+ DisposeHelper::DisposeAndClear( m_xZAxis );
+ DisposeHelper::DisposeAndClear( m_xSecondXAxis );
+ DisposeHelper::DisposeAndClear( m_xSecondYAxis );
+ DisposeHelper::DisposeAndClear( m_xWall );
+ DisposeHelper::DisposeAndClear( m_xFloor );
+ DisposeHelper::DisposeAndClear( m_xMinMaxLineWrapper );
+ DisposeHelper::DisposeAndClear( m_xUpBarWrapper );
+ DisposeHelper::DisposeAndClear( m_xDownBarWrapper );
+
+ clearWrappedPropertySet();
+}
+
+void SAL_CALL DiagramWrapper::addEventListener(
+ const Reference< lang::XEventListener >& xListener )
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL DiagramWrapper::removeEventListener(
+ const Reference< lang::XEventListener >& aListener )
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+namespace {
+
+//PROP_DIAGRAM_DATAROW_SOURCE
+class WrappedDataRowSourceProperty : public WrappedProperty
+{
+public:
+ explicit WrappedDataRowSourceProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ mutable Any m_aOuterValue;
+};
+
+}
+
+WrappedDataRowSourceProperty::WrappedDataRowSourceProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty("DataRowSource",OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_aOuterValue()
+{
+ m_aOuterValue = WrappedDataRowSourceProperty::getPropertyDefault( nullptr );
+}
+
+void WrappedDataRowSourceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ css::chart::ChartDataRowSource eChartDataRowSource = css::chart::ChartDataRowSource_ROWS;
+ if( ! (rOuterValue >>= eChartDataRowSource) )
+ {
+ sal_Int32 nNew = sal_Int32(css::chart::ChartDataRowSource_ROWS);
+ if( !(rOuterValue >>= nNew) )
+ throw lang::IllegalArgumentException( "Property DataRowSource requires css::chart::ChartDataRowSource value", nullptr, 0 );
+ eChartDataRowSource = css::chart::ChartDataRowSource(nNew);
+ }
+
+ m_aOuterValue = rOuterValue;
+
+ bool bNewUseColumns = eChartDataRowSource == css::chart::ChartDataRowSource_COLUMNS;
+
+ OUString aRangeString;
+ bool bUseColumns = true;
+ bool bFirstCellAsLabel = true;
+ bool bHasCategories = true;
+ uno::Sequence< sal_Int32 > aSequenceMapping;
+
+ if( DataSourceHelper::detectRangeSegmentation(
+ m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
+ , bFirstCellAsLabel, bHasCategories ) )
+ {
+ if( bUseColumns != bNewUseColumns )
+ {
+ aSequenceMapping.realloc(0);
+ DataSourceHelper::setRangeSegmentation(
+ m_spChart2ModelContact->getChartModel(), aSequenceMapping, bNewUseColumns , bFirstCellAsLabel , bHasCategories);
+ }
+ }
+}
+
+Any WrappedDataRowSourceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ OUString aRangeString;
+ bool bUseColumns = true;
+ bool bFirstCellAsLabel = true;
+ bool bHasCategories = true;
+ uno::Sequence< sal_Int32 > aSequenceMapping;
+
+ if( DataSourceHelper::detectRangeSegmentation(
+ m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns
+ , bFirstCellAsLabel, bHasCategories ) )
+ {
+ css::chart::ChartDataRowSource eChartDataRowSource = css::chart::ChartDataRowSource_ROWS;
+ if(bUseColumns)
+ eChartDataRowSource = css::chart::ChartDataRowSource_COLUMNS;
+
+ m_aOuterValue <<= eChartDataRowSource;
+ }
+
+ return m_aOuterValue;
+}
+
+Any WrappedDataRowSourceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= css::chart::ChartDataRowSource_COLUMNS;
+ return aRet;
+}
+
+namespace {
+
+//PROP_DIAGRAM_STACKED
+//PROP_DIAGRAM_DEEP
+//PROP_DIAGRAM_PERCENT_STACKED
+class WrappedStackingProperty : public WrappedProperty
+{
+public:
+ WrappedStackingProperty(StackMode eStackMode, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+protected: //methods
+ bool detectInnerValue( StackMode& eInnerStackMode ) const;
+
+private: //member
+std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ const StackMode m_eStackMode;
+ mutable Any m_aOuterValue;
+};
+
+}
+
+WrappedStackingProperty::WrappedStackingProperty(StackMode eStackMode, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty(OUString(),OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_eStackMode( eStackMode )
+ , m_aOuterValue()
+{
+ switch( m_eStackMode )
+ {
+ case StackMode::YStacked:
+ m_aOuterName = "Stacked";
+ break;
+ case StackMode::YStackedPercent:
+ m_aOuterName = "Percent";
+ break;
+ case StackMode::ZStacked:
+ m_aOuterName = "Deep";
+ break;
+ default:
+ OSL_FAIL( "unexpected stack mode" );
+ break;
+ }
+}
+
+bool WrappedStackingProperty::detectInnerValue( StackMode& eStackMode ) const
+{
+ bool bHasDetectableInnerValue = false;
+ bool bIsAmbiguous = false;
+ eStackMode = DiagramHelper::getStackMode( m_spChart2ModelContact->getChart2Diagram()
+ , bHasDetectableInnerValue, bIsAmbiguous );
+ return bHasDetectableInnerValue;
+}
+
+void WrappedStackingProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ bool bNewValue = false;
+ if( ! (rOuterValue >>= bNewValue) )
+ throw lang::IllegalArgumentException( "Stacking Properties require boolean values", nullptr, 0 );
+
+ StackMode eInnerStackMode;
+ bool bHasDetectableInnerValue = detectInnerValue( eInnerStackMode );
+
+ if( !bHasDetectableInnerValue )
+ {
+ m_aOuterValue = rOuterValue;
+ return;
+ }
+
+ if( bNewValue && eInnerStackMode == m_eStackMode )
+ return;
+ if( !bNewValue && eInnerStackMode != m_eStackMode )
+ return;
+
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( xDiagram.is() )
+ {
+ StackMode eNewStackMode = bNewValue ? m_eStackMode : StackMode::NONE;
+ DiagramHelper::setStackMode( xDiagram, eNewStackMode );
+ }
+}
+
+Any WrappedStackingProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ StackMode eInnerStackMode;
+ if( detectInnerValue( eInnerStackMode ) )
+ {
+ bool bValue = (eInnerStackMode == m_eStackMode);
+ return Any(bValue);
+ }
+ return m_aOuterValue;
+}
+
+Any WrappedStackingProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= false;
+ return aRet;
+}
+
+namespace {
+
+//PROP_DIAGRAM_THREE_D
+class WrappedDim3DProperty : public WrappedProperty
+{
+public:
+ explicit WrappedDim3DProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ mutable Any m_aOuterValue;
+};
+
+}
+
+WrappedDim3DProperty::WrappedDim3DProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty("Dim3D",OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_aOuterValue()
+{
+ m_aOuterValue = WrappedDim3DProperty::getPropertyDefault( nullptr );
+}
+
+void WrappedDim3DProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ bool bNew3D = false;
+ if( ! (rOuterValue >>= bNew3D) )
+ throw lang::IllegalArgumentException( "Property Dim3D requires boolean value", nullptr, 0 );
+
+ m_aOuterValue = rOuterValue;
+
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( !xDiagram.is() )
+ return;
+
+ bool bOld3D = DiagramHelper::getDimension( xDiagram ) == 3;
+ if( bOld3D != bNew3D )
+ DiagramHelper::setDimension( xDiagram, bNew3D ? 3 : 2 );
+}
+
+Any WrappedDim3DProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( xDiagram.is() )
+ {
+ bool b3D = DiagramHelper::getDimension( xDiagram ) == 3;
+ m_aOuterValue <<= b3D;
+ }
+ return m_aOuterValue;
+}
+
+Any WrappedDim3DProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= false;
+ return aRet;
+}
+
+namespace {
+
+//PROP_DIAGRAM_VERTICAL
+class WrappedVerticalProperty : public WrappedProperty
+{
+public:
+ explicit WrappedVerticalProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ mutable Any m_aOuterValue;
+};
+
+}
+
+WrappedVerticalProperty::WrappedVerticalProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty("Vertical",OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_aOuterValue()
+{
+ m_aOuterValue = WrappedVerticalProperty::getPropertyDefault( nullptr );
+}
+
+void WrappedVerticalProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ bool bNewVertical = false;
+ if( ! (rOuterValue >>= bNewVertical) )
+ throw lang::IllegalArgumentException( "Property Vertical requires boolean value", nullptr, 0 );
+
+ m_aOuterValue = rOuterValue;
+
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( !xDiagram.is() )
+ return;
+
+ bool bFound = false;
+ bool bAmbiguous = false;
+ bool bOldVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
+ if( bFound && ( bOldVertical != bNewVertical || bAmbiguous ) )
+ DiagramHelper::setVertical( xDiagram, bNewVertical );
+}
+
+Any WrappedVerticalProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( xDiagram.is() )
+ {
+ bool bFound = false;
+ bool bAmbiguous = false;
+ bool bVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
+ if( bFound )
+ m_aOuterValue <<= bVertical;
+ }
+ return m_aOuterValue;
+}
+
+Any WrappedVerticalProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= false;
+ return aRet;
+}
+
+namespace {
+
+//PROP_DIAGRAM_NUMBER_OF_LINES
+class WrappedNumberOfLinesProperty : public WrappedProperty
+{
+public:
+ explicit WrappedNumberOfLinesProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+protected: //methods
+ bool detectInnerValue( uno::Any& rInnerValue ) const;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ mutable Any m_aOuterValue;
+};
+
+}
+
+WrappedNumberOfLinesProperty::WrappedNumberOfLinesProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty("NumberOfLines",OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_aOuterValue( getPropertyDefault(nullptr) )
+{
+}
+
+bool WrappedNumberOfLinesProperty::detectInnerValue( uno::Any& rInnerValue ) const
+{
+ sal_Int32 nNumberOfLines = 0;
+ bool bHasDetectableInnerValue = false;
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ uno::Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ if( xDiagram.is() && xChartDoc.is() )
+ {
+ std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+ if( !aSeriesVector.empty() )
+ {
+ Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+ DiagramHelper::tTemplateWithServiceName aTemplateAndService =
+ DiagramHelper::getTemplateForDiagram( xDiagram, xFact );
+ if( aTemplateAndService.second == "com.sun.star.chart2.template.ColumnWithLine" )
+ {
+ try
+ {
+ uno::Reference< beans::XPropertySet > xProp( aTemplateAndService.first, uno::UNO_QUERY );
+ xProp->getPropertyValue( m_aOuterName ) >>= nNumberOfLines;
+ bHasDetectableInnerValue = true;
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+ }
+ }
+ if(bHasDetectableInnerValue)
+ rInnerValue <<= nNumberOfLines;
+ return bHasDetectableInnerValue;
+}
+
+void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ sal_Int32 nNewValue;
+ if( ! (rOuterValue >>= nNewValue) )
+ throw lang::IllegalArgumentException( "property NumberOfLines requires sal_Int32 value", nullptr, 0 );
+
+ m_aOuterValue = rOuterValue;
+
+ uno::Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram );
+ if( !(xChartDoc.is() && xDiagram.is() && nDimension == 2) )
+ return;
+
+ Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+ DiagramHelper::tTemplateWithServiceName aTemplateAndService =
+ DiagramHelper::getTemplateForDiagram( xDiagram, xFact );
+
+ uno::Reference< chart2::XChartTypeTemplate > xTemplate;
+ if( aTemplateAndService.second == "com.sun.star.chart2.template.ColumnWithLine" )
+ {
+ if( nNewValue != 0 )
+ {
+ xTemplate.set( aTemplateAndService.first );
+ try
+ {
+ sal_Int32 nOldValue = 0;
+ uno::Reference< beans::XPropertySet > xProp( xTemplate, uno::UNO_QUERY );
+ xProp->getPropertyValue( m_aOuterName ) >>= nOldValue;
+ if( nOldValue == nNewValue )
+ return;
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+ else
+ {
+ xTemplate.set( xFact->createInstance("com.sun.star.chart2.template.Column"), uno::UNO_QUERY );
+ }
+ }
+ else if( aTemplateAndService.second == "com.sun.star.chart2.template.Column" )
+ {
+ if( nNewValue == 0 )
+ return;
+ xTemplate.set( xFact->createInstance( "com.sun.star.chart2.template.ColumnWithLine" ), uno::UNO_QUERY );
+ }
+
+ if(!xTemplate.is())
+ return;
+
+ try
+ {
+ // locked controllers
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+ uno::Reference< beans::XPropertySet > xProp( xTemplate, uno::UNO_QUERY );
+ xProp->setPropertyValue( "NumberOfLines", uno::Any(nNewValue) );
+ xTemplate->changeDiagram( xDiagram );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+Any WrappedNumberOfLinesProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ Any aRet;
+ if( !detectInnerValue( aRet ) )
+ aRet = m_aOuterValue;
+ return aRet;
+}
+
+Any WrappedNumberOfLinesProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= sal_Int32( 0 );
+ return aRet;
+}
+
+namespace {
+
+//PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS
+class WrappedAttributedDataPointsProperty : public WrappedProperty
+{
+public:
+ explicit WrappedAttributedDataPointsProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ mutable Any m_aOuterValue;
+};
+
+}
+
+WrappedAttributedDataPointsProperty::WrappedAttributedDataPointsProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty("AttributedDataPoints",OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_aOuterValue()
+{
+ m_aOuterValue = WrappedAttributedDataPointsProperty::getPropertyDefault( nullptr );
+}
+
+void WrappedAttributedDataPointsProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ uno::Sequence< uno::Sequence< sal_Int32 > > aNewValue;
+ if( ! (rOuterValue >>= aNewValue) )
+ throw lang::IllegalArgumentException( "Property AttributedDataPoints requires value of type uno::Sequence< uno::Sequence< sal_Int32 > >", nullptr, 0 );
+
+ m_aOuterValue = rOuterValue;
+
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY );
+
+ if( !(xDiagram.is() && xDiaProp.is()))
+ return;
+
+ std::vector< Reference< chart2::XDataSeries > > aSeriesVector(
+ ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+ sal_Int32 i = 0;
+ for (auto const& series : aSeriesVector)
+ {
+ Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY);
+ if( xProp.is())
+ {
+ uno::Any aVal;
+ if( i < aNewValue.getLength() )
+ aVal <<= aNewValue[i];
+ else
+ {
+ //set empty sequence
+ uno::Sequence< sal_Int32 > aSeq;
+ aVal <<= aSeq;
+ }
+ xProp->setPropertyValue( "AttributedDataPoints", aVal );
+ }
+ ++i;
+ }
+}
+
+Any WrappedAttributedDataPointsProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY );
+
+ if( xDiagram.is() && xDiaProp.is())
+ {
+ std::vector< Reference< chart2::XDataSeries > > aSeriesVector(
+ ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+
+ uno::Sequence< uno::Sequence< sal_Int32 > > aResult( aSeriesVector.size() );
+
+ sal_Int32 i = 0;
+ for (auto const& series : aSeriesVector)
+ {
+ Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY);
+ if( xProp.is())
+ {
+ uno::Any aVal(
+ xProp->getPropertyValue("AttributedDataPoints"));
+ uno::Sequence< sal_Int32 > aSeq;
+ if( aVal >>= aSeq )
+ aResult[ i ] = aSeq;
+ }
+ ++i;
+ }
+ m_aOuterValue <<= aResult;
+ }
+ return m_aOuterValue;
+}
+
+Any WrappedAttributedDataPointsProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ uno::Sequence< uno::Sequence< sal_Int32 > > aSeq;
+ aRet <<= aSeq;
+ return aRet;
+}
+
+namespace {
+
+//PROP_DIAGRAM_SOLIDTYPE
+class WrappedSolidTypeProperty : public WrappedProperty
+{
+public:
+ explicit WrappedSolidTypeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ mutable Any m_aOuterValue;
+};
+
+}
+
+WrappedSolidTypeProperty::WrappedSolidTypeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty( "SolidType", OUString() )
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_aOuterValue()
+{
+ m_aOuterValue = WrappedSolidTypeProperty::getPropertyDefault( nullptr );
+}
+
+void WrappedSolidTypeProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ sal_Int32 nNewSolidType = css::chart::ChartSolidType::RECTANGULAR_SOLID;
+ if( ! (rOuterValue >>= nNewSolidType) )
+ throw lang::IllegalArgumentException( "Property SolidType requires integer value", nullptr, 0 );
+
+ m_aOuterValue = rOuterValue;
+
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( !xDiagram.is() )
+ return;
+
+ bool bFound = false;
+ bool bAmbiguous = false;
+ sal_Int32 nOldSolidType = DiagramHelper::getGeometry3D( xDiagram, bFound, bAmbiguous );
+ if( bFound && ( nOldSolidType != nNewSolidType || bAmbiguous ) )
+ DiagramHelper::setGeometry3D( xDiagram, nNewSolidType );
+}
+
+Any WrappedSolidTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( xDiagram.is() )
+ {
+ bool bFound = false;
+ bool bAmbiguous = false;
+ sal_Int32 nGeometry = DiagramHelper::getGeometry3D( xDiagram, bFound, bAmbiguous );
+ if( bFound )
+ m_aOuterValue <<= nGeometry;
+ }
+ return m_aOuterValue;
+}
+
+Any WrappedSolidTypeProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ return uno::Any( css::chart::ChartSolidType::RECTANGULAR_SOLID );
+}
+
+namespace {
+
+class WrappedAutomaticSizeProperty : public WrappedProperty
+{
+public:
+ WrappedAutomaticSizeProperty();
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+};
+
+}
+
+WrappedAutomaticSizeProperty::WrappedAutomaticSizeProperty()
+ : WrappedProperty( "AutomaticSize", OUString() )
+{
+}
+
+void WrappedAutomaticSizeProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ if( !xInnerPropertySet.is() )
+ return;
+
+ bool bNewValue = true;
+ if( ! (rOuterValue >>= bNewValue) )
+ throw lang::IllegalArgumentException( "Property AutomaticSize requires value of type boolean", nullptr, 0 );
+
+ try
+ {
+ if( bNewValue )
+ {
+ Any aRelativeSize( xInnerPropertySet->getPropertyValue( "RelativeSize" ) );
+ if( aRelativeSize.hasValue() )
+ xInnerPropertySet->setPropertyValue( "RelativeSize", Any() );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+Any WrappedAutomaticSizeProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) );
+ if( xInnerPropertySet.is() )
+ {
+ Any aRelativeSize( xInnerPropertySet->getPropertyValue( "RelativeSize" ) );
+ if( !aRelativeSize.hasValue() )
+ aRet <<= true;
+ }
+ return aRet;
+}
+
+Any WrappedAutomaticSizeProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= false;
+ return aRet;
+}
+
+namespace {
+
+//PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS
+class WrappedIncludeHiddenCellsProperty : public WrappedProperty
+{
+public:
+ explicit WrappedIncludeHiddenCellsProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+ virtual Any getPropertyValue(const Reference<beans::XPropertySet>& xInnerPropertySet) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+};
+
+}
+
+WrappedIncludeHiddenCellsProperty::WrappedIncludeHiddenCellsProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty("IncludeHiddenCells","IncludeHiddenCells")
+ , m_spChart2ModelContact( spChart2ModelContact )
+{
+}
+
+void WrappedIncludeHiddenCellsProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ bool bNewValue = false;
+ if( ! (rOuterValue >>= bNewValue) )
+ throw lang::IllegalArgumentException( "Property IncludeHiddenCells requires boolean value", nullptr, 0 );
+
+ ChartModelHelper::setIncludeHiddenCells( bNewValue, *m_spChart2ModelContact->getModel() );
+}
+
+Any WrappedIncludeHiddenCellsProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ bool bValue = ChartModelHelper::isIncludeHiddenCells( m_spChart2ModelContact->getChartModel() );
+ return uno::Any(bValue);
+}
+
+// ____ XDiagramProvider ____
+Reference< chart2::XDiagram > SAL_CALL DiagramWrapper::getDiagram()
+{
+ return m_spChart2ModelContact->getChart2Diagram();
+}
+
+void SAL_CALL DiagramWrapper::setDiagram(
+ const Reference< chart2::XDiagram >& /*xDiagram*/ )
+{
+ //@todo: remove this method from interface
+ OSL_FAIL("DiagramWrapper::setDiagram is not implemented, should be removed and not be called" );
+}
+
+Reference< beans::XPropertySet > DiagramWrapper::getInnerPropertySet()
+{
+ return Reference< beans::XPropertySet >( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY );
+}
+
+const Sequence< beans::Property >& DiagramWrapper::getPropertySequence()
+{
+ return *StaticDiagramWrapperPropertyArray::get();
+}
+
+std::vector< std::unique_ptr<WrappedProperty> > DiagramWrapper::createWrappedProperties()
+{
+ std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
+
+ WrappedAxisAndGridExistenceProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
+ WrappedAxisTitleExistenceProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
+ WrappedAxisLabelExistenceProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
+ WrappedSceneProperty::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
+ WrappedIgnoreProperties::addIgnoreFillProperties( aWrappedProperties );
+ WrappedIgnoreProperties::addIgnoreLineProperties( aWrappedProperties );
+ WrappedStatisticProperties::addWrappedPropertiesForDiagram( aWrappedProperties, m_spChart2ModelContact );
+ WrappedSymbolProperties::addWrappedPropertiesForDiagram( aWrappedProperties, m_spChart2ModelContact );
+ WrappedDataCaptionProperties::addWrappedPropertiesForDiagram( aWrappedProperties, m_spChart2ModelContact );
+ WrappedSplineProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
+ WrappedStockProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
+ WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties );
+
+ aWrappedProperties.emplace_back( new WrappedDataRowSourceProperty( m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedStackingProperty( StackMode::YStacked,m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedStackingProperty( StackMode::YStackedPercent, m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedStackingProperty( StackMode::ZStacked, m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedDim3DProperty( m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedVerticalProperty( m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedNumberOfLinesProperty( m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedAttributedDataPointsProperty( m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedProperty( "StackedBarsConnected", "ConnectBars" ) );
+ aWrappedProperties.emplace_back( new WrappedSolidTypeProperty( m_spChart2ModelContact ) );
+ aWrappedProperties.emplace_back( new WrappedAutomaticSizeProperty() );
+ aWrappedProperties.emplace_back( new WrappedIncludeHiddenCellsProperty( m_spChart2ModelContact ) );
+
+ return aWrappedProperties;
+}
+
+OUString SAL_CALL DiagramWrapper::getImplementationName()
+{
+ return "com.sun.star.comp.chart.Diagram";
+}
+
+sal_Bool SAL_CALL DiagramWrapper::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL DiagramWrapper::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart.Diagram",
+ "com.sun.star.xml.UserDefinedAttributesSupplier",
+ "com.sun.star.chart.StackableDiagram",
+ "com.sun.star.chart.ChartAxisXSupplier",
+ "com.sun.star.chart.ChartAxisYSupplier",
+ "com.sun.star.chart.ChartAxisZSupplier",
+ "com.sun.star.chart.ChartTwoAxisXSupplier",
+ "com.sun.star.chart.ChartTwoAxisYSupplier"
+ };
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx
new file mode 100644
index 000000000..ca7d8ca89
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx
@@ -0,0 +1,224 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_DIAGRAMWRAPPER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_DIAGRAMWRAPPER_HXX
+
+#include <WrappedPropertySet.hxx>
+
+#include <comphelper/interfacecontainer2.hxx>
+#include <com/sun/star/chart/XDiagramPositioning.hpp>
+#include <com/sun/star/chart2/XDiagramProvider.hpp>
+#include <com/sun/star/chart/XDiagram.hpp>
+#include <com/sun/star/chart/XAxisSupplier.hpp>
+#include <com/sun/star/chart/XAxisZSupplier.hpp>
+#include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
+#include <com/sun/star/chart/XTwoAxisYSupplier.hpp>
+#include <com/sun/star/chart/XStatisticDisplay.hpp>
+#include <com/sun/star/chart/X3DDisplay.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp>
+
+#include <com/sun/star/chart/X3DDefaultSetter.hpp>
+#include <memory>
+
+namespace com::sun::star::chart2 { class XDiagram; }
+namespace com::sun::star::lang { class XEventListener; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class Chart2ModelContact;
+
+class DiagramWrapper : public cppu::ImplInheritanceHelper<
+ WrappedPropertySet
+ , css::chart::XDiagram
+ , css::chart::XAxisSupplier
+ , css::chart::XAxisZSupplier
+ , css::chart::XTwoAxisXSupplier // : XAxisXSupplier
+ , css::chart::XTwoAxisYSupplier // : XAxisYSupplier
+ , css::chart::XStatisticDisplay
+ , css::chart::X3DDisplay
+ , css::chart::X3DDefaultSetter
+ , css::lang::XServiceInfo
+ , css::lang::XComponent
+ , css::chart::XDiagramPositioning
+ , css::chart2::XDiagramProvider
+ , css::chart::XSecondAxisTitleSupplier
+ >
+{
+public:
+ explicit DiagramWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ virtual ~DiagramWrapper() override;
+
+ /// XServiceInfo declarations
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose() override;
+ virtual void SAL_CALL addEventListener( const css::uno::Reference<
+ css::lang::XEventListener >& xListener ) override;
+ virtual void SAL_CALL removeEventListener( const css::uno::Reference<
+ css::lang::XEventListener >& aListener ) override;
+
+ // ____ XDiagram ____
+ virtual OUString SAL_CALL getDiagramType() override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getDataRowProperties( sal_Int32 nRow ) override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getDataPointProperties( sal_Int32 nCol, sal_Int32 nRow ) override;
+
+ // ____ XShape (base of XDiagram) ____
+ virtual css::awt::Point SAL_CALL getPosition() override;
+ virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
+ virtual css::awt::Size SAL_CALL getSize() override;
+ virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
+
+ // ____ XShapeDescriptor (base of XShape) ____
+ virtual OUString SAL_CALL getShapeType() override;
+
+ // ____ XAxisSupplier ____
+ virtual css::uno::Reference<
+ css::chart::XAxis > SAL_CALL getAxis( sal_Int32 nDimensionIndex ) override;
+ virtual css::uno::Reference<
+ css::chart::XAxis > SAL_CALL getSecondaryAxis( sal_Int32 nDimensionIndex ) override;
+
+ // ____ XAxisZSupplier ____
+ virtual css::uno::Reference<
+ css::drawing::XShape > SAL_CALL getZAxisTitle() override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getZMainGrid() override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getZHelpGrid() override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getZAxis() override;
+
+ // ____ XTwoAxisXSupplier ____
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getSecondaryXAxis() override;
+
+ // ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____
+ virtual css::uno::Reference<
+ css::drawing::XShape > SAL_CALL getXAxisTitle() override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getXAxis() override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getXMainGrid() override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getXHelpGrid() override;
+
+ // ____ XTwoAxisYSupplier ____
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getSecondaryYAxis() override;
+
+ // ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____
+ virtual css::uno::Reference<
+ css::drawing::XShape > SAL_CALL getYAxisTitle() override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getYAxis() override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getYHelpGrid() override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getYMainGrid() override;
+
+ // ____ XSecondAxisTitleSupplier ____
+ virtual css::uno::Reference<
+ css::drawing::XShape > SAL_CALL getSecondXAxisTitle() override;
+ virtual css::uno::Reference<
+ css::drawing::XShape > SAL_CALL getSecondYAxisTitle() override;
+
+ // ____ XStatisticDisplay ____
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getUpBar() override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getDownBar() override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getMinMaxLine() override;
+
+ // ____ X3DDisplay ____
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getWall() override;
+ virtual css::uno::Reference<
+ css::beans::XPropertySet > SAL_CALL getFloor() override;
+
+ // ____ X3DDefaultSetter ____
+ virtual void SAL_CALL set3DSettingsToDefault() override;
+ virtual void SAL_CALL setDefaultRotation() override;
+ virtual void SAL_CALL setDefaultIllumination() override;
+
+ // ____ XDiagramPositioning ____
+ virtual void SAL_CALL setAutomaticDiagramPositioning( ) override;
+ virtual sal_Bool SAL_CALL isAutomaticDiagramPositioning( ) override;
+ virtual void SAL_CALL setDiagramPositionExcludingAxes( const css::awt::Rectangle& PositionRect ) override;
+ virtual sal_Bool SAL_CALL isExcludingDiagramPositioning( ) override;
+ virtual css::awt::Rectangle SAL_CALL calculateDiagramPositionExcludingAxes( ) override;
+ virtual void SAL_CALL setDiagramPositionIncludingAxes( const css::awt::Rectangle& PositionRect ) override;
+ virtual css::awt::Rectangle SAL_CALL calculateDiagramPositionIncludingAxes( ) override;
+ virtual void SAL_CALL setDiagramPositionIncludingAxesAndAxisTitles( const css::awt::Rectangle& PositionRect ) override;
+ virtual css::awt::Rectangle SAL_CALL calculateDiagramPositionIncludingAxesAndAxisTitles( ) override;
+
+ // ____ XDiagramProvider ____
+ virtual css::uno::Reference< css::chart2::XDiagram > SAL_CALL getDiagram() override;
+ virtual void SAL_CALL setDiagram( const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override;
+
+protected:
+ // ____ WrappedPropertySet ____
+ virtual const css::uno::Sequence< css::beans::Property >& getPropertySequence() override;
+ virtual std::vector< std::unique_ptr<WrappedProperty> > createWrappedProperties() override;
+ virtual css::uno::Reference< css::beans::XPropertySet > getInnerPropertySet() override;
+
+private:
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer;
+
+ css::uno::Reference<
+ css::chart::XAxis > m_xXAxis;
+ css::uno::Reference<
+ css::chart::XAxis > m_xYAxis;
+ css::uno::Reference<
+ css::chart::XAxis > m_xZAxis;
+ css::uno::Reference<
+ css::chart::XAxis > m_xSecondXAxis;
+ css::uno::Reference<
+ css::chart::XAxis > m_xSecondYAxis;
+
+ css::uno::Reference<
+ css::beans::XPropertySet > m_xWall;
+ css::uno::Reference<
+ css::beans::XPropertySet > m_xFloor;
+
+ css::uno::Reference<
+ css::beans::XPropertySet > m_xMinMaxLineWrapper;
+ css::uno::Reference<
+ css::beans::XPropertySet > m_xUpBarWrapper;
+ css::uno::Reference<
+ css::beans::XPropertySet > m_xDownBarWrapper;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_DIAGRAMWRAPPER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx
new file mode 100644
index 000000000..649086a1a
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx
@@ -0,0 +1,187 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "GridWrapper.hxx"
+#include <AxisHelper.hxx>
+#include "Chart2ModelContact.hxx"
+#include <AxisIndexDefines.hxx>
+
+#include <LinePropertiesHelper.hxx>
+#include <UserDefinedProperties.hxx>
+#include <WrappedDefaultProperty.hxx>
+
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <algorithm>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+namespace
+{
+
+struct StaticGridWrapperPropertyArray_Initializer
+{
+ Sequence< Property >* operator()()
+ {
+ static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
+ return &aPropSeq;
+ }
+private:
+ static Sequence< Property > lcl_GetPropertySequence()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+};
+
+struct StaticGridWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticGridWrapperPropertyArray_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart::wrapper
+{
+
+GridWrapper::GridWrapper(tGridType eType, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : m_spChart2ModelContact(spChart2ModelContact)
+ , m_aEventListenerContainer(m_aMutex)
+ , m_eType(eType)
+{
+}
+
+GridWrapper::~GridWrapper()
+{}
+
+void GridWrapper::getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDimensionIndex, bool& rbSubGrid )
+{
+ rnDimensionIndex = 1;
+ rbSubGrid = false;
+
+ switch( eType )
+ {
+ case X_MAJOR_GRID:
+ rnDimensionIndex = 0; rbSubGrid = false; break;
+ case Y_MAJOR_GRID:
+ rnDimensionIndex = 1; rbSubGrid = false; break;
+ case Z_MAJOR_GRID:
+ rnDimensionIndex = 2; rbSubGrid = false; break;
+ case X_MINOR_GRID:
+ rnDimensionIndex = 0; rbSubGrid = true; break;
+ case Y_MINOR_GRID:
+ rnDimensionIndex = 1; rbSubGrid = true; break;
+ case Z_MINOR_GRID:
+ rnDimensionIndex = 2; rbSubGrid = true; break;
+ }
+}
+
+// ____ XComponent ____
+void SAL_CALL GridWrapper::dispose()
+{
+ Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+
+ clearWrappedPropertySet();
+}
+
+void SAL_CALL GridWrapper::addEventListener(
+ const Reference< lang::XEventListener >& xListener )
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL GridWrapper::removeEventListener(
+ const Reference< lang::XEventListener >& aListener )
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+// WrappedPropertySet
+
+Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet()
+{
+ Reference< beans::XPropertySet > xRet;
+ try
+ {
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 /*nCooSysIndex*/ ) );
+
+ sal_Int32 nDimensionIndex = 1;
+ bool bSubGrid = false;
+ getDimensionAndSubGridBool( m_eType, nDimensionIndex, bSubGrid );
+
+ sal_Int32 nSubGridIndex = bSubGrid ? 0 : -1;
+ xRet.set( AxisHelper::getGridProperties( xCooSys , nDimensionIndex, MAIN_AXIS_INDEX, nSubGridIndex ) );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return xRet;
+}
+
+const Sequence< beans::Property >& GridWrapper::getPropertySequence()
+{
+ return *StaticGridWrapperPropertyArray::get();
+}
+
+std::vector< std::unique_ptr<WrappedProperty> > GridWrapper::createWrappedProperties()
+{
+ std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
+
+ aWrappedProperties.emplace_back( new WrappedDefaultProperty( "LineColor", "LineColor", uno::Any( sal_Int32( 0x000000) ) ) ); // black
+
+ return aWrappedProperties;
+}
+
+OUString SAL_CALL GridWrapper::getImplementationName()
+{
+ return "com.sun.star.comp.chart.Grid";
+}
+
+sal_Bool SAL_CALL GridWrapper::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL GridWrapper::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart.ChartGrid",
+ "com.sun.star.xml.UserDefinedAttributesSupplier",
+ "com.sun.star.drawing.LineProperties",
+ "com.sun.star.beans.PropertySet"
+ };
+}
+
+} // namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.hxx b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx
new file mode 100644
index 000000000..275d28279
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx
@@ -0,0 +1,88 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_GRIDWRAPPER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_GRIDWRAPPER_HXX
+
+#include <WrappedPropertySet.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <comphelper/interfacecontainer2.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <memory>
+
+namespace chart
+{
+namespace wrapper
+{
+
+class Chart2ModelContact;
+
+class GridWrapper : public ::cppu::ImplInheritanceHelper<
+ WrappedPropertySet
+ , css::lang::XComponent
+ , css::lang::XServiceInfo
+ >
+{
+public:
+ enum tGridType
+ {
+ X_MAJOR_GRID,
+ Y_MAJOR_GRID,
+ Z_MAJOR_GRID,
+ X_MINOR_GRID,
+ Y_MINOR_GRID,
+ Z_MINOR_GRID
+ };
+
+ GridWrapper(tGridType eType, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ virtual ~GridWrapper() override;
+
+ static void getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDimensionIndex, bool& rbSubGrid );
+
+ /// XServiceInfo declarations
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose() override;
+ virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
+ virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
+
+protected:
+ // ____ WrappedPropertySet ____
+ virtual const css::uno::Sequence< css::beans::Property >& getPropertySequence() override;
+ virtual std::vector< std::unique_ptr<WrappedProperty> > createWrappedProperties() override;
+ virtual css::uno::Reference< css::beans::XPropertySet > getInnerPropertySet() override;
+
+private:
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer;
+
+ tGridType m_eType;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_GRIDWRAPPER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx
new file mode 100644
index 000000000..01dc74e7b
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx
@@ -0,0 +1,423 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "LegendWrapper.hxx"
+#include "Chart2ModelContact.hxx"
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/chart/ChartLegendPosition.hpp>
+#include <com/sun/star/chart2/LegendPosition.hpp>
+#include <com/sun/star/chart/ChartLegendExpansion.hpp>
+#include <com/sun/star/chart2/RelativePosition.hpp>
+#include <com/sun/star/chart2/XDiagram.hpp>
+
+#include <CharacterProperties.hxx>
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <UserDefinedProperties.hxx>
+#include "WrappedCharacterHeightProperty.hxx"
+#include <PositionAndSizeHelper.hxx>
+#include <WrappedDirectStateProperty.hxx>
+#include "WrappedAutomaticPositionProperties.hxx"
+#include "WrappedScaleTextProperties.hxx"
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::beans::Property;
+using ::osl::MutexGuard;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+namespace chart
+{
+namespace {
+
+class WrappedLegendAlignmentProperty : public WrappedProperty
+{
+public:
+ WrappedLegendAlignmentProperty();
+
+ virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const override;
+ virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override;
+
+protected:
+ virtual Any convertInnerToOuterValue( const Any& rInnerValue ) const override;
+ virtual Any convertOuterToInnerValue( const Any& rOuterValue ) const override;
+};
+
+}
+
+WrappedLegendAlignmentProperty::WrappedLegendAlignmentProperty()
+ : ::chart::WrappedProperty( "Alignment", "AnchorPosition" )
+{
+}
+
+Any WrappedLegendAlignmentProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ Any aRet;
+ if( xInnerPropertySet.is() )
+ {
+ bool bShowLegend = true;
+ xInnerPropertySet->getPropertyValue( "Show" ) >>= bShowLegend;
+ if(!bShowLegend)
+ {
+ aRet <<= css::chart::ChartLegendPosition_NONE;
+ }
+ else
+ {
+ aRet = xInnerPropertySet->getPropertyValue( m_aInnerName );
+ aRet = convertInnerToOuterValue( aRet );
+ }
+ }
+ return aRet;
+}
+
+void WrappedLegendAlignmentProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ if(!xInnerPropertySet.is())
+ return;
+
+ bool bNewShowLegend = true;
+ bool bOldShowLegend = true;
+ {
+ css::chart::ChartLegendPosition eOuterPos(css::chart::ChartLegendPosition_NONE);
+ if( (rOuterValue >>= eOuterPos) && eOuterPos == css::chart::ChartLegendPosition_NONE )
+ bNewShowLegend = false;
+ xInnerPropertySet->getPropertyValue( "Show" ) >>= bOldShowLegend;
+ }
+ if(bNewShowLegend!=bOldShowLegend)
+ {
+ xInnerPropertySet->setPropertyValue( "Show", uno::Any(bNewShowLegend) );
+ }
+ if(!bNewShowLegend)
+ return;
+
+ //set corresponding LegendPosition
+ Any aInnerValue = convertOuterToInnerValue( rOuterValue );
+ xInnerPropertySet->setPropertyValue( m_aInnerName, aInnerValue );
+
+ //correct LegendExpansion
+ chart2::LegendPosition eNewInnerPos(chart2::LegendPosition_LINE_END);
+ if( aInnerValue >>= eNewInnerPos )
+ {
+ css::chart::ChartLegendExpansion eNewExpansion =
+ ( eNewInnerPos == chart2::LegendPosition_LINE_END ||
+ eNewInnerPos == chart2::LegendPosition_LINE_START )
+ ? css::chart::ChartLegendExpansion_HIGH
+ : css::chart::ChartLegendExpansion_WIDE;
+
+ css::chart::ChartLegendExpansion eOldExpansion( css::chart::ChartLegendExpansion_HIGH );
+ bool bExpansionWasSet(
+ xInnerPropertySet->getPropertyValue( "Expansion" ) >>= eOldExpansion );
+
+ if( !bExpansionWasSet || (eOldExpansion != eNewExpansion))
+ xInnerPropertySet->setPropertyValue( "Expansion", uno::Any( eNewExpansion ));
+ }
+
+ //correct RelativePosition
+ Any aRelativePosition( xInnerPropertySet->getPropertyValue("RelativePosition") );
+ if(aRelativePosition.hasValue())
+ {
+ xInnerPropertySet->setPropertyValue( "RelativePosition", Any() );
+ }
+}
+
+Any WrappedLegendAlignmentProperty::convertInnerToOuterValue( const Any& rInnerValue ) const
+{
+ css::chart::ChartLegendPosition ePos = css::chart::ChartLegendPosition_NONE;
+
+ chart2::LegendPosition eNewPos;
+ if( rInnerValue >>= eNewPos )
+ {
+ switch( eNewPos )
+ {
+ case chart2::LegendPosition_LINE_START:
+ ePos = css::chart::ChartLegendPosition_LEFT;
+ break;
+ case chart2::LegendPosition_LINE_END:
+ ePos = css::chart::ChartLegendPosition_RIGHT;
+ break;
+ case chart2::LegendPosition_PAGE_START:
+ ePos = css::chart::ChartLegendPosition_TOP;
+ break;
+ case chart2::LegendPosition_PAGE_END:
+ ePos = css::chart::ChartLegendPosition_BOTTOM;
+ break;
+
+ default:
+ ePos = css::chart::ChartLegendPosition_NONE;
+ break;
+ }
+ }
+ return uno::Any( ePos );
+}
+Any WrappedLegendAlignmentProperty::convertOuterToInnerValue( const Any& rOuterValue ) const
+{
+ chart2::LegendPosition eNewPos = chart2::LegendPosition_LINE_END;
+
+ css::chart::ChartLegendPosition ePos;
+ if( rOuterValue >>= ePos )
+ {
+ switch( ePos )
+ {
+ case css::chart::ChartLegendPosition_LEFT:
+ eNewPos = chart2::LegendPosition_LINE_START;
+ break;
+ case css::chart::ChartLegendPosition_RIGHT:
+ eNewPos = chart2::LegendPosition_LINE_END;
+ break;
+ case css::chart::ChartLegendPosition_TOP:
+ eNewPos = chart2::LegendPosition_PAGE_START;
+ break;
+ case css::chart::ChartLegendPosition_BOTTOM:
+ eNewPos = chart2::LegendPosition_PAGE_END;
+ break;
+ default: // NONE
+ break;
+ }
+ }
+
+ return uno::Any( eNewPos );
+}
+}
+
+namespace
+{
+
+enum
+{
+ PROP_LEGEND_ALIGNMENT,
+ PROP_LEGEND_EXPANSION
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "Alignment",
+ PROP_LEGEND_ALIGNMENT,
+ cppu::UnoType<css::chart::ChartLegendPosition>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "Expansion",
+ PROP_LEGEND_EXPANSION,
+ cppu::UnoType<css::chart::ChartLegendExpansion>::get(),
+ //#i111967# no PropertyChangeEvent is fired on change so far
+ beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+struct StaticLegendWrapperPropertyArray_Initializer
+{
+ Sequence< Property >* operator()()
+ {
+ static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
+ return &aPropSeq;
+ }
+
+private:
+ static Sequence< Property > lcl_GetPropertySequence()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+ ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties );
+ ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+};
+
+struct StaticLegendWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticLegendWrapperPropertyArray_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart::wrapper
+{
+
+LegendWrapper::LegendWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : m_spChart2ModelContact(spChart2ModelContact)
+ , m_aEventListenerContainer(m_aMutex)
+{
+}
+
+LegendWrapper::~LegendWrapper()
+{
+}
+
+// ____ XShape ____
+awt::Point SAL_CALL LegendWrapper::getPosition()
+{
+ return m_spChart2ModelContact->GetLegendPosition();
+}
+
+void SAL_CALL LegendWrapper::setPosition( const awt::Point& aPosition )
+{
+ Reference< beans::XPropertySet > xProp( getInnerPropertySet() );
+ if( xProp.is() )
+ {
+ awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() );
+
+ chart2::RelativePosition aRelativePosition;
+ aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT;
+ aRelativePosition.Primary = aPageSize.Width == 0 ? 0 : double(aPosition.X)/double(aPageSize.Width);
+ aRelativePosition.Secondary = aPageSize.Height == 0 ? 0 : double(aPosition.Y)/double(aPageSize.Height);
+ xProp->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition) );
+ }
+}
+
+awt::Size SAL_CALL LegendWrapper::getSize()
+{
+ return m_spChart2ModelContact->GetLegendSize();
+}
+
+void SAL_CALL LegendWrapper::setSize( const awt::Size& aSize )
+{
+ Reference< beans::XPropertySet > xProp( getInnerPropertySet() );
+ if( xProp.is() )
+ {
+ awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() );
+ awt::Rectangle aPageRectangle( 0,0,aPageSize.Width,aPageSize.Height);
+
+ awt::Point aPos( getPosition() );
+ awt::Rectangle aNewPositionAndSize(aPos.X,aPos.Y,aSize.Width,aSize.Height);
+
+ PositionAndSizeHelper::moveObject( OBJECTTYPE_LEGEND
+ , xProp, aNewPositionAndSize, awt::Rectangle(), aPageRectangle );
+ }
+}
+
+// ____ XShapeDescriptor (base of XShape) ____
+OUString SAL_CALL LegendWrapper::getShapeType()
+{
+ return "com.sun.star.chart.ChartLegend";
+}
+
+// ____ XComponent ____
+void SAL_CALL LegendWrapper::dispose()
+{
+ Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+
+ MutexGuard aGuard( m_aMutex);
+ clearWrappedPropertySet();
+}
+
+void SAL_CALL LegendWrapper::addEventListener(
+ const Reference< lang::XEventListener >& xListener )
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL LegendWrapper::removeEventListener(
+ const Reference< lang::XEventListener >& aListener )
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+//ReferenceSizePropertyProvider
+void LegendWrapper::updateReferenceSize()
+{
+ Reference< beans::XPropertySet > xProp = getInnerPropertySet();
+ if( xProp.is() )
+ {
+ if( xProp->getPropertyValue( "ReferencePageSize" ).hasValue() )
+ xProp->setPropertyValue( "ReferencePageSize", uno::Any(
+ m_spChart2ModelContact->GetPageSize() ));
+ }
+}
+Any LegendWrapper::getReferenceSize()
+{
+ Any aRet;
+ Reference< beans::XPropertySet > xProp = getInnerPropertySet();
+ if( xProp.is() )
+ aRet = xProp->getPropertyValue( "ReferencePageSize" );
+
+ return aRet;
+}
+awt::Size LegendWrapper::getCurrentSizeForReference()
+{
+ return m_spChart2ModelContact->GetPageSize();
+}
+
+// WrappedPropertySet
+Reference< beans::XPropertySet > LegendWrapper::getInnerPropertySet()
+{
+ Reference< beans::XPropertySet > xRet;
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( xDiagram.is() )
+ xRet.set( xDiagram->getLegend(), uno::UNO_QUERY );
+ OSL_ENSURE(xRet.is(),"LegendWrapper::getInnerPropertySet() is NULL");
+ return xRet;
+}
+
+const Sequence< beans::Property >& LegendWrapper::getPropertySequence()
+{
+ return *StaticLegendWrapperPropertyArray::get();
+}
+
+std::vector< std::unique_ptr<WrappedProperty> > LegendWrapper::createWrappedProperties()
+{
+ std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
+
+ aWrappedProperties.emplace_back( new WrappedLegendAlignmentProperty() );
+ aWrappedProperties.emplace_back( new WrappedProperty( "Expansion", "Expansion"));
+ WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this );
+ //same problem as for wall: the defaults in the old chart are different for different charttypes, so we need to export explicitly
+ aWrappedProperties.emplace_back( new WrappedDirectStateProperty("FillStyle", "FillStyle"));
+ aWrappedProperties.emplace_back( new WrappedDirectStateProperty("FillColor", "FillColor"));
+ WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties );
+ WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
+
+ return aWrappedProperties;
+}
+
+OUString SAL_CALL LegendWrapper::getImplementationName()
+{
+ return "com.sun.star.comp.chart.Legend";
+}
+
+sal_Bool SAL_CALL LegendWrapper::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL LegendWrapper::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart.ChartLegend",
+ "com.sun.star.drawing.Shape",
+ "com.sun.star.xml.UserDefinedAttributesSupplier",
+ "com.sun.star.style.CharacterProperties"
+ };
+}
+
+} // namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx
new file mode 100644
index 000000000..b614b55ca
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx
@@ -0,0 +1,95 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_LEGENDWRAPPER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_LEGENDWRAPPER_HXX
+
+#include <WrappedPropertySet.hxx>
+#include "ReferenceSizePropertyProvider.hxx"
+#include <cppuhelper/implbase.hxx>
+#include <comphelper/interfacecontainer2.hxx>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <memory>
+
+namespace chart
+{
+
+namespace wrapper
+{
+
+class Chart2ModelContact;
+
+class LegendWrapper : public ::cppu::ImplInheritanceHelper<
+ WrappedPropertySet
+ , css::drawing::XShape
+ , css::lang::XComponent
+ , css::lang::XServiceInfo
+ >
+ , public ReferenceSizePropertyProvider
+{
+public:
+ explicit LegendWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ virtual ~LegendWrapper() override;
+
+ /// XServiceInfo declarations
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ //ReferenceSizePropertyProvider
+ virtual void updateReferenceSize() override;
+ virtual css::uno::Any getReferenceSize() override;
+ virtual css::awt::Size getCurrentSizeForReference() override;
+
+ // ____ XShape ____
+ virtual css::awt::Point SAL_CALL getPosition() override;
+ virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
+ virtual css::awt::Size SAL_CALL getSize() override;
+ virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
+
+ // ____ XShapeDescriptor (base of XShape) ____
+ virtual OUString SAL_CALL getShapeType() override;
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose() override;
+ virtual void SAL_CALL addEventListener( const css::uno::Reference<
+ css::lang::XEventListener >& xListener ) override;
+ virtual void SAL_CALL removeEventListener( const css::uno::Reference<
+ css::lang::XEventListener >& aListener ) override;
+
+protected:
+ // ____ WrappedPropertySet ____
+ virtual const css::uno::Sequence< css::beans::Property >& getPropertySequence() override;
+ virtual std::vector< std::unique_ptr<WrappedProperty> > createWrappedProperties() override;
+ virtual css::uno::Reference< css::beans::XPropertySet > getInnerPropertySet() override;
+
+private:
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_LEGENDWRAPPER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx
new file mode 100644
index 000000000..a0f39774b
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx
@@ -0,0 +1,393 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "MinMaxLineWrapper.hxx"
+#include "Chart2ModelContact.hxx"
+#include <DiagramHelper.hxx>
+#include <servicenames_charttypes.hxx>
+#include <cppuhelper/propshlp.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/chart2/XChartType.hpp>
+#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
+#include <com/sun/star/drawing/LineJoint.hpp>
+#include <comphelper/sequence.hxx>
+
+#include <LinePropertiesHelper.hxx>
+#include <UserDefinedProperties.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Any;
+
+namespace
+{
+
+struct StaticMinMaxLineWrapperDefaults_Initializer
+{
+ ::chart::tPropertyValueMap* operator()()
+ {
+ static ::chart::tPropertyValueMap aStaticDefaults;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aStaticDefaults );
+ return &aStaticDefaults;
+ }
+};
+
+struct StaticMinMaxLineWrapperDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticMinMaxLineWrapperDefaults_Initializer >
+{
+};
+
+struct StaticMinMaxLineWrapperPropertyArray_Initializer
+{
+ Sequence< Property >* operator()()
+ {
+ static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
+ return &aPropSeq;
+ }
+
+private:
+ static Sequence< Property > lcl_GetPropertySequence()
+ {
+ std::vector< css::beans::Property > aProperties;
+
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+};
+
+struct StaticMinMaxLineWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticMinMaxLineWrapperPropertyArray_Initializer >
+{
+};
+
+struct StaticMinMaxLineWrapperInfoHelper_Initializer
+{
+ ::cppu::OPropertyArrayHelper* operator()()
+ {
+ static ::cppu::OPropertyArrayHelper aPropHelper( *StaticMinMaxLineWrapperPropertyArray::get() );
+ return &aPropHelper;
+ }
+};
+
+struct StaticMinMaxLineWrapperInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticMinMaxLineWrapperInfoHelper_Initializer >
+{
+};
+
+struct StaticMinMaxLineWrapperInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticMinMaxLineWrapperInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+struct StaticMinMaxLineWrapperInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticMinMaxLineWrapperInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart::wrapper
+{
+
+MinMaxLineWrapper::MinMaxLineWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : m_spChart2ModelContact( spChart2ModelContact )
+ , m_aEventListenerContainer( m_aMutex )
+ , m_aWrappedLineJointProperty( "LineJoint", uno::Any( drawing::LineJoint_NONE ))
+{
+}
+
+MinMaxLineWrapper::~MinMaxLineWrapper()
+{
+}
+
+// ____ XComponent ____
+void SAL_CALL MinMaxLineWrapper::dispose()
+{
+ Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+}
+
+void SAL_CALL MinMaxLineWrapper::addEventListener(
+ const Reference< lang::XEventListener >& xListener )
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL MinMaxLineWrapper::removeEventListener(
+ const Reference< lang::XEventListener >& aListener )
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+//XPropertySet
+uno::Reference< beans::XPropertySetInfo > SAL_CALL MinMaxLineWrapper::getPropertySetInfo()
+{
+ return *StaticMinMaxLineWrapperInfo::get();
+}
+
+void SAL_CALL MinMaxLineWrapper::setPropertyValue( const OUString& rPropertyName, const uno::Any& rValue )
+{
+ Reference< beans::XPropertySet > xPropSet;
+
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ const Sequence< Reference< chart2::XChartType > > aTypes(
+ ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) );
+ for( Reference< chart2::XChartType > const & xType : aTypes )
+ {
+ if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
+ {
+ Reference< chart2::XDataSeriesContainer > xSeriesContainer(xType,uno::UNO_QUERY);
+ if( xSeriesContainer.is() )
+ {
+ Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesContainer->getDataSeries() );
+ if(aSeriesSeq.hasElements())
+ {
+ xPropSet.set(aSeriesSeq[0],uno::UNO_QUERY);
+ if(xPropSet.is())
+ {
+ if( rPropertyName == "LineColor" )
+ xPropSet->setPropertyValue( "Color", rValue );
+ else if( rPropertyName == "LineTransparence" )
+ xPropSet->setPropertyValue( "Transparency", rValue );
+ else if( rPropertyName == m_aWrappedLineJointProperty.getOuterName() )
+ m_aWrappedLineJointProperty.setPropertyValue( rValue, xPropSet );
+ else
+ xPropSet->setPropertyValue( rPropertyName, rValue );
+ return;
+ }
+ }
+ }
+ }
+ }
+}
+uno::Any SAL_CALL MinMaxLineWrapper::getPropertyValue( const OUString& rPropertyName )
+{
+ Any aRet;
+
+ Reference< beans::XPropertySet > xPropSet;
+
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ const Sequence< Reference< chart2::XChartType > > aTypes(
+ ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) );
+ for( Reference< chart2::XChartType > const & xType : aTypes )
+ {
+ if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
+ {
+ Reference< chart2::XDataSeriesContainer > xSeriesContainer(xType,uno::UNO_QUERY);
+ if( xSeriesContainer.is() )
+ {
+ Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesContainer->getDataSeries() );
+ if(aSeriesSeq.hasElements())
+ {
+ xPropSet.set(aSeriesSeq[0],uno::UNO_QUERY);
+ break;
+ }
+ }
+ }
+ }
+ if(xPropSet.is())
+ {
+ if( rPropertyName == "LineColor" )
+ aRet = xPropSet->getPropertyValue( "Color" );
+ else if( rPropertyName == "LineTransparence" )
+ aRet = xPropSet->getPropertyValue( "Transparency" );
+ else if( rPropertyName == m_aWrappedLineJointProperty.getOuterName() )
+ aRet = m_aWrappedLineJointProperty.getPropertyValue( xPropSet );
+ else
+ aRet = xPropSet->getPropertyValue( rPropertyName );
+
+ }
+ return aRet;
+}
+
+void SAL_CALL MinMaxLineWrapper::addPropertyChangeListener( const OUString& /*aPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
+{
+ OSL_FAIL("not implemented");
+}
+void SAL_CALL MinMaxLineWrapper::removePropertyChangeListener( const OUString& /*aPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
+{
+ OSL_FAIL("not implemented");
+}
+void SAL_CALL MinMaxLineWrapper::addVetoableChangeListener( const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
+{
+ OSL_FAIL("not implemented");
+}
+void SAL_CALL MinMaxLineWrapper::removeVetoableChangeListener( const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
+{
+ OSL_FAIL("not implemented");
+}
+
+//XMultiPropertySet
+//getPropertySetInfo() already declared in XPropertySet
+void SAL_CALL MinMaxLineWrapper::setPropertyValues( const uno::Sequence< OUString >& rNameSeq, const uno::Sequence< uno::Any >& rValueSeq )
+{
+ sal_Int32 nMinCount = std::min( rValueSeq.getLength(), rNameSeq.getLength() );
+ for(sal_Int32 nN=0; nN<nMinCount; nN++)
+ {
+ OUString aPropertyName( rNameSeq[nN] );
+ try
+ {
+ setPropertyValue( aPropertyName, rValueSeq[nN] );
+ }
+ catch( const beans::UnknownPropertyException& )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+ //todo: store unknown properties elsewhere
+}
+uno::Sequence< uno::Any > SAL_CALL MinMaxLineWrapper::getPropertyValues( const uno::Sequence< OUString >& rNameSeq )
+{
+ Sequence< Any > aRetSeq;
+ if( rNameSeq.hasElements() )
+ {
+ aRetSeq.realloc( rNameSeq.getLength() );
+ for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
+ {
+ OUString aPropertyName( rNameSeq[nN] );
+ aRetSeq[nN] = getPropertyValue( aPropertyName );
+ }
+ }
+ return aRetSeq;
+}
+void SAL_CALL MinMaxLineWrapper::addPropertiesChangeListener(
+ const uno::Sequence< OUString >& /* aPropertyNames */,
+ const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
+{
+ OSL_FAIL("not implemented");
+}
+void SAL_CALL MinMaxLineWrapper::removePropertiesChangeListener(
+ const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
+{
+ OSL_FAIL("not implemented");
+}
+void SAL_CALL MinMaxLineWrapper::firePropertiesChangeEvent(
+ const uno::Sequence< OUString >& /* aPropertyNames */,
+ const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
+{
+ OSL_FAIL("not implemented");
+}
+
+//XPropertyState
+beans::PropertyState SAL_CALL MinMaxLineWrapper::getPropertyState( const OUString& rPropertyName )
+{
+ if( rPropertyName == m_aWrappedLineJointProperty.getOuterName() )
+ return beans::PropertyState_DEFAULT_VALUE;
+
+ uno::Any aDefault( getPropertyDefault( rPropertyName ) );
+ uno::Any aValue( getPropertyValue( rPropertyName ) );
+
+ if( aDefault == aValue )
+ return beans::PropertyState_DEFAULT_VALUE;
+
+ return beans::PropertyState_DIRECT_VALUE;
+}
+uno::Sequence< beans::PropertyState > SAL_CALL MinMaxLineWrapper::getPropertyStates( const uno::Sequence< OUString >& rNameSeq )
+{
+ Sequence< beans::PropertyState > aRetSeq;
+ if( rNameSeq.hasElements() )
+ {
+ aRetSeq.realloc( rNameSeq.getLength() );
+ for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
+ {
+ OUString aPropertyName( rNameSeq[nN] );
+ aRetSeq[nN] = getPropertyState( aPropertyName );
+ }
+ }
+ return aRetSeq;
+}
+void SAL_CALL MinMaxLineWrapper::setPropertyToDefault( const OUString& rPropertyName )
+{
+ setPropertyValue( rPropertyName, getPropertyDefault(rPropertyName) );
+}
+
+uno::Any SAL_CALL MinMaxLineWrapper::getPropertyDefault( const OUString& rPropertyName )
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticMinMaxLineWrapperDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( StaticMinMaxLineWrapperInfoHelper::get()->getHandleByName( rPropertyName ) ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+//XMultiPropertyStates
+//getPropertyStates() already declared in XPropertyState
+void SAL_CALL MinMaxLineWrapper::setAllPropertiesToDefault( )
+{
+ const Sequence< beans::Property >& rPropSeq = *StaticMinMaxLineWrapperPropertyArray::get();
+ for(beans::Property const & prop : rPropSeq)
+ {
+ setPropertyToDefault( prop.Name );
+ }
+}
+void SAL_CALL MinMaxLineWrapper::setPropertiesToDefault( const uno::Sequence< OUString >& rNameSeq )
+{
+ for(OUString const & s : rNameSeq)
+ {
+ setPropertyToDefault( s );
+ }
+}
+uno::Sequence< uno::Any > SAL_CALL MinMaxLineWrapper::getPropertyDefaults( const uno::Sequence< OUString >& rNameSeq )
+{
+ Sequence< Any > aRetSeq;
+ if( rNameSeq.hasElements() )
+ {
+ aRetSeq.realloc( rNameSeq.getLength() );
+ for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
+ {
+ OUString aPropertyName( rNameSeq[nN] );
+ aRetSeq[nN] = getPropertyDefault( aPropertyName );
+ }
+ }
+ return aRetSeq;
+}
+
+OUString SAL_CALL MinMaxLineWrapper::getImplementationName()
+{
+ return "com.sun.star.comp.chart.ChartLine";
+}
+
+sal_Bool SAL_CALL MinMaxLineWrapper::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL MinMaxLineWrapper::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart.ChartLine",
+ "com.sun.star.xml.UserDefinedAttributesSupplier",
+ "com.sun.star.drawing.LineProperties"
+ };
+}
+
+} // namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx
new file mode 100644
index 000000000..72966ee04
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx
@@ -0,0 +1,112 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_MINMAXLINEWRAPPER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_MINMAXLINEWRAPPER_HXX
+
+#include <MutexContainer.hxx>
+#include <WrappedIgnoreProperty.hxx>
+#include <comphelper/interfacecontainer2.hxx>
+
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XMultiPropertyStates.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <memory>
+
+namespace chart
+{
+
+namespace wrapper
+{
+
+class Chart2ModelContact;
+
+class MinMaxLineWrapper : public MutexContainer
+ , public ::cppu::WeakImplHelper
+ < css::lang::XComponent
+ , css::lang::XServiceInfo
+ , css::beans::XPropertySet
+ , css::beans::XMultiPropertySet
+ , css::beans::XPropertyState
+ , css::beans::XMultiPropertyStates
+ >
+{
+public:
+ explicit MinMaxLineWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ virtual ~MinMaxLineWrapper() override;
+
+ /// XServiceInfo declarations
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose() override;
+ virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
+ virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
+
+ //XPropertySet
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
+
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
+ virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
+
+ virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
+ virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
+ virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
+ virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
+
+ //XMultiPropertySet
+ //getPropertySetInfo() already declared in XPropertySet
+ virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override;
+ virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
+ virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
+ virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
+ virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
+
+ //XPropertyState
+ virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
+ virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
+ virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
+ virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
+
+ //XMultiPropertyStates
+ //getPropertyStates() already declared in XPropertyState
+ virtual void SAL_CALL setAllPropertiesToDefault( ) override;
+ virtual void SAL_CALL setPropertiesToDefault( const css::uno::Sequence< OUString >& aPropertyNames ) override;
+ virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer;
+
+ WrappedIgnoreProperty m_aWrappedLineJointProperty;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_MINMAXLINEWRAPPER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/ReferenceSizePropertyProvider.hxx b/chart2/source/controller/chartapiwrapper/ReferenceSizePropertyProvider.hxx
new file mode 100644
index 000000000..432f3123c
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/ReferenceSizePropertyProvider.hxx
@@ -0,0 +1,45 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_REFERENCESIZEPROPERTYPROVIDER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_REFERENCESIZEPROPERTYPROVIDER_HXX
+
+#include <com/sun/star/awt/Size.hpp>
+
+namespace chart
+{
+namespace wrapper
+{
+class ReferenceSizePropertyProvider
+{
+public:
+ virtual void updateReferenceSize() = 0;
+ virtual css::uno::Any getReferenceSize() = 0;
+ virtual css::awt::Size getCurrentSizeForReference() = 0;
+
+protected:
+ ~ReferenceSizePropertyProvider() {}
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_REFERENCESIZEPROPERTYPROVIDER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
new file mode 100644
index 000000000..7de1b376b
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx
@@ -0,0 +1,512 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "TitleWrapper.hxx"
+#include "Chart2ModelContact.hxx"
+#include <ControllerLockGuard.hxx>
+
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/chart2/RelativePosition.hpp>
+#include <com/sun/star/chart2/XTitle.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+
+#include <CharacterProperties.hxx>
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <UserDefinedProperties.hxx>
+#include "WrappedCharacterHeightProperty.hxx"
+#include "WrappedTextRotationProperty.hxx"
+#include "WrappedAutomaticPositionProperties.hxx"
+#include "WrappedScaleTextProperties.hxx"
+
+#include <algorithm>
+#include <rtl/ustrbuf.hxx>
+#include <cppuhelper/propshlp.hxx>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::beans::Property;
+using ::osl::MutexGuard;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+namespace chart
+{
+namespace {
+
+class WrappedTitleStringProperty : public WrappedProperty
+{
+public:
+ explicit WrappedTitleStringProperty( const Reference< uno::XComponentContext >& xContext );
+
+ virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const override;
+ virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override;
+ virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override;
+
+protected:
+ Reference< uno::XComponentContext > m_xContext;
+};
+
+}
+
+WrappedTitleStringProperty::WrappedTitleStringProperty( const Reference< uno::XComponentContext >& xContext )
+ : ::chart::WrappedProperty( "String", OUString() )
+ , m_xContext( xContext )
+{
+}
+
+void WrappedTitleStringProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ Reference< chart2::XTitle > xTitle(xInnerPropertySet,uno::UNO_QUERY);
+ if(xTitle.is())
+ {
+ OUString aString;
+ rOuterValue >>= aString;
+ TitleHelper::setCompleteString( aString, xTitle, m_xContext );
+ }
+}
+Any WrappedTitleStringProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) );
+ Reference< chart2::XTitle > xTitle(xInnerPropertySet,uno::UNO_QUERY);
+ if(xTitle.is())
+ {
+ const Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText());
+
+ OUStringBuffer aBuf;
+ for( Reference< chart2::XFormattedString > const & formattedStr : aStrings )
+ {
+ aBuf.append( formattedStr->getString());
+ }
+ aRet <<= aBuf.makeStringAndClear();
+ }
+ return aRet;
+}
+Any WrappedTitleStringProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ return uno::Any( OUString() );//default title is an empty String
+}
+
+namespace {
+
+class WrappedStackedTextProperty : public WrappedProperty
+{
+public:
+ WrappedStackedTextProperty();
+};
+
+}
+
+WrappedStackedTextProperty::WrappedStackedTextProperty()
+ : ::chart::WrappedProperty( "StackedText", "StackCharacters" )
+{
+}
+
+}// end namespace chart
+
+namespace
+{
+
+enum
+{
+ PROP_TITLE_STRING,
+ PROP_TITLE_TEXT_ROTATION,
+ PROP_TITLE_TEXT_STACKED
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "String",
+ PROP_TITLE_STRING,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "TextRotation",
+ PROP_TITLE_TEXT_ROTATION,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "StackedText",
+ PROP_TITLE_TEXT_STACKED,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+struct StaticTitleWrapperPropertyArray_Initializer
+{
+ Sequence< Property >* operator()()
+ {
+ static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
+ return &aPropSeq;
+ }
+
+private:
+ static Sequence< Property > lcl_GetPropertySequence()
+ {
+ std::vector< beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+ ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties );
+ ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+};
+
+struct StaticTitleWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticTitleWrapperPropertyArray_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart::wrapper
+{
+
+TitleWrapper::TitleWrapper( ::chart::TitleHelper::eTitleType eTitleType,
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) :
+ m_spChart2ModelContact( spChart2ModelContact ),
+ m_aEventListenerContainer( m_aMutex ),
+ m_eTitleType(eTitleType)
+{
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChart2Document() );
+ if( !getTitleObject().is() ) //#i83831# create an empty title at the model, thus references to properties can be mapped correctly
+ TitleHelper::createTitle( m_eTitleType, OUString(), m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
+}
+
+TitleWrapper::~TitleWrapper()
+{
+}
+
+// ____ XShape ____
+awt::Point SAL_CALL TitleWrapper::getPosition()
+{
+ return m_spChart2ModelContact->GetTitlePosition( getTitleObject() );
+}
+
+void SAL_CALL TitleWrapper::setPosition( const awt::Point& aPosition )
+{
+ Reference< beans::XPropertySet > xPropertySet( getInnerPropertySet() );
+ if(xPropertySet.is())
+ {
+ awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() );
+
+ chart2::RelativePosition aRelativePosition;
+ aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT;
+ aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width);
+ aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height);
+ xPropertySet->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition) );
+ }
+}
+
+awt::Size SAL_CALL TitleWrapper::getSize()
+{
+ return m_spChart2ModelContact->GetTitleSize( getTitleObject() );
+}
+
+void SAL_CALL TitleWrapper::setSize( const awt::Size& /*aSize*/ )
+{
+ OSL_FAIL( "trying to set size of title" );
+}
+
+// ____ XShapeDescriptor (base of XShape) ____
+OUString SAL_CALL TitleWrapper::getShapeType()
+{
+ return "com.sun.star.chart.ChartTitle";
+}
+
+// ____ XComponent ____
+void SAL_CALL TitleWrapper::dispose()
+{
+ Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+
+ MutexGuard aGuard( m_aMutex);
+ clearWrappedPropertySet();
+}
+
+void SAL_CALL TitleWrapper::addEventListener(
+ const Reference< lang::XEventListener >& xListener )
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL TitleWrapper::removeEventListener(
+ const Reference< lang::XEventListener >& aListener )
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+Reference< beans::XPropertySet > TitleWrapper::getFirstCharacterPropertySet()
+{
+ Reference< beans::XPropertySet > xProp;
+
+ Reference< chart2::XTitle > xTitle( getTitleObject() );
+ if( xTitle.is())
+ {
+ Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText());
+ if( aStrings.hasElements() )
+ xProp.set( aStrings[0], uno::UNO_QUERY );
+ }
+
+ return xProp;
+}
+
+void TitleWrapper::getFastCharacterPropertyValue( sal_Int32 nHandle, Any& rValue )
+{
+ OSL_ASSERT( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle &&
+ nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP );
+
+ Reference< beans::XPropertySet > xProp = getFirstCharacterPropertySet();
+ Reference< beans::XFastPropertySet > xFastProp( xProp, uno::UNO_QUERY );
+ if(xProp.is())
+ {
+ const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle );
+ if( pWrappedProperty )
+ {
+ rValue = pWrappedProperty->getPropertyValue( xProp );
+ }
+ else if( xFastProp.is() )
+ {
+ rValue = xFastProp->getFastPropertyValue( nHandle );
+ }
+ }
+
+}
+
+void TitleWrapper::setFastCharacterPropertyValue(
+ sal_Int32 nHandle, const Any& rValue )
+{
+ OSL_ASSERT( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle &&
+ nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP );
+
+ Reference< chart2::XTitle > xTitle( getTitleObject() );
+ if( !xTitle.is())
+ return;
+
+ const Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText());
+ const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle );
+
+ for( Reference< chart2::XFormattedString > const & formattedStr : aStrings )
+ {
+ Reference< beans::XFastPropertySet > xFastPropertySet( formattedStr, uno::UNO_QUERY );
+ Reference< beans::XPropertySet > xPropSet( xFastPropertySet, uno::UNO_QUERY );
+
+ if( pWrappedProperty )
+ pWrappedProperty->setPropertyValue( rValue, xPropSet );
+ else if( xFastPropertySet.is() )
+ xFastPropertySet->setFastPropertyValue( nHandle, rValue );
+ }
+}
+
+// WrappedPropertySet
+
+void SAL_CALL TitleWrapper::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
+{
+ sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
+ if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
+ {
+ setFastCharacterPropertyValue( nHandle, rValue );
+ }
+ else
+ WrappedPropertySet::setPropertyValue( rPropertyName, rValue );
+}
+
+Any SAL_CALL TitleWrapper::getPropertyValue( const OUString& rPropertyName )
+{
+ Any aRet;
+ sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
+ if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
+ getFastCharacterPropertyValue( nHandle, aRet );
+ else
+ aRet = WrappedPropertySet::getPropertyValue( rPropertyName );
+ return aRet;
+}
+
+beans::PropertyState SAL_CALL TitleWrapper::getPropertyState( const OUString& rPropertyName )
+{
+ beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE );
+
+ sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
+ if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
+ {
+ Reference< beans::XPropertyState > xPropState( getFirstCharacterPropertySet(), uno::UNO_QUERY );
+ if( xPropState.is() )
+ {
+ const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
+ if( pWrappedProperty )
+ aState = pWrappedProperty->getPropertyState( xPropState );
+ else
+ aState = xPropState->getPropertyState( rPropertyName );
+ }
+ }
+ else
+ aState = WrappedPropertySet::getPropertyState( rPropertyName );
+
+ return aState;
+}
+void SAL_CALL TitleWrapper::setPropertyToDefault( const OUString& rPropertyName )
+{
+ sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
+ if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
+ {
+ Any aDefault = getPropertyDefault( rPropertyName );
+ setFastCharacterPropertyValue( nHandle, aDefault );
+ }
+ else
+ WrappedPropertySet::setPropertyToDefault( rPropertyName );
+}
+Any SAL_CALL TitleWrapper::getPropertyDefault( const OUString& rPropertyName )
+{
+ Any aRet;
+
+ sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
+ if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
+ {
+ Reference< beans::XPropertyState > xPropState( getFirstCharacterPropertySet(), uno::UNO_QUERY );
+ if( xPropState.is() )
+ {
+ const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName );
+ if( pWrappedProperty )
+ aRet = pWrappedProperty->getPropertyDefault(xPropState);
+ else
+ aRet = xPropState->getPropertyDefault( rPropertyName );
+ }
+ }
+ else
+ aRet = WrappedPropertySet::getPropertyDefault( rPropertyName );
+
+ return aRet;
+}
+
+void SAL_CALL TitleWrapper::addPropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& xListener )
+{
+ sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
+ if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
+ {
+ Reference< beans::XPropertySet > xPropSet = getFirstCharacterPropertySet();
+ if( xPropSet.is() )
+ xPropSet->addPropertyChangeListener( rPropertyName, xListener );
+ }
+ else
+ WrappedPropertySet::addPropertyChangeListener( rPropertyName, xListener );
+}
+void SAL_CALL TitleWrapper::removePropertyChangeListener( const OUString& rPropertyName, const Reference< beans::XPropertyChangeListener >& xListener )
+{
+ sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName );
+ if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) )
+ {
+ Reference< beans::XPropertySet > xPropSet = getFirstCharacterPropertySet();
+ if( xPropSet.is() )
+ xPropSet->removePropertyChangeListener( rPropertyName, xListener );
+ }
+ else
+ WrappedPropertySet::removePropertyChangeListener( rPropertyName, xListener );
+}
+
+//ReferenceSizePropertyProvider
+void TitleWrapper::updateReferenceSize()
+{
+ Reference< beans::XPropertySet > xProp( getTitleObject(), uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ if( xProp->getPropertyValue( "ReferencePageSize" ).hasValue() )
+ xProp->setPropertyValue( "ReferencePageSize", uno::Any(
+ m_spChart2ModelContact->GetPageSize() ));
+ }
+}
+Any TitleWrapper::getReferenceSize()
+{
+ Any aRet;
+ Reference< beans::XPropertySet > xProp( getTitleObject(), uno::UNO_QUERY );
+ if( xProp.is() )
+ aRet = xProp->getPropertyValue( "ReferencePageSize" );
+
+ return aRet;
+}
+awt::Size TitleWrapper::getCurrentSizeForReference()
+{
+ return m_spChart2ModelContact->GetPageSize();
+}
+
+Reference< chart2::XTitle > TitleWrapper::getTitleObject()
+{
+ return TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() );
+}
+
+// WrappedPropertySet
+
+Reference< beans::XPropertySet > TitleWrapper::getInnerPropertySet()
+{
+ return Reference< beans::XPropertySet >( getTitleObject(), uno::UNO_QUERY );
+}
+
+const Sequence< beans::Property >& TitleWrapper::getPropertySequence()
+{
+ return *StaticTitleWrapperPropertyArray::get();
+}
+
+std::vector< std::unique_ptr<WrappedProperty> > TitleWrapper::createWrappedProperties()
+{
+ std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
+
+ aWrappedProperties.emplace_back( new WrappedTitleStringProperty( m_spChart2ModelContact->m_xContext ) );
+ aWrappedProperties.emplace_back( new WrappedTextRotationProperty( true ) );
+ aWrappedProperties.emplace_back( new WrappedStackedTextProperty() );
+ WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this );
+ WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties );
+ WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact );
+
+ return aWrappedProperties;
+}
+
+OUString SAL_CALL TitleWrapper::getImplementationName()
+{
+ return "com.sun.star.comp.chart.Title";
+}
+
+sal_Bool SAL_CALL TitleWrapper::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL TitleWrapper::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart.ChartTitle",
+ "com.sun.star.drawing.Shape",
+ "com.sun.star.xml.UserDefinedAttributesSupplier",
+ "com.sun.star.style.CharacterProperties"
+ };
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx
new file mode 100644
index 000000000..e1e7282af
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx
@@ -0,0 +1,117 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_TITLEWRAPPER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_TITLEWRAPPER_HXX
+
+#include <WrappedPropertySet.hxx>
+#include "ReferenceSizePropertyProvider.hxx"
+#include <TitleHelper.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <comphelper/interfacecontainer2.hxx>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <memory>
+
+namespace chart::wrapper { class Chart2ModelContact; }
+namespace com::sun::star::chart2 { class XTitle; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class TitleWrapper final : public ::cppu::ImplInheritanceHelper<
+ WrappedPropertySet
+ , css::drawing::XShape
+ , css::lang::XComponent
+ , css::lang::XServiceInfo
+ >
+ , public ReferenceSizePropertyProvider
+{
+public:
+ TitleWrapper( ::chart::TitleHelper::eTitleType eTitleType,
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact );
+ virtual ~TitleWrapper() override;
+
+ /// XServiceInfo declarations
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ //ReferenceSizePropertyProvider
+ virtual void updateReferenceSize() override;
+ virtual css::uno::Any getReferenceSize() override;
+ virtual css::awt::Size getCurrentSizeForReference() override;
+
+private:
+ // ____ XShape ____
+ virtual css::awt::Point SAL_CALL getPosition() override;
+ virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override;
+ virtual css::awt::Size SAL_CALL getSize() override;
+ virtual void SAL_CALL setSize( const css::awt::Size& aSize ) override;
+
+ // ____ XShapeDescriptor (base of XShape) ____
+ virtual OUString SAL_CALL getShapeType() override;
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose() override;
+ virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
+ virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
+
+ // character properties have to be handled differently (via the XFormattedString elements)
+ void getFastCharacterPropertyValue( sal_Int32 nHandle, css::uno::Any& rValue );
+ /// @throws css::uno::Exception
+ void setFastCharacterPropertyValue( sal_Int32 nHandle, const css::uno::Any& rValue );
+
+ // ____ WrappedPropertySet ____
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
+ virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
+
+ virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
+ virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
+
+ virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
+
+ virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
+ virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
+
+ virtual css::uno::Reference< css::beans::XPropertySet > getInnerPropertySet() override;
+
+ virtual const css::uno::Sequence< css::beans::Property >& getPropertySequence() override;
+ virtual std::vector< std::unique_ptr<WrappedProperty> > createWrappedProperties() override;
+
+ css::uno::Reference< css::beans::XPropertySet > getFirstCharacterPropertySet();
+
+ css::uno::Reference< css::chart2::XTitle > getTitleObject();
+
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer;
+
+ ::chart::TitleHelper::eTitleType m_eTitleType;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_TITLEWRAPPER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx
new file mode 100644
index 000000000..ab7e5b333
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx
@@ -0,0 +1,361 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "UpDownBarWrapper.hxx"
+#include "Chart2ModelContact.hxx"
+#include <DiagramHelper.hxx>
+#include <servicenames_charttypes.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <cppuhelper/propshlp.hxx>
+#include <com/sun/star/chart2/XChartType.hpp>
+#include <comphelper/sequence.hxx>
+
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <UserDefinedProperties.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Any;
+
+namespace
+{
+
+struct StaticUpDownBarWrapperPropertyArray_Initializer
+{
+ Sequence< Property >* operator()()
+ {
+ static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
+ return &aPropSeq;
+ }
+
+private:
+ static Sequence< Property > lcl_GetPropertySequence()
+ {
+ std::vector< css::beans::Property > aProperties;
+
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+};
+
+struct StaticUpDownBarWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticUpDownBarWrapperPropertyArray_Initializer >
+{
+};
+
+struct StaticUpDownBarWrapperInfoHelper_Initializer
+{
+ ::cppu::OPropertyArrayHelper* operator()()
+ {
+ static ::cppu::OPropertyArrayHelper aPropHelper( *StaticUpDownBarWrapperPropertyArray::get() );
+ return &aPropHelper;
+ }
+};
+
+struct StaticUpDownBarWrapperInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticUpDownBarWrapperInfoHelper_Initializer >
+{
+};
+
+struct StaticUpDownBarWrapperInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticUpDownBarWrapperInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+struct StaticUpDownBarWrapperInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticUpDownBarWrapperInfo_Initializer >
+{
+};
+
+struct StaticUpDownBarWrapperDefaults_Initializer
+{
+ ::chart::tPropertyValueMap* operator()()
+ {
+ static ::chart::tPropertyValueMap aStaticDefaults;
+ lcl_AddDefaultsToMap( aStaticDefaults );
+ return &aStaticDefaults;
+ }
+private:
+ static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
+ {
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
+ ::chart::FillProperties::AddDefaultsToMap( rOutMap );
+ }
+};
+
+struct StaticUpDownBarWrapperDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticUpDownBarWrapperDefaults_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart::wrapper
+{
+
+UpDownBarWrapper::UpDownBarWrapper(
+ bool bUp, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : m_spChart2ModelContact( spChart2ModelContact )
+ , m_aEventListenerContainer( m_aMutex )
+ , m_aPropertySetName( bUp ? OUString( "WhiteDay" ) : OUString( "BlackDay" ))
+{
+}
+
+UpDownBarWrapper::~UpDownBarWrapper()
+{
+}
+
+// ____ XComponent ____
+void SAL_CALL UpDownBarWrapper::dispose()
+{
+ Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+}
+
+void SAL_CALL UpDownBarWrapper::addEventListener(
+ const Reference< lang::XEventListener >& xListener )
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL UpDownBarWrapper::removeEventListener(
+ const Reference< lang::XEventListener >& aListener )
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+//XPropertySet
+uno::Reference< beans::XPropertySetInfo > SAL_CALL UpDownBarWrapper::getPropertySetInfo()
+{
+ return *StaticUpDownBarWrapperInfo::get();
+}
+void SAL_CALL UpDownBarWrapper::setPropertyValue( const OUString& rPropertyName, const uno::Any& rValue )
+{
+ Reference< beans::XPropertySet > xPropSet;
+
+ const Sequence< Reference< chart2::XChartType > > aTypes(
+ ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) );
+ for( Reference< chart2::XChartType > const & xType : aTypes )
+ {
+ if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
+ {
+ Reference< beans::XPropertySet > xTypeProps( xType, uno::UNO_QUERY );
+ if(xTypeProps.is())
+ {
+ xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet;
+ }
+ }
+ }
+ if(xPropSet.is())
+ xPropSet->setPropertyValue( rPropertyName, rValue );
+}
+uno::Any SAL_CALL UpDownBarWrapper::getPropertyValue( const OUString& rPropertyName )
+{
+ Any aRet;
+
+ Reference< beans::XPropertySet > xPropSet;
+
+ const Sequence< Reference< chart2::XChartType > > aTypes(
+ ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) );
+ for( Reference< chart2::XChartType > const & xType : aTypes )
+ {
+ if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
+ {
+ Reference< beans::XPropertySet > xTypeProps( xType, uno::UNO_QUERY );
+ if(xTypeProps.is())
+ {
+ xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet;
+ }
+ }
+ }
+ if(xPropSet.is())
+ aRet = xPropSet->getPropertyValue( rPropertyName );
+ return aRet;
+}
+
+void SAL_CALL UpDownBarWrapper::addPropertyChangeListener( const OUString& /*aPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
+{
+ OSL_FAIL("not implemented");
+}
+void SAL_CALL UpDownBarWrapper::removePropertyChangeListener( const OUString& /*aPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
+{
+ OSL_FAIL("not implemented");
+}
+void SAL_CALL UpDownBarWrapper::addVetoableChangeListener( const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
+{
+ OSL_FAIL("not implemented");
+}
+void SAL_CALL UpDownBarWrapper::removeVetoableChangeListener( const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
+{
+ OSL_FAIL("not implemented");
+}
+
+//XMultiPropertySet
+//getPropertySetInfo() already declared in XPropertySet
+void SAL_CALL UpDownBarWrapper::setPropertyValues( const uno::Sequence< OUString >& rNameSeq, const uno::Sequence< uno::Any >& rValueSeq )
+{
+ sal_Int32 nMinCount = std::min( rValueSeq.getLength(), rNameSeq.getLength() );
+ for(sal_Int32 nN=0; nN<nMinCount; nN++)
+ {
+ OUString aPropertyName( rNameSeq[nN] );
+ try
+ {
+ setPropertyValue( aPropertyName, rValueSeq[nN] );
+ }
+ catch( const beans::UnknownPropertyException& )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+ //todo: store unknown properties elsewhere
+}
+uno::Sequence< uno::Any > SAL_CALL UpDownBarWrapper::getPropertyValues( const uno::Sequence< OUString >& rNameSeq )
+{
+ Sequence< Any > aRetSeq;
+ if( rNameSeq.hasElements() )
+ {
+ aRetSeq.realloc( rNameSeq.getLength() );
+ for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
+ {
+ OUString aPropertyName( rNameSeq[nN] );
+ aRetSeq[nN] = getPropertyValue( aPropertyName );
+ }
+ }
+ return aRetSeq;
+}
+void SAL_CALL UpDownBarWrapper::addPropertiesChangeListener( const uno::Sequence< OUString >& /* aPropertyNames */, const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
+{
+ OSL_FAIL("not implemented");
+}
+void SAL_CALL UpDownBarWrapper::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
+{
+ OSL_FAIL("not implemented");
+}
+void SAL_CALL UpDownBarWrapper::firePropertiesChangeEvent( const uno::Sequence< OUString >& /* aPropertyNames */, const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
+{
+ OSL_FAIL("not implemented");
+}
+
+//XPropertyState
+beans::PropertyState SAL_CALL UpDownBarWrapper::getPropertyState( const OUString& rPropertyName )
+{
+ uno::Any aDefault( getPropertyDefault( rPropertyName ) );
+ uno::Any aValue( getPropertyValue( rPropertyName ) );
+
+ if( aDefault == aValue )
+ return beans::PropertyState_DEFAULT_VALUE;
+
+ return beans::PropertyState_DIRECT_VALUE;
+}
+uno::Sequence< beans::PropertyState > SAL_CALL UpDownBarWrapper::getPropertyStates( const uno::Sequence< OUString >& rNameSeq )
+{
+ Sequence< beans::PropertyState > aRetSeq;
+ if( rNameSeq.hasElements() )
+ {
+ aRetSeq.realloc( rNameSeq.getLength() );
+ for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
+ {
+ OUString aPropertyName( rNameSeq[nN] );
+ aRetSeq[nN] = getPropertyState( aPropertyName );
+ }
+ }
+ return aRetSeq;
+}
+void SAL_CALL UpDownBarWrapper::setPropertyToDefault( const OUString& rPropertyName )
+{
+ setPropertyValue( rPropertyName, getPropertyDefault(rPropertyName) );
+}
+
+uno::Any SAL_CALL UpDownBarWrapper::getPropertyDefault( const OUString& rPropertyName )
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticUpDownBarWrapperDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( StaticUpDownBarWrapperInfoHelper::get()->getHandleByName( rPropertyName ) ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+//XMultiPropertyStates
+//getPropertyStates() already declared in XPropertyState
+void SAL_CALL UpDownBarWrapper::setAllPropertiesToDefault( )
+{
+ const Sequence< beans::Property >& rPropSeq = *StaticUpDownBarWrapperPropertyArray::get();
+ for(beans::Property const & prop : rPropSeq)
+ {
+ setPropertyToDefault( prop.Name );
+ }
+}
+void SAL_CALL UpDownBarWrapper::setPropertiesToDefault( const uno::Sequence< OUString >& rNameSeq )
+{
+ for(OUString const & s : rNameSeq)
+ {
+ setPropertyToDefault( s );
+ }
+}
+uno::Sequence< uno::Any > SAL_CALL UpDownBarWrapper::getPropertyDefaults( const uno::Sequence< OUString >& rNameSeq )
+{
+ Sequence< Any > aRetSeq;
+ if( rNameSeq.hasElements() )
+ {
+ aRetSeq.realloc( rNameSeq.getLength() );
+ for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++)
+ {
+ OUString aPropertyName( rNameSeq[nN] );
+ aRetSeq[nN] = getPropertyDefault( aPropertyName );
+ }
+ }
+ return aRetSeq;
+}
+
+OUString SAL_CALL UpDownBarWrapper::getImplementationName()
+{
+ return "com.sun.star.comp.chart.ChartArea";
+}
+
+sal_Bool SAL_CALL UpDownBarWrapper::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL UpDownBarWrapper::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart.ChartArea",
+ "com.sun.star.drawing.LineProperties",
+ "com.sun.star.drawing.FillProperties",
+ "com.sun.star.xml.UserDefinedAttributesSupplier"
+ };
+}
+
+} // namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx
new file mode 100644
index 000000000..a1b455bcc
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx
@@ -0,0 +1,113 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_UPDOWNBARWRAPPER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_UPDOWNBARWRAPPER_HXX
+
+#include <MutexContainer.hxx>
+#include <comphelper/interfacecontainer2.hxx>
+
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XMultiPropertyStates.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <memory>
+
+namespace chart
+{
+
+namespace wrapper
+{
+
+class Chart2ModelContact;
+
+class UpDownBarWrapper : public MutexContainer
+ , public ::cppu::WeakImplHelper
+ < css::lang::XComponent
+ , css::lang::XServiceInfo
+ , css::beans::XPropertySet
+ , css::beans::XMultiPropertySet
+ , css::beans::XPropertyState
+ , css::beans::XMultiPropertyStates
+ >
+{
+public:
+ UpDownBarWrapper(bool bUp, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ virtual ~UpDownBarWrapper() override;
+
+ /// XServiceInfo declarations
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose() override;
+ virtual void SAL_CALL addEventListener( const css::uno::Reference<
+ css::lang::XEventListener >& xListener ) override;
+ virtual void SAL_CALL removeEventListener( const css::uno::Reference<
+ css::lang::XEventListener >& aListener ) override;
+
+ //XPropertySet
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
+
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
+ virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
+
+ virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
+ virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
+ virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
+ virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
+
+ //XMultiPropertySet
+ //getPropertySetInfo() already declared in XPropertySet
+ virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override;
+ virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
+ virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
+ virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
+ virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
+
+ //XPropertyState
+ virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
+ virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
+ virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
+ virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
+
+ //XMultiPropertyStates
+ //getPropertyStates() already declared in XPropertyState
+ virtual void SAL_CALL setAllPropertiesToDefault( ) override;
+ virtual void SAL_CALL setPropertiesToDefault( const css::uno::Sequence< OUString >& aPropertyNames ) override;
+ virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer;
+
+ OUString m_aPropertySetName;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_UPDOWNBARWRAPPER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx
new file mode 100644
index 000000000..daa0f1de4
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx
@@ -0,0 +1,169 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WallFloorWrapper.hxx"
+#include "Chart2ModelContact.hxx"
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/chart2/XDiagram.hpp>
+
+#include <FillProperties.hxx>
+#include <LinePropertiesHelper.hxx>
+#include <UserDefinedProperties.hxx>
+#include <WrappedDirectStateProperty.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+
+using ::com::sun::star::beans::Property;
+using ::osl::MutexGuard;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+namespace
+{
+
+struct StaticWallFloorWrapperPropertyArray_Initializer
+{
+ Sequence< Property >* operator()()
+ {
+ static Sequence< Property > aPropSeq( lcl_GetPropertySequence() );
+ return &aPropSeq;
+ }
+
+private:
+ static Sequence< Property > lcl_GetPropertySequence()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+};
+
+struct StaticWallFloorWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticWallFloorWrapperPropertyArray_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart::wrapper
+{
+
+WallFloorWrapper::WallFloorWrapper( bool bWall,
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) :
+ m_spChart2ModelContact( spChart2ModelContact ),
+ m_aEventListenerContainer( m_aMutex ),
+ m_bWall( bWall )
+
+{
+}
+
+WallFloorWrapper::~WallFloorWrapper()
+{
+}
+
+// ____ XComponent ____
+void SAL_CALL WallFloorWrapper::dispose()
+{
+ Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) );
+ m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
+
+ MutexGuard aGuard( m_aMutex);
+ clearWrappedPropertySet();
+}
+
+void SAL_CALL WallFloorWrapper::addEventListener(
+ const Reference< lang::XEventListener >& xListener )
+{
+ m_aEventListenerContainer.addInterface( xListener );
+}
+
+void SAL_CALL WallFloorWrapper::removeEventListener(
+ const Reference< lang::XEventListener >& aListener )
+{
+ m_aEventListenerContainer.removeInterface( aListener );
+}
+
+// WrappedPropertySet
+Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet()
+{
+ Reference< beans::XPropertySet > xRet;
+
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( xDiagram.is() )
+ {
+ if( m_bWall )
+ xRet.set( xDiagram->getWall() );
+ else
+ xRet.set( xDiagram->getFloor() );
+ }
+
+ return xRet;
+}
+
+const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence()
+{
+ return *StaticWallFloorWrapperPropertyArray::get();
+}
+
+std::vector< std::unique_ptr<WrappedProperty> > WallFloorWrapper::createWrappedProperties()
+{
+ std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties;
+
+ // use direct state always, so that in XML the value is always
+ // exported. Because in the old chart the defaults is as follows:
+ // Floor: SOLID (new and old model default), Wall: NONE, except for some chart types (line, scatter)
+ if( m_bWall )
+ aWrappedProperties.emplace_back( new WrappedDirectStateProperty( "FillStyle", "FillStyle" ));
+ aWrappedProperties.emplace_back( new WrappedDirectStateProperty( "FillColor", "FillColor" ));
+
+ return aWrappedProperties;
+}
+
+OUString SAL_CALL WallFloorWrapper::getImplementationName()
+{
+ return "com.sun.star.comp.chart.WallOrFloor";
+}
+
+sal_Bool SAL_CALL WallFloorWrapper::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL WallFloorWrapper::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.xml.UserDefinedAttributesSupplier",
+ "com.sun.star.drawing.FillProperties",
+ "com.sun.star.drawing.LineProperties",
+ "com.sun.star.beans.PropertySet"
+ };
+}
+
+} // namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx
new file mode 100644
index 000000000..2a79c211e
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx
@@ -0,0 +1,77 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WALLFLOORWRAPPER_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WALLFLOORWRAPPER_HXX
+
+#include <WrappedPropertySet.hxx>
+#include <cppuhelper/implbase.hxx>
+#include <comphelper/interfacecontainer2.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <memory>
+
+namespace chart
+{
+
+namespace wrapper
+{
+
+class Chart2ModelContact;
+
+class WallFloorWrapper : public ::cppu::ImplInheritanceHelper<
+ WrappedPropertySet
+ , css::lang::XComponent
+ , css::lang::XServiceInfo
+ >
+{
+public:
+ WallFloorWrapper(bool bWall, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ virtual ~WallFloorWrapper() override;
+
+ /// XServiceInfo declarations
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ // ____ XComponent ____
+ virtual void SAL_CALL dispose() override;
+ virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
+ virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
+
+protected:
+ // ____ WrappedPropertySet ____
+ virtual const css::uno::Sequence< css::beans::Property >& getPropertySequence() override;
+ virtual std::vector< std::unique_ptr<WrappedProperty> > createWrappedProperties() override;
+ virtual css::uno::Reference< css::beans::XPropertySet > getInnerPropertySet() override;
+
+private:
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer;
+
+ bool m_bWall;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WALLFLOORWRAPPER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.cxx
new file mode 100644
index 000000000..24a6dfb78
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.cxx
@@ -0,0 +1,121 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedAddInProperty.hxx"
+#include <ChartDocumentWrapper.hxx>
+#include <com/sun/star/util/XRefreshable.hpp>
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Any;
+using namespace ::com::sun::star;
+
+namespace chart::wrapper
+{
+
+WrappedAddInProperty::WrappedAddInProperty( ChartDocumentWrapper& rChartDocumentWrapper )
+ : ::chart::WrappedProperty( "AddIn", OUString() )
+ , m_rChartDocumentWrapper( rChartDocumentWrapper )
+{
+}
+WrappedAddInProperty::~WrappedAddInProperty()
+{
+}
+
+void WrappedAddInProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ Reference< util::XRefreshable > xAddIn;
+ if( ! (rOuterValue >>= xAddIn) )
+ throw lang::IllegalArgumentException( "AddIn properties require type XRefreshable", nullptr, 0 );
+
+ m_rChartDocumentWrapper.setAddIn( xAddIn );
+}
+
+Any WrappedAddInProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ return uno::Any( m_rChartDocumentWrapper.getAddIn() );
+}
+
+WrappedBaseDiagramProperty::WrappedBaseDiagramProperty( ChartDocumentWrapper& rChartDocumentWrapper )
+ : ::chart::WrappedProperty( "BaseDiagram" , OUString() )
+ , m_rChartDocumentWrapper( rChartDocumentWrapper )
+{
+}
+WrappedBaseDiagramProperty::~WrappedBaseDiagramProperty()
+{
+}
+
+void WrappedBaseDiagramProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ OUString aBaseDiagram;
+ if( ! (rOuterValue >>= aBaseDiagram) )
+ throw lang::IllegalArgumentException( "BaseDiagram properties require type OUString", nullptr, 0 );
+
+ m_rChartDocumentWrapper.setBaseDiagram( aBaseDiagram );
+}
+
+Any WrappedBaseDiagramProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ return uno::Any( m_rChartDocumentWrapper.getBaseDiagram() );
+}
+
+WrappedAdditionalShapesProperty::WrappedAdditionalShapesProperty( ChartDocumentWrapper& rChartDocumentWrapper )
+ : ::chart::WrappedProperty( "AdditionalShapes" , OUString() )
+ , m_rChartDocumentWrapper( rChartDocumentWrapper )
+{
+}
+WrappedAdditionalShapesProperty::~WrappedAdditionalShapesProperty()
+{
+}
+
+void WrappedAdditionalShapesProperty::setPropertyValue( const Any& /*rOuterValue*/, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ throw lang::IllegalArgumentException( "AdditionalShapes is a read only property", nullptr, 0 );
+}
+
+Any WrappedAdditionalShapesProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ return uno::Any( m_rChartDocumentWrapper.getAdditionalShapes() );
+}
+
+WrappedRefreshAddInAllowedProperty::WrappedRefreshAddInAllowedProperty( ChartDocumentWrapper& rChartDocumentWrapper )
+ : ::chart::WrappedProperty( "RefreshAddInAllowed" , OUString() )
+ , m_rChartDocumentWrapper( rChartDocumentWrapper )
+{
+}
+WrappedRefreshAddInAllowedProperty::~WrappedRefreshAddInAllowedProperty()
+{
+}
+
+void WrappedRefreshAddInAllowedProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /* xInnerPropertySet */ ) const
+{
+ bool bUpdateAddIn = true;
+ if( ! (rOuterValue >>= bUpdateAddIn) )
+ throw lang::IllegalArgumentException( "The property RefreshAddInAllowed requires type boolean", nullptr, 0 );
+
+ m_rChartDocumentWrapper.setUpdateAddIn( bUpdateAddIn );
+}
+
+Any WrappedRefreshAddInAllowedProperty::getPropertyValue( const Reference< beans::XPropertySet >& /* xInnerPropertySet */ ) const
+{
+ return uno::Any( m_rChartDocumentWrapper.getUpdateAddIn() );
+}
+
+} //namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.hxx
new file mode 100644
index 000000000..0cf598134
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.hxx
@@ -0,0 +1,94 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDADDINPROPERTY_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDADDINPROPERTY_HXX
+
+#include <WrappedProperty.hxx>
+
+namespace chart::wrapper { class ChartDocumentWrapper; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class WrappedAddInProperty : public WrappedProperty
+{
+public:
+ explicit WrappedAddInProperty( ChartDocumentWrapper& rChartDocumentWrapper );
+ virtual ~WrappedAddInProperty() override;
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+private:
+ ChartDocumentWrapper& m_rChartDocumentWrapper;
+};
+
+class WrappedBaseDiagramProperty : public WrappedProperty
+{
+public:
+ explicit WrappedBaseDiagramProperty( ChartDocumentWrapper& rChartDocumentWrapper );
+ virtual ~WrappedBaseDiagramProperty() override;
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+private:
+ ChartDocumentWrapper& m_rChartDocumentWrapper;
+};
+
+class WrappedAdditionalShapesProperty : public WrappedProperty
+{
+public:
+ explicit WrappedAdditionalShapesProperty( ChartDocumentWrapper& rChartDocumentWrapper );
+ virtual ~WrappedAdditionalShapesProperty() override;
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+private:
+ ChartDocumentWrapper& m_rChartDocumentWrapper;
+};
+
+class WrappedRefreshAddInAllowedProperty : public WrappedProperty
+{
+public:
+ explicit WrappedRefreshAddInAllowedProperty( ChartDocumentWrapper& rChartDocumentWrapper );
+ virtual ~WrappedRefreshAddInAllowedProperty() override;
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+private:
+ ChartDocumentWrapper& m_rChartDocumentWrapper;
+};
+
+} //namespace wrapper
+
+} //namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDADDINPROPERTY_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx
new file mode 100644
index 000000000..2bfb5ed42
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx
@@ -0,0 +1,123 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedAutomaticPositionProperties.hxx"
+#include <FastPropertyIdRanges.hxx>
+#include <WrappedProperty.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::beans::Property;
+
+namespace chart::wrapper
+{
+
+namespace {
+
+class WrappedAutomaticPositionProperty : public WrappedProperty
+{
+public:
+ WrappedAutomaticPositionProperty();
+
+ virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const override;
+ virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override;
+ virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override;
+};
+
+}
+
+WrappedAutomaticPositionProperty::WrappedAutomaticPositionProperty()
+ : ::chart::WrappedProperty( "AutomaticPosition" , OUString() )
+{
+}
+
+void WrappedAutomaticPositionProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ if( !xInnerPropertySet.is() )
+ return;
+
+ bool bNewValue = true;
+ if( ! (rOuterValue >>= bNewValue) )
+ throw lang::IllegalArgumentException( "Property AutomaticPosition requires value of type boolean", nullptr, 0 );
+
+ try
+ {
+ if( bNewValue )
+ {
+ Any aRelativePosition( xInnerPropertySet->getPropertyValue( "RelativePosition" ) );
+ if( aRelativePosition.hasValue() )
+ xInnerPropertySet->setPropertyValue( "RelativePosition", Any() );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+Any WrappedAutomaticPositionProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) );
+ if( xInnerPropertySet.is() )
+ {
+ Any aRelativePosition( xInnerPropertySet->getPropertyValue( "RelativePosition" ) );
+ if( !aRelativePosition.hasValue() )
+ aRet <<= true;
+ }
+ return aRet;
+}
+
+Any WrappedAutomaticPositionProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= false;
+ return aRet;
+}
+
+namespace
+{
+enum
+{
+ PROP_CHART_AUTOMATIC_POSITION = FAST_PROPERTY_ID_START_CHART_AUTOPOSITION_PROP
+};
+
+}//anonymous namespace
+
+void WrappedAutomaticPositionProperties::addProperties( std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "AutomaticPosition",
+ PROP_CHART_AUTOMATIC_POSITION,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+void WrappedAutomaticPositionProperties::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList )
+{
+ rList.emplace_back( new WrappedAutomaticPositionProperty() );
+}
+
+} //namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.hxx
new file mode 100644
index 000000000..35a00856c
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.hxx
@@ -0,0 +1,46 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDAUTOMATICPOSITIONPROPERTIES_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDAUTOMATICPOSITIONPROPERTIES_HXX
+
+#include <sal/types.h>
+#include <memory>
+#include <vector>
+
+namespace chart { class WrappedProperty; }
+namespace com::sun::star::beans { struct Property; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class WrappedAutomaticPositionProperties
+{
+public:
+ static void addProperties( std::vector< css::beans::Property >& rOutProperties );
+ static void addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList );
+};
+
+} //namespace wrapper
+} //namespace chart
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx
new file mode 100644
index 000000000..7b9d07f00
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx
@@ -0,0 +1,403 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedAxisAndGridExistenceProperties.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/chart2/XAxis.hpp>
+#include <com/sun/star/chart2/XDiagram.hpp>
+#include <AxisHelper.hxx>
+#include <WrappedProperty.hxx>
+#include "Chart2ModelContact.hxx"
+#include <TitleHelper.hxx>
+#include <osl/diagnose.h>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+
+namespace chart::wrapper
+{
+
+namespace {
+
+class WrappedAxisAndGridExistenceProperty : public WrappedProperty
+{
+public:
+ WrappedAxisAndGridExistenceProperty( bool bAxis, bool bMain, sal_Int32 nDimensionIndex
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact );
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ bool m_bAxis;
+ bool m_bMain;
+ sal_Int32 m_nDimensionIndex;
+};
+
+}
+
+void WrappedAxisAndGridExistenceProperties::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ rList.emplace_back( new WrappedAxisAndGridExistenceProperty( true, true, 0, spChart2ModelContact ) );//x axis
+ rList.emplace_back( new WrappedAxisAndGridExistenceProperty( true, false, 0, spChart2ModelContact ) );//x secondary axis
+ rList.emplace_back( new WrappedAxisAndGridExistenceProperty( false, true, 0, spChart2ModelContact ) );//x grid
+ rList.emplace_back( new WrappedAxisAndGridExistenceProperty( false, false, 0, spChart2ModelContact ) );//x help grid
+
+ rList.emplace_back( new WrappedAxisAndGridExistenceProperty( true, true, 1, spChart2ModelContact ) );//y axis
+ rList.emplace_back( new WrappedAxisAndGridExistenceProperty( true, false, 1, spChart2ModelContact ) );//y secondary axis
+ rList.emplace_back( new WrappedAxisAndGridExistenceProperty( false, true, 1, spChart2ModelContact ) );//y grid
+ rList.emplace_back( new WrappedAxisAndGridExistenceProperty( false, false, 1, spChart2ModelContact ) );//y help grid
+
+ rList.emplace_back( new WrappedAxisAndGridExistenceProperty( true, true, 2, spChart2ModelContact ) );//z axis
+ rList.emplace_back( new WrappedAxisAndGridExistenceProperty( false, true, 2, spChart2ModelContact ) );//z grid
+ rList.emplace_back( new WrappedAxisAndGridExistenceProperty( false, false, 2, spChart2ModelContact ) );//z help grid
+}
+
+WrappedAxisAndGridExistenceProperty::WrappedAxisAndGridExistenceProperty( bool bAxis, bool bMain, sal_Int32 nDimensionIndex
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact )
+ : WrappedProperty(OUString(),OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_bAxis( bAxis )
+ , m_bMain( bMain )
+ , m_nDimensionIndex( nDimensionIndex )
+{
+ switch( m_nDimensionIndex )
+ {
+ case 0:
+ {
+ if( m_bAxis )
+ {
+ if( m_bMain )
+ m_aOuterName = "HasXAxis";
+ else
+ m_aOuterName = "HasSecondaryXAxis";
+ }
+ else
+ {
+ if( m_bMain )
+ m_aOuterName = "HasXAxisGrid";
+ else
+ m_aOuterName = "HasXAxisHelpGrid";
+ }
+ }
+ break;
+ case 2:
+ {
+ if( m_bAxis )
+ {
+ OSL_ENSURE(m_bMain,"there is no secondary z axis at the old api");
+ m_bMain = true;
+ m_aOuterName = "HasZAxis";
+ }
+ else
+ {
+ if( m_bMain )
+ m_aOuterName = "HasZAxisGrid";
+ else
+ m_aOuterName = "HasZAxisHelpGrid";
+ }
+ }
+ break;
+ default:
+ {
+ if( m_bAxis )
+ {
+ if( m_bMain )
+ m_aOuterName = "HasYAxis";
+ else
+ m_aOuterName = "HasSecondaryYAxis";
+ }
+ else
+ {
+ if( m_bMain )
+ m_aOuterName = "HasYAxisGrid";
+ else
+ m_aOuterName = "HasYAxisHelpGrid";
+ }
+ }
+ break;
+ }
+}
+
+void WrappedAxisAndGridExistenceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ bool bNewValue = false;
+ if( ! (rOuterValue >>= bNewValue) )
+ throw lang::IllegalArgumentException( "Has axis or grid properties require boolean values", nullptr, 0 );
+
+ bool bOldValue = false;
+ getPropertyValue( xInnerPropertySet ) >>= bOldValue;
+
+ if( bOldValue == bNewValue )
+ return;
+
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( bNewValue )
+ {
+ if( m_bAxis )
+ AxisHelper::showAxis( m_nDimensionIndex, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext );
+ else
+ AxisHelper::showGrid( m_nDimensionIndex, 0, m_bMain, xDiagram );
+ }
+ else
+ {
+ if( m_bAxis )
+ AxisHelper::hideAxis( m_nDimensionIndex, m_bMain, xDiagram );
+ else
+ AxisHelper::hideGrid( m_nDimensionIndex, 0, m_bMain, xDiagram );
+ }
+}
+
+Any WrappedAxisAndGridExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /* xInnerPropertySet */ ) const
+{
+ Any aRet;
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if(m_bAxis)
+ {
+ bool bShown = AxisHelper::isAxisShown( m_nDimensionIndex, m_bMain, xDiagram );
+ aRet <<= bShown;
+ }
+ else
+ {
+ bool bShown = AxisHelper::isGridShown( m_nDimensionIndex, 0, m_bMain, xDiagram );
+ aRet <<= bShown;
+ }
+ return aRet;
+}
+
+Any WrappedAxisAndGridExistenceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= false;
+ return aRet;
+}
+
+namespace {
+
+class WrappedAxisTitleExistenceProperty : public WrappedProperty
+{
+public:
+ WrappedAxisTitleExistenceProperty( sal_Int32 nTitleIndex
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact );
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ TitleHelper::eTitleType m_eTitleType;
+};
+
+}
+
+void WrappedAxisTitleExistenceProperties::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ rList.emplace_back( new WrappedAxisTitleExistenceProperty( 0, spChart2ModelContact ) );//x axis title
+ rList.emplace_back( new WrappedAxisTitleExistenceProperty( 1, spChart2ModelContact ) );//y axis title
+ rList.emplace_back( new WrappedAxisTitleExistenceProperty( 2, spChart2ModelContact ) );//z axis title
+ rList.emplace_back( new WrappedAxisTitleExistenceProperty( 3, spChart2ModelContact ) );//secondary x axis title
+ rList.emplace_back( new WrappedAxisTitleExistenceProperty( 4, spChart2ModelContact ) );//secondary y axis title
+}
+
+WrappedAxisTitleExistenceProperty::WrappedAxisTitleExistenceProperty(sal_Int32 nTitleIndex
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty(OUString(),OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_eTitleType( TitleHelper::Y_AXIS_TITLE )
+{
+ switch( nTitleIndex )
+ {
+ case 0:
+ m_aOuterName = "HasXAxisTitle";
+ m_eTitleType = TitleHelper::X_AXIS_TITLE;
+ break;
+ case 2:
+ m_aOuterName = "HasZAxisTitle";
+ m_eTitleType = TitleHelper::Z_AXIS_TITLE;
+ break;
+ case 3:
+ m_aOuterName = "HasSecondaryXAxisTitle";
+ m_eTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE;
+ break;
+ case 4:
+ m_aOuterName = "HasSecondaryYAxisTitle";
+ m_eTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE;
+ break;
+ default:
+ m_aOuterName = "HasYAxisTitle";
+ m_eTitleType = TitleHelper::Y_AXIS_TITLE;
+ break;
+ }
+}
+
+void WrappedAxisTitleExistenceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ bool bNewValue = false;
+ if( ! (rOuterValue >>= bNewValue) )
+ throw lang::IllegalArgumentException( "Has axis or grid properties require boolean values", nullptr, 0 );
+
+ bool bOldValue = false;
+ getPropertyValue( xInnerPropertySet ) >>= bOldValue;
+
+ if( bOldValue == bNewValue )
+ return;
+
+ if( bNewValue )
+ {
+ TitleHelper::createTitle( m_eTitleType, OUString()
+ , m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext );
+ }
+ else
+ {
+ TitleHelper::removeTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() );
+ }
+}
+
+Any WrappedAxisTitleExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ bool bHasTitle = false;
+
+ Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() ) );
+ if( xTitle.is() && !TitleHelper::getCompleteString( xTitle ).isEmpty() )
+ bHasTitle = true;
+
+ Any aRet;
+ aRet <<= bHasTitle;
+ return aRet;
+
+}
+
+Any WrappedAxisTitleExistenceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= false;
+ return aRet;
+}
+
+namespace {
+
+class WrappedAxisLabelExistenceProperty : public WrappedProperty
+{
+public:
+ WrappedAxisLabelExistenceProperty( bool bMain, sal_Int32 nDimensionIndex
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact );
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private: //member
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ bool m_bMain;
+ sal_Int32 m_nDimensionIndex;
+};
+
+}
+
+void WrappedAxisLabelExistenceProperties::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ rList.emplace_back( new WrappedAxisLabelExistenceProperty( true, 0, spChart2ModelContact ) );//x axis
+ rList.emplace_back( new WrappedAxisLabelExistenceProperty( true, 1, spChart2ModelContact ) );//y axis
+ rList.emplace_back( new WrappedAxisLabelExistenceProperty( true, 2, spChart2ModelContact ) );//z axis
+ rList.emplace_back( new WrappedAxisLabelExistenceProperty( false, 0, spChart2ModelContact ) );//secondary x axis
+ rList.emplace_back( new WrappedAxisLabelExistenceProperty( false, 1, spChart2ModelContact ) );//secondary y axis
+}
+
+WrappedAxisLabelExistenceProperty::WrappedAxisLabelExistenceProperty(bool bMain, sal_Int32 nDimensionIndex
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty(OUString(),OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_bMain( bMain )
+ , m_nDimensionIndex( nDimensionIndex )
+{
+ switch( m_nDimensionIndex )
+ {
+ case 0:
+ m_aOuterName = m_bMain ? OUStringLiteral("HasXAxisDescription") : OUStringLiteral("HasSecondaryXAxisDescription");
+ break;
+ case 2:
+ OSL_ENSURE(m_bMain,"there is no description available for a secondary z axis");
+ m_aOuterName = "HasZAxisDescription";
+ break;
+ default:
+ m_aOuterName = m_bMain ? OUStringLiteral("HasYAxisDescription") : OUStringLiteral("HasSecondaryYAxisDescription");
+ break;
+ }
+}
+
+void WrappedAxisLabelExistenceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ bool bNewValue = false;
+ if( ! (rOuterValue >>= bNewValue) )
+ throw lang::IllegalArgumentException( "Has axis or grid properties require boolean values", nullptr, 0 );
+
+ bool bOldValue = false;
+ getPropertyValue( xInnerPropertySet ) >>= bOldValue;
+
+ if( bOldValue == bNewValue )
+ return;
+
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ Reference< beans::XPropertySet > xProp( AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ), uno::UNO_QUERY );
+ if( !xProp.is() && bNewValue )
+ {
+ //create axis if needed
+ xProp.set( AxisHelper::createAxis( m_nDimensionIndex, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext ), uno::UNO_QUERY );
+ if( xProp.is() )
+ xProp->setPropertyValue( "Show", uno::Any( false ) );
+ }
+ if( xProp.is() )
+ xProp->setPropertyValue( "DisplayLabels", rOuterValue );
+}
+
+Any WrappedAxisLabelExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ Any aRet;
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ Reference< beans::XPropertySet > xProp( AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ), uno::UNO_QUERY );
+ if( xProp.is() )
+ aRet = xProp->getPropertyValue( "DisplayLabels" );
+ else
+ aRet <<= false;
+ return aRet;
+}
+
+Any WrappedAxisLabelExistenceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= true;
+ return aRet;
+}
+
+} //namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.hxx
new file mode 100644
index 000000000..cfc627345
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.hxx
@@ -0,0 +1,60 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDAXISANDGRIDEXISTENCEPROPERTIES_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDAXISANDGRIDEXISTENCEPROPERTIES_HXX
+
+#include <memory>
+#include <vector>
+
+namespace chart { class WrappedProperty; }
+namespace chart::wrapper { class Chart2ModelContact; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class WrappedAxisAndGridExistenceProperties
+{
+public:
+ static void addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+};
+
+class WrappedAxisTitleExistenceProperties
+{
+public:
+ static void addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+};
+
+class WrappedAxisLabelExistenceProperties
+{
+public:
+ static void addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+};
+
+} //namespace wrapper
+} //namespace chart
+
+#endif // INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDAXISANDGRIDEXISTENCEPROPERTIES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx
new file mode 100644
index 000000000..67ea51b0e
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx
@@ -0,0 +1,138 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedCharacterHeightProperty.hxx"
+#include <RelativeSizeHelper.hxx>
+#include "ReferenceSizePropertyProvider.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <osl/diagnose.h>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Any;
+
+namespace chart::wrapper
+{
+WrappedCharacterHeightProperty_Base::WrappedCharacterHeightProperty_Base(
+ const OUString& rOuterEqualsInnerName
+ , ReferenceSizePropertyProvider* pRefSizePropProvider )
+ : WrappedProperty( rOuterEqualsInnerName, rOuterEqualsInnerName )
+ , m_pRefSizePropProvider( pRefSizePropProvider )
+{
+}
+WrappedCharacterHeightProperty_Base::~WrappedCharacterHeightProperty_Base()
+{
+}
+
+void WrappedCharacterHeightProperty::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , ReferenceSizePropertyProvider* pRefSizePropProvider )
+{
+ rList.emplace_back( new WrappedCharacterHeightProperty( pRefSizePropProvider ) );
+ rList.emplace_back( new WrappedAsianCharacterHeightProperty( pRefSizePropProvider ) );
+ rList.emplace_back( new WrappedComplexCharacterHeightProperty( pRefSizePropProvider ) );
+}
+
+void WrappedCharacterHeightProperty_Base::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ if(xInnerPropertySet.is())
+ {
+ if( m_pRefSizePropProvider )
+ m_pRefSizePropProvider->updateReferenceSize();
+ xInnerPropertySet->setPropertyValue( m_aInnerName, rOuterValue );
+ }
+}
+
+Any WrappedCharacterHeightProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ Any aRet;
+ if( xInnerPropertySet.is() )
+ {
+ aRet = xInnerPropertySet->getPropertyValue( m_aInnerName );
+ float fHeight = 0;
+ if( aRet >>= fHeight )
+ {
+ if( m_pRefSizePropProvider )
+ {
+ awt::Size aReferenceSize;
+ if( m_pRefSizePropProvider->getReferenceSize() >>= aReferenceSize )
+ {
+ awt::Size aCurrentSize = m_pRefSizePropProvider->getCurrentSizeForReference();
+ aRet <<= static_cast< float >(
+ RelativeSizeHelper::calculate( fHeight, aReferenceSize, aCurrentSize ));
+ }
+ }
+ }
+ }
+ return aRet;
+}
+
+Any WrappedCharacterHeightProperty_Base::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
+{
+ Any aRet;
+ if( xInnerPropertyState.is() )
+ {
+ aRet = xInnerPropertyState->getPropertyDefault( m_aInnerName );
+ }
+ return aRet;
+}
+
+beans::PropertyState WrappedCharacterHeightProperty_Base::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ return beans::PropertyState_DIRECT_VALUE;
+}
+
+Any WrappedCharacterHeightProperty_Base::convertInnerToOuterValue( const Any& rInnerValue ) const
+{
+ OSL_FAIL("should not be used: WrappedCharacterHeightProperty_Base::convertInnerToOuterValue - check if you miss data");
+ return rInnerValue;
+}
+Any WrappedCharacterHeightProperty_Base::convertOuterToInnerValue( const Any& rOuterValue ) const
+{
+ OSL_FAIL("should not be used: WrappedCharacterHeightProperty_Base::convertOuterToInnerValue - check if you miss data");
+ return rOuterValue;
+}
+
+WrappedCharacterHeightProperty::WrappedCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
+ : WrappedCharacterHeightProperty_Base( "CharHeight", pRefSizePropProvider )
+{
+}
+WrappedCharacterHeightProperty::~WrappedCharacterHeightProperty()
+{
+}
+
+WrappedAsianCharacterHeightProperty::WrappedAsianCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
+ : WrappedCharacterHeightProperty_Base( "CharHeightAsian", pRefSizePropProvider )
+{
+}
+WrappedAsianCharacterHeightProperty::~WrappedAsianCharacterHeightProperty()
+{
+}
+
+WrappedComplexCharacterHeightProperty::WrappedComplexCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider )
+ : WrappedCharacterHeightProperty_Base( "CharHeightComplex", pRefSizePropProvider )
+{
+}
+WrappedComplexCharacterHeightProperty::~WrappedComplexCharacterHeightProperty()
+{
+}
+
+} //namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx
new file mode 100644
index 000000000..5e43b37ae
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx
@@ -0,0 +1,84 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDCHARACTERHEIGHTPROPERTY_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDCHARACTERHEIGHTPROPERTY_HXX
+
+#include <WrappedProperty.hxx>
+
+#include <vector>
+
+namespace chart
+{
+namespace wrapper
+{
+
+class ReferenceSizePropertyProvider;
+
+class WrappedCharacterHeightProperty_Base : public WrappedProperty
+{
+public:
+ WrappedCharacterHeightProperty_Base( const OUString& rOuterEqualsInnerName, ReferenceSizePropertyProvider* pRefSizePropProvider );
+ virtual ~WrappedCharacterHeightProperty_Base() override;
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+ virtual css::beans::PropertyState getPropertyState( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+protected:
+ virtual css::uno::Any convertInnerToOuterValue( const css::uno::Any& rInnerValue ) const override;
+ virtual css::uno::Any convertOuterToInnerValue( const css::uno::Any& rOuterValue ) const override;
+
+protected:
+ ReferenceSizePropertyProvider* m_pRefSizePropProvider;
+};
+
+class WrappedCharacterHeightProperty : public WrappedCharacterHeightProperty_Base
+{
+public:
+ explicit WrappedCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider );
+ virtual ~WrappedCharacterHeightProperty() override;
+
+ static void addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList, ReferenceSizePropertyProvider* pRefSizePropProvider );
+};
+
+class WrappedAsianCharacterHeightProperty : public WrappedCharacterHeightProperty_Base
+{
+public:
+ explicit WrappedAsianCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider );
+ virtual ~WrappedAsianCharacterHeightProperty() override;
+};
+
+class WrappedComplexCharacterHeightProperty : public WrappedCharacterHeightProperty_Base
+{
+public:
+ explicit WrappedComplexCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider );
+ virtual ~WrappedComplexCharacterHeightProperty() override;
+};
+
+} //namespace wrapper
+} //namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDCHARACTERHEIGHTPROPERTY_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx
new file mode 100644
index 000000000..f55540f67
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx
@@ -0,0 +1,150 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedDataCaptionProperties.hxx"
+#include "WrappedSeriesOrDiagramProperty.hxx"
+#include <FastPropertyIdRanges.hxx>
+#include <unonames.hxx>
+
+#include <com/sun/star/chart2/DataPointLabel.hpp>
+#include <com/sun/star/chart/ChartDataCaption.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::beans::Property;
+
+namespace chart::wrapper
+{
+
+namespace
+{
+
+class WrappedDataCaptionProperty : public WrappedSeriesOrDiagramProperty< sal_Int32 >
+{
+public:
+ virtual sal_Int32 getValueFromSeries( const css::uno::Reference< css::beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const css::uno::Reference< css::beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& aNewValue ) const override;
+
+ explicit WrappedDataCaptionProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType );
+};
+
+enum
+{
+ //data caption properties
+ PROP_CHART_DATAPOINT_DATA_CAPTION = FAST_PROPERTY_ID_START_CHART_DATACAPTION_PROP
+};
+
+sal_Int32 lcl_LabelToCaption( const chart2::DataPointLabel& rLabel )
+{
+ sal_Int32 nCaption=0;
+
+ if( rLabel.ShowNumber )
+ nCaption |= css::chart::ChartDataCaption::VALUE;
+ if( rLabel.ShowNumberInPercent )
+ nCaption |= css::chart::ChartDataCaption::PERCENT;
+ if( rLabel.ShowCategoryName )
+ nCaption |= css::chart::ChartDataCaption::TEXT;
+ if( rLabel.ShowLegendSymbol )
+ nCaption |= css::chart::ChartDataCaption::SYMBOL;
+
+ return nCaption;
+}
+
+chart2::DataPointLabel lcl_CaptionToLabel( sal_Int32 nCaption )
+{
+ chart2::DataPointLabel aLabel(false,false,false,false);
+
+ if( nCaption & css::chart::ChartDataCaption::VALUE )
+ aLabel.ShowNumber = true;
+ if( nCaption & css::chart::ChartDataCaption::PERCENT )
+ aLabel.ShowNumberInPercent = true;
+ if( nCaption & css::chart::ChartDataCaption::TEXT )
+ aLabel.ShowCategoryName = true;
+ if( nCaption & css::chart::ChartDataCaption::SYMBOL )
+ aLabel.ShowLegendSymbol = true;
+
+ return aLabel;
+}
+
+void lcl_addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact
+ , tSeriesOrDiagramPropertyType ePropertyType )
+{
+ //if !spChart2ModelContact.get() is then the created properties do belong to a single series or single datapoint
+ //otherwise they do belong to the whole diagram
+
+ rList.emplace_back( new WrappedDataCaptionProperty( spChart2ModelContact, ePropertyType ) );
+}
+
+}//anonymous namespace
+
+void WrappedDataCaptionProperties::addProperties( std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "DataCaption",
+ PROP_CHART_DATAPOINT_DATA_CAPTION,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+void WrappedDataCaptionProperties::addWrappedPropertiesForSeries( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES );
+}
+
+void WrappedDataCaptionProperties::addWrappedPropertiesForDiagram( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM );
+}
+
+WrappedDataCaptionProperty::WrappedDataCaptionProperty(
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact
+ , tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedSeriesOrDiagramProperty< sal_Int32 >( "DataCaption"
+ , uno::Any( sal_Int32(0) ), spChart2ModelContact, ePropertyType )
+{
+}
+
+sal_Int32 WrappedDataCaptionProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ sal_Int32 aRet = 0;
+ m_aDefaultValue >>= aRet;
+ chart2::DataPointLabel aLabel;
+ if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel ) )
+ aRet = lcl_LabelToCaption( aLabel );
+ return aRet;
+}
+
+void WrappedDataCaptionProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& nCaption ) const
+{
+ if(!xSeriesPropertySet.is())
+ return;
+
+ chart2::DataPointLabel aLabel = lcl_CaptionToLabel( nCaption );
+ xSeriesPropertySet->setPropertyValue( CHART_UNONAME_LABEL, uno::Any( aLabel ) );
+}
+
+} //namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.hxx
new file mode 100644
index 000000000..7180f7e19
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.hxx
@@ -0,0 +1,51 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDDATACAPTIONPROPERTIES_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDDATACAPTIONPROPERTIES_HXX
+
+#include <sal/types.h>
+#include <memory>
+#include <vector>
+
+namespace chart { class WrappedProperty; }
+namespace chart::wrapper { class Chart2ModelContact; }
+namespace com::sun::star::beans { struct Property; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class WrappedDataCaptionProperties
+{
+public:
+ static void addProperties( std::vector< css::beans::Property > & rOutProperties );
+ static void addWrappedPropertiesForSeries( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+ static void addWrappedPropertiesForDiagram( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+};
+
+} //namespace wrapper
+} //namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDDATACAPTIONPROPERTIES_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx
new file mode 100644
index 000000000..63abadee1
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx
@@ -0,0 +1,171 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedGapwidthProperty.hxx"
+#include "Chart2ModelContact.hxx"
+#include <DiagramHelper.hxx>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Any;
+
+namespace chart::wrapper
+{
+
+const sal_Int32 DEFAULT_GAPWIDTH = 100;
+const sal_Int32 DEFAULT_OVERLAP = 0;
+
+WrappedBarPositionProperty_Base::WrappedBarPositionProperty_Base(
+ const OUString& rOuterName
+ , const OUString& rInnerSequencePropertyName
+ , sal_Int32 nDefaultValue
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact )
+ : WrappedDefaultProperty( rOuterName, OUString(), uno::Any( nDefaultValue ) )
+ , m_nDimensionIndex(0)
+ , m_nAxisIndex(0)
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_nDefaultValue( nDefaultValue )
+ , m_InnerSequencePropertyName( rInnerSequencePropertyName )
+{
+}
+
+void WrappedBarPositionProperty_Base::setDimensionAndAxisIndex( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
+{
+ m_nDimensionIndex = nDimensionIndex;
+ m_nAxisIndex = nAxisIndex;
+}
+
+WrappedBarPositionProperty_Base::~WrappedBarPositionProperty_Base()
+{
+}
+
+void WrappedBarPositionProperty_Base::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ sal_Int32 nNewValue = 0;
+ if( ! (rOuterValue >>= nNewValue) )
+ throw lang::IllegalArgumentException( "GapWidth and Overlap property require value of type sal_Int32", nullptr, 0 );
+
+ m_aOuterValue = rOuterValue;
+
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( !xDiagram.is() )
+ return;
+
+ if( m_nDimensionIndex!=1 )
+ return;
+
+ const Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) );
+ for( Reference< chart2::XChartType > const & chartType : aChartTypeList )
+ {
+ try
+ {
+ Reference< beans::XPropertySet > xProp( chartType, uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ Sequence< sal_Int32 > aBarPositionSequence;
+ xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence;
+
+ long nOldLength = aBarPositionSequence.getLength();
+ if( nOldLength <= m_nAxisIndex )
+ {
+ aBarPositionSequence.realloc( m_nAxisIndex+1 );
+ for( sal_Int32 i=nOldLength; i<m_nAxisIndex; i++ )
+ {
+ aBarPositionSequence[i] = m_nDefaultValue;
+ }
+ }
+ aBarPositionSequence[m_nAxisIndex] = nNewValue;
+
+ xProp->setPropertyValue( m_InnerSequencePropertyName, uno::Any( aBarPositionSequence ) );
+ }
+ }
+ catch( uno::Exception& e )
+ {
+ //the above properties are not supported by all charttypes (only by column and bar)
+ //in that cases this exception is ok
+ e.Context.is();//to have debug information without compilation warnings
+ }
+ }
+}
+
+Any WrappedBarPositionProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( xDiagram.is() )
+ {
+ bool bInnerValueDetected = false;
+ sal_Int32 nInnerValue = m_nDefaultValue;
+
+ if( m_nDimensionIndex==1 )
+ {
+ Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) );
+ for( sal_Int32 nN = 0; nN < aChartTypeList.getLength() && !bInnerValueDetected; nN++ )
+ {
+ try
+ {
+ Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ Sequence< sal_Int32 > aBarPositionSequence;
+ xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence;
+ if( m_nAxisIndex < aBarPositionSequence.getLength() )
+ {
+ nInnerValue = aBarPositionSequence[m_nAxisIndex];
+ bInnerValueDetected = true;
+ }
+ }
+ }
+ catch( uno::Exception& e )
+ {
+ //the above properties are not supported by all charttypes (only by column and bar)
+ //in that cases this exception is ok
+ e.Context.is();//to have debug information without compilation warnings
+ }
+ }
+ }
+ if( bInnerValueDetected )
+ {
+ m_aOuterValue <<= nInnerValue;
+ }
+ }
+ return m_aOuterValue;
+}
+
+WrappedGapwidthProperty::WrappedGapwidthProperty(
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedBarPositionProperty_Base( "GapWidth", "GapwidthSequence", DEFAULT_GAPWIDTH, spChart2ModelContact )
+{
+}
+WrappedGapwidthProperty::~WrappedGapwidthProperty()
+{
+}
+
+WrappedBarOverlapProperty::WrappedBarOverlapProperty(
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact )
+ : WrappedBarPositionProperty_Base( "Overlap", "OverlapSequence", DEFAULT_OVERLAP, spChart2ModelContact )
+{
+}
+WrappedBarOverlapProperty::~WrappedBarOverlapProperty()
+{
+}
+
+} // namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx
new file mode 100644
index 000000000..a20a4bbc3
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx
@@ -0,0 +1,80 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDGAPWIDTHPROPERTY_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDGAPWIDTHPROPERTY_HXX
+
+#include <WrappedDefaultProperty.hxx>
+
+#include <memory>
+
+namespace chart::wrapper { class Chart2ModelContact; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class WrappedBarPositionProperty_Base : public WrappedDefaultProperty
+{
+public:
+ WrappedBarPositionProperty_Base(
+ const OUString& rOuterName
+ , const OUString& rInnerSequencePropertyName
+ , sal_Int32 nDefaultValue
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact );
+ virtual ~WrappedBarPositionProperty_Base() override;
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ void setDimensionAndAxisIndex( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
+
+protected:
+ sal_Int32 m_nDimensionIndex;
+ sal_Int32 m_nAxisIndex;
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+
+ sal_Int32 m_nDefaultValue;
+ OUString m_InnerSequencePropertyName;
+
+ mutable css::uno::Any m_aOuterValue;
+};
+
+class WrappedGapwidthProperty : public WrappedBarPositionProperty_Base
+{
+public:
+ explicit WrappedGapwidthProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ virtual ~WrappedGapwidthProperty() override;
+};
+
+class WrappedBarOverlapProperty : public WrappedBarPositionProperty_Base
+{
+public:
+ explicit WrappedBarOverlapProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ virtual ~WrappedBarOverlapProperty() override;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDGAPWIDTHPROPERTY_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx
new file mode 100644
index 000000000..1ce277c32
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx
@@ -0,0 +1,121 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedNumberFormatProperty.hxx"
+#include "Chart2ModelContact.hxx"
+#include <com/sun/star/chart2/XAxis.hpp>
+#include <com/sun/star/chart2/XDataSeries.hpp>
+#include <unonames.hxx>
+#include <osl/diagnose.h>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Any;
+
+namespace chart::wrapper
+{
+
+WrappedNumberFormatProperty::WrappedNumberFormatProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedDirectStateProperty( CHART_UNONAME_NUMFMT, CHART_UNONAME_NUMFMT )
+ , m_spChart2ModelContact(spChart2ModelContact)
+{
+}
+
+WrappedNumberFormatProperty::~WrappedNumberFormatProperty()
+{
+}
+
+void WrappedNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ sal_Int32 nFormat = 0;
+ if( ! (rOuterValue >>= nFormat) )
+ throw lang::IllegalArgumentException( "Property 'NumberFormat' requires value of type sal_Int32", nullptr, 0 );
+
+ if(xInnerPropertySet.is())
+ xInnerPropertySet->setPropertyValue(getInnerName(), convertOuterToInnerValue(rOuterValue));
+}
+
+Any WrappedNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ if( !xInnerPropertySet.is() )
+ {
+ OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
+ return Any();
+ }
+ Any aRet( xInnerPropertySet->getPropertyValue(getInnerName()));
+ if( !aRet.hasValue() )
+ {
+ sal_Int32 nKey = 0;
+ Reference< chart2::XDataSeries > xSeries( xInnerPropertySet, uno::UNO_QUERY );
+ if( xSeries.is() )
+ nKey = Chart2ModelContact::getExplicitNumberFormatKeyForSeries( xSeries );
+ else
+ {
+ Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY );
+ nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForAxis( xAxis );
+ }
+ aRet <<= nKey;
+ }
+ return aRet;
+}
+
+Any WrappedNumberFormatProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ return uno::Any( sal_Int32( 0 ) );
+}
+
+WrappedLinkNumberFormatProperty::WrappedLinkNumberFormatProperty() :
+ WrappedDirectStateProperty(CHART_UNONAME_LINK_TO_SRC_NUMFMT, CHART_UNONAME_LINK_TO_SRC_NUMFMT)
+{
+}
+
+WrappedLinkNumberFormatProperty::~WrappedLinkNumberFormatProperty()
+{
+}
+
+void WrappedLinkNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ if( !xInnerPropertySet.is() )
+ {
+ OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::setPropertyValue");
+ return;
+ }
+
+ xInnerPropertySet->setPropertyValue(getInnerName(), rOuterValue);
+}
+
+Any WrappedLinkNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ if( !xInnerPropertySet.is() )
+ {
+ OSL_FAIL("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue");
+ return getPropertyDefault(nullptr);
+ }
+
+ return xInnerPropertySet->getPropertyValue(getInnerName());
+}
+
+Any WrappedLinkNumberFormatProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ return uno::Any( true ); // bLink
+}
+
+} //namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx
new file mode 100644
index 000000000..59bb1f3b1
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx
@@ -0,0 +1,71 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDNUMBERFORMATPROPERTY_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDNUMBERFORMATPROPERTY_HXX
+
+#include <WrappedDirectStateProperty.hxx>
+
+#include <memory>
+
+namespace chart::wrapper { class Chart2ModelContact; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+
+class WrappedNumberFormatProperty : public WrappedDirectStateProperty
+{
+public:
+ explicit WrappedNumberFormatProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ virtual ~WrappedNumberFormatProperty() override;
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+ friend class WrappedLinkNumberFormatProperty;
+private:
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+};
+
+class WrappedLinkNumberFormatProperty : public WrappedDirectStateProperty
+{
+public:
+ explicit WrappedLinkNumberFormatProperty();
+ virtual ~WrappedLinkNumberFormatProperty() override;
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+};
+
+} //namespace wrapper
+} //namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDNUMBERFORMATPROPERTY_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx
new file mode 100644
index 000000000..d9ad4a3e6
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx
@@ -0,0 +1,584 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedScaleProperty.hxx"
+#include "Chart2ModelContact.hxx"
+#include <CommonConverters.hxx>
+#include <AxisHelper.hxx>
+#include <com/sun/star/chart2/AxisType.hpp>
+#include <com/sun/star/chart2/XAxis.hpp>
+#include <com/sun/star/chart/ChartAxisType.hpp>
+#include <chartview/ExplicitScaleValues.hxx>
+#include <osl/diagnose.h>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Any;
+using namespace ::com::sun::star::chart2;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::chart::TimeIncrement;
+
+namespace chart::wrapper
+{
+
+WrappedScaleProperty::WrappedScaleProperty(tScaleProperty eScaleProperty
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedProperty(OUString(),OUString())
+ , m_spChart2ModelContact( spChart2ModelContact )
+ , m_eScaleProperty( eScaleProperty )
+{
+ switch( m_eScaleProperty )
+ {
+ case SCALE_PROP_MAX:
+ m_aOuterName = "Max";
+ break;
+ case SCALE_PROP_MIN:
+ m_aOuterName = "Min";
+ break;
+ case SCALE_PROP_ORIGIN:
+ m_aOuterName = "Origin";
+ break;
+ case SCALE_PROP_STEPMAIN:
+ m_aOuterName = "StepMain";
+ break;
+ case SCALE_PROP_STEPHELP:
+ m_aOuterName = "StepHelp";
+ break;
+ case SCALE_PROP_STEPHELP_COUNT:
+ m_aOuterName = "StepHelpCount";
+ break;
+ case SCALE_PROP_AUTO_MAX:
+ m_aOuterName = "AutoMax";
+ break;
+ case SCALE_PROP_AUTO_MIN:
+ m_aOuterName = "AutoMin";
+ break;
+ case SCALE_PROP_AUTO_ORIGIN:
+ m_aOuterName = "AutoOrigin";
+ break;
+ case SCALE_PROP_AUTO_STEPMAIN:
+ m_aOuterName = "AutoStepMain";
+ break;
+ case SCALE_PROP_AUTO_STEPHELP:
+ m_aOuterName = "AutoStepHelp";
+ break;
+ case SCALE_PROP_AXIS_TYPE:
+ m_aOuterName = "AxisType";
+ break;
+ case SCALE_PROP_DATE_INCREMENT:
+ m_aOuterName = "TimeIncrement";
+ break;
+ case SCALE_PROP_EXPLICIT_DATE_INCREMENT:
+ m_aOuterName = "ExplicitTimeIncrement";
+ break;
+ case SCALE_PROP_LOGARITHMIC:
+ m_aOuterName = "Logarithmic";
+ break;
+ case SCALE_PROP_REVERSEDIRECTION:
+ m_aOuterName = "ReverseDirection";
+ break;
+ default:
+ OSL_FAIL("unknown scale property");
+ break;
+ }
+}
+
+WrappedScaleProperty::~WrappedScaleProperty()
+{
+}
+
+void WrappedScaleProperty::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_MAX, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_MIN, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_ORIGIN, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_STEPMAIN, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_STEPHELP, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_STEPHELP_COUNT, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_AUTO_MAX, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_AUTO_MIN, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_AUTO_ORIGIN, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPMAIN, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPHELP, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_AXIS_TYPE, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_DATE_INCREMENT, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_EXPLICIT_DATE_INCREMENT, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_LOGARITHMIC, spChart2ModelContact ) );
+ rList.emplace_back( new WrappedScaleProperty( SCALE_PROP_REVERSEDIRECTION, spChart2ModelContact ) );
+}
+
+void WrappedScaleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ setPropertyValue( m_eScaleProperty, rOuterValue, xInnerPropertySet );
+}
+
+Any WrappedScaleProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ return getPropertyValue( m_eScaleProperty, xInnerPropertySet );
+}
+
+void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ m_aOuterValue = rOuterValue;
+
+ Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY );
+ OSL_ENSURE(xAxis.is(),"need an XAxis");
+ if(!xAxis.is())
+ return;
+
+ bool bSetScaleData = false;
+
+ chart2::ScaleData aScaleData( xAxis->getScaleData() );
+
+ bool bBool = false;
+ switch( eScaleProperty )
+ {
+ case SCALE_PROP_MAX:
+ {
+ aScaleData.Maximum = rOuterValue;
+ bSetScaleData = true;
+ break;
+ }
+ case SCALE_PROP_MIN:
+ {
+ aScaleData.Minimum = rOuterValue;
+ bSetScaleData = true;
+ break;
+ }
+ case SCALE_PROP_STEPMAIN:
+ {
+ aScaleData.IncrementData.Distance = rOuterValue;
+ bSetScaleData = true;
+ break;
+ }
+ case SCALE_PROP_STEPHELP:
+ {
+ Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
+ if( !rSubIncrements.hasElements() )
+ rSubIncrements.realloc( 1 );
+
+ double fStepHelp = 0;
+ if( rOuterValue >>= fStepHelp )
+ {
+ double fStepMain = 0;
+ if( AxisHelper::isLogarithmic(aScaleData.Scaling) )
+ {
+ sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepHelp);
+ rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount;
+ }
+ else if( (fStepHelp != 0.0) &&
+ (aScaleData.IncrementData.Distance >>= fStepMain) )
+ {
+ // approximate interval count
+ sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepMain / fStepHelp);//cppcheck-suppress zerodiv
+ rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount;
+ }
+ }
+ bSetScaleData = true;
+ break;
+ }
+ case SCALE_PROP_STEPHELP_COUNT:
+ {
+ Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
+ if( !rSubIncrements.hasElements() )
+ rSubIncrements.realloc( 1 );
+ sal_Int32 nIntervalCount=0;
+ if( rOuterValue>>=nIntervalCount )
+ rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount;
+ else
+ rSubIncrements[ 0 ].IntervalCount = Any();
+ bSetScaleData = true;
+ break;
+ }
+ case SCALE_PROP_AUTO_MAX:
+ {
+ if( (rOuterValue >>= bBool) && bBool )
+ aScaleData.Maximum = Any();
+ else
+ aScaleData.Maximum = getPropertyValue( SCALE_PROP_MAX, xInnerPropertySet );
+ bSetScaleData = true;
+ break;
+ }
+ case SCALE_PROP_AUTO_MIN:
+ {
+ if( (rOuterValue >>= bBool) && bBool )
+ aScaleData.Minimum = Any();
+ else
+ aScaleData.Minimum = getPropertyValue( SCALE_PROP_MIN, xInnerPropertySet );
+ bSetScaleData = true;
+ break;
+ }
+ case SCALE_PROP_AUTO_STEPMAIN:
+ {
+ if( (rOuterValue >>= bBool) && bBool )
+ aScaleData.IncrementData.Distance = Any();
+ else
+ aScaleData.IncrementData.Distance = getPropertyValue( SCALE_PROP_STEPMAIN, xInnerPropertySet );
+ bSetScaleData = true;
+ break;
+ }
+ case SCALE_PROP_AUTO_STEPHELP:
+ {
+ Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
+ if( !rSubIncrements.hasElements() )
+ rSubIncrements.realloc( 1 );
+
+ if( (rOuterValue >>= bBool) && bBool )
+ rSubIncrements[ 0 ].IntervalCount = Any();
+ else
+ rSubIncrements[ 0 ].IntervalCount = getPropertyValue( SCALE_PROP_STEPHELP_COUNT, xInnerPropertySet );
+ bSetScaleData = true;
+ break;
+ }
+ case SCALE_PROP_ORIGIN:
+ {
+ aScaleData.Origin = rOuterValue;
+ bSetScaleData = true;
+ break;
+ }
+ case SCALE_PROP_AUTO_ORIGIN:
+ {
+ if( (rOuterValue >>= bBool) && bBool )
+ aScaleData.Origin = Any();
+ else
+ aScaleData.Origin = getPropertyValue( SCALE_PROP_ORIGIN, xInnerPropertySet );
+ bSetScaleData = true;
+ break;
+ }
+ case SCALE_PROP_AXIS_TYPE:
+ {
+ sal_Int32 nType = 0;
+ if( rOuterValue >>= nType )
+ {
+ if( nType == css::chart::ChartAxisType::AUTOMATIC )
+ {
+ aScaleData.AutoDateAxis = true;
+ if( aScaleData.AxisType == AxisType::DATE )
+ aScaleData.AxisType = AxisType::CATEGORY;
+ }
+ else if( nType == css::chart::ChartAxisType::CATEGORY )
+ {
+ aScaleData.AutoDateAxis = false;
+ if( aScaleData.AxisType == AxisType::DATE )
+ aScaleData.AxisType = AxisType::CATEGORY;
+ }
+ else if( nType == css::chart::ChartAxisType::DATE )
+ {
+ if( aScaleData.AxisType == AxisType::CATEGORY )
+ aScaleData.AxisType = AxisType::DATE;
+ }
+ bSetScaleData = true;
+ }
+ break;
+ }
+ case SCALE_PROP_DATE_INCREMENT:
+ {
+ TimeIncrement aTimeIncrement;
+ rOuterValue >>= aTimeIncrement;
+ aScaleData.TimeIncrement = aTimeIncrement;
+ bSetScaleData = true;
+ break;
+ }
+ case SCALE_PROP_EXPLICIT_DATE_INCREMENT:
+ //read only property
+ break;
+ case SCALE_PROP_LOGARITHMIC:
+ {
+ if( rOuterValue >>= bBool )
+ {
+ bool bWasLogarithm = AxisHelper::isLogarithmic( aScaleData.Scaling );
+
+ // safe comparison between sal_Bool and bool
+ if( (!bBool) != (!bWasLogarithm) )
+ {
+ if( bBool )
+ aScaleData.Scaling = AxisHelper::createLogarithmicScaling( 10.0 );
+ else
+ aScaleData.Scaling = nullptr;
+ bSetScaleData = true;
+ }
+ }
+ break;
+ }
+ case SCALE_PROP_REVERSEDIRECTION:
+ {
+ if( rOuterValue >>= bBool )
+ {
+ bool bWasReverse = ( aScaleData.Orientation == AxisOrientation_REVERSE );
+ if( (!bBool) != (!bWasReverse) ) // safe comparison between sal_Bool and bool
+ {
+ aScaleData.Orientation = bBool ? AxisOrientation_REVERSE : AxisOrientation_MATHEMATICAL;
+ bSetScaleData = true;
+ }
+ }
+ break;
+ }
+ default:
+ {
+ OSL_FAIL("unknown scale property");
+ break;
+ }
+ }
+
+ if( bSetScaleData )
+ xAxis->setScaleData( aScaleData );
+}
+
+Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ Any aRet( m_aOuterValue );
+
+ Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY );
+ OSL_ENSURE(xAxis.is(),"need an XAxis");
+ if(!xAxis.is())
+ return aRet;
+
+ chart2::ScaleData aScaleData( xAxis->getScaleData() );
+
+ ExplicitScaleData aExplicitScale;
+ ExplicitIncrementData aExplicitIncrement;
+
+ switch( eScaleProperty )
+ {
+ case SCALE_PROP_MAX:
+ {
+ aRet = aScaleData.Maximum;
+ if( !aRet.hasValue() )
+ {
+ m_spChart2ModelContact->getExplicitValuesForAxis(
+ xAxis, aExplicitScale, aExplicitIncrement );
+ aRet <<= aExplicitScale.Maximum;
+ }
+ break;
+ }
+ case SCALE_PROP_MIN:
+ {
+ aRet = aScaleData.Minimum;
+ if( !aRet.hasValue() )
+ {
+ m_spChart2ModelContact->getExplicitValuesForAxis(
+ xAxis, aExplicitScale, aExplicitIncrement );
+ aRet <<= aExplicitScale.Minimum;
+ }
+ break;
+ }
+
+ case SCALE_PROP_STEPMAIN:
+ {
+ aRet = aScaleData.IncrementData.Distance;
+ if( !aRet.hasValue() )
+ {
+ m_spChart2ModelContact->getExplicitValuesForAxis(
+ xAxis, aExplicitScale, aExplicitIncrement );
+ aRet <<= aExplicitIncrement.Distance;
+ }
+ break;
+ }
+ case SCALE_PROP_STEPHELP:
+ {
+ // todo: evaluate PostEquidistant
+ bool bNeedToCalculateExplicitValues = true;
+
+ bool bLogarithmic( AxisHelper::isLogarithmic(aScaleData.Scaling) );
+ Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
+ if( bLogarithmic )
+ {
+ if( rSubIncrements.hasElements() )
+ {
+ sal_Int32 nIntervalCount = 0;
+ rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount;
+ aRet <<= double(nIntervalCount);
+ bNeedToCalculateExplicitValues = false;
+ }
+ }
+ else if( aScaleData.IncrementData.Distance.hasValue() )
+ {
+ if( rSubIncrements.hasElements() )
+ {
+ double fStepMain = 0;
+ sal_Int32 nIntervalCount = 0;
+ if( (aScaleData.IncrementData.Distance >>= fStepMain) &&
+ (rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount) &&
+ nIntervalCount > 0 )
+ {
+ aRet <<= fStepMain / static_cast< double >( nIntervalCount );
+ bNeedToCalculateExplicitValues = false;
+ }
+ }
+ else
+ {
+ aRet = aScaleData.IncrementData.Distance;
+ bNeedToCalculateExplicitValues = false;
+ }
+ }
+
+ if( bNeedToCalculateExplicitValues )
+ {
+ m_spChart2ModelContact->getExplicitValuesForAxis(
+ xAxis, aExplicitScale, aExplicitIncrement );
+
+ if( !aExplicitIncrement.SubIncrements.empty() &&
+ aExplicitIncrement.SubIncrements[ 0 ].IntervalCount > 0 )
+ {
+ if( bLogarithmic )
+ {
+ if( rSubIncrements.hasElements() )
+ {
+ sal_Int32 nIntervalCount = aExplicitIncrement.SubIncrements[ 0 ].IntervalCount;
+ aRet <<= double(nIntervalCount);
+ }
+ }
+ else
+ aRet <<= aExplicitIncrement.Distance /
+ static_cast< double >(
+ aExplicitIncrement.SubIncrements[ 0 ].IntervalCount );
+ }
+ else
+ {
+ if( bLogarithmic )
+ aRet <<= 5.0;
+ else
+ aRet <<= aExplicitIncrement.Distance;
+ }
+ }
+ break;
+ }
+ case SCALE_PROP_STEPHELP_COUNT:
+ {
+ sal_Int32 nIntervalCount = 0;
+ bool bNeedToCalculateExplicitValues = true;
+ Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
+ if( rSubIncrements.hasElements() )
+ {
+ if( (rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount) && (nIntervalCount > 0) )
+ bNeedToCalculateExplicitValues = false;
+ }
+ if( bNeedToCalculateExplicitValues )
+ {
+ m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement );
+ if( !aExplicitIncrement.SubIncrements.empty() )
+ nIntervalCount = aExplicitIncrement.SubIncrements[ 0 ].IntervalCount;
+ }
+ aRet <<= nIntervalCount;
+ break;
+ }
+ case SCALE_PROP_AUTO_MAX:
+ {
+ aRet <<= !aScaleData.Maximum.hasValue();
+ break;
+ }
+ case SCALE_PROP_AUTO_MIN:
+ {
+ aRet <<= !aScaleData.Minimum.hasValue();
+ break;
+ }
+ case SCALE_PROP_AUTO_STEPMAIN:
+ {
+ aRet <<= !aScaleData.IncrementData.Distance.hasValue();
+ break;
+ }
+ case SCALE_PROP_AUTO_STEPHELP:
+ {
+ Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements );
+ if( rSubIncrements.hasElements() )
+ aRet <<= !rSubIncrements[ 0 ].IntervalCount.hasValue();
+ else
+ aRet <<= true;
+ break;
+ }
+ case SCALE_PROP_ORIGIN:
+ {
+ aRet = aScaleData.Origin;
+ if( !aRet.hasValue() )
+ {
+ m_spChart2ModelContact->getExplicitValuesForAxis(
+ xAxis, aExplicitScale, aExplicitIncrement );
+ aRet <<= aExplicitScale.Origin;
+ }
+ break;
+ }
+ case SCALE_PROP_AUTO_ORIGIN:
+ {
+ aRet <<= !hasDoubleValue(aScaleData.Origin);
+ break;
+ }
+ case SCALE_PROP_AXIS_TYPE:
+ {
+ sal_Int32 nType = css::chart::ChartAxisType::AUTOMATIC;
+ if( aScaleData.AxisType == AxisType::DATE )
+ {
+ nType = css::chart::ChartAxisType::DATE;
+ }
+ else if( aScaleData.AxisType == AxisType::CATEGORY )
+ {
+ if( !aScaleData.AutoDateAxis )
+ nType = css::chart::ChartAxisType::CATEGORY;
+ }
+ aRet <<= nType;
+ break;
+ }
+ case SCALE_PROP_DATE_INCREMENT:
+ {
+ if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis )
+ aRet <<= aScaleData.TimeIncrement;
+ break;
+ }
+ case SCALE_PROP_EXPLICIT_DATE_INCREMENT:
+ {
+ if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis )
+ {
+ m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement );
+ if( aExplicitScale.AxisType == AxisType::DATE )
+ {
+ TimeIncrement aTimeIncrement;
+ aTimeIncrement.MajorTimeInterval <<= aExplicitIncrement.MajorTimeInterval;
+ aTimeIncrement.MinorTimeInterval <<= aExplicitIncrement.MinorTimeInterval;
+ aTimeIncrement.TimeResolution <<= aExplicitScale.TimeResolution;
+ aRet <<= aTimeIncrement;
+ }
+ else
+ aRet <<= aScaleData.TimeIncrement;
+ }
+
+ break;
+ }
+ case SCALE_PROP_LOGARITHMIC:
+ {
+ aRet <<= AxisHelper::isLogarithmic(aScaleData.Scaling);
+ break;
+ }
+ case SCALE_PROP_REVERSEDIRECTION:
+ {
+ aRet <<= aScaleData.Orientation == AxisOrientation_REVERSE;
+ break;
+ }
+ default:
+ {
+ OSL_FAIL("unknown scale property");
+ break;
+ }
+ }
+
+ return aRet;
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx
new file mode 100644
index 000000000..e62b5f702
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx
@@ -0,0 +1,90 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSCALEPROPERTY_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSCALEPROPERTY_HXX
+
+#include <WrappedProperty.hxx>
+
+#include <memory>
+#include <vector>
+
+namespace chart::wrapper { class Chart2ModelContact; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class WrappedScaleProperty final : public WrappedProperty
+{
+public:
+ enum tScaleProperty
+ {
+ SCALE_PROP_MAX
+ , SCALE_PROP_MIN
+ , SCALE_PROP_ORIGIN
+ , SCALE_PROP_STEPMAIN
+ , SCALE_PROP_STEPHELP //deprecated property
+ , SCALE_PROP_STEPHELP_COUNT
+ , SCALE_PROP_AUTO_MAX
+ , SCALE_PROP_AUTO_MIN
+ , SCALE_PROP_AUTO_ORIGIN
+ , SCALE_PROP_AUTO_STEPMAIN
+ , SCALE_PROP_AUTO_STEPHELP
+ , SCALE_PROP_AXIS_TYPE
+ , SCALE_PROP_DATE_INCREMENT
+ , SCALE_PROP_EXPLICIT_DATE_INCREMENT
+ , SCALE_PROP_LOGARITHMIC
+ , SCALE_PROP_REVERSEDIRECTION
+ };
+
+ WrappedScaleProperty(tScaleProperty eScaleProperty, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ virtual ~WrappedScaleProperty() override;
+
+ static void addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList, const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+private:
+ /// @throws css::beans::UnknownPropertyException
+ /// @throws css::beans::PropertyVetoException
+ /// @throws css::lang::IllegalArgumentException
+ /// @throws css::lang::WrappedTargetException
+ /// @throws css::uno::RuntimeException
+ void setPropertyValue( tScaleProperty eScaleProperty, const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const;
+ /// @throws css::beans::UnknownPropertyException
+ /// @throws css::lang::WrappedTargetException
+ /// @throws css::uno::RuntimeException
+ css::uno::Any getPropertyValue( tScaleProperty eScaleProperty, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const;
+
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ tScaleProperty m_eScaleProperty;
+
+ mutable css::uno::Any m_aOuterValue;
+};
+
+} // namespace wrapper
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSCALEPROPERTY_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx
new file mode 100644
index 000000000..373fec6c8
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx
@@ -0,0 +1,138 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedScaleTextProperties.hxx"
+#include "Chart2ModelContact.hxx"
+#include <FastPropertyIdRanges.hxx>
+#include <WrappedProperty.hxx>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::beans::Property;
+
+namespace chart::wrapper
+{
+
+namespace {
+
+class WrappedScaleTextProperty : public WrappedProperty
+{
+public:
+ explicit WrappedScaleTextProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const override;
+ virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override;
+ virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private:
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+};
+
+}
+
+WrappedScaleTextProperty::WrappedScaleTextProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : ::chart::WrappedProperty( "ScaleText" , OUString() )
+ , m_spChart2ModelContact( spChart2ModelContact )
+{
+}
+
+void WrappedScaleTextProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ static const char aRefSizeName[] = "ReferencePageSize";
+
+ if( !xInnerPropertySet.is() )
+ return;
+
+ bool bNewValue = false;
+ if( ! (rOuterValue >>= bNewValue) )
+ {
+ if( rOuterValue.hasValue() )
+ throw lang::IllegalArgumentException( "Property ScaleText requires value of type boolean", nullptr, 0 );
+ }
+
+ try
+ {
+ if( bNewValue )
+ {
+ awt::Size aRefSize( m_spChart2ModelContact->GetPageSize() );
+ xInnerPropertySet->setPropertyValue( aRefSizeName, uno::Any( aRefSize ) );
+ }
+ else
+ xInnerPropertySet->setPropertyValue( aRefSizeName, Any() );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+Any WrappedScaleTextProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) );
+ if( xInnerPropertySet.is() )
+ {
+ if( xInnerPropertySet->getPropertyValue( "ReferencePageSize" ).hasValue() )
+ aRet <<= true;
+ else
+ aRet <<= false;
+ }
+
+ return aRet;
+}
+
+Any WrappedScaleTextProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ Any aRet;
+ aRet <<= false;
+ return aRet;
+}
+
+namespace
+{
+enum
+{
+ PROP_CHART_SCALE_TEXT = FAST_PROPERTY_ID_START_SCALE_TEXT_PROP
+};
+
+}//anonymous namespace
+
+void WrappedScaleTextProperties::addProperties( std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "ScaleText",
+ PROP_CHART_SCALE_TEXT,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::MAYBEVOID
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+void WrappedScaleTextProperties::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ rList.emplace_back( new WrappedScaleTextProperty( spChart2ModelContact ) );
+}
+
+} //namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.hxx
new file mode 100644
index 000000000..85748851a
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.hxx
@@ -0,0 +1,46 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <sal/types.h>
+#include <memory>
+#include <vector>
+
+namespace chart { class WrappedProperty; }
+namespace chart::wrapper { class Chart2ModelContact; }
+namespace com::sun::star::beans { struct Property; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class WrappedScaleTextProperties
+{
+public:
+ static void addProperties( std::vector< css::beans::Property >& rOutProperties );
+ static void addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+};
+
+} //namespace wrapper
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx
new file mode 100644
index 000000000..d3a883429
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx
@@ -0,0 +1,101 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedSceneProperty.hxx"
+#include "Chart2ModelContact.hxx"
+#include <DiagramHelper.hxx>
+#include <BaseGFXHelper.hxx>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+
+namespace chart::wrapper
+{
+
+void WrappedSceneProperty::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ rList.emplace_back( new WrappedD3DTransformMatrixProperty( spChart2ModelContact ) );
+}
+
+WrappedD3DTransformMatrixProperty::WrappedD3DTransformMatrixProperty(
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact )
+ : WrappedProperty("D3DTransformMatrix","D3DTransformMatrix")
+ , m_spChart2ModelContact( spChart2ModelContact )
+{
+}
+
+WrappedD3DTransformMatrixProperty::~WrappedD3DTransformMatrixProperty()
+{
+}
+
+void WrappedD3DTransformMatrixProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) )
+ {
+ drawing::HomogenMatrix aHM;
+ if( rOuterValue >>= aHM )
+ {
+ ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
+ BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
+
+ ::basegfx::B3DHomMatrix aMatrix;
+ aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
+ ::basegfx::B3DHomMatrix aObjectMatrix;
+ ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
+
+ aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
+
+ WrappedProperty::setPropertyValue( uno::Any(aHM), xInnerPropertySet );
+ return;
+ }
+ }
+
+ WrappedProperty::setPropertyValue( rOuterValue, xInnerPropertySet );
+}
+
+Any WrappedD3DTransformMatrixProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) )
+ {
+ uno::Any aAMatrix( WrappedProperty::getPropertyValue( xInnerPropertySet ) );
+ drawing::HomogenMatrix aHM;
+ if( aAMatrix >>= aHM )
+ {
+ ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix(
+ BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) );
+
+ ::basegfx::B3DHomMatrix aMatrix;
+ aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() );
+ ::basegfx::B3DHomMatrix aObjectMatrix;
+ ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix;
+
+ aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix);
+
+ return uno::Any(aHM);
+ }
+ }
+
+ return WrappedProperty::getPropertyValue( xInnerPropertySet );
+}
+
+} //namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx
new file mode 100644
index 000000000..6b7ae6416
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx
@@ -0,0 +1,62 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSCENEPROPERTY_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSCENEPROPERTY_HXX
+
+#include <WrappedProperty.hxx>
+
+#include <memory>
+#include <vector>
+
+namespace chart::wrapper { class Chart2ModelContact; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class WrappedSceneProperty
+{
+public:
+ static void addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+};
+
+class WrappedD3DTransformMatrixProperty : public WrappedProperty
+{
+public:
+ explicit WrappedD3DTransformMatrixProperty(
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+ virtual ~WrappedD3DTransformMatrixProperty() override;
+
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+private:
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+};
+
+} //namespace wrapper
+} //namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSCENEPROPERTY_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx
new file mode 100644
index 000000000..88fa72696
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx
@@ -0,0 +1,51 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedSeriesAreaOrLineProperty.hxx"
+#include "DataSeriesPointWrapper.hxx"
+
+namespace chart::wrapper
+{
+
+WrappedSeriesAreaOrLineProperty::WrappedSeriesAreaOrLineProperty(
+ const OUString& rOuterName
+ , const OUString& rInnerAreaTypeName
+ , const OUString& rInnerLineTypeName
+ , DataSeriesPointWrapper* pDataSeriesPointWrapper )
+ : WrappedProperty( rOuterName, OUString() )
+ , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper )
+ , m_aInnerAreaTypeName( rInnerAreaTypeName )
+ , m_aInnerLineTypeName( rInnerLineTypeName )
+{
+}
+WrappedSeriesAreaOrLineProperty::~WrappedSeriesAreaOrLineProperty()
+{
+}
+
+//virtual
+OUString WrappedSeriesAreaOrLineProperty::getInnerName() const
+{
+ if( m_pDataSeriesPointWrapper && !m_pDataSeriesPointWrapper->isSupportingAreaProperties() )
+ return m_aInnerLineTypeName;
+ return m_aInnerAreaTypeName;
+}
+
+} //namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx
new file mode 100644
index 000000000..2c3eff9da
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx
@@ -0,0 +1,52 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSERIESAREAORLINEPROPERTY_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSERIESAREAORLINEPROPERTY_HXX
+
+#include <WrappedProperty.hxx>
+
+namespace chart
+{
+namespace wrapper
+{
+
+class DataSeriesPointWrapper;
+class WrappedSeriesAreaOrLineProperty : public WrappedProperty
+{
+public:
+ WrappedSeriesAreaOrLineProperty( const OUString& rOuterName
+ , const OUString& rInnerAreaTypeName, const OUString& rInnerLineTypeName
+ , DataSeriesPointWrapper* pDataSeriesPointWrapper );
+ virtual ~WrappedSeriesAreaOrLineProperty() override;
+
+ virtual OUString getInnerName() const override;
+
+private:
+ DataSeriesPointWrapper* m_pDataSeriesPointWrapper;
+ OUString m_aInnerAreaTypeName;
+ OUString m_aInnerLineTypeName;
+};
+
+} //namespace wrapper
+} //namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSERIESAREAORLINEPROPERTY_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx
new file mode 100644
index 000000000..26c260ffc
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx
@@ -0,0 +1,173 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSERIESORDIAGRAMPROPERTY_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSERIESORDIAGRAMPROPERTY_HXX
+
+#include <WrappedProperty.hxx>
+#include "Chart2ModelContact.hxx"
+#include <DiagramHelper.hxx>
+
+#include <memory>
+#include <vector>
+
+namespace com::sun::star::chart2 { class XDataSeries; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+enum tSeriesOrDiagramPropertyType
+{
+ DATA_SERIES,
+ DIAGRAM
+};
+
+//PROPERTYTYPE is the type of the outer property
+
+template< typename PROPERTYTYPE >
+class WrappedSeriesOrDiagramProperty : public WrappedProperty
+{
+public:
+ virtual PROPERTYTYPE getValueFromSeries( const css::uno::Reference< css::beans::XPropertySet >& xSeriesPropertySet ) const =0;
+ virtual void setValueToSeries( const css::uno::Reference< css::beans::XPropertySet >& xSeriesPropertySet, const PROPERTYTYPE & aNewValue ) const =0;
+
+ explicit WrappedSeriesOrDiagramProperty( const OUString& rName, const css::uno::Any& rDefaulValue
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact
+ , tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedProperty(rName,OUString())
+ , m_spChart2ModelContact(spChart2ModelContact)
+ , m_aOuterValue(rDefaulValue)
+ , m_aDefaultValue(rDefaulValue)
+ , m_ePropertyType( ePropertyType )
+ {
+ }
+
+ bool detectInnerValue( PROPERTYTYPE& rValue, bool& rHasAmbiguousValue ) const
+ {
+ bool bHasDetectableInnerValue = false;
+ rHasAmbiguousValue = false;
+ if( m_ePropertyType == DIAGRAM &&
+ m_spChart2ModelContact )
+ {
+ std::vector< css::uno::Reference< css::chart2::XDataSeries > > aSeriesVector(
+ ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) );
+ for (auto const& series : aSeriesVector)
+ {
+ PROPERTYTYPE aCurValue = getValueFromSeries( css::uno::Reference< css::beans::XPropertySet >::query(series) );
+ if( !bHasDetectableInnerValue )
+ rValue = aCurValue;
+ else
+ {
+ if( rValue != aCurValue )
+ {
+ rHasAmbiguousValue = true;
+ break;
+ }
+ else
+ rValue = aCurValue;
+ }
+ bHasDetectableInnerValue = true;
+ }
+ }
+ return bHasDetectableInnerValue;
+ }
+ void setInnerValue( PROPERTYTYPE aNewValue ) const
+ {
+ if( m_ePropertyType == DIAGRAM &&
+ m_spChart2ModelContact )
+ {
+ std::vector< css::uno::Reference< css::chart2::XDataSeries > > aSeriesVector(
+ ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) );
+ for (auto const& series : aSeriesVector)
+ {
+ css::uno::Reference< css::beans::XPropertySet > xSeriesPropertySet(series, css::uno::UNO_QUERY);
+ if( xSeriesPropertySet.is() )
+ {
+ setValueToSeries( xSeriesPropertySet, aNewValue );
+ }
+ }
+ }
+ }
+ virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override
+ {
+ PROPERTYTYPE aNewValue = PROPERTYTYPE();
+ if( ! (rOuterValue >>= aNewValue) )
+ throw css::lang::IllegalArgumentException( "statistic property requires different type", nullptr, 0 );
+
+ if( m_ePropertyType == DIAGRAM )
+ {
+ m_aOuterValue = rOuterValue;
+
+ bool bHasAmbiguousValue = false;
+ PROPERTYTYPE aOldValue = PROPERTYTYPE();
+ if( detectInnerValue( aOldValue, bHasAmbiguousValue ) )
+ {
+ if( bHasAmbiguousValue || aNewValue != aOldValue )
+ setInnerValue( aNewValue );
+ }
+ }
+ else
+ {
+ setValueToSeries( xInnerPropertySet, aNewValue );
+ }
+ }
+
+ virtual css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override
+ {
+ if( m_ePropertyType == DIAGRAM )
+ {
+ bool bHasAmbiguousValue = false;
+ PROPERTYTYPE aValue = PROPERTYTYPE();
+ if( detectInnerValue( aValue, bHasAmbiguousValue ) )
+ {
+ if(bHasAmbiguousValue)
+ m_aOuterValue = m_aDefaultValue;
+ else
+ m_aOuterValue <<= aValue;
+ }
+ return m_aOuterValue;
+ }
+ else
+ {
+ css::uno::Any aRet( m_aDefaultValue );
+ aRet <<= getValueFromSeries( xInnerPropertySet );
+ return aRet;
+ }
+ }
+
+ virtual css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& /* xInnerPropertyState */ ) const override
+ {
+ return m_aDefaultValue;
+ }
+
+protected:
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ mutable css::uno::Any m_aOuterValue;
+ css::uno::Any m_aDefaultValue;
+ tSeriesOrDiagramPropertyType m_ePropertyType;
+};
+
+} //namespace wrapper
+} //namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSERIESORDIAGRAMPROPERTY_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx
new file mode 100644
index 000000000..ad07a98bc
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx
@@ -0,0 +1,291 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedSplineProperties.hxx"
+#include "Chart2ModelContact.hxx"
+#include <FastPropertyIdRanges.hxx>
+#include <DiagramHelper.hxx>
+#include <WrappedProperty.hxx>
+#include <unonames.hxx>
+
+#include <sal/log.hxx>
+
+#include <com/sun/star/chart2/CurveStyle.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::Property;
+
+namespace chart::wrapper
+{
+
+namespace
+{
+
+//PROPERTYTYPE is the type of the outer property
+
+template< typename PROPERTYTYPE >
+class WrappedSplineProperty : public WrappedProperty
+{
+public:
+ explicit WrappedSplineProperty( const OUString& rOuterName, const OUString& rInnerName
+ , const css::uno::Any& rDefaulValue
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact )
+ : WrappedProperty(rOuterName,OUString())
+ , m_spChart2ModelContact(spChart2ModelContact)
+ , m_aOuterValue(rDefaulValue)
+ , m_aDefaultValue(rDefaulValue)
+ , m_aOwnInnerName(rInnerName)
+ {
+ }
+
+ bool detectInnerValue( PROPERTYTYPE& rValue, bool& rHasAmbiguousValue ) const
+ {
+ bool bHasDetectableInnerValue = false;
+ rHasAmbiguousValue = false;
+ Sequence< css::uno::Reference< css::chart2::XChartType > > aChartTypes(
+ ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) );
+ for( sal_Int32 nN = aChartTypes.getLength(); nN--; )
+ {
+ try
+ {
+ uno::Reference<beans::XPropertySet> xChartTypePropertySet(aChartTypes[nN], uno::UNO_QUERY);
+ if (!xChartTypePropertySet.is())
+ continue;
+
+ Any aSingleValue = convertInnerToOuterValue( xChartTypePropertySet->getPropertyValue(m_aOwnInnerName) );
+ PROPERTYTYPE aCurValue = PROPERTYTYPE();
+ aSingleValue >>= aCurValue;
+ if( !bHasDetectableInnerValue )
+ rValue = aCurValue;
+ else
+ {
+ if( rValue != aCurValue )
+ {
+ rHasAmbiguousValue = true;
+ break;
+ }
+ else
+ rValue = aCurValue;
+ }
+ bHasDetectableInnerValue = true;
+ }
+ catch( uno::Exception & ex )
+ {
+ //spline properties are not supported by all charttypes
+ //in that cases this exception is ok
+ ex.Context.is();//to have debug information without compilation warnings
+ }
+ }
+ return bHasDetectableInnerValue;
+ }
+ void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& /*xInnerPropertySet*/ ) const override
+ {
+ PROPERTYTYPE aNewValue;
+ if( ! (rOuterValue >>= aNewValue) )
+ throw css::lang::IllegalArgumentException( "spline property requires different type", nullptr, 0 );
+
+ m_aOuterValue = rOuterValue;
+
+ bool bHasAmbiguousValue = false;
+ PROPERTYTYPE aOldValue = PROPERTYTYPE();
+ if( !detectInnerValue( aOldValue, bHasAmbiguousValue ) )
+ return;
+
+ if( !(bHasAmbiguousValue || aNewValue != aOldValue) )
+ return;
+
+ Sequence< css::uno::Reference< css::chart2::XChartType > > aChartTypes(
+ ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) );
+ for( sal_Int32 nN = aChartTypes.getLength(); nN--; )
+ {
+ try
+ {
+ css::uno::Reference< css::beans::XPropertySet > xChartTypePropertySet( aChartTypes[nN], css::uno::UNO_QUERY );
+ if( xChartTypePropertySet.is() )
+ {
+ xChartTypePropertySet->setPropertyValue(m_aOwnInnerName,convertOuterToInnerValue(uno::Any(aNewValue)));
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ //spline properties are not supported by all charttypes
+ //in that cases this exception is ok
+ ex.Context.is();//to have debug information without compilation warnings
+ }
+ }
+ }
+
+ css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& /*xInnerPropertySet*/ ) const override
+ {
+ bool bHasAmbiguousValue = false;
+ PROPERTYTYPE aValue;
+ if( detectInnerValue( aValue, bHasAmbiguousValue ) )
+ {
+ m_aOuterValue <<= aValue;
+ }
+ return m_aOuterValue;
+ }
+
+ css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& /*xInnerPropertyState*/ ) const override
+ {
+ return m_aDefaultValue;
+ }
+
+protected:
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ mutable css::uno::Any m_aOuterValue;
+ css::uno::Any m_aDefaultValue;
+ // this inner name is not set as inner name at the base class
+ const OUString m_aOwnInnerName;
+};
+
+class WrappedSplineTypeProperty : public WrappedSplineProperty< sal_Int32 >
+{
+public:
+ explicit WrappedSplineTypeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ virtual css::uno::Any convertInnerToOuterValue( const css::uno::Any& rInnerValue ) const override;
+ virtual css::uno::Any convertOuterToInnerValue( const css::uno::Any& rOuterValue ) const override;
+};
+
+enum
+{
+ //spline properties
+ PROP_CHART_SPLINE_TYPE = FAST_PROPERTY_ID_START_CHART_SPLINE_PROP
+ , PROP_CHART_SPLINE_ORDER
+ , PROP_CHART_SPLINE_RESOLUTION
+};
+
+}//anonymous namespace
+
+void WrappedSplineProperties::addProperties( std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( CHART_UNONAME_SPLINE_TYPE,
+ PROP_CHART_SPLINE_TYPE,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( CHART_UNONAME_SPLINE_ORDER,
+ PROP_CHART_SPLINE_ORDER,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( CHART_UNONAME_SPLINE_RESOLUTION,
+ PROP_CHART_SPLINE_RESOLUTION,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT
+ | beans::PropertyAttribute::MAYBEVOID );
+}
+
+void WrappedSplineProperties::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ rList.emplace_back( new WrappedSplineTypeProperty( spChart2ModelContact ) );
+ rList.emplace_back(
+ new WrappedSplineProperty<sal_Int32>(
+ CHART_UNONAME_SPLINE_ORDER, CHART_UNONAME_SPLINE_ORDER,
+ uno::Any(sal_Int32(3)), spChart2ModelContact));
+ rList.emplace_back(
+ new WrappedSplineProperty<sal_Int32>(
+ CHART_UNONAME_SPLINE_RESOLUTION, CHART_UNONAME_CURVE_RESOLUTION,
+ uno::Any(sal_Int32(20)), spChart2ModelContact));
+}
+
+WrappedSplineTypeProperty::WrappedSplineTypeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedSplineProperty<sal_Int32>(CHART_UNONAME_SPLINE_TYPE, CHART_UNONAME_CURVE_STYLE, uno::Any(sal_Int32(0)), spChart2ModelContact )
+{
+}
+
+Any WrappedSplineTypeProperty::convertInnerToOuterValue( const Any& rInnerValue ) const
+{
+ chart2::CurveStyle aInnerValue = chart2::CurveStyle_LINES;
+ rInnerValue >>= aInnerValue;
+
+ sal_Int32 nOuterValue;
+ switch (aInnerValue)
+ {
+ case chart2::CurveStyle_CUBIC_SPLINES:
+ nOuterValue = 1;
+ break;
+ case chart2::CurveStyle_B_SPLINES:
+ nOuterValue = 2;
+ break;
+ case chart2::CurveStyle_STEP_START:
+ nOuterValue = 3;
+ break;
+ case chart2::CurveStyle_STEP_END:
+ nOuterValue = 4;
+ break;
+ case chart2::CurveStyle_STEP_CENTER_X:
+ nOuterValue = 5;
+ break;
+ case chart2::CurveStyle_STEP_CENTER_Y:
+ nOuterValue = 6;
+ break;
+ default:
+ nOuterValue = 0;
+ }
+
+ return uno::Any(nOuterValue);
+}
+Any WrappedSplineTypeProperty::convertOuterToInnerValue( const Any& rOuterValue ) const
+{
+ sal_Int32 nOuterValue=0;
+ rOuterValue >>= nOuterValue;
+
+ chart2::CurveStyle aInnerValue;
+
+ switch (nOuterValue)
+ {
+ case 1:
+ aInnerValue = chart2::CurveStyle_CUBIC_SPLINES;
+ break;
+ case 2:
+ aInnerValue = chart2::CurveStyle_B_SPLINES;
+ break;
+ case 3:
+ aInnerValue = chart2::CurveStyle_STEP_START;
+ break;
+ case 4:
+ aInnerValue = chart2::CurveStyle_STEP_END;
+ break;
+ case 5:
+ aInnerValue = chart2::CurveStyle_STEP_CENTER_X;
+ break;
+ case 6:
+ aInnerValue = chart2::CurveStyle_STEP_CENTER_Y;
+ break;
+ default:
+ SAL_WARN_IF(nOuterValue != 0, "chart2", "Unknown line style");
+ aInnerValue = chart2::CurveStyle_LINES;
+ }
+
+ return uno::Any(aInnerValue);
+}
+
+} //namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.hxx
new file mode 100644
index 000000000..d52c102c0
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.hxx
@@ -0,0 +1,49 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSPLINEPROPERTIES_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSPLINEPROPERTIES_HXX
+
+#include <sal/types.h>
+#include <memory>
+#include <vector>
+
+namespace chart { class WrappedProperty; }
+namespace chart::wrapper { class Chart2ModelContact; }
+namespace com::sun::star::beans { struct Property; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class WrappedSplineProperties
+{
+public:
+ static void addProperties( std::vector< css::beans::Property > & rOutProperties );
+ static void addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+};
+
+} //namespace wrapper
+} //namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSPLINEPROPERTIES_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx
new file mode 100644
index 000000000..6e12bea50
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx
@@ -0,0 +1,1072 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedStatisticProperties.hxx"
+#include "WrappedSeriesOrDiagramProperty.hxx"
+#include <FastPropertyIdRanges.hxx>
+#include <RegressionCurveHelper.hxx>
+#include <ErrorBar.hxx>
+#include <StatisticsHelper.hxx>
+#include <unonames.hxx>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/chart/ChartErrorCategory.hpp>
+#include <com/sun/star/chart/ErrorBarStyle.hpp>
+#include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
+#include <com/sun/star/chart/ChartRegressionCurveType.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
+#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
+#include <utility>
+
+namespace com::sun::star::chart2::data { class XDataProvider; }
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::beans::Property;
+
+namespace chart::wrapper
+{
+
+namespace
+{
+
+Any lcl_getRegressionDefault()
+{
+ Any aRet;
+ aRet <<= css::chart::ChartRegressionCurveType_NONE;
+ return aRet;
+}
+
+css::chart::ChartRegressionCurveType lcl_getRegressionCurveType(SvxChartRegress eRegressionType)
+{
+ css::chart::ChartRegressionCurveType eRet = css::chart::ChartRegressionCurveType_NONE;
+ switch(eRegressionType)
+ {
+ case SvxChartRegress::Linear:
+ eRet = css::chart::ChartRegressionCurveType_LINEAR;
+ break;
+ case SvxChartRegress::Log:
+ eRet = css::chart::ChartRegressionCurveType_LOGARITHM;
+ break;
+ case SvxChartRegress::Exp:
+ eRet = css::chart::ChartRegressionCurveType_EXPONENTIAL;
+ break;
+ case SvxChartRegress::Power:
+ eRet = css::chart::ChartRegressionCurveType_POWER;
+ break;
+ case SvxChartRegress::Polynomial:
+ eRet = css::chart::ChartRegressionCurveType_POLYNOMIAL;
+ break;
+ /*case SvxChartRegress::MovingAverage:
+ eRet = css::chart::ChartRegressionCurveType_MOVING_AVERAGE;
+ break;*/
+ default:
+ eRet = css::chart::ChartRegressionCurveType_NONE;
+ break;
+ }
+ return eRet;
+}
+
+SvxChartRegress lcl_getRegressionType( css::chart::ChartRegressionCurveType eRegressionCurveType )
+{
+ SvxChartRegress eRet;
+ switch (eRegressionCurveType)
+ {
+ case css::chart::ChartRegressionCurveType_LINEAR:
+ eRet = SvxChartRegress::Linear;
+ break;
+ case css::chart::ChartRegressionCurveType_LOGARITHM:
+ eRet = SvxChartRegress::Log;
+ break;
+ case css::chart::ChartRegressionCurveType_EXPONENTIAL:
+ eRet = SvxChartRegress::Exp;
+ break;
+ case css::chart::ChartRegressionCurveType_POLYNOMIAL:
+ //case css::chart::ChartRegressionCurveType_MOVING_AVERAGE:
+ case css::chart::ChartRegressionCurveType_POWER:
+ eRet = SvxChartRegress::Power;
+ break;
+ default:
+ eRet = SvxChartRegress::NONE;
+ break;
+ }
+ return eRet;
+}
+
+sal_Int32 lcl_getErrorBarStyle( const uno::Reference< beans::XPropertySet >& xErrorBarProperties )
+{
+ sal_Int32 nStyle = css::chart::ErrorBarStyle::NONE;
+ if(xErrorBarProperties.is())
+ xErrorBarProperties->getPropertyValue( "ErrorBarStyle" ) >>= nStyle;
+ return nStyle;
+}
+
+uno::Reference< chart2::data::XDataProvider > lcl_getDataProviderFromContact(
+ const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ uno::Reference< chart2::data::XDataProvider > xResult;
+ if( spChart2ModelContact)
+ {
+ uno::Reference< chart2::XChartDocument > xChartDoc(
+ spChart2ModelContact->getChart2Document());
+ if( xChartDoc.is())
+ xResult.set( xChartDoc->getDataProvider());
+ }
+ return xResult;
+}
+
+void lcl_ConvertRangeFromXML(
+ OUString & rInOutRange,
+ const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ if( !rInOutRange.isEmpty())
+ {
+ uno::Reference< chart2::data::XRangeXMLConversion > xConverter(
+ lcl_getDataProviderFromContact( spChart2ModelContact ), uno::UNO_QUERY );
+ if( xConverter.is())
+ {
+ OUString aResult = xConverter->convertRangeFromXML( rInOutRange );
+ rInOutRange = aResult;
+ }
+ }
+}
+
+void lcl_ConvertRangeToXML(
+ OUString & rInOutRange,
+ const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ if( !rInOutRange.isEmpty())
+ {
+ uno::Reference< chart2::data::XRangeXMLConversion > xConverter(
+ lcl_getDataProviderFromContact( spChart2ModelContact ), uno::UNO_QUERY );
+ if( xConverter.is())
+ {
+ OUString aResult = xConverter->convertRangeToXML( rInOutRange );
+ rInOutRange = aResult;
+ }
+ }
+}
+
+template< typename PROPERTYTYPE >
+class WrappedStatisticProperty : public WrappedSeriesOrDiagramProperty< PROPERTYTYPE >
+{
+public:
+ explicit WrappedStatisticProperty(
+ const OUString& rName, const Any& rDefaulValue,
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType)
+ : WrappedSeriesOrDiagramProperty<PROPERTYTYPE>(rName, rDefaulValue, spChart2ModelContact,
+ ePropertyType)
+ {}
+
+protected:
+ static uno::Reference< beans::XPropertySet > getOrCreateErrorBarProperties( const Reference< beans::XPropertySet >& xSeriesPropertySet )
+ {
+ if(!xSeriesPropertySet.is())
+ return nullptr;
+ uno::Reference< beans::XPropertySet > xErrorBarProperties;
+ xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties;
+ if( !xErrorBarProperties.is() )
+ {
+ xErrorBarProperties = new ::chart::ErrorBar;
+ //default in new and old api are different
+ xErrorBarProperties->setPropertyValue( "ShowPositiveError" , uno::Any(false) );
+ xErrorBarProperties->setPropertyValue( "ShowNegativeError" , uno::Any(false) );
+ xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::Any(css::chart::ErrorBarStyle::NONE) );
+ xSeriesPropertySet->setPropertyValue( CHART_UNONAME_ERRORBAR_Y , uno::Any( xErrorBarProperties ) );
+ }
+ return xErrorBarProperties;
+ }
+
+};
+
+//PROP_CHART_STATISTIC_CONST_ERROR_LOW
+class WrappedConstantErrorLowProperty : public WrappedStatisticProperty< double >
+{
+public:
+ virtual double getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const override;
+
+ explicit WrappedConstantErrorLowProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType );
+
+private:
+ mutable Any m_aOuterValue;
+};
+
+}//anonymous namespace
+
+WrappedConstantErrorLowProperty::WrappedConstantErrorLowProperty(
+ std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedStatisticProperty< double >( "ConstantErrorLow"
+ , uno::Any( 0.0 ), std::move(spChart2ModelContact), ePropertyType )
+{
+}
+
+double WrappedConstantErrorLowProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ double aRet = 0.0;
+ m_aDefaultValue >>= aRet;
+ uno::Reference< beans::XPropertySet > xErrorBarProperties;
+ if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
+ {
+ if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::ABSOLUTE )
+ xErrorBarProperties->getPropertyValue( "NegativeError" ) >>= aRet;
+ else
+ m_aOuterValue >>= aRet;
+ }
+ return aRet;
+}
+
+void WrappedConstantErrorLowProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const
+{
+ uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
+ if( xErrorBarProperties.is() )
+ {
+ m_aOuterValue <<= aNewValue;
+ if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::ABSOLUTE )
+ {
+ xErrorBarProperties->setPropertyValue( "NegativeError", m_aOuterValue );
+ }
+ }
+}
+
+namespace {
+
+//PROP_CHART_STATISTIC_CONST_ERROR_HIGH
+class WrappedConstantErrorHighProperty : public WrappedStatisticProperty< double >
+{
+public:
+ virtual double getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const override;
+
+ explicit WrappedConstantErrorHighProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType );
+
+private:
+ mutable Any m_aOuterValue;
+};
+
+}
+
+WrappedConstantErrorHighProperty::WrappedConstantErrorHighProperty(
+ std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedStatisticProperty< double >( "ConstantErrorHigh"
+ , uno::Any( 0.0 ), std::move(spChart2ModelContact), ePropertyType )
+{
+}
+
+double WrappedConstantErrorHighProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ double aRet = 0.0;
+ m_aDefaultValue >>= aRet;
+ uno::Reference< beans::XPropertySet > xErrorBarProperties;
+ if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
+ {
+ if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::ABSOLUTE )
+ xErrorBarProperties->getPropertyValue( "PositiveError" ) >>= aRet;
+ else
+ m_aOuterValue >>= aRet;
+ }
+ return aRet;
+}
+
+void WrappedConstantErrorHighProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const
+{
+ uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
+ if( xErrorBarProperties.is() )
+ {
+ m_aOuterValue <<= aNewValue;
+ if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::ABSOLUTE )
+ {
+ xErrorBarProperties->setPropertyValue( "PositiveError" , m_aOuterValue );
+ }
+ }
+}
+
+namespace {
+
+//PROP_CHART_STATISTIC_MEAN_VALUE
+class WrappedMeanValueProperty : public WrappedStatisticProperty< bool >
+{
+public:
+ virtual bool getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const bool& aNewValue ) const override;
+
+ explicit WrappedMeanValueProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType );
+};
+
+}
+
+WrappedMeanValueProperty::WrappedMeanValueProperty(
+ std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedStatisticProperty< bool >( "MeanValue", uno::Any( false ), std::move(spChart2ModelContact), ePropertyType )
+{
+}
+
+bool WrappedMeanValueProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ bool bRet = false;
+ uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY );
+ if( xRegCnt.is() )
+ bRet = RegressionCurveHelper::hasMeanValueLine( xRegCnt );
+ return bRet;
+}
+
+void WrappedMeanValueProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const bool& aNewValue ) const
+{
+ uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY );
+ if( xRegCnt.is() )
+ {
+ if(aNewValue)
+ RegressionCurveHelper::addMeanValueLine( xRegCnt, nullptr );
+ else
+ RegressionCurveHelper::removeMeanValueLine( xRegCnt );
+ }
+}
+
+namespace {
+
+//PROP_CHART_STATISTIC_ERROR_CATEGORY
+// deprecated, replaced by ErrorBarStyle
+class WrappedErrorCategoryProperty : public WrappedStatisticProperty< css::chart::ChartErrorCategory >
+{
+public:
+ virtual css::chart::ChartErrorCategory getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const css::chart::ChartErrorCategory& aNewValue ) const override;
+
+ explicit WrappedErrorCategoryProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType );
+};
+
+}
+
+WrappedErrorCategoryProperty::WrappedErrorCategoryProperty(
+ std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedStatisticProperty< css::chart::ChartErrorCategory >( "ErrorCategory"
+ , uno::Any( css::chart::ChartErrorCategory_NONE ), std::move(spChart2ModelContact), ePropertyType )
+{
+}
+
+css::chart::ChartErrorCategory WrappedErrorCategoryProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ css::chart::ChartErrorCategory aRet = css::chart::ChartErrorCategory_NONE;
+ m_aDefaultValue >>= aRet;
+ uno::Reference< beans::XPropertySet > xErrorBarProperties;
+ if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
+ {
+ sal_Int32 nStyle = css::chart::ErrorBarStyle::NONE;
+ xErrorBarProperties->getPropertyValue( "ErrorBarStyle" ) >>= nStyle;
+ switch(nStyle)
+ {
+ case css::chart::ErrorBarStyle::NONE:
+ aRet = css::chart::ChartErrorCategory_NONE;
+ break;
+ case css::chart::ErrorBarStyle::VARIANCE:
+ aRet = css::chart::ChartErrorCategory_VARIANCE;
+ break;
+ case css::chart::ErrorBarStyle::STANDARD_DEVIATION:
+ aRet = css::chart::ChartErrorCategory_STANDARD_DEVIATION;
+ break;
+ case css::chart::ErrorBarStyle::ABSOLUTE:
+ aRet = css::chart::ChartErrorCategory_CONSTANT_VALUE;
+ break;
+ case css::chart::ErrorBarStyle::RELATIVE:
+ aRet = css::chart::ChartErrorCategory_PERCENT;
+ break;
+ case css::chart::ErrorBarStyle::ERROR_MARGIN:
+ aRet = css::chart::ChartErrorCategory_ERROR_MARGIN;
+ break;
+ case css::chart::ErrorBarStyle::STANDARD_ERROR:
+ break;
+ case css::chart::ErrorBarStyle::FROM_DATA:
+ break;
+ default:
+ break;
+ }
+ }
+ return aRet;
+}
+void WrappedErrorCategoryProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const css::chart::ChartErrorCategory& aNewValue ) const
+{
+ if( !xSeriesPropertySet.is() )
+ return;
+
+ uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
+ if( !xErrorBarProperties.is() )
+ return;
+
+ sal_Int32 nNewStyle = css::chart::ErrorBarStyle::NONE;
+ switch(aNewValue)
+ {
+ case css::chart::ChartErrorCategory_NONE:
+ nNewStyle = css::chart::ErrorBarStyle::NONE;
+ break;
+ case css::chart::ChartErrorCategory_VARIANCE:
+ nNewStyle = css::chart::ErrorBarStyle::VARIANCE;
+ break;
+ case css::chart::ChartErrorCategory_STANDARD_DEVIATION:
+ nNewStyle = css::chart::ErrorBarStyle::STANDARD_DEVIATION;
+ break;
+ case css::chart::ChartErrorCategory_CONSTANT_VALUE:
+ nNewStyle = css::chart::ErrorBarStyle::ABSOLUTE;
+ break;
+ case css::chart::ChartErrorCategory_PERCENT:
+ nNewStyle = css::chart::ErrorBarStyle::RELATIVE;
+ break;
+ case css::chart::ChartErrorCategory_ERROR_MARGIN:
+ nNewStyle = css::chart::ErrorBarStyle::ERROR_MARGIN;
+ break;
+ default:
+ break;
+ }
+ xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::Any(nNewStyle) );
+}
+
+namespace {
+
+//PROP_CHART_STATISTIC_PERCENT_ERROR
+class WrappedPercentageErrorProperty : public WrappedStatisticProperty< double >
+{
+public:
+ virtual double getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const override;
+
+ explicit WrappedPercentageErrorProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType );
+
+private:
+ mutable Any m_aOuterValue;
+};
+
+}
+
+WrappedPercentageErrorProperty::WrappedPercentageErrorProperty(
+ std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedStatisticProperty< double >( "PercentageError"
+ , uno::Any( 0.0 ), std::move(spChart2ModelContact), ePropertyType )
+{
+}
+
+double WrappedPercentageErrorProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ double aRet = 0.0;
+ m_aDefaultValue >>= aRet;
+ uno::Reference< beans::XPropertySet > xErrorBarProperties;
+ if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
+ {
+ if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::RELATIVE )
+ xErrorBarProperties->getPropertyValue( "PositiveError" ) >>= aRet;
+ else
+ m_aOuterValue >>= aRet;
+ }
+ return aRet;
+}
+void WrappedPercentageErrorProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const
+{
+ uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
+ if( xErrorBarProperties.is() )
+ {
+ m_aOuterValue <<= aNewValue;
+ if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::RELATIVE )
+ {
+ xErrorBarProperties->setPropertyValue( "PositiveError" , m_aOuterValue );
+ xErrorBarProperties->setPropertyValue( "NegativeError" , m_aOuterValue );
+ }
+ }
+}
+
+namespace {
+
+//PROP_CHART_STATISTIC_ERROR_MARGIN
+class WrappedErrorMarginProperty : public WrappedStatisticProperty< double >
+{
+public:
+ virtual double getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const override;
+
+ explicit WrappedErrorMarginProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType );
+
+private:
+ mutable Any m_aOuterValue;
+};
+
+}
+
+WrappedErrorMarginProperty::WrappedErrorMarginProperty(
+ std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedStatisticProperty< double >( "ErrorMargin"
+ , uno::Any( 0.0 ), std::move(spChart2ModelContact), ePropertyType )
+{
+}
+
+double WrappedErrorMarginProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ double aRet = 0.0;
+ m_aDefaultValue >>= aRet;
+ uno::Reference< beans::XPropertySet > xErrorBarProperties;
+ if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
+ {
+ if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::ERROR_MARGIN )
+ xErrorBarProperties->getPropertyValue( "PositiveError" ) >>= aRet;
+ else
+ m_aOuterValue >>= aRet;
+ }
+ return aRet;
+}
+void WrappedErrorMarginProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const
+{
+ uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
+ if( xErrorBarProperties.is() )
+ {
+ m_aOuterValue <<= aNewValue;
+ if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::ERROR_MARGIN )
+ {
+ xErrorBarProperties->setPropertyValue( "PositiveError" , m_aOuterValue );
+ xErrorBarProperties->setPropertyValue( "NegativeError" , m_aOuterValue );
+ }
+ }
+}
+
+namespace {
+
+//PROP_CHART_STATISTIC_ERROR_INDICATOR
+class WrappedErrorIndicatorProperty : public WrappedStatisticProperty< css::chart::ChartErrorIndicatorType >
+{
+public:
+ virtual css::chart::ChartErrorIndicatorType getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const css::chart::ChartErrorIndicatorType& aNewValue ) const override;
+
+ explicit WrappedErrorIndicatorProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType );
+};
+
+}
+
+WrappedErrorIndicatorProperty::WrappedErrorIndicatorProperty(
+ std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedStatisticProperty< css::chart::ChartErrorIndicatorType >( "ErrorIndicator"
+ , uno::Any( css::chart::ChartErrorIndicatorType_NONE ), std::move(spChart2ModelContact), ePropertyType )
+{
+}
+
+css::chart::ChartErrorIndicatorType WrappedErrorIndicatorProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ css::chart::ChartErrorIndicatorType aRet = css::chart::ChartErrorIndicatorType_NONE;
+ m_aDefaultValue >>= aRet;
+ uno::Reference< beans::XPropertySet > xErrorBarProperties;
+ if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
+ {
+ bool bPositive = false;
+ bool bNegative = false;
+ xErrorBarProperties->getPropertyValue( "ShowPositiveError" ) >>= bPositive;
+ xErrorBarProperties->getPropertyValue( "ShowNegativeError" ) >>= bNegative;
+
+ if( bPositive && bNegative )
+ aRet = css::chart::ChartErrorIndicatorType_TOP_AND_BOTTOM;
+ else if( bPositive && !bNegative )
+ aRet = css::chart::ChartErrorIndicatorType_UPPER;
+ else if( !bPositive && bNegative )
+ aRet = css::chart::ChartErrorIndicatorType_LOWER;
+ }
+ return aRet;
+}
+void WrappedErrorIndicatorProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const css::chart::ChartErrorIndicatorType& aNewValue ) const
+{
+ uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
+ if( !xErrorBarProperties.is() )
+ return;
+
+ bool bPositive = false;
+ bool bNegative = false;
+ switch( aNewValue )
+ {
+ case css::chart::ChartErrorIndicatorType_TOP_AND_BOTTOM:
+ bPositive = true;
+ bNegative = true;
+ break;
+ case css::chart::ChartErrorIndicatorType_UPPER:
+ bPositive = true;
+ break;
+ case css::chart::ChartErrorIndicatorType_LOWER:
+ bNegative = true;
+ break;
+ default:
+ break;
+ }
+
+ xErrorBarProperties->setPropertyValue( "ShowPositiveError" , uno::Any(bPositive) );
+ xErrorBarProperties->setPropertyValue( "ShowNegativeError" , uno::Any(bNegative) );
+}
+
+namespace {
+
+//PROP_CHART_STATISTIC_ERROR_BAR_STYLE
+// this is the new constant group that replaces the deprecated enum ChartErrorCategory
+class WrappedErrorBarStyleProperty : public WrappedStatisticProperty< sal_Int32 >
+{
+public:
+ virtual sal_Int32 getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& nNewValue ) const override;
+
+ explicit WrappedErrorBarStyleProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact1,
+ tSeriesOrDiagramPropertyType ePropertyType );
+};
+
+}
+
+WrappedErrorBarStyleProperty::WrappedErrorBarStyleProperty(
+ std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedStatisticProperty< sal_Int32 >( "ErrorBarStyle"
+ , uno::Any( css::chart::ErrorBarStyle::NONE ), std::move(spChart2ModelContact), ePropertyType )
+{
+}
+
+sal_Int32 WrappedErrorBarStyleProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ sal_Int32 nRet = css::chart::ErrorBarStyle::NONE;
+ m_aDefaultValue >>= nRet;
+ uno::Reference< beans::XPropertySet > xErrorBarProperties;
+ if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
+ {
+ xErrorBarProperties->getPropertyValue( "ErrorBarStyle" ) >>= nRet;
+ }
+ return nRet;
+}
+void WrappedErrorBarStyleProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& nNewValue ) const
+{
+ if( !xSeriesPropertySet.is() )
+ return;
+
+ uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
+ if( xErrorBarProperties.is() )
+ {
+ xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::Any( nNewValue ));
+ }
+}
+
+namespace {
+
+//PROP_CHART_STATISTIC_ERROR_RANGE_POSITIVE
+class WrappedErrorBarRangePositiveProperty : public WrappedStatisticProperty< OUString >
+{
+public:
+ virtual OUString getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewValue ) const override;
+
+ explicit WrappedErrorBarRangePositiveProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType );
+};
+
+}
+
+WrappedErrorBarRangePositiveProperty::WrappedErrorBarRangePositiveProperty(
+ std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedStatisticProperty< OUString >( "ErrorBarRangePositive"
+ , uno::Any( OUString() ), std::move(spChart2ModelContact), ePropertyType )
+{
+}
+
+OUString WrappedErrorBarRangePositiveProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ OUString aRet;
+ m_aDefaultValue >>= aRet;
+ uno::Reference< chart2::data::XDataSource > xErrorBarDataSource;
+ if( xSeriesPropertySet.is() &&
+ ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarDataSource ) &&
+ xErrorBarDataSource.is())
+ {
+ uno::Reference< chart2::data::XDataSequence > xSeq(
+ StatisticsHelper::getErrorDataSequenceFromDataSource(
+ xErrorBarDataSource, true /* positive */ ));
+ if( xSeq.is())
+ aRet = xSeq->getSourceRangeRepresentation();
+ else
+ m_aOuterValue >>= aRet;
+ }
+ lcl_ConvertRangeToXML( aRet, m_spChart2ModelContact );
+ return aRet;
+}
+
+void WrappedErrorBarRangePositiveProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewValue ) const
+{
+ uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
+ if( !xErrorBarProperties.is() )
+ return;
+
+ uno::Reference< chart2::data::XDataProvider > xDataProvider(
+ lcl_getDataProviderFromContact( m_spChart2ModelContact ));
+ uno::Reference< chart2::data::XDataSource > xDataSource( xErrorBarProperties, uno::UNO_QUERY );
+ if( xDataSource.is() && xDataProvider.is())
+ {
+ OUString aTmp( aNewValue );
+ OUString aXMLRange( aNewValue );
+ lcl_ConvertRangeFromXML( aTmp, m_spChart2ModelContact );
+ StatisticsHelper::setErrorDataSequence(
+ xDataSource, xDataProvider, aTmp, true /* positive */, true /* y-error */, &aXMLRange );
+ m_aOuterValue <<= aTmp;
+ }
+}
+
+namespace {
+
+//PROP_CHART_STATISTIC_ERROR_RANGE_NEGATIVE
+class WrappedErrorBarRangeNegativeProperty : public WrappedStatisticProperty< OUString >
+{
+public:
+ virtual OUString getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewValue ) const override;
+
+ explicit WrappedErrorBarRangeNegativeProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType );
+};
+
+}
+
+WrappedErrorBarRangeNegativeProperty::WrappedErrorBarRangeNegativeProperty(
+ std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedStatisticProperty< OUString >( "ErrorBarRangeNegative"
+ , uno::Any( OUString() ), std::move(spChart2ModelContact), ePropertyType )
+{
+}
+
+OUString WrappedErrorBarRangeNegativeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ OUString aRet;
+ m_aDefaultValue >>= aRet;
+ uno::Reference< chart2::data::XDataSource > xErrorBarDataSource;
+ if( xSeriesPropertySet.is() &&
+ ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarDataSource ) &&
+ xErrorBarDataSource.is())
+ {
+ uno::Reference< chart2::data::XDataSequence > xSeq(
+ StatisticsHelper::getErrorDataSequenceFromDataSource(
+ xErrorBarDataSource, false /* positive */ ));
+ if( xSeq.is())
+ aRet = xSeq->getSourceRangeRepresentation();
+ else
+ m_aOuterValue >>= aRet;
+ }
+ lcl_ConvertRangeToXML( aRet, m_spChart2ModelContact );
+ return aRet;
+}
+
+void WrappedErrorBarRangeNegativeProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewValue ) const
+{
+ uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
+ if( !xErrorBarProperties.is() )
+ return;
+
+ uno::Reference< chart2::data::XDataProvider > xDataProvider(
+ lcl_getDataProviderFromContact( m_spChart2ModelContact ));
+ uno::Reference< chart2::data::XDataSource > xDataSource( xErrorBarProperties, uno::UNO_QUERY );
+ if( xDataSource.is() && xDataProvider.is())
+ {
+ OUString aTmp( aNewValue );
+ OUString aXMLRange( aNewValue );
+ lcl_ConvertRangeFromXML( aTmp, m_spChart2ModelContact );
+ StatisticsHelper::setErrorDataSequence(
+ xDataSource, xDataProvider, aTmp, false /* positive */, true /* y-error */, &aXMLRange );
+ m_aOuterValue <<= aTmp;
+ }
+}
+
+namespace {
+
+//PROP_CHART_STATISTIC_REGRESSION_CURVES
+class WrappedRegressionCurvesProperty : public WrappedStatisticProperty< css::chart::ChartRegressionCurveType >
+{
+public:
+ virtual css::chart::ChartRegressionCurveType getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const css::chart::ChartRegressionCurveType & aNewValue ) const override;
+
+ explicit WrappedRegressionCurvesProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType );
+};
+
+}
+
+WrappedRegressionCurvesProperty::WrappedRegressionCurvesProperty(
+ std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedStatisticProperty< css::chart::ChartRegressionCurveType >( "RegressionCurves"
+ , lcl_getRegressionDefault(), std::move(spChart2ModelContact), ePropertyType )
+{
+}
+
+css::chart::ChartRegressionCurveType WrappedRegressionCurvesProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ css::chart::ChartRegressionCurveType aRet;
+ m_aDefaultValue >>= aRet;
+ uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY );
+ if( xRegCnt.is() )
+ {
+ aRet = lcl_getRegressionCurveType(
+ RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( xRegCnt ) );
+ }
+ return aRet;
+}
+void WrappedRegressionCurvesProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const css::chart::ChartRegressionCurveType& aNewValue ) const
+{
+ uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( xSeriesPropertySet, uno::UNO_QUERY );
+ uno::Reference< chart2::XRegressionCurve > xRegressionCurve( xSeriesPropertySet, uno::UNO_QUERY );
+
+ if( xRegressionCurveContainer.is() && xRegressionCurve.is() )
+ {
+ SvxChartRegress eNewRegressionType = lcl_getRegressionType( aNewValue );
+
+ RegressionCurveHelper::changeRegressionCurveType(
+ eNewRegressionType,
+ xRegressionCurveContainer,
+ xRegressionCurve);
+ }
+}
+
+namespace {
+
+//PROP_CHART_STATISTIC_REGRESSION_PROPERTIES
+//PROP_CHART_STATISTIC_ERROR_PROPERTIES
+//PROP_CHART_STATISTIC_MEAN_VALUE_PROPERTIES
+class WrappedStatisticPropertySetProperty : public WrappedStatisticProperty< Reference< beans::XPropertySet > >
+{
+public:
+ virtual Reference< beans::XPropertySet > getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ // properties are read-only, so this method should never be called
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const Reference< beans::XPropertySet > & xNewValue ) const override;
+
+ enum PropertySetType
+ {
+ PROPERTY_SET_TYPE_REGRESSION,
+ PROPERTY_SET_TYPE_ERROR_BAR,
+ PROPERTY_SET_TYPE_MEAN_VALUE
+ };
+
+ explicit WrappedStatisticPropertySetProperty(
+ PropertySetType ePropertySetType, std::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType );
+
+private:
+ PropertySetType m_eType;
+};
+
+}
+
+WrappedStatisticPropertySetProperty::WrappedStatisticPropertySetProperty(
+ PropertySetType ePropertySetType
+ , std::shared_ptr< Chart2ModelContact > spChart2ModelContact
+ , tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedStatisticProperty< Reference< beans::XPropertySet > >(
+ (ePropertySetType == PROPERTY_SET_TYPE_REGRESSION)
+ ? OUString("DataRegressionProperties")
+ : (ePropertySetType == PROPERTY_SET_TYPE_ERROR_BAR)
+ ? OUString("DataErrorProperties")
+ : OUString("DataMeanValueProperties")
+ , uno::Any(), std::move(spChart2ModelContact), ePropertyType )
+ , m_eType( ePropertySetType )
+{
+}
+
+Reference< beans::XPropertySet > WrappedStatisticPropertySetProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ Reference< beans::XPropertySet > xResult;
+ uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY );
+
+ switch( m_eType )
+ {
+ case PROPERTY_SET_TYPE_REGRESSION:
+ if( xRegCnt.is() )
+ xResult.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt ), uno::UNO_QUERY );
+ break;
+ case PROPERTY_SET_TYPE_ERROR_BAR:
+ if( xSeriesPropertySet.is())
+ xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xResult;
+ break;
+ case PROPERTY_SET_TYPE_MEAN_VALUE:
+ if( xRegCnt.is() )
+ xResult.set( RegressionCurveHelper::getMeanValueLine( xRegCnt ), uno::UNO_QUERY );
+ break;
+ }
+
+ return xResult;
+}
+
+void WrappedStatisticPropertySetProperty::setValueToSeries(
+ const Reference< beans::XPropertySet >& /* xSeriesPropertySet */
+ , const Reference< beans::XPropertySet >& /* xNewValue */ ) const
+{
+}
+
+namespace
+{
+enum
+{
+ //statistic properties
+ PROP_CHART_STATISTIC_CONST_ERROR_LOW = FAST_PROPERTY_ID_START_CHART_STATISTIC_PROP,
+ PROP_CHART_STATISTIC_CONST_ERROR_HIGH,
+ PROP_CHART_STATISTIC_MEAN_VALUE,
+ PROP_CHART_STATISTIC_ERROR_CATEGORY,
+ PROP_CHART_STATISTIC_ERROR_BAR_STYLE,
+ PROP_CHART_STATISTIC_PERCENT_ERROR,
+ PROP_CHART_STATISTIC_ERROR_MARGIN,
+ PROP_CHART_STATISTIC_ERROR_INDICATOR,
+ PROP_CHART_STATISTIC_ERROR_RANGE_POSITIVE,
+ PROP_CHART_STATISTIC_ERROR_RANGE_NEGATIVE,
+ PROP_CHART_STATISTIC_REGRESSION_CURVES,
+ PROP_CHART_STATISTIC_REGRESSION_PROPERTIES,
+ PROP_CHART_STATISTIC_ERROR_PROPERTIES,
+ PROP_CHART_STATISTIC_MEAN_VALUE_PROPERTIES
+};
+
+/** @parameter bDataSeriesProperty if true, this property is for a single data
+ series, if false, it is for the whole diagram, i.e. for all
+ series
+ */
+void lcl_addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact
+ , tSeriesOrDiagramPropertyType ePropertyType )
+{
+ rList.emplace_back( new WrappedConstantErrorLowProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedConstantErrorHighProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedMeanValueProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedErrorCategoryProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedErrorBarStyleProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedPercentageErrorProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedErrorMarginProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedErrorIndicatorProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedErrorBarRangePositiveProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedErrorBarRangeNegativeProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedRegressionCurvesProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedStatisticPropertySetProperty(
+ WrappedStatisticPropertySetProperty::PROPERTY_SET_TYPE_REGRESSION, spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedStatisticPropertySetProperty(
+ WrappedStatisticPropertySetProperty::PROPERTY_SET_TYPE_ERROR_BAR, spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedStatisticPropertySetProperty(
+ WrappedStatisticPropertySetProperty::PROPERTY_SET_TYPE_MEAN_VALUE, spChart2ModelContact, ePropertyType ) );
+}
+
+}//anonymous namespace
+
+void WrappedStatisticProperties::addProperties( std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "ConstantErrorLow",
+ PROP_CHART_STATISTIC_CONST_ERROR_LOW,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "ConstantErrorHigh",
+ PROP_CHART_STATISTIC_CONST_ERROR_HIGH,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "MeanValue",
+ PROP_CHART_STATISTIC_MEAN_VALUE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "ErrorCategory",
+ PROP_CHART_STATISTIC_ERROR_CATEGORY,
+ cppu::UnoType<css::chart::ChartErrorCategory>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "ErrorBarStyle",
+ PROP_CHART_STATISTIC_ERROR_BAR_STYLE,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "PercentageError",
+ PROP_CHART_STATISTIC_PERCENT_ERROR,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "ErrorMargin",
+ PROP_CHART_STATISTIC_ERROR_MARGIN,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "ErrorIndicator",
+ PROP_CHART_STATISTIC_ERROR_INDICATOR,
+ cppu::UnoType<css::chart::ChartErrorIndicatorType>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "ErrorBarRangePositive",
+ PROP_CHART_STATISTIC_ERROR_RANGE_POSITIVE,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "ErrorBarRangeNegative",
+ PROP_CHART_STATISTIC_ERROR_RANGE_NEGATIVE,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "RegressionCurves",
+ PROP_CHART_STATISTIC_REGRESSION_CURVES,
+ cppu::UnoType<css::chart::ChartRegressionCurveType>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "DataRegressionProperties",
+ PROP_CHART_STATISTIC_REGRESSION_PROPERTIES,
+ cppu::UnoType<beans::XPropertySet>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( "DataErrorProperties",
+ PROP_CHART_STATISTIC_ERROR_PROPERTIES,
+ cppu::UnoType<beans::XPropertySet>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( "DataMeanValueProperties",
+ PROP_CHART_STATISTIC_MEAN_VALUE_PROPERTIES,
+ cppu::UnoType<beans::XPropertySet>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::READONLY
+ | beans::PropertyAttribute::MAYBEVOID );
+}
+
+void WrappedStatisticProperties::addWrappedPropertiesForSeries( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES );
+}
+
+void WrappedStatisticProperties::addWrappedPropertiesForDiagram( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM );
+}
+
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.hxx
new file mode 100644
index 000000000..774d7a6da
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.hxx
@@ -0,0 +1,51 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSTATISTICPROPERTIES_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSTATISTICPROPERTIES_HXX
+
+#include <sal/types.h>
+#include <memory>
+#include <vector>
+
+namespace chart { class WrappedProperty; }
+namespace chart::wrapper { class Chart2ModelContact; }
+namespace com::sun::star::beans { struct Property; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class WrappedStatisticProperties
+{
+public:
+ static void addProperties( std::vector< css::beans::Property > & rOutProperties );
+ static void addWrappedPropertiesForSeries( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+ static void addWrappedPropertiesForDiagram( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+};
+
+} //namespace wrapper
+} //namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSTATISTICPROPERTIES_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
new file mode 100644
index 000000000..5e7a2808f
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx
@@ -0,0 +1,281 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedStockProperties.hxx"
+#include "Chart2ModelContact.hxx"
+#include <FastPropertyIdRanges.hxx>
+#include <DiagramHelper.hxx>
+#include <ControllerLockGuard.hxx>
+#include <WrappedProperty.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::beans::Property;
+
+namespace chart::wrapper
+{
+
+namespace {
+
+class WrappedStockProperty : public WrappedProperty
+{
+public:
+ explicit WrappedStockProperty( const OUString& rOuterName
+ , const css::uno::Any& rDefaulValue
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact );
+
+ void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+ virtual uno::Reference< chart2::XChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const = 0;
+
+protected:
+ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ mutable css::uno::Any m_aOuterValue;
+ css::uno::Any m_aDefaultValue;
+};
+
+}
+
+WrappedStockProperty::WrappedStockProperty( const OUString& rOuterName
+ , const css::uno::Any& rDefaulValue
+ , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact )
+ : WrappedProperty(rOuterName,OUString())
+ , m_spChart2ModelContact(spChart2ModelContact)
+ , m_aOuterValue()
+ , m_aDefaultValue(rDefaulValue)
+{
+}
+
+void WrappedStockProperty::setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ bool bNewValue = false;
+ if( ! (rOuterValue >>= bNewValue) )
+ throw lang::IllegalArgumentException( "stock properties require type sal_Bool", nullptr, 0 );
+
+ m_aOuterValue = rOuterValue;
+
+ Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram );
+ if( !(xChartDoc.is() && xDiagram.is() && nDimension==2) )
+ return;
+
+ Reference< lang::XMultiServiceFactory > xFactory( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+ DiagramHelper::tTemplateWithServiceName aTemplateAndService =
+ DiagramHelper::getTemplateForDiagram( xDiagram, xFactory );
+
+ uno::Reference< chart2::XChartTypeTemplate > xTemplate =
+ getNewTemplate( bNewValue, aTemplateAndService.second, xFactory );
+
+ if(!xTemplate.is())
+ return;
+
+ try
+ {
+ // locked controllers
+ ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() );
+ xTemplate->changeDiagram( xDiagram );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+css::uno::Any WrappedStockProperty::getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ return m_aDefaultValue;
+}
+
+namespace {
+
+class WrappedVolumeProperty : public WrappedStockProperty
+{
+public:
+ explicit WrappedVolumeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ uno::Reference< chart2::XChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const override;
+};
+
+}
+
+WrappedVolumeProperty::WrappedVolumeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedStockProperty( "Volume", uno::Any(false) , spChart2ModelContact )
+{
+}
+
+css::uno::Any WrappedVolumeProperty::getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( xDiagram.is() && xChartDoc.is() )
+ {
+ std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+ if( !aSeriesVector.empty() )
+ {
+ Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+ DiagramHelper::tTemplateWithServiceName aTemplateAndService =
+ DiagramHelper::getTemplateForDiagram( xDiagram, xFact );
+
+ if( aTemplateAndService.second == "com.sun.star.chart2.template.StockVolumeLowHighClose"
+ || aTemplateAndService.second == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
+ m_aOuterValue <<= true;
+ else if( !aTemplateAndService.second.isEmpty() || !m_aOuterValue.hasValue() )
+ m_aOuterValue <<= false;
+ }
+ else if(!m_aOuterValue.hasValue())
+ m_aOuterValue <<= false;
+ }
+ return m_aOuterValue;
+}
+
+uno::Reference< chart2::XChartTypeTemplate > WrappedVolumeProperty::getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const
+{
+ uno::Reference< chart2::XChartTypeTemplate > xTemplate;
+
+ if(!xFactory.is())
+ return xTemplate;
+
+ if( bNewValue ) //add volume
+ {
+ if( rCurrentTemplate == "com.sun.star.chart2.template.StockLowHighClose" )
+ xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockVolumeLowHighClose" ), uno::UNO_QUERY );
+ else if( rCurrentTemplate == "com.sun.star.chart2.template.StockOpenLowHighClose" )
+ xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ), uno::UNO_QUERY );
+ }
+ else //remove volume
+ {
+ if( rCurrentTemplate == "com.sun.star.chart2.template.StockVolumeLowHighClose" )
+ xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockLowHighClose" ), uno::UNO_QUERY );
+ else if( rCurrentTemplate == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
+ xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockOpenLowHighClose" ), uno::UNO_QUERY );
+ }
+ return xTemplate;
+}
+
+namespace {
+
+class WrappedUpDownProperty : public WrappedStockProperty
+{
+public:
+ explicit WrappedUpDownProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact);
+
+ css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override;
+
+ uno::Reference< chart2::XChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const override;
+};
+
+}
+
+WrappedUpDownProperty::WrappedUpDownProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact)
+ : WrappedStockProperty( "UpDown", uno::Any(false) , spChart2ModelContact )
+{
+}
+
+css::uno::Any WrappedUpDownProperty::getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& /*xInnerPropertySet*/ ) const
+{
+ Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ if( xDiagram.is() && xChartDoc.is() )
+ {
+ std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
+ if( !aSeriesVector.empty() )
+ {
+ Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
+ DiagramHelper::tTemplateWithServiceName aTemplateAndService =
+ DiagramHelper::getTemplateForDiagram( xDiagram, xFact );
+
+ if( aTemplateAndService.second == "com.sun.star.chart2.template.StockOpenLowHighClose"
+ || aTemplateAndService.second == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
+ m_aOuterValue <<= true;
+ else if( !aTemplateAndService.second.isEmpty() || !m_aOuterValue.hasValue() )
+ m_aOuterValue <<= false;
+ }
+ else if(!m_aOuterValue.hasValue())
+ m_aOuterValue <<= false;
+ }
+ return m_aOuterValue;
+}
+uno::Reference< chart2::XChartTypeTemplate > WrappedUpDownProperty::getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const
+{
+ uno::Reference< chart2::XChartTypeTemplate > xTemplate;
+ if( bNewValue ) //add open series
+ {
+ if( rCurrentTemplate == "com.sun.star.chart2.template.StockLowHighClose" )
+ xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockOpenLowHighClose" ), uno::UNO_QUERY );
+ else if( rCurrentTemplate == "com.sun.star.chart2.template.StockVolumeLowHighClose" )
+ xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ), uno::UNO_QUERY );
+ }
+ else //remove open series
+ {
+ if( rCurrentTemplate == "com.sun.star.chart2.template.StockOpenLowHighClose" )
+ xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockLowHighClose" ), uno::UNO_QUERY );
+ else if( rCurrentTemplate == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" )
+ xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockVolumeLowHighClose" ), uno::UNO_QUERY );
+ }
+ return xTemplate;
+}
+
+namespace
+{
+enum
+{
+ //spline properties
+ PROP_CHART_STOCK_VOLUME = FAST_PROPERTY_ID_START_CHART_STOCK_PROP
+ , PROP_CHART_STOCK_UPDOWN
+};
+
+}//anonymous namespace
+
+void WrappedStockProperties::addProperties( std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "Volume",
+ PROP_CHART_STOCK_VOLUME,
+ cppu::UnoType<sal_Bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( "UpDown",
+ PROP_CHART_STOCK_UPDOWN,
+ cppu::UnoType<sal_Bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT
+ | beans::PropertyAttribute::MAYBEVOID );
+}
+
+void WrappedStockProperties::addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ rList.emplace_back( new WrappedVolumeProperty( spChart2ModelContact ) );
+ rList.emplace_back( new WrappedUpDownProperty( spChart2ModelContact ) );
+}
+
+} //namespace chart::wrapper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.hxx
new file mode 100644
index 000000000..1cc9d579b
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.hxx
@@ -0,0 +1,49 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSTOCKPROPERTIES_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSTOCKPROPERTIES_HXX
+
+#include <sal/types.h>
+#include <memory>
+#include <vector>
+
+namespace chart { class WrappedProperty; }
+namespace chart::wrapper { class Chart2ModelContact; }
+namespace com::sun::star::beans { struct Property; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class WrappedStockProperties
+{
+public:
+ static void addProperties( std::vector< css::beans::Property > & rOutProperties );
+ static void addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+};
+
+} //namespace wrapper
+} //namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSTOCKPROPERTIES_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx
new file mode 100644
index 000000000..4dfabee48
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx
@@ -0,0 +1,530 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedSymbolProperties.hxx"
+#include "WrappedSeriesOrDiagramProperty.hxx"
+#include <FastPropertyIdRanges.hxx>
+#include <ChartTypeHelper.hxx>
+#include <com/sun/star/chart2/Symbol.hpp>
+#include <com/sun/star/chart2/SymbolStyle.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/chart/ChartSymbolType.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <vcl/GraphicLoader.hxx>
+
+#include <vcl/graph.hxx>
+#include <vcl/outdev.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::beans::Property;
+
+namespace chart::wrapper
+{
+
+namespace
+{
+
+class WrappedSymbolTypeProperty : public WrappedSeriesOrDiagramProperty< sal_Int32 >
+{
+public:
+ virtual sal_Int32 getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& aNewValue ) const override;
+
+ virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override;
+ virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override;
+
+ explicit WrappedSymbolTypeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType);
+};
+
+class WrappedSymbolBitmapURLProperty : public WrappedSeriesOrDiagramProperty<OUString>
+{
+public:
+ virtual OUString getValueFromSeries(const Reference<beans::XPropertySet>& xSeriesPropertySet) const override;
+ virtual void setValueToSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet, OUString const & xNewGraphicURL) const override;
+
+ explicit WrappedSymbolBitmapURLProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType);
+};
+
+class WrappedSymbolBitmapProperty : public WrappedSeriesOrDiagramProperty<uno::Reference<graphic::XGraphic>>
+{
+public:
+ virtual uno::Reference<graphic::XGraphic> getValueFromSeries(const Reference<beans::XPropertySet>& xSeriesPropertySet) const override;
+ virtual void setValueToSeries(const Reference<beans::XPropertySet> & xSeriesPropertySet, uno::Reference<graphic::XGraphic> const & xNewGraphic) const override;
+
+ explicit WrappedSymbolBitmapProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType);
+};
+
+class WrappedSymbolSizeProperty : public WrappedSeriesOrDiagramProperty< awt::Size >
+{
+public:
+ virtual awt::Size getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const awt::Size& aNewSize ) const override;
+ virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override;
+
+ explicit WrappedSymbolSizeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType);
+};
+
+class WrappedSymbolAndLinesProperty : public WrappedSeriesOrDiagramProperty< bool >
+{
+public:
+ virtual bool getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const override;
+ virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const bool& bDrawLines ) const override;
+ virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override;
+
+ explicit WrappedSymbolAndLinesProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType);
+};
+
+enum
+{
+ //symbol properties
+ PROP_CHART_SYMBOL_TYPE = FAST_PROPERTY_ID_START_CHART_SYMBOL_PROP,
+ PROP_CHART_SYMBOL_BITMAP_URL,
+ PROP_CHART_SYMBOL_BITMAP,
+ PROP_CHART_SYMBOL_SIZE,
+ PROP_CHART_SYMBOL_AND_LINES
+};
+
+sal_Int32 lcl_getSymbolType( const css::chart2::Symbol& rSymbol )
+{
+ sal_Int32 nSymbol = css::chart::ChartSymbolType::NONE;
+ switch( rSymbol.Style )
+ {
+ case chart2::SymbolStyle_NONE:
+ break;
+ case chart2::SymbolStyle_AUTO:
+ nSymbol = css::chart::ChartSymbolType::AUTO;
+ break;
+ case chart2::SymbolStyle_STANDARD:
+ nSymbol = rSymbol.StandardSymbol%15;
+ break;
+ case chart2::SymbolStyle_POLYGON://new feature
+ nSymbol = css::chart::ChartSymbolType::AUTO;
+ break;
+ case chart2::SymbolStyle_GRAPHIC:
+ nSymbol = css::chart::ChartSymbolType::BITMAPURL;
+ break;
+ default:
+ nSymbol = css::chart::ChartSymbolType::AUTO;
+ break;
+ }
+ return nSymbol;
+}
+void lcl_setSymbolTypeToSymbol( sal_Int32 nSymbolType, chart2::Symbol& rSymbol )
+{
+ switch( nSymbolType )
+ {
+ case css::chart::ChartSymbolType::NONE:
+ rSymbol.Style = chart2::SymbolStyle_NONE;
+ break;
+ case css::chart::ChartSymbolType::AUTO:
+ rSymbol.Style = chart2::SymbolStyle_AUTO;
+ break;
+ case css::chart::ChartSymbolType::BITMAPURL:
+ rSymbol.Style = chart2::SymbolStyle_GRAPHIC;
+ break;
+ default:
+ rSymbol.Style = chart2::SymbolStyle_STANDARD;
+ rSymbol.StandardSymbol = nSymbolType;
+ break;
+ }
+}
+
+void lcl_addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact
+ , tSeriesOrDiagramPropertyType ePropertyType )
+{
+ rList.emplace_back( new WrappedSymbolTypeProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedSymbolBitmapURLProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedSymbolBitmapProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedSymbolSizeProperty( spChart2ModelContact, ePropertyType ) );
+ rList.emplace_back( new WrappedSymbolAndLinesProperty( spChart2ModelContact, ePropertyType ) );
+}
+
+}//anonymous namespace
+
+void WrappedSymbolProperties::addProperties( std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "SymbolType",
+ PROP_CHART_SYMBOL_TYPE,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "SymbolBitmapURL",
+ PROP_CHART_SYMBOL_BITMAP_URL,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "SymbolBitmap",
+ PROP_CHART_SYMBOL_BITMAP,
+ cppu::UnoType<graphic::XGraphic>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "SymbolSize",
+ PROP_CHART_SYMBOL_SIZE,
+ cppu::UnoType<awt::Size>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "Lines",
+ PROP_CHART_SYMBOL_AND_LINES,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+void WrappedSymbolProperties::addWrappedPropertiesForSeries( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES );
+}
+
+void WrappedSymbolProperties::addWrappedPropertiesForDiagram( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact )
+{
+ lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM );
+}
+
+WrappedSymbolTypeProperty::WrappedSymbolTypeProperty(
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedSeriesOrDiagramProperty< sal_Int32 >( "SymbolType"
+ , uno::Any( css::chart::ChartSymbolType::NONE )
+ , spChart2ModelContact
+ , ePropertyType )
+{
+}
+
+sal_Int32 WrappedSymbolTypeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ sal_Int32 aRet = 0;
+ m_aDefaultValue >>= aRet;
+ chart2::Symbol aSymbol;
+ if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ) )
+ aRet = lcl_getSymbolType( aSymbol );
+ return aRet;
+}
+
+void WrappedSymbolTypeProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& nSymbolType ) const
+{
+ if(!xSeriesPropertySet.is())
+ return;
+
+ chart2::Symbol aSymbol;
+ xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol;
+
+ lcl_setSymbolTypeToSymbol( nSymbolType, aSymbol );
+ xSeriesPropertySet->setPropertyValue( "Symbol", uno::Any( aSymbol ) );
+}
+
+Any WrappedSymbolTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const
+{
+ //the old chart (< OOo 2.3) needs symbol-type="automatic" at the plot-area if any of the series should be able to have symbols
+ if( m_ePropertyType == DIAGRAM )
+ {
+ bool bHasAmbiguousValue = false;
+ sal_Int32 aValue = 0;
+ if( detectInnerValue( aValue, bHasAmbiguousValue ) )
+ {
+ if(bHasAmbiguousValue)
+ {
+ m_aOuterValue <<= css::chart::ChartSymbolType::AUTO;
+ }
+ else
+ {
+ if( aValue == css::chart::ChartSymbolType::NONE )
+ m_aOuterValue <<= css::chart::ChartSymbolType::NONE;
+ else
+ m_aOuterValue <<= css::chart::ChartSymbolType::AUTO;
+ }
+ }
+ return m_aOuterValue;
+ }
+ else
+ {
+ css::uno::Any aRet( m_aDefaultValue );
+ aRet <<= getValueFromSeries( xInnerPropertySet );
+ return aRet;
+ }
+}
+
+beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
+{
+ //the special situation for this property here is that the diagram default can be
+ //different from the normal default and different from all singles series values
+ //so we need to return PropertyState_DIRECT_VALUE for more cases
+
+ if( m_ePropertyType == DATA_SERIES && //single series or point
+ m_spChart2ModelContact)
+ {
+ Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() );
+ Reference< chart2::XDataSeries > xSeries( xInnerPropertyState, uno::UNO_QUERY );
+ Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) );
+ if( ChartTypeHelper::isSupportingSymbolProperties( xChartType, 2 ) )
+ return beans::PropertyState_DIRECT_VALUE;
+ }
+ return WrappedProperty::getPropertyState( xInnerPropertyState );
+}
+
+WrappedSymbolBitmapURLProperty::WrappedSymbolBitmapURLProperty(
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedSeriesOrDiagramProperty<OUString>("SymbolBitmapURL",
+ uno::Any(OUString()), spChart2ModelContact, ePropertyType)
+{
+}
+
+OUString WrappedSymbolBitmapURLProperty::getValueFromSeries(const Reference< beans::XPropertySet >& /*xSeriesPropertySet*/) const
+{
+ return OUString();
+}
+
+void WrappedSymbolBitmapURLProperty::setValueToSeries(
+ const Reference< beans::XPropertySet >& xSeriesPropertySet,
+ OUString const & xNewGraphicURL) const
+{
+ if (!xSeriesPropertySet.is())
+ return;
+
+ chart2::Symbol aSymbol;
+ if (xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol)
+ {
+ if (!xNewGraphicURL.isEmpty())
+ {
+ Graphic aGraphic = vcl::graphic::loadFromURL(xNewGraphicURL);
+ aSymbol.Graphic.set(aGraphic.GetXGraphic());
+ xSeriesPropertySet->setPropertyValue("Symbol", uno::Any(aSymbol));
+ }
+ }
+}
+
+WrappedSymbolBitmapProperty::WrappedSymbolBitmapProperty(
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedSeriesOrDiagramProperty<uno::Reference<graphic::XGraphic>>("SymbolBitmap",
+ uno::Any(uno::Reference<graphic::XGraphic>()), spChart2ModelContact, ePropertyType)
+{
+}
+
+uno::Reference<graphic::XGraphic> WrappedSymbolBitmapProperty::getValueFromSeries(const Reference< beans::XPropertySet >& xSeriesPropertySet) const
+{
+ uno::Reference<graphic::XGraphic> xGraphic;
+ m_aDefaultValue >>= xGraphic;
+
+ chart2::Symbol aSymbol;
+ if (xSeriesPropertySet.is() && (xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol)
+ && aSymbol.Graphic.is())
+ {
+ xGraphic = aSymbol.Graphic;
+ }
+ return xGraphic;
+}
+
+void WrappedSymbolBitmapProperty::setValueToSeries(
+ const Reference< beans::XPropertySet >& xSeriesPropertySet,
+ uno::Reference<graphic::XGraphic> const & xNewGraphic) const
+{
+ if (!xSeriesPropertySet.is())
+ return;
+
+ chart2::Symbol aSymbol;
+ if (xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol)
+ {
+ if (xNewGraphic.is())
+ {
+ aSymbol.Graphic.set(xNewGraphic);
+ xSeriesPropertySet->setPropertyValue("Symbol", uno::Any(aSymbol));
+ }
+ }
+}
+
+namespace
+{
+
+void lcl_correctSymbolSizeForBitmaps( chart2::Symbol& rSymbol )
+{
+ if( rSymbol.Style != chart2::SymbolStyle_GRAPHIC )
+ return;
+ if( rSymbol.Size.Width != -1 )
+ return;
+ if( rSymbol.Size.Height != -1 )
+ return;
+
+ //find a good automatic size
+ try
+ {
+ const awt::Size aDefaultSize(250,250);
+ awt::Size aSize = aDefaultSize;
+ uno::Reference< beans::XPropertySet > xProp( rSymbol.Graphic, uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ bool bFoundSize = false;
+ try
+ {
+ if( xProp->getPropertyValue( "Size100thMM" ) >>= aSize )
+ {
+ if( aSize.Width == 0 && aSize.Height == 0 )
+ aSize = aDefaultSize;
+ else
+ bFoundSize = true;
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "" );
+ }
+
+ if(!bFoundSize)
+ {
+ awt::Size aAWTPixelSize(10,10);
+ if( xProp->getPropertyValue( "SizePixel" ) >>= aAWTPixelSize )
+ {
+ Size aPixelSize(aAWTPixelSize.Width,aAWTPixelSize.Height);
+ Size aNewSize = OutputDevice::LogicToLogic(aPixelSize, MapMode(MapUnit::MapPixel), MapMode(MapUnit::Map100thMM));
+ aSize = awt::Size( aNewSize.Width(), aNewSize.Height() );
+
+ if( aSize.Width == 0 && aSize.Height == 0 )
+ aSize = aDefaultSize;
+ }
+ }
+ }
+ rSymbol.Size = aSize;
+ }
+ catch( const uno::Exception& )
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "" );
+ }
+}
+
+}//end anonymous namespace
+
+WrappedSymbolSizeProperty::WrappedSymbolSizeProperty(
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedSeriesOrDiagramProperty< awt::Size >( "SymbolSize"
+ , uno::Any( awt::Size(250,250) ), spChart2ModelContact, ePropertyType )
+{
+}
+
+awt::Size WrappedSymbolSizeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
+{
+ awt::Size aRet;
+ m_aDefaultValue >>= aRet;
+ chart2::Symbol aSymbol;
+ if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ))
+ aRet = aSymbol.Size;
+ return aRet;
+}
+
+void WrappedSymbolSizeProperty::setValueToSeries(
+ const Reference< beans::XPropertySet >& xSeriesPropertySet,
+ const awt::Size& aNewSize ) const
+{
+ if(!xSeriesPropertySet.is())
+ return;
+
+ chart2::Symbol aSymbol;
+ if( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol )
+ {
+ aSymbol.Size = aNewSize;
+ lcl_correctSymbolSizeForBitmaps(aSymbol);
+ xSeriesPropertySet->setPropertyValue( "Symbol", uno::Any( aSymbol ) );
+ }
+}
+
+beans::PropertyState WrappedSymbolSizeProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const
+{
+ //only export symbol size if necessary
+ if( m_ePropertyType == DIAGRAM )
+ return beans::PropertyState_DEFAULT_VALUE;
+
+ try
+ {
+ chart2::Symbol aSymbol;
+ Reference< beans::XPropertySet > xSeriesPropertySet( xInnerPropertyState, uno::UNO_QUERY );
+ if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ))
+ {
+ if( aSymbol.Style != chart2::SymbolStyle_NONE )
+ return beans::PropertyState_DIRECT_VALUE;
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return beans::PropertyState_DEFAULT_VALUE;
+}
+
+WrappedSymbolAndLinesProperty::WrappedSymbolAndLinesProperty(
+ const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact,
+ tSeriesOrDiagramPropertyType ePropertyType )
+ : WrappedSeriesOrDiagramProperty< bool >( "Lines"
+ , uno::Any( true ), spChart2ModelContact, ePropertyType )
+{
+}
+
+bool WrappedSymbolAndLinesProperty::getValueFromSeries( const Reference< beans::XPropertySet >& /*xSeriesPropertySet*/ ) const
+{
+ //do not export this property anymore, instead use a linestyle none for no lines
+ return true;
+}
+
+void WrappedSymbolAndLinesProperty::setValueToSeries(
+ const Reference< beans::XPropertySet >& xSeriesPropertySet,
+ const bool& bDrawLines ) const
+{
+ if(!xSeriesPropertySet.is())
+ return;
+
+ drawing::LineStyle eOldLineStyle( drawing::LineStyle_SOLID );
+ xSeriesPropertySet->getPropertyValue( "LineStyle" ) >>= eOldLineStyle;
+ if( bDrawLines )
+ {
+ //#i114298# don't overwrite dashed lines with solid lines here
+ if( eOldLineStyle == drawing::LineStyle_NONE )
+ xSeriesPropertySet->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_SOLID ) );
+ }
+ else
+ {
+ if( eOldLineStyle != drawing::LineStyle_NONE )
+ xSeriesPropertySet->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE ) );
+ }
+}
+
+beans::PropertyState WrappedSymbolAndLinesProperty::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const
+{
+ //do not export this property anymore, instead use a linestyle none for no lines
+ return beans::PropertyState_DEFAULT_VALUE;
+}
+
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.hxx
new file mode 100644
index 000000000..d8eca1a93
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.hxx
@@ -0,0 +1,51 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSYMBOLPROPERTIES_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSYMBOLPROPERTIES_HXX
+
+#include <sal/types.h>
+#include <memory>
+#include <vector>
+
+namespace chart { class WrappedProperty; }
+namespace chart::wrapper { class Chart2ModelContact; }
+namespace com::sun::star::beans { struct Property; }
+
+namespace chart
+{
+namespace wrapper
+{
+
+class WrappedSymbolProperties
+{
+public:
+ static void addProperties( std::vector< css::beans::Property > & rOutProperties );
+ static void addWrappedPropertiesForSeries( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+ static void addWrappedPropertiesForDiagram( std::vector< std::unique_ptr<WrappedProperty> >& rList
+ , const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact );
+};
+
+} //namespace wrapper
+} //namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDSYMBOLPROPERTIES_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.cxx
new file mode 100644
index 000000000..c35a75e31
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.cxx
@@ -0,0 +1,71 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "WrappedTextRotationProperty.hxx"
+
+namespace com::sun::star::beans { class XPropertyState; }
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Any;
+
+namespace chart
+{
+
+WrappedTextRotationProperty::WrappedTextRotationProperty( bool bDirectState )
+ : ::chart::WrappedProperty( "TextRotation" , "TextRotation" )
+ , m_bDirectState( bDirectState )
+{
+}
+WrappedTextRotationProperty::~WrappedTextRotationProperty()
+{
+}
+
+beans::PropertyState WrappedTextRotationProperty::getPropertyState( const uno::Reference< beans::XPropertyState >& xInnerPropertyState ) const
+{
+ if( m_bDirectState )
+ return beans::PropertyState_DIRECT_VALUE;
+ return WrappedProperty::getPropertyState( xInnerPropertyState );
+}
+
+Any WrappedTextRotationProperty::convertInnerToOuterValue( const Any& rInnerValue ) const
+{
+ Any aRet;
+ double fVal = 0;
+ if( rInnerValue >>= fVal )
+ {
+ sal_Int32 n100thDegrees = static_cast< sal_Int32 >( fVal * 100.0 );
+ aRet <<= n100thDegrees;
+ }
+ return aRet;
+}
+Any WrappedTextRotationProperty::convertOuterToInnerValue( const Any& rOuterValue ) const
+{
+ Any aRet;
+ sal_Int32 nVal = 0;
+ if( rOuterValue >>= nVal )
+ {
+ double fDoubleDegrees = static_cast< double >( nVal ) / 100.0;
+ aRet <<= fDoubleDegrees;
+ }
+ return aRet;
+}
+
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.hxx
new file mode 100644
index 000000000..58392f0a7
--- /dev/null
+++ b/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.hxx
@@ -0,0 +1,47 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDTEXTROTATIONPROPERTY_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDTEXTROTATIONPROPERTY_HXX
+
+#include <WrappedProperty.hxx>
+
+namespace chart
+{
+
+class WrappedTextRotationProperty final : public WrappedProperty
+{
+public:
+ explicit WrappedTextRotationProperty( bool bDirectState=false );
+ virtual ~WrappedTextRotationProperty() override;
+
+ virtual css::beans::PropertyState getPropertyState( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override;
+
+private:
+ virtual css::uno::Any convertInnerToOuterValue( const css::uno::Any& rInnerValue ) const override;
+ virtual css::uno::Any convertOuterToInnerValue( const css::uno::Any& rOuterValue ) const override;
+
+ bool m_bDirectState;
+};
+
+} //namespace chart
+
+// INCLUDED_CHART2_SOURCE_CONTROLLER_CHARTAPIWRAPPER_WRAPPEDTEXTROTATIONPROPERTY_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */