summaryrefslogtreecommitdiff
path: root/chart2/source/model
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/model')
-rw-r--r--chart2/source/model/filter/XMLFilter.cxx31
-rw-r--r--chart2/source/model/inc/BaseCoordinateSystem.hxx125
-rw-r--r--chart2/source/model/inc/CartesianCoordinateSystem.hxx6
-rw-r--r--chart2/source/model/inc/ChartTypeManager.hxx70
-rw-r--r--chart2/source/model/inc/DataSeries.hxx168
-rw-r--r--chart2/source/model/inc/Diagram.hxx182
-rw-r--r--chart2/source/model/inc/PolarCoordinateSystem.hxx6
-rw-r--r--chart2/source/model/inc/StockBar.hxx12
-rw-r--r--chart2/source/model/inc/XMLFilter.hxx7
-rw-r--r--chart2/source/model/main/Axis.cxx262
-rw-r--r--chart2/source/model/main/Axis.hxx134
-rw-r--r--chart2/source/model/main/BaseCoordinateSystem.cxx204
-rw-r--r--chart2/source/model/main/CartesianCoordinateSystem.cxx2
-rw-r--r--chart2/source/model/main/ChartModel.cxx230
-rw-r--r--chart2/source/model/main/ChartModel_Persistence.cxx116
-rw-r--r--chart2/source/model/main/DataPoint.cxx90
-rw-r--r--chart2/source/model/main/DataPoint.hxx9
-rw-r--r--chart2/source/model/main/DataPointProperties.cxx48
-rw-r--r--chart2/source/model/main/DataPointProperties.hxx3
-rw-r--r--chart2/source/model/main/DataSeries.cxx351
-rw-r--r--chart2/source/model/main/DataSeriesProperties.cxx4
-rw-r--r--chart2/source/model/main/DataSeriesProperties.hxx48
-rw-r--r--chart2/source/model/main/DataTable.cxx209
-rw-r--r--chart2/source/model/main/Diagram.cxx1825
-rw-r--r--chart2/source/model/main/FormattedString.cxx112
-rw-r--r--chart2/source/model/main/FormattedString.hxx142
-rw-r--r--chart2/source/model/main/GridProperties.cxx126
-rw-r--r--chart2/source/model/main/GridProperties.hxx101
-rw-r--r--chart2/source/model/main/Legend.cxx150
-rw-r--r--chart2/source/model/main/Legend.hxx103
-rw-r--r--chart2/source/model/main/PageBackground.cxx149
-rw-r--r--chart2/source/model/main/PageBackground.hxx16
-rw-r--r--chart2/source/model/main/PolarCoordinateSystem.cxx4
-rw-r--r--chart2/source/model/main/StockBar.cxx131
-rw-r--r--chart2/source/model/main/Title.cxx168
-rw-r--r--chart2/source/model/main/Title.hxx111
-rw-r--r--chart2/source/model/main/UndoManager.cxx14
-rw-r--r--chart2/source/model/main/UndoManager.hxx3
-rw-r--r--chart2/source/model/main/Wall.cxx138
-rw-r--r--chart2/source/model/main/Wall.hxx14
-rw-r--r--chart2/source/model/template/AreaChartType.cxx5
-rw-r--r--chart2/source/model/template/AreaChartType.hxx4
-rw-r--r--chart2/source/model/template/AreaChartTypeTemplate.cxx140
-rw-r--r--chart2/source/model/template/AreaChartTypeTemplate.hxx24
-rw-r--r--chart2/source/model/template/BarChartType.cxx5
-rw-r--r--chart2/source/model/template/BarChartType.hxx4
-rw-r--r--chart2/source/model/template/BarChartTypeTemplate.cxx178
-rw-r--r--chart2/source/model/template/BarChartTypeTemplate.hxx34
-rw-r--r--chart2/source/model/template/BubbleChartType.cxx94
-rw-r--r--chart2/source/model/template/BubbleChartType.hxx11
-rw-r--r--chart2/source/model/template/BubbleChartTypeTemplate.cxx125
-rw-r--r--chart2/source/model/template/BubbleChartTypeTemplate.hxx21
-rw-r--r--chart2/source/model/template/BubbleDataInterpreter.cxx102
-rw-r--r--chart2/source/model/template/BubbleDataInterpreter.hxx16
-rw-r--r--chart2/source/model/template/CandleStickChartType.cxx103
-rw-r--r--chart2/source/model/template/CandleStickChartType.hxx10
-rw-r--r--chart2/source/model/template/ChartType.cxx106
-rw-r--r--chart2/source/model/template/ChartType.hxx137
-rw-r--r--chart2/source/model/template/ChartTypeManager.cxx590
-rw-r--r--chart2/source/model/template/ChartTypeTemplate.cxx473
-rw-r--r--chart2/source/model/template/ChartTypeTemplate.hxx252
-rw-r--r--chart2/source/model/template/ColumnChartType.cxx102
-rw-r--r--chart2/source/model/template/ColumnChartType.hxx6
-rw-r--r--chart2/source/model/template/ColumnLineChartTypeTemplate.cxx248
-rw-r--r--chart2/source/model/template/ColumnLineChartTypeTemplate.hxx46
-rw-r--r--chart2/source/model/template/ColumnLineDataInterpreter.cxx27
-rw-r--r--chart2/source/model/template/ColumnLineDataInterpreter.hxx9
-rw-r--r--chart2/source/model/template/DataInterpreter.cxx116
-rw-r--r--chart2/source/model/template/DataInterpreter.hxx77
-rw-r--r--chart2/source/model/template/FilledNetChartType.cxx6
-rw-r--r--chart2/source/model/template/FilledNetChartType.hxx2
-rw-r--r--chart2/source/model/template/LineChartType.cxx127
-rw-r--r--chart2/source/model/template/LineChartType.hxx6
-rw-r--r--chart2/source/model/template/LineChartTypeTemplate.cxx230
-rw-r--r--chart2/source/model/template/LineChartTypeTemplate.hxx27
-rw-r--r--chart2/source/model/template/NetChartType.cxx58
-rw-r--r--chart2/source/model/template/NetChartType.hxx13
-rw-r--r--chart2/source/model/template/NetChartTypeTemplate.cxx79
-rw-r--r--chart2/source/model/template/NetChartTypeTemplate.hxx21
-rw-r--r--chart2/source/model/template/PieChartType.cxx139
-rw-r--r--chart2/source/model/template/PieChartType.hxx12
-rw-r--r--chart2/source/model/template/PieChartTypeTemplate.cxx342
-rw-r--r--chart2/source/model/template/PieChartTypeTemplate.hxx56
-rw-r--r--chart2/source/model/template/ScatterChartType.cxx138
-rw-r--r--chart2/source/model/template/ScatterChartType.hxx11
-rw-r--r--chart2/source/model/template/ScatterChartTypeTemplate.cxx236
-rw-r--r--chart2/source/model/template/ScatterChartTypeTemplate.hxx28
-rw-r--r--chart2/source/model/template/StockChartTypeTemplate.cxx241
-rw-r--r--chart2/source/model/template/StockChartTypeTemplate.hxx49
-rw-r--r--chart2/source/model/template/StockDataInterpreter.cxx120
-rw-r--r--chart2/source/model/template/StockDataInterpreter.hxx16
-rw-r--r--chart2/source/model/template/XYDataInterpreter.cxx96
-rw-r--r--chart2/source/model/template/XYDataInterpreter.hxx16
93 files changed, 5098 insertions, 5660 deletions
diff --git a/chart2/source/model/filter/XMLFilter.cxx b/chart2/source/model/filter/XMLFilter.cxx
index 6cc27d10f127..f1001f3333ea 100644
--- a/chart2/source/model/filter/XMLFilter.cxx
+++ b/chart2/source/model/filter/XMLFilter.cxx
@@ -22,7 +22,6 @@
#include <officecfg/Office/Common.hxx>
#include <svtools/sfxecode.hxx>
-#include <unotools/saveopt.hxx>
#include <comphelper/genericpropertyset.hxx>
#include <comphelper/propertysetinfo.hxx>
#include <comphelper/documentconstants.hxx>
@@ -48,7 +47,7 @@
#include <com/sun/star/xml/sax/XFastParser.hpp>
#include <com/sun/star/packages/zip/ZipIOException.hpp>
#include <com/sun/star/document/GraphicStorageHandler.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
using namespace ::com::sun::star;
@@ -59,9 +58,9 @@ using ::osl::MutexGuard;
namespace
{
-constexpr OUStringLiteral sXML_metaStreamName = u"meta.xml";
-constexpr OUStringLiteral sXML_styleStreamName = u"styles.xml";
-constexpr OUStringLiteral sXML_contentStreamName = u"content.xml";
+constexpr OUString sXML_metaStreamName = u"meta.xml"_ustr;
+constexpr OUString sXML_styleStreamName = u"styles.xml"_ustr;
+constexpr OUString sXML_contentStreamName = u"content.xml"_ustr;
uno::Reference< embed::XStorage > lcl_getWriteStorage(
@@ -187,8 +186,7 @@ namespace chart
{
XMLFilter::XMLFilter( Reference< uno::XComponentContext > const & xContext ) :
- m_xContext( xContext ),
- m_bCancelOperation( false )
+ m_xContext( xContext )
{}
XMLFilter::~XMLFilter()
@@ -202,11 +200,6 @@ sal_Bool SAL_CALL XMLFilter::filter(
MutexGuard aGuard( m_aMutex );
- // ignore cancel flag at start of function
- // note: is currently ignored during import/export
- if( m_bCancelOperation )
- m_bCancelOperation = false;
-
if( m_xSourceDoc.is())
{
OSL_ENSURE( ! m_xTargetDoc.is(), "source doc is set -> target document should not be set" );
@@ -236,12 +229,6 @@ sal_Bool SAL_CALL XMLFilter::filter(
void SAL_CALL XMLFilter::cancel()
{
- // if mutex is locked set "cancel state"
- // note: is currently ignored in filter-method
- if( ! m_aMutex.tryToAcquire())
- {
- m_bCancelOperation = true;
- }
}
// ____ XImporter ____
@@ -309,7 +296,7 @@ ErrCode XMLFilter::impl_Import(
// create XPropertySet with extra information for the filter
/** property map for import info set */
- comphelper::PropertyMapEntry const aImportInfoMap[] =
+ static comphelper::PropertyMapEntry const aImportInfoMap[] =
{
// necessary properties for XML progress bar at load time
{ OUString("ProgressRange"), 0, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
@@ -320,7 +307,6 @@ ErrCode XMLFilter::impl_Import(
{ OUString("StreamRelPath"), 0, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
{ OUString("StreamName"), 0, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
{ OUString("BuildId"), 0, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
- { OUString(), 0, css::uno::Type(), 0, 0 }
};
uno::Reference< beans::XPropertySet > xImportInfo(
comphelper::GenericPropertySet_CreateInstance(
@@ -570,14 +556,13 @@ ErrCode XMLFilter::impl_Export(
xGraphicStorageHandler.set(document::GraphicStorageHandler::createWithStorage(m_xContext, xStorage));
// property map for export info set
- comphelper::PropertyMapEntry const aExportInfoMap[] =
+ static comphelper::PropertyMapEntry const aExportInfoMap[] =
{
{ OUString("UsePrettyPrinting"), 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::MAYBEVOID, 0},
{ OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
{ OUString("StreamRelPath"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
{ OUString("StreamName"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
{ OUString("ExportTableNumberList"), 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
- { OUString(), 0, css::uno::Type(), 0, 0 }
};
uno::Reference< beans::XPropertySet > xInfoSet =
@@ -723,7 +708,7 @@ void XMLFilter::isOasisFormat(const Sequence< beans::PropertyValue >& _rMediaDes
}
OUString XMLFilter::getMediaType(bool _bOasis)
{
- return _bOasis ? OUString(MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII) : OUString(MIMETYPE_VND_SUN_XML_CHART_ASCII);
+ return _bOasis ? MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII : MIMETYPE_VND_SUN_XML_CHART_ASCII;
}
OUString SAL_CALL XMLFilter::getImplementationName()
diff --git a/chart2/source/model/inc/BaseCoordinateSystem.hxx b/chart2/source/model/inc/BaseCoordinateSystem.hxx
deleted file mode 100644
index 5e00a442ccb0..000000000000
--- a/chart2/source/model/inc/BaseCoordinateSystem.hxx
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*- 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 <OPropertySet.hxx>
-#include <MutexContainer.hxx>
-#include <cppuhelper/implbase.hxx>
-#include <comphelper/uno3.hxx>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/chart2/XCoordinateSystem.hpp>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-
-#include <vector>
-
-namespace chart
-{
-
-namespace impl
-{
-typedef ::cppu::WeakImplHelper
- < css::lang::XServiceInfo,
- css::chart2::XCoordinateSystem,
- css::chart2::XChartTypeContainer,
- css::util::XCloneable,
- css::util::XModifyBroadcaster,
- css::util::XModifyListener >
- BaseCoordinateSystem_Base;
-}
-
-class BaseCoordinateSystem :
- public impl::BaseCoordinateSystem_Base,
- public MutexContainer,
- public ::property::OPropertySet
-{
-public:
- BaseCoordinateSystem( sal_Int32 nDimensionCount );
- explicit BaseCoordinateSystem( const BaseCoordinateSystem & rSource );
- virtual ~BaseCoordinateSystem() override;
-
- // ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
-
- virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
-
- // ____ XPropertySet ____
- virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
- getPropertySetInfo() override;
-
- /// merge XInterface implementations
- DECLARE_XINTERFACE()
- /// merge XTypeProvider implementations
- DECLARE_XTYPEPROVIDER()
-
-protected:
- // ____ XCoordinateSystem ____
- virtual ::sal_Int32 SAL_CALL getDimension() override;
- virtual void SAL_CALL setAxisByDimension(
- ::sal_Int32 nDimension,
- const css::uno::Reference< css::chart2::XAxis >& xAxis,
- ::sal_Int32 nIndex ) override;
- virtual css::uno::Reference< css::chart2::XAxis > SAL_CALL getAxisByDimension(
- ::sal_Int32 nDimension, ::sal_Int32 nIndex ) override;
- virtual ::sal_Int32 SAL_CALL getMaximumAxisIndexByDimension( ::sal_Int32 nDimension ) override;
-
- // ____ XChartTypeContainer ____
- virtual void SAL_CALL addChartType(
- const css::uno::Reference< css::chart2::XChartType >& aChartType ) override;
- virtual void SAL_CALL removeChartType(
- const css::uno::Reference< css::chart2::XChartType >& aChartType ) override;
- virtual css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > > SAL_CALL getChartTypes() override;
- virtual void SAL_CALL setChartTypes(
- const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > >& aChartTypes ) override;
-
- // ____ XModifyBroadcaster ____
- virtual void SAL_CALL addModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
- virtual void SAL_CALL removeModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
-
- // ____ XModifyListener ____
- virtual void SAL_CALL modified(
- const css::lang::EventObject& aEvent ) override;
-
- // ____ XEventListener (base of XModifyListener) ____
- virtual void SAL_CALL disposing(
- const css::lang::EventObject& Source ) override;
-
- // ____ OPropertySet ____
- virtual void firePropertyChangeEvent() override;
- using OPropertySet::disposing;
-
- void fireModifyEvent();
-
-protected:
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
-
-private:
- sal_Int32 m_nDimensionCount;
- typedef std::vector< std::vector< css::uno::Reference< css::chart2::XAxis > > > tAxisVecVecType;
- tAxisVecVecType m_aAllAxis; //outer sequence is the dimension; inner sequence is the axis index that indicates main or secondary axis
- std::vector< css::uno::Reference< css::chart2::XChartType > > m_aChartTypes;
-};
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/CartesianCoordinateSystem.hxx b/chart2/source/model/inc/CartesianCoordinateSystem.hxx
index ac8571441557..d84f53bf5719 100644
--- a/chart2/source/model/inc/CartesianCoordinateSystem.hxx
+++ b/chart2/source/model/inc/CartesianCoordinateSystem.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "BaseCoordinateSystem.hxx"
+#include <BaseCoordinateSystem.hxx>
namespace chart
{
@@ -42,7 +42,7 @@ public:
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
};
-class CartesianCoordinateSystem2d : public CartesianCoordinateSystem
+class CartesianCoordinateSystem2d final : public CartesianCoordinateSystem
{
public:
explicit CartesianCoordinateSystem2d();
@@ -54,7 +54,7 @@ public:
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
};
-class CartesianCoordinateSystem3d : public CartesianCoordinateSystem
+class CartesianCoordinateSystem3d final : public CartesianCoordinateSystem
{
public:
explicit CartesianCoordinateSystem3d();
diff --git a/chart2/source/model/inc/ChartTypeManager.hxx b/chart2/source/model/inc/ChartTypeManager.hxx
deleted file mode 100644
index f3918a8679e9..000000000000
--- a/chart2/source/model/inc/ChartTypeManager.hxx
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- 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 <cppuhelper/implbase.hxx>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/chart2/XChartTypeManager.hpp>
-
-namespace com::sun::star::uno { class XComponentContext; }
-
-namespace chart
-{
-
-class ChartTypeManager :
- public ::cppu::WeakImplHelper<
- css::lang::XServiceInfo,
- css::lang::XMultiServiceFactory,
- css::chart2::XChartTypeManager >
-{
-public:
- explicit ChartTypeManager(
- css::uno::Reference< css::uno::XComponentContext > const & xContext );
- virtual ~ChartTypeManager() override;
-
- 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;
-
-protected:
- // ____ XMultiServiceFactory ____
- virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override;
- virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(
- const OUString& ServiceSpecifier,
- const css::uno::Sequence< css::uno::Any >& Arguments ) override;
- virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override;
-
- // ____ XChartTypeManager ____
- // currently empty
-
-private:
- css::uno::Reference< css::uno::XComponentContext >
- m_xContext;
-};
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/DataSeries.hxx b/chart2/source/model/inc/DataSeries.hxx
deleted file mode 100644
index 35e7725aa06b..000000000000
--- a/chart2/source/model/inc/DataSeries.hxx
+++ /dev/null
@@ -1,168 +0,0 @@
-/* -*- 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
-
-// UNO types
-#include <com/sun/star/chart2/XDataSeries.hpp>
-#include <com/sun/star/chart2/data/XDataSink.hpp>
-#include <com/sun/star/chart2/data/XDataSource.hpp>
-#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-
-// helper classes
-#include <cppuhelper/implbase.hxx>
-#include <comphelper/uno3.hxx>
-
-// STL
-#include <vector>
-#include <map>
-
-#include <MutexContainer.hxx>
-#include <OPropertySet.hxx>
-
-namespace com::sun::star::beans { class XPropertySet; }
-
-namespace chart
-{
-
-namespace impl
-{
-typedef ::cppu::WeakImplHelper<
- css::chart2::XDataSeries,
- css::chart2::data::XDataSink,
- css::chart2::data::XDataSource,
- css::lang::XServiceInfo,
- css::chart2::XRegressionCurveContainer,
- css::util::XCloneable,
- css::util::XModifyBroadcaster,
- css::util::XModifyListener >
- DataSeries_Base;
-}
-
-class DataSeries final :
- public MutexContainer,
- public impl::DataSeries_Base,
- public ::property::OPropertySet
-{
-public:
- explicit DataSeries();
- virtual ~DataSeries() 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;
-
- /// merge XInterface implementations
- DECLARE_XINTERFACE()
- /// merge XTypeProvider implementations
- DECLARE_XTYPEPROVIDER()
-
-private:
- explicit DataSeries( const DataSeries & rOther );
-
- // late initialization to call after copy-constructing
- void Init( const DataSeries & rOther );
-
- // ____ XDataSeries ____
- /// @see css::chart2::XDataSeries
- virtual css::uno::Reference< css::beans::XPropertySet >
- SAL_CALL getDataPointByIndex( sal_Int32 nIndex ) override;
- virtual void SAL_CALL resetDataPoint( sal_Int32 nIndex ) override;
- virtual void SAL_CALL resetAllDataPoints() override;
-
- // ____ XDataSink ____
- /// @see css::chart2::data::XDataSink
- virtual void SAL_CALL setData( const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > >& aData ) override;
-
- // ____ XDataSource ____
- /// @see css::chart2::data::XDataSource
- virtual css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences() override;
-
- // ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
- virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override;
- virtual void SAL_CALL setFastPropertyValue_NoBroadcast
- ( sal_Int32 nHandle,
- const css::uno::Any& rValue ) override;
-
- virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
-
- // ____ XPropertySet ____
- /// @see css::beans::XPropertySet
- virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
- getPropertySetInfo() override;
-
- /// make original interface function visible again
- using ::com::sun::star::beans::XFastPropertySet::getFastPropertyValue;
-
- // ____ XRegressionCurveContainer ____
- /// @see css::chart2::XRegressionCurveContainer
- virtual void SAL_CALL addRegressionCurve(
- const css::uno::Reference< css::chart2::XRegressionCurve >& aRegressionCurve ) override;
- virtual void SAL_CALL removeRegressionCurve(
- const css::uno::Reference< css::chart2::XRegressionCurve >& aRegressionCurve ) override;
- virtual css::uno::Sequence< css::uno::Reference< css::chart2::XRegressionCurve > > SAL_CALL getRegressionCurves() override;
- virtual void SAL_CALL setRegressionCurves(
- const css::uno::Sequence< css::uno::Reference< css::chart2::XRegressionCurve > >& aRegressionCurves ) override;
-
- // ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- // ____ XModifyBroadcaster ____
- virtual void SAL_CALL addModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
- virtual void SAL_CALL removeModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
-
- // ____ XModifyListener ____
- virtual void SAL_CALL modified(
- const css::lang::EventObject& aEvent ) override;
-
- // ____ XEventListener (base of XModifyListener) ____
- virtual void SAL_CALL disposing(
- const css::lang::EventObject& Source ) override;
-
- // ____ OPropertySet ____
- virtual void firePropertyChangeEvent() override;
- using OPropertySet::disposing;
-
- void fireModifyEvent();
-
- typedef std::vector< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > tDataSequenceContainer;
- tDataSequenceContainer m_aDataSequences;
-
- typedef std::map< sal_Int32,
- css::uno::Reference< css::beans::XPropertySet > > tDataPointAttributeContainer;
- tDataPointAttributeContainer m_aAttributedDataPoints;
-
- typedef
- std::vector< css::uno::Reference< css::chart2::XRegressionCurve > >
- tRegressionCurveContainerType;
- tRegressionCurveContainerType m_aRegressionCurves;
-
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
-};
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/Diagram.hxx b/chart2/source/model/inc/Diagram.hxx
deleted file mode 100644
index 4e32b48b895c..000000000000
--- a/chart2/source/model/inc/Diagram.hxx
+++ /dev/null
@@ -1,182 +0,0 @@
-/* -*- 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 <OPropertySet.hxx>
-#include <MutexContainer.hxx>
-#include <cppuhelper/implbase.hxx>
-#include <comphelper/uno3.hxx>
-#include <com/sun/star/chart2/XDiagram.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
-#include <com/sun/star/chart2/XTitled.hpp>
-#include <com/sun/star/chart/X3DDefaultSetter.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-
-#include <vector>
-
-namespace com::sun::star::beans { struct PropertyValue; }
-namespace com::sun::star::chart2::data { class XDataSource; }
-namespace com::sun::star::uno { class XComponentContext; }
-
-namespace chart
-{
-
-namespace impl
-{
-typedef ::cppu::WeakImplHelper<
- css::chart2::XDiagram,
- css::lang::XServiceInfo,
- css::chart2::XCoordinateSystemContainer,
- css::chart2::XTitled,
- css::chart::X3DDefaultSetter,
- css::util::XModifyBroadcaster,
- css::util::XModifyListener,
- css::util::XCloneable >
- Diagram_Base;
-}
-
-class Diagram final :
- public MutexContainer,
- public impl::Diagram_Base,
- public ::property::OPropertySet
-{
-public:
- Diagram( css::uno::Reference< css::uno::XComponentContext > const & xContext );
- virtual ~Diagram() 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;
-
- /// merge XInterface implementations
- DECLARE_XINTERFACE()
- /// merge XTypeProvider implementations
- DECLARE_XTYPEPROVIDER()
-
-private:
- explicit Diagram( const Diagram & rOther );
-
- // ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
-
- // ____ OPropertySet ____
- virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
-
- // ____ XPropertySet ____
- virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
- getPropertySetInfo() override;
-
- // ____ XFastPropertySet ____
- virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const css::uno::Any& rValue ) override;
-
- /// make original interface function visible again
- using ::com::sun::star::beans::XFastPropertySet::getFastPropertyValue;
-
- virtual void SAL_CALL getFastPropertyValue(
- css::uno::Any& rValue, sal_Int32 nHandle ) const override;
-
- // ____ XDiagram ____
- virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getWall() override;
- virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getFloor() override;
- virtual css::uno::Reference< css::chart2::XLegend > SAL_CALL getLegend() override;
- virtual void SAL_CALL setLegend( const css::uno::Reference<
- css::chart2::XLegend >& xLegend ) override;
- virtual css::uno::Reference< css::chart2::XColorScheme > SAL_CALL getDefaultColorScheme() override;
- virtual void SAL_CALL setDefaultColorScheme(
- const css::uno::Reference< css::chart2::XColorScheme >& xColorScheme ) override;
- virtual void SAL_CALL setDiagramData(
- const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource,
- const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override;
-
- // ____ XCoordinateSystemContainer ____
- virtual void SAL_CALL addCoordinateSystem(
- const css::uno::Reference< css::chart2::XCoordinateSystem >& aCoordSys ) override;
- virtual void SAL_CALL removeCoordinateSystem(
- const css::uno::Reference< css::chart2::XCoordinateSystem >& aCoordSys ) override;
- virtual css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > SAL_CALL getCoordinateSystems() override;
- virtual void SAL_CALL setCoordinateSystems(
- const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > >& aCoordinateSystems ) override;
-
- // ____ XTitled ____
- virtual css::uno::Reference<
- css::chart2::XTitle > SAL_CALL getTitleObject() override;
- virtual void SAL_CALL setTitleObject( const css::uno::Reference<
- css::chart2::XTitle >& Title ) override;
-
- // ____ X3DDefaultSetter ____
- virtual void SAL_CALL set3DSettingsToDefault() override;
- virtual void SAL_CALL setDefaultRotation() override;
- virtual void SAL_CALL setDefaultIllumination() override;
-
- // ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- // ____ XModifyBroadcaster ____
- virtual void SAL_CALL addModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
- virtual void SAL_CALL removeModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
-
- // ____ XModifyListener ____
- virtual void SAL_CALL modified(
- const css::lang::EventObject& aEvent ) override;
-
- // ____ XEventListener (base of XModifyListener) ____
- virtual void SAL_CALL disposing(
- const css::lang::EventObject& Source ) override;
-
- // ____ OPropertySet ____
- virtual void firePropertyChangeEvent() override;
- using OPropertySet::disposing;
-
- void fireModifyEvent();
-
- css::uno::Reference< css::uno::XComponentContext > m_xContext;
-
- typedef
- std::vector< css::uno::Reference< css::chart2::XCoordinateSystem > >
- tCoordinateSystemContainerType;
-
- tCoordinateSystemContainerType m_aCoordSystems;
-
- css::uno::Reference< css::beans::XPropertySet >
- m_xWall;
-
- css::uno::Reference< css::beans::XPropertySet >
- m_xFloor;
-
- css::uno::Reference< css::chart2::XTitle >
- m_xTitle;
-
- css::uno::Reference< css::chart2::XLegend >
- m_xLegend;
-
- css::uno::Reference< css::chart2::XColorScheme >
- m_xColorScheme;
-
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
-};
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/PolarCoordinateSystem.hxx b/chart2/source/model/inc/PolarCoordinateSystem.hxx
index ff0ff040d3b1..43eaefa5b0d6 100644
--- a/chart2/source/model/inc/PolarCoordinateSystem.hxx
+++ b/chart2/source/model/inc/PolarCoordinateSystem.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "BaseCoordinateSystem.hxx"
+#include <BaseCoordinateSystem.hxx>
namespace chart
{
@@ -42,7 +42,7 @@ public:
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
};
-class PolarCoordinateSystem2d : public PolarCoordinateSystem
+class PolarCoordinateSystem2d final : public PolarCoordinateSystem
{
public:
explicit PolarCoordinateSystem2d();
@@ -54,7 +54,7 @@ public:
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
};
-class PolarCoordinateSystem3d : public PolarCoordinateSystem
+class PolarCoordinateSystem3d final : public PolarCoordinateSystem
{
public:
explicit PolarCoordinateSystem3d();
diff --git a/chart2/source/model/inc/StockBar.hxx b/chart2/source/model/inc/StockBar.hxx
index 91437751bfc1..38f5c2629b4a 100644
--- a/chart2/source/model/inc/StockBar.hxx
+++ b/chart2/source/model/inc/StockBar.hxx
@@ -19,13 +19,11 @@
#pragma once
#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-#include <MutexContainer.hxx>
#include <OPropertySet.hxx>
#include <cppuhelper/implbase.hxx>
#include <comphelper/uno3.hxx>
+#include <ModifyListenerHelper.hxx>
namespace chart
{
@@ -40,7 +38,6 @@ typedef ::cppu::WeakImplHelper<
}
class StockBar final :
- public MutexContainer,
public impl::StockBar_Base,
public ::property::OPropertySet
{
@@ -54,8 +51,11 @@ public:
private:
explicit StockBar( const StockBar & rOther );
+ // ____ XTypeProvider ____
+ virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
+
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -84,7 +84,7 @@ private:
virtual void firePropertyChangeEvent() override;
using OPropertySet::disposing;
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
+ rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder;
};
} // namespace chart
diff --git a/chart2/source/model/inc/XMLFilter.hxx b/chart2/source/model/inc/XMLFilter.hxx
index 1a37e461ac48..12c28ad40e79 100644
--- a/chart2/source/model/inc/XMLFilter.hxx
+++ b/chart2/source/model/inc/XMLFilter.hxx
@@ -24,9 +24,8 @@
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/io/XActiveDataSource.hpp>
#include <osl/mutex.hxx>
-#include <vcl/errcode.hxx>
+#include <comphelper/errcode.hxx>
namespace com::sun::star::beans { class XPropertySet; }
namespace com::sun::star::uno { class XComponentContext; }
@@ -124,12 +123,10 @@ private:
css::uno::Sequence<css::beans::PropertyValue> m_aMediaDescriptor;
OUString m_sDocumentHandler; // when set it will be set as doc handler
-
- volatile bool m_bCancelOperation;
::osl::Mutex m_aMutex;
};
-class XMLReportFilterHelper : public XMLFilter
+class XMLReportFilterHelper final : public XMLFilter
{
virtual void isOasisFormat(const css::uno::Sequence< css::beans::PropertyValue >& _rMediaDescriptor,
bool & _rOutOASIS ) override;
diff --git a/chart2/source/model/main/Axis.cxx b/chart2/source/model/main/Axis.cxx
index bfdccbd54e2f..3d7cfc6267b8 100644
--- a/chart2/source/model/main/Axis.cxx
+++ b/chart2/source/model/main/Axis.cxx
@@ -17,16 +17,16 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "Axis.hxx"
-#include "GridProperties.hxx"
+#include <Axis.hxx>
+#include <GridProperties.hxx>
#include <CharacterProperties.hxx>
#include <LinePropertiesHelper.hxx>
#include <UserDefinedProperties.hxx>
#include <PropertyHelper.hxx>
-#include <CloneHelper.hxx>
#include <AxisHelper.hxx>
#include <EventListenerHelper.hxx>
#include <ModifyListenerHelper.hxx>
+#include <Title.hxx>
#include <unonames.hxx>
#include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
@@ -36,7 +36,7 @@
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/awt/Size.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <rtl/ref.hxx>
#include <vector>
@@ -204,116 +204,75 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEVOID );
}
+} // namespace
-struct StaticAxisDefaults_Initializer
+namespace chart
{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
- ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
-
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_SHOW, true );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_CROSSOVER_POSITION, css::chart::ChartAxisPosition_ZERO );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_DISPLAY_LABELS, true );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE, true );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_LABEL_POSITION, css::chart::ChartAxisLabelPosition_NEAR_AXIS );
- ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_AXIS_TEXT_ROTATION, 0.0 );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_BREAK, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_OVERLAP, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_STACKED, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_ARRANGE_ORDER, css::chart::ChartAxisArrangeOrderType_AUTO );
-
- float fDefaultCharHeight = 10.0;
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
-
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MAJOR_TICKMARKS, 2 /* CHAXIS_MARK_OUTER */ );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MINOR_TICKMARKS, 0 /* CHAXIS_MARK_NONE */ );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_MARK_POSITION, css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_DISPLAY_UNITS, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TRY_STAGGERING_FIRST, false );
- }
-};
-
-struct StaticAxisDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticAxisDefaults_Initializer >
+const ::chart::tPropertyValueMap & StaticAxisDefaults()
{
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aMap;
+ ::chart::CharacterProperties::AddDefaultsToMap( aMap );
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aMap );
+
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_SHOW, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_CROSSOVER_POSITION, css::chart::ChartAxisPosition_ZERO );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_DISPLAY_LABELS, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_LABEL_POSITION, css::chart::ChartAxisLabelPosition_NEAR_AXIS );
+ ::chart::PropertyHelper::setPropertyValueDefault< double >( aMap, PROP_AXIS_TEXT_ROTATION, 0.0 );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TEXT_BREAK, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TEXT_OVERLAP, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TEXT_STACKED, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TEXT_ARRANGE_ORDER, css::chart::ChartAxisArrangeOrderType_AUTO );
+
+ float fDefaultCharHeight = 10.0;
+ ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
+
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_AXIS_MAJOR_TICKMARKS, 2 /* CHAXIS_MARK_OUTER */ );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_AXIS_MINOR_TICKMARKS, 0 /* CHAXIS_MARK_NONE */ );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_MARK_POSITION, css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_DISPLAY_UNITS, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TRY_STAGGERING_FIRST, false );
+ return aMap;
+ }();
+ return aStaticDefaults;
};
+} // namespace chart
-struct StaticAxisInfoHelper_Initializer
+namespace
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-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 );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-};
-
-struct StaticAxisInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticAxisInfoHelper_Initializer >
+::cppu::OPropertyArrayHelper& StaticAxisInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
-struct StaticAxisInfo_Initializer
+std::vector< rtl::Reference< ::chart::GridProperties > > lcl_CloneSubGrids(
+ const std::vector< rtl::Reference< ::chart::GridProperties > > & rSource )
{
- uno::Reference< beans::XPropertySetInfo >* operator()()
+ std::vector< rtl::Reference< ::chart::GridProperties > > aDestination;
+ aDestination.reserve( rSource.size());
+ for( rtl::Reference< ::chart::GridProperties > const & i : rSource )
{
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAxisInfoHelper::get() ) );
- return &xPropertySetInfo;
+ aDestination.push_back(new ::chart::GridProperties(*i));
}
-};
-
-struct StaticAxisInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticAxisInfo_Initializer >
-{
-};
-
-typedef uno::Reference< beans::XPropertySet > lcl_tSubGridType;
-
-void lcl_CloneSubGrids(
- const uno::Sequence< lcl_tSubGridType > & rSource, uno::Sequence< lcl_tSubGridType > & rDestination )
-{
- rDestination.realloc( rSource.getLength());
- lcl_tSubGridType * pDestBegin = rDestination.getArray();
- lcl_tSubGridType * pDestEnd = pDestBegin + rDestination.getLength();
- lcl_tSubGridType * pDestIt = pDestBegin;
-
- for( Reference< beans::XPropertySet > const & i : rSource )
- {
- Reference< beans::XPropertySet > xSubGrid( i );
- if( xSubGrid.is())
- {
- Reference< util::XCloneable > xCloneable( xSubGrid, uno::UNO_QUERY );
- if( xCloneable.is())
- xSubGrid.set( xCloneable->createClone(), uno::UNO_QUERY );
- }
-
- (*pDestIt) = xSubGrid;
- OSL_ASSERT( pDestIt != pDestEnd );
- ++pDestIt;
- }
- OSL_ASSERT( pDestIt == pDestEnd );
+ return aDestination;
}
} // anonymous namespace
@@ -322,8 +281,7 @@ namespace chart
{
Axis::Axis() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_aScaleData( AxisHelper::createDefaultScale() ),
m_xGrid( new GridProperties() )
{
@@ -342,22 +300,24 @@ Axis::Axis() :
Axis::Axis( const Axis & rOther ) :
impl::Axis_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_aScaleData( rOther.m_aScaleData )
{
- m_xGrid.set( CloneHelper::CreateRefClone< beans::XPropertySet >()( rOther.m_xGrid ));
+ if (rOther.m_xGrid)
+ m_xGrid = new ::chart::GridProperties(*rOther.m_xGrid);
if( m_xGrid.is())
ModifyListenerHelper::addListener( m_xGrid, m_xModifyEventForwarder );
if( m_aScaleData.Categories.is())
ModifyListenerHelper::addListener( m_aScaleData.Categories, m_xModifyEventForwarder );
- if( rOther.m_aSubGridProperties.hasElements() )
- lcl_CloneSubGrids( rOther.m_aSubGridProperties, m_aSubGridProperties );
- ModifyListenerHelper::addListenerToAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder );
+ if( !rOther.m_aSubGridProperties.empty() )
+ m_aSubGridProperties = lcl_CloneSubGrids( rOther.m_aSubGridProperties );
+ ModifyListenerHelper::addListenerToAllElements( m_aSubGridProperties, m_xModifyEventForwarder );
- m_xTitle.set( CloneHelper::CreateRefClone< chart2::XTitle >()( rOther.m_xTitle ));
+ if ( rOther.m_xTitle )
+ m_xTitle = new Title( *rOther.m_xTitle );
if( m_xTitle.is())
ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
}
@@ -374,12 +334,12 @@ Axis::~Axis()
try
{
ModifyListenerHelper::removeListener( m_xGrid, m_xModifyEventForwarder );
- ModifyListenerHelper::removeListenerFromAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder );
+ ModifyListenerHelper::removeListenerFromAllElements( m_aSubGridProperties, m_xModifyEventForwarder );
ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
if( m_aScaleData.Categories.is())
{
ModifyListenerHelper::removeListener( m_aScaleData.Categories, m_xModifyEventForwarder );
- m_aScaleData.Categories.set(nullptr);
+ m_aScaleData.Categories.clear();
}
}
catch( const uno::Exception & )
@@ -387,7 +347,7 @@ Axis::~Axis()
DBG_UNHANDLED_EXCEPTION("chart2");
}
- m_aSubGridProperties.realloc(0);
+ m_aSubGridProperties.clear();
m_xGrid = nullptr;
m_xTitle = nullptr;
}
@@ -396,32 +356,31 @@ void Axis::AllocateSubGrids()
{
Reference< util::XModifyListener > xModifyEventForwarder;
Reference< lang::XEventListener > xEventListener;
- std::vector< Reference< beans::XPropertySet > > aOldBroadcasters;
- std::vector< Reference< beans::XPropertySet > > aNewBroadcasters;
+ std::vector< rtl::Reference< GridProperties > > aOldBroadcasters;
+ std::vector< rtl::Reference< GridProperties > > aNewBroadcasters;
{
MutexGuard aGuard( m_aMutex );
xModifyEventForwarder = m_xModifyEventForwarder;
xEventListener = this;
sal_Int32 nNewSubIncCount = m_aScaleData.IncrementData.SubIncrements.getLength();
- sal_Int32 nOldSubIncCount = m_aSubGridProperties.getLength();
+ sal_Int32 nOldSubIncCount = m_aSubGridProperties.size();
if( nOldSubIncCount > nNewSubIncCount )
{
// remove superfluous entries
for( sal_Int32 i = nNewSubIncCount; i < nOldSubIncCount; ++i )
aOldBroadcasters.push_back( m_aSubGridProperties[ i ] );
- m_aSubGridProperties.realloc( nNewSubIncCount );
+ m_aSubGridProperties.resize( nNewSubIncCount );
}
else if( nOldSubIncCount < nNewSubIncCount )
{
- m_aSubGridProperties.realloc( nNewSubIncCount );
- auto pSubGridProperties = m_aSubGridProperties.getArray();
+ m_aSubGridProperties.resize( nNewSubIncCount );
// allocate new entries
for( sal_Int32 i = nOldSubIncCount; i < nNewSubIncCount; ++i )
{
- pSubGridProperties[ i ] = new GridProperties();
+ m_aSubGridProperties[ i ] = new GridProperties();
LinePropertiesHelper::SetLineInvisible( m_aSubGridProperties[ i ] );
LinePropertiesHelper::SetLineColor( m_aSubGridProperties[ i ], static_cast<sal_Int32>(0xdddddd) ); //gray2
aNewBroadcasters.push_back( m_aSubGridProperties[ i ] );
@@ -476,9 +435,20 @@ Reference< beans::XPropertySet > SAL_CALL Axis::getGridProperties()
MutexGuard aGuard( m_aMutex );
return m_xGrid;
}
+rtl::Reference< ::chart::GridProperties > Axis::getGridProperties2()
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xGrid;
+}
Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubGridProperties()
{
MutexGuard aGuard( m_aMutex );
+ return comphelper::containerToSequence<Reference< beans::XPropertySet >>(m_aSubGridProperties);
+}
+
+std::vector< rtl::Reference< GridProperties > > Axis::getSubGridProperties2()
+{
+ MutexGuard aGuard( m_aMutex );
return m_aSubGridProperties;
}
@@ -495,10 +465,23 @@ Reference< chart2::XTitle > SAL_CALL Axis::getTitleObject()
return m_xTitle;
}
+rtl::Reference< Title > Axis::getTitleObject2() const
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xTitle;
+}
+
void SAL_CALL Axis::setTitleObject( const Reference< chart2::XTitle >& xNewTitle )
{
+ rtl::Reference<Title> xTitle = dynamic_cast<Title*>(xNewTitle.get());
+ assert(!xNewTitle || xTitle);
+ setTitleObject(xTitle);
+}
+
+void Axis::setTitleObject( const rtl::Reference< Title >& xNewTitle )
+{
Reference< util::XModifyListener > xModifyEventForwarder;
- Reference< chart2::XTitle > xOldTitle;
+ rtl::Reference< Title > xOldTitle;
{
MutexGuard aGuard( m_aMutex );
xOldTitle = m_xTitle;
@@ -526,28 +509,12 @@ Reference< util::XCloneable > SAL_CALL Axis::createClone()
// ____ XModifyBroadcaster ____
void SAL_CALL Axis::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception &)
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL Axis::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -575,24 +542,27 @@ void Axis::fireModifyEvent()
}
// ____ OPropertySet ____
-uno::Any Axis::GetDefaultValue( sal_Int32 nHandle ) const
+void Axis::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticAxisDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticAxisDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL Axis::getInfoHelper()
{
- return *StaticAxisInfoHelper::get();
+ return StaticAxisInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL Axis::getPropertySetInfo()
{
- return *StaticAxisInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticAxisInfoHelper() ) );
+ return xPropertySetInfo;
}
using impl::Axis_Base;
diff --git a/chart2/source/model/main/Axis.hxx b/chart2/source/model/main/Axis.hxx
deleted file mode 100644
index 3ee419a7fec7..000000000000
--- a/chart2/source/model/main/Axis.hxx
+++ /dev/null
@@ -1,134 +0,0 @@
-/* -*- 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 <MutexContainer.hxx>
-#include <OPropertySet.hxx>
-#include <cppuhelper/implbase.hxx>
-#include <comphelper/uno3.hxx>
-
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/chart2/XAxis.hpp>
-#include <com/sun/star/chart2/XTitled.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-
-namespace chart
-{
-
-namespace impl
-{
-typedef ::cppu::WeakImplHelper<
- css::chart2::XAxis,
- css::chart2::XTitled,
- css::lang::XServiceInfo,
- css::util::XCloneable,
- css::util::XModifyBroadcaster,
- css::util::XModifyListener >
- Axis_Base;
-}
-
-class Axis final :
- public MutexContainer,
- public impl::Axis_Base,
- public ::property::OPropertySet
-{
-public:
- explicit Axis();
- virtual ~Axis() 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;
-
- /// merge XInterface implementations
- DECLARE_XINTERFACE()
- /// merge XTypeProvider implementations
- DECLARE_XTYPEPROVIDER()
-
-private:
- explicit Axis( const Axis & rOther );
-
- // late initialization to call after copy-constructing
- void Init();
-
- // ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
-
- // ____ OPropertySet ____
- virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
-
- // ____ XPropertySet ____
- virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
- getPropertySetInfo() override;
-
- // ____ XAxis ____
- virtual void SAL_CALL setScaleData( const css::chart2::ScaleData& rScaleData ) override;
- virtual css::chart2::ScaleData SAL_CALL getScaleData() override;
- virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getGridProperties() override;
- virtual css::uno::Sequence< css::uno::Reference< css::beans::XPropertySet > > SAL_CALL getSubGridProperties() override;
- virtual css::uno::Sequence< css::uno::Reference< css::beans::XPropertySet > > SAL_CALL getSubTickProperties() override;
-
- // ____ XTitled ____
- virtual css::uno::Reference< css::chart2::XTitle > SAL_CALL getTitleObject() override;
- virtual void SAL_CALL setTitleObject(
- const css::uno::Reference< css::chart2::XTitle >& Title ) override;
-
- // ____ XCloneable ____
- // Note: the coordinate systems are not cloned!
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- // ____ XModifyBroadcaster ____
- virtual void SAL_CALL addModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
- virtual void SAL_CALL removeModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
-
- // ____ XModifyListener ____
- virtual void SAL_CALL modified(
- const css::lang::EventObject& aEvent ) override;
-
- // ____ XEventListener (base of XModifyListener) ____
- virtual void SAL_CALL disposing(
- const css::lang::EventObject& Source ) override;
-
- // ____ OPropertySet ____
- virtual void firePropertyChangeEvent() override;
- using OPropertySet::disposing;
-
- void fireModifyEvent();
-
- void AllocateSubGrids();
-
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
-
- css::chart2::ScaleData m_aScaleData;
-
- css::uno::Reference< css::beans::XPropertySet > m_xGrid;
-
- css::uno::Sequence< css::uno::Reference< css::beans::XPropertySet > > m_aSubGridProperties;
-
- css::uno::Reference< css::chart2::XTitle > m_xTitle;
-};
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/BaseCoordinateSystem.cxx b/chart2/source/model/main/BaseCoordinateSystem.cxx
index f44f565fa86c..8af32fa09678 100644
--- a/chart2/source/model/main/BaseCoordinateSystem.cxx
+++ b/chart2/source/model/main/BaseCoordinateSystem.cxx
@@ -22,12 +22,13 @@
#include <UserDefinedProperties.hxx>
#include <CloneHelper.hxx>
#include <ModifyListenerHelper.hxx>
-#include "Axis.hxx"
+#include <Axis.hxx>
+#include <ChartType.hxx>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/container/NoSuchElementException.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <o3tl/safeint.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -55,58 +56,31 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEVOID );
}
-struct StaticCooSysDefaults_Initializer
+const ::chart::tPropertyValueMap & StaticCooSysDefaults()
{
- ::chart::tPropertyValueMap* operator()()
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
{
- static ::chart::tPropertyValueMap aStaticDefaults;
- ::chart::PropertyHelper::setPropertyValueDefault( aStaticDefaults, PROP_COORDINATESYSTEM_SWAPXANDYAXIS, false );
- return &aStaticDefaults;
- }
+ ::chart::tPropertyValueMap aMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_COORDINATESYSTEM_SWAPXANDYAXIS, false );
+ return aMap;
+ }();
+ return aStaticDefaults;
};
-struct StaticCooSysDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticCooSysDefaults_Initializer >
+::cppu::OPropertyArrayHelper& StaticCooSysInfoHelper()
{
-};
-
-struct StaticCooSysInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-struct StaticCooSysInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticCooSysInfoHelper_Initializer >
-{
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticCooSysInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticCooSysInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticCooSysInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticCooSysInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -116,15 +90,14 @@ namespace chart
BaseCoordinateSystem::BaseCoordinateSystem(
sal_Int32 nDimensionCount /* = 2 */ ) :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_nDimensionCount( nDimensionCount )
{
m_aAllAxis.resize( m_nDimensionCount );
for( sal_Int32 nN=0; nN<m_nDimensionCount; nN++ )
{
m_aAllAxis[nN].resize( 1 );
- Reference< chart2::XAxis > xAxis( new Axis );
+ rtl::Reference< Axis > xAxis( new Axis );
m_aAllAxis[nN][0] = xAxis;
ModifyListenerHelper::addListenerToAllElements( m_aAllAxis[nN], m_xModifyEventForwarder );
@@ -151,19 +124,21 @@ BaseCoordinateSystem::BaseCoordinateSystem(
BaseCoordinateSystem::BaseCoordinateSystem(
const BaseCoordinateSystem & rSource ) :
impl::BaseCoordinateSystem_Base(rSource),
- ::property::OPropertySet( rSource, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ ::property::OPropertySet( rSource ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_nDimensionCount( rSource.m_nDimensionCount )
{
m_aAllAxis.resize(rSource.m_aAllAxis.size());
tAxisVecVecType::size_type nN=0;
for( nN=0; nN<m_aAllAxis.size(); nN++ )
- CloneHelper::CloneRefVector<chart2::XAxis>( rSource.m_aAllAxis[nN], m_aAllAxis[nN] );
- CloneHelper::CloneRefVector<chart2::XChartType>( rSource.m_aChartTypes, m_aChartTypes );
+ CloneHelper::CloneRefVector( rSource.m_aAllAxis[nN], m_aAllAxis[nN] );
+ for (const auto & rxChartType : rSource.m_aChartTypes)
+ m_aChartTypes.push_back(rxChartType->cloneChartType());
for( nN=0; nN<m_aAllAxis.size(); nN++ )
ModifyListenerHelper::addListenerToAllElements( m_aAllAxis[nN], m_xModifyEventForwarder );
- ModifyListenerHelper::addListenerToAllElements( m_aChartTypes, m_xModifyEventForwarder );
+ for (const auto & rxChartType : m_aChartTypes)
+ rxChartType->addModifyListener( m_xModifyEventForwarder );
}
BaseCoordinateSystem::~BaseCoordinateSystem()
@@ -172,7 +147,8 @@ BaseCoordinateSystem::~BaseCoordinateSystem()
{
for(const tAxisVecVecType::value_type & i : m_aAllAxis)
ModifyListenerHelper::removeListenerFromAllElements( i, m_xModifyEventForwarder );
- ModifyListenerHelper::removeListenerFromAllElements( m_aChartTypes, m_xModifyEventForwarder );
+ for (const auto & rxChartType : m_aChartTypes)
+ rxChartType->removeModifyListener( m_xModifyEventForwarder );
}
catch( const uno::Exception & )
{
@@ -197,13 +173,41 @@ void SAL_CALL BaseCoordinateSystem::setAxisByDimension(
if( nIndex < 0 )
throw lang::IndexOutOfBoundsException();
+ assert(!xAxis || dynamic_cast<Axis*>(xAxis.get()));
+
+ if( m_aAllAxis[ nDimensionIndex ].size() < o3tl::make_unsigned( nIndex+1 ))
+ {
+ m_aAllAxis[ nDimensionIndex ].resize( nIndex+1 );
+ m_aAllAxis[ nDimensionIndex ][nIndex] = nullptr;
+ }
+
+ rtl::Reference< Axis > xOldAxis( m_aAllAxis[ nDimensionIndex ][nIndex] );
+ if( xOldAxis.is())
+ ModifyListenerHelper::removeListener( xOldAxis, m_xModifyEventForwarder );
+ m_aAllAxis[ nDimensionIndex ][nIndex] = dynamic_cast<Axis*>(xAxis.get());
+ if( xAxis.is())
+ ModifyListenerHelper::addListener( xAxis, m_xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+void BaseCoordinateSystem::setAxisByDimension(
+ sal_Int32 nDimensionIndex,
+ const rtl::Reference< Axis >& xAxis,
+ sal_Int32 nIndex )
+{
+ if( nDimensionIndex < 0 || nDimensionIndex >= getDimension() )
+ throw lang::IndexOutOfBoundsException();
+
+ if( nIndex < 0 )
+ throw lang::IndexOutOfBoundsException();
+
if( m_aAllAxis[ nDimensionIndex ].size() < o3tl::make_unsigned( nIndex+1 ))
{
m_aAllAxis[ nDimensionIndex ].resize( nIndex+1 );
m_aAllAxis[ nDimensionIndex ][nIndex] = nullptr;
}
- Reference< chart2::XAxis > xOldAxis( m_aAllAxis[ nDimensionIndex ][nIndex] );
+ rtl::Reference< Axis > xOldAxis( m_aAllAxis[ nDimensionIndex ][nIndex] );
if( xOldAxis.is())
ModifyListenerHelper::removeListener( xOldAxis, m_xModifyEventForwarder );
m_aAllAxis[ nDimensionIndex ][nIndex] = xAxis;
@@ -226,6 +230,20 @@ Reference< chart2::XAxis > SAL_CALL BaseCoordinateSystem::getAxisByDimension(
return m_aAllAxis[ nDimensionIndex ][nAxisIndex];
}
+const rtl::Reference< Axis > & BaseCoordinateSystem::getAxisByDimension2(
+ sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
+{
+ if( nDimensionIndex < 0 || nDimensionIndex >= m_nDimensionCount )
+ throw lang::IndexOutOfBoundsException();
+
+ OSL_ASSERT( m_aAllAxis.size() == static_cast< size_t >( m_nDimensionCount));
+
+ if( nAxisIndex < 0 || o3tl::make_unsigned(nAxisIndex) > m_aAllAxis[ nDimensionIndex ].size() )
+ throw lang::IndexOutOfBoundsException();
+
+ return m_aAllAxis[ nDimensionIndex ][nAxisIndex];
+}
+
sal_Int32 SAL_CALL BaseCoordinateSystem::getMaximumAxisIndexByDimension( sal_Int32 nDimensionIndex )
{
if( nDimensionIndex < 0 || nDimensionIndex >= getDimension() )
@@ -243,19 +261,23 @@ sal_Int32 SAL_CALL BaseCoordinateSystem::getMaximumAxisIndexByDimension( sal_Int
// ____ XChartTypeContainer ____
void SAL_CALL BaseCoordinateSystem::addChartType( const Reference< chart2::XChartType >& aChartType )
{
- if( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), aChartType )
+ auto pChartType = dynamic_cast<ChartType*>(aChartType.get());
+ assert(pChartType);
+
+ if( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), pChartType )
!= m_aChartTypes.end())
throw lang::IllegalArgumentException("type not found", static_cast<cppu::OWeakObject*>(this), 1);
- m_aChartTypes.push_back( aChartType );
+ m_aChartTypes.push_back( pChartType );
ModifyListenerHelper::addListener( aChartType, m_xModifyEventForwarder );
fireModifyEvent();
}
void SAL_CALL BaseCoordinateSystem::removeChartType( const Reference< chart2::XChartType >& aChartType )
{
- std::vector< uno::Reference< chart2::XChartType > >::iterator
- aIt( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), aChartType ));
+ auto pChartType = dynamic_cast<ChartType*>(aChartType.get());
+ assert(pChartType);
+ auto aIt( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), pChartType ));
if( aIt == m_aChartTypes.end())
throw container::NoSuchElementException(
"The given chart type is no element of the container",
@@ -268,42 +290,43 @@ void SAL_CALL BaseCoordinateSystem::removeChartType( const Reference< chart2::XC
Sequence< Reference< chart2::XChartType > > SAL_CALL BaseCoordinateSystem::getChartTypes()
{
- return comphelper::containerToSequence( m_aChartTypes );
+ return comphelper::containerToSequence< Reference< chart2::XChartType > >( m_aChartTypes );
}
void SAL_CALL BaseCoordinateSystem::setChartTypes( const Sequence< Reference< chart2::XChartType > >& aChartTypes )
{
- ModifyListenerHelper::removeListenerFromAllElements( m_aChartTypes, m_xModifyEventForwarder );
- m_aChartTypes = comphelper::sequenceToContainer<std::vector< css::uno::Reference< css::chart2::XChartType > >>( aChartTypes );
- ModifyListenerHelper::addListenerToAllElements( m_aChartTypes, m_xModifyEventForwarder );
+ for (auto const & aChartType : m_aChartTypes)
+ aChartType->removeModifyListener( m_xModifyEventForwarder );
+ m_aChartTypes.clear();
+ for (auto const & aChartType : aChartTypes)
+ {
+ auto pChartType = dynamic_cast<ChartType*>(aChartType.get());
+ assert(pChartType);
+ m_aChartTypes.push_back(pChartType);
+ pChartType->addModifyListener( m_xModifyEventForwarder );
+ }
+ fireModifyEvent();
+}
+
+void BaseCoordinateSystem::setChartTypes( const std::vector< rtl::Reference< ChartType > >& aChartTypes )
+{
+ for (auto const & aChartType : m_aChartTypes)
+ aChartType->removeModifyListener( m_xModifyEventForwarder );
+ m_aChartTypes = aChartTypes;
+ for (auto const & aChartType : m_aChartTypes)
+ aChartType->addModifyListener( m_xModifyEventForwarder );
fireModifyEvent();
}
// ____ XModifyBroadcaster ____
void SAL_CALL BaseCoordinateSystem::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2" );
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL BaseCoordinateSystem::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2" );
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -330,25 +353,28 @@ void BaseCoordinateSystem::fireModifyEvent()
}
// ____ OPropertySet ____
-uno::Any BaseCoordinateSystem::GetDefaultValue( sal_Int32 nHandle ) const
+void BaseCoordinateSystem::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticCooSysDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticCooSysDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL BaseCoordinateSystem::getInfoHelper()
{
- return *StaticCooSysInfoHelper::get();
+ return StaticCooSysInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL BaseCoordinateSystem::getPropertySetInfo()
{
- return *StaticCooSysInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticCooSysInfoHelper() ) );
+ return xPropertySetInfo;
}
using impl::BaseCoordinateSystem_Base;
diff --git a/chart2/source/model/main/CartesianCoordinateSystem.cxx b/chart2/source/model/main/CartesianCoordinateSystem.cxx
index c65adee25829..1f1320d8ae69 100644
--- a/chart2/source/model/main/CartesianCoordinateSystem.cxx
+++ b/chart2/source/model/main/CartesianCoordinateSystem.cxx
@@ -31,7 +31,7 @@ namespace com::sun::star::uno { class XComponentContext; }
namespace
{
-constexpr OUStringLiteral CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME = u"com.sun.star.chart2.CoordinateSystems.Cartesian";
+constexpr OUString CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME = u"com.sun.star.chart2.CoordinateSystems.Cartesian"_ustr;
}
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index e5e518b63818..c0627abf7bbd 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -18,11 +18,15 @@
*/
#include <ChartModel.hxx>
+#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
#include <servicenames.hxx>
+#include <DataSource.hxx>
#include <DataSourceHelper.hxx>
#include <ChartModelHelper.hxx>
#include <DisposeHelper.hxx>
#include <ControllerLockGuard.hxx>
+#include <InternalDataProvider.hxx>
#include <ObjectIdentifier.hxx>
#include "PageBackground.hxx"
#include <CloneHelper.hxx>
@@ -31,6 +35,9 @@
#include <ChartView.hxx>
#include <PopupRequest.hxx>
#include <ModifyListenerHelper.hxx>
+#include <RangeHighlighter.hxx>
+#include <Diagram.hxx>
+#include <comphelper/dumpxmltostring.hxx>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp>
@@ -42,7 +49,6 @@
#include <svl/numformat.hxx>
#include <svl/numuno.hxx>
#include <com/sun/star/lang/DisposedException.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/embed/EmbedMapUnits.hpp>
#include <com/sun/star/embed/Aspects.hpp>
@@ -52,11 +58,10 @@
#include <com/sun/star/document/DocumentProperties.hpp>
#include <com/sun/star/util/CloseVetoException.hpp>
#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/chart2/XChartTypeTemplate.hpp>
#include <sal/log.hxx>
-#include <svl/zforlist.hxx>
-#include <tools/diagnose_ex.h>
+#include <utility>
+#include <comphelper/diagnose_ex.hxx>
#include <libxml/xmlwriter.h>
using ::com::sun::star::uno::Sequence;
@@ -66,14 +71,13 @@ using ::osl::MutexGuard;
using namespace ::com::sun::star;
using namespace ::apphelper;
-using namespace ::chart::CloneHelper;
namespace
{
-constexpr OUStringLiteral lcl_aGDIMetaFileMIMEType(
- u"application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"");
-constexpr OUStringLiteral lcl_aGDIMetaFileMIMETypeHighContrast(
- u"application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\"");
+constexpr OUString lcl_aGDIMetaFileMIMEType(
+ u"application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\""_ustr);
+constexpr OUString lcl_aGDIMetaFileMIMETypeHighContrast(
+ u"application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\""_ustr);
} // anonymous namespace
@@ -82,7 +86,7 @@ constexpr OUStringLiteral lcl_aGDIMetaFileMIMETypeHighContrast(
namespace chart
{
-ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
+ChartModel::ChartModel(uno::Reference<uno::XComponentContext > xContext)
: m_aLifeTimeManager( this, this )
, m_bReadOnly( false )
, m_bModified( false )
@@ -91,11 +95,10 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
, mbTimeBased(false)
, m_aControllers( m_aModelMutex )
, m_nControllerLockCount(0)
- , m_xContext( xContext )
+ , m_xContext(std::move( xContext ))
, m_aVisualAreaSize( ChartModelHelper::getDefaultPageSize() )
, m_xPageBackground( new PageBackground )
- , m_xXMLNamespaceMap( createNameContainer( ::cppu::UnoType<OUString>::get(),
- "com.sun.star.xml.NamespaceMap", "com.sun.star.comp.chart.XMLNameSpaceMap" ) )
+ , m_xXMLNamespaceMap( new NameContainer() )
, mnStart(0)
, mnEnd(0)
{
@@ -109,9 +112,8 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
}
{
- ModifyListenerHelper::addListener( m_xPageBackground, this );
- m_xChartTypeManager.set( xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.chart2.ChartTypeManager", m_xContext ), uno::UNO_QUERY );
+ m_xPageBackground->addModifyListener( this );
+ m_xChartTypeManager = new ::chart::ChartTypeManager( m_xContext );
}
osl_atomic_decrement(&m_refCount);
}
@@ -149,25 +151,34 @@ ChartModel::ChartModel( const ChartModel & rOther )
m_xOldModelAgg->setDelegator( *this );
Reference< util::XModifyListener > xListener;
- Reference< chart2::XTitle > xNewTitle = CreateRefClone< chart2::XTitle >()( rOther.m_xTitle );
- Reference< chart2::XDiagram > xNewDiagram = CreateRefClone< chart2::XDiagram >()( rOther.m_xDiagram );
- Reference< beans::XPropertySet > xNewPageBackground = CreateRefClone< beans::XPropertySet >()( rOther.m_xPageBackground );
- Reference< chart2::XChartTypeManager > xChartTypeManager = CreateRefClone< chart2::XChartTypeManager >()( rOther.m_xChartTypeManager );
- Reference< container::XNameAccess > xXMLNamespaceMap = CreateRefClone< container::XNameAccess >()( rOther.m_xXMLNamespaceMap );
+ rtl::Reference< Title > xNewTitle;
+ if ( rOther.m_xTitle )
+ xNewTitle = new Title(*rOther.m_xTitle);
+ rtl::Reference< ::chart::Diagram > xNewDiagram;
+ if (rOther.m_xDiagram.is())
+ xNewDiagram = new ::chart::Diagram( *rOther.m_xDiagram );
+ rtl::Reference< ::chart::PageBackground > xNewPageBackground = new PageBackground( *rOther.m_xPageBackground );
{
- MutexGuard aGuard( m_aModelMutex );
- xListener = this;
- m_xTitle = xNewTitle;
- m_xDiagram = xNewDiagram;
- m_xPageBackground = xNewPageBackground;
- m_xChartTypeManager = xChartTypeManager;
- m_xXMLNamespaceMap = xXMLNamespaceMap;
+ rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager; // does not implement XCloneable
+ rtl::Reference< ::chart::NameContainer > xXMLNamespaceMap = new NameContainer( *rOther.m_xXMLNamespaceMap );
+
+ {
+ MutexGuard aGuard( m_aModelMutex );
+ xListener = this;
+ m_xTitle = xNewTitle;
+ m_xDiagram = xNewDiagram;
+ m_xPageBackground = xNewPageBackground;
+ m_xChartTypeManager = std::move(xChartTypeManager);
+ m_xXMLNamespaceMap = std::move(xXMLNamespaceMap);
+ }
}
ModifyListenerHelper::addListener( xNewTitle, xListener );
- ModifyListenerHelper::addListener( xNewDiagram, xListener );
- ModifyListenerHelper::addListener( xNewPageBackground, xListener );
+ if( xNewDiagram && xListener)
+ xNewDiagram->addModifyListener( xListener );
+ if( xNewPageBackground && xListener)
+ xNewPageBackground->addModifyListener( xListener );
xListener.clear();
}
osl_atomic_decrement(&m_refCount);
@@ -189,9 +200,9 @@ void SAL_CALL ChartModel::initialize( const Sequence< Any >& /*rArguments*/ )
//support argument "DocumentRecoverySupport"?
}
-css::uno::Reference< css::uno::XInterface > ChartModel::getChartView() const
+ChartView* ChartModel::getChartView() const
{
- return static_cast< ::cppu::OWeakObject* >( mxChartView.get() );
+ return mxChartView.get();
}
// private methods
@@ -244,16 +255,11 @@ uno::Reference< frame::XController > ChartModel::impl_getCurrentController()
void ChartModel::impl_notifyCloseListeners()
{
- ::comphelper::OInterfaceContainerHelper2* pIC = m_aLifeTimeManager.m_aListenerContainer
- .getContainer( cppu::UnoType<util::XCloseListener>::get());
- if( pIC )
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ if( m_aLifeTimeManager.m_aCloseListeners.getLength(aGuard) )
{
lang::EventObject aEvent( static_cast< lang::XComponent*>(this) );
- ::comphelper::OInterfaceIteratorHelper2 aIt( *pIC );
- while( aIt.hasMoreElements() )
- {
- static_cast< util::XCloseListener* >( aIt.next() )->notifyClosing( aEvent );
- }
+ m_aLifeTimeManager.m_aCloseListeners.notifyEach(aGuard, &util::XCloseListener::notifyClosing, aEvent);
}
}
@@ -391,7 +397,11 @@ void SAL_CALL ChartModel::disconnectController( const uno::Reference< frame::XCo
if( m_xCurrentController == xController )
m_xCurrentController.clear();
- DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
+ if (m_xRangeHighlighter)
+ {
+ m_xRangeHighlighter->dispose();
+ m_xRangeHighlighter.clear();
+ }
DisposeHelper::DisposeAndClear(m_xPopupRequest);
}
@@ -476,7 +486,11 @@ void SAL_CALL ChartModel::setCurrentController( const uno::Reference< frame::XCo
m_xCurrentController = xController;
- DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
+ if (m_xRangeHighlighter)
+ {
+ m_xRangeHighlighter->dispose();
+ m_xRangeHighlighter.clear();
+ }
DisposeHelper::DisposeAndClear(m_xPopupRequest);
}
@@ -500,7 +514,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartModel::getCurrentSelection()
uno::Any aSel = xSelectionSupl->getSelection();
OUString aObjectCID;
if( aSel >>= aObjectCID )
- xReturn.set( ObjectIdentifier::getObjectPropertySet( aObjectCID, Reference< XChartDocument >(this)));
+ xReturn.set( ObjectIdentifier::getObjectPropertySet( aObjectCID, this));
}
}
return xReturn;
@@ -524,7 +538,7 @@ void SAL_CALL ChartModel::dispose()
//// @todo
if ( m_xDiagram.is() )
- ModifyListenerHelper::removeListener( m_xDiagram, this );
+ m_xDiagram->removeModifyListener( this );
if ( m_xDataProvider.is() )
{
@@ -536,12 +550,12 @@ void SAL_CALL ChartModel::dispose()
m_xDataProvider.clear();
m_xInternalDataProvider.clear();
m_xNumberFormatsSupplier.clear();
- DisposeHelper::DisposeAndClear( m_xOwnNumberFormatsSupplier );
- DisposeHelper::DisposeAndClear( m_xChartTypeManager );
- DisposeHelper::DisposeAndClear( m_xDiagram );
- DisposeHelper::DisposeAndClear( m_xTitle );
- DisposeHelper::DisposeAndClear( m_xPageBackground );
- DisposeHelper::DisposeAndClear( m_xXMLNamespaceMap );
+ m_xOwnNumberFormatsSupplier.clear();
+ m_xChartTypeManager.clear();
+ m_xDiagram.clear();
+ m_xTitle.clear();
+ m_xPageBackground.clear();
+ m_xXMLNamespaceMap.clear();
m_xStorage.clear();
// just clear, don't dispose - we're not the owner
@@ -557,7 +571,11 @@ void SAL_CALL ChartModel::dispose()
m_aControllers.disposeAndClear( lang::EventObject( static_cast< cppu::OWeakObject * >( this )));
m_xCurrentController.clear();
- DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
+ if (m_xRangeHighlighter)
+ {
+ m_xRangeHighlighter->dispose();
+ m_xRangeHighlighter.clear();
+ }
DisposeHelper::DisposeAndClear(m_xPopupRequest);
if( m_xOldModelAgg.is())
@@ -569,7 +587,8 @@ void SAL_CALL ChartModel::addEventListener( const uno::Reference< lang::XEventLi
if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.addInterface( cppu::UnoType<lang::XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aEventListeners.addInterface( aGuard, xListener );
}
void SAL_CALL ChartModel::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
@@ -577,7 +596,8 @@ void SAL_CALL ChartModel::removeEventListener( const uno::Reference< lang::XEven
if( m_aLifeTimeManager.impl_isDisposedOrClosed(false) )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.removeInterface( cppu::UnoType<lang::XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aEventListeners.removeInterface( aGuard, xListener );
}
// util::XCloseBroadcaster (base of XCloseable)
@@ -591,7 +611,8 @@ void SAL_CALL ChartModel::removeCloseListener( const uno::Reference< util::XClos
if( m_aLifeTimeManager.impl_isDisposedOrClosed(false) )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.removeInterface( cppu::UnoType<util::XCloseListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aCloseListeners.removeInterface( aGuard, xListener );
}
// util::XCloseable
@@ -669,18 +690,20 @@ uno::Reference< chart2::XDiagram > SAL_CALL ChartModel::getFirstDiagram()
void SAL_CALL ChartModel::setFirstDiagram( const uno::Reference< chart2::XDiagram >& xDiagram )
{
- Reference< chart2::XDiagram > xOldDiagram;
+ rtl::Reference< ::chart::Diagram > xOldDiagram;
Reference< util::XModifyListener > xListener;
{
MutexGuard aGuard( m_aModelMutex );
- if( xDiagram == m_xDiagram )
+ if( xDiagram.get() == m_xDiagram.get() )
return;
xOldDiagram = m_xDiagram;
- m_xDiagram = xDiagram;
+ assert(!xDiagram || dynamic_cast<::chart::Diagram*>(xDiagram.get()));
+ m_xDiagram = dynamic_cast<::chart::Diagram*>(xDiagram.get());
xListener = this;
}
//don't keep the mutex locked while calling out
- ModifyListenerHelper::removeListener( xOldDiagram, xListener );
+ if( xOldDiagram && xListener )
+ xOldDiagram->removeModifyListener( xListener );
ModifyListenerHelper::addListener( xDiagram, xListener );
setModified( true );
}
@@ -690,24 +713,20 @@ Reference< chart2::data::XDataSource > ChartModel::impl_createDefaultData()
Reference< chart2::data::XDataSource > xDataSource;
if( hasInternalDataProvider() )
{
- uno::Reference< lang::XInitialization > xIni(m_xInternalDataProvider,uno::UNO_QUERY);
- if( xIni.is() )
+ //init internal dataprovider
{
- //init internal dataprovider
- {
- beans::NamedValue aParam( "CreateDefaultData" ,uno::Any(true) );
- uno::Sequence< uno::Any > aArgs{ uno::Any(aParam) };
- xIni->initialize(aArgs);
- }
- //create data
- uno::Sequence<beans::PropertyValue> aArgs( comphelper::InitPropertySequence({
- { "CellRangeRepresentation", uno::Any( OUString("all") ) },
- { "HasCategories", uno::Any( true ) },
- { "FirstCellAsLabel", uno::Any( true ) },
- { "DataRowSource", uno::Any( css::chart::ChartDataRowSource_COLUMNS ) }
- }));
- xDataSource = m_xInternalDataProvider->createDataSource( aArgs );
+ beans::NamedValue aParam( "CreateDefaultData" ,uno::Any(true) );
+ uno::Sequence< uno::Any > aArgs{ uno::Any(aParam) };
+ m_xInternalDataProvider->initialize(aArgs);
}
+ //create data
+ uno::Sequence<beans::PropertyValue> aArgs( comphelper::InitPropertySequence({
+ { "CellRangeRepresentation", uno::Any( OUString("all") ) },
+ { "HasCategories", uno::Any( true ) },
+ { "FirstCellAsLabel", uno::Any( true ) },
+ { "DataRowSource", uno::Any( css::chart::ChartDataRowSource_COLUMNS ) }
+ }));
+ xDataSource = m_xInternalDataProvider->createDataSource( aArgs );
}
return xDataSource;
}
@@ -723,7 +742,7 @@ void SAL_CALL ChartModel::createInternalDataProvider( sal_Bool bCloneExistingDat
if( bCloneExistingData )
m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( this, true );
else
- m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( Reference<XChartDocument>(), true );
+ m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( nullptr, true );
m_xDataProvider.set( m_xInternalDataProvider );
}
setModified( true );
@@ -772,7 +791,7 @@ void SAL_CALL ChartModel::attachDataProvider( const uno::Reference< chart2::data
{
try
{
- bool bIncludeHiddenCells = ChartModelHelper::isIncludeHiddenCells( Reference< frame::XModel >(this) );
+ bool bIncludeHiddenCells = ChartModelHelper::isIncludeHiddenCells( this );
xProp->setPropertyValue("IncludeHiddenCells", uno::Any(bIncludeHiddenCells));
}
catch (const beans::UnknownPropertyException&)
@@ -798,9 +817,9 @@ void SAL_CALL ChartModel::attachNumberFormatsSupplier( const uno::Reference< uti
{
{
MutexGuard aGuard( m_aModelMutex );
- if( xNewSupplier==m_xNumberFormatsSupplier )
+ if( xNewSupplier == m_xNumberFormatsSupplier )
return;
- if( xNewSupplier==m_xOwnNumberFormatsSupplier )
+ if( xNewSupplier == uno::Reference<XNumberFormatsSupplier>(m_xOwnNumberFormatsSupplier) )
return;
if( m_xOwnNumberFormatsSupplier.is() && xNewSupplier.is() )
{
@@ -836,10 +855,10 @@ void SAL_CALL ChartModel::setArguments( const Sequence< beans::PropertyValue >&
Reference< chart2::data::XDataSource > xDataSource( m_xDataProvider->createDataSource( aArguments ) );
if( xDataSource.is() )
{
- Reference< chart2::XDiagram > xDia( getFirstDiagram() );
+ rtl::Reference< Diagram > xDia = getFirstChartDiagram();
if( !xDia.is() )
{
- Reference< chart2::XChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() );
+ rtl::Reference< ::chart::ChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() );
if( xTemplate.is())
setFirstDiagram( xTemplate->createDiagramByDataSource( xDataSource, aArguments ) );
}
@@ -862,22 +881,18 @@ void SAL_CALL ChartModel::setArguments( const Sequence< beans::PropertyValue >&
Sequence< OUString > SAL_CALL ChartModel::getUsedRangeRepresentations()
{
- return DataSourceHelper::getUsedDataRanges( Reference< frame::XModel >(this));
+ return DataSourceHelper::getUsedDataRanges( this );
}
Reference< chart2::data::XDataSource > SAL_CALL ChartModel::getUsedData()
{
- return DataSourceHelper::getUsedData( Reference< chart2::XChartDocument >(this));
+ return DataSourceHelper::getUsedData( *this );
}
Reference< chart2::data::XRangeHighlighter > SAL_CALL ChartModel::getRangeHighlighter()
{
if( ! m_xRangeHighlighter.is())
- {
- uno::Reference< view::XSelectionSupplier > xSelSupp( getCurrentController(), uno::UNO_QUERY );
- if( xSelSupp.is() )
- m_xRangeHighlighter.set( ChartModelHelper::createRangeHighlighter( xSelSupp ));
- }
+ m_xRangeHighlighter = new RangeHighlighter( this );
return m_xRangeHighlighter;
}
@@ -888,12 +903,11 @@ Reference<awt::XRequestCallback> SAL_CALL ChartModel::getPopupRequest()
return m_xPopupRequest;
}
-Reference< chart2::XChartTypeTemplate > ChartModel::impl_createDefaultChartTypeTemplate()
+rtl::Reference< ::chart::ChartTypeTemplate > ChartModel::impl_createDefaultChartTypeTemplate()
{
- Reference< chart2::XChartTypeTemplate > xTemplate;
- Reference< lang::XMultiServiceFactory > xFact( m_xChartTypeManager, uno::UNO_QUERY );
- if( xFact.is() )
- xTemplate.set( xFact->createInstance( "com.sun.star.chart2.template.Column" ), uno::UNO_QUERY );
+ rtl::Reference< ::chart::ChartTypeTemplate > xTemplate;
+ if( m_xChartTypeManager.is() )
+ xTemplate = m_xChartTypeManager->createTemplate( "com.sun.star.chart2.template.Column" );
return xTemplate;
}
@@ -901,7 +915,8 @@ void SAL_CALL ChartModel::setChartTypeManager( const uno::Reference< chart2::XCh
{
{
MutexGuard aGuard( m_aModelMutex );
- m_xChartTypeManager = xNewManager;
+ m_xChartTypeManager = dynamic_cast<::chart::ChartTypeManager*>(xNewManager.get());
+ assert(!xNewManager || m_xChartTypeManager);
}
setModified( true );
}
@@ -930,7 +945,20 @@ uno::Reference< chart2::XTitle > SAL_CALL ChartModel::getTitleObject()
return m_xTitle;
}
-void SAL_CALL ChartModel::setTitleObject( const uno::Reference< chart2::XTitle >& xTitle )
+rtl::Reference< Title > ChartModel::getTitleObject2() const
+{
+ MutexGuard aGuard( m_aModelMutex );
+ return m_xTitle;
+}
+
+void SAL_CALL ChartModel::setTitleObject( const uno::Reference< chart2::XTitle >& xNewTitle )
+{
+ rtl::Reference<Title> xTitle = dynamic_cast<Title*>(xNewTitle.get());
+ assert(!xNewTitle || xTitle);
+ setTitleObject(xTitle);
+}
+
+void ChartModel::setTitleObject( const rtl::Reference< Title >& xTitle )
{
{
MutexGuard aGuard( m_aModelMutex );
@@ -1141,7 +1169,7 @@ Reference< uno::XInterface > SAL_CALL ChartModel::createInstance( const OUString
}
break;
case SERVICE_NAMESPACE_MAP:
- return Reference< uno::XInterface >( m_xXMLNamespaceMap );
+ return static_cast<cppu::OWeakObject*>(m_xXMLNamespaceMap.get());
}
}
else if(rServiceSpecifier == CHART_VIEW_SERVICE_NAME)
@@ -1250,8 +1278,7 @@ void SAL_CALL ChartModel::setParent( const Reference< uno::XInterface >& Parent
// ____ XDataSource ____
uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL ChartModel::getDataSequences()
{
- Reference< chart2::data::XDataSource > xSource(
- DataSourceHelper::getUsedData( uno::Reference< frame::XModel >(this) ) );
+ rtl::Reference< DataSource > xSource = DataSourceHelper::getUsedData( *this );
if( xSource.is())
return xSource->getDataSequences();
@@ -1259,12 +1286,17 @@ uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL ChartM
}
//XDumper
-OUString SAL_CALL ChartModel::dump()
+OUString SAL_CALL ChartModel::dump(OUString const & kind)
{
+ if (kind.isEmpty()) {
+ return comphelper::dumpXmlToString([this](auto writer) { return dumpAsXml(writer); });
+ }
+
+ // kind == "shapes":
uno::Reference< qa::XDumper > xDumper(
createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
if (xDumper.is())
- return xDumper->dump();
+ return xDumper->dump(kind);
return OUString();
}
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index b246aa18f2b1..4fb17e9f1001 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -22,10 +22,15 @@
#include <MediaDescriptorHelper.hxx>
#include <ChartViewHelper.hxx>
#include <ChartModelHelper.hxx>
+#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
#include <DataSourceHelper.hxx>
#include <AxisHelper.hxx>
#include <ThreeDHelper.hxx>
-#include <DiagramHelper.hxx>
+#include <Diagram.hxx>
+#include <BaseCoordinateSystem.hxx>
+#include <Legend.hxx>
+#include <XMLFilter.hxx>
#include <com/sun/star/chart2/LegendPosition.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
@@ -41,8 +46,6 @@
#include <com/sun/star/io/IOException.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/io/TempFile.hpp>
-#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/ucb/CommandFailedException.hpp>
#include <com/sun/star/ucb/ContentCreationException.hpp>
@@ -50,12 +53,14 @@
#include <ucbhelper/content.hxx>
#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/tempfile.hxx>
+#include <utility>
#include <vcl/cvtgrf.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/storagehelper.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
#include <sfx2/objsh.hxx>
@@ -71,8 +76,8 @@ namespace
{
struct lcl_PropNameEquals
{
- explicit lcl_PropNameEquals( const OUString & rStrToCompareWith ) :
- m_aStr( rStrToCompareWith )
+ explicit lcl_PropNameEquals( OUString aStrToCompareWith ) :
+ m_aStr(std::move( aStrToCompareWith ))
{}
bool operator() ( const beans::PropertyValue & rProp )
{
@@ -195,10 +200,7 @@ Reference< document::XFilter > ChartModel::impl_createFilter(
if( ! xFilter.is())
{
SAL_WARN("chart2", "No FilterName passed in MediaDescriptor" );
- xFilter.set(
- m_xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.comp.chart2.XMLFilter", m_xContext ),
- uno::UNO_QUERY_THROW );
+ xFilter = new XMLFilter(m_xContext);
}
return xFilter;
@@ -299,8 +301,7 @@ void SAL_CALL ChartModel::storeToURL(
{
if( m_xContext.is() && aMediaDescriptorHelper.ISSET_OutputStream )
{
- Reference< io::XStream > xStream(
- io::TempFile::create(m_xContext), uno::UNO_QUERY_THROW );
+ rtl::Reference< utl::TempFileFastService > xStream = new utl::TempFileFastService;
Reference< io::XInputStream > xInputStream( xStream->getInputStream());
Reference< embed::XStorage > xStorage(
@@ -309,8 +310,7 @@ void SAL_CALL ChartModel::storeToURL(
{
impl_store( aReducedMediaDescriptor, xStorage );
- Reference< io::XSeekable > xSeekable( xStream, uno::UNO_QUERY_THROW );
- xSeekable->seek( 0 );
+ xStream->seek( 0 );
::comphelper::OStorageHelper::CopyInputToOutput( xInputStream, aMediaDescriptorHelper.OutputStream );
}
}
@@ -384,7 +384,7 @@ void ChartModel::insertDefaultChart()
try
{
// create default chart
- Reference< chart2::XChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() );
+ rtl::Reference< ::chart::ChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() );
if( xTemplate.is())
{
try
@@ -399,7 +399,7 @@ void ChartModel::insertDefaultChart()
beans::PropertyState_DIRECT_VALUE ) };
}
- Reference< chart2::XDiagram > xDiagram( xTemplate->createDiagramByDataSource( xDataSource, aParam ) );
+ rtl::Reference< Diagram > xDiagram( xTemplate->createDiagramByDataSource2( xDataSource, aParam ) );
setFirstDiagram( xDiagram );
@@ -409,30 +409,23 @@ void ChartModel::insertDefaultChart()
AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
// create and attach legend
- Reference< chart2::XLegend > xLegend(
- m_xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.chart2.Legend", m_xContext ), uno::UNO_QUERY_THROW );
- Reference< beans::XPropertySet > xLegendProperties( xLegend, uno::UNO_QUERY );
- if( xLegendProperties.is() )
- {
- xLegendProperties->setPropertyValue( "FillStyle", uno::Any( drawing::FillStyle_NONE ));
- xLegendProperties->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE ));
- xLegendProperties->setPropertyValue( "LineColor", uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) )); // gray30
- xLegendProperties->setPropertyValue( "FillColor", uno::Any( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
+ rtl::Reference< Legend > xLegend = new Legend();
+ xLegend->setPropertyValue( "FillStyle", uno::Any( drawing::FillStyle_NONE ));
+ xLegend->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE ));
+ xLegend->setPropertyValue( "LineColor", uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) )); // gray30
+ xLegend->setPropertyValue( "FillColor", uno::Any( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
- if( bIsRTL )
- xLegendProperties->setPropertyValue( "AnchorPosition", uno::Any( chart2::LegendPosition_LINE_START ));
- }
+ if( bIsRTL )
+ xLegend->setPropertyValue( "AnchorPosition", uno::Any( chart2::LegendPosition_LINE_START ));
if(xDiagram.is())
xDiagram->setLegend( xLegend );
// set simple 3D look
- Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY );
- if( xDiagramProperties.is() )
+ if( xDiagram.is() )
{
- xDiagramProperties->setPropertyValue( "RightAngledAxes", uno::Any( true ));
- xDiagramProperties->setPropertyValue( "D3DScenePerspective", uno::Any( drawing::ProjectionMode_PARALLEL ));
- ThreeDHelper::setScheme( xDiagram, ThreeDLookScheme::ThreeDLookScheme_Realistic );
+ xDiagram->setPropertyValue( "RightAngledAxes", uno::Any( true ));
+ xDiagram->setPropertyValue( "D3DScenePerspective", uno::Any( drawing::ProjectionMode_PARALLEL ));
+ xDiagram->setScheme( ThreeDLookScheme::ThreeDLookScheme_Realistic );
}
//set some new 'defaults' for wall and floor
@@ -642,16 +635,11 @@ void ChartModel::impl_notifyModifiedListeners()
//always notify the view first!
ChartViewHelper::setViewToDirtyState( this );
- ::comphelper::OInterfaceContainerHelper2* pIC = m_aLifeTimeManager.m_aListenerContainer
- .getContainer( cppu::UnoType<util::XModifyListener>::get());
- if( pIC )
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ if( m_aLifeTimeManager.m_aModifyListeners.getLength(aGuard) )
{
lang::EventObject aEvent( static_cast< lang::XComponent*>(this) );
- ::comphelper::OInterfaceIteratorHelper2 aIt( *pIC );
- while( aIt.hasMoreElements() )
- {
- static_cast< util::XModifyListener* >( aIt.next() )->modified( aEvent );
- }
+ m_aLifeTimeManager.m_aModifyListeners.notifyEach(aGuard, &util::XModifyListener::modified, aEvent);
}
}
@@ -680,7 +668,8 @@ void SAL_CALL ChartModel::setModified( sal_Bool bModified )
if( m_nControllerLockCount > 0 )
{
- m_bUpdateNotificationsPending = true;
+ if (bModified)
+ m_bUpdateNotificationsPending = true; // Maybe !bModified should reset it?
return;//don't call listeners if controllers are locked
}
aGuard.clear();
@@ -696,8 +685,8 @@ void SAL_CALL ChartModel::addModifyListener(
if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.addInterface(
- cppu::UnoType<util::XModifyListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aModifyListeners.addInterface( aGuard, xListener );
}
void SAL_CALL ChartModel::removeModifyListener(
@@ -706,8 +695,8 @@ void SAL_CALL ChartModel::removeModifyListener(
if( m_aLifeTimeManager.impl_isDisposedOrClosed(false) )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.removeInterface(
- cppu::UnoType<util::XModifyListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aModifyListeners.removeInterface( aGuard, xListener );
}
// util::XModifyListener
@@ -724,12 +713,11 @@ void SAL_CALL ChartModel::modified( const lang::EventObject& rEvenObject)
DataSourceHelper::createArguments("PivotChart", uno::Sequence<sal_Int32>(), true, true, true);
Reference<chart2::data::XDataSource> xDataSource(xDataProvider->createDataSource(aArguments));
- Reference<lang::XMultiServiceFactory> xFactory(getChartTypeManager(), uno::UNO_QUERY);
- Reference<chart2::XDiagram> xDiagram(getFirstDiagram());
+ rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = getTypeManager();
+ rtl::Reference<Diagram> xDiagram(getFirstChartDiagram());
- DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram(xDiagram, xFactory);
- css::uno::Reference<css::chart2::XChartTypeTemplate> xChartTypeTemplate(aTemplateAndService.first);
- xChartTypeTemplate->changeDiagramData(xDiagram, xDataSource, aArguments);
+ Diagram::tTemplateWithServiceName aTemplateAndService = xDiagram->getTemplate(xChartTypeManager);
+ aTemplateAndService.xChartTypeTemplate->changeDiagramData(xDiagram, xDataSource, aArguments);
}
catch (const uno::Exception &)
{
@@ -777,16 +765,14 @@ Reference< embed::XStorage > SAL_CALL ChartModel::getDocumentStorage()
void ChartModel::impl_notifyStorageChangeListeners()
{
- ::comphelper::OInterfaceContainerHelper2* pIC = m_aLifeTimeManager.m_aListenerContainer
- .getContainer( cppu::UnoType<document::XStorageChangeListener>::get());
- if( pIC )
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ if( m_aLifeTimeManager.m_aStorageChangeListeners.getLength(aGuard) )
{
- ::comphelper::OInterfaceIteratorHelper2 aIt( *pIC );
- while( aIt.hasMoreElements() )
- {
- static_cast< document::XStorageChangeListener* >( aIt.next() )
- ->notifyStorageChange( static_cast< ::cppu::OWeakObject* >( this ), m_xStorage );
- }
+ m_aLifeTimeManager.m_aStorageChangeListeners.forEach(aGuard,
+ [this](const uno::Reference<document::XStorageChangeListener>& l)
+ {
+ l->notifyStorageChange( static_cast< ::cppu::OWeakObject* >( this ), m_xStorage );
+ });
}
}
@@ -795,8 +781,8 @@ void SAL_CALL ChartModel::addStorageChangeListener( const Reference< document::X
if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.addInterface(
- cppu::UnoType<document::XStorageChangeListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aStorageChangeListeners.addInterface( aGuard, xListener );
}
void SAL_CALL ChartModel::removeStorageChangeListener( const Reference< document::XStorageChangeListener >& xListener )
@@ -804,8 +790,8 @@ void SAL_CALL ChartModel::removeStorageChangeListener( const Reference< document
if( m_aLifeTimeManager.impl_isDisposedOrClosed(false) )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.removeInterface(
- cppu::UnoType<document::XStorageChangeListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aStorageChangeListeners.removeInterface(aGuard, xListener );
}
} // namespace chart
diff --git a/chart2/source/model/main/DataPoint.cxx b/chart2/source/model/main/DataPoint.cxx
index 6e9f6d483ccc..d6c8a9e2ac3b 100644
--- a/chart2/source/model/main/DataPoint.cxx
+++ b/chart2/source/model/main/DataPoint.cxx
@@ -26,7 +26,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -39,45 +39,21 @@ using ::com::sun::star::beans::Property;
namespace
{
-struct StaticDataPointInfoHelper_Initializer
+::cppu::OPropertyArrayHelper& StaticDataPointInfoHelper()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- ::chart::DataPointProperties::AddPropertiesToVector( aProperties );
- ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::DataPointProperties::AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-struct StaticDataPointInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDataPointInfoHelper_Initializer >
-{
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticDataPointInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDataPointInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticDataPointInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticDataPointInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -86,9 +62,8 @@ namespace chart
{
DataPoint::DataPoint( const uno::Reference< beans::XPropertySet > & rParentProperties ) :
- ::property::OPropertySet( m_aMutex ),
m_xParentProperties( rParentProperties ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_bNoParentPropAllowed( false )
{
SetNewValuesExplicitlyEvenIfTheyEqualDefault();
@@ -96,8 +71,8 @@ DataPoint::DataPoint( const uno::Reference< beans::XPropertySet > & rParentPrope
DataPoint::DataPoint( const DataPoint & rOther ) :
impl::DataPoint_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_bNoParentPropAllowed( true )
{
SetNewValuesExplicitlyEvenIfTheyEqualDefault();
@@ -165,17 +140,18 @@ void SAL_CALL DataPoint::setParent(
}
// ____ OPropertySet ____
-uno::Any DataPoint::GetDefaultValue( sal_Int32 nHandle ) const
+void DataPoint::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
// the value set at the data series is the default
uno::Reference< beans::XFastPropertySet > xFast( m_xParentProperties.get(), uno::UNO_QUERY );
if( !xFast.is())
{
OSL_ENSURE( m_bNoParentPropAllowed, "data point needs a parent property set to provide values correctly" );
- return uno::Any();
+ rAny.clear();
+ return;
}
- return xFast->getFastPropertyValue( nHandle );
+ rAny = xFast->getFastPropertyValue( nHandle );
}
void SAL_CALL DataPoint::setFastPropertyValue_NoBroadcast(
@@ -208,40 +184,26 @@ void SAL_CALL DataPoint::setFastPropertyValue_NoBroadcast(
::cppu::IPropertyArrayHelper & SAL_CALL DataPoint::getInfoHelper()
{
- return *StaticDataPointInfoHelper::get();
+ return StaticDataPointInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL DataPoint::getPropertySetInfo()
{
- return *StaticDataPointInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDataPointInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XModifyBroadcaster ____
void SAL_CALL DataPoint::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL DataPoint::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
diff --git a/chart2/source/model/main/DataPoint.hxx b/chart2/source/model/main/DataPoint.hxx
index 4171571a1755..ba94449fff94 100644
--- a/chart2/source/model/main/DataPoint.hxx
+++ b/chart2/source/model/main/DataPoint.hxx
@@ -23,12 +23,10 @@
#include <comphelper/uno3.hxx>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
+#include <ModifyListenerHelper.hxx>
namespace chart
{
@@ -45,7 +43,6 @@ typedef ::cppu::WeakImplHelper<
}
class DataPoint final :
- public MutexContainer,
public impl::DataPoint_Base,
public ::property::OPropertySet
{
@@ -64,7 +61,7 @@ private:
explicit DataPoint( const DataPoint & rOther );
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
virtual void SAL_CALL setFastPropertyValue_NoBroadcast
( sal_Int32 nHandle,
@@ -103,7 +100,7 @@ private:
css::uno::WeakReference< css::beans::XPropertySet > m_xParentProperties;
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
+ rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder;
bool m_bNoParentPropAllowed;
};
diff --git a/chart2/source/model/main/DataPointProperties.cxx b/chart2/source/model/main/DataPointProperties.cxx
index 267bf9014dca..c27407c98fca 100644
--- a/chart2/source/model/main/DataPointProperties.cxx
+++ b/chart2/source/model/main/DataPointProperties.cxx
@@ -30,11 +30,14 @@
#include <com/sun/star/drawing/BitmapMode.hpp>
#include <com/sun/star/drawing/RectanglePoint.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
+#include <com/sun/star/chart2/RelativeSize.hpp>
#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
#include <com/sun/star/chart2/DataPointGeometry3D.hpp>
#include <com/sun/star/chart2/DataPointLabel.hpp>
#include <com/sun/star/chart2/Symbol.hpp>
+#include <tools/color.hxx>
+
using namespace ::com::sun::star;
using ::com::sun::star::beans::Property;
@@ -445,13 +448,18 @@ void DataPointProperties::AddPropertiesToVector(
cppu::UnoType<chart2::RelativePosition>::get(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back("CustomLabelSize", PROP_DATAPOINT_LABEL_CUSTOM_SIZE,
+ cppu::UnoType<chart2::RelativeSize>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID);
}
void DataPointProperties::AddDefaultsToMap(
::chart::tPropertyValueMap & rOutMap )
{
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DATAPOINT_COLOR, 0x0099ccff ); // blue 8
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_DATAPOINT_TRANSPARENCY, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_COLOR, Color(0x99, 0xcc, 0xff) ); // blue 8
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_TRANSPARENCY, sal_Int16(0) );
//fill
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_FILL_STYLE, drawing::FillStyle_SOLID );
@@ -462,29 +470,29 @@ void DataPointProperties::AddDefaultsToMap(
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_FILL_BACKGROUND, false );
//border
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DATAPOINT_BORDER_COLOR, 0x000000 ); // black
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_BORDER_COLOR, COL_BLACK );
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_BORDER_STYLE, drawing::LineStyle_SOLID ); // drawing::LineStyle_NONE
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DATAPOINT_BORDER_WIDTH, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_BORDER_WIDTH, sal_Int32(0) );
PropertyHelper::setEmptyPropertyValueDefault( rOutMap, PROP_DATAPOINT_BORDER_DASH_NAME );
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_DATAPOINT_BORDER_TRANSPARENCY, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_BORDER_TRANSPARENCY, sal_Int16(0) );
//line
PropertyHelper::setPropertyValueDefault( rOutMap, LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_SOLID );
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, LinePropertiesHelper::PROP_LINE_WIDTH, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, LinePropertiesHelper::PROP_LINE_WIDTH, sal_Int32(0) );
PropertyHelper::setPropertyValueDefault( rOutMap, LinePropertiesHelper::PROP_LINE_DASH, drawing::LineDash());
PropertyHelper::setEmptyPropertyValueDefault( rOutMap, LinePropertiesHelper::PROP_LINE_DASH_NAME );
PropertyHelper::setPropertyValueDefault( rOutMap, LinePropertiesHelper::PROP_LINE_CAP, drawing::LineCap_BUTT);
//fill bitmap
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETX, 0 );
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETY, 0 );
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETX, 0 );
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETY, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETX, sal_Int16(0) );
+ PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETY, sal_Int16(0) );
+ PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETX, sal_Int16(0) );
+ PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETY, sal_Int16(0) );
PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_RECTANGLEPOINT, drawing::RectanglePoint_MIDDLE_MIDDLE );
PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_LOGICALSIZE, true );
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEX, 0 );
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEY, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEX, sal_Int32(0) );
+ PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEY, sal_Int32(0) );
PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_MODE, drawing::BitmapMode_REPEAT );
//others
@@ -492,19 +500,19 @@ void DataPointProperties::AddDefaultsToMap(
aSymbProp.Style = chart2::SymbolStyle_NONE;
aSymbProp.StandardSymbol = 0;
aSymbProp.Size = awt::Size( 250, 250 ); // ca. 7pt x 7pt (7pt=246.94)
- aSymbProp.BorderColor = 0x000000; // Black
+ aSymbProp.BorderColor = sal_Int32(COL_BLACK);
aSymbProp.FillColor = 0xee4000; // OrangeRed2
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_SYMBOL_PROP, aSymbProp );
- PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_DATAPOINT_OFFSET, 0.0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_OFFSET, 0.0 );
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_GEOMETRY3D, chart2::DataPointGeometry3D::CUBOID );
//@todo maybe choose a different one here -> should be dynamically that of the attached axis
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_ERROR_BAR_X, uno::Reference< beans::XPropertySet >());
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_ERROR_BAR_Y, uno::Reference< beans::XPropertySet >());
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_DATAPOINT_PERCENT_DIAGONAL, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_PERCENT_DIAGONAL, sal_Int16(0) );
- PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_DATAPOINT_TEXT_ROTATION, 0.0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_TEXT_ROTATION, 0.0 );
PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LINK_NUMBERFORMAT_TO_SOURCE, true);
@@ -521,17 +529,17 @@ void DataPointProperties::AddDefaultsToMap(
));
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_TEXT_WORD_WRAP, false );
- PropertyHelper::setPropertyValueDefault< OUString >( rOutMap, PROP_DATAPOINT_LABEL_SEPARATOR, " " );
- PropertyHelper::setPropertyValueDefault<sal_Int32>(rOutMap, PROP_DATAPOINT_LABEL_BORDER_STYLE, sal_Int32(drawing::LineStyle_NONE));
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_LABEL_SEPARATOR, OUString(" ") );
+ PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_STYLE, drawing::LineStyle_NONE);
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_COLOR);
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_FILL_STYLE);
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_FILL_COLOR);
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_FILL_BACKGROUND);
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_FILL_HATCH_NAME);
- PropertyHelper::setPropertyValueDefault<sal_Int32>(rOutMap, PROP_DATAPOINT_LABEL_BORDER_WIDTH, 0);
+ PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_WIDTH, sal_Int32(0));
PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_DASH, drawing::LineDash());
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_DASH_NAME);
- PropertyHelper::setPropertyValueDefault<sal_Int16>(rOutMap, PROP_DATAPOINT_LABEL_BORDER_TRANS, 0);
+ PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_TRANS, sal_Int16(0));
uno::Sequence<uno::Reference<chart2::XDataPointCustomLabelField>> aFields(0);
PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_CUSTOM_LABEL_FIELDS, aFields);
diff --git a/chart2/source/model/main/DataPointProperties.hxx b/chart2/source/model/main/DataPointProperties.hxx
index ada7907b888f..1689322148d8 100644
--- a/chart2/source/model/main/DataPointProperties.hxx
+++ b/chart2/source/model/main/DataPointProperties.hxx
@@ -87,7 +87,8 @@ namespace DataPointProperties
PROP_DATAPOINT_LABEL_BORDER_DASH_NAME,
PROP_DATAPOINT_LABEL_BORDER_TRANS,
PROP_DATAPOINT_CUSTOM_LABEL_FIELDS,
- PROP_DATAPOINT_LABEL_CUSTOM_POS
+ PROP_DATAPOINT_LABEL_CUSTOM_POS,
+ PROP_DATAPOINT_LABEL_CUSTOM_SIZE
// additionally some properties from ::chart::LineProperties
};
diff --git a/chart2/source/model/main/DataSeries.cxx b/chart2/source/model/main/DataSeries.cxx
index b873c19650b9..38f2c474b47a 100644
--- a/chart2/source/model/main/DataSeries.cxx
+++ b/chart2/source/model/main/DataSeries.cxx
@@ -18,20 +18,22 @@
*/
#include <DataSeries.hxx>
-#include "DataSeriesProperties.hxx"
+#include <DataSeriesProperties.hxx>
#include "DataPointProperties.hxx"
#include <CharacterProperties.hxx>
#include <UserDefinedProperties.hxx>
#include "DataPoint.hxx"
#include <DataSeriesHelper.hxx>
#include <CloneHelper.hxx>
+#include <RegressionCurveModel.hxx>
#include <ModifyListenerHelper.hxx>
-#include <EventListenerHelper.hxx>
+#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
#include <com/sun/star/container/NoSuchElementException.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <rtl/ref.hxx>
+#include <rtl/ustrbuf.hxx>
#include <algorithm>
@@ -44,46 +46,43 @@ using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Reference;
using ::osl::MutexGuard;
-namespace
+namespace chart
{
-
-struct StaticDataSeriesDefaults : public rtl::StaticWithInit< ::chart::tPropertyValueMap, StaticDataSeriesDefaults >
+const ::chart::tPropertyValueMap & StaticDataSeriesDefaults()
{
- ::chart::tPropertyValueMap operator()()
- {
- ::chart::tPropertyValueMap aStaticDefaults;
- ::chart::DataSeriesProperties::AddDefaultsToMap( aStaticDefaults );
- ::chart::CharacterProperties::AddDefaultsToMap( aStaticDefaults );
- float fDefaultCharHeight = 10.0;
- ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
- return aStaticDefaults;
- }
+ static const ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aMap;
+ ::chart::DataSeriesProperties::AddDefaultsToMap( aMap );
+ ::chart::CharacterProperties::AddDefaultsToMap( aMap );
+ float fDefaultCharHeight = 10.0;
+ ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
+ return aMap;
+ }();
+ return aStaticDefaults;
};
+} // namespace chart
-struct StaticDataSeriesInfoHelper : public rtl::StaticWithInit< ::cppu::OPropertyArrayHelper, StaticDataSeriesInfoHelper, StaticDataSeriesInfoHelper, uno::Sequence< Property > >
+namespace
{
- uno::Sequence< Property > operator()()
- {
- std::vector< css::beans::Property > aProperties;
- ::chart::DataSeriesProperties::AddPropertiesToVector( aProperties );
- ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
+::cppu::OPropertyArrayHelper& StaticDataSeriesInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper oHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::DataSeriesProperties::AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
- return comphelper::containerToSequence( aProperties );
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticDataSeriesInfo : public rtl::StaticWithInit< uno::Reference< beans::XPropertySetInfo >, StaticDataSeriesInfo >
-{
- uno::Reference< beans::XPropertySetInfo > operator()()
- {
- return ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDataSeriesInfoHelper::get() );
- }
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return oHelper;
};
void lcl_SetParent(
@@ -127,24 +126,22 @@ namespace chart
{
DataSeries::DataSeries() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
}
DataSeries::DataSeries( const DataSeries & rOther ) :
impl::DataSeries_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
if( ! rOther.m_aDataSequences.empty())
{
- CloneHelper::CloneRefVector<css::chart2::data::XLabeledDataSequence>(
- rOther.m_aDataSequences, m_aDataSequences );
+ CloneHelper::CloneRefVector(rOther.m_aDataSequences, m_aDataSequences );
ModifyListenerHelper::addListenerToAllElements( m_aDataSequences, m_xModifyEventForwarder );
}
- CloneHelper::CloneRefVector< chart2::XRegressionCurve >( rOther.m_aRegressionCurves, m_aRegressionCurves );
+ CloneHelper::CloneRefVector( rOther.m_aRegressionCurves, m_aRegressionCurves );
ModifyListenerHelper::addListenerToAllElements( m_aRegressionCurves, m_xModifyEventForwarder );
// add as listener to XPropertySet properties
@@ -165,9 +162,6 @@ DataSeries::DataSeries( const DataSeries & rOther ) :
// late initialization to call after copy-constructing
void DataSeries::Init( const DataSeries & rOther )
{
- if( ! rOther.m_aDataSequences.empty())
- EventListenerHelper::addListenerToAllElements( m_aDataSequences, this );
-
Reference< uno::XInterface > xThisInterface( static_cast< ::cppu::OWeakObject * >( this ));
if( ! rOther.m_aAttributedDataPoints.empty())
{
@@ -230,25 +224,28 @@ uno::Reference< util::XCloneable > SAL_CALL DataSeries::createClone()
}
// ____ OPropertySet ____
-uno::Any DataSeries::GetDefaultValue( sal_Int32 nHandle ) const
+void DataSeries::GetDefaultValue( sal_Int32 nHandle, uno::Any& rDest ) const
{
- const tPropertyValueMap& rStaticDefaults = StaticDataSeriesDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticDataSeriesDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rDest.clear();
+ else
+ rDest = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL DataSeries::getInfoHelper()
{
- return StaticDataSeriesInfoHelper::get();
+ return StaticDataSeriesInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL DataSeries::getPropertySetInfo()
{
- return StaticDataSeriesInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropSetInfo =
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDataSeriesInfoHelper() );
+ return xPropSetInfo;
}
void SAL_CALL DataSeries::getFastPropertyValue
@@ -299,13 +296,13 @@ Reference< beans::XPropertySet >
{
Reference< beans::XPropertySet > xResult;
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences;
{
MutexGuard aGuard( m_aMutex );
- aSequences = comphelper::containerToSequence( m_aDataSequences );
+ aSequences = m_aDataSequences;
}
- std::vector< Reference< chart2::data::XLabeledDataSequence > > aValuesSeries(
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aValuesSeries(
DataSeriesHelper::getAllDataSequencesByRole( aSequences , "values" ) );
if (aValuesSeries.empty())
@@ -387,18 +384,34 @@ void SAL_CALL DataSeries::setData( const uno::Sequence< Reference< chart2::data:
tDataSequenceContainer aOldDataSequences;
tDataSequenceContainer aNewDataSequences;
Reference< util::XModifyListener > xModifyEventForwarder;
- Reference< lang::XEventListener > xListener;
{
MutexGuard aGuard( m_aMutex );
xModifyEventForwarder = m_xModifyEventForwarder;
- xListener = this;
std::swap( aOldDataSequences, m_aDataSequences );
- aNewDataSequences = comphelper::sequenceToContainer<tDataSequenceContainer>( aData );
+ for (const auto & i : aData)
+ {
+ aNewDataSequences.push_back(i);
+ }
+ m_aDataSequences = aNewDataSequences;
+ }
+ ModifyListenerHelper::removeListenerFromAllElements( aOldDataSequences, xModifyEventForwarder );
+ ModifyListenerHelper::addListenerToAllElements( aNewDataSequences, xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+void DataSeries::setData( const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > >& aData )
+{
+ tDataSequenceContainer aOldDataSequences;
+ tDataSequenceContainer aNewDataSequences;
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ {
+ MutexGuard aGuard( m_aMutex );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ std::swap( aOldDataSequences, m_aDataSequences );
+ aNewDataSequences = aData;
m_aDataSequences = aNewDataSequences;
}
ModifyListenerHelper::removeListenerFromAllElements( aOldDataSequences, xModifyEventForwarder );
- EventListenerHelper::removeListenerFromAllElements( aOldDataSequences, xListener );
- EventListenerHelper::addListenerToAllElements( aNewDataSequences, xListener );
ModifyListenerHelper::addListenerToAllElements( aNewDataSequences, xModifyEventForwarder );
fireModifyEvent();
}
@@ -407,23 +420,25 @@ void SAL_CALL DataSeries::setData( const uno::Sequence< Reference< chart2::data:
Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL DataSeries::getDataSequences()
{
MutexGuard aGuard( m_aMutex );
- return comphelper::containerToSequence( m_aDataSequences );
+ return comphelper::containerToSequence<Reference< chart2::data::XLabeledDataSequence >>( m_aDataSequences );
}
// ____ XRegressionCurveContainer ____
void SAL_CALL DataSeries::addRegressionCurve(
const uno::Reference< chart2::XRegressionCurve >& xRegressionCurve )
{
+ auto pRegressionCurve = dynamic_cast<RegressionCurveModel*>(xRegressionCurve.get());
+ assert(pRegressionCurve);
Reference< util::XModifyListener > xModifyEventForwarder;
{
MutexGuard aGuard( m_aMutex );
xModifyEventForwarder = m_xModifyEventForwarder;
- if( std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), xRegressionCurve )
+ if( std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), pRegressionCurve )
!= m_aRegressionCurves.end())
throw lang::IllegalArgumentException("curve not found", static_cast<cppu::OWeakObject*>(this), 1);
- m_aRegressionCurves.push_back( xRegressionCurve );
+ m_aRegressionCurves.push_back( pRegressionCurve );
}
- ModifyListenerHelper::addListener( xRegressionCurve, xModifyEventForwarder );
+ ModifyListenerHelper::addListener( rtl::Reference<RegressionCurveModel>(pRegressionCurve), xModifyEventForwarder );
fireModifyEvent();
}
@@ -432,13 +447,15 @@ void SAL_CALL DataSeries::removeRegressionCurve(
{
if( !xRegressionCurve.is() )
throw container::NoSuchElementException();
+ auto pRegressionCurve = dynamic_cast<RegressionCurveModel*>(xRegressionCurve.get());
+ assert(pRegressionCurve);
Reference< util::XModifyListener > xModifyEventForwarder;
{
MutexGuard aGuard( m_aMutex );
xModifyEventForwarder = m_xModifyEventForwarder;
tRegressionCurveContainerType::iterator aIt(
- std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), xRegressionCurve ) );
+ std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), pRegressionCurve ) );
if( aIt == m_aRegressionCurves.end())
throw container::NoSuchElementException(
"The given regression curve is no element of this series",
@@ -446,21 +463,27 @@ void SAL_CALL DataSeries::removeRegressionCurve(
m_aRegressionCurves.erase( aIt );
}
- ModifyListenerHelper::removeListener( xRegressionCurve, xModifyEventForwarder );
+ ModifyListenerHelper::removeListener( rtl::Reference<RegressionCurveModel>(pRegressionCurve), xModifyEventForwarder );
fireModifyEvent();
}
uno::Sequence< uno::Reference< chart2::XRegressionCurve > > SAL_CALL DataSeries::getRegressionCurves()
{
MutexGuard aGuard( m_aMutex );
- return comphelper::containerToSequence( m_aRegressionCurves );
+ return comphelper::containerToSequence<uno::Reference< chart2::XRegressionCurve >>( m_aRegressionCurves );
}
void SAL_CALL DataSeries::setRegressionCurves(
const Sequence< Reference< chart2::XRegressionCurve > >& aRegressionCurves )
{
tRegressionCurveContainerType aOldCurves;
- auto aNewCurves( comphelper::sequenceToContainer<tRegressionCurveContainerType>( aRegressionCurves ) );
+ tRegressionCurveContainerType aNewCurves;
+ for (const auto & i : aRegressionCurves)
+ {
+ auto pRegressionCurve = dynamic_cast<RegressionCurveModel*>(i.get());
+ assert(pRegressionCurve);
+ aNewCurves.push_back(pRegressionCurve);
+ }
Reference< util::XModifyListener > xModifyEventForwarder;
{
MutexGuard aGuard( m_aMutex );
@@ -476,28 +499,12 @@ void SAL_CALL DataSeries::setRegressionCurves(
// ____ XModifyBroadcaster ____
void SAL_CALL DataSeries::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL DataSeries::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -507,13 +514,8 @@ void SAL_CALL DataSeries::modified( const lang::EventObject& aEvent )
}
// ____ XEventListener (base of XModifyListener) ____
-void SAL_CALL DataSeries::disposing( const lang::EventObject& rEventObject )
+void SAL_CALL DataSeries::disposing( const lang::EventObject& )
{
- // forget disposed data sequences
- tDataSequenceContainer::iterator aIt(
- std::find( m_aDataSequences.begin(), m_aDataSequences.end(), rEventObject.Source ));
- if( aIt != m_aDataSequences.end())
- m_aDataSequences.erase( aIt );
}
// ____ OPropertySet ____
@@ -552,6 +554,173 @@ css::uno::Sequence< OUString > SAL_CALL DataSeries::getSupportedServiceNames()
"com.sun.star.beans.PropertySet" };
}
+static Reference< chart2::data::XLabeledDataSequence > lcl_findLSequenceWithOnlyLabel(
+ const Sequence< Reference< chart2::data::XLabeledDataSequence > > & rDataSequences )
+{
+ Reference< chart2::data::XLabeledDataSequence > xResult;
+
+ for( auto const & labeledData : rDataSequences )
+ {
+ OSL_ENSURE( labeledData.is(), "empty LabeledDataSequence" );
+ // no values are set but a label exists
+ if( labeledData.is() &&
+ ( ! labeledData->getValues().is() &&
+ labeledData->getLabel().is()))
+ {
+ xResult.set( labeledData );
+ break;
+ }
+ }
+
+ return xResult;
+}
+
+static OUString lcl_getDataSequenceLabel( const Reference< chart2::data::XDataSequence > & xSequence )
+{
+ OUString aResult;
+
+ Reference< chart2::data::XTextualDataSequence > xTextSeq( xSequence, uno::UNO_QUERY );
+ if( xTextSeq.is())
+ {
+ Sequence< OUString > aSeq( xTextSeq->getTextualData());
+
+ const sal_Int32 nMax = aSeq.getLength() - 1;
+ OUStringBuffer aBuf;
+
+ for( sal_Int32 i = 0; i <= nMax; ++i )
+ {
+ aBuf.append( aSeq[i] );
+ if( i < nMax )
+ aBuf.append( ' ');
+ }
+ aResult = aBuf.makeStringAndClear();
+ }
+ else if( xSequence.is())
+ {
+ Sequence< uno::Any > aSeq( xSequence->getData());
+
+ const sal_Int32 nMax = aSeq.getLength() - 1;
+ OUString aVal;
+ OUStringBuffer aBuf;
+ double fNum = 0;
+
+ for( sal_Int32 i = 0; i <= nMax; ++i )
+ {
+ if( aSeq[i] >>= aVal )
+ {
+ aBuf.append( aVal );
+ if( i < nMax )
+ aBuf.append( ' ');
+ }
+ else if( aSeq[ i ] >>= fNum )
+ {
+ aBuf.append( fNum );
+ if( i < nMax )
+ aBuf.append( ' ');
+ }
+ }
+ aResult = aBuf.makeStringAndClear();
+ }
+
+ return aResult;
+}
+
+static OUString getLabelForLabeledDataSequence(
+ const Reference< chart2::data::XLabeledDataSequence > & xLabeledSeq )
+{
+ OUString aResult;
+ if( xLabeledSeq.is())
+ {
+ Reference< chart2::data::XDataSequence > xSeq( xLabeledSeq->getLabel());
+ if( xSeq.is() )
+ aResult = lcl_getDataSequenceLabel( xSeq );
+ if( !xSeq.is() || aResult.isEmpty() )
+ {
+ // no label set or label content is empty -> use auto-generated one
+ Reference< chart2::data::XDataSequence > xValueSeq( xLabeledSeq->getValues() );
+ if( xValueSeq.is() )
+ {
+ Sequence< OUString > aLabels( xValueSeq->generateLabel(
+ chart2::data::LabelOrigin_SHORT_SIDE ) );
+ // no labels returned is interpreted as: auto-generation not
+ // supported by sequence
+ if( aLabels.hasElements() )
+ aResult=aLabels[0];
+ else
+ {
+ //todo?: maybe use the index of the series as name
+ //but as the index may change it would be better to have such a name persistent
+ //what is not possible at the moment
+ //--> maybe use the identifier as part of the name ...
+ aResult = lcl_getDataSequenceLabel( xValueSeq );
+ }
+ }
+ }
+ }
+ return aResult;
+}
+
+OUString DataSeries::getLabelForRole( const OUString & rLabelSequenceRole )
+{
+ OUString aResult;
+
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
+ ::chart::DataSeriesHelper::getDataSequenceByRole( this, rLabelSequenceRole ));
+ if( xLabeledSeq.is())
+ aResult = getLabelForLabeledDataSequence( xLabeledSeq );
+ else
+ {
+ // special case: labeled data series with only a label and no values may
+ // serve as label
+ xLabeledSeq.set( lcl_findLSequenceWithOnlyLabel( getDataSequences() ));
+ if( xLabeledSeq.is())
+ {
+ Reference< chart2::data::XDataSequence > xSeq( xLabeledSeq->getLabel());
+ if( xSeq.is())
+ aResult = lcl_getDataSequenceLabel( xSeq );
+ }
+ }
+
+ return aResult;
+}
+
+static bool lcl_SequenceHasUnhiddenData( const uno::Reference< chart2::data::XDataSequence >& xDataSequence )
+{
+ if (!xDataSequence.is())
+ return false;
+ uno::Reference< beans::XPropertySet > xProp( xDataSequence, uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ uno::Sequence< sal_Int32 > aHiddenValues;
+ try
+ {
+ xProp->getPropertyValue( "HiddenValues" ) >>= aHiddenValues;
+ if( !aHiddenValues.hasElements() )
+ return true;
+ }
+ catch( const uno::Exception& )
+ {
+ return true;
+ }
+ }
+ return xDataSequence->getData().hasElements();
+}
+
+bool DataSeries::hasUnhiddenData()
+{
+ MutexGuard aGuard( m_aMutex );
+
+ for(uno::Reference< chart2::data::XLabeledDataSequence > const & rDataSequence : m_aDataSequences)
+ {
+ if( !rDataSequence.is() )
+ continue;
+ if( lcl_SequenceHasUnhiddenData( rDataSequence->getValues() ) )
+ return true;
+ }
+ return false;
+}
+
+
} // namespace chart
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
diff --git a/chart2/source/model/main/DataSeriesProperties.cxx b/chart2/source/model/main/DataSeriesProperties.cxx
index d85d264753c1..e6d40feb5ab6 100644
--- a/chart2/source/model/main/DataSeriesProperties.cxx
+++ b/chart2/source/model/main/DataSeriesProperties.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "DataSeriesProperties.hxx"
+#include <DataSeriesProperties.hxx>
#include "DataPointProperties.hxx"
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/chart2/StackingDirection.hpp>
@@ -84,7 +84,7 @@ void DataSeriesProperties::AddDefaultsToMap(
{
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATASERIES_STACKING_DIRECTION, chart2::StackingDirection_NO_STACKING );
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATASERIES_VARY_COLORS_BY_POINT, false );
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DATASERIES_ATTACHED_AXIS_INDEX, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATASERIES_ATTACHED_AXIS_INDEX, sal_Int32(0) );
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATASERIES_SHOW_LEGEND_ENTRY, true );
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES, true );
diff --git a/chart2/source/model/main/DataSeriesProperties.hxx b/chart2/source/model/main/DataSeriesProperties.hxx
deleted file mode 100644
index 13636d442fb5..000000000000
--- a/chart2/source/model/main/DataSeriesProperties.hxx
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- 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 <PropertyHelper.hxx>
-#include <FastPropertyIdRanges.hxx>
-
-#include <vector>
-
-namespace com::sun::star::beans { struct Property; }
-
-namespace chart::DataSeriesProperties
-{
- enum
- {
- PROP_DATASERIES_ATTRIBUTED_DATA_POINTS = FAST_PROPERTY_ID_START_DATA_SERIES,
- PROP_DATASERIES_STACKING_DIRECTION,
- PROP_DATASERIES_VARY_COLORS_BY_POINT,
- PROP_DATASERIES_ATTACHED_AXIS_INDEX,
- PROP_DATASERIES_SHOW_LEGEND_ENTRY,
- PROP_DATASERIES_DELETED_LEGEND_ENTRIES,
- PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES
- };
-
- void AddPropertiesToVector(
- std::vector< css::beans::Property > & rOutProperties );
-
- void AddDefaultsToMap( tPropertyValueMap & rOutMap );
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/DataTable.cxx b/chart2/source/model/main/DataTable.cxx
new file mode 100644
index 000000000000..6cec190615bd
--- /dev/null
+++ b/chart2/source/model/main/DataTable.cxx
@@ -0,0 +1,209 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <DataTable.hxx>
+
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <CharacterProperties.hxx>
+#include <ModifyListenerHelper.hxx>
+#include <PropertyHelper.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+
+#include <algorithm>
+
+using namespace css;
+
+namespace
+{
+/** DataTable Properties */
+enum
+{
+ DataTableProperty_HorizontalBorder,
+ DataTableProperty_VerticalBorder,
+ DataTableProperty_Outilne,
+ DataTableProperty_Keys,
+};
+
+void lcl_AddPropertiesToVector(std::vector<beans::Property>& rProps)
+{
+ auto const nBound = beans::PropertyAttribute::BOUND;
+ auto const nMaybeDefault = beans::PropertyAttribute::MAYBEDEFAULT;
+
+ rProps.emplace_back("HBorder", DataTableProperty_HorizontalBorder, cppu::UnoType<bool>::get(),
+ nBound | nMaybeDefault);
+ rProps.emplace_back("VBorder", DataTableProperty_VerticalBorder, cppu::UnoType<bool>::get(),
+ nBound | nMaybeDefault);
+ rProps.emplace_back("Outline", DataTableProperty_Outilne, cppu::UnoType<bool>::get(),
+ nBound | nMaybeDefault);
+ rProps.emplace_back("Keys", DataTableProperty_Keys, cppu::UnoType<bool>::get(),
+ nBound | nMaybeDefault);
+}
+
+const ::chart::tPropertyValueMap& StaticDataTableDefaults()
+{
+ static ::chart::tPropertyValueMap aStaticDefaults = []() {
+ ::chart::tPropertyValueMap aMap;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap(aMap);
+ ::chart::FillProperties::AddDefaultsToMap(aMap);
+ ::chart::CharacterProperties::AddDefaultsToMap(aMap);
+
+ ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_HorizontalBorder,
+ false);
+ ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_VerticalBorder,
+ false);
+ ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Outilne, false);
+ ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Keys, false);
+
+ ::chart::PropertyHelper::setPropertyValue(
+ aMap, ::chart::LinePropertiesHelper::PROP_LINE_WIDTH, uno::Any(sal_Int32(1)));
+
+ ::chart::PropertyHelper::setPropertyValueDefault(
+ aMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE);
+
+ float fDefaultCharHeight = 10.0;
+ ::chart::PropertyHelper::setPropertyValue(
+ aMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight);
+ ::chart::PropertyHelper::setPropertyValue(
+ aMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight);
+ ::chart::PropertyHelper::setPropertyValue(
+ aMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight);
+ return aMap;
+ }();
+ return aStaticDefaults;
+};
+
+cppu::OPropertyArrayHelper& StaticDataTableInfoHelper()
+{
+ static cppu::OPropertyArrayHelper aPropHelper = []() {
+ std::vector<beans::Property> aProperties;
+ lcl_AddPropertiesToVector(aProperties);
+ ::chart::LinePropertiesHelper::AddPropertiesToVector(aProperties);
+ ::chart::FillProperties::AddPropertiesToVector(aProperties);
+ ::chart::CharacterProperties::AddPropertiesToVector(aProperties);
+ std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess());
+
+ return comphelper::containerToSequence(aProperties);
+ }();
+ return aPropHelper;
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+DataTable::DataTable()
+ : m_xModifyEventForwarder(new ModifyEventForwarder())
+{
+}
+
+DataTable::DataTable(const DataTable& rOther)
+ : DataTable_Base(rOther)
+ , ::property::OPropertySet(rOther)
+ , m_xModifyEventForwarder(new ModifyEventForwarder())
+{
+}
+
+DataTable::~DataTable() = default;
+
+// ____ XCloneable ____
+uno::Reference<util::XCloneable> SAL_CALL DataTable::createClone()
+{
+ return uno::Reference<util::XCloneable>(new DataTable(*this));
+}
+
+// ____ XModifyBroadcaster ____
+void SAL_CALL DataTable::addModifyListener(const uno::Reference<util::XModifyListener>& aListener)
+{
+ m_xModifyEventForwarder->addModifyListener(aListener);
+}
+
+void SAL_CALL
+DataTable::removeModifyListener(const uno::Reference<util::XModifyListener>& aListener)
+{
+ m_xModifyEventForwarder->removeModifyListener(aListener);
+}
+
+// ____ XModifyListener ____
+void SAL_CALL DataTable::modified(const lang::EventObject& aEvent)
+{
+ m_xModifyEventForwarder->modified(aEvent);
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL DataTable::disposing(const lang::EventObject& /* Source */)
+{
+ // nothing
+}
+
+// ____ OPropertySet ____
+void DataTable::firePropertyChangeEvent()
+{
+ m_xModifyEventForwarder->modified(lang::EventObject(static_cast<uno::XWeak*>(this)));
+}
+
+// ____ OPropertySet ____
+void DataTable::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const
+{
+ const tPropertyValueMap& rStaticDefaults = StaticDataTableDefaults();
+ auto aFound = rStaticDefaults.find(nHandle);
+ if (aFound == rStaticDefaults.end())
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper& SAL_CALL DataTable::getInfoHelper()
+{
+ return StaticDataTableInfoHelper();
+}
+
+// ____ XPropertySet ____
+uno::Reference<beans::XPropertySetInfo> SAL_CALL DataTable::getPropertySetInfo()
+{
+ static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDataTableInfoHelper()));
+ return xPropertySetInfo;
+}
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+OUString SAL_CALL DataTable::getImplementationName()
+{
+ return "com.sun.star.comp.chart2.DataTable";
+}
+
+sal_Bool SAL_CALL DataTable::supportsService(const OUString& rServiceName)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+uno::Sequence<OUString> SAL_CALL DataTable::getSupportedServiceNames()
+{
+ return { "com.sun.star.chart2.DataTable", "com.sun.star.beans.PropertySet",
+ "com.sun.star.drawing.FillProperties", "com.sun.star.drawing.LineProperties",
+ "com.sun.star.style.CharacterProperties" };
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2(DataTable, DataTable_Base, ::property::OPropertySet)
+IMPLEMENT_FORWARD_XTYPEPROVIDER2(DataTable, DataTable_Base, ::property::OPropertySet)
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
+com_sun_star_comp_chart2_DataTable_get_implementation(
+ css::uno::XComponentContext* /*pComponentContext*/, uno::Sequence<uno::Any> const& /*rAny*/)
+{
+ return cppu::acquire(new ::chart::DataTable);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx
index 8255115bead1..a963e2a25c07 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -18,7 +18,16 @@
*/
#include <Diagram.hxx>
+#include <AxisHelper.hxx>
+#include <BaseGFXHelper.hxx>
+#include <ChartTypeHelper.hxx>
+#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
+#include <ChartType.hxx>
+#include <DataSeriesHelper.hxx>
#include <PropertyHelper.hxx>
+#include <RegressionCurveHelper.hxx>
+#include <RegressionCurveModel.hxx>
#include "Wall.hxx"
#include <ModifyListenerHelper.hxx>
#include <UserDefinedProperties.hxx>
@@ -28,22 +37,39 @@
#include <CloneHelper.hxx>
#include <SceneProperties.hxx>
#include <unonames.hxx>
+#include <BaseCoordinateSystem.hxx>
+#include <Legend.hxx>
+#include <Axis.hxx>
+#include <DataTable.hxx>
+#include <servicenames_charttypes.hxx>
+#include <defines.hxx>
#include <basegfx/numeric/ftools.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/chart2/AxisType.hpp>
+#include <com/sun/star/chart2/DataPointGeometry3D.hpp>
+#include <com/sun/star/chart2/StackingDirection.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/RelativeSize.hpp>
+#include <com/sun/star/chart2/PieChartSubType.hpp>
+#include <com/sun/star/chart/MissingValueTreatment.hpp>
#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <com/sun/star/drawing/ShadeMode.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/CloseVetoException.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <o3tl/safeint.hxx>
+#include <rtl/math.hxx>
+#include <tools/helpers.hxx>
#include <algorithm>
+#include <utility>
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans::PropertyAttribute;
+using namespace ::chart::SceneProperties;
using ::com::sun::star::beans::Property;
using ::com::sun::star::uno::Sequence;
@@ -71,6 +97,7 @@ enum
PROP_DIAGRAM_MISSING_VALUE_TREATMENT,
PROP_DIAGRAM_3DRELATIVEHEIGHT,
PROP_DIAGRAM_DATATABLEHBORDER,
+ PROP_DIAGRAM_OF_PIE_TYPE,
PROP_DIAGRAM_DATATABLEVBORDER,
PROP_DIAGRAM_DATATABLEOUTLINE,
PROP_DIAGRAM_EXTERNALDATA
@@ -157,21 +184,10 @@ void lcl_AddPropertiesToVector(
PROP_DIAGRAM_3DRELATIVEHEIGHT,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::MAYBEVOID );
- 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( "SubPieType",
+ PROP_DIAGRAM_OF_PIE_TYPE,
+ cppu::UnoType<chart2::PieChartSubType>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
rOutProperties.emplace_back( "ExternalData",
PROP_DIAGRAM_EXTERNALDATA,
cppu::UnoType<OUString>::get(),
@@ -189,11 +205,10 @@ const ::chart::tPropertyValueMap& StaticDiagramDefaults()
::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true );
::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true );
::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false );
- ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_DATATABLEHBORDER, false );
- ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_DATATABLEVBORDER, false );
- ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_DATATABLEOUTLINE, false );
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_STARTING_ANGLE, 90 );
::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_3DRELATIVEHEIGHT, 100 );
+ ::chart::PropertyHelper::setPropertyValueDefault< chart2::PieChartSubType >( aMap, PROP_DIAGRAM_OF_PIE_TYPE,
+ chart2::PieChartSubType_NONE);
::chart::SceneProperties::AddDefaultsToMap( aMap );
return aMap;
}();
@@ -224,27 +239,16 @@ const uno::Reference< beans::XPropertySetInfo >& StaticDiagramInfo()
return xPropertySetInfo;
};
-/// clones a UNO-sequence of UNO-References
-typedef Reference< chart2::XCoordinateSystem > lcl_tCooSysRef;
-typedef std::vector< lcl_tCooSysRef > lcl_tCooSysVector;
-
void lcl_CloneCoordinateSystems(
- const lcl_tCooSysVector & rSource,
- lcl_tCooSysVector & rDestination )
+ const ::chart::Diagram::tCoordinateSystemContainerType & rSource,
+ ::chart::Diagram::tCoordinateSystemContainerType & rDestination )
{
- for( auto const & i : rSource )
+ for( rtl::Reference< ::chart::BaseCoordinateSystem > const & i : rSource )
{
- lcl_tCooSysRef xClone;
- css::uno::Reference< css::util::XCloneable > xCloneable( i, css::uno::UNO_QUERY );
- if( xCloneable.is())
- xClone.set( xCloneable->createClone(), css::uno::UNO_QUERY );
-
- if( xClone.is())
- {
- rDestination.push_back( xClone );
- }
- else
- rDestination.push_back( i );
+ auto xClone = i->createClone();
+ ::chart::BaseCoordinateSystem* pClone = dynamic_cast<::chart::BaseCoordinateSystem*>(xClone.get());
+ assert(pClone);
+ rDestination.push_back( pClone );
}
}
@@ -253,36 +257,43 @@ void lcl_CloneCoordinateSystems(
namespace chart
{
-Diagram::Diagram( uno::Reference< uno::XComponentContext > const & xContext ) :
- ::property::OPropertySet( m_aMutex ),
- m_xContext( xContext ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+Diagram::Diagram( uno::Reference< uno::XComponentContext > xContext ) :
+ m_xContext(std::move( xContext )),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
// Set camera position to a default position (that should be set hard, so
// that it will be exported. The property default is a camera looking
// straight ono the scene). These defaults have been acquired from the old
// chart implementation.
setFastPropertyValue_NoBroadcast(
- SceneProperties::PROP_SCENE_CAMERA_GEOMETRY, uno::Any(
+ PROP_SCENE_CAMERA_GEOMETRY, uno::Any(
ThreeDHelper::getDefaultCameraGeometry()));
}
Diagram::Diagram( const Diagram & rOther ) :
impl::Diagram_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
+ ::property::OPropertySet( rOther ),
m_xContext( rOther.m_xContext ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
lcl_CloneCoordinateSystems( rOther.m_aCoordSystems, m_aCoordSystems );
- ModifyListenerHelper::addListenerToAllElements( m_aCoordSystems, m_xModifyEventForwarder );
+ for (auto & xSystem : m_aCoordSystems)
+ xSystem->addModifyListener(m_xModifyEventForwarder);
- m_xWall.set( CloneHelper::CreateRefClone< beans::XPropertySet >()( rOther.m_xWall ));
- m_xFloor.set( CloneHelper::CreateRefClone< beans::XPropertySet >()( rOther.m_xFloor ));
+ if ( rOther.m_xWall )
+ m_xWall = new Wall( *rOther.m_xWall );
+ if ( rOther.m_xFloor )
+ m_xFloor = new Wall( *rOther.m_xFloor );
m_xTitle.set( CloneHelper::CreateRefClone< chart2::XTitle >()( rOther.m_xTitle ));
- m_xLegend.set( CloneHelper::CreateRefClone< chart2::XLegend >()( rOther.m_xLegend ));
-
- ModifyListenerHelper::addListener( m_xWall, m_xModifyEventForwarder );
- ModifyListenerHelper::addListener( m_xFloor, m_xModifyEventForwarder );
+ if (rOther.m_xLegend)
+ m_xLegend = new Legend(*rOther.m_xLegend);
+ if (rOther.m_xDataTable)
+ m_xDataTable = new DataTable(*rOther.m_xDataTable);
+
+ if ( m_xWall )
+ m_xWall->addModifyListener( m_xModifyEventForwarder );
+ if ( m_xFloor )
+ m_xFloor->addModifyListener( m_xModifyEventForwarder );
ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
ModifyListenerHelper::addListener( m_xLegend, m_xModifyEventForwarder );
}
@@ -291,10 +302,13 @@ Diagram::~Diagram()
{
try
{
- ModifyListenerHelper::removeListenerFromAllElements( m_aCoordSystems, m_xModifyEventForwarder );
+ for (auto & xSystem : m_aCoordSystems)
+ xSystem->removeModifyListener(m_xModifyEventForwarder);
- ModifyListenerHelper::removeListener( m_xWall, m_xModifyEventForwarder );
- ModifyListenerHelper::removeListener( m_xFloor, m_xModifyEventForwarder );
+ if ( m_xWall )
+ m_xWall->removeModifyListener( m_xModifyEventForwarder );
+ if ( m_xFloor )
+ m_xFloor->removeModifyListener( m_xModifyEventForwarder );
ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
ModifyListenerHelper::removeListener( m_xLegend, m_xModifyEventForwarder );
}
@@ -307,7 +321,7 @@ Diagram::~Diagram()
// ____ XDiagram ____
uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getWall()
{
- uno::Reference< beans::XPropertySet > xRet;
+ rtl::Reference< Wall > xRet;
bool bAddListener = false;
{
MutexGuard aGuard( m_aMutex );
@@ -319,13 +333,13 @@ uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getWall()
xRet = m_xWall;
}
if(bAddListener)
- ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
+ xRet->addModifyListener( m_xModifyEventForwarder );
return xRet;
}
uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getFloor()
{
- uno::Reference< beans::XPropertySet > xRet;
+ rtl::Reference< Wall > xRet;
bool bAddListener = false;
{
MutexGuard aGuard( m_aMutex );
@@ -337,7 +351,7 @@ uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getFloor()
xRet = m_xFloor;
}
if(bAddListener)
- ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
+ xRet->addModifyListener( m_xModifyEventForwarder );
return xRet;
}
@@ -347,9 +361,22 @@ uno::Reference< chart2::XLegend > SAL_CALL Diagram::getLegend()
return m_xLegend;
}
+rtl::Reference< ::chart::Legend > Diagram::getLegend2() const
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xLegend;
+}
+
void SAL_CALL Diagram::setLegend( const uno::Reference< chart2::XLegend >& xNewLegend )
{
- Reference< chart2::XLegend > xOldLegend;
+ auto pLegend = dynamic_cast<Legend*>(xNewLegend.get());
+ assert(!xNewLegend || pLegend);
+ setLegend(rtl::Reference< Legend >(pLegend));
+}
+
+void Diagram::setLegend( const rtl::Reference< Legend >& xNewLegend )
+{
+ rtl::Reference< Legend > xOldLegend;
{
MutexGuard aGuard( m_aMutex );
if( m_xLegend == xNewLegend )
@@ -394,15 +421,14 @@ void SAL_CALL Diagram::setDiagramData(
const Reference< chart2::data::XDataSource >& xDataSource,
const Sequence< beans::PropertyValue >& aArguments )
{
- uno::Reference< lang::XMultiServiceFactory > xChartTypeManager( m_xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.chart2.ChartTypeManager", m_xContext ), uno::UNO_QUERY );
- DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram( this, xChartTypeManager );
- uno::Reference< chart2::XChartTypeTemplate > xTemplate( aTemplateAndService.first );
+ rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = new ::chart::ChartTypeManager( m_xContext );
+ Diagram::tTemplateWithServiceName aTemplateAndService = getTemplate( xChartTypeManager );
+ rtl::Reference< ::chart::ChartTypeTemplate > xTemplate( aTemplateAndService.xChartTypeTemplate );
if( !xTemplate.is() )
- xTemplate.set( xChartTypeManager->createInstance( "com.sun.star.chart2.template.Column" ), uno::UNO_QUERY );
+ xTemplate = xChartTypeManager->createTemplate( "com.sun.star.chart2.template.Column" );
if(!xTemplate.is())
return;
- xTemplate->changeDiagramData( this, xDataSource, aArguments );
+ xTemplate->changeDiagramData( rtl::Reference< ::chart::Diagram >(this), xDataSource, aArguments );
}
// ____ XTitled ____
@@ -432,26 +458,129 @@ void SAL_CALL Diagram::setTitleObject( const uno::Reference< chart2::XTitle >& x
// ____ X3DDefaultSetter ____
void SAL_CALL Diagram::set3DSettingsToDefault()
{
- ThreeDHelper::set3DSettingsToDefault( this );
+ setPropertyToDefault( "D3DSceneDistance");
+ setPropertyToDefault( "D3DSceneFocalLength");
+ setDefaultRotation();
+ setDefaultIllumination();
}
void SAL_CALL Diagram::setDefaultRotation()
{
- ThreeDHelper::setDefaultRotation( this );
+ bool bPieOrDonut( isPieOrDonutChart() );
+ setDefaultRotation( bPieOrDonut );
+}
+
+static ::basegfx::B3DHomMatrix lcl_getCompleteRotationMatrix( Diagram& rDiagram )
+{
+ ::basegfx::B3DHomMatrix aCompleteRotation;
+ double fXAngleRad=0.0;
+ double fYAngleRad=0.0;
+ double fZAngleRad=0.0;
+ rDiagram.getRotationAngle( fXAngleRad, fYAngleRad, fZAngleRad );
+ aCompleteRotation.rotate( fXAngleRad, fYAngleRad, fZAngleRad );
+ return aCompleteRotation;
+}
+static void lcl_RotateLightSource( Diagram& rDiagram
+ , int nLightSourceDirectionProp
+ , int nLightSourceOnProp
+ , const ::basegfx::B3DHomMatrix& rRotationMatrix )
+{
+ bool bLightOn = false;
+ if( !(rDiagram.getFastPropertyValue( nLightSourceOnProp ) >>= bLightOn) )
+ return;
+
+ if( bLightOn )
+ {
+ drawing::Direction3D aLight;
+ if( rDiagram.getFastPropertyValue( nLightSourceDirectionProp ) >>= aLight )
+ {
+ ::basegfx::B3DVector aLightVector( BaseGFXHelper::Direction3DToB3DVector( aLight ) );
+ aLightVector = rRotationMatrix*aLightVector;
+
+ rDiagram.setFastPropertyValue( nLightSourceDirectionProp
+ , uno::Any( BaseGFXHelper::B3DVectorToDirection3D( aLightVector ) ) );
+ }
+ }
+}
+
+static void lcl_setLightsForScheme( Diagram& rDiagram, const ThreeDLookScheme& rScheme )
+{
+ if( rScheme == ThreeDLookScheme::ThreeDLookScheme_Unknown)
+ return;
+
+ // "D3DSceneLightOn2" / UNO_NAME_3D_SCENE_LIGHTON_2
+ rDiagram.setFastPropertyValue( PROP_SCENE_LIGHT_ON_2, uno::Any( true ) );
+
+ rtl::Reference< ChartType > xChartType( rDiagram.getChartTypeByIndex( 0 ) );
+ uno::Any aADirection( rScheme == ThreeDLookScheme::ThreeDLookScheme_Simple
+ ? ChartTypeHelper::getDefaultSimpleLightDirection(xChartType)
+ : ChartTypeHelper::getDefaultRealisticLightDirection(xChartType) );
+
+ // "D3DSceneLightDirection2" / UNO_NAME_3D_SCENE_LIGHTDIRECTION_2
+ rDiagram.setFastPropertyValue( PROP_SCENE_LIGHT_DIRECTION_2, aADirection );
+ //rotate light direction when right angled axes are off but supported
+ {
+ bool bRightAngledAxes = false;
+ rDiagram.getFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES ) >>= bRightAngledAxes; // "RightAngledAxes"
+ if(!bRightAngledAxes)
+ {
+ if( ChartTypeHelper::isSupportingRightAngledAxes( xChartType ) )
+ {
+ ::basegfx::B3DHomMatrix aRotation( lcl_getCompleteRotationMatrix( rDiagram ) );
+ BaseGFXHelper::ReduceToRotationMatrix( aRotation );
+ // "D3DSceneLightDirection2", "D3DSceneLightOn2"
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_2, PROP_SCENE_LIGHT_ON_2, aRotation );
+ }
+ }
+ }
+
+ sal_Int32 nColor = ::chart::ChartTypeHelper::getDefaultDirectLightColor(
+ rScheme == ThreeDLookScheme::ThreeDLookScheme_Simple, xChartType);
+ // "D3DSceneLightColor2" / UNO_NAME_3D_SCENE_LIGHTCOLOR_2
+ rDiagram.setFastPropertyValue( PROP_SCENE_LIGHT_COLOR_2, uno::Any( nColor ) );
+
+ sal_Int32 nAmbientColor = ::chart::ChartTypeHelper::getDefaultAmbientLightColor(
+ rScheme == ThreeDLookScheme::ThreeDLookScheme_Simple, xChartType);
+ // "D3DSceneAmbientColor" / UNO_NAME_3D_SCENE_AMBIENTCOLOR
+ rDiagram.setFastPropertyValue( PROP_SCENE_AMBIENT_COLOR, uno::Any( nAmbientColor ) );
}
void SAL_CALL Diagram::setDefaultIllumination()
{
- ThreeDHelper::setDefaultIllumination( this );
+ drawing::ShadeMode aShadeMode( drawing::ShadeMode_SMOOTH );
+ try
+ {
+ // "D3DSceneShadeMode"
+ getFastPropertyValue( PROP_SCENE_SHADE_MODE )>>= aShadeMode;
+ // "D3DSceneLightOn1" / UNO_NAME_3D_SCENE_LIGHTON_1
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_1, uno::Any( false ) );
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_3, uno::Any( false ) );
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_4, uno::Any( false ) );
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_5, uno::Any( false ) );
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_6, uno::Any( false ) );
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_7, uno::Any( false ) );
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_8, uno::Any( false ) );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ ThreeDLookScheme aScheme = (aShadeMode == drawing::ShadeMode_FLAT)
+ ? ThreeDLookScheme::ThreeDLookScheme_Simple
+ : ThreeDLookScheme::ThreeDLookScheme_Realistic;
+ lcl_setLightsForScheme( *this, aScheme );
}
// ____ XCoordinateSystemContainer ____
void SAL_CALL Diagram::addCoordinateSystem(
const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
{
+ ::chart::BaseCoordinateSystem* pCoordSys = dynamic_cast<::chart::BaseCoordinateSystem*>(aCoordSys.get());
+ assert(pCoordSys);
{
MutexGuard aGuard( m_aMutex );
- if( std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys )
+ if( std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), pCoordSys )
!= m_aCoordSystems.end())
throw lang::IllegalArgumentException("coordsys not found", static_cast<cppu::OWeakObject*>(this), 1);
@@ -460,7 +589,7 @@ void SAL_CALL Diagram::addCoordinateSystem(
OSL_FAIL( "more than one coordinatesystem is not supported yet by the fileformat" );
return;
}
- m_aCoordSystems.push_back( aCoordSys );
+ m_aCoordSystems.push_back( pCoordSys );
}
ModifyListenerHelper::addListener( aCoordSys, m_xModifyEventForwarder );
fireModifyEvent();
@@ -469,10 +598,11 @@ void SAL_CALL Diagram::addCoordinateSystem(
void SAL_CALL Diagram::removeCoordinateSystem(
const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
{
+ ::chart::BaseCoordinateSystem* pCoordSys = dynamic_cast<::chart::BaseCoordinateSystem*>(aCoordSys.get());
+ assert(pCoordSys);
{
MutexGuard aGuard( m_aMutex );
- std::vector< uno::Reference< chart2::XCoordinateSystem > >::iterator
- aIt( std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys ));
+ auto aIt = std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), pCoordSys );
if( aIt == m_aCoordSystems.end())
throw container::NoSuchElementException(
"The given coordinate-system is no element of the container",
@@ -486,7 +616,13 @@ void SAL_CALL Diagram::removeCoordinateSystem(
uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > SAL_CALL Diagram::getCoordinateSystems()
{
MutexGuard aGuard( m_aMutex );
- return comphelper::containerToSequence( m_aCoordSystems );
+ return comphelper::containerToSequence<uno::Reference< chart2::XCoordinateSystem >>( m_aCoordSystems );
+}
+
+Diagram::tCoordinateSystemContainerType Diagram::getBaseCoordinateSystems() const
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_aCoordSystems;
}
void SAL_CALL Diagram::setCoordinateSystems(
@@ -497,6 +633,30 @@ void SAL_CALL Diagram::setCoordinateSystems(
if( aCoordinateSystems.hasElements() )
{
OSL_ENSURE( aCoordinateSystems.getLength()<=1, "more than one coordinatesystem is not supported yet by the fileformat" );
+ ::chart::BaseCoordinateSystem* pCoordSys = dynamic_cast<::chart::BaseCoordinateSystem*>(aCoordinateSystems[0].get());
+ assert(pCoordSys);
+ aNew.push_back( pCoordSys );
+ }
+ {
+ MutexGuard aGuard( m_aMutex );
+ std::swap( aOld, m_aCoordSystems );
+ m_aCoordSystems = aNew;
+ }
+ for (auto & xSystem : aOld)
+ xSystem->removeModifyListener(m_xModifyEventForwarder);
+ for (auto & xSystem : aNew)
+ xSystem->addModifyListener(m_xModifyEventForwarder);
+ fireModifyEvent();
+}
+
+void Diagram::setCoordinateSystems(
+ const std::vector< rtl::Reference< BaseCoordinateSystem > >& aCoordinateSystems )
+{
+ tCoordinateSystemContainerType aNew;
+ tCoordinateSystemContainerType aOld;
+ if( !aCoordinateSystems.empty() )
+ {
+ OSL_ENSURE( aCoordinateSystems.size()<=1, "more than one coordinatesystem is not supported yet by the fileformat" );
aNew.push_back( aCoordinateSystems[0] );
}
{
@@ -504,8 +664,10 @@ void SAL_CALL Diagram::setCoordinateSystems(
std::swap( aOld, m_aCoordSystems );
m_aCoordSystems = aNew;
}
- ModifyListenerHelper::removeListenerFromAllElements( aOld, m_xModifyEventForwarder );
- ModifyListenerHelper::addListenerToAllElements( aNew, m_xModifyEventForwarder );
+ for (auto & xSystem : aOld)
+ xSystem->removeModifyListener(m_xModifyEventForwarder);
+ for (auto & xSystem : aNew)
+ xSystem->addModifyListener(m_xModifyEventForwarder);
fireModifyEvent();
}
@@ -519,28 +681,12 @@ Reference< util::XCloneable > SAL_CALL Diagram::createClone()
// ____ XModifyBroadcaster ____
void SAL_CALL Diagram::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL Diagram::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -567,13 +713,14 @@ void Diagram::fireModifyEvent()
}
// ____ OPropertySet ____
-uno::Any Diagram::GetDefaultValue( sal_Int32 nHandle ) const
+void Diagram::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
const tPropertyValueMap& rStaticDefaults = StaticDiagramDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
@@ -589,14 +736,14 @@ uno::Reference< beans::XPropertySetInfo > SAL_CALL Diagram::getPropertySetInfo()
}
// ____ XFastPropertySet ____
-void SAL_CALL Diagram::setFastPropertyValue( sal_Int32 nHandle, const Any& rValue )
+void SAL_CALL Diagram::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue )
{
//special treatment for some 3D properties
if( nHandle == PROP_DIAGRAM_PERSPECTIVE )
{
sal_Int32 fPerspective = 20;
if( rValue >>=fPerspective )
- ThreeDHelper::setCameraDistance( this, ThreeDHelper::PerspectiveToCameraDistance( fPerspective ) );
+ setCameraDistance( ThreeDHelper::PerspectiveToCameraDistance( fPerspective ) );
}
else if( nHandle == PROP_DIAGRAM_ROTATION_HORIZONTAL
|| nHandle == PROP_DIAGRAM_ROTATION_VERTICAL )
@@ -605,16 +752,16 @@ void SAL_CALL Diagram::setFastPropertyValue( sal_Int32 nHandle, const Any& rValu
if( rValue >>=nNewAngleDegree )
{
sal_Int32 nHorizontal, nVertical;
- ThreeDHelper::getRotationFromDiagram( this, nHorizontal, nVertical );
+ getRotation( nHorizontal, nVertical );
if( nHandle == PROP_DIAGRAM_ROTATION_HORIZONTAL )
nHorizontal = nNewAngleDegree;
else
nVertical = nNewAngleDegree;
- ThreeDHelper::setRotationToDiagram( this, nHorizontal, nVertical );
+ setRotation( nHorizontal, nVertical );
}
}
else
- ::property::OPropertySet::setFastPropertyValue( nHandle, rValue );
+ ::property::OPropertySet::setFastPropertyValue_NoBroadcast( nHandle, rValue );
}
void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
@@ -623,14 +770,14 @@ void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) co
if( nHandle == PROP_DIAGRAM_PERSPECTIVE )
{
sal_Int32 nPerspective = ::basegfx::fround( ThreeDHelper::CameraDistanceToPerspective(
- ThreeDHelper::getCameraDistance( const_cast< Diagram* >( this ) ) ) );
+ const_cast< Diagram* >( this )->getCameraDistance() ) );
rValue <<= nPerspective;
}
else if( nHandle == PROP_DIAGRAM_ROTATION_HORIZONTAL
|| nHandle == PROP_DIAGRAM_ROTATION_VERTICAL )
{
sal_Int32 nHorizontal, nVertical;
- ThreeDHelper::getRotationFromDiagram( const_cast< Diagram* >( this ), nHorizontal, nVertical );
+ const_cast< Diagram* >( this )->getRotation( nHorizontal, nVertical );
sal_Int32 nAngleDegree = 0;
if( nHandle == PROP_DIAGRAM_ROTATION_HORIZONTAL )
nAngleDegree = nHorizontal;
@@ -642,6 +789,42 @@ void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) co
::property::OPropertySet::getFastPropertyValue( rValue,nHandle );
}
+uno::Reference<chart2::XDataTable> SAL_CALL Diagram::getDataTable()
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xDataTable;
+}
+
+rtl::Reference<::chart::DataTable> Diagram::getDataTableRef() const
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xDataTable;
+}
+
+void SAL_CALL Diagram::setDataTable(const uno::Reference<chart2::XDataTable>& xDataTable)
+{
+ auto* pDataTable = dynamic_cast<DataTable*>(xDataTable.get());
+ assert(!xDataTable || pDataTable);
+ setDataTable(rtl::Reference<DataTable>(pDataTable));
+}
+
+void Diagram::setDataTable(const rtl::Reference<DataTable>& xNewDataTable)
+{
+ rtl::Reference<DataTable> xOldDataTable;
+ {
+ MutexGuard aGuard(m_aMutex);
+ if (m_xDataTable == xNewDataTable)
+ return;
+ xOldDataTable = m_xDataTable;
+ m_xDataTable = xNewDataTable;
+ }
+ if (xOldDataTable.is())
+ ModifyListenerHelper::removeListener(xOldDataTable, m_xModifyEventForwarder);
+ if (xNewDataTable.is())
+ ModifyListenerHelper::addListener(xNewDataTable, m_xModifyEventForwarder);
+ fireModifyEvent();
+}
+
using impl::Diagram_Base;
IMPLEMENT_FORWARD_XINTERFACE2( Diagram, Diagram_Base, ::property::OPropertySet )
@@ -666,6 +849,1440 @@ css::uno::Sequence< OUString > SAL_CALL Diagram::getSupportedServiceNames()
"com.sun.star.beans.PropertySet" };
}
+DiagramPositioningMode Diagram::getDiagramPositioningMode()
+{
+ DiagramPositioningMode eMode = DiagramPositioningMode::Auto;
+ chart2::RelativePosition aRelPos;
+ chart2::RelativeSize aRelSize;
+ if( (getFastPropertyValue(PROP_DIAGRAM_REL_POS) >>= aRelPos ) &&
+ (getFastPropertyValue(PROP_DIAGRAM_REL_SIZE) >>= aRelSize ) )
+ {
+ bool bPosSizeExcludeAxes=false;
+ getFastPropertyValue(PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS) >>= bPosSizeExcludeAxes;
+ if( bPosSizeExcludeAxes )
+ eMode = DiagramPositioningMode::Excluding;
+ else
+ eMode = DiagramPositioningMode::Including;
+ }
+ return eMode;
+}
+
+
+sal_Int32 Diagram::getCorrectedMissingValueTreatment(
+ const rtl::Reference< ChartType >& xChartType )
+{
+ sal_Int32 nResult = css::chart::MissingValueTreatment::LEAVE_GAP;
+ const uno::Sequence < sal_Int32 > aAvailableMissingValueTreatments(
+ ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ) );
+
+ if( getFastPropertyValue( PROP_DIAGRAM_MISSING_VALUE_TREATMENT ) >>= nResult )
+ {
+ //ensure that the set value is supported by this charttype
+ for( sal_Int32 n : aAvailableMissingValueTreatments )
+ if( n == nResult )
+ return nResult; //ok
+ }
+
+ //otherwise use the first supported one
+ if( aAvailableMissingValueTreatments.hasElements() )
+ {
+ nResult = aAvailableMissingValueTreatments[0];
+ return nResult;
+ }
+
+ return nResult;
+}
+
+void Diagram::setGeometry3D( sal_Int32 nNewGeometry )
+{
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ getDataSeries();
+
+ for (auto const& series : aSeriesVec)
+ {
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(
+ series, "Geometry3D", uno::Any( nNewGeometry ));
+ }
+}
+
+sal_Int32 Diagram::getGeometry3D( bool& rbFound, bool& rbAmbiguous )
+{
+ sal_Int32 nCommonGeom( css::chart2::DataPointGeometry3D::CUBOID );
+ rbFound = false;
+ rbAmbiguous = false;
+
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec = getDataSeries();
+
+ if( aSeriesVec.empty())
+ rbAmbiguous = true;
+
+ for (auto const& series : aSeriesVec)
+ {
+ try
+ {
+ sal_Int32 nGeom = 0;
+ if( series->getPropertyValue( "Geometry3D") >>= nGeom )
+ {
+ if( ! rbFound )
+ {
+ // first series
+ nCommonGeom = nGeom;
+ rbFound = true;
+ }
+ // further series: compare for uniqueness
+ else if( nCommonGeom != nGeom )
+ {
+ rbAmbiguous = true;
+ break;
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return nCommonGeom;
+}
+
+bool Diagram::isPieOrDonutChart()
+{
+ rtl::Reference< ChartType > xChartType = getChartTypeByIndex( 0 );
+
+ if( xChartType .is() )
+ {
+ OUString aChartType = xChartType->getChartType();
+ if( aChartType == CHART2_SERVICE_NAME_CHARTTYPE_PIE )
+ return true;
+ }
+ return false;
+}
+
+bool Diagram::isSupportingFloorAndWall()
+{
+ //pies and donuts currently do not support this because of wrong files from older versions
+ //todo: allow this in future again, if fileversion is available for OLE objects (metastream)
+ //thus the wrong bottom can be removed on import
+
+ const std::vector< rtl::Reference< ChartType > > aTypes = getChartTypes();
+ for( rtl::Reference< ChartType > const & xType : aTypes )
+ {
+ OUString sChartType = xType->getChartType();
+ if( sChartType.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
+ return false;
+ if( sChartType.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
+ return false;
+ if( sChartType.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
+ return false;
+ }
+ return true;
+}
+
+ /**
+ * This method implements the logic of checking if a series can be moved
+ * forward/backward. Depending on the "bDoMove" parameter the series will
+ * be moved (bDoMove = true) or the function just will test if the
+ * series can be moved without doing the move (bDoMove = false).
+ *
+ * @param xDiagram
+ * Reference to the diagram that contains the series.
+ *
+ * @param xGivenDataSeries
+ * Reference to the series that should moved or tested for moving.
+ *
+ * @param bForward
+ * Direction in which the series should be moved or tested for moving.
+ *
+ * @param bDoMove
+ * Should this function really move the series (true) or just test if it is
+ * possible (false).
+ *
+ *
+ * @returns
+ * in case of bDoMove == true
+ * - True : if the move was done
+ * - False : the move failed
+ * in case of bDoMove == false
+ * - True : the series can be moved
+ * - False : the series can not be moved
+ *
+ */
+static bool lcl_moveSeriesOrCheckIfMoveIsAllowed(
+ Diagram& rDiagram,
+ const rtl::Reference< DataSeries >& xGivenDataSeries,
+ bool bForward,
+ bool bDoMove )
+{
+ bool bMovedOrMoveAllowed = false;
+
+ try
+ {
+ if( !xGivenDataSeries.is() )
+ return false;
+
+ //find position of series.
+ bool bFound = false;
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & aCooSysList( rDiagram.getBaseCoordinateSystems() );
+
+ for( std::size_t nCS = 0; !bFound && nCS < aCooSysList.size(); ++nCS )
+ {
+ const rtl::Reference< BaseCoordinateSystem > & xCooSys( aCooSysList[nCS] );
+
+ //iterate through all chart types in the current coordinate system
+ std::vector< rtl::Reference< ChartType > > aChartTypeList( xCooSys->getChartTypes2() );
+ rtl::Reference< ChartType > xFormerChartType;
+
+ for( std::size_t nT = 0; !bFound && nT < aChartTypeList.size(); ++nT )
+ {
+ rtl::Reference< ChartType > xCurrentChartType( aChartTypeList[nT] );
+
+ //iterate through all series in this chart type
+
+ std::vector< rtl::Reference< DataSeries > > aSeriesList = xCurrentChartType->getDataSeries2();
+
+ for( std::size_t nS = 0; !bFound && nS < aSeriesList.size(); ++nS )
+ {
+
+ // We found the series we are interested in!
+ if( xGivenDataSeries==aSeriesList[nS] )
+ {
+ std::size_t nOldSeriesIndex = nS;
+ bFound = true;
+
+ try
+ {
+ sal_Int32 nNewSeriesIndex = nS;
+
+ // tdf#34517 Bringing forward means increasing, backwards means decreasing series position
+ if( !bForward )
+ nNewSeriesIndex--;
+ else
+ nNewSeriesIndex++;
+
+ if( nNewSeriesIndex >= 0 && o3tl::make_unsigned(nNewSeriesIndex) < aSeriesList.size() )
+ {
+ //move series in the same charttype
+ bMovedOrMoveAllowed = true;
+ if( bDoMove )
+ {
+ aSeriesList[ nOldSeriesIndex ] = aSeriesList[ nNewSeriesIndex ];
+ aSeriesList[ nNewSeriesIndex ] = xGivenDataSeries;
+ xCurrentChartType->setDataSeries( aSeriesList );
+ }
+ }
+ else if( nNewSeriesIndex<0 )
+ {
+ //exchange series with former charttype
+ if( xFormerChartType.is() && DiagramHelper::areChartTypesCompatible( xFormerChartType, xCurrentChartType ) )
+ {
+ bMovedOrMoveAllowed = true;
+ if( bDoMove )
+ {
+ std::vector< rtl::Reference< DataSeries > > aOtherSeriesList = xFormerChartType->getDataSeries2();
+ sal_Int32 nOtherSeriesIndex = aOtherSeriesList.size()-1;
+ if( nOtherSeriesIndex >= 0 && o3tl::make_unsigned(nOtherSeriesIndex) < aOtherSeriesList.size() )
+ {
+ rtl::Reference< DataSeries > xExchangeSeries( aOtherSeriesList[nOtherSeriesIndex] );
+ aOtherSeriesList[nOtherSeriesIndex] = xGivenDataSeries;
+ xFormerChartType->setDataSeries(aOtherSeriesList);
+
+ aSeriesList[nOldSeriesIndex] = std::move(xExchangeSeries);
+ xCurrentChartType->setDataSeries(aSeriesList);
+ }
+ }
+ }
+ }
+ else if( nT+1 < aChartTypeList.size() )
+ {
+ //exchange series with next charttype
+ rtl::Reference< ChartType > xOtherChartType( aChartTypeList[nT+1] );
+ if( xOtherChartType.is() && DiagramHelper::areChartTypesCompatible( xOtherChartType, xCurrentChartType ) )
+ {
+ bMovedOrMoveAllowed = true;
+ if( bDoMove )
+ {
+ std::vector< rtl::Reference< DataSeries > > aOtherSeriesList = xOtherChartType->getDataSeries2();
+ if( !aOtherSeriesList.empty() )
+ {
+ rtl::Reference<DataSeries> xExchangeSeries(aOtherSeriesList[0]);
+ aOtherSeriesList[0] = xGivenDataSeries;
+ xOtherChartType->setDataSeries(aOtherSeriesList);
+
+ aSeriesList[nOldSeriesIndex] = std::move(xExchangeSeries);
+ xCurrentChartType->setDataSeries(aSeriesList);
+ }
+ }
+ }
+ }
+ }
+ catch( const util::CloseVetoException& )
+ {
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ }
+ }
+ xFormerChartType = xCurrentChartType;
+ }
+ }
+ }
+ catch( const util::CloseVetoException& )
+ {
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ return bMovedOrMoveAllowed;
+}
+
+bool Diagram::isSeriesMoveable(
+ const rtl::Reference< DataSeries >& xGivenDataSeries,
+ bool bForward )
+{
+ const bool bDoMove = false;
+
+ bool bIsMoveable = lcl_moveSeriesOrCheckIfMoveIsAllowed(
+ *this, xGivenDataSeries, bForward, bDoMove );
+
+ return bIsMoveable;
+}
+
+bool Diagram::moveSeries( const rtl::Reference< DataSeries >& xGivenDataSeries, bool bForward )
+{
+ const bool bDoMove = true;
+
+ bool bMoved = lcl_moveSeriesOrCheckIfMoveIsAllowed(
+ *this, xGivenDataSeries, bForward, bDoMove );
+
+ return bMoved;
+}
+
+std::vector< rtl::Reference< ChartType > > Diagram::getChartTypes()
+{
+ std::vector< rtl::Reference< ChartType > > aResult;
+ try
+ {
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : getBaseCoordinateSystems() )
+ {
+ const std::vector< rtl::Reference< ChartType > > & aChartTypeSeq( coords->getChartTypes2());
+ aResult.insert( aResult.end(), aChartTypeSeq.begin(), aChartTypeSeq.end() );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return aResult;
+}
+
+rtl::Reference< ChartType > Diagram::getChartTypeByIndex( sal_Int32 nIndex )
+{
+ rtl::Reference< ChartType > xChartType;
+
+ //iterate through all coordinate systems
+ sal_Int32 nTypesSoFar = 0;
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : getBaseCoordinateSystems() )
+ {
+ const std::vector< rtl::Reference< ChartType > > & aChartTypeList( coords->getChartTypes2() );
+ if( nIndex >= 0 && o3tl::make_unsigned(nIndex) < nTypesSoFar + aChartTypeList.size() )
+ {
+ xChartType = aChartTypeList[nIndex - nTypesSoFar];
+ break;
+ }
+ nTypesSoFar += aChartTypeList.size();
+ }
+
+ return xChartType;
+}
+
+bool Diagram::isSupportingDateAxis()
+{
+ return ::chart::ChartTypeHelper::isSupportingDateAxis( getChartTypeByIndex( 0 ), 0 );
+}
+
+static std::vector< rtl::Reference< Axis > > lcl_getAxisHoldingCategoriesFromDiagram(
+ Diagram& rDiagram )
+{
+ std::vector< rtl::Reference< Axis > > aRet;
+
+ // return first x-axis as fall-back
+ rtl::Reference< Axis > xFallBack;
+ try
+ {
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : rDiagram.getBaseCoordinateSystems() )
+ {
+ OSL_ASSERT( xCooSys.is());
+ for( sal_Int32 nN = xCooSys->getDimension(); nN--; )
+ {
+ const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nN);
+ for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI)
+ {
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2( nN,nI );
+ OSL_ASSERT( xAxis.is());
+ if( xAxis.is())
+ {
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ if( aScaleData.Categories.is() || (aScaleData.AxisType == chart2::AxisType::CATEGORY) )
+ {
+ aRet.push_back(xAxis);
+ }
+ if( (nN == 0) && !xFallBack.is())
+ xFallBack = xAxis;
+ }
+ }
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2" );
+ }
+
+ if( aRet.empty() )
+ aRet.push_back(xFallBack);
+
+ return aRet;
+}
+
+uno::Reference< chart2::data::XLabeledDataSequence > Diagram::getCategories()
+{
+ uno::Reference< chart2::data::XLabeledDataSequence > xResult;
+
+ try
+ {
+ std::vector< rtl::Reference< Axis > > aCatAxes(
+ lcl_getAxisHoldingCategoriesFromDiagram( *this ));
+ //search for first categories
+ if (aCatAxes.empty())
+ return xResult;
+
+ rtl::Reference< Axis > xCatAxis(aCatAxes[0]);
+ if( !xCatAxis.is())
+ return xResult;
+
+ chart2::ScaleData aScaleData( xCatAxis->getScaleData());
+ if( !aScaleData.Categories.is() )
+ return xResult;
+
+ xResult = aScaleData.Categories;
+ uno::Reference<beans::XPropertySet> xProp(xResult->getValues(), uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ try
+ {
+ xProp->setPropertyValue( "Role", uno::Any( OUString("categories") ) );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xResult;
+}
+
+void Diagram::setCategories(
+ const uno::Reference< chart2::data::XLabeledDataSequence >& xCategories,
+ bool bSetAxisType /* = false */,
+ bool bCategoryAxis /* = true */ )
+{
+ std::vector< rtl::Reference< Axis > > aCatAxes(
+ lcl_getAxisHoldingCategoriesFromDiagram( *this ));
+
+ for (const rtl::Reference< Axis >& xCatAxis : aCatAxes)
+ {
+ if( xCatAxis.is())
+ {
+ chart2::ScaleData aScaleData( xCatAxis->getScaleData());
+ aScaleData.Categories = xCategories;
+ if( bSetAxisType )
+ {
+ if( bCategoryAxis )
+ aScaleData.AxisType = chart2::AxisType::CATEGORY;
+ else if( aScaleData.AxisType == chart2::AxisType::CATEGORY || aScaleData.AxisType == chart2::AxisType::DATE )
+ aScaleData.AxisType = chart2::AxisType::REALNUMBER;
+ }
+ xCatAxis->setScaleData( aScaleData );
+ }
+ }
+}
+
+bool Diagram::isCategory()
+{
+ try
+ {
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() )
+ {
+ for( sal_Int32 nN = xCooSys->getDimension(); nN--; )
+ {
+ const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nN);
+ for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI)
+ {
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2( nN,nI );
+ OSL_ASSERT( xAxis.is());
+ if( xAxis.is())
+ {
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ if( aScaleData.AxisType == chart2::AxisType::CATEGORY || aScaleData.AxisType == chart2::AxisType::DATE )
+ return true;
+ }
+ }
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return false;
+}
+
+std::vector< std::vector< rtl::Reference< DataSeries > > >
+Diagram::getDataSeriesGroups()
+{
+ std::vector< std::vector< rtl::Reference< DataSeries > > > aResult;
+
+ //iterate through all coordinate systems
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : getBaseCoordinateSystems() )
+ {
+ //iterate through all chart types in the current coordinate system
+ for( rtl::Reference< ChartType > const & chartType : coords->getChartTypes2() )
+ {
+ aResult.push_back( chartType->getDataSeries2() );
+ }
+ }
+ return aResult;
+}
+
+std::vector< rtl::Reference< ::chart::DataSeries > >
+ Diagram::getDataSeries()
+{
+ std::vector< rtl::Reference< DataSeries > > aResult;
+ try
+ {
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : getBaseCoordinateSystems() )
+ {
+ for( rtl::Reference< ChartType> const & chartType : coords->getChartTypes2() )
+ {
+ const std::vector< rtl::Reference< DataSeries > > aSeriesSeq( chartType->getDataSeries2() );
+ aResult.insert( aResult.end(), aSeriesSeq.begin(), aSeriesSeq.end() );
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return aResult;
+}
+
+rtl::Reference< ChartType > Diagram::getChartTypeOfSeries(
+ const rtl::Reference< DataSeries >& xGivenDataSeries )
+{
+ if( !xGivenDataSeries.is() )
+ return nullptr;
+
+ //iterate through the model to find the given xSeries
+ //the found parent indicates the charttype
+
+ //iterate through all coordinate systems
+
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() )
+ {
+ //iterate through all chart types in the current coordinate system
+ const std::vector< rtl::Reference< ChartType > > & aChartTypeList( xCooSys->getChartTypes2() );
+ for( rtl::Reference< ChartType > const & xChartType : aChartTypeList )
+ {
+ //iterate through all series in this chart type
+ for( rtl::Reference< DataSeries > const & dataSeries : xChartType->getDataSeries2() )
+ {
+ if( xGivenDataSeries==dataSeries )
+ return xChartType;
+ }
+ }
+ }
+ return nullptr;
+}
+
+rtl::Reference< Axis > Diagram::getAttachedAxis(
+ const rtl::Reference< DataSeries >& xSeries )
+{
+ return AxisHelper::getAxis( 1, DiagramHelper::isSeriesAttachedToMainAxis( xSeries ), this );
+}
+
+bool Diagram::attachSeriesToAxis( bool bAttachToMainAxis
+ , const rtl::Reference< DataSeries >& xDataSeries
+ , const uno::Reference< uno::XComponentContext > & xContext
+ , bool bAdaptAxes )
+{
+ bool bChanged = false;
+
+ //set property at axis
+
+ sal_Int32 nNewAxisIndex = bAttachToMainAxis ? 0 : 1;
+ sal_Int32 nOldAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries);
+ rtl::Reference< Axis > xOldAxis = getAttachedAxis( xDataSeries );
+
+ if( nOldAxisIndex != nNewAxisIndex )
+ {
+ try
+ {
+ xDataSeries->setPropertyValue( "AttachedAxisIndex", uno::Any( nNewAxisIndex ) );
+ bChanged = true;
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ if( bChanged )
+ {
+ rtl::Reference< Axis > xAxis = AxisHelper::getAxis( 1, bAttachToMainAxis, this );
+ if(!xAxis.is()) //create an axis if necessary
+ xAxis = AxisHelper::createAxis( 1, bAttachToMainAxis, this, xContext );
+ if( bAdaptAxes )
+ {
+ AxisHelper::makeAxisVisible( xAxis );
+ AxisHelper::hideAxisIfNoDataIsAttached( xOldAxis, this );
+ }
+ }
+
+ return bChanged;
+}
+
+void Diagram::replaceCoordinateSystem(
+ const rtl::Reference< BaseCoordinateSystem > & xCooSysToReplace,
+ const rtl::Reference< BaseCoordinateSystem > & xReplacement )
+{
+ // update the coordinate-system container
+ try
+ {
+ uno::Reference< chart2::data::XLabeledDataSequence > xCategories = getCategories();
+
+ // move chart types of xCooSysToReplace to xReplacement
+ xReplacement->setChartTypes( xCooSysToReplace->getChartTypes());
+
+ removeCoordinateSystem( xCooSysToReplace );
+ addCoordinateSystem( xReplacement );
+
+ if( xCategories.is() )
+ setCategories( xCategories );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+sal_Int32 Diagram::getDimension()
+{
+ // -1: not yet set
+ sal_Int32 nResult = -1;
+
+ try
+ {
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() )
+ {
+ if(xCooSys.is())
+ {
+ nResult = xCooSys->getDimension();
+ break;
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return nResult;
+}
+
+void Diagram::setDimension( sal_Int32 nNewDimensionCount )
+{
+ if( getDimension() == nNewDimensionCount )
+ return;
+
+ try
+ {
+ bool rbFound = false;
+ bool rbAmbiguous = true;
+ StackMode eStackMode = getStackMode( rbFound, rbAmbiguous );
+ bool bIsSupportingOnlyDeepStackingFor3D=false;
+
+ //change all coordinate systems:
+ auto aCoordSystems = getBaseCoordinateSystems();
+ for( rtl::Reference<BaseCoordinateSystem> const & xOldCooSys : aCoordSystems )
+ {
+ rtl::Reference< BaseCoordinateSystem > xNewCooSys;
+
+ const std::vector< rtl::Reference< ChartType > > aChartTypeList( xOldCooSys->getChartTypes2() );
+ for( rtl::Reference< ChartType > const & xChartType : aChartTypeList )
+ {
+ bIsSupportingOnlyDeepStackingFor3D = ChartTypeHelper::isSupportingOnlyDeepStackingFor3D( xChartType );
+ if(!xNewCooSys.is())
+ {
+ xNewCooSys = dynamic_cast<BaseCoordinateSystem*>(xChartType->createCoordinateSystem( nNewDimensionCount ).get());
+ assert(xNewCooSys);
+ break;
+ }
+ //@todo make sure that all following charttypes are also capable of the new dimension
+ //otherwise separate them in a different group
+ //BM: might be done in replaceCoordinateSystem()
+ }
+
+ // replace the old coordinate system at all places where it was used
+ replaceCoordinateSystem( xOldCooSys, xNewCooSys );
+ }
+
+ //correct stack mode if necessary
+ if( nNewDimensionCount==3 && eStackMode != StackMode::ZStacked && bIsSupportingOnlyDeepStackingFor3D )
+ setStackMode( StackMode::ZStacked );
+ else if( nNewDimensionCount==2 && eStackMode == StackMode::ZStacked )
+ setStackMode( StackMode::NONE );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+void Diagram::setStackMode( StackMode eStackMode )
+{
+ try
+ {
+ bool bValueFound = false;
+ bool bIsAmbiguous = false;
+ StackMode eOldStackMode = getStackMode( bValueFound, bIsAmbiguous );
+
+ if( eStackMode == eOldStackMode && !bIsAmbiguous )
+ return;
+
+ chart2::StackingDirection eNewDirection = chart2::StackingDirection_NO_STACKING;
+ if( eStackMode == StackMode::YStacked || eStackMode == StackMode::YStackedPercent )
+ eNewDirection = chart2::StackingDirection_Y_STACKING;
+ else if( eStackMode == StackMode::ZStacked )
+ eNewDirection = chart2::StackingDirection_Z_STACKING;
+
+ uno::Any aNewDirection( eNewDirection );
+
+ bool bPercent = false;
+ if( eStackMode == StackMode::YStackedPercent )
+ bPercent = true;
+
+ //iterate through all coordinate systems
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() )
+ {
+ //set correct percent stacking
+ const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(1);
+ for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI)
+ {
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2( 1,nI );
+ if( xAxis.is())
+ {
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ if( (aScaleData.AxisType==chart2::AxisType::PERCENT) != bPercent )
+ {
+ if( bPercent )
+ aScaleData.AxisType = chart2::AxisType::PERCENT;
+ else
+ aScaleData.AxisType = chart2::AxisType::REALNUMBER;
+ xAxis->setScaleData( aScaleData );
+ }
+ }
+ }
+ //iterate through all chart types in the current coordinate system
+ const std::vector< rtl::Reference< ChartType > > & aChartTypeList( xCooSys->getChartTypes2() );
+ if (aChartTypeList.empty())
+ continue;
+
+ rtl::Reference< ChartType > xChartType( aChartTypeList[0] );
+
+ //iterate through all series in this chart type
+ for( rtl::Reference< DataSeries > const & dataSeries : xChartType->getDataSeries2() )
+ {
+ dataSeries->setPropertyValue( "StackingDirection", aNewDirection );
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+StackMode Diagram::getStackMode( bool& rbFound, bool& rbAmbiguous )
+{
+ rbFound=false;
+ rbAmbiguous=false;
+
+ StackMode eGlobalStackMode = StackMode::NONE;
+
+ //iterate through all coordinate systems
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() )
+ {
+ //iterate through all chart types in the current coordinate system
+ std::vector< rtl::Reference< ChartType > > aChartTypeList( xCooSys->getChartTypes2() );
+ for( std::size_t nT = 0; nT < aChartTypeList.size(); ++nT )
+ {
+ rtl::Reference< ChartType > xChartType( aChartTypeList[nT] );
+
+ StackMode eLocalStackMode = DiagramHelper::getStackModeFromChartType(
+ xChartType, rbFound, rbAmbiguous, xCooSys );
+
+ if( rbFound && eLocalStackMode != eGlobalStackMode && nT>0 )
+ {
+ rbAmbiguous = true;
+ return eGlobalStackMode;
+ }
+
+ eGlobalStackMode = eLocalStackMode;
+ }
+ }
+
+ return eGlobalStackMode;
+}
+
+void Diagram::setVertical( bool bVertical /* = true */ )
+{
+ try
+ {
+ uno::Any aValue;
+ aValue <<= bVertical;
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() )
+ {
+ bool bChanged = false;
+ bool bOldSwap = false;
+ if( !(xCooSys->getPropertyValue("SwapXAndYAxis") >>= bOldSwap)
+ || bVertical != bOldSwap )
+ bChanged = true;
+
+ if( bChanged )
+ xCooSys->setPropertyValue("SwapXAndYAxis", aValue);
+
+ const sal_Int32 nDimensionCount = xCooSys->getDimension();
+ sal_Int32 nDimIndex = 0;
+ for (nDimIndex=0; nDimIndex < nDimensionCount; ++nDimIndex)
+ {
+ const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nDimIndex);
+ for (sal_Int32 nI = 0; nI <= nMaximumScaleIndex; ++nI)
+ {
+ rtl::Reference<Axis> xAxis = xCooSys->getAxisByDimension2(nDimIndex,nI);
+ if (!xAxis.is())
+ continue;
+
+ //adapt title rotation only when axis swapping has changed
+ if (!bChanged)
+ continue;
+
+ Reference< beans::XPropertySet > xTitleProps( xAxis->getTitleObject(), uno::UNO_QUERY );
+ if (!xTitleProps.is())
+ continue;
+
+ double fAngleDegree = 0.0;
+ xTitleProps->getPropertyValue("TextRotation") >>= fAngleDegree;
+ if (fAngleDegree != 0.0 &&
+ !rtl::math::approxEqual(fAngleDegree, 90.0))
+ continue;
+
+ double fNewAngleDegree = 0.0;
+ if( !bVertical && nDimIndex == 1 )
+ fNewAngleDegree = 90.0;
+ else if( bVertical && nDimIndex == 0 )
+ fNewAngleDegree = 90.0;
+
+ xTitleProps->setPropertyValue("TextRotation", uno::Any(fNewAngleDegree));
+ }
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+bool Diagram::getVertical( bool& rbFound, bool& rbAmbiguous )
+{
+ bool bValue = false;
+ rbFound = false;
+ rbAmbiguous = false;
+
+ for (rtl::Reference<BaseCoordinateSystem> const & coords : getBaseCoordinateSystems())
+ {
+ bool bCurrent = false;
+ if (coords->getPropertyValue("SwapXAndYAxis") >>= bCurrent)
+ {
+ if (!rbFound)
+ {
+ bValue = bCurrent;
+ rbFound = true;
+ }
+ else if (bCurrent != bValue)
+ {
+ // ambiguous -> choose always first found
+ rbAmbiguous = true;
+ }
+ }
+ }
+ return bValue;
+}
+
+Diagram::tTemplateWithServiceName
+ Diagram::getTemplate(
+ const rtl::Reference< ::chart::ChartTypeManager > & xChartTypeManager )
+{
+ tTemplateWithServiceName aResult;
+
+ if( !xChartTypeManager )
+ return aResult;
+
+ Sequence< OUString > aServiceNames( xChartTypeManager->getAvailableServiceNames());
+ const sal_Int32 nLength = aServiceNames.getLength();
+
+ bool bTemplateFound = false;
+
+ for( sal_Int32 i = 0; ! bTemplateFound && i < nLength; ++i )
+ {
+ try
+ {
+ rtl::Reference< ::chart::ChartTypeTemplate > xTempl =
+ xChartTypeManager->createTemplate( aServiceNames[ i ] );
+
+ if (xTempl.is() && xTempl->matchesTemplate2(this, true))
+ {
+ aResult.xChartTypeTemplate = xTempl;
+ aResult.sServiceName = aServiceNames[ i ];
+ bTemplateFound = true;
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return aResult;
+}
+
+std::vector< rtl::Reference< RegressionCurveModel > >
+ Diagram::getAllRegressionCurvesNotMeanValueLine()
+{
+ std::vector< rtl::Reference< RegressionCurveModel > > aResult;
+ std::vector< rtl::Reference< DataSeries > > aSeries( getDataSeries());
+ for (auto const& elem : aSeries)
+ {
+ for( rtl::Reference< RegressionCurveModel > const & curve : elem->getRegressionCurves2() )
+ {
+ if( ! RegressionCurveHelper::isMeanValueLine( curve ))
+ aResult.push_back( curve );
+ }
+ }
+
+ return aResult;
+}
+
+double Diagram::getCameraDistance()
+{
+ double fCameraDistance = FIXED_SIZE_FOR_3D_CHART_VOLUME;
+
+ try
+ {
+ drawing::CameraGeometry aCG( ThreeDHelper::getDefaultCameraGeometry() );
+ getFastPropertyValue( PROP_SCENE_CAMERA_GEOMETRY ) >>= aCG;
+ ::basegfx::B3DVector aVRP( BaseGFXHelper::Position3DToB3DVector( aCG.vrp ) );
+ fCameraDistance = aVRP.getLength();
+
+ ThreeDHelper::ensureCameraDistanceRange( fCameraDistance );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return fCameraDistance;
+}
+
+void Diagram::setCameraDistance(double fCameraDistance )
+{
+ try
+ {
+ if( fCameraDistance <= 0 )
+ fCameraDistance = FIXED_SIZE_FOR_3D_CHART_VOLUME;
+
+ drawing::CameraGeometry aCG( ThreeDHelper::getDefaultCameraGeometry() );
+ getFastPropertyValue( PROP_SCENE_CAMERA_GEOMETRY ) >>= aCG;
+ ::basegfx::B3DVector aVRP( BaseGFXHelper::Position3DToB3DVector( aCG.vrp ) );
+ if( ::basegfx::fTools::equalZero( aVRP.getLength() ) )
+ aVRP = ::basegfx::B3DVector(0,0,1);
+ aVRP.setLength(fCameraDistance);
+ aCG.vrp = BaseGFXHelper::B3DVectorToPosition3D( aVRP );
+
+ setFastPropertyValue( PROP_SCENE_CAMERA_GEOMETRY, uno::Any( aCG ));
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+static bool lcl_isRightAngledAxesSetAndSupported( Diagram& rDiagram )
+{
+ bool bRightAngledAxes = false;
+ rDiagram.getFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES ) >>= bRightAngledAxes; // "RightAngledAxes"
+ if(bRightAngledAxes)
+ {
+ if( ChartTypeHelper::isSupportingRightAngledAxes(
+ rDiagram.getChartTypeByIndex( 0 ) ) )
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+void Diagram::getRotation( sal_Int32& rnHorizontalAngleDegree, sal_Int32& rnVerticalAngleDegree )
+{
+ double fXAngle, fYAngle, fZAngle;
+ getRotationAngle( fXAngle, fYAngle, fZAngle );
+
+ if( !lcl_isRightAngledAxesSetAndSupported( *this ) )
+ {
+ ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
+ rnHorizontalAngleDegree, rnVerticalAngleDegree, fXAngle, fYAngle, fZAngle);
+ rnVerticalAngleDegree*=-1;
+ }
+ else
+ {
+ rnHorizontalAngleDegree = basegfx::fround(basegfx::rad2deg(fXAngle));
+ rnVerticalAngleDegree = basegfx::fround(-1.0 * basegfx::rad2deg(fYAngle));
+ // nZRotation = basegfx::fround(-1.0 * basegfx::rad2deg(fZAngle));
+ }
+
+ rnHorizontalAngleDegree = NormAngle180(rnHorizontalAngleDegree);
+ rnVerticalAngleDegree = NormAngle180(rnVerticalAngleDegree);
+}
+
+void Diagram::setRotation( sal_Int32 nHorizontalAngleDegree, sal_Int32 nVerticalYAngleDegree )
+{
+ //todo: x and y is not equal to horz and vert in case of RightAngledAxes==false
+ double fXAngle = basegfx::deg2rad(nHorizontalAngleDegree);
+ double fYAngle = basegfx::deg2rad(-1 * nVerticalYAngleDegree);
+ double fZAngle = 0.0;
+
+ if( !lcl_isRightAngledAxesSetAndSupported( *this ) )
+ ThreeDHelper::convertElevationRotationDegToXYZAngleRad(
+ nHorizontalAngleDegree, -1*nVerticalYAngleDegree, fXAngle, fYAngle, fZAngle );
+
+ setRotationAngle( fXAngle, fYAngle, fZAngle );
+}
+
+static ::basegfx::B3DHomMatrix lcl_getCameraMatrix( Diagram& rDiagram )
+{
+ drawing::HomogenMatrix aCameraMatrix;
+
+ drawing::CameraGeometry aCG( ThreeDHelper::getDefaultCameraGeometry() );
+ rDiagram.getFastPropertyValue( PROP_SCENE_CAMERA_GEOMETRY ) >>= aCG; // "D3DCameraGeometry"
+
+ ::basegfx::B3DVector aVPN( BaseGFXHelper::Direction3DToB3DVector( aCG.vpn ) );
+ ::basegfx::B3DVector aVUP( BaseGFXHelper::Direction3DToB3DVector( aCG.vup ) );
+
+ //normalize vectors:
+ aVPN.normalize();
+ aVUP.normalize();
+
+ ::basegfx::B3DVector aCross = ::basegfx::cross( aVUP, aVPN );
+
+ //first line is VUP x VPN
+ aCameraMatrix.Line1.Column1 = aCross[0];
+ aCameraMatrix.Line1.Column2 = aCross[1];
+ aCameraMatrix.Line1.Column3 = aCross[2];
+ aCameraMatrix.Line1.Column4 = 0.0;
+
+ //second line is VUP
+ aCameraMatrix.Line2.Column1 = aVUP[0];
+ aCameraMatrix.Line2.Column2 = aVUP[1];
+ aCameraMatrix.Line2.Column3 = aVUP[2];
+ aCameraMatrix.Line2.Column4 = 0.0;
+
+ //third line is VPN
+ aCameraMatrix.Line3.Column1 = aVPN[0];
+ aCameraMatrix.Line3.Column2 = aVPN[1];
+ aCameraMatrix.Line3.Column3 = aVPN[2];
+ aCameraMatrix.Line3.Column4 = 0.0;
+
+ //fourth line is 0 0 0 1
+ aCameraMatrix.Line4.Column1 = 0.0;
+ aCameraMatrix.Line4.Column2 = 0.0;
+ aCameraMatrix.Line4.Column3 = 0.0;
+ aCameraMatrix.Line4.Column4 = 1.0;
+
+ return BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aCameraMatrix );
+}
+
+static double lcl_shiftAngleToIntervalMinusPiToPi( double fAngleRad )
+{
+ //valid range: ]-Pi,Pi]
+ while( fAngleRad<=-M_PI )
+ fAngleRad+=(2*M_PI);
+ while( fAngleRad>M_PI )
+ fAngleRad-=(2*M_PI);
+ return fAngleRad;
+}
+
+void Diagram::getRotationAngle( double& rfXAngleRad, double& rfYAngleRad, double& rfZAngleRad )
+{
+ //takes the camera and the transformation matrix into account
+
+ rfXAngleRad = rfYAngleRad = rfZAngleRad = 0.0;
+
+ //get camera rotation
+ ::basegfx::B3DHomMatrix aFixCameraRotationMatrix( lcl_getCameraMatrix( *this ) );
+ BaseGFXHelper::ReduceToRotationMatrix( aFixCameraRotationMatrix );
+
+ //get scene rotation
+ ::basegfx::B3DHomMatrix aSceneRotation;
+ {
+ drawing::HomogenMatrix aHomMatrix;
+ // "D3DTransformMatrix"
+ if( getFastPropertyValue( PROP_SCENE_TRANSF_MATRIX ) >>= aHomMatrix )
+ {
+ aSceneRotation = BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHomMatrix );
+ BaseGFXHelper::ReduceToRotationMatrix( aSceneRotation );
+ }
+ }
+
+ ::basegfx::B3DHomMatrix aResultRotation = aFixCameraRotationMatrix * aSceneRotation;
+ ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix( aResultRotation ) );
+
+ rfXAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(aRotation.getX());
+ rfYAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(aRotation.getY());
+ rfZAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(aRotation.getZ());
+
+ if(rfZAngleRad<-M_PI_2 || rfZAngleRad>M_PI_2)
+ {
+ rfZAngleRad-=M_PI;
+ rfXAngleRad-=M_PI;
+ rfYAngleRad=(M_PI-rfYAngleRad);
+
+ rfXAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(rfXAngleRad);
+ rfYAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(rfYAngleRad);
+ rfZAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(rfZAngleRad);
+ }
+}
+
+static ::basegfx::B3DHomMatrix lcl_getInverseRotationMatrix( Diagram& rDiagram )
+{
+ ::basegfx::B3DHomMatrix aInverseRotation;
+ double fXAngleRad=0.0;
+ double fYAngleRad=0.0;
+ double fZAngleRad=0.0;
+ rDiagram.getRotationAngle( fXAngleRad, fYAngleRad, fZAngleRad );
+ aInverseRotation.rotate( 0.0, 0.0, -fZAngleRad );
+ aInverseRotation.rotate( 0.0, -fYAngleRad, 0.0 );
+ aInverseRotation.rotate( -fXAngleRad, 0.0, 0.0 );
+ return aInverseRotation;
+}
+
+static void lcl_rotateLights( const ::basegfx::B3DHomMatrix& rLightRotation, Diagram& rDiagram )
+{
+ ::basegfx::B3DHomMatrix aLightRotation( rLightRotation );
+ BaseGFXHelper::ReduceToRotationMatrix( aLightRotation );
+
+ // "D3DSceneLightDirection1","D3DSceneLightOn1",
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_1, PROP_SCENE_LIGHT_ON_1, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_2, PROP_SCENE_LIGHT_ON_2, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_3, PROP_SCENE_LIGHT_ON_3, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_4, PROP_SCENE_LIGHT_ON_4, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_5, PROP_SCENE_LIGHT_ON_5, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_6, PROP_SCENE_LIGHT_ON_6, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_7, PROP_SCENE_LIGHT_ON_7, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_8, PROP_SCENE_LIGHT_ON_8, aLightRotation );
+}
+
+void Diagram::setRotationAngle(
+ double fXAngleRad, double fYAngleRad, double fZAngleRad )
+{
+ //the rotation of the camera is not touched but taken into account
+ //the rotation difference is applied to the transformation matrix
+
+ //the light sources will be adapted also
+
+ try
+ {
+ //remind old rotation for adaptation of light directions
+ ::basegfx::B3DHomMatrix aInverseOldRotation( lcl_getInverseRotationMatrix( *this ) );
+
+ ::basegfx::B3DHomMatrix aInverseCameraRotation;
+ {
+ ::basegfx::B3DTuple aR( BaseGFXHelper::GetRotationFromMatrix(
+ lcl_getCameraMatrix( *this ) ) );
+ aInverseCameraRotation.rotate( 0.0, 0.0, -aR.getZ() );
+ aInverseCameraRotation.rotate( 0.0, -aR.getY(), 0.0 );
+ aInverseCameraRotation.rotate( -aR.getX(), 0.0, 0.0 );
+ }
+
+ ::basegfx::B3DHomMatrix aCumulatedRotation;
+ aCumulatedRotation.rotate( fXAngleRad, fYAngleRad, fZAngleRad );
+
+ //calculate new scene matrix
+ ::basegfx::B3DHomMatrix aSceneRotation = aInverseCameraRotation*aCumulatedRotation;
+ BaseGFXHelper::ReduceToRotationMatrix( aSceneRotation );
+
+ //set new rotation to transformation matrix ("D3DTransformMatrix")
+ setFastPropertyValue(
+ PROP_SCENE_TRANSF_MATRIX, uno::Any( BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aSceneRotation )));
+
+ //rotate lights if RightAngledAxes are not set or not supported
+ bool bRightAngledAxes = false;
+ getFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES ) >>= bRightAngledAxes;
+ if(!bRightAngledAxes || !ChartTypeHelper::isSupportingRightAngledAxes(
+ getChartTypeByIndex( 0 ) ) )
+ {
+ ::basegfx::B3DHomMatrix aNewRotation;
+ aNewRotation.rotate( fXAngleRad, fYAngleRad, fZAngleRad );
+ lcl_rotateLights( aNewRotation*aInverseOldRotation, *this );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+static bool lcl_isEqual( const drawing::Direction3D& rA, const drawing::Direction3D& rB )
+{
+ return ::rtl::math::approxEqual(rA.DirectionX, rB.DirectionX)
+ && ::rtl::math::approxEqual(rA.DirectionY, rB.DirectionY)
+ && ::rtl::math::approxEqual(rA.DirectionZ, rB.DirectionZ);
+}
+static bool lcl_isSimpleScheme( drawing::ShadeMode aShadeMode
+ , sal_Int32 nRoundedEdges
+ , sal_Int32 nObjectLines
+ , const rtl::Reference< Diagram >& xDiagram )
+{
+ if(aShadeMode!=drawing::ShadeMode_FLAT)
+ return false;
+ if(nRoundedEdges!=0)
+ return false;
+ if(nObjectLines==0)
+ {
+ rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) );
+ return ChartTypeHelper::noBordersForSimpleScheme( xChartType );
+ }
+ if(nObjectLines!=1)
+ return false;
+ return true;
+}
+static bool lcl_isRealisticScheme( drawing::ShadeMode aShadeMode
+ , sal_Int32 nRoundedEdges
+ , sal_Int32 nObjectLines )
+{
+ if(aShadeMode!=drawing::ShadeMode_SMOOTH)
+ return false;
+ if(nRoundedEdges!=5)
+ return false;
+ if(nObjectLines!=0)
+ return false;
+ return true;
+}
+static bool lcl_isLightScheme( Diagram& rDiagram, bool bRealistic )
+{
+ bool bIsOn = false;
+ // "D3DSceneLightOn2" / UNO_NAME_3D_SCENE_LIGHTON_2
+ rDiagram.getFastPropertyValue( PROP_SCENE_LIGHT_ON_2 ) >>= bIsOn;
+ if(!bIsOn)
+ return false;
+
+ rtl::Reference< ChartType > xChartType( rDiagram.getChartTypeByIndex( 0 ) );
+
+ sal_Int32 nColor = 0;
+ // "D3DSceneLightColor2" / UNO_NAME_3D_SCENE_LIGHTCOLOR_2
+ rDiagram.getFastPropertyValue( PROP_SCENE_LIGHT_COLOR_2 ) >>= nColor;
+ if( nColor != ::chart::ChartTypeHelper::getDefaultDirectLightColor( !bRealistic, xChartType ) )
+ return false;
+
+ sal_Int32 nAmbientColor = 0;
+ // "D3DSceneAmbientColor" / UNO_NAME_3D_SCENE_AMBIENTCOLOR
+ rDiagram.getFastPropertyValue( PROP_SCENE_AMBIENT_COLOR ) >>= nAmbientColor;
+ if( nAmbientColor != ::chart::ChartTypeHelper::getDefaultAmbientLightColor( !bRealistic, xChartType ) )
+ return false;
+
+ drawing::Direction3D aDirection(0,0,0);
+ // "D3DSceneLightDirection2" / UNO_NAME_3D_SCENE_LIGHTDIRECTION_2
+ rDiagram.getFastPropertyValue( PROP_SCENE_LIGHT_DIRECTION_2 ) >>= aDirection;
+
+ drawing::Direction3D aDefaultDirection( bRealistic
+ ? ChartTypeHelper::getDefaultRealisticLightDirection(xChartType)
+ : ChartTypeHelper::getDefaultSimpleLightDirection(xChartType) );
+
+ //rotate default light direction when right angled axes are off but supported
+ {
+ bool bRightAngledAxes = false;
+ rDiagram.getFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES ) >>= bRightAngledAxes; // "RightAngledAxes"
+ if(!bRightAngledAxes)
+ {
+ if( ChartTypeHelper::isSupportingRightAngledAxes(
+ rDiagram.getChartTypeByIndex( 0 ) ) )
+ {
+ ::basegfx::B3DHomMatrix aRotation( lcl_getCompleteRotationMatrix( rDiagram ) );
+ BaseGFXHelper::ReduceToRotationMatrix( aRotation );
+ ::basegfx::B3DVector aLightVector( BaseGFXHelper::Direction3DToB3DVector( aDefaultDirection ) );
+ aLightVector = aRotation*aLightVector;
+ aDefaultDirection = BaseGFXHelper::B3DVectorToDirection3D( aLightVector );
+ }
+ }
+ }
+
+ return lcl_isEqual( aDirection, aDefaultDirection );
+}
+static bool lcl_isRealisticLightScheme( Diagram& rDiagram )
+{
+ return lcl_isLightScheme( rDiagram, true /*bRealistic*/ );
+}
+static bool lcl_isSimpleLightScheme( Diagram& rDiagram )
+{
+ return lcl_isLightScheme( rDiagram, false /*bRealistic*/ );
+}
+
+ThreeDLookScheme Diagram::detectScheme()
+{
+ ThreeDLookScheme aScheme = ThreeDLookScheme::ThreeDLookScheme_Unknown;
+
+ sal_Int32 nRoundedEdges;
+ sal_Int32 nObjectLines;
+ ThreeDHelper::getRoundedEdgesAndObjectLines( this, nRoundedEdges, nObjectLines );
+
+ //get shade mode and light settings:
+ drawing::ShadeMode aShadeMode( drawing::ShadeMode_SMOOTH );
+ try
+ {
+ getFastPropertyValue( PROP_SCENE_SHADE_MODE )>>= aShadeMode; // "D3DSceneShadeMode"
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ if( lcl_isSimpleScheme( aShadeMode, nRoundedEdges, nObjectLines, this ) )
+ {
+ if( lcl_isSimpleLightScheme(*this) )
+ aScheme = ThreeDLookScheme::ThreeDLookScheme_Simple;
+ }
+ else if( lcl_isRealisticScheme( aShadeMode, nRoundedEdges, nObjectLines ) )
+ {
+ if( lcl_isRealisticLightScheme(*this) )
+ aScheme = ThreeDLookScheme::ThreeDLookScheme_Realistic;
+ }
+
+ return aScheme;
+}
+
+static void lcl_setRealisticScheme( drawing::ShadeMode& rShadeMode
+ , sal_Int32& rnRoundedEdges
+ , sal_Int32& rnObjectLines )
+{
+ rShadeMode = drawing::ShadeMode_SMOOTH;
+ rnRoundedEdges = 5;
+ rnObjectLines = 0;
+}
+
+static void lcl_setSimpleScheme( drawing::ShadeMode& rShadeMode
+ , sal_Int32& rnRoundedEdges
+ , sal_Int32& rnObjectLines
+ , const rtl::Reference< Diagram >& xDiagram )
+{
+ rShadeMode = drawing::ShadeMode_FLAT;
+ rnRoundedEdges = 0;
+
+ rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) );
+ rnObjectLines = ChartTypeHelper::noBordersForSimpleScheme( xChartType ) ? 0 : 1;
+}
+void Diagram::setScheme( ThreeDLookScheme aScheme )
+{
+ if( aScheme == ThreeDLookScheme::ThreeDLookScheme_Unknown )
+ return;
+
+ drawing::ShadeMode aShadeMode;
+ sal_Int32 nRoundedEdges;
+ sal_Int32 nObjectLines;
+
+ if( aScheme == ThreeDLookScheme::ThreeDLookScheme_Simple )
+ lcl_setSimpleScheme(aShadeMode,nRoundedEdges,nObjectLines,this);
+ else
+ lcl_setRealisticScheme(aShadeMode,nRoundedEdges,nObjectLines);
+
+ try
+ {
+ ThreeDHelper::setRoundedEdgesAndObjectLines( this, nRoundedEdges, nObjectLines );
+
+ drawing::ShadeMode aOldShadeMode;
+ if( ! (getFastPropertyValue( PROP_SCENE_SHADE_MODE)>>=aOldShadeMode) ||
+ aOldShadeMode != aShadeMode )
+ {
+ setFastPropertyValue( PROP_SCENE_SHADE_MODE, uno::Any( aShadeMode )); // "D3DSceneShadeMode"
+ }
+
+ lcl_setLightsForScheme( *this, aScheme );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+}
+
+void Diagram::setDefaultRotation( bool bPieOrDonut )
+{
+ drawing::CameraGeometry aCameraGeo( ThreeDHelper::getDefaultCameraGeometry( bPieOrDonut ) );
+ // "D3DCameraGeometry"
+ setFastPropertyValue( PROP_SCENE_CAMERA_GEOMETRY, uno::Any( aCameraGeo ));
+
+ ::basegfx::B3DHomMatrix aSceneRotation;
+ if( bPieOrDonut )
+ aSceneRotation.rotate( -M_PI/3.0, 0, 0 );
+ // "D3DTransformMatrix"
+ setFastPropertyValue( PROP_SCENE_TRANSF_MATRIX,
+ uno::Any( BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aSceneRotation )));
+}
+
+void Diagram::switchRightAngledAxes( bool bRightAngledAxes )
+{
+ try
+ {
+ bool bOldRightAngledAxes = false;
+ getFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES ) >>= bOldRightAngledAxes; // "RightAngledAxes"
+ if( bOldRightAngledAxes!=bRightAngledAxes)
+ {
+ setFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES, uno::Any( bRightAngledAxes ));
+ if(bRightAngledAxes)
+ {
+ ::basegfx::B3DHomMatrix aInverseRotation( lcl_getInverseRotationMatrix( *this ) );
+ lcl_rotateLights( aInverseRotation, *this );
+ }
+ else
+ {
+ ::basegfx::B3DHomMatrix aCompleteRotation( lcl_getCompleteRotationMatrix( *this ) );
+ lcl_rotateLights( aCompleteRotation, *this );
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
} // namespace chart
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
diff --git a/chart2/source/model/main/FormattedString.cxx b/chart2/source/model/main/FormattedString.cxx
index 782729294789..dbd5876b978a 100644
--- a/chart2/source/model/main/FormattedString.cxx
+++ b/chart2/source/model/main/FormattedString.cxx
@@ -17,13 +17,12 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "FormattedString.hxx"
+#include <FormattedString.hxx>
#include <CharacterProperties.hxx>
#include <PropertyHelper.hxx>
#include <ModifyListenerHelper.hxx>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
namespace com::sun::star::uno { class XComponentContext; }
@@ -33,61 +32,36 @@ using ::com::sun::star::beans::Property;
using ::com::sun::star::uno::Sequence;
using ::osl::MutexGuard;
-namespace
-{
-
-struct StaticFormattedStringDefaults_Initializer
+namespace chart
{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- ::chart::CharacterProperties::AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-};
-
-struct StaticFormattedStringDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticFormattedStringDefaults_Initializer >
+const ::chart::tPropertyValueMap & StaticFormattedStringDefaults()
{
+ static ::chart::tPropertyValueMap aStaticDefaults = []
+ {
+ ::chart::tPropertyValueMap aMap;
+ ::chart::CharacterProperties::AddDefaultsToMap( aMap );
+ return aMap;
+ }();
+ return aStaticDefaults;
};
+} // namespace chart
-struct StaticFormattedStringInfoHelper_Initializer
+namespace
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-};
-
-struct StaticFormattedStringInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticFormattedStringInfoHelper_Initializer >
+::cppu::OPropertyArrayHelper& StaticFormattedStringInfoHelper()
{
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
-struct StaticFormattedStringInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticFormattedStringInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticFormattedStringInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticFormattedStringInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -96,20 +70,19 @@ namespace chart
{
FormattedString::FormattedString() :
- ::property::OPropertySet( m_aMutex ),
m_aType(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT),
m_bDataLabelsRange(false),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
FormattedString::FormattedString( const FormattedString & rOther ) :
impl::FormattedString_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
+ ::property::OPropertySet( rOther ),
m_aString( rOther.m_aString ),
m_aType(rOther.m_aType),
m_aGuid(rOther.m_aGuid),
m_bDataLabelsRange(rOther.m_bDataLabelsRange),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
FormattedString::~FormattedString()
@@ -209,28 +182,12 @@ void SAL_CALL FormattedString::setCellRange( const OUString& cellRange )
// ____ XModifyBroadcaster ____
void SAL_CALL FormattedString::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL FormattedString::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -257,25 +214,28 @@ void FormattedString::fireModifyEvent()
}
// ____ OPropertySet ____
-uno::Any FormattedString::GetDefaultValue( sal_Int32 nHandle ) const
+void FormattedString::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticFormattedStringDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticFormattedStringDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL FormattedString::getInfoHelper()
{
- return *StaticFormattedStringInfoHelper::get();
+ return StaticFormattedStringInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL FormattedString::getPropertySetInfo()
{
- return *StaticFormattedStringInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticFormattedStringInfoHelper() ) );
+ return xPropertySetInfo;
}
using impl::FormattedString_Base;
diff --git a/chart2/source/model/main/FormattedString.hxx b/chart2/source/model/main/FormattedString.hxx
deleted file mode 100644
index bd7415fb921a..000000000000
--- a/chart2/source/model/main/FormattedString.hxx
+++ /dev/null
@@ -1,142 +0,0 @@
-/* -*- 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 <MutexContainer.hxx>
-#include <OPropertySet.hxx>
-#include <cppuhelper/implbase.hxx>
-#include <comphelper/uno3.hxx>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-
-namespace chart
-{
-
-namespace impl
-{
-typedef ::cppu::WeakImplHelper<
- css::chart2::XDataPointCustomLabelField, // inherits from XFormattedString2
- css::lang::XServiceInfo,
- css::util::XCloneable,
- css::util::XModifyBroadcaster,
- css::util::XModifyListener >
- FormattedString_Base;
-}
-
-class FormattedString final :
- public MutexContainer,
- public impl::FormattedString_Base,
- public ::property::OPropertySet
-{
-public:
- explicit FormattedString();
- virtual ~FormattedString() override;
-
- /// declare XServiceInfo methods
- 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;
-
- /// merge XInterface implementations
- DECLARE_XINTERFACE()
- /// merge XTypeProvider implementations
- DECLARE_XTYPEPROVIDER()
-
- virtual void SAL_CALL setPropertyValue(const OUString& p1, const css::uno::Any& p2) override
- { ::property::OPropertySet::setPropertyValue(p1, p2); }
- virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& p1) override
- { return ::property::OPropertySet::getPropertyValue(p1); }
- virtual void SAL_CALL addPropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) override
- { ::property::OPropertySet::addPropertyChangeListener(p1, p2); }
- virtual void SAL_CALL removePropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) override
- { ::property::OPropertySet::removePropertyChangeListener(p1, p2); }
- virtual void SAL_CALL addVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) override
- { ::property::OPropertySet::addVetoableChangeListener(p1, p2); }
- virtual void SAL_CALL removeVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) override
- { ::property::OPropertySet::removeVetoableChangeListener(p1, p2); }
-
-private:
- explicit FormattedString( const FormattedString & rOther );
-
- // ____ XFormattedString ____
- virtual OUString SAL_CALL getString() override;
- virtual void SAL_CALL setString( const OUString& String ) override;
-
- // ____ XDataPointCustomLabelField ____
- virtual css::chart2::DataPointCustomLabelFieldType SAL_CALL getFieldType() override;
- virtual void SAL_CALL
- setFieldType( const css::chart2::DataPointCustomLabelFieldType FieldType ) override;
- virtual OUString SAL_CALL getGuid() override;
- void SAL_CALL setGuid( const OUString& guid ) override;
- virtual sal_Bool SAL_CALL getDataLabelsRange() override;
- virtual void SAL_CALL setDataLabelsRange( sal_Bool dataLabelsRange ) override;
- virtual OUString SAL_CALL getCellRange() override;
- virtual void SAL_CALL setCellRange( const OUString& cellRange ) override;
-
- // ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
-
- // ____ OPropertySet ____
- virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
-
- // ____ XPropertySet ____
- virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
- getPropertySetInfo() override;
-
- // ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- // ____ XModifyBroadcaster ____
- virtual void SAL_CALL addModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
- virtual void SAL_CALL removeModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
-
- // ____ XModifyListener ____
- virtual void SAL_CALL modified(
- const css::lang::EventObject& aEvent ) override;
-
- // ____ XEventListener (base of XModifyListener) ____
- virtual void SAL_CALL disposing(
- const css::lang::EventObject& Source ) override;
-
- // ____ OPropertySet ____
- virtual void firePropertyChangeEvent() override;
- using OPropertySet::disposing;
-
- void fireModifyEvent();
-
- // ____ XFormattedString ____
- OUString m_aString;
-
- // ____ XDataPointCustomLabelField ____
- css::chart2::DataPointCustomLabelFieldType m_aType;
- OUString m_aGuid;
- OUString m_aCellRange;
- bool m_bDataLabelsRange;
-
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
-};
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/GridProperties.cxx b/chart2/source/model/main/GridProperties.cxx
index 44d3fffd8c67..a495f631f7e2 100644
--- a/chart2/source/model/main/GridProperties.cxx
+++ b/chart2/source/model/main/GridProperties.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "GridProperties.hxx"
+#include <GridProperties.hxx>
#include <LinePropertiesHelper.hxx>
#include <UserDefinedProperties.hxx>
#include <PropertyHelper.hxx>
@@ -25,7 +25,6 @@
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
namespace com::sun::star::beans { class XPropertySetInfo; }
namespace com::sun::star::uno { class XComponentContext; }
@@ -54,71 +53,38 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEDEFAULT );
}
-struct StaticGridDefaults_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::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_GRID_SHOW, false );
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue< sal_Int32 >(
- rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_COLOR, 0xb3b3b3 ); // gray30
- }
-};
-
-struct StaticGridDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticGridDefaults_Initializer >
-{
-};
-
-struct StaticGridInfoHelper_Initializer
+const ::chart::tPropertyValueMap & StaticGridDefaults()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
- ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_GRID_SHOW, false );
+ // override other defaults
+ ::chart::PropertyHelper::setPropertyValue< sal_Int32 >(
+ aTmp, ::chart::LinePropertiesHelper::PROP_LINE_COLOR, 0xb3b3b3 ); // gray30
+ return aTmp;
+ }();
+ return aStaticDefaults;
};
-struct StaticGridInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticGridInfoHelper_Initializer >
+::cppu::OPropertyArrayHelper& StaticGridInfoHelper()
{
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-struct StaticGridInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticGridInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticGridInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticGridInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -127,14 +93,13 @@ namespace chart
{
GridProperties::GridProperties() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
GridProperties::GridProperties( const GridProperties & rOther ) :
impl::GridProperties_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
}
@@ -142,24 +107,27 @@ GridProperties::~GridProperties()
{}
// ____ OPropertySet ____
-uno::Any GridProperties::GetDefaultValue( sal_Int32 nHandle ) const
+void GridProperties::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticGridDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticGridDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL GridProperties::getInfoHelper()
{
- return *StaticGridInfoHelper::get();
+ return StaticGridInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL GridProperties::getPropertySetInfo()
{
- return *StaticGridInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticGridInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XCloneable ____
@@ -171,28 +139,12 @@ uno::Reference< util::XCloneable > SAL_CALL GridProperties::createClone()
// ____ XModifyBroadcaster ____
void SAL_CALL GridProperties::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL GridProperties::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
diff --git a/chart2/source/model/main/GridProperties.hxx b/chart2/source/model/main/GridProperties.hxx
deleted file mode 100644
index 4e90d36176b9..000000000000
--- a/chart2/source/model/main/GridProperties.hxx
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- 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 <cppuhelper/implbase.hxx>
-#include <comphelper/uno3.hxx>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-
-#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
-
-namespace chart
-{
-
-namespace impl
-{
-typedef ::cppu::WeakImplHelper<
- css::lang::XServiceInfo,
- css::util::XCloneable,
- css::util::XModifyBroadcaster,
- css::util::XModifyListener >
- GridProperties_Base;
-}
-
-class GridProperties final :
- public MutexContainer,
- public impl::GridProperties_Base,
- public ::property::OPropertySet
-{
-public:
- explicit GridProperties();
- virtual ~GridProperties() 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;
-
- /// merge XInterface implementations
- DECLARE_XINTERFACE()
- /// merge XTypeProvider implementations
- DECLARE_XTYPEPROVIDER()
-
-private:
- explicit GridProperties( const GridProperties & rOther );
-
- // ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
-
- virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
-
- // ____ XPropertySet ____
- virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
- getPropertySetInfo() override;
-
- // ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- // ____ XModifyBroadcaster ____
- virtual void SAL_CALL addModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
- virtual void SAL_CALL removeModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
-
- // ____ XModifyListener ____
- virtual void SAL_CALL modified(
- const css::lang::EventObject& aEvent ) override;
-
- // ____ XEventListener (base of XModifyListener) ____
- virtual void SAL_CALL disposing(
- const css::lang::EventObject& Source ) override;
-
- // ____ OPropertySet ____
- virtual void firePropertyChangeEvent() override;
- using OPropertySet::disposing;
-
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
-};
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/Legend.cxx b/chart2/source/model/main/Legend.cxx
index 4c3b9f0e5167..f72868b58cb5 100644
--- a/chart2/source/model/main/Legend.cxx
+++ b/chart2/source/model/main/Legend.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "Legend.hxx"
+#include <Legend.hxx>
#include <LinePropertiesHelper.hxx>
#include <FillProperties.hxx>
#include <CharacterProperties.hxx>
@@ -31,7 +31,6 @@
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/RelativeSize.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
#include <algorithm>
@@ -106,78 +105,53 @@ void lcl_AddPropertiesToVector(
}
-struct StaticLegendDefaults_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 );
- ::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
-
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_ANCHOR_POSITION, chart2::LegendPosition_LINE_END );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_EXPANSION, css::chart::ChartLegendExpansion_HIGH );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_SHOW, true );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_OVERLAY, false );
-
- float fDefaultCharHeight = 10.0;
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
- }
-};
+} // namespace
-struct StaticLegendDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLegendDefaults_Initializer >
+namespace chart
{
-};
-
-struct StaticLegendInfoHelper_Initializer
+const ::chart::tPropertyValueMap& StaticLegendDefaults()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
- ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
- ::chart::FillProperties::AddPropertiesToVector( aProperties );
- ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
+ ::chart::FillProperties::AddDefaultsToMap( aTmp );
+ ::chart::CharacterProperties::AddDefaultsToMap( aTmp );
+
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_LEGEND_ANCHOR_POSITION, chart2::LegendPosition_LINE_END );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_LEGEND_EXPANSION, css::chart::ChartLegendExpansion_HIGH );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_LEGEND_SHOW, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_LEGEND_OVERLAY, false );
+
+ float fDefaultCharHeight = 10.0;
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
+ return aTmp;
+ }();
+ return aStaticDefaults;
};
+} // namespace chart
-struct StaticLegendInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLegendInfoHelper_Initializer >
-{
-};
-
-struct StaticLegendInfo_Initializer
+namespace
{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLegendInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticLegendInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLegendInfo_Initializer >
+::cppu::OPropertyArrayHelper& StaticLegendInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -186,15 +160,14 @@ namespace chart
{
Legend::Legend() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
}
Legend::Legend( const Legend & rOther ) :
impl::Legend_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
}
@@ -211,28 +184,12 @@ Reference< util::XCloneable > SAL_CALL Legend::createClone()
// ____ XModifyBroadcaster ____
void SAL_CALL Legend::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL Legend::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -254,24 +211,27 @@ void Legend::firePropertyChangeEvent()
}
// ____ OPropertySet ____
-Any Legend::GetDefaultValue( sal_Int32 nHandle ) const
+void Legend::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticLegendDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticLegendDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL Legend::getInfoHelper()
{
- return *StaticLegendInfoHelper::get();
+ return StaticLegendInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL Legend::getPropertySetInfo()
{
- return *StaticLegendInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticLegendInfoHelper() ) );
+ return xPropertySetInfo;
}
// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
diff --git a/chart2/source/model/main/Legend.hxx b/chart2/source/model/main/Legend.hxx
deleted file mode 100644
index 4e1a943277bd..000000000000
--- a/chart2/source/model/main/Legend.hxx
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- 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 <OPropertySet.hxx>
-#include <MutexContainer.hxx>
-#include <cppuhelper/implbase.hxx>
-#include <comphelper/uno3.hxx>
-#include <com/sun/star/chart2/XLegend.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-
-namespace chart
-{
-
-namespace impl
-{
-typedef ::cppu::WeakImplHelper<
- css::chart2::XLegend,
- css::lang::XServiceInfo,
- css::util::XCloneable,
- css::util::XModifyBroadcaster,
- css::util::XModifyListener >
- Legend_Base;
-}
-
-class Legend final :
- public MutexContainer,
- public impl::Legend_Base,
- public ::property::OPropertySet
-{
-public:
- explicit Legend();
- virtual ~Legend() 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;
-
- /// merge XInterface implementations
- DECLARE_XINTERFACE()
- /// merge XTypeProvider implementations
- DECLARE_XTYPEPROVIDER()
-
-private:
- explicit Legend( const Legend & rOther );
-
- // ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
-
- // ____ OPropertySet ____
- virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
-
- // ____ XPropertySet ____
- virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
- getPropertySetInfo() override;
-
- // ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- // ____ XModifyBroadcaster ____
- virtual void SAL_CALL addModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
- virtual void SAL_CALL removeModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
-
- // ____ XModifyListener ____
- virtual void SAL_CALL modified(
- const css::lang::EventObject& aEvent ) override;
-
- // ____ XEventListener (base of XModifyListener) ____
- virtual void SAL_CALL disposing(
- const css::lang::EventObject& Source ) override;
-
- // ____ OPropertySet ____
- virtual void firePropertyChangeEvent() override;
- using OPropertySet::disposing;
-
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
-};
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/PageBackground.cxx b/chart2/source/model/main/PageBackground.cxx
index 5dda4cb5a7b4..deae689d7a2b 100644
--- a/chart2/source/model/main/PageBackground.cxx
+++ b/chart2/source/model/main/PageBackground.cxx
@@ -18,15 +18,17 @@
*/
#include "PageBackground.hxx"
+#include <comphelper/lok.hxx>
#include <LinePropertiesHelper.hxx>
#include <FillProperties.hxx>
#include <UserDefinedProperties.hxx>
#include <PropertyHelper.hxx>
#include <ModifyListenerHelper.hxx>
+#include <svtools/colorcfg.hxx>
+#include <sfx2/viewsh.hxx>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
#include <vector>
#include <algorithm>
@@ -40,70 +42,47 @@ using ::com::sun::star::beans::Property;
namespace
{
-struct StaticPageBackgroundDefaults_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 );
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
- }
+const ::chart::tPropertyValueMap& StaticPageBackgroundDefaults()
+{
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
+ ::chart::FillProperties::AddDefaultsToMap( aTmp );
+
+ // override other defaults
+ Color aDocColor = COL_WHITE;
+ if (comphelper::LibreOfficeKit::isActive()) {
+ aDocColor = COL_AUTO;
+ } else {
+ if (SfxViewShell* pCurrentSh = SfxViewShell::Current()) {
+ aDocColor = pCurrentSh->GetColorConfigColor(svtools::DOCCOLOR);
+ } else {
+ aDocColor = svtools::ColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
+ }
+ }
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::FillProperties::PROP_FILL_COLOR, aDocColor );
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
+ return aTmp;
+ }();
+ return aStaticDefaults;
};
-struct StaticPageBackgroundDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPageBackgroundDefaults_Initializer >
+::cppu::OPropertyArrayHelper& StaticPageBackgroundInfoHelper()
{
-};
-
-struct StaticPageBackgroundInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static uno::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() );
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
- return comphelper::containerToSequence( aProperties );
- }
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-};
-
-struct StaticPageBackgroundInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticPageBackgroundInfoHelper_Initializer >
-{
-};
-
-struct StaticPageBackgroundInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPageBackgroundInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticPageBackgroundInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPageBackgroundInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -112,19 +91,26 @@ namespace chart
{
PageBackground::PageBackground() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
PageBackground::PageBackground( const PageBackground & rOther ) :
impl::PageBackground_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
PageBackground::~PageBackground()
{}
+// ____ XTypeProvider ____
+uno::Sequence< css::uno::Type > SAL_CALL PageBackground::getTypes()
+{
+ return ::comphelper::concatSequences(
+ impl::PageBackground_Base::getTypes(),
+ ::property::OPropertySet::getTypes());
+}
+
// ____ XCloneable ____
uno::Reference< util::XCloneable > SAL_CALL PageBackground::createClone()
{
@@ -132,51 +118,38 @@ uno::Reference< util::XCloneable > SAL_CALL PageBackground::createClone()
}
// ____ OPropertySet ____
-uno::Any PageBackground::GetDefaultValue( sal_Int32 nHandle ) const
+void PageBackground::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticPageBackgroundDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticPageBackgroundDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL PageBackground::getInfoHelper()
{
- return *StaticPageBackgroundInfoHelper::get();
+ return StaticPageBackgroundInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL PageBackground::getPropertySetInfo()
{
- return *StaticPageBackgroundInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticPageBackgroundInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XModifyBroadcaster ____
void SAL_CALL PageBackground::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL PageBackground::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
diff --git a/chart2/source/model/main/PageBackground.hxx b/chart2/source/model/main/PageBackground.hxx
index 7624fbf8e215..2aef8bd45ebe 100644
--- a/chart2/source/model/main/PageBackground.hxx
+++ b/chart2/source/model/main/PageBackground.hxx
@@ -20,13 +20,10 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-#include <MutexContainer.hxx>
#include <OPropertySet.hxx>
#include <cppuhelper/implbase.hxx>
-
#include <comphelper/uno3.hxx>
+#include <ModifyListenerHelper.hxx>
namespace chart
{
@@ -42,7 +39,6 @@ typedef ::cppu::WeakImplHelper<
}
class PageBackground final :
- public MutexContainer,
public impl::PageBackground_Base,
public ::property::OPropertySet
{
@@ -58,11 +54,13 @@ public:
/// merge XInterface implementations
DECLARE_XINTERFACE()
-private:
explicit PageBackground( const PageBackground & rOther );
+ // ____ XTypeProvider ____
+ virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
+
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
// ____ OPropertySet ____
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -80,6 +78,8 @@ private:
virtual void SAL_CALL removeModifyListener(
const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
+private:
+
// ____ XModifyListener ____
virtual void SAL_CALL modified(
const css::lang::EventObject& aEvent ) override;
@@ -92,7 +92,7 @@ private:
virtual void firePropertyChangeEvent() override;
using OPropertySet::disposing;
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
+ rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder;
};
} // namespace chart
diff --git a/chart2/source/model/main/PolarCoordinateSystem.cxx b/chart2/source/model/main/PolarCoordinateSystem.cxx
index 5c891989e37f..0807415dac24 100644
--- a/chart2/source/model/main/PolarCoordinateSystem.cxx
+++ b/chart2/source/model/main/PolarCoordinateSystem.cxx
@@ -31,8 +31,8 @@ using ::com::sun::star::uno::Sequence;
namespace
{
-constexpr OUStringLiteral CHART2_COOSYSTEM_POLAR_SERVICE_NAME
- = u"com.sun.star.chart2.CoordinateSystems.Polar";
+constexpr OUString CHART2_COOSYSTEM_POLAR_SERVICE_NAME
+ = u"com.sun.star.chart2.CoordinateSystems.Polar"_ustr;
}
diff --git a/chart2/source/model/main/StockBar.cxx b/chart2/source/model/main/StockBar.cxx
index 22e082ad06b3..5d7efdc5f0d9 100644
--- a/chart2/source/model/main/StockBar.cxx
+++ b/chart2/source/model/main/StockBar.cxx
@@ -23,8 +23,6 @@
#include <UserDefinedProperties.hxx>
#include <PropertyHelper.hxx>
#include <ModifyListenerHelper.hxx>
-#include <com/sun/star/uno/Sequence.hxx>
-#include <tools/diagnose_ex.h>
#include <algorithm>
@@ -38,69 +36,36 @@ using ::com::sun::star::beans::Property;
namespace
{
-struct StaticStockBarInfoHelper_Initializer
+::cppu::OPropertyArrayHelper& StaticStockBarInfoHelper()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-private:
- static uno::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() );
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticStockBarInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticStockBarInfoHelper_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
-struct StaticStockBarInfo_Initializer
+const ::chart::tPropertyValueMap & StaticStockBarDefaults()
{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticStockBarInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
+ ::chart::FillProperties::AddDefaultsToMap( aTmp );
-struct StaticStockBarInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticStockBarInfo_Initializer >
-{
-};
-
-struct StaticStockBarDefaults_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 );
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); // white
- }
-};
-
-struct StaticStockBarDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticStockBarDefaults_Initializer >
-{
+ // override other defaults
+ ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( aTmp, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); // white
+ return aTmp;
+ }();
+ return aStaticDefaults;
};
} // anonymous namespace
@@ -109,8 +74,7 @@ namespace chart
{
StockBar::StockBar( bool bRisingCourse ) :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
if( ! bRisingCourse )
{
@@ -125,13 +89,21 @@ StockBar::StockBar( bool bRisingCourse ) :
StockBar::StockBar( const StockBar & rOther ) :
impl::StockBar_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
StockBar::~StockBar()
{}
+// ____ XTypeProvider ____
+uno::Sequence< css::uno::Type > SAL_CALL StockBar::getTypes()
+{
+ return ::comphelper::concatSequences(
+ impl::StockBar_Base::getTypes(),
+ ::property::OPropertySet::getTypes());
+}
+
// ____ XCloneable ____
uno::Reference< util::XCloneable > SAL_CALL StockBar::createClone()
{
@@ -139,51 +111,38 @@ uno::Reference< util::XCloneable > SAL_CALL StockBar::createClone()
}
// ____ OPropertySet ____
-uno::Any StockBar::GetDefaultValue( sal_Int32 nHandle ) const
+void StockBar::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticStockBarDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticStockBarDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL StockBar::getInfoHelper()
{
- return *StaticStockBarInfoHelper::get();
+ return StaticStockBarInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL StockBar::getPropertySetInfo()
{
- return *StaticStockBarInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticStockBarInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XModifyBroadcaster ____
void SAL_CALL StockBar::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL StockBar::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
diff --git a/chart2/source/model/main/Title.cxx b/chart2/source/model/main/Title.cxx
index a42374ce5f51..10551ce6e318 100644
--- a/chart2/source/model/main/Title.cxx
+++ b/chart2/source/model/main/Title.cxx
@@ -17,7 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "Title.hxx"
+#include <Title.hxx>
+#include <CharacterProperties.hxx>
#include <LinePropertiesHelper.hxx>
#include <FillProperties.hxx>
#include <CloneHelper.hxx>
@@ -30,7 +31,6 @@
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/awt/Size.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
#include <vector>
#include <algorithm>
@@ -140,86 +140,56 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEVOID );
}
-struct StaticTitleDefaults_Initializer
+const ::chart::tPropertyValueMap& StaticTitleDefaults()
{
- ::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 );
-
- // ParagraphProperties
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_PARA_ADJUST,
- css::style::ParagraphAdjust_CENTER );
- // PROP_TITLE_PARA_LAST_LINE_ADJUST
-
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_LEFT_MARGIN, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_RIGHT_MARGIN, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_TOP_MARGIN, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_BOTTOM_MARGIN, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_PARA_IS_HYPHENATION, true );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_VISIBLE, true );
-
- // own properties
- ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_TITLE_TEXT_ROTATION, 0.0 );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_TEXT_STACKED, false );
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
- }
-};
-
-struct StaticTitleDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticTitleDefaults_Initializer >
-{
-};
-
-struct StaticTitleInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static uno::Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
- ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
- ::chart::FillProperties::AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticTitleInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticTitleInfoHelper_Initializer >
-{
-};
-
-struct StaticTitleInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticTitleInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+
+ ::chart::CharacterProperties::AddDefaultsToMap( aTmp );
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
+ ::chart::FillProperties::AddDefaultsToMap( aTmp );
+
+ // ParagraphProperties
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_TITLE_PARA_ADJUST,
+ css::style::ParagraphAdjust_CENTER );
+ // PROP_TITLE_PARA_LAST_LINE_ADJUST
+
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_TITLE_PARA_LEFT_MARGIN, 0 );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_TITLE_PARA_RIGHT_MARGIN, 0 );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_TITLE_PARA_TOP_MARGIN, 0 );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_TITLE_PARA_BOTTOM_MARGIN, 0 );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_TITLE_PARA_IS_HYPHENATION, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_TITLE_VISIBLE, true );
+
+ // own properties
+ ::chart::PropertyHelper::setPropertyValueDefault< double >( aTmp, PROP_TITLE_TEXT_ROTATION, 0.0 );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_TITLE_TEXT_STACKED, false );
+
+ // override other defaults
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE );
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
+ return aTmp;
+ }();
+ return aStaticDefaults;
};
-struct StaticTitleInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticTitleInfo_Initializer >
+::cppu::OPropertyArrayHelper& StaticTitleInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -228,14 +198,13 @@ namespace chart
{
Title::Title() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
Title::Title( const Title & rOther ) :
impl::Title_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
CloneHelper::CloneRefSequence<chart2::XFormattedString>(
rOther.m_aStrings, m_aStrings );
@@ -283,51 +252,38 @@ void SAL_CALL Title::setText( const uno::Sequence< uno::Reference< chart2::XForm
}
// ____ OPropertySet ____
-uno::Any Title::GetDefaultValue( sal_Int32 nHandle ) const
+void Title::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticTitleDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticTitleDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL Title::getInfoHelper()
{
- return *StaticTitleInfoHelper::get();
+ return StaticTitleInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL Title::getPropertySetInfo()
{
- return *StaticTitleInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticTitleInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XModifyBroadcaster ____
void SAL_CALL Title::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL Title::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
diff --git a/chart2/source/model/main/Title.hxx b/chart2/source/model/main/Title.hxx
deleted file mode 100644
index c700827cbb74..000000000000
--- a/chart2/source/model/main/Title.hxx
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -*- 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 <OPropertySet.hxx>
-#include <MutexContainer.hxx>
-#include <cppuhelper/implbase.hxx>
-#include <comphelper/uno3.hxx>
-#include <com/sun/star/chart2/XTitle.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-
-namespace chart
-{
-
-namespace impl
-{
-typedef ::cppu::WeakImplHelper<
- css::chart2::XTitle,
- css::lang::XServiceInfo,
- css::util::XCloneable,
- css::util::XModifyBroadcaster,
- css::util::XModifyListener >
- Title_Base;
-}
-
-class Title final :
- public MutexContainer,
- public impl::Title_Base,
- public ::property::OPropertySet
-{
-public:
- explicit Title();
- virtual ~Title() 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;
-
- /// merge XInterface implementations
- DECLARE_XINTERFACE()
- /// merge XTypeProvider implementations
- DECLARE_XTYPEPROVIDER()
-
-private:
- explicit Title( const Title & rOther );
-
- // ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
-
- // ____ OPropertySet ____
- virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
-
- // ____ XPropertySet ____
- virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
- getPropertySetInfo() override;
-
- // ____ XTitle ____
- virtual css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > > SAL_CALL getText() override;
- virtual void SAL_CALL setText( const css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& Strings ) override;
-
- // ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
-
- // ____ XModifyBroadcaster ____
- virtual void SAL_CALL addModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
- virtual void SAL_CALL removeModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
-
- // ____ XModifyListener ____
- virtual void SAL_CALL modified(
- const css::lang::EventObject& aEvent ) override;
-
- // ____ XEventListener (base of XModifyListener) ____
- virtual void SAL_CALL disposing(
- const css::lang::EventObject& Source ) override;
-
- // ____ OPropertySet ____
- virtual void firePropertyChangeEvent() override;
- using OPropertySet::disposing;
-
- void fireModifyEvent();
-
- css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > > m_aStrings;
-
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
-};
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/UndoManager.cxx b/chart2/source/model/main/UndoManager.cxx
index 63dacf48444c..3688863b3883 100644
--- a/chart2/source/model/main/UndoManager.cxx
+++ b/chart2/source/model/main/UndoManager.cxx
@@ -18,9 +18,9 @@
*/
#include "UndoManager.hxx"
+#include <ChartModel.hxx>
#include <ChartViewHelper.hxx>
-#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/NoSupportException.hpp>
@@ -49,7 +49,7 @@ namespace chart
class UndoManager_Impl : public ::framework::IUndoManagerImplementation
{
public:
- UndoManager_Impl( UndoManager& i_antiImpl, ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ UndoManager_Impl( UndoManager& i_antiImpl, ::chart::ChartModel& i_parent, ::osl::Mutex& i_mutex )
:m_rAntiImpl( i_antiImpl )
,m_rParent( i_parent )
,m_rMutex( i_mutex )
@@ -70,7 +70,7 @@ namespace chart
virtual Reference< XUndoManager > getThis() override;
// attribute access
- ::cppu::OWeakObject& getParent() { return m_rParent; }
+ ::chart::ChartModel& getParent() { return m_rParent; }
::framework::UndoManagerHelper& getUndoHelper() { return m_aUndoHelper; }
// public interface
@@ -83,7 +83,7 @@ namespace chart
private:
UndoManager& m_rAntiImpl;
- ::cppu::OWeakObject& m_rParent;
+ ::chart::ChartModel& m_rParent;
::osl::Mutex& m_rMutex;
bool m_bDisposed;
@@ -172,7 +172,7 @@ namespace chart
using impl::UndoManagerMethodGuard;
- UndoManager::UndoManager( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ UndoManager::UndoManager( ::chart::ChartModel& i_parent, ::osl::Mutex& i_mutex )
:m_pImpl( new impl::UndoManager_Impl( *this, i_parent, i_mutex ) )
{
}
@@ -225,7 +225,7 @@ namespace chart
UndoManagerMethodGuard aGuard( *m_pImpl );
m_pImpl->getUndoHelper().undo( aGuard );
- ChartViewHelper::setViewToDirtyState( Reference< XModel >( getParent(), UNO_QUERY ) );
+ ChartViewHelper::setViewToDirtyState( &m_pImpl->getParent() );
}
void SAL_CALL UndoManager::redo( )
@@ -233,7 +233,7 @@ namespace chart
UndoManagerMethodGuard aGuard( *m_pImpl );
m_pImpl->getUndoHelper().redo( aGuard );
- ChartViewHelper::setViewToDirtyState( Reference< XModel >( getParent(), UNO_QUERY ) );
+ ChartViewHelper::setViewToDirtyState( &m_pImpl->getParent() );
}
sal_Bool SAL_CALL UndoManager::isUndoPossible( )
diff --git a/chart2/source/model/main/UndoManager.hxx b/chart2/source/model/main/UndoManager.hxx
index 4d0a214e5a70..c20dcef6643d 100644
--- a/chart2/source/model/main/UndoManager.hxx
+++ b/chart2/source/model/main/UndoManager.hxx
@@ -28,6 +28,7 @@
namespace chart
{
+class ChartModel;
namespace impl
{
@@ -40,7 +41,7 @@ namespace chart
class UndoManager : public impl::UndoManager_Base
{
public:
- UndoManager( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex );
+ UndoManager( ::chart::ChartModel& i_parent, ::osl::Mutex& i_mutex );
virtual ~UndoManager();
// XInterface
diff --git a/chart2/source/model/main/Wall.cxx b/chart2/source/model/main/Wall.cxx
index 5ba8aaf18401..1bbe133de905 100644
--- a/chart2/source/model/main/Wall.cxx
+++ b/chart2/source/model/main/Wall.cxx
@@ -24,7 +24,6 @@
#include <PropertyHelper.hxx>
#include <ModifyListenerHelper.hxx>
#include <com/sun/star/drawing/LineStyle.hpp>
-#include <tools/diagnose_ex.h>
#include <vector>
#include <algorithm>
@@ -36,69 +35,21 @@ using ::com::sun::star::beans::Property;
namespace
{
-struct StaticWallDefaults_Initializer
+::cppu::OPropertyArrayHelper& StaticWallInfoHelper()
{
- ::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 );
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
- }
-};
-
-struct StaticWallDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticWallDefaults_Initializer >
-{
-};
-
-struct StaticWallInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static uno::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 StaticWallInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticWallInfoHelper_Initializer >
-{
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-struct StaticWallInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticWallInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticWallInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticWallInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -107,19 +58,26 @@ namespace chart
{
Wall::Wall() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
Wall::Wall( const Wall & rOther ) :
impl::Wall_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
Wall::~Wall()
{}
+// ____ XTypeProvider ____
+uno::Sequence< css::uno::Type > SAL_CALL Wall::getTypes()
+{
+ return ::comphelper::concatSequences(
+ impl::Wall_Base::getTypes(),
+ ::property::OPropertySet::getTypes());
+}
+
// ____ XCloneable ____
uno::Reference< util::XCloneable > SAL_CALL Wall::createClone()
{
@@ -127,51 +85,47 @@ uno::Reference< util::XCloneable > SAL_CALL Wall::createClone()
}
// ____ OPropertySet ____
-uno::Any Wall::GetDefaultValue( sal_Int32 nHandle ) const
-{
- const tPropertyValueMap& rStaticDefaults = *StaticWallDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+void Wall::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
+{
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
+ ::chart::FillProperties::AddDefaultsToMap( aTmp );
+
+ // override other defaults
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
+ return aTmp;
+ }();
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL Wall::getInfoHelper()
{
- return *StaticWallInfoHelper::get();
+ return StaticWallInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL Wall::getPropertySetInfo()
{
- return *StaticWallInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticWallInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XModifyBroadcaster ____
void SAL_CALL Wall::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL Wall::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
diff --git a/chart2/source/model/main/Wall.hxx b/chart2/source/model/main/Wall.hxx
index b63a754853b0..6cae798959c1 100644
--- a/chart2/source/model/main/Wall.hxx
+++ b/chart2/source/model/main/Wall.hxx
@@ -19,13 +19,11 @@
#pragma once
#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-#include <MutexContainer.hxx>
#include <OPropertySet.hxx>
#include <cppuhelper/implbase.hxx>
#include <comphelper/uno3.hxx>
+#include <ModifyListenerHelper.hxx>
namespace chart
{
@@ -40,7 +38,6 @@ typedef ::cppu::WeakImplHelper<
}
class Wall final :
- public MutexContainer,
public impl::Wall_Base,
public ::property::OPropertySet
{
@@ -51,11 +48,13 @@ public:
/// merge XInterface implementations
DECLARE_XINTERFACE()
-private:
explicit Wall( const Wall & rOther );
+ // ____ XTypeProvider ____
+ virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
+
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
// ____ OPropertySet ____
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -73,6 +72,7 @@ private:
virtual void SAL_CALL removeModifyListener(
const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
+private:
// ____ XModifyListener ____
virtual void SAL_CALL modified(
const css::lang::EventObject& aEvent ) override;
@@ -87,7 +87,7 @@ private:
private:
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
+ rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder;
};
} // namespace chart
diff --git a/chart2/source/model/template/AreaChartType.cxx b/chart2/source/model/template/AreaChartType.cxx
index 840bdba036d7..b0581ddc8837 100644
--- a/chart2/source/model/template/AreaChartType.cxx
+++ b/chart2/source/model/template/AreaChartType.cxx
@@ -44,6 +44,11 @@ uno::Reference< util::XCloneable > SAL_CALL AreaChartType::createClone()
return uno::Reference< util::XCloneable >( new AreaChartType( *this ));
}
+rtl::Reference< ChartType > AreaChartType::cloneChartType() const
+{
+ return new AreaChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL AreaChartType::getChartType()
{
diff --git a/chart2/source/model/template/AreaChartType.hxx b/chart2/source/model/template/AreaChartType.hxx
index fdd2df3a234b..8ca01e1f3afd 100644
--- a/chart2/source/model/template/AreaChartType.hxx
+++ b/chart2/source/model/template/AreaChartType.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -36,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit AreaChartType( const AreaChartType & rOther );
diff --git a/chart2/source/model/template/AreaChartTypeTemplate.cxx b/chart2/source/model/template/AreaChartTypeTemplate.cxx
index 401dc6971dc9..2ffad2a416fc 100644
--- a/chart2/source/model/template/AreaChartTypeTemplate.cxx
+++ b/chart2/source/model/template/AreaChartTypeTemplate.cxx
@@ -18,15 +18,15 @@
*/
#include "AreaChartTypeTemplate.hxx"
-#include <servicenames_charttypes.hxx>
-#include <DiagramHelper.hxx>
+#include "AreaChartType.hxx"
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <PropertyHelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -54,58 +54,19 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEDEFAULT );
}
-struct StaticAreaChartTypeTemplateDefaults_Initializer
+::cppu::OPropertyArrayHelper& StaticAreaChartTypeTemplateInfoHelper()
{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aStaticDefaults, PROP_AREA_TEMPLATE_DIMENSION, 2 );
- return &aStaticDefaults;
- }
-};
-
-struct StaticAreaChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticAreaChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticAreaChartTypeTemplateInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-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 StaticAreaChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticAreaChartTypeTemplateInfoHelper_Initializer >
-{
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
-struct StaticAreaChartTypeTemplateInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAreaChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticAreaChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticAreaChartTypeTemplateInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -120,7 +81,6 @@ AreaChartTypeTemplate::AreaChartTypeTemplate(
StackMode eStackMode,
sal_Int32 nDim /* = 2 */ ) :
ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex ),
m_eStackMode( eStackMode )
{
setFastPropertyValue_NoBroadcast( PROP_AREA_TEMPLATE_DIMENSION, uno::Any( nDim ));
@@ -130,24 +90,32 @@ AreaChartTypeTemplate::~AreaChartTypeTemplate()
{}
// ____ OPropertySet ____
-uno::Any AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticAreaChartTypeTemplateDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_AREA_TEMPLATE_DIMENSION, 2 );
+ return aTmp;
+ }();
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL AreaChartTypeTemplate::getInfoHelper()
{
- return *StaticAreaChartTypeTemplateInfoHelper::get();
+ return StaticAreaChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL AreaChartTypeTemplate::getPropertySetInfo()
{
- return *StaticAreaChartTypeTemplateInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticAreaChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
}
sal_Int32 AreaChartTypeTemplate::getDimension() const
@@ -172,59 +140,41 @@ StackMode AreaChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ )
return m_eStackMode;
}
-// ____ XChartTypeTemplate ____
-void SAL_CALL AreaChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+// ____ ChartTypeTemplate ____
+void AreaChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
}
-void SAL_CALL AreaChartTypeTemplate::resetStyles( const Reference< chart2::XDiagram >& xDiagram )
+void AreaChartTypeTemplate::resetStyles2( const rtl::Reference< ::chart::Diagram >& xDiagram )
{
- ChartTypeTemplate::resetStyles( xDiagram );
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ ChartTypeTemplate::resetStyles2( xDiagram );
+ std::vector< rtl::Reference< ::chart::DataSeries > > aSeriesVec(
+ xDiagram->getDataSeries());
uno::Any aLineStyleAny( drawing::LineStyle_NONE );
for (auto const& series : aSeriesVec)
{
- Reference< beans::XPropertyState > xState(series, uno::UNO_QUERY);
- Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY);
- if( xState.is() &&
- xProp.is() &&
- xProp->getPropertyValue( "BorderStyle") == aLineStyleAny )
+ if( series->getPropertyValue( "BorderStyle") == aLineStyleAny )
{
- xState->setPropertyToDefault( "BorderStyle");
+ series->setPropertyToDefault( "BorderStyle");
}
}
}
-Reference< chart2::XChartType > AreaChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+rtl::Reference< ChartType > AreaChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
{
- Reference< chart2::XChartType > xResult;
-
- try
- {
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_AREA ), uno::UNO_QUERY_THROW );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
- return xResult;
+ return new AreaChartType();
}
-Reference< chart2::XChartType > SAL_CALL AreaChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > AreaChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult( getChartTypeForIndex( 0 ) );
+ rtl::Reference< ChartType > xResult( getChartTypeForIndex( 0 ) );
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
return xResult;
}
diff --git a/chart2/source/model/template/AreaChartTypeTemplate.hxx b/chart2/source/model/template/AreaChartTypeTemplate.hxx
index dd5c62a3df8f..76a5bfd4c890 100644
--- a/chart2/source/model/template/AreaChartTypeTemplate.hxx
+++ b/chart2/source/model/template/AreaChartTypeTemplate.hxx
@@ -18,18 +18,16 @@
*/
#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <StackMode.hxx>
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
namespace chart
{
class AreaChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -48,27 +46,27 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence<
- css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ // ____ ChartTypeTemplate ____
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
- virtual void SAL_CALL resetStyles(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override;
+ virtual void resetStyles2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram ) override;
// ____ ChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual sal_Int32 getDimension() const override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
diff --git a/chart2/source/model/template/BarChartType.cxx b/chart2/source/model/template/BarChartType.cxx
index d32aa6efeca3..2a94db82ba2a 100644
--- a/chart2/source/model/template/BarChartType.cxx
+++ b/chart2/source/model/template/BarChartType.cxx
@@ -45,6 +45,11 @@ uno::Reference< util::XCloneable > SAL_CALL BarChartType::createClone()
return uno::Reference< util::XCloneable >( new BarChartType( *this ));
}
+rtl::Reference< ChartType > BarChartType::cloneChartType() const
+{
+ return new BarChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL BarChartType::getChartType()
{
diff --git a/chart2/source/model/template/BarChartType.hxx b/chart2/source/model/template/BarChartType.hxx
index 62ed9aa0c2a2..cceaf05777f0 100644
--- a/chart2/source/model/template/BarChartType.hxx
+++ b/chart2/source/model/template/BarChartType.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -36,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit BarChartType( const BarChartType & rOther );
diff --git a/chart2/source/model/template/BarChartTypeTemplate.cxx b/chart2/source/model/template/BarChartTypeTemplate.cxx
index dce1ffbb09d9..2b649ec43364 100644
--- a/chart2/source/model/template/BarChartTypeTemplate.cxx
+++ b/chart2/source/model/template/BarChartTypeTemplate.cxx
@@ -18,17 +18,16 @@
*/
#include "BarChartTypeTemplate.hxx"
-#include <DiagramHelper.hxx>
-#include <servicenames_charttypes.hxx>
+#include "ColumnChartType.hxx"
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <PropertyHelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/chart2/DataPointGeometry3D.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -62,64 +61,19 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEDEFAULT );
}
-struct StaticBarChartTypeTemplateDefaults_Initializer
+::cppu::OPropertyArrayHelper& StaticBarChartTypeTemplateInfoHelper()
{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_BAR_TEMPLATE_DIMENSION, 2 );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BAR_TEMPLATE_GEOMETRY3D, ::chart2::DataPointGeometry3D::CUBOID );
- }
-};
-
-struct StaticBarChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBarChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticBarChartTypeTemplateInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static 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 StaticBarChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBarChartTypeTemplateInfoHelper_Initializer >
-{
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
-struct StaticBarChartTypeTemplateInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBarChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticBarChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBarChartTypeTemplateInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -135,7 +89,6 @@ BarChartTypeTemplate::BarChartTypeTemplate(
BarDirection eDirection,
sal_Int32 nDim /* = 2 */ ) :
ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex ),
m_eStackMode( eStackMode ),
m_eBarDirection( eDirection ),
m_nDim( nDim )
@@ -159,19 +112,19 @@ bool BarChartTypeTemplate::isSwapXAndY() const
return (m_eBarDirection == HORIZONTAL);
}
-// ____ XChartTypeTemplate ____
-sal_Bool SAL_CALL BarChartTypeTemplate::matchesTemplate(
- const Reference< chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties )
+// ____ ChartTypeTemplate ____
+bool BarChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties )
{
- bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
+ bool bResult = ChartTypeTemplate::matchesTemplate2( xDiagram, bAdaptProperties );
//check BarDirection
if( bResult )
{
bool bFound = false;
bool bAmbiguous = false;
- bool bVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
+ bool bVertical = xDiagram->getVertical( bFound, bAmbiguous );
if( m_eBarDirection == HORIZONTAL )
bResult = bVertical;
else if( m_eBarDirection == VERTICAL )
@@ -185,7 +138,7 @@ sal_Bool SAL_CALL BarChartTypeTemplate::matchesTemplate(
{
bool bGeomFound = false, bGeomAmbiguous = false;
- sal_Int32 aCommonGeom = DiagramHelper::getGeometry3D( xDiagram, bGeomFound, bGeomAmbiguous );
+ sal_Int32 aCommonGeom = xDiagram->getGeometry3D( bGeomFound, bGeomAmbiguous );
if( !bGeomAmbiguous )
{
@@ -196,61 +149,57 @@ sal_Bool SAL_CALL BarChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< chart2::XChartType > BarChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
-{
- Reference< chart2::XChartType > xResult;
-
- try
- {
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY_THROW );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
- return xResult;
+rtl::Reference< ChartType > BarChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+{
+ return new ColumnChartType();
}
-Reference< chart2::XChartType > SAL_CALL BarChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > BarChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult( getChartTypeForIndex( 0 ) );
+ rtl::Reference< ChartType > xResult( getChartTypeForIndex( 0 ) );
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
return xResult;
}
// ____ OPropertySet ____
-uno::Any BarChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void BarChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticBarChartTypeTemplateDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_BAR_TEMPLATE_DIMENSION, 2 );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_BAR_TEMPLATE_GEOMETRY3D, ::chart2::DataPointGeometry3D::CUBOID );
+ return aTmp;
+ }();
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL BarChartTypeTemplate::getInfoHelper()
{
- return *StaticBarChartTypeTemplateInfoHelper::get();
+ return StaticBarChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL BarChartTypeTemplate::getPropertySetInfo()
{
- return *StaticBarChartTypeTemplateInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticBarChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
}
-void SAL_CALL BarChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void BarChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
if( getDimension() != 3 )
return;
@@ -268,39 +217,32 @@ void SAL_CALL BarChartTypeTemplate::applyStyle(
}
}
-void SAL_CALL BarChartTypeTemplate::resetStyles(
- const Reference< chart2::XDiagram >& xDiagram )
+void BarChartTypeTemplate::resetStyles2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram )
{
- ChartTypeTemplate::resetStyles( xDiagram );
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ ChartTypeTemplate::resetStyles2( xDiagram );
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec(
+ xDiagram->getDataSeries());
uno::Any aLineStyleAny( drawing::LineStyle_NONE );
for (auto const& series : aSeriesVec)
{
- Reference< beans::XPropertyState > xState(series, uno::UNO_QUERY);
- if( xState.is())
+ if( getDimension() == 3 )
+ series->setPropertyToDefault( "Geometry3D");
+ if( series->getPropertyValue( "BorderStyle") == aLineStyleAny )
{
- if( getDimension() == 3 )
- xState->setPropertyToDefault( "Geometry3D");
- Reference< beans::XPropertySet > xProp( xState, uno::UNO_QUERY );
- if( xProp.is() &&
- xProp->getPropertyValue( "BorderStyle") == aLineStyleAny )
- {
- xState->setPropertyToDefault( "BorderStyle");
- }
+ series->setPropertyToDefault( "BorderStyle");
}
}
- DiagramHelper::setVertical( xDiagram, false );
+ xDiagram->setVertical( false );
}
void BarChartTypeTemplate::createCoordinateSystems(
- const Reference< chart2::XCoordinateSystemContainer > & xCooSysCnt )
+ const rtl::Reference< ::chart::Diagram > & xDiagram )
{
- ChartTypeTemplate::createCoordinateSystems( xCooSysCnt );
+ ChartTypeTemplate::createCoordinateSystems( xDiagram );
- Reference< chart2::XDiagram > xDiagram( xCooSysCnt, uno::UNO_QUERY );
- DiagramHelper::setVertical( xDiagram, m_eBarDirection == HORIZONTAL );
+ xDiagram->setVertical( m_eBarDirection == HORIZONTAL );
}
IMPLEMENT_FORWARD_XINTERFACE2( BarChartTypeTemplate, ChartTypeTemplate, OPropertySet )
diff --git a/chart2/source/model/template/BarChartTypeTemplate.hxx b/chart2/source/model/template/BarChartTypeTemplate.hxx
index 350a62517965..ab56869e71cd 100644
--- a/chart2/source/model/template/BarChartTypeTemplate.hxx
+++ b/chart2/source/model/template/BarChartTypeTemplate.hxx
@@ -19,17 +19,15 @@
#pragma once
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <StackMode.hxx>
namespace chart
{
class BarChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -55,37 +53,35 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence<
- css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ // ____ ChartTypeTemplate ____
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
- virtual void SAL_CALL resetStyles(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override;
-
- // ____ ChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual void resetStyles2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram ) override;
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual sal_Int32 getDimension() const override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
virtual bool isSwapXAndY() const override;
virtual void createCoordinateSystems(
- const css::uno::Reference< css::chart2::XCoordinateSystemContainer > & xCooSysCnt ) override;
+ const rtl::Reference< ::chart::Diagram > & xDiagram ) override;
private:
StackMode m_eStackMode;
diff --git a/chart2/source/model/template/BubbleChartType.cxx b/chart2/source/model/template/BubbleChartType.cxx
index 1998eb9e4dc7..bd8bf287d96a 100644
--- a/chart2/source/model/template/BubbleChartType.cxx
+++ b/chart2/source/model/template/BubbleChartType.cxx
@@ -21,6 +21,7 @@
#include <PropertyHelper.hxx>
#include <servicenames_charttypes.hxx>
#include <CartesianCoordinateSystem.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
#include <AxisIndexDefines.hxx>
#include <com/sun/star/chart2/AxisType.hpp>
@@ -35,55 +36,16 @@ using ::com::sun::star::uno::Reference;
namespace
{
-struct StaticBubbleChartTypeDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- return &aStaticDefaults;
- }
-};
-
-struct StaticBubbleChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeDefaults_Initializer >
-{
-};
-
-struct StaticBubbleChartTypeInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-};
-
-struct StaticBubbleChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeInfoHelper_Initializer >
-{
-};
-
-struct StaticBubbleChartTypeInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticBubbleChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeInfo_Initializer >
+::cppu::OPropertyArrayHelper& StaticBubbleChartTypeInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -109,16 +71,21 @@ uno::Reference< util::XCloneable > SAL_CALL BubbleChartType::createClone()
return uno::Reference< util::XCloneable >( new BubbleChartType( *this ));
}
+rtl::Reference< ChartType > BubbleChartType::cloneChartType() const
+{
+ return new BubbleChartType( *this );
+}
+
// ____ XChartType ____
-Reference< chart2::XCoordinateSystem > SAL_CALL
- BubbleChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
+rtl::Reference< ::chart::BaseCoordinateSystem >
+ BubbleChartType::createCoordinateSystem2( sal_Int32 DimensionCount )
{
- Reference< chart2::XCoordinateSystem > xResult(
- new CartesianCoordinateSystem( DimensionCount ));
+ rtl::Reference< CartesianCoordinateSystem > xResult =
+ new CartesianCoordinateSystem( DimensionCount );
for( sal_Int32 i=0; i<DimensionCount; ++i )
{
- Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
+ rtl::Reference< Axis > xAxis = xResult->getAxisByDimension2( i, MAIN_AXIS_INDEX );
if( !xAxis.is() )
{
OSL_FAIL("a created coordinate system should have an axis for each dimension");
@@ -161,25 +128,28 @@ OUString SAL_CALL BubbleChartType::getRoleOfSequenceForSeriesLabel()
}
// ____ OPropertySet ____
-uno::Any BubbleChartType::GetDefaultValue( sal_Int32 nHandle ) const
-{
- const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+void BubbleChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
+{
+ static ::chart::tPropertyValueMap aStaticDefaults;
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartType::getInfoHelper()
{
- return *StaticBubbleChartTypeInfoHelper::get();
+ return StaticBubbleChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartType::getPropertySetInfo()
{
- return *StaticBubbleChartTypeInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticBubbleChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
}
OUString SAL_CALL BubbleChartType::getImplementationName()
diff --git a/chart2/source/model/template/BubbleChartType.hxx b/chart2/source/model/template/BubbleChartType.hxx
index a7d75ea94088..a2afa7e6941d 100644
--- a/chart2/source/model/template/BubbleChartType.hxx
+++ b/chart2/source/model/template/BubbleChartType.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -36,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit BubbleChartType( const BubbleChartType & rOther );
@@ -45,12 +47,10 @@ private:
getSupportedMandatoryRoles() override;
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedPropertyRoles() override;
- virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL
- createCoordinateSystem( ::sal_Int32 DimensionCount ) override;
virtual OUString SAL_CALL getRoleOfSequenceForSeriesLabel() override;
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
// ____ OPropertySet ____
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -61,6 +61,9 @@ private:
// ____ XCloneable ____
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+
+ virtual rtl::Reference< ::chart::BaseCoordinateSystem >
+ createCoordinateSystem2( sal_Int32 DimensionCount ) override;
};
} // namespace chart
diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.cxx b/chart2/source/model/template/BubbleChartTypeTemplate.cxx
index 90ec1a75db21..55f39ef0669b 100644
--- a/chart2/source/model/template/BubbleChartTypeTemplate.cxx
+++ b/chart2/source/model/template/BubbleChartTypeTemplate.cxx
@@ -18,14 +18,14 @@
*/
#include "BubbleChartTypeTemplate.hxx"
+#include "BubbleChartType.hxx"
#include "BubbleDataInterpreter.hxx"
-#include <servicenames_charttypes.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <PropertyHelper.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -38,56 +38,16 @@ using ::com::sun::star::beans::Property;
namespace
{
-struct StaticBubbleChartTypeTemplateDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- return &aStaticDefaults;
- }
-};
-
-struct StaticBubbleChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticBubbleChartTypeTemplateInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticBubbleChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeTemplateInfoHelper_Initializer >
-{
-};
-
-struct StaticBubbleChartTypeTemplateInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticBubbleChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeTemplateInfo_Initializer >
+::cppu::OPropertyArrayHelper & StaticBubbleChartTypeTemplateInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -99,8 +59,7 @@ BubbleChartTypeTemplate::BubbleChartTypeTemplate(
Reference<
uno::XComponentContext > const & xContext,
const OUString & rServiceName ) :
- ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex )
+ ChartTypeTemplate( xContext, rServiceName )
{
}
@@ -108,24 +67,27 @@ BubbleChartTypeTemplate::~BubbleChartTypeTemplate()
{}
// ____ OPropertySet ____
-uno::Any BubbleChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
-{
- const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeTemplateDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+void BubbleChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
+{
+ static ::chart::tPropertyValueMap aStaticDefaults;
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartTypeTemplate::getInfoHelper()
{
- return *StaticBubbleChartTypeTemplateInfoHelper::get();
+ return StaticBubbleChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartTypeTemplate::getPropertySetInfo()
{
- return *StaticBubbleChartTypeTemplateInfo::get();
+ static const uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticBubbleChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
}
sal_Int32 BubbleChartTypeTemplate::getDimension() const
@@ -138,13 +100,13 @@ StackMode BubbleChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */
return StackMode::NONE;
}
-void SAL_CALL BubbleChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void BubbleChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
}
@@ -154,36 +116,19 @@ sal_Bool SAL_CALL BubbleChartTypeTemplate::supportsCategories()
return false;
}
-Reference< chart2::XChartType > BubbleChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+rtl::Reference< ChartType > BubbleChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
{
- Reference< chart2::XChartType > xResult;
-
- try
- {
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE ), uno::UNO_QUERY_THROW );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
- return xResult;
+ return new BubbleChartType();
}
-Reference< chart2::XChartType > SAL_CALL BubbleChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > BubbleChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE ), uno::UNO_QUERY_THROW );
+ xResult = new BubbleChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
}
@@ -195,7 +140,7 @@ Reference< chart2::XChartType > SAL_CALL BubbleChartTypeTemplate::getChartTypeFo
return xResult;
}
-Reference< chart2::XDataInterpreter > SAL_CALL BubbleChartTypeTemplate::getDataInterpreter()
+rtl::Reference< DataInterpreter > BubbleChartTypeTemplate::getDataInterpreter2()
{
if( ! m_xDataInterpreter.is())
m_xDataInterpreter.set( new BubbleDataInterpreter );
diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.hxx b/chart2/source/model/template/BubbleChartTypeTemplate.hxx
index 1a75035cd0d3..8a59e5e72817 100644
--- a/chart2/source/model/template/BubbleChartTypeTemplate.hxx
+++ b/chart2/source/model/template/BubbleChartTypeTemplate.hxx
@@ -18,16 +18,14 @@
*/
#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
namespace chart
{
class BubbleChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -44,26 +42,27 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
+ // ____ ChartTypeTemplate ____
virtual sal_Bool SAL_CALL supportsCategories() override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual css::uno::Reference< css::chart2::XDataInterpreter > SAL_CALL getDataInterpreter() override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual rtl::Reference< ::chart::DataInterpreter > getDataInterpreter2() override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
// ____ ChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual sal_Int32 getDimension() const override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
diff --git a/chart2/source/model/template/BubbleDataInterpreter.cxx b/chart2/source/model/template/BubbleDataInterpreter.cxx
index 09fd1c25d7da..bb468fd9723d 100644
--- a/chart2/source/model/template/BubbleDataInterpreter.cxx
+++ b/chart2/source/model/template/BubbleDataInterpreter.cxx
@@ -17,17 +17,19 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cstddef>
+
#include "BubbleDataInterpreter.hxx"
#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <CommonConverters.hxx>
-#include <com/sun/star/chart2/data/XDataSink.hpp>
#include <com/sun/star/util/XCloneable.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
-using namespace ::std;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -44,25 +46,25 @@ BubbleDataInterpreter::~BubbleDataInterpreter()
}
// ____ XDataInterpreter ____
-chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
+InterpretedData BubbleDataInterpreter::interpretDataSource(
const Reference< chart2::data::XDataSource >& xSource,
const Sequence< beans::PropertyValue >& aArguments,
- const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+ const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
{
if( ! xSource.is())
return InterpretedData();
- Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aData = DataInterpreter::getDataSequences(xSource);
- Reference< data::XLabeledDataSequence > xValuesX;
- vector< Reference< data::XLabeledDataSequence > > aYValuesVector;
- vector< Reference< data::XLabeledDataSequence > > aSizeValuesVector;
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesX;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aYValuesVector;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSizeValuesVector;
- Reference< data::XLabeledDataSequence > xCategories;
+ uno::Reference< chart2::data::XLabeledDataSequence > xCategories;
bool bHasCategories = HasCategories( aArguments, aData );
bool bUseCategoriesAsX = UseCategoriesAsX( aArguments );
- sal_Int32 nDataSeqCount = aData.getLength();
+ sal_Int32 nDataSeqCount = aData.size();
bool bSetXValues = bHasCategories ? ( (nDataSeqCount-1) > 2 && (nDataSeqCount-1) % 2 != 0 )
:( nDataSeqCount > 2 && nDataSeqCount % 2 != 0 );
@@ -75,7 +77,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
{
if( bHasCategories && !bCategoriesUsed )
{
- xCategories.set( aData[nDataIdx] );
+ xCategories = aData[nDataIdx];
if( xCategories.is())
{
SetRole( xCategories->getValues(), "categories");
@@ -89,7 +91,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
}
else if( !xValuesX.is() && bSetXValues )
{
- xValuesX.set( aData[nDataIdx] );
+ xValuesX = aData[nDataIdx];
if( xValuesX.is())
SetRole( xValuesX->getValues(), "values-x");
}
@@ -115,8 +117,8 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
}
// create DataSeries
- sal_Int32 nSeriesIndex = 0;
- vector< Reference< XDataSeries > > aSeriesVec;
+ std::size_t nSeriesIndex = 0;
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec;
aSeriesVec.reserve( aSizeValuesVector.size());
Reference< data::XLabeledDataSequence > xClonedXValues = xValuesX;
@@ -124,7 +126,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
for( size_t nN = 0; nN < aSizeValuesVector.size(); ++nN, ++nSeriesIndex )
{
- vector< Reference< data::XLabeledDataSequence > > aNewData;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewData;
if( xValuesX.is() )
{
if( nN > 0 && xCloneableX.is() )
@@ -135,51 +137,48 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
aNewData.push_back( aYValuesVector[nN] );
aNewData.push_back(aSizeValuesVector[nN]);
- Reference< XDataSeries > xSeries;
- if( nSeriesIndex < aSeriesToReUse.getLength())
- xSeries.set( aSeriesToReUse[nSeriesIndex] );
+ rtl::Reference< DataSeries > xSeries;
+ if( nSeriesIndex < aSeriesToReUse.size())
+ xSeries = aSeriesToReUse[nSeriesIndex];
else
- xSeries.set( new DataSeries );
- OSL_ASSERT( xSeries.is() );
- Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
- OSL_ASSERT( xSink.is() );
- xSink->setData( comphelper::containerToSequence( aNewData ) );
+ xSeries = new DataSeries;
+ assert( xSeries.is() );
+ xSeries->setData( aNewData );
aSeriesVec.push_back( xSeries );
}
- return InterpretedData( { comphelper::containerToSequence(aSeriesVec) }, xCategories );
+ return { { aSeriesVec }, xCategories };
}
-chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
- const chart2::InterpretedData& aInterpretedData )
+InterpretedData BubbleDataInterpreter::reinterpretDataSeries(
+ const InterpretedData& aInterpretedData )
{
InterpretedData aResult( aInterpretedData );
sal_Int32 i=0;
- Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- const sal_Int32 nCount = aSeries.getLength();
+ std::vector< rtl::Reference< DataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ const sal_Int32 nCount = aSeries.size();
for( ; i<nCount; ++i )
{
try
{
- Reference< data::XDataSource > xSeriesSource( aSeries[i], uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aNewSequences;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewSequences;
- Reference< data::XLabeledDataSequence > xValuesSize(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-size" ));
- Reference< data::XLabeledDataSequence > xValuesY(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-y" ));
- Reference< data::XLabeledDataSequence > xValuesX(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-x" ));
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesSize(
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values-size" ));
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesY(
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values-y" ));
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesX(
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values-x" ));
if( ! xValuesX.is() ||
! xValuesY.is() ||
! xValuesSize.is() )
{
- vector< Reference< data::XLabeledDataSequence > > aValueSeqVec(
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aValueSeqVec(
DataSeriesHelper::getAllDataSequencesByRole(
- xSeriesSource->getDataSequences(), "values" ));
+ aSeries[i]->getDataSequences2(), "values" ));
if( xValuesX.is())
aValueSeqVec.erase( find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesX ));
if( xValuesY.is())
@@ -192,7 +191,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
if( ! xValuesSize.is() &&
aValueSeqVec.size() > nIndex )
{
- xValuesSize.set( aValueSeqVec[nIndex++] );
+ xValuesSize = aValueSeqVec[nIndex++];
if( xValuesSize.is())
SetRole( xValuesSize->getValues(), "values-size");
}
@@ -200,7 +199,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
if( ! xValuesY.is() &&
aValueSeqVec.size() > nIndex )
{
- xValuesY.set( aValueSeqVec[nIndex++] );
+ xValuesY = aValueSeqVec[nIndex++];
if( xValuesY.is())
SetRole( xValuesY->getValues(), "values-y");
}
@@ -208,7 +207,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
if( ! xValuesX.is() &&
aValueSeqVec.size() > nIndex )
{
- xValuesX.set( aValueSeqVec[nIndex++] );
+ xValuesX = aValueSeqVec[nIndex++];
if( xValuesX.is())
SetRole( xValuesY->getValues(), "values-x");
}
@@ -232,8 +231,8 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
}
}
- const Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
- if( aSeqs.getLength() != aNewSequences.getLength() )
+ const std::vector< uno::Reference< data::XLabeledDataSequence > > & aSeqs = aSeries[i]->getDataSequences2();
+ if( aSeqs.size() != aNewSequences.size() )
{
#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
for( auto const & j : aSeqs )
@@ -241,8 +240,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
assert( (j == xValuesY || j == xValuesX || j == xValuesSize) && "All sequences should be used" );
}
#endif
- Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
- xSink->setData( aNewSequences );
+ aSeries[i]->setData( aNewSequences );
}
}
catch( const uno::Exception & )
@@ -254,17 +252,15 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
return aResult;
}
-sal_Bool SAL_CALL BubbleDataInterpreter::isDataCompatible(
- const chart2::InterpretedData& aInterpretedData )
+bool BubbleDataInterpreter::isDataCompatible(
+ const InterpretedData& aInterpretedData )
{
- const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- for( Reference< XDataSeries > const & dataSeries : aSeries )
+ const std::vector< rtl::Reference< DataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ for( rtl::Reference< DataSeries > const & dataSeries : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
- if( aSeq.getLength() != 3 )
+ if( dataSeries->getDataSequences2().size() != 3 )
return false;
}
catch( const uno::Exception & )
diff --git a/chart2/source/model/template/BubbleDataInterpreter.hxx b/chart2/source/model/template/BubbleDataInterpreter.hxx
index e5a9041a75e3..ff4b56de615a 100644
--- a/chart2/source/model/template/BubbleDataInterpreter.hxx
+++ b/chart2/source/model/template/BubbleDataInterpreter.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "DataInterpreter.hxx"
+#include <DataInterpreter.hxx>
namespace chart
{
@@ -30,15 +30,15 @@ public:
virtual ~BubbleDataInterpreter() override;
protected:
- // ____ XDataInterpreter ____
- virtual css::chart2::InterpretedData SAL_CALL interpretDataSource(
+ // ____ DataInterpreter ____
+ virtual InterpretedData interpretDataSource(
const css::uno::Reference< css::chart2::data::XDataSource >& xSource,
const css::uno::Sequence< css::beans::PropertyValue >& aArguments,
- const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > >& aSeriesToReUse ) override;
- virtual css::chart2::InterpretedData SAL_CALL reinterpretDataSeries(
- const css::chart2::InterpretedData& aInterpretedData ) override;
- virtual sal_Bool SAL_CALL isDataCompatible(
- const css::chart2::InterpretedData& aInterpretedData ) override;
+ const std::vector< rtl::Reference< ::chart::DataSeries > >& aSeriesToReUse ) override;
+ virtual InterpretedData reinterpretDataSeries(
+ const InterpretedData& aInterpretedData ) override;
+ virtual bool isDataCompatible(
+ const InterpretedData& aInterpretedData ) override;
};
} // namespace chart
diff --git a/chart2/source/model/template/CandleStickChartType.cxx b/chart2/source/model/template/CandleStickChartType.cxx
index af0c1f04f52b..247a68406808 100644
--- a/chart2/source/model/template/CandleStickChartType.cxx
+++ b/chart2/source/model/template/CandleStickChartType.cxx
@@ -24,7 +24,7 @@
#include <servicenames_charttypes.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
namespace com::sun::star::uno { class XComponentContext; }
@@ -79,66 +79,17 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEDEFAULT );
}
-struct StaticCandleStickChartTypeDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- // must match default in CTOR!
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_JAPANESE, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW, true );
- }
-};
-
-struct StaticCandleStickChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticCandleStickChartTypeDefaults_Initializer >
-{
-};
-
-struct StaticCandleStickChartTypeInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static 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 StaticCandleStickChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticCandleStickChartTypeInfoHelper_Initializer >
-{
-};
-
-struct StaticCandleStickChartTypeInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticCandleStickChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticCandleStickChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticCandleStickChartTypeInfo_Initializer >
+::cppu::OPropertyArrayHelper& StaticCandleStickChartTypeInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -206,6 +157,11 @@ uno::Reference< util::XCloneable > SAL_CALL CandleStickChartType::createClone()
return uno::Reference< util::XCloneable >( new CandleStickChartType( *this ));
}
+rtl::Reference< ChartType > CandleStickChartType::cloneChartType() const
+{
+ return new CandleStickChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL CandleStickChartType::getChartType()
{
@@ -263,25 +219,36 @@ OUString SAL_CALL CandleStickChartType::getRoleOfSequenceForSeriesLabel()
}
// ____ OPropertySet ____
-uno::Any CandleStickChartType::GetDefaultValue( sal_Int32 nHandle ) const
+void CandleStickChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticCandleStickChartTypeDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ static const ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ // must match default in CTOR!
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_CANDLESTICKCHARTTYPE_JAPANESE, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW, true );
+ return aTmp;
+ }();
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL CandleStickChartType::getInfoHelper()
{
- return *StaticCandleStickChartTypeInfoHelper::get();
+ return StaticCandleStickChartTypeInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL CandleStickChartType::getPropertySetInfo()
{
- return *StaticCandleStickChartTypeInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticCandleStickChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
}
void SAL_CALL CandleStickChartType::setFastPropertyValue_NoBroadcast(
diff --git a/chart2/source/model/template/CandleStickChartType.hxx b/chart2/source/model/template/CandleStickChartType.hxx
index 13dfb30db47f..822422aac85f 100644
--- a/chart2/source/model/template/CandleStickChartType.hxx
+++ b/chart2/source/model/template/CandleStickChartType.hxx
@@ -18,14 +18,12 @@
*/
#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
-// see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100797> "[10/11/12 Regression] using
-// declaration causing virtual call with wrongly adjusted this pointer" before restoring 'final'
-class CandleStickChartType /* final */ : public ChartType
+class CandleStickChartType final : public ChartType
{
public:
explicit CandleStickChartType();
@@ -38,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit CandleStickChartType( const CandleStickChartType & rOther );
@@ -50,7 +50,7 @@ private:
virtual OUString SAL_CALL getRoleOfSequenceForSeriesLabel() override;
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
// ____ OPropertySet ____
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
diff --git a/chart2/source/model/template/ChartType.cxx b/chart2/source/model/template/ChartType.cxx
index 5eb0adca0f06..9448a766071c 100644
--- a/chart2/source/model/template/ChartType.cxx
+++ b/chart2/source/model/template/ChartType.cxx
@@ -17,16 +17,18 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "ChartType.hxx"
+#include <ChartType.hxx>
#include <CartesianCoordinateSystem.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
#include <CloneHelper.hxx>
#include <AxisIndexDefines.hxx>
#include <ModifyListenerHelper.hxx>
+#include <DataSeries.hxx>
#include <vcl/svapp.hxx>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/container/NoSuchElementException.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::com::sun::star;
@@ -38,20 +40,19 @@ namespace chart
{
ChartType::ChartType() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_bNotifyChanges( true )
{}
ChartType::ChartType( const ChartType & rOther ) :
impl::ChartType_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_bNotifyChanges( true )
{
{
SolarMutexGuard g; // access to rOther.m_aDataSeries
- CloneHelper::CloneRefVector<css::chart2::XDataSeries>(
+ CloneHelper::CloneRefVector(
rOther.m_aDataSeries, m_aDataSeries);
}
ModifyListenerHelper::addListenerToAllElements( m_aDataSeries, m_xModifyEventForwarder );
@@ -67,12 +68,18 @@ ChartType::~ChartType()
Reference< chart2::XCoordinateSystem > SAL_CALL
ChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
{
- Reference< chart2::XCoordinateSystem > xResult(
- new CartesianCoordinateSystem( DimensionCount ));
+ return createCoordinateSystem2(DimensionCount);
+}
+
+rtl::Reference< BaseCoordinateSystem >
+ ChartType::createCoordinateSystem2( ::sal_Int32 DimensionCount )
+{
+ rtl::Reference< CartesianCoordinateSystem > xResult =
+ new CartesianCoordinateSystem( DimensionCount );
for( sal_Int32 i=0; i<DimensionCount; ++i )
{
- Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
+ rtl::Reference< Axis > xAxis = xResult->getAxisByDimension2( i, MAIN_AXIS_INDEX );
if( !xAxis.is() )
{
OSL_FAIL("a created coordinate system should have an axis for each dimension");
@@ -117,7 +124,7 @@ OUString SAL_CALL ChartType::getRoleOfSequenceForSeriesLabel()
}
void ChartType::impl_addDataSeriesWithoutNotification(
- const Reference< chart2::XDataSeries >& xDataSeries )
+ const rtl::Reference< DataSeries >& xDataSeries )
{
if( std::find( m_aDataSeries.begin(), m_aDataSeries.end(), xDataSeries )
!= m_aDataSeries.end())
@@ -130,6 +137,13 @@ void ChartType::impl_addDataSeriesWithoutNotification(
// ____ XDataSeriesContainer ____
void SAL_CALL ChartType::addDataSeries( const Reference< chart2::XDataSeries >& xDataSeries )
{
+ rtl::Reference<DataSeries> xTmp = dynamic_cast<DataSeries*>(xDataSeries.get());
+ assert(xTmp);
+ addDataSeries(xTmp);
+}
+
+void ChartType::addDataSeries( const rtl::Reference< DataSeries >& xDataSeries )
+{
SolarMutexGuard g;
impl_addDataSeriesWithoutNotification( xDataSeries );
@@ -138,13 +152,19 @@ void SAL_CALL ChartType::addDataSeries( const Reference< chart2::XDataSeries >&
void SAL_CALL ChartType::removeDataSeries( const Reference< chart2::XDataSeries >& xDataSeries )
{
+ rtl::Reference<DataSeries> xTmp = dynamic_cast<DataSeries*>(xDataSeries.get());
+ assert(xTmp);
+ removeDataSeries(xTmp);
+}
+
+void ChartType::removeDataSeries( const rtl::Reference< DataSeries >& xDataSeries )
+{
if( !xDataSeries.is())
throw container::NoSuchElementException();
SolarMutexGuard g;
- tDataSeriesContainerType::iterator aIt(
- std::find( m_aDataSeries.begin(), m_aDataSeries.end(), xDataSeries ) );
+ auto aIt = std::find( m_aDataSeries.begin(), m_aDataSeries.end(), xDataSeries );
if( aIt == m_aDataSeries.end())
throw container::NoSuchElementException(
@@ -160,18 +180,29 @@ Sequence< Reference< chart2::XDataSeries > > SAL_CALL ChartType::getDataSeries()
{
SolarMutexGuard g;
- return comphelper::containerToSequence( m_aDataSeries );
+ return comphelper::containerToSequence< Reference< chart2::XDataSeries > >( m_aDataSeries );
}
void SAL_CALL ChartType::setDataSeries( const Sequence< Reference< chart2::XDataSeries > >& aDataSeries )
{
+ std::vector< rtl::Reference<DataSeries> > aTmp;
+ for (auto const & i : aDataSeries)
+ {
+ auto p = dynamic_cast<DataSeries*>(i.get());
+ assert(p);
+ aTmp.push_back(p);
+ }
+ setDataSeries(aTmp);
+}
+
+void ChartType::setDataSeries( const std::vector< rtl::Reference< DataSeries > >& aDataSeries )
+{
SolarMutexGuard g;
m_bNotifyChanges = false;
try
{
- const Sequence< Reference< chart2::XDataSeries > > aOldSeries( getDataSeries() );
- for( auto const & i : aOldSeries )
+ for( auto const & i : m_aDataSeries )
ModifyListenerHelper::removeListener( i, m_xModifyEventForwarder );
m_aDataSeries.clear();
@@ -188,39 +219,18 @@ void SAL_CALL ChartType::setDataSeries( const Sequence< Reference< chart2::XData
}
// ____ OPropertySet ____
-uno::Any ChartType::GetDefaultValue( sal_Int32 /* nHandle */ ) const
+void ChartType::GetDefaultValue( sal_Int32 /* nHandle */, uno::Any& rAny ) const
{
- return uno::Any();
+ rAny.clear();
}
namespace
{
-struct StaticChartTypeInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( Sequence< beans::Property >{} );
- return &aPropHelper;
- }
-};
-
-struct StaticChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticChartTypeInfoHelper_Initializer >
-{
-};
-
-struct StaticChartTypeInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticChartTypeInfo_Initializer >
+::cppu::OPropertyArrayHelper& StaticChartTypeInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper( Sequence< beans::Property >{} );
+ return aPropHelper;
};
}
@@ -228,13 +238,15 @@ struct StaticChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans:
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL ChartType::getInfoHelper()
{
- return *StaticChartTypeInfoHelper::get();
+ return StaticChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL ChartType::getPropertySetInfo()
{
- return *StaticChartTypeInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo( StaticChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XModifyBroadcaster ____
@@ -242,8 +254,7 @@ void SAL_CALL ChartType::addModifyListener( const uno::Reference< util::XModifyL
{
try
{
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
catch( const uno::Exception & )
{
@@ -255,8 +266,7 @@ void SAL_CALL ChartType::removeModifyListener( const uno::Reference< util::XModi
{
try
{
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
catch( const uno::Exception & )
{
diff --git a/chart2/source/model/template/ChartType.hxx b/chart2/source/model/template/ChartType.hxx
deleted file mode 100644
index 9606275abd64..000000000000
--- a/chart2/source/model/template/ChartType.hxx
+++ /dev/null
@@ -1,137 +0,0 @@
-/* -*- 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 <MutexContainer.hxx>
-#include <OPropertySet.hxx>
-#include <cppuhelper/implbase.hxx>
-#include <comphelper/uno3.hxx>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/chart2/XChartType.hpp>
-#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-
-#include <vector>
-
-namespace chart
-{
-
-namespace impl
-{
-typedef ::cppu::WeakImplHelper<
- css::lang::XServiceInfo,
- css::chart2::XChartType,
- css::chart2::XDataSeriesContainer,
- css::util::XCloneable,
- css::util::XModifyBroadcaster,
- css::util::XModifyListener >
- ChartType_Base;
-}
-
-class ChartType :
- public MutexContainer,
- public impl::ChartType_Base,
- public ::property::OPropertySet
-{
-public:
- explicit ChartType();
- virtual ~ChartType() override;
-
- /// merge XInterface implementations
- DECLARE_XINTERFACE()
-
-protected:
- explicit ChartType( const ChartType & rOther );
-
- // ____ XChartType ____
- // still abstract ! implement !
- virtual OUString SAL_CALL getChartType() override = 0;
- virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL
- createCoordinateSystem( ::sal_Int32 DimensionCount ) override;
- virtual css::uno::Sequence< OUString > SAL_CALL
- getSupportedMandatoryRoles() override;
- virtual css::uno::Sequence< OUString > SAL_CALL
- getSupportedOptionalRoles() override;
- virtual OUString SAL_CALL getRoleOfSequenceForSeriesLabel() override;
- virtual css::uno::Sequence< OUString > SAL_CALL
- getSupportedPropertyRoles() override;
-
- // ____ XDataSeriesContainer ____
- virtual void SAL_CALL addDataSeries(
- const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries ) override;
- virtual void SAL_CALL removeDataSeries(
- const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries ) override;
- virtual css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > > SAL_CALL getDataSeries() override;
- virtual void SAL_CALL setDataSeries(
- const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > >& aDataSeries ) override;
-
- // ____ XModifyBroadcaster ____
- virtual void SAL_CALL addModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
- virtual void SAL_CALL removeModifyListener(
- const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
-
- // ____ XModifyListener ____
- virtual void SAL_CALL modified(
- const css::lang::EventObject& aEvent ) override;
-
- // ____ XEventListener (base of XModifyListener) ____
- virtual void SAL_CALL disposing(
- const css::lang::EventObject& Source ) override;
-
- void fireModifyEvent();
-
- // ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
- virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
-
- virtual void firePropertyChangeEvent() override;
- using OPropertySet::disposing;
-
- // ____ XPropertySet ____
- virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
- getPropertySetInfo() override;
-
- /// merge XTypeProvider implementations
- DECLARE_XTYPEPROVIDER()
-
-protected:
- css::uno::Reference< css::util::XModifyListener >
- const m_xModifyEventForwarder;
-
-private:
- void impl_addDataSeriesWithoutNotification(
- const css::uno::Reference< css::chart2::XDataSeries >& aDataSeries );
-
-private:
- typedef
- std::vector< css::uno::Reference< css::chart2::XDataSeries > > tDataSeriesContainerType;
-
- // --- mutable members: the following members need mutex guard ---
-
- tDataSeriesContainerType m_aDataSeries;
-
- bool m_bNotifyChanges;
-};
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ChartTypeManager.cxx b/chart2/source/model/template/ChartTypeManager.cxx
index c0bcc0a03d33..2e6753444d99 100644
--- a/chart2/source/model/template/ChartTypeManager.cxx
+++ b/chart2/source/model/template/ChartTypeManager.cxx
@@ -33,13 +33,13 @@
#include <com/sun/star/container/XContentEnumerationAccess.hpp>
#include <com/sun/star/lang/XServiceName.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <tools/diagnose_ex.h>
#include <sal/log.hxx>
#include <algorithm>
#include <iterator>
#include <o3tl/functional.hxx>
#include <map>
+#include <utility>
using namespace ::com::sun::star;
@@ -89,6 +89,8 @@ enum TemplateId
TEMPLATE_PIEALLEXPLODED,
TEMPLATE_DONUT,
TEMPLATE_DONUTALLEXPLODED,
+ TEMPLATE_BAROFPIE,
+ TEMPLATE_PIEOFPIE,
TEMPLATE_THREEDPIE,
TEMPLATE_THREEDPIEALLEXPLODED,
TEMPLATE_THREEDDONUT,
@@ -163,6 +165,9 @@ const tTemplateMapType & lcl_DefaultChartTypeMap()
{"com.sun.star.chart2.template.PieAllExploded", TEMPLATE_PIEALLEXPLODED},
{"com.sun.star.chart2.template.Donut", TEMPLATE_DONUT},
{"com.sun.star.chart2.template.DonutAllExploded", TEMPLATE_DONUTALLEXPLODED},
+ {"com.sun.star.chart2.template.BarOfPie", TEMPLATE_BAROFPIE},
+ {"com.sun.star.chart2.template.PieOfPie", TEMPLATE_PIEOFPIE},
+ {"com.sun.star.chart2.template.DonutAllExploded", TEMPLATE_DONUTALLEXPLODED},
{"com.sun.star.chart2.template.ThreeDPie", TEMPLATE_THREEDPIE},
{"com.sun.star.chart2.template.ThreeDPieAllExploded", TEMPLATE_THREEDPIEALLEXPLODED},
{"com.sun.star.chart2.template.ThreeDDonut", TEMPLATE_THREEDDONUT},
@@ -213,8 +218,8 @@ namespace chart
ChartTypeManager::ChartTypeManager(
uno::Reference<
- uno::XComponentContext > const & xContext ) :
- m_xContext( xContext )
+ uno::XComponentContext > xContext ) :
+ m_xContext(std::move( xContext ))
{}
ChartTypeManager::~ChartTypeManager()
@@ -224,312 +229,307 @@ ChartTypeManager::~ChartTypeManager()
uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance(
const OUString& aServiceSpecifier )
{
- uno::Reference< uno::XInterface > xResult;
+ return static_cast<cppu::OWeakObject*>(createTemplate(aServiceSpecifier).get());
+}
+
+rtl::Reference< ::chart::ChartTypeTemplate > ChartTypeManager::createTemplate(
+ const OUString& aServiceSpecifier )
+{
TemplateId nId = lcl_GetTemplateIdForService( aServiceSpecifier );
- if( nId == TEMPLATE_NOT_FOUND )
+ rtl::Reference< ::chart::ChartTypeTemplate > xTemplate;
+ switch( nId )
{
- try
- {
- xResult = m_xContext->getServiceManager()->createInstanceWithContext(
- aServiceSpecifier, m_xContext );
- }
-// catch( registry::InvalidValueException & ex )
- catch( const uno::Exception & )
+ // Point (category x axis)
+ case TEMPLATE_SYMBOL:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, true, false ));
+ break;
+ case TEMPLATE_STACKEDSYMBOL:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, true, false ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDSYMBOL:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, true, false ));
+ break;
+ // Line (category x axis)
+ case TEMPLATE_LINE:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, false ));
+ break;
+ case TEMPLATE_STACKEDLINE:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, false ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDLINE:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, false ));
+ break;
+ case TEMPLATE_LINESYMBOL:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, true ));
+ break;
+ case TEMPLATE_STACKEDLINESYMBOL:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, true ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDLINESYMBOL:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, true ));
+ break;
+ case TEMPLATE_THREEDLINE:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, false, true, 3 ));
+ break;
+ case TEMPLATE_STACKEDTHREEDLINE:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, false, true, 3 ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDTHREEDLINE:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, false, true, 3 ));
+ break;
+ case TEMPLATE_THREEDLINEDEEP:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::ZStacked, false, true, 3 ));
+ break;
+
+ // Bar/Column
+ case TEMPLATE_COLUMN:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, BarChartTypeTemplate::VERTICAL ));
+ break;
+ case TEMPLATE_STACKEDCOLUMN:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, BarChartTypeTemplate::VERTICAL ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDCOLUMN:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, BarChartTypeTemplate::VERTICAL ));
+ break;
+ case TEMPLATE_BAR:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, BarChartTypeTemplate::HORIZONTAL ));
+ break;
+ case TEMPLATE_STACKEDBAR:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, BarChartTypeTemplate::HORIZONTAL ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDBAR:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, BarChartTypeTemplate::HORIZONTAL ));
+ break;
+ case TEMPLATE_THREEDCOLUMNDEEP:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::ZStacked, BarChartTypeTemplate::VERTICAL, 3 ));
+ break;
+ case TEMPLATE_THREEDCOLUMNFLAT:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, BarChartTypeTemplate::VERTICAL, 3 ));
+ break;
+ case TEMPLATE_STACKEDTHREEDCOLUMNFLAT:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, BarChartTypeTemplate::VERTICAL, 3 ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, BarChartTypeTemplate::VERTICAL, 3 ));
+ break;
+ case TEMPLATE_THREEDBARDEEP:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::ZStacked, BarChartTypeTemplate::HORIZONTAL, 3 ));
+ break;
+ case TEMPLATE_THREEDBARFLAT:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, BarChartTypeTemplate::HORIZONTAL, 3 ));
+ break;
+ case TEMPLATE_STACKEDTHREEDBARFLAT:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, BarChartTypeTemplate::HORIZONTAL, 3 ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, BarChartTypeTemplate::HORIZONTAL, 3 ));
+ break;
+
+ // Combi-Chart Line/Column
+ case TEMPLATE_COLUMNWITHLINE:
+ case TEMPLATE_STACKEDCOLUMNWITHLINE:
{
- // couldn't create service via factory
+ StackMode eMode = ( nId == TEMPLATE_COLUMNWITHLINE )
+ ? StackMode::NONE
+ : StackMode::YStacked;
- // As XMultiServiceFactory does not specify, what to do in case
- // createInstance is called with an unknown service-name, this
- // function will just return an empty XInterface.
- DBG_UNHANDLED_EXCEPTION("chart2");
- SAL_WARN("chart2", "Couldn't instantiate service: "<< aServiceSpecifier );
- xResult.set( nullptr );
+ xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, aServiceSpecifier, eMode, 1 ));
}
- }
- else
- {
- uno::Reference< chart2::XChartTypeTemplate > xTemplate;
- switch( nId )
- {
- // Point (category x axis)
- case TEMPLATE_SYMBOL:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, true, false ));
- break;
- case TEMPLATE_STACKEDSYMBOL:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, true, false ));
- break;
- case TEMPLATE_PERCENTSTACKEDSYMBOL:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, true, false ));
- break;
- // Line (category x axis)
- case TEMPLATE_LINE:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, false ));
- break;
- case TEMPLATE_STACKEDLINE:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, false ));
- break;
- case TEMPLATE_PERCENTSTACKEDLINE:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, false ));
- break;
- case TEMPLATE_LINESYMBOL:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, true ));
- break;
- case TEMPLATE_STACKEDLINESYMBOL:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, true ));
- break;
- case TEMPLATE_PERCENTSTACKEDLINESYMBOL:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, true ));
- break;
- case TEMPLATE_THREEDLINE:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, false, true, 3 ));
- break;
- case TEMPLATE_STACKEDTHREEDLINE:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, false, true, 3 ));
- break;
- case TEMPLATE_PERCENTSTACKEDTHREEDLINE:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, false, true, 3 ));
- break;
- case TEMPLATE_THREEDLINEDEEP:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::ZStacked, false, true, 3 ));
- break;
-
- // Bar/Column
- case TEMPLATE_COLUMN:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, BarChartTypeTemplate::VERTICAL ));
- break;
- case TEMPLATE_STACKEDCOLUMN:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, BarChartTypeTemplate::VERTICAL ));
- break;
- case TEMPLATE_PERCENTSTACKEDCOLUMN:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, BarChartTypeTemplate::VERTICAL ));
- break;
- case TEMPLATE_BAR:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, BarChartTypeTemplate::HORIZONTAL ));
- break;
- case TEMPLATE_STACKEDBAR:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, BarChartTypeTemplate::HORIZONTAL ));
- break;
- case TEMPLATE_PERCENTSTACKEDBAR:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, BarChartTypeTemplate::HORIZONTAL ));
- break;
- case TEMPLATE_THREEDCOLUMNDEEP:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::ZStacked, BarChartTypeTemplate::VERTICAL, 3 ));
- break;
- case TEMPLATE_THREEDCOLUMNFLAT:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, BarChartTypeTemplate::VERTICAL, 3 ));
- break;
- case TEMPLATE_STACKEDTHREEDCOLUMNFLAT:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, BarChartTypeTemplate::VERTICAL, 3 ));
- break;
- case TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, BarChartTypeTemplate::VERTICAL, 3 ));
- break;
- case TEMPLATE_THREEDBARDEEP:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::ZStacked, BarChartTypeTemplate::HORIZONTAL, 3 ));
- break;
- case TEMPLATE_THREEDBARFLAT:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, BarChartTypeTemplate::HORIZONTAL, 3 ));
- break;
- case TEMPLATE_STACKEDTHREEDBARFLAT:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, BarChartTypeTemplate::HORIZONTAL, 3 ));
- break;
- case TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, BarChartTypeTemplate::HORIZONTAL, 3 ));
- break;
-
- // Combi-Chart Line/Column
- case TEMPLATE_COLUMNWITHLINE:
- case TEMPLATE_STACKEDCOLUMNWITHLINE:
- {
- StackMode eMode = ( nId == TEMPLATE_COLUMNWITHLINE )
- ? StackMode::NONE
- : StackMode::YStacked;
+ break;
- xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, aServiceSpecifier, eMode, 1 ));
- }
+ // Area
+ case TEMPLATE_AREA:
+ xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::NONE ));
+ break;
+ case TEMPLATE_STACKEDAREA:
+ xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::YStacked ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDAREA:
+ xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::YStackedPercent ));
+ break;
+ case TEMPLATE_THREEDAREA:
+ xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::ZStacked, 3 ));
+ break;
+ case TEMPLATE_STACKEDTHREEDAREA:
+ xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::YStacked, 3 ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDTHREEDAREA:
+ xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::YStackedPercent, 3 ));
+ break;
+
+ case TEMPLATE_PIE:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_NONE, false, chart2::PieChartSubType_NONE ));
+ break;
+ case TEMPLATE_PIEALLEXPLODED:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_ALL_EXPLODED, false,
+ chart2::PieChartSubType_NONE ));
+ break;
+ case TEMPLATE_DONUT:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_NONE, true, chart2::PieChartSubType_NONE ));
+ break;
+ case TEMPLATE_DONUTALLEXPLODED:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_ALL_EXPLODED, true,
+ chart2::PieChartSubType_NONE ));
+ break;
+ case TEMPLATE_BAROFPIE:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_NONE, false, chart2::PieChartSubType_BAR ));
+ break;
+ case TEMPLATE_PIEOFPIE:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_NONE, false, chart2::PieChartSubType_PIE ));
+ break;
+ case TEMPLATE_THREEDPIE:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_NONE, false, chart2::PieChartSubType_NONE, 3 ));
+ break;
+ case TEMPLATE_THREEDPIEALLEXPLODED:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_ALL_EXPLODED, false,
+ chart2::PieChartSubType_NONE, 3 ));
+ break;
+ case TEMPLATE_THREEDDONUT:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_NONE, true, chart2::PieChartSubType_NONE, 3 ));
+ break;
+ case TEMPLATE_THREEDDONUTALLEXPLODED:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_ALL_EXPLODED, true,
+ chart2::PieChartSubType_NONE, 3 ));
break;
- // Area
- case TEMPLATE_AREA:
- xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::NONE ));
- break;
- case TEMPLATE_STACKEDAREA:
- xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::YStacked ));
- break;
- case TEMPLATE_PERCENTSTACKEDAREA:
- xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::YStackedPercent ));
- break;
- case TEMPLATE_THREEDAREA:
- xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::ZStacked, 3 ));
- break;
- case TEMPLATE_STACKEDTHREEDAREA:
- xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::YStacked, 3 ));
- break;
- case TEMPLATE_PERCENTSTACKEDTHREEDAREA:
- xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::YStackedPercent, 3 ));
- break;
-
- case TEMPLATE_PIE:
- xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
- chart2::PieChartOffsetMode_NONE, false ));
- break;
- case TEMPLATE_PIEALLEXPLODED:
- xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
- chart2::PieChartOffsetMode_ALL_EXPLODED, false ));
- break;
- case TEMPLATE_DONUT:
- xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
- chart2::PieChartOffsetMode_NONE, true ));
- break;
- case TEMPLATE_DONUTALLEXPLODED:
- xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
- chart2::PieChartOffsetMode_ALL_EXPLODED, true ));
- break;
- case TEMPLATE_THREEDPIE:
- xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
- chart2::PieChartOffsetMode_NONE, false, 3 ));
- break;
- case TEMPLATE_THREEDPIEALLEXPLODED:
- xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
- chart2::PieChartOffsetMode_ALL_EXPLODED, false, 3 ));
- break;
- case TEMPLATE_THREEDDONUT:
- xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
- chart2::PieChartOffsetMode_NONE, true, 3 ));
- break;
- case TEMPLATE_THREEDDONUTALLEXPLODED:
- xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
- chart2::PieChartOffsetMode_ALL_EXPLODED, true, 3 ));
- break;
-
- case TEMPLATE_SCATTERLINESYMBOL:
- xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true ));
- break;
- case TEMPLATE_SCATTERLINE:
- xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ false ));
- break;
- case TEMPLATE_SCATTERSYMBOL:
- xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true, /* bHasLines */ false ));
- break;
- case TEMPLATE_THREEDSCATTER:
- xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ false, /* bHasLines */ true, 3 ));
- break;
-
- // NetChart
- case TEMPLATE_NET:
- xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, true ));
- break;
- case TEMPLATE_NETSYMBOL:
- xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, true, false ));
- break;
- case TEMPLATE_NETLINE:
- xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, false ));
- break;
-
- case TEMPLATE_STACKEDNET:
- xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, true ));
- break;
- case TEMPLATE_STACKEDNETSYMBOL:
- xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, true, false ));
- break;
- case TEMPLATE_STACKEDNETLINE:
- xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, false, true ));
- break;
-
- case TEMPLATE_PERCENTSTACKEDNET:
- xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, true ));
- break;
- case TEMPLATE_PERCENTSTACKEDNETSYMBOL:
- xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, true, false ));
- break;
- case TEMPLATE_PERCENTSTACKEDNETLINE:
- xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, false, true ));
- break;
-
- case TEMPLATE_FILLEDNET:
- xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, false, false, true ));
- break;
- case TEMPLATE_STACKEDFILLEDNET:
- xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, false, false, true ));
- break;
- case TEMPLATE_PERCENTSTACKEDFILLEDNET:
- xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, false, false, true ));
- break;
-
- case TEMPLATE_STOCKLOWHIGHCLOSE:
- xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
- StockChartTypeTemplate::StockVariant::NONE, false ));
- break;
- case TEMPLATE_STOCKOPENLOWHIGHCLOSE:
- xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
- StockChartTypeTemplate::StockVariant::Open, true ));
- break;
- case TEMPLATE_STOCKVOLUMELOWHIGHCLOSE:
- xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
- StockChartTypeTemplate::StockVariant::Volume, false ));
- break;
- case TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE:
- xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
- StockChartTypeTemplate::StockVariant::VolumeOpen, true ));
- break;
-
- //BubbleChart
- case TEMPLATE_BUBBLE:
- xTemplate.set( new BubbleChartTypeTemplate( m_xContext, aServiceSpecifier ));
- break;
- default: break;
+ case TEMPLATE_SCATTERLINESYMBOL:
+ xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true ));
+ break;
+ case TEMPLATE_SCATTERLINE:
+ xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ false ));
+ break;
+ case TEMPLATE_SCATTERSYMBOL:
+ xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ true, /* bHasLines */ false ));
+ break;
+ case TEMPLATE_THREEDSCATTER:
+ xTemplate.set( new ScatterChartTypeTemplate( m_xContext, aServiceSpecifier, /* bSymbols */ false, /* bHasLines */ true, 3 ));
+ break;
+
+ // NetChart
+ case TEMPLATE_NET:
+ xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, true ));
+ break;
+ case TEMPLATE_NETSYMBOL:
+ xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, true, false ));
+ break;
+ case TEMPLATE_NETLINE:
+ xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, false ));
+ break;
+
+ case TEMPLATE_STACKEDNET:
+ xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, true ));
+ break;
+ case TEMPLATE_STACKEDNETSYMBOL:
+ xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, true, false ));
+ break;
+ case TEMPLATE_STACKEDNETLINE:
+ xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, false, true ));
+ break;
+
+ case TEMPLATE_PERCENTSTACKEDNET:
+ xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, true ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDNETSYMBOL:
+ xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, true, false ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDNETLINE:
+ xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, false, true ));
+ break;
+
+ case TEMPLATE_FILLEDNET:
+ xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, false, false, true ));
+ break;
+ case TEMPLATE_STACKEDFILLEDNET:
+ xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, false, false, true ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDFILLEDNET:
+ xTemplate.set( new NetChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, false, false, true ));
+ break;
+
+ case TEMPLATE_STOCKLOWHIGHCLOSE:
+ xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StockChartTypeTemplate::StockVariant::NONE, false ));
+ break;
+ case TEMPLATE_STOCKOPENLOWHIGHCLOSE:
+ xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StockChartTypeTemplate::StockVariant::Open, true ));
+ break;
+ case TEMPLATE_STOCKVOLUMELOWHIGHCLOSE:
+ xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StockChartTypeTemplate::StockVariant::Volume, false ));
+ break;
+ case TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE:
+ xTemplate.set( new StockChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StockChartTypeTemplate::StockVariant::VolumeOpen, true ));
+ break;
+
+ //BubbleChart
+ case TEMPLATE_BUBBLE:
+ xTemplate.set( new BubbleChartTypeTemplate( m_xContext, aServiceSpecifier ));
+ break;
+
+ case TEMPLATE_NOT_FOUND:
+ SAL_WARN("chart2", "Couldn't instantiate service: "<< aServiceSpecifier );
+ assert(false);
+ break;
+
+ default: break;
// case TEMPLATE_SURFACE:
// case TEMPLATE_ADDIN:
// break;
-
- case TEMPLATE_NOT_FOUND:
- OSL_ASSERT( false );
- break;
- }
- xResult.set( xTemplate, uno::UNO_QUERY );
}
- return xResult;
+ return xTemplate;
}
uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstanceWithArguments(
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx
index 1f1b09cff89f..79ed5c7f4c90 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -17,30 +17,36 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "ChartTypeTemplate.hxx"
-#include "DataInterpreter.hxx"
+#include <ChartTypeTemplate.hxx>
+#include <DataInterpreter.hxx>
#include <CommonConverters.hxx>
#include <ChartTypeHelper.hxx>
+#include <ChartType.hxx>
+#include <DataSeriesProperties.hxx>
+#include <DataSource.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
+#include <Diagram.hxx>
#include <DiagramHelper.hxx>
#include <AxisIndexDefines.hxx>
+#include <BaseCoordinateSystem.hxx>
#include <unonames.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/chart2/StackingDirection.hpp>
-#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
-#include <tools/diagnose_ex.h>
+#include <com/sun/star/chart2/XColorScheme.hpp>
+#include <comphelper/diagnose_ex.hxx>
#include <comphelper/property.hxx>
-#include <comphelper/sequence.hxx>
#include <algorithm>
+#include <cstddef>
+#include <utility>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
+using namespace ::chart::DataSeriesProperties;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Reference;
@@ -49,18 +55,17 @@ namespace
{
void lcl_applyDefaultStyle(
- const Reference< XDataSeries > & xSeries,
+ const rtl::Reference< ::chart::DataSeries > & xSeries,
sal_Int32 nIndex,
- const Reference< XDiagram > & xDiagram )
+ const rtl::Reference< ::chart::Diagram > & xDiagram )
{
// @deprecated: correct default color should be found by view without
// setting color as hard attribute
if( xSeries.is() && xDiagram.is())
{
- Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
Reference< chart2::XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme());
- if( xSeriesProp.is() && xColorScheme.is() )
- xSeriesProp->setPropertyValue(
+ if( xColorScheme.is() )
+ xSeries->setPropertyValue(
"Color",
uno::Any( xColorScheme->getColorByIndex( nIndex )));
}
@@ -102,18 +107,17 @@ void lcl_resetLabelPlacementIfDefault( const Reference< beans::XPropertySet >& x
}
}
-void lcl_ensureCorrectMissingValueTreatment( const Reference< chart2::XDiagram >& xDiagram, const Reference< XChartType >& xChartType )
+void lcl_ensureCorrectMissingValueTreatment( const rtl::Reference< ::chart::Diagram >& xDiagram, const rtl::Reference< ::chart::ChartType >& xChartType )
{
- Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY );
- if( xDiaProp.is() )
+ if( xDiagram.is() )
{
uno::Sequence < sal_Int32 > aAvailableMissingValueTreatment(
::chart::ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ) );
if( aAvailableMissingValueTreatment.hasElements() )
- xDiaProp->setPropertyValue( "MissingValueTreatment", uno::Any( aAvailableMissingValueTreatment[0] ) );
+ xDiagram->setPropertyValue( "MissingValueTreatment", uno::Any( aAvailableMissingValueTreatment[0] ) );
else
- xDiaProp->setPropertyValue( "MissingValueTreatment", uno::Any() );
+ xDiagram->setPropertyValue( "MissingValueTreatment", uno::Any() );
}
}
@@ -124,44 +128,39 @@ namespace chart
ChartTypeTemplate::ChartTypeTemplate(
Reference< uno::XComponentContext > const & xContext,
- const OUString & rServiceName ) :
+ OUString aServiceName ) :
m_xContext( xContext ),
- m_aServiceName( rServiceName )
+ m_aServiceName(std::move( aServiceName ))
{
}
ChartTypeTemplate::~ChartTypeTemplate()
{}
-// ____ XChartTypeTemplate ____
-uno::Reference< XDiagram > SAL_CALL ChartTypeTemplate::createDiagramByDataSource(
+// ____ ChartTypeTemplate ____
+rtl::Reference< Diagram > ChartTypeTemplate::createDiagramByDataSource2(
const uno::Reference< data::XDataSource >& xDataSource,
const uno::Sequence< beans::PropertyValue >& aArguments )
{
- Reference< XDiagram > xDia;
+ rtl::Reference< Diagram > xDia;
try
{
// create diagram
- xDia.set(
- GetComponentContext()->getServiceManager()->createInstanceWithContext(
- "com.sun.star.chart2.Diagram",
- GetComponentContext() ),
- uno::UNO_QUERY_THROW );
+ xDia = new Diagram(GetComponentContext());
// modify diagram
- Reference< chart2::XDataInterpreter > xInterpreter( getDataInterpreter());
- chart2::InterpretedData aData(
+ rtl::Reference< DataInterpreter > xInterpreter( getDataInterpreter2());
+ InterpretedData aData(
xInterpreter->interpretDataSource(
- xDataSource, aArguments, Sequence< Reference< XDataSeries > >() ));
+ xDataSource, aArguments, {} ));
- const Sequence< Sequence< Reference< XDataSeries > > > aSeries( aData.Series );
sal_Int32 nCount = 0;
- for( auto const & i : aSeries )
+ for( auto const & i : aData.Series )
for( auto const & j : i )
lcl_applyDefaultStyle( j, nCount++, xDia );
- Sequence< Reference< XChartType > > aOldChartTypesSeq;
+ std::vector< rtl::Reference< ChartType > > aOldChartTypesSeq;
FillDiagram( xDia, aData.Series, aData.Categories, aOldChartTypesSeq );
}
catch( const uno::Exception & )
@@ -177,23 +176,23 @@ sal_Bool SAL_CALL ChartTypeTemplate::supportsCategories()
return true;
}
-void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >& xDiagram )
+void ChartTypeTemplate::changeDiagram( const rtl::Reference< Diagram >& xDiagram )
{
if( ! xDiagram.is())
return;
try
{
- Sequence< Sequence< Reference< XDataSeries > > > aSeriesSeq(
- DiagramHelper::getDataSeriesGroups( xDiagram ));
- Sequence< Reference< XDataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq ));
- const sal_Int32 nFormerSeriesCount = aFlatSeriesSeq.getLength();
+ std::vector< std::vector< rtl::Reference< DataSeries > > > aSeriesSeq =
+ xDiagram->getDataSeriesGroups();
+ std::vector< rtl::Reference< DataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq ));
+ const sal_Int32 nFormerSeriesCount = aFlatSeriesSeq.size();
// chart-type specific interpretation of existing data series
- Reference< chart2::XDataInterpreter > xInterpreter( getDataInterpreter());
- chart2::InterpretedData aData;
+ rtl::Reference< DataInterpreter > xInterpreter( getDataInterpreter2());
+ InterpretedData aData;
aData.Series = aSeriesSeq;
- aData.Categories = DiagramHelper::getCategoriesFromDiagram( xDiagram );
+ aData.Categories = xDiagram->getCategories();
if( xInterpreter->isDataCompatible( aData ) )
{
@@ -201,7 +200,7 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >
}
else
{
- Reference< data::XDataSource > xSource( xInterpreter->mergeInterpretedData( aData ));
+ rtl::Reference< DataSource > xSource = DataInterpreter::mergeInterpretedData( aData );
// todo: get a "range-union" from the data provider by calling
// OUString aRange = getRangeRepresentationByData( xSource );
// xSource.set( getDataByRangeRepresentation( aRange, aParam ));
@@ -217,7 +216,7 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >
aSeriesSeq = aData.Series;
sal_Int32 nIndex = 0;
- for( auto const & i : std::as_const(aSeriesSeq) )
+ for (auto const& i : aSeriesSeq)
for( auto const & j : i )
{
if( nIndex >= nFormerSeriesCount )
@@ -225,21 +224,12 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >
}
// remove charttype groups from all coordinate systems
- Sequence< Reference< XChartType > > aOldChartTypesSeq(
- DiagramHelper::getChartTypesFromDiagram(xDiagram) );
+ std::vector< rtl::Reference< ChartType > > aOldChartTypesSeq =
+ xDiagram->getChartTypes();
- Reference< XCoordinateSystemContainer > xCoordSysCnt( xDiagram, uno::UNO_QUERY );
- OSL_ASSERT( xCoordSysCnt.is());
- if( xCoordSysCnt.is())
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : xDiagram->getBaseCoordinateSystems() )
{
- const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
- xCoordSysCnt->getCoordinateSystems());
- for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
- {
- Reference< XChartTypeContainer > xContainer( coords, uno::UNO_QUERY );
- if( xContainer.is() )
- xContainer->setChartTypes( Sequence< Reference< XChartType > >() );
- }
+ coords->setChartTypes( Sequence< Reference< XChartType > >() );
}
FillDiagram( xDiagram, aSeriesSeq, aData.Categories, aOldChartTypesSeq );
@@ -250,8 +240,8 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >
}
}
-void SAL_CALL ChartTypeTemplate::changeDiagramData(
- const Reference< chart2::XDiagram >& xDiagram,
+void ChartTypeTemplate::changeDiagramData(
+ const rtl::Reference< Diagram >& xDiagram,
const Reference< chart2::data::XDataSource >& xDataSource,
const Sequence< beans::PropertyValue >& aArguments )
{
@@ -262,37 +252,34 @@ void SAL_CALL ChartTypeTemplate::changeDiagramData(
try
{
// interpret new data and re-use existing series
- Sequence< Reference< XDataSeries > > aFlatSeriesSeq(
- comphelper::containerToSequence( DiagramHelper::getDataSeriesFromDiagram( xDiagram )));
- const sal_Int32 nFormerSeriesCount = aFlatSeriesSeq.getLength();
- Reference< chart2::XDataInterpreter > xInterpreter( getDataInterpreter());
- chart2::InterpretedData aData =
+ std::vector< rtl::Reference< DataSeries > > aFlatSeriesSeq =
+ xDiagram->getDataSeries();
+ const sal_Int32 nFormerSeriesCount = aFlatSeriesSeq.size();
+ rtl::Reference< DataInterpreter > xInterpreter( getDataInterpreter2());
+ InterpretedData aData =
xInterpreter->interpretDataSource( xDataSource, aArguments, aFlatSeriesSeq );
// data series
- Sequence< Sequence< Reference< XDataSeries > > > aSeriesSeq( aData.Series );
-
- sal_Int32 i, j, nIndex = 0;
- for( i=0; i<aSeriesSeq.getLength(); ++i )
- for( j=0; j<aSeriesSeq[i].getLength(); ++j, ++nIndex )
+ sal_Int32 nIndex = 0;
+ for( std::size_t i=0; i<aData.Series.size(); ++i )
+ for( std::size_t j=0; j<aData.Series[i].size(); ++j, ++nIndex )
{
if( nIndex >= nFormerSeriesCount )
{
- lcl_applyDefaultStyle( aSeriesSeq[i][j], nIndex, xDiagram );
- applyStyle( aSeriesSeq[i][j], i, j, aSeriesSeq[i].getLength() );
+ lcl_applyDefaultStyle( aData.Series[i][j], nIndex, xDiagram );
+ applyStyle2( aData.Series[i][j], i, j, aData.Series[i].size() );
}
}
// categories
- DiagramHelper::setCategoriesToDiagram( aData.Categories, xDiagram, true, supportsCategories() );
+ xDiagram->setCategories( aData.Categories, true, supportsCategories() );
- Sequence< Reference< XChartType > > aChartTypes(
- DiagramHelper::getChartTypesFromDiagram( xDiagram ));
- sal_Int32 nMax = std::min( aChartTypes.getLength(), aSeriesSeq.getLength());
- for( i=0; i<nMax; ++i )
+ std::vector< rtl::Reference< ChartType > > aChartTypes =
+ xDiagram->getChartTypes();
+ sal_Int32 nMax = std::min( aChartTypes.size(), aData.Series.size());
+ for( sal_Int32 i=0; i<nMax; ++i )
{
- Reference< XDataSeriesContainer > xDSCnt( aChartTypes[i], uno::UNO_QUERY_THROW );
- xDSCnt->setDataSeries( aSeriesSeq[i] );
+ aChartTypes[i]->setDataSeries( aData.Series[i] );
}
}
catch( const uno::Exception & )
@@ -301,9 +288,9 @@ void SAL_CALL ChartTypeTemplate::changeDiagramData(
}
}
-sal_Bool SAL_CALL ChartTypeTemplate::matchesTemplate(
- const Reference< chart2::XDiagram >& xDiagram,
- sal_Bool /* bAdaptProperties */ )
+bool ChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool /* bAdaptProperties */ )
{
bool bResult = false;
@@ -312,34 +299,28 @@ sal_Bool SAL_CALL ChartTypeTemplate::matchesTemplate(
try
{
- Reference< XCoordinateSystemContainer > xCooSysCnt(
- xDiagram, uno::UNO_QUERY_THROW );
- Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
- xCooSysCnt->getCoordinateSystems());
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & aCooSysSeq(
+ xDiagram->getBaseCoordinateSystems());
// need to have at least one coordinate system
- bResult = aCooSysSeq.hasElements();
+ bResult = !aCooSysSeq.empty();
if( bResult )
{
- Sequence< Reference< XChartType > > aFormerlyUsedChartTypes;
- Reference<XChartType> xOldCT = getChartTypeForNewSeries(aFormerlyUsedChartTypes);
+ std::vector< rtl::Reference< ChartType > > aFormerlyUsedChartTypes;
+ rtl::Reference<ChartType> xOldCT = getChartTypeForNewSeries2(aFormerlyUsedChartTypes);
if (!xOldCT.is())
return false;
const OUString aChartTypeToMatch = xOldCT->getChartType();
const sal_Int32 nDimensionToMatch = getDimension();
- for( sal_Int32 nCooSysIdx=0; bResult && (nCooSysIdx < aCooSysSeq.getLength()); ++nCooSysIdx )
+ for( std::size_t nCooSysIdx=0; bResult && (nCooSysIdx < aCooSysSeq.size()); ++nCooSysIdx )
{
// match dimension
bResult = bResult && (aCooSysSeq[nCooSysIdx]->getDimension() == nDimensionToMatch);
- Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW );
- Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
- for( sal_Int32 nCTIdx=0; bResult && (nCTIdx < aChartTypeSeq.getLength()); ++nCTIdx )
+ const std::vector< rtl::Reference< ChartType > > & aChartTypeSeq( aCooSysSeq[nCooSysIdx]->getChartTypes2());
+ for( std::size_t nCTIdx=0; bResult && (nCTIdx < aChartTypeSeq.size()); ++nCTIdx )
{
- if (!aChartTypeSeq[nCTIdx].is())
- return false;
-
// match chart type
bResult = bResult && aChartTypeSeq[nCTIdx]->getChartType() == aChartTypeToMatch;
bool bFound=false;
@@ -362,7 +343,7 @@ sal_Bool SAL_CALL ChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< chart2::XDataInterpreter > SAL_CALL ChartTypeTemplate::getDataInterpreter()
+rtl::Reference< DataInterpreter > ChartTypeTemplate::getDataInterpreter2()
{
if( ! m_xDataInterpreter.is())
m_xDataInterpreter.set( new DataInterpreter );
@@ -370,15 +351,14 @@ Reference< chart2::XDataInterpreter > SAL_CALL ChartTypeTemplate::getDataInterpr
return m_xDataInterpreter;
}
-void SAL_CALL ChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void ChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 /* nSeriesIndex */,
::sal_Int32 /* nSeriesCount */ )
{
// sset stacking mode
- Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
- if( !xSeriesProp.is())
+ if( !xSeries.is())
return;
try
@@ -391,16 +371,17 @@ void SAL_CALL ChartTypeTemplate::applyStyle(
: (eStackMode == StackMode::ZStacked )
? chart2::StackingDirection_Z_STACKING
: chart2::StackingDirection_NO_STACKING );
- xSeriesProp->setPropertyValue( "StackingDirection", aPropValue );
+ xSeries->setPropertyValue( "StackingDirection", aPropValue );
//ensure valid label placement
{
uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements(
getChartTypeForIndex( nChartTypeIndex ), isSwapXAndY(), xSeries ) );
- lcl_ensureCorrectLabelPlacement( xSeriesProp, aAvailablePlacements );
+ lcl_ensureCorrectLabelPlacement( xSeries, aAvailablePlacements );
uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- if( xSeriesProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
+ // "AttributedDataPoints"
+ if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList )
for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
lcl_ensureCorrectLabelPlacement( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]), aAvailablePlacements );
}
@@ -411,88 +392,63 @@ void SAL_CALL ChartTypeTemplate::applyStyle(
}
}
-void ChartTypeTemplate::applyStyles( const Reference< chart2::XDiagram >& xDiagram )
+void ChartTypeTemplate::applyStyles( const rtl::Reference< ::chart::Diagram >& xDiagram )
{
// apply chart-type specific styles, like "symbols on" for example
- Sequence< Sequence< Reference< XDataSeries > > > aNewSeriesSeq(
- DiagramHelper::getDataSeriesGroups( xDiagram ));
- for( sal_Int32 i=0; i<aNewSeriesSeq.getLength(); ++i )
+ std::vector< std::vector< rtl::Reference< DataSeries > > > aNewSeriesSeq(
+ xDiagram->getDataSeriesGroups());
+ for( std::size_t i=0; i<aNewSeriesSeq.size(); ++i )
{
- const sal_Int32 nNumSeries = aNewSeriesSeq[i].getLength();
+ const sal_Int32 nNumSeries = aNewSeriesSeq[i].size();
for( sal_Int32 j=0; j<nNumSeries; ++j )
- applyStyle( aNewSeriesSeq[i][j], i, j, nNumSeries );
+ applyStyle2( aNewSeriesSeq[i][j], i, j, nNumSeries );
}
//ensure valid empty cell handling (for first chart type...)
lcl_ensureCorrectMissingValueTreatment( xDiagram, getChartTypeForIndex( 0 ) );
}
-void SAL_CALL ChartTypeTemplate::resetStyles( const Reference< chart2::XDiagram >& xDiagram )
+void ChartTypeTemplate::resetStyles2( const rtl::Reference< ::chart::Diagram >& xDiagram )
{
// reset number format if we had percent stacking on
bool bPercent = (getStackMode(0) == StackMode::YStackedPercent);
if( bPercent )
{
- const Sequence< Reference< chart2::XAxis > > aAxisSeq( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
- for( Reference< chart2::XAxis > const & axis : aAxisSeq )
+ const std::vector< rtl::Reference< Axis > > aAxisSeq( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
+ for( rtl::Reference< Axis > const & axis : aAxisSeq )
{
if( AxisHelper::getDimensionIndexOfAxis( axis, xDiagram )== 1 )
{
- Reference< beans::XPropertySet > xAxisProp( axis, uno::UNO_QUERY );
- if( xAxisProp.is())
- {
- // set number format to source format
- xAxisProp->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(true));
- xAxisProp->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any());
- }
+ // set number format to source format
+ axis->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(true));
+ axis->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any());
}
}
}
//reset label placement if default
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : xDiagram->getBaseCoordinateSystems() )
{
- uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if( xCooSysContainer.is() )
+ //iterate through all chart types in the current coordinate system
+ for( rtl::Reference< ChartType > const & xChartType : xCooSys->getChartTypes2() )
{
- const uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- for( uno::Reference< XCoordinateSystem > const & xCooSys : aCooSysList )
+ //iterate through all series in this chart type
+ for( rtl::Reference< DataSeries > const & xSeries : xChartType->getDataSeries2() )
{
- //iterate through all chart types in the current coordinate system
- uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
- OSL_ASSERT( xChartTypeContainer.is());
- if( !xChartTypeContainer.is() )
+ uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements(
+ xChartType, isSwapXAndY(), xSeries ) );
+ if(!aAvailablePlacements.hasElements())
continue;
- const uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
- for( uno::Reference< XChartType > const & xChartType : aChartTypeList )
- {
- //iterate through all series in this chart type
- uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
- OSL_ASSERT( xDataSeriesContainer.is());
- if( !xDataSeriesContainer.is() )
- continue;
-
- const uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() );
- for( Reference< XDataSeries > const & xSeries : aSeriesList )
- {
- Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
- if(!xSeries.is() || !xSeriesProp.is() )
- continue;
- uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements(
- xChartType, isSwapXAndY(), xSeries ) );
- if(!aAvailablePlacements.hasElements())
- continue;
+ sal_Int32 nDefaultPlacement = aAvailablePlacements[0];
- sal_Int32 nDefaultPlacement = aAvailablePlacements[0];
+ lcl_resetLabelPlacementIfDefault( xSeries, nDefaultPlacement );
- lcl_resetLabelPlacementIfDefault( xSeriesProp, nDefaultPlacement );
-
- uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- if( xSeriesProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
- for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
- lcl_resetLabelPlacementIfDefault( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]), nDefaultPlacement );
- }
- }
+ uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
+ // "AttributedDataPoints"
+ if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList )
+ for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
+ lcl_resetLabelPlacementIfDefault( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]), nDefaultPlacement );
}
}
}
@@ -521,36 +477,36 @@ bool ChartTypeTemplate::isSwapXAndY() const
}
void ChartTypeTemplate::createCoordinateSystems(
- const Reference< chart2::XCoordinateSystemContainer > & xOutCooSysCnt )
+ const rtl::Reference< ::chart::Diagram > & xDiagram )
{
- if( ! xOutCooSysCnt.is())
+ if( ! xDiagram.is())
return;
- Sequence< Reference< XChartType > > aFormerlyUsedChartTypes;
- Reference< XChartType > xChartType( getChartTypeForNewSeries(aFormerlyUsedChartTypes));
+ std::vector< rtl::Reference< ChartType > > aFormerlyUsedChartTypes;
+ rtl::Reference< ChartType > xChartType( getChartTypeForNewSeries2(aFormerlyUsedChartTypes));
if( ! xChartType.is())
return;
- Reference< XCoordinateSystem > xCooSys( xChartType->createCoordinateSystem( getDimension()));
+ rtl::Reference< BaseCoordinateSystem > xCooSys = xChartType->createCoordinateSystem2( getDimension());
if( ! xCooSys.is())
{
// chart type wants no coordinate systems
- xOutCooSysCnt->setCoordinateSystems( Sequence< Reference< XCoordinateSystem > >());
+ xDiagram->setCoordinateSystems( Sequence< Reference< XCoordinateSystem > >());
return;
}
// #i69680# make grid of first y-axis visible (was in the CooSys CTOR before)
if( xCooSys->getDimension() >= 2 )
{
- Reference< chart2::XAxis > xAxis( xCooSys->getAxisByDimension( 1, 0 ));
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2( 1, 0 );
if( xAxis.is())
- AxisHelper::makeGridVisible( xAxis->getGridProperties() );
+ AxisHelper::makeGridVisible( xAxis->getGridProperties2() );
}
- Sequence< Reference< XCoordinateSystem > > aCoordinateSystems(
- xOutCooSysCnt->getCoordinateSystems());
+ std::vector< rtl::Reference< BaseCoordinateSystem > > aCoordinateSystems(
+ xDiagram->getBaseCoordinateSystems());
- if( aCoordinateSystems.hasElements())
+ if( !aCoordinateSystems.empty() )
{
bool bOk = true;
- for( sal_Int32 i=0; bOk && i<aCoordinateSystems.getLength(); ++i )
+ for( std::size_t i=0; bOk && i<aCoordinateSystems.size(); ++i )
bOk = bOk && ( xCooSys->getCoordinateSystemType() == aCoordinateSystems[i]->getCoordinateSystemType() &&
(xCooSys->getDimension() == aCoordinateSystems[i]->getDimension()) );
// coordinate systems are ok
@@ -560,9 +516,9 @@ void ChartTypeTemplate::createCoordinateSystems(
}
//copy as much info from former coordinate system as possible:
- if( aCoordinateSystems.hasElements() )
+ if( !aCoordinateSystems.empty() )
{
- Reference< XCoordinateSystem > xOldCooSys( aCoordinateSystems[0] );
+ rtl::Reference< BaseCoordinateSystem > xOldCooSys( aCoordinateSystems[0] );
sal_Int32 nMaxDimensionCount = std::min( xCooSys->getDimension(), xOldCooSys->getDimension() );
for(sal_Int32 nDimensionIndex=0; nDimensionIndex<nMaxDimensionCount; nDimensionIndex++)
@@ -570,7 +526,7 @@ void ChartTypeTemplate::createCoordinateSystems(
const sal_Int32 nMaximumAxisIndex = xOldCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
for(sal_Int32 nAxisIndex=0; nAxisIndex<=nMaximumAxisIndex; ++nAxisIndex)
{
- uno::Reference< XAxis > xAxis( xOldCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) );
+ rtl::Reference< Axis > xAxis = xOldCooSys->getAxisByDimension2( nDimensionIndex, nAxisIndex );
if( xAxis.is())
{
xCooSys->setAxisByDimension( nDimensionIndex, xAxis, nAxisIndex );
@@ -582,22 +538,19 @@ void ChartTypeTemplate::createCoordinateSystems(
// set new coordinate systems
aCoordinateSystems = { xCooSys };
- xOutCooSysCnt->setCoordinateSystems( aCoordinateSystems );
+ xDiagram->setCoordinateSystems( aCoordinateSystems );
}
void ChartTypeTemplate::adaptScales(
- const Sequence< Reference< chart2::XCoordinateSystem > > & aCooSysSeq,
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & aCooSysSeq,
const Reference< data::XLabeledDataSequence > & xCategories //@todo: in future there may be more than one sequence of categories (e.g. charttype with categories at x and y axis )
)
{
bool bSupportsCategories( supportsCategories() );
- for( Reference< XCoordinateSystem > const & xCooSys : aCooSysSeq )
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : aCooSysSeq )
{
try
{
- if( !xCooSys.is() )
- continue;
-
// attach categories to first axis
sal_Int32 nDim( xCooSys->getDimension());
if( nDim > 0 )
@@ -606,17 +559,23 @@ void ChartTypeTemplate::adaptScales(
const sal_Int32 nMaxIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionX);
for(sal_Int32 nI=0; nI<=nMaxIndex; ++nI)
{
- Reference< XAxis > xAxis( xCooSys->getAxisByDimension(nDimensionX,nI) );
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2(nDimensionX,nI);
if( xAxis.is())
{
ScaleData aData( xAxis->getScaleData() );
aData.Categories = xCategories;
if(bSupportsCategories)
{
- Reference< XChartType > xChartType(getChartTypeForNewSeries(Sequence< Reference< XChartType > >()));
+ rtl::Reference< ChartType > xChartType = getChartTypeForNewSeries2({});
if( aData.AxisType == AxisType::CATEGORY )
{
- aData.ShiftedCategoryPosition = m_aServiceName.indexOf("Column") != -1 || m_aServiceName.indexOf("Bar") != -1 || m_aServiceName.endsWith("Close");
+ // Shift for Column, Hi-Lo-Close, and regular
+ // Bar types, but not BarOfPie
+ aData.ShiftedCategoryPosition =
+ m_aServiceName.indexOf("Column") != -1 ||
+ (m_aServiceName.indexOf("Bar") != -1 &&
+ !m_aServiceName.indexOf("BarOfPie")) ||
+ m_aServiceName.endsWith("Close");
}
bool bSupportsDates = ::chart::ChartTypeHelper::isSupportingDateAxis( xChartType, nDimensionX );
if( aData.AxisType != AxisType::CATEGORY && ( aData.AxisType != AxisType::DATE || !bSupportsDates) )
@@ -639,7 +598,7 @@ void ChartTypeTemplate::adaptScales(
const sal_Int32 nMaxIndex = xCooSys->getMaximumAxisIndexByDimension(1);
for(sal_Int32 nI=0; nI<=nMaxIndex; ++nI)
{
- Reference< chart2::XAxis > xAxis( xCooSys->getAxisByDimension( 1,nI ));
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2( 1,nI );
if( xAxis.is())
{
bool bPercent = (getStackMode(0) == StackMode::YStackedPercent);
@@ -664,18 +623,18 @@ void ChartTypeTemplate::adaptScales(
}
}
-void ChartTypeTemplate::adaptDiagram( const Reference< XDiagram > & /* xDiagram */ )
+void ChartTypeTemplate::adaptDiagram( const rtl::Reference< ::chart::Diagram > & /* xDiagram */ )
{
- }
+}
void ChartTypeTemplate::createAxes(
- const Sequence< Reference< XCoordinateSystem > > & rCoordSys )
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys )
{
//create missing axes
- if( !rCoordSys.hasElements() )
+ if( rCoordSys.empty() )
return;
- Reference< XCoordinateSystem > xCooSys( rCoordSys[0] );
+ rtl::Reference< BaseCoordinateSystem > xCooSys( rCoordSys[0] );
if(!xCooSys.is())
return;
@@ -702,14 +661,14 @@ void ChartTypeTemplate::createAxes(
}
void ChartTypeTemplate::adaptAxes(
- const Sequence< Reference< XCoordinateSystem > > & rCoordSys )
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys )
{
//adapt properties of existing axes and remove superfluous axes
- if( !rCoordSys.hasElements() )
+ if( rCoordSys.empty() )
return;
- for( Reference< XCoordinateSystem > const & xCooSys : rCoordSys )
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : rCoordSys )
{
if( !xCooSys.is() )
continue;
@@ -719,7 +678,7 @@ void ChartTypeTemplate::adaptAxes(
sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension( nDim );
for( sal_Int32 nAxisIndex=0; nAxisIndex<=nMaxAxisIndex; nAxisIndex++ )
{
- Reference< XAxis > xAxis( AxisHelper::getAxis( nDim, nAxisIndex, xCooSys ) );
+ rtl::Reference< Axis > xAxis = AxisHelper::getAxis( nDim, nAxisIndex, xCooSys );
if( !xAxis.is() )
continue;
@@ -729,13 +688,9 @@ void ChartTypeTemplate::adaptAxes(
bool bPercent = (getStackMode(0) == StackMode::YStackedPercent);
if( bPercent && nDim == 1 )
{
- Reference< beans::XPropertySet > xAxisProp( xAxis, uno::UNO_QUERY );
- if( xAxisProp.is())
- {
- // set number format to source format
- xAxisProp->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(true));
- xAxisProp->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any());
- }
+ // set number format to source format
+ xAxis->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(true));
+ xAxis->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any());
}
}
}
@@ -749,19 +704,18 @@ sal_Int32 ChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension )
}
void ChartTypeTemplate::FillDiagram(
- const Reference< XDiagram >& xDiagram,
- const Sequence< Sequence< Reference< XDataSeries > > >& aSeriesSeq,
- const Reference< data::XLabeledDataSequence >& xCategories,
- const Sequence< Reference< XChartType > >& aOldChartTypesSeq )
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ const std::vector< std::vector< rtl::Reference< DataSeries > > >& aSeriesSeq,
+ const uno::Reference< chart2::data::XLabeledDataSequence >& xCategories,
+ const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq )
{
adaptDiagram( xDiagram );
try
{
// create coordinate systems and scales
- Reference< XCoordinateSystemContainer > xCoordSysCnt( xDiagram, uno::UNO_QUERY_THROW );
- createCoordinateSystems( xCoordSysCnt );
- Sequence< Reference< XCoordinateSystem > > aCoordinateSystems( xCoordSysCnt->getCoordinateSystems());
+ createCoordinateSystems( xDiagram );
+ std::vector< rtl::Reference< BaseCoordinateSystem > > aCoordinateSystems( xDiagram->getBaseCoordinateSystems());
createAxes( aCoordinateSystems );
adaptAxes( aCoordinateSystems );
adaptScales( aCoordinateSystems, xCategories );
@@ -777,62 +731,57 @@ void ChartTypeTemplate::FillDiagram(
}
void ChartTypeTemplate::createChartTypes(
- const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq,
- const Sequence< Reference< XCoordinateSystem > > & rCoordSys,
- const Sequence< Reference< XChartType > >& aOldChartTypesSeq )
+ const std::vector< std::vector< rtl::Reference< DataSeries > > > & aSeriesSeq,
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq )
{
- if( ! rCoordSys.hasElements() ||
- ! rCoordSys[0].is() )
+ if( rCoordSys.empty() )
return;
try
{
- sal_Int32 nCooSysIdx=0;
- Reference< XChartType > xCT;
- if( !aSeriesSeq.hasElements() )
+ std::size_t nCooSysIdx=0;
+ rtl::Reference< ChartType > xCT;
+ if( aSeriesSeq.empty() )
{
// we need a new chart type
- xCT.set( getChartTypeForNewSeries( aOldChartTypesSeq ));
- Reference< XChartTypeContainer > xCTCnt( rCoordSys[nCooSysIdx], uno::UNO_QUERY_THROW );
- xCTCnt->setChartTypes({ xCT });
+ xCT = getChartTypeForNewSeries2( aOldChartTypesSeq );
+ rCoordSys[nCooSysIdx]->setChartTypes(std::vector{ xCT });
}
else
{
- for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
+ for( std::size_t nSeriesIdx=0; nSeriesIdx<aSeriesSeq.size(); ++nSeriesIdx )
{
if( nSeriesIdx == nCooSysIdx )
{
// we need a new chart type
- xCT.set( getChartTypeForNewSeries( aOldChartTypesSeq ));
- Reference< XChartTypeContainer > xCTCnt( rCoordSys[nCooSysIdx], uno::UNO_QUERY_THROW );
- Sequence< Reference< XChartType > > aCTSeq( xCTCnt->getChartTypes());
- if( aCTSeq.hasElements())
+ xCT = getChartTypeForNewSeries2( aOldChartTypesSeq );
+ std::vector< rtl::Reference< ChartType > > aCTSeq( rCoordSys[nCooSysIdx]->getChartTypes2());
+ if( !aCTSeq.empty())
{
- aCTSeq.getArray()[0] = xCT;
- xCTCnt->setChartTypes( aCTSeq );
+ aCTSeq[0] = xCT;
+ rCoordSys[nCooSysIdx]->setChartTypes( aCTSeq );
}
else
- xCTCnt->addChartType( xCT );
+ rCoordSys[nCooSysIdx]->addChartType( xCT );
- Reference< chart2::XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- xDSCnt->setDataSeries( aSeriesSeq[nSeriesIdx] );
+ xCT->setDataSeries( aSeriesSeq[nSeriesIdx] );
}
else
{
// reuse existing chart type
OSL_ASSERT( xCT.is());
- Reference< chart2::XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- Sequence< Reference< XDataSeries > > aNewSeriesSeq( xDSCnt->getDataSeries());
- sal_Int32 nNewStartIndex = aNewSeriesSeq.getLength();
- aNewSeriesSeq.realloc( nNewStartIndex + aSeriesSeq[nSeriesIdx].getLength() );
+ std::vector< rtl::Reference< DataSeries > > aNewSeriesSeq = xCT->getDataSeries2();
+ sal_Int32 nNewStartIndex = aNewSeriesSeq.size();
+ aNewSeriesSeq.resize( nNewStartIndex + aSeriesSeq[nSeriesIdx].size() );
std::copy( aSeriesSeq[nSeriesIdx].begin(),
aSeriesSeq[nSeriesIdx].end(),
- aNewSeriesSeq.getArray() + nNewStartIndex );
- xDSCnt->setDataSeries( aNewSeriesSeq );
+ aNewSeriesSeq.begin() + nNewStartIndex );
+ xCT->setDataSeries( aNewSeriesSeq );
}
// spread the series over the available coordinate systems
- if( rCoordSys.getLength() > (nCooSysIdx + 1) )
+ if( rCoordSys.size() > (nCooSysIdx + 1) )
++nCooSysIdx;
}
}
@@ -844,27 +793,77 @@ void ChartTypeTemplate::createChartTypes(
}
void ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(
- const Sequence< Reference< XChartType > > & rOldChartTypesSeq,
- const Reference< XChartType > & xNewChartType )
+ const std::vector< rtl::Reference< ChartType > > & rOldChartTypesSeq,
+ const rtl::Reference< ChartType > & xNewChartType )
{
- Reference< beans::XPropertySet > xDestination( xNewChartType, uno::UNO_QUERY );
- if( !xDestination.is() )
+ if( !xNewChartType.is() )
return;
OUString aNewChartType( xNewChartType->getChartType() );
Reference< beans::XPropertySet > xSource;
- for( Reference< XChartType > const & xOldType : rOldChartTypesSeq )
+ for( rtl::Reference< ChartType > const & xOldType : rOldChartTypesSeq )
{
if( xOldType.is() && xOldType->getChartType() == aNewChartType )
{
- xSource.set( Reference< beans::XPropertySet >(xOldType, uno::UNO_QUERY ) );
+ xSource = xOldType;
if( xSource.is() )
break;
}
}
if( xSource.is() )
- comphelper::copyProperties( xSource, xDestination );
+ comphelper::copyProperties( xSource, xNewChartType );
+}
+
+css::uno::Reference< css::uno::XInterface > ChartTypeTemplate::getDataInterpreter()
+{
+ return static_cast<cppu::OWeakObject*>(getDataInterpreter2().get());
+}
+css::uno::Reference< css::chart2::XDiagram > ChartTypeTemplate::createDiagramByDataSource(
+ const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource,
+ const css::uno::Sequence< css::beans::PropertyValue >& aArguments )
+{
+ return createDiagramByDataSource2(xDataSource, aArguments);
+}
+void ChartTypeTemplate::changeDiagram(
+ const css::uno::Reference< css::chart2::XDiagram >& xDiagram )
+{
+ changeDiagram(rtl::Reference<Diagram>(dynamic_cast<Diagram*>(xDiagram.get())));
+}
+void ChartTypeTemplate::changeDiagramData(
+ const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
+ const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource,
+ const css::uno::Sequence< css::beans::PropertyValue >& aArguments )
+{
+ changeDiagramData(rtl::Reference<Diagram>(dynamic_cast<Diagram*>(xDiagram.get())), xDataSource, aArguments);
+}
+sal_Bool ChartTypeTemplate::matchesTemplate(
+ const css::uno::Reference<css::chart2::XDiagram >& xDiagram,
+ sal_Bool bAdaptProperties )
+{
+ return matchesTemplate2(dynamic_cast<Diagram*>(xDiagram.get()), static_cast<bool>(bAdaptProperties));
+}
+css::uno::Reference< ::css::chart2::XChartType > ChartTypeTemplate::getChartTypeForNewSeries(
+ const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes )
+{
+ std::vector< rtl::Reference< ::chart::ChartType > > aTmp;
+ aTmp.reserve(aFormerlyUsedChartTypes.getLength());
+ for (auto const & rxChartType : aFormerlyUsedChartTypes)
+ aTmp.push_back(dynamic_cast<ChartType*>(rxChartType.get()));
+ return getChartTypeForNewSeries2(aTmp);
+}
+void ChartTypeTemplate::applyStyle(
+ const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount )
+{
+ applyStyle2(dynamic_cast<DataSeries*>(xSeries.get()), nChartTypeIndex, nSeriesIndex, nSeriesCount);
+}
+void ChartTypeTemplate::resetStyles(
+ const css::uno::Reference< css::chart2::XDiagram >& xDiagram )
+{
+ resetStyles2(dynamic_cast<Diagram*>(xDiagram.get()));
}
} // namespace chart
diff --git a/chart2/source/model/template/ChartTypeTemplate.hxx b/chart2/source/model/template/ChartTypeTemplate.hxx
deleted file mode 100644
index dcd62646a239..000000000000
--- a/chart2/source/model/template/ChartTypeTemplate.hxx
+++ /dev/null
@@ -1,252 +0,0 @@
-/* -*- 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 <cppuhelper/implbase.hxx>
-#include <StackMode.hxx>
-#include <com/sun/star/chart2/XChartTypeTemplate.hpp>
-#include <com/sun/star/lang/XServiceName.hpp>
-
-namespace com::sun::star::chart2 { class XChartType; }
-namespace com::sun::star::chart2 { class XCoordinateSystemContainer; }
-namespace com::sun::star::chart2 { class XDataSeries; }
-namespace com::sun::star::uno { class XComponentContext; }
-
-namespace chart
-{
-
-/** For creating diagrams and modifying existing diagrams. A base class that
- implements XChartTypeTemplate and offers some tooling for classes that
- derive from this class.
-
- createDiagramByDataSource
-
- This does the following steps using some virtual helper-methods, that may be
- overridden by derived classes:
-
- * creates an XDiagram via service-factory.
-
- * convert the given XDataSource to a sequence of XDataSeries using the
- method createDataSeries(). In this class the DataInterpreter helper class
- is used to create a standard interpretation (just y-values).
-
- * call applyDefaultStyle() for all XDataSeries in order to apply default
- styles. In this class the series get the system-wide default colors as
- "Color" property.
-
- * call applyStyle() for applying chart-type specific styles to all series.
- The default implementation is empty.
-
- * call createCoordinateSystems() and apply them to the diagram. As
- default one cartesian system with Scales using a linear Scaling is
- created.
-
- * createChartTypes() is called in order to define the structure of the
- diagram. For details see comment of this function. As default this
- method creates a tree where all series appear in one branch with the chart
- type determined by getChartTypeForNewSeries(). The stacking is determined
- via the method getStackMode().
-
- * create an XLegend via the global service factory, set it at the diagram.
- */
-class ChartTypeTemplate : public ::cppu::WeakImplHelper<
- css::chart2::XChartTypeTemplate,
- css::lang::XServiceName >
-{
-public:
- explicit ChartTypeTemplate( css::uno::Reference< css::uno::XComponentContext > const & xContext,
- const OUString & rServiceName );
- virtual ~ChartTypeTemplate() override;
-
-protected:
- // ____ XChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XDiagram > SAL_CALL createDiagramByDataSource(
- const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource,
- const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override;
- /// denotes if the chart needs categories at the first scale
- virtual sal_Bool SAL_CALL supportsCategories() override;
-
- virtual void SAL_CALL changeDiagram(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override;
- virtual void SAL_CALL changeDiagramData(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource,
- const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override;
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference<
- css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- // still abstract: getChartTypeForNewSeries()
- virtual css::uno::Reference< css::chart2::XDataInterpreter > SAL_CALL getDataInterpreter() override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
- ::sal_Int32 nChartTypeIndex,
- ::sal_Int32 nSeriesIndex,
- ::sal_Int32 nSeriesCount ) override;
- virtual void SAL_CALL resetStyles(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override;
-
- /// @throws css::uno::RuntimeException
- void applyStyles(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram );
-
- // ____ XServiceName ____
- virtual OUString SAL_CALL getServiceName() override;
-
- // Methods to override for automatic creation
-
- /// returns 2 by default. Supported are 2 and 3
- virtual sal_Int32 getDimension() const;
-
- /** returns StackMode::NONE by default. This is a global flag used for all
- series of a specific chart type. If percent stacking is supported, the
- percent stacking mode is retrieved from the first chart type (index 0)
-
- @param nChartTypeIndex denotes the index of the charttype in means
- defined by the template creation order, i.e., 0 means the first
- chart type that a template creates.
- */
- virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const;
-
- virtual css::uno::Reference< css::chart2::XChartType >
- getChartTypeForIndex( sal_Int32 nChartTypeIndex ) = 0;
-
- virtual bool isSwapXAndY() const;
-
- // Methods for creating the diagram piecewise
-
- /** Allows derived classes to manipulate the diagrams whole, like changing
- the wall color. The default implementation is empty. It is called by
- FillDiagram which is called by createDiagramByDataSource and
- changeDiagram
- */
- virtual void adaptDiagram(
- const css::uno::Reference< css::chart2::XDiagram > & xDiagram );
-
- /** Creates a 2d or 3d cartesian coordinate system with mathematically
- oriented, linear scales with auto-min/max. If the given
- CoordinateSystemContainer is not empty, those coordinate system should
- be reused.
-
- <p>The dimension depends on the value returned by getDimension().</p>
- */
- virtual void createCoordinateSystems(
- const css::uno::Reference< css::chart2::XCoordinateSystemContainer > & xOutCooSysCnt );
-
- /** Sets categories at the scales of dimension 0 and the percent stacking at
- the scales of dimension 1 of all given coordinate systems.
-
- <p>Called by FillDiagram.</p>
- */
- virtual void adaptScales(
- const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & aCooSysSeq,
- const css::uno::Reference< css::chart2::data::XLabeledDataSequence > & xCategories );
-
- /** create a data series tree, that fits the requirements of the chart type.
-
- <p>As default, this creates a tree with the following structure:</p>
-
- <pre>
- root
- |
- +-- chart type (determined by getChartTypeForNewSeries())
- |
- +-- category (DiscreteStackableScaleGroup using scale 0)
- |
- +-- values (ContinuousStackableScaleGroup using scale 1)
- |
- +-- series 0
- |
- +-- series 1
- |
- ...
- |
- +.. series n-1
- </pre>
-
- <p>If there are less than two scales available the returned tree is
- empty.</p>
- */
- virtual void createChartTypes(
- const css::uno::Sequence<
- css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XDataSeries > > > & aSeriesSeq,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XCoordinateSystem > > & rCoordSys,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XChartType > > & aOldChartTypesSeq
- );
-
- /** create axes and add them to the given container. If there are already
- compatible axes in the container these should be maintained.
-
- <p>As default, this method creates as many axes as there are dimensions
- in the given first coordinate system. Each of the axis
- represents one of the dimensions of the coordinate systems. If there are series
- requesting a secondary axes a secondary y axes is added</p>
- */
- void createAxes(
- const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & rCoordSys );
-
- /** Give the number of requested axis per dimension here. Default is one
- axis for each dimension
- */
- virtual sal_Int32 getAxisCountByDimension( sal_Int32 nDimension );
-
- /** adapt properties of existing axes and remove superfluous axes
- */
- virtual void adaptAxes(
- const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & rCoordSys );
-
- const css::uno::Reference< css::uno::XComponentContext >&
- GetComponentContext() const { return m_xContext;}
-
- static void copyPropertiesFromOldToNewCoordinateSystem(
- const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > > & rOldChartTypesSeq,
- const css::uno::Reference< css::chart2::XChartType > & xNewChartType );
-
-protected:
- css::uno::Reference< css::uno::XComponentContext > m_xContext;
- mutable css::uno::Reference< css::chart2::XDataInterpreter > m_xDataInterpreter;
-
-private:
- const OUString m_aServiceName;
-
-private:
- /** modifies the given diagram
- */
- void FillDiagram( const css::uno::Reference<
- css::chart2::XDiagram > & xDiagram,
- const css::uno::Sequence<
- css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XDataSeries > > > & aSeriesSeq,
- const css::uno::Reference<
- css::chart2::data::XLabeledDataSequence >& xCategories,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XChartType > > & aOldChartTypesSeq);
-};
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ColumnChartType.cxx b/chart2/source/model/template/ColumnChartType.cxx
index 36eb72b33623..cc351e77512b 100644
--- a/chart2/source/model/template/ColumnChartType.cxx
+++ b/chart2/source/model/template/ColumnChartType.cxx
@@ -54,67 +54,19 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEDEFAULT );
}
-struct StaticColumnChartTypeDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- Sequence< sal_Int32 > aSeq{ 0, 0 };
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq );
-
- aSeq = { 100, 100 };
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq );
- }
-};
-
-struct StaticColumnChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticColumnChartTypeDefaults_Initializer >
-{
-};
-
-struct StaticColumnChartTypeInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static 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 StaticColumnChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticColumnChartTypeInfoHelper_Initializer >
+::cppu::OPropertyArrayHelper & StaticColumnChartTypeInfoHelper()
{
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
-struct StaticColumnChartTypeInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticColumnChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnChartTypeInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -139,6 +91,11 @@ uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone()
return uno::Reference< util::XCloneable >( new ColumnChartType( *this ));
}
+rtl::Reference< ChartType > ColumnChartType::cloneChartType() const
+{
+ return new ColumnChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL ColumnChartType::getChartType()
{
@@ -151,24 +108,35 @@ uno::Sequence< OUString > ColumnChartType::getSupportedPropertyRoles()
}
// ____ OPropertySet ____
-uno::Any ColumnChartType::GetDefaultValue( sal_Int32 nHandle ) const
-{
- const tPropertyValueMap& rStaticDefaults = *StaticColumnChartTypeDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+void ColumnChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
+{
+ static const ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ Sequence< sal_Int32 > aSeq{ 0, 0 };
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq );
+ aSeq = { 100, 100 };
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq );
+ return aTmp;
+ }();
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL ColumnChartType::getInfoHelper()
{
- return *StaticColumnChartTypeInfoHelper::get();
+ return StaticColumnChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnChartType::getPropertySetInfo()
{
- return *StaticColumnChartTypeInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticColumnChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
}
OUString SAL_CALL ColumnChartType::getImplementationName()
diff --git a/chart2/source/model/template/ColumnChartType.hxx b/chart2/source/model/template/ColumnChartType.hxx
index 3245185650da..2c6b3d762321 100644
--- a/chart2/source/model/template/ColumnChartType.hxx
+++ b/chart2/source/model/template/ColumnChartType.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -36,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit ColumnChartType( const ColumnChartType & rOther );
@@ -45,7 +47,7 @@ private:
getSupportedPropertyRoles() override;
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
index 889ca43f40e7..7e0117cca295 100644
--- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
@@ -18,24 +18,24 @@
*/
#include "ColumnLineChartTypeTemplate.hxx"
+#include "ColumnChartType.hxx"
+#include "LineChartType.hxx"
#include <CommonConverters.hxx>
+#include <BaseCoordinateSystem.hxx>
+#include <Diagram.hxx>
#include <DiagramHelper.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <servicenames_charttypes.hxx>
#include "ColumnLineDataInterpreter.hxx"
#include <PropertyHelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
-using namespace ::com::sun::star::chart2;
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
@@ -50,69 +50,44 @@ enum
PROP_COL_LINE_NUMBER_OF_LINES
};
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+::chart::tPropertyValueMap& StaticColumnLineChartTypeTemplateDefaults()
{
- rOutProperties.emplace_back( "NumberOfLines",
- PROP_COL_LINE_NUMBER_OF_LINES,
- cppu::UnoType<sal_Int32>::get(),
- beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ []()
+ {
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_COL_LINE_NUMBER_OF_LINES, 1 );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
}
-struct StaticColumnLineChartTypeTemplateDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aStaticDefaults, PROP_COL_LINE_NUMBER_OF_LINES, 1 );
- return &aStaticDefaults;
- }
-};
-
-struct StaticColumnLineChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticColumnLineChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticColumnLineChartTypeTemplateInfoHelper_Initializer
+::cppu::OPropertyArrayHelper& StaticColumnLineChartTypeTemplateInfoHelper()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-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 );
- }
-
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { "NumberOfLines",
+ PROP_COL_LINE_NUMBER_OF_LINES,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT } };
-struct StaticColumnLineChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticColumnLineChartTypeTemplateInfoHelper_Initializer >
-{
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticColumnLineChartTypeTemplateInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnLineChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ return comphelper::containerToSequence( aProperties );
+ }());
+ return aPropHelper;
+}
-struct StaticColumnLineChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnLineChartTypeTemplateInfo_Initializer >
+uno::Reference< beans::XPropertySetInfo >& StaticColumnLineChartTypeTemplateInfo()
{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticColumnLineChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -126,7 +101,6 @@ ColumnLineChartTypeTemplate::ColumnLineChartTypeTemplate(
StackMode eStackMode,
sal_Int32 nNumberOfLines ) :
ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex ),
m_eStackMode( eStackMode )
{
setFastPropertyValue_NoBroadcast( PROP_COL_LINE_NUMBER_OF_LINES, uno::Any( nNumberOfLines ));
@@ -136,41 +110,39 @@ ColumnLineChartTypeTemplate::~ColumnLineChartTypeTemplate()
{}
// ____ OPropertySet ____
-uno::Any ColumnLineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void ColumnLineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticColumnLineChartTypeTemplateDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticColumnLineChartTypeTemplateDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL ColumnLineChartTypeTemplate::getInfoHelper()
{
- return *StaticColumnLineChartTypeTemplateInfoHelper::get();
+ return StaticColumnLineChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnLineChartTypeTemplate::getPropertySetInfo()
{
- return *StaticColumnLineChartTypeTemplateInfo::get();
+ return StaticColumnLineChartTypeTemplateInfo();
}
void ColumnLineChartTypeTemplate::createChartTypes(
- const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq,
- const Sequence< Reference< XCoordinateSystem > > & rCoordSys,
- const Sequence< Reference< XChartType > >& aOldChartTypesSeq )
+ const std::vector< std::vector< rtl::Reference< DataSeries > > > & aSeriesSeq,
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq )
{
- if( ! rCoordSys.hasElements() ||
- ! rCoordSys[0].is() )
+ if( rCoordSys.empty() )
return;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- const Sequence< Reference< XDataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq ));
- sal_Int32 nNumberOfSeries = aFlatSeriesSeq.getLength();
+ const std::vector< rtl::Reference< DataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq ));
+ sal_Int32 nNumberOfSeries = aFlatSeriesSeq.size();
sal_Int32 nNumberOfLines = 0;
sal_Int32 nNumberOfColumns = 0;
@@ -194,38 +166,33 @@ void ColumnLineChartTypeTemplate::createChartTypes(
// Columns
- Reference< XChartType > xCT(
- xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY_THROW );
+ rtl::Reference< ChartType > xCT = new ColumnChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aOldChartTypesSeq, xCT );
- Reference< XChartTypeContainer > xCTCnt( rCoordSys[ 0 ], uno::UNO_QUERY_THROW );
- xCTCnt->setChartTypes( Sequence< Reference< chart2::XChartType > >( &xCT, 1 ));
+ rCoordSys[ 0 ]->setChartTypes( std::vector{xCT} );
if( nNumberOfColumns > 0 )
{
- Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- Sequence< Reference< XDataSeries > > aColumnSeq( nNumberOfColumns );
+ std::vector< rtl::Reference< DataSeries > > aColumnSeq( nNumberOfColumns );
std::copy( aFlatSeriesSeq.begin(),
aFlatSeriesSeq.begin() + nNumberOfColumns,
- aColumnSeq.getArray());
- xDSCnt->setDataSeries( aColumnSeq );
+ aColumnSeq.begin());
+ xCT->setDataSeries( aColumnSeq );
}
// Lines
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
- xCTCnt.set( rCoordSys[ 0 ], uno::UNO_QUERY_THROW );
- xCTCnt->addChartType( xCT );
+ xCT = new LineChartType();
+ rCoordSys[ 0 ]->addChartType( xCT );
if( nNumberOfLines > 0 )
{
- Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- Sequence< Reference< XDataSeries > > aLineSeq( nNumberOfLines );
+ std::vector< rtl::Reference< DataSeries > > aLineSeq( nNumberOfLines );
std::copy( aFlatSeriesSeq.begin() + nNumberOfColumns,
aFlatSeriesSeq.end(),
- aLineSeq.getArray());
- xDSCnt->setDataSeries( aLineSeq );
+ aLineSeq.begin());
+ xCT->setDataSeries( aLineSeq );
}
}
catch( const uno::Exception & )
@@ -234,13 +201,13 @@ void ColumnLineChartTypeTemplate::createChartTypes(
}
}
-void SAL_CALL ColumnLineChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void ColumnLineChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
if( nChartTypeIndex==0 ) // columns
{
@@ -248,13 +215,9 @@ void SAL_CALL ColumnLineChartTypeTemplate::applyStyle(
}
else if( nChartTypeIndex==1 ) // lines
{
- Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY );
- if( xProp.is() )
- {
- DataSeriesHelper::switchLinesOnOrOff( xProp, true );
- DataSeriesHelper::switchSymbolsOnOrOff( xProp, false, nSeriesIndex );
- DataSeriesHelper::makeLinesThickOrThin( xProp, true );
- }
+ DataSeriesHelper::switchLinesOnOrOff( xSeries, true );
+ DataSeriesHelper::switchSymbolsOnOrOff( xSeries, false, nSeriesIndex );
+ DataSeriesHelper::makeLinesThickOrThin( xSeries, true );
}
}
@@ -266,9 +229,9 @@ StackMode ColumnLineChartTypeTemplate::getStackMode( sal_Int32 nChartTypeIndex )
}
// ____ XChartTypeTemplate ____
-sal_Bool SAL_CALL ColumnLineChartTypeTemplate::matchesTemplate(
- const uno::Reference< XDiagram >& xDiagram,
- sal_Bool bAdaptProperties )
+bool ColumnLineChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties )
{
bool bResult = false;
@@ -277,35 +240,27 @@ sal_Bool SAL_CALL ColumnLineChartTypeTemplate::matchesTemplate(
try
{
- Reference< chart2::XChartType > xColumnChartType;
- Reference< XCoordinateSystem > xColumnChartCooSys;
- Reference< chart2::XChartType > xLineChartType;
+ rtl::Reference< ChartType > xColumnChartType;
+ rtl::Reference< BaseCoordinateSystem > xColumnChartCooSys;
+ rtl::Reference< ChartType > xLineChartType;
sal_Int32 nNumberOfChartTypes = 0;
- Reference< XCoordinateSystemContainer > xCooSysCnt(
- xDiagram, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
- xCooSysCnt->getCoordinateSystems());
- for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : xDiagram->getBaseCoordinateSystems() )
{
- Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
- for( Reference< XChartType > const & chartType : aChartTypeSeq )
+ const std::vector< rtl::Reference< ChartType > > aChartTypeSeq( coords->getChartTypes2());
+ for( rtl::Reference< ChartType > const & chartType : aChartTypeSeq )
{
- if( chartType.is())
+ ++nNumberOfChartTypes;
+ if( nNumberOfChartTypes > 2 )
+ break;
+ OUString aCTService = chartType->getChartType();
+ if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
{
- ++nNumberOfChartTypes;
- if( nNumberOfChartTypes > 2 )
- break;
- OUString aCTService = chartType->getChartType();
- if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
- {
- xColumnChartType.set( chartType );
- xColumnChartCooSys.set( coords );
- }
- else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
- xLineChartType.set( chartType );
+ xColumnChartType = chartType;
+ xColumnChartCooSys = coords;
}
+ else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
+ xLineChartType = chartType;
}
if( nNumberOfChartTypes > 2 )
break;
@@ -330,10 +285,9 @@ sal_Bool SAL_CALL ColumnLineChartTypeTemplate::matchesTemplate(
if( bResult && bAdaptProperties )
{
- Reference< XDataSeriesContainer > xSeriesContainer( xLineChartType, uno::UNO_QUERY );
- if( xSeriesContainer.is() )
+ if( xLineChartType.is() )
{
- sal_Int32 nNumberOfLines = xSeriesContainer->getDataSeries().getLength();
+ sal_Int32 nNumberOfLines = xLineChartType->getDataSeries().getLength();
setFastPropertyValue_NoBroadcast( PROP_COL_LINE_NUMBER_OF_LINES, uno::Any( nNumberOfLines ));
}
}
@@ -348,32 +302,22 @@ sal_Bool SAL_CALL ColumnLineChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< chart2::XChartType > ColumnLineChartTypeTemplate::getChartTypeForIndex( sal_Int32 nChartTypeIndex )
+rtl::Reference< ChartType > ColumnLineChartTypeTemplate::getChartTypeForIndex( sal_Int32 nChartTypeIndex )
{
- Reference< chart2::XChartType > xCT;
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY );
- if(xFact.is())
- {
- if( nChartTypeIndex == 0 )
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY );
- else
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY );
- }
- return xCT;
+ if( nChartTypeIndex == 0 )
+ return new ColumnChartType();
+ else
+ return new LineChartType();
}
-Reference< XChartType > SAL_CALL ColumnLineChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > ColumnLineChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
+ xResult = new LineChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
}
catch( const uno::Exception & )
@@ -384,13 +328,13 @@ Reference< XChartType > SAL_CALL ColumnLineChartTypeTemplate::getChartTypeForNew
return xResult;
}
-Reference< XDataInterpreter > SAL_CALL ColumnLineChartTypeTemplate::getDataInterpreter()
+rtl::Reference< DataInterpreter > ColumnLineChartTypeTemplate::getDataInterpreter2()
{
if( ! m_xDataInterpreter.is())
{
sal_Int32 nNumberOfLines = 1;
getFastPropertyValue( PROP_COL_LINE_NUMBER_OF_LINES ) >>= nNumberOfLines;
- m_xDataInterpreter.set( new ColumnLineDataInterpreter( nNumberOfLines ) );
+ m_xDataInterpreter = new ColumnLineDataInterpreter( nNumberOfLines );
}
else
{
diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx
index c3c6f1c00851..68f144d6fedb 100644
--- a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx
+++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx
@@ -18,18 +18,16 @@
*/
#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <StackMode.hxx>
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
namespace chart
{
class ColumnLineChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -48,42 +46,40 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence<
- css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ // ____ ChartTypeTemplate ____
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
- virtual css::uno::Reference< css::chart2::XDataInterpreter > SAL_CALL getDataInterpreter() override;
+ virtual rtl::Reference< ::chart::DataInterpreter > getDataInterpreter2() override;
// ____ ChartTypeTemplate ____
virtual void createChartTypes(
- const css::uno::Sequence<
- css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XDataSeries > > > & aSeriesSeq,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XCoordinateSystem > > & rCoordSys,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XChartType > > & aOldChartTypesSeq
+ const std::vector<
+ std::vector<
+ rtl::Reference<
+ ::chart::DataSeries > > > & aSeriesSeq,
+ const std::vector<
+ rtl::Reference<
+ ::chart::BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq
) override;
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
diff --git a/chart2/source/model/template/ColumnLineDataInterpreter.cxx b/chart2/source/model/template/ColumnLineDataInterpreter.cxx
index 658bf2fd62d9..5cce30cd97a0 100644
--- a/chart2/source/model/template/ColumnLineDataInterpreter.cxx
+++ b/chart2/source/model/template/ColumnLineDataInterpreter.cxx
@@ -18,13 +18,13 @@
*/
#include "ColumnLineDataInterpreter.hxx"
+#include <DataSeries.hxx>
#include <osl/diagnose.h>
#include <algorithm>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
-using namespace ::std;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -41,34 +41,33 @@ ColumnLineDataInterpreter::ColumnLineDataInterpreter(
ColumnLineDataInterpreter::~ColumnLineDataInterpreter()
{}
-// ____ XDataInterpreter ____
-InterpretedData SAL_CALL ColumnLineDataInterpreter::interpretDataSource(
+// ____ DataInterpreter ____
+InterpretedData ColumnLineDataInterpreter::interpretDataSource(
const Reference< data::XDataSource >& xSource,
const Sequence< beans::PropertyValue >& aArguments,
- const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+ const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
{
InterpretedData aResult( DataInterpreter::interpretDataSource( xSource, aArguments, aSeriesToReUse ));
// the base class should return one group
- OSL_ASSERT( aResult.Series.getLength() == 1 );
- if( aResult.Series.getLength() == 1 )
+ OSL_ASSERT( aResult.Series.size() == 1 );
+ if( aResult.Series.size() == 1 )
{
- sal_Int32 nNumberOfSeries = aResult.Series[0].getLength();
+ sal_Int32 nNumberOfSeries = aResult.Series[0].size();
// if we have more than one series put the last nNumOfLines ones into a new group
if( nNumberOfSeries > 1 && m_nNumberOfLines > 0 )
{
sal_Int32 nNumOfLines = std::min( m_nNumberOfLines, nNumberOfSeries - 1 );
- aResult.Series.realloc(2);
- auto pSeries = aResult.Series.getArray();
+ aResult.Series.resize(2);
- Sequence< Reference< XDataSeries > > & rColumnDataSeries = pSeries[0];
- Sequence< Reference< XDataSeries > > & rLineDataSeries = pSeries[1];
- rLineDataSeries.realloc( nNumOfLines );
+ std::vector< rtl::Reference< DataSeries > > & rColumnDataSeries = aResult.Series[0];
+ std::vector< rtl::Reference< DataSeries > > & rLineDataSeries = aResult.Series[1];
+ rLineDataSeries.resize( nNumOfLines );
std::copy( std::cbegin(rColumnDataSeries) + nNumberOfSeries - nNumOfLines,
std::cbegin(rColumnDataSeries) + nNumberOfSeries,
- rLineDataSeries.getArray() );
- rColumnDataSeries.realloc( nNumberOfSeries - nNumOfLines );
+ rLineDataSeries.begin() );
+ rColumnDataSeries.resize( nNumberOfSeries - nNumOfLines );
}
}
diff --git a/chart2/source/model/template/ColumnLineDataInterpreter.hxx b/chart2/source/model/template/ColumnLineDataInterpreter.hxx
index 43801bc249d3..c2ec75826007 100644
--- a/chart2/source/model/template/ColumnLineDataInterpreter.hxx
+++ b/chart2/source/model/template/ColumnLineDataInterpreter.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "DataInterpreter.hxx"
+#include <DataInterpreter.hxx>
namespace chart
{
@@ -29,12 +29,11 @@ public:
virtual ~ColumnLineDataInterpreter() override;
protected:
- // ____ XDataInterpreter ____
- virtual css::chart2::InterpretedData SAL_CALL interpretDataSource(
+ // ____ DataInterpreter ____
+ virtual InterpretedData interpretDataSource(
const css::uno::Reference<css::chart2::data::XDataSource>& xSource,
const css::uno::Sequence<css::beans::PropertyValue>& aArguments,
- const css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries>>& aSeriesToReUse)
- override;
+ const std::vector<rtl::Reference<::chart::DataSeries>>& aSeriesToReUse) override;
private:
sal_Int32 m_nNumberOfLines;
diff --git a/chart2/source/model/template/DataInterpreter.cxx b/chart2/source/model/template/DataInterpreter.cxx
index 524ce73d0d2d..0f5cebc3bbec 100644
--- a/chart2/source/model/template/DataInterpreter.cxx
+++ b/chart2/source/model/template/DataInterpreter.cxx
@@ -17,22 +17,20 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "DataInterpreter.hxx"
+#include <DataInterpreter.hxx>
#include <DataSeries.hxx>
-#include <DataSourceHelper.hxx>
+#include <DataSource.hxx>
#include <DataSeriesHelper.hxx>
#include <CommonConverters.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/chart2/data/XDataSink.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
-#include <vector>
#include <algorithm>
+#include <cstddef>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
-using namespace ::std;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -54,10 +52,10 @@ DataInterpreter::~DataInterpreter()
{}
// ____ XDataInterpreter ____
-InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
+InterpretedData DataInterpreter::interpretDataSource(
const Reference< data::XDataSource >& xSource,
const Sequence< beans::PropertyValue >& aArguments,
- const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+ const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
{
if( ! xSource.is())
return InterpretedData();
@@ -66,10 +64,10 @@ InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
lcl_ShowDataSource( xSource );
#endif
- const Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aData = getDataSequences(xSource);
- Reference< data::XLabeledDataSequence > xCategories;
- vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
+ uno::Reference< chart2::data::XLabeledDataSequence > xCategories;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSequencesVec;
// check if we should use categories
@@ -77,13 +75,13 @@ InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
// parse data
bool bCategoriesUsed = false;
- for( Reference< data::XLabeledDataSequence > const & labeledData : aData )
+ for( uno::Reference< chart2::data::XLabeledDataSequence > const & labeledData : aData )
{
try
{
if( bHasCategories && ! bCategoriesUsed )
{
- xCategories.set( labeledData );
+ xCategories = labeledData;
if( xCategories.is())
SetRole( xCategories->getValues(), "categories");
bCategoriesUsed = true;
@@ -102,53 +100,50 @@ InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
}
// create DataSeries
- sal_Int32 nSeriesIndex = 0;
- vector< Reference< XDataSeries > > aSeriesVec;
+ std::size_t nSeriesIndex = 0;
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec;
aSeriesVec.reserve( aSequencesVec.size());
for (auto const& elem : aSequencesVec)
{
- Sequence< Reference< data::XLabeledDataSequence > > aNewData( &elem, 1 );
- Reference< XDataSeries > xSeries;
- if( nSeriesIndex < aSeriesToReUse.getLength())
- xSeries.set( aSeriesToReUse[nSeriesIndex] );
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewData { elem };
+ rtl::Reference< DataSeries > xSeries;
+ if( nSeriesIndex < aSeriesToReUse.size())
+ xSeries = aSeriesToReUse[nSeriesIndex];
else
- xSeries.set( new DataSeries );
- OSL_ASSERT( xSeries.is() );
- Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
- OSL_ASSERT( xSink.is() );
- xSink->setData( aNewData );
+ xSeries = new DataSeries;
+ assert( xSeries.is() );
+ xSeries->setData( aNewData );
aSeriesVec.push_back( xSeries );
++nSeriesIndex;
}
- return InterpretedData( { comphelper::containerToSequence( aSeriesVec ) }, xCategories );
+ return { { aSeriesVec }, xCategories };
}
-InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
+InterpretedData DataInterpreter::reinterpretDataSeries(
const InterpretedData& aInterpretedData )
{
InterpretedData aResult( aInterpretedData );
sal_Int32 i=0;
- Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- const sal_Int32 nCount = aSeries.getLength();
+ std::vector< rtl::Reference< DataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ const sal_Int32 nCount = aSeries.size();
for( ; i<nCount; ++i )
{
try
{
- Reference< data::XDataSource > xSeriesSource( aSeries[i], uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aNewSequences;
+ std::vector< uno::Reference< data::XLabeledDataSequence > > aNewSequences;
// values-y
- Reference< data::XLabeledDataSequence > xValuesY(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-y" ));
+ uno::Reference< data::XLabeledDataSequence > xValuesY =
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values-y" );
// re-use values-... as values-y
if( ! xValuesY.is())
{
- xValuesY.set(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values", true ));
+ xValuesY =
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values", true );
if( xValuesY.is())
SetRole( xValuesY->getValues(), "values-y");
}
@@ -157,8 +152,8 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
aNewSequences = { xValuesY };
}
- Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
- if( aSeqs.getLength() != aNewSequences.getLength() )
+ const std::vector< uno::Reference< data::XLabeledDataSequence > > & aSeqs = aSeries[i]->getDataSequences2();
+ if( aSeqs.size() != aNewSequences.size() )
{
#ifdef DEBUG_CHART2_TEMPLATE
sal_Int32 j=0;
@@ -167,8 +162,7 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
assert( aSeqs[j] == xValuesY && "All sequences should be used" );
}
#endif
- Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
- xSink->setData( aNewSequences );
+ aSeries[i]->setData( aNewSequences );
}
}
catch( const uno::Exception & )
@@ -181,17 +175,15 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
}
// criterion: all series must have exactly one data::XLabeledDataSequence
-sal_Bool SAL_CALL DataInterpreter::isDataCompatible(
- const chart2::InterpretedData& aInterpretedData )
+bool DataInterpreter::isDataCompatible(
+ const InterpretedData& aInterpretedData )
{
- const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- for( Reference< XDataSeries > const & i : aSeries )
+ const std::vector< rtl::Reference< DataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ for( rtl::Reference< DataSeries > const & i : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( i, uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
- if( aSeq.getLength() != 1 )
+ if( i->getDataSequences2().size() != 1 )
return false;
}
catch( const uno::Exception & )
@@ -256,27 +248,24 @@ private:
} // anonymous namespace
-Reference< data::XDataSource > SAL_CALL DataInterpreter::mergeInterpretedData(
+rtl::Reference< DataSource > DataInterpreter::mergeInterpretedData(
const InterpretedData& aInterpretedData )
{
- vector< Reference< data::XLabeledDataSequence > > aResultVec;
- aResultVec.reserve( aInterpretedData.Series.getLength() +
+ std::vector< Reference< data::XLabeledDataSequence > > aResultVec;
+ aResultVec.reserve( aInterpretedData.Series.size() +
1 // categories
);
if( aInterpretedData.Categories.is())
aResultVec.push_back( aInterpretedData.Categories );
- const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- for( Reference< XDataSeries > const & dataSeries : aSeries )
+ const std::vector< rtl::Reference< DataSeries > > aSeries = FlattenSequence( aInterpretedData.Series );
+ for( rtl::Reference< DataSeries > const & dataSeries : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
- const Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
-
// add all sequences of data series
- for( Reference< data::XLabeledDataSequence > const & xAdd : aSeq )
+ for( uno::Reference< data::XLabeledDataSequence > const & xAdd : dataSeries->getDataSequences2() )
{
// only add if sequence is not yet in the result
if( none_of( aResultVec.begin(), aResultVec.end(),
@@ -292,10 +281,10 @@ Reference< data::XDataSource > SAL_CALL DataInterpreter::mergeInterpretedData(
}
}
- return DataSourceHelper::createDataSource( comphelper::containerToSequence( aResultVec ) );
+ return new DataSource(aResultVec);
}
-uno::Any SAL_CALL DataInterpreter::getChartTypeSpecificData(
+uno::Any DataInterpreter::getChartTypeSpecificData(
const OUString & )
{
return uno::Any();
@@ -350,14 +339,14 @@ uno::Any DataInterpreter::GetProperty(
bool DataInterpreter::HasCategories(
const Sequence< beans::PropertyValue > & rArguments,
- const Sequence< Reference< data::XLabeledDataSequence > > & rData )
+ const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & rData )
{
bool bHasCategories = false;
if( rArguments.hasElements() )
GetProperty( rArguments, u"HasCategories" ) >>= bHasCategories;
- for( sal_Int32 nLSeqIdx=0; ! bHasCategories && nLSeqIdx<rData.getLength(); ++nLSeqIdx )
+ for( std::size_t nLSeqIdx=0; ! bHasCategories && nLSeqIdx<rData.size(); ++nLSeqIdx )
bHasCategories = ( rData[nLSeqIdx].is() && GetRole( rData[nLSeqIdx]->getValues() ) == "categories");
return bHasCategories;
@@ -386,6 +375,17 @@ css::uno::Sequence< OUString > SAL_CALL DataInterpreter::getSupportedServiceName
return { "com.sun.star.chart2.DataInterpreter" };
}
+std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > DataInterpreter::getDataSequences(
+ const css::uno::Reference< css::chart2::data::XDataSource >& xSource)
+{
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aData;
+ for (const Reference< data::XLabeledDataSequence > & rLDS : xSource->getDataSequences() )
+ {
+ aData.push_back(rLDS);
+ }
+ return aData;
+}
+
} // namespace chart
#ifdef DEBUG_CHART2_TEMPLATE
diff --git a/chart2/source/model/template/DataInterpreter.hxx b/chart2/source/model/template/DataInterpreter.hxx
deleted file mode 100644
index 5f9a9239202f..000000000000
--- a/chart2/source/model/template/DataInterpreter.hxx
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- 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 <cppuhelper/implbase.hxx>
-#include <com/sun/star/chart2/XDataInterpreter.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-
-namespace chart
-{
-
-class DataInterpreter : public ::cppu::WeakImplHelper<
- css::chart2::XDataInterpreter,
- css::lang::XServiceInfo >
-{
-public:
- explicit DataInterpreter();
- virtual ~DataInterpreter() 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;
-
- // convenience methods
- static OUString GetRole( const css::uno::Reference< css::chart2::data::XDataSequence > & xSeq );
-
- static void SetRole(
- const css::uno::Reference< css::chart2::data::XDataSequence > & xSeq,
- const OUString & rRole );
-
- static css::uno::Any GetProperty(
- const css::uno::Sequence<css::beans::PropertyValue > & aArguments,
- std::u16string_view rName );
-
- static bool HasCategories(
- const css::uno::Sequence< css::beans::PropertyValue > & rArguments,
- const css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > & rData );
-
- static bool UseCategoriesAsX(
- const css::uno::Sequence< css::beans::PropertyValue > & rArguments );
-
-protected:
- // ____ XDataInterpreter ____
- virtual css::chart2::InterpretedData SAL_CALL interpretDataSource(
- const css::uno::Reference< css::chart2::data::XDataSource >& xSource,
- const css::uno::Sequence< css::beans::PropertyValue >& aArguments,
- const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > >& aSeriesToReUse ) override;
- virtual css::chart2::InterpretedData SAL_CALL reinterpretDataSeries(
- const css::chart2::InterpretedData& aInterpretedData ) override;
- virtual sal_Bool SAL_CALL isDataCompatible(
- const css::chart2::InterpretedData& aInterpretedData ) override;
- virtual css::uno::Reference< css::chart2::data::XDataSource > SAL_CALL mergeInterpretedData(
- const css::chart2::InterpretedData& aInterpretedData ) override;
- virtual css::uno::Any SAL_CALL getChartTypeSpecificData(
- const OUString& sKey ) override;
-};
-
-} // namespace chart
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/FilledNetChartType.cxx b/chart2/source/model/template/FilledNetChartType.cxx
index 3179317daee5..60672259b905 100644
--- a/chart2/source/model/template/FilledNetChartType.cxx
+++ b/chart2/source/model/template/FilledNetChartType.cxx
@@ -24,7 +24,6 @@
namespace com::sun::star::uno { class XComponentContext; }
using namespace ::com::sun::star;
-using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Sequence;
@@ -48,6 +47,11 @@ uno::Reference< util::XCloneable > SAL_CALL FilledNetChartType::createClone()
return uno::Reference< util::XCloneable >( new FilledNetChartType( *this ));
}
+rtl::Reference< ChartType > FilledNetChartType::cloneChartType() const
+{
+ return new FilledNetChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL FilledNetChartType::getChartType()
{
diff --git a/chart2/source/model/template/FilledNetChartType.hxx b/chart2/source/model/template/FilledNetChartType.hxx
index 0ca41b60ba55..b2d239aeca36 100644
--- a/chart2/source/model/template/FilledNetChartType.hxx
+++ b/chart2/source/model/template/FilledNetChartType.hxx
@@ -32,6 +32,8 @@ public:
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit FilledNetChartType(const FilledNetChartType& rOther);
diff --git a/chart2/source/model/template/LineChartType.cxx b/chart2/source/model/template/LineChartType.cxx
index 64b2fe9c146f..e9d7cf808e53 100644
--- a/chart2/source/model/template/LineChartType.cxx
+++ b/chart2/source/model/template/LineChartType.cxx
@@ -43,90 +43,59 @@ enum
PROP_LINECHARTTYPE_SPLINE_ORDER
};
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+::chart::tPropertyValueMap& StaticLineChartTypeDefaults()
+{
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ []()
+ {
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_LINECHARTTYPE_CURVE_STYLE, ::chart2::CurveStyle_LINES );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_CURVE_RESOLUTION, 20 );
+
+ // todo: check whether order 3 means polygons of order 3 or 2. (see
+ // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_SPLINE_ORDER, 3 );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
+}
+
+::cppu::OPropertyArrayHelper& StaticLineChartTypeInfoHelper()
{
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_STYLE,
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { CHART_UNONAME_CURVE_STYLE,
PROP_LINECHARTTYPE_CURVE_STYLE,
cppu::UnoType<chart2::CurveStyle>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
-
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_RESOLUTION,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_CURVE_RESOLUTION,
PROP_LINECHARTTYPE_CURVE_RESOLUTION,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_SPLINE_ORDER,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_SPLINE_ORDER,
PROP_LINECHARTTYPE_SPLINE_ORDER,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
-}
-
-struct StaticLineChartTypeDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINECHARTTYPE_CURVE_STYLE, ::chart2::CurveStyle_LINES );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_CURVE_RESOLUTION, 20 );
-
- // todo: check whether order 3 means polygons of order 3 or 2. (see
- // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_SPLINE_ORDER, 3 );
- }
-};
-
-struct StaticLineChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLineChartTypeDefaults_Initializer >
-{
-};
-
-struct StaticLineChartTypeInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
+ | beans::PropertyAttribute::MAYBEDEFAULT } };
- return comphelper::containerToSequence( aProperties );
- }
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-};
-
-struct StaticLineChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLineChartTypeInfoHelper_Initializer >
-{
-};
-
-struct StaticLineChartTypeInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLineChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ return comphelper::containerToSequence( aProperties );
+ }());
+ return aPropHelper;
+}
-struct StaticLineChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLineChartTypeInfo_Initializer >
+uno::Reference< beans::XPropertySetInfo >& StaticLineChartTypeInfo()
{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticLineChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -151,6 +120,11 @@ uno::Reference< util::XCloneable > SAL_CALL LineChartType::createClone()
return uno::Reference< util::XCloneable >( new LineChartType( *this ));
}
+rtl::Reference< ChartType > LineChartType::cloneChartType() const
+{
+ return new LineChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL LineChartType::getChartType()
{
@@ -158,24 +132,25 @@ OUString SAL_CALL LineChartType::getChartType()
}
// ____ OPropertySet ____
-uno::Any LineChartType::GetDefaultValue( sal_Int32 nHandle ) const
+void LineChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticLineChartTypeDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticLineChartTypeDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL LineChartType::getInfoHelper()
{
- return *StaticLineChartTypeInfoHelper::get();
+ return StaticLineChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL LineChartType::getPropertySetInfo()
{
- return *StaticLineChartTypeInfo::get();
+ return StaticLineChartTypeInfo();
}
OUString SAL_CALL LineChartType::getImplementationName()
diff --git a/chart2/source/model/template/LineChartType.hxx b/chart2/source/model/template/LineChartType.hxx
index 7be0b6ad3d04..4c44cca9c349 100644
--- a/chart2/source/model/template/LineChartType.hxx
+++ b/chart2/source/model/template/LineChartType.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -36,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit LineChartType( const LineChartType & rOther );
@@ -43,7 +45,7 @@ private:
virtual OUString SAL_CALL getChartType() override;
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
diff --git a/chart2/source/model/template/LineChartTypeTemplate.cxx b/chart2/source/model/template/LineChartTypeTemplate.cxx
index 7989a743529a..e4d347960f18 100644
--- a/chart2/source/model/template/LineChartTypeTemplate.cxx
+++ b/chart2/source/model/template/LineChartTypeTemplate.cxx
@@ -18,10 +18,12 @@
*/
#include "LineChartTypeTemplate.hxx"
-#include <DiagramHelper.hxx>
-#include <servicenames_charttypes.hxx>
+#include "LineChartType.hxx"
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <PropertyHelper.hxx>
+#include <ChartType.hxx>
#include <unonames.hxx>
#include <com/sun/star/chart2/CurveStyle.hpp>
@@ -30,8 +32,7 @@
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -52,89 +53,58 @@ enum
};
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+::chart::tPropertyValueMap& StaticLineChartTypeTemplateDefaults()
{
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_STYLE,
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ []()
+ {
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 );
+
+ // todo: check whether order 3 means polygons of order 3 or 2. (see
+ // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
+}
+
+::cppu::OPropertyArrayHelper& StaticLineChartTypeTemplateInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { CHART_UNONAME_CURVE_STYLE,
PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE,
cppu::UnoType<chart2::CurveStyle>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_RESOLUTION,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_CURVE_RESOLUTION,
PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_SPLINE_ORDER,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_SPLINE_ORDER,
PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
-}
-
-struct StaticLineChartTypeTemplateDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 );
-
- // todo: check whether order 3 means polygons of order 3 or 2. (see
- // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 );
- }
-};
-
-struct StaticLineChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLineChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticLineChartTypeTemplateInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
+ | beans::PropertyAttribute::MAYBEDEFAULT } };
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticLineChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLineChartTypeTemplateInfoHelper_Initializer >
-{
-};
-
-struct StaticLineChartTypeTemplateInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLineChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ return comphelper::containerToSequence( aProperties );
+ }());
+ return aPropHelper;
+}
-struct StaticLineChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLineChartTypeTemplateInfo_Initializer >
+uno::Reference< beans::XPropertySetInfo >& StaticLineChartTypeTemplateInfo()
{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticLineChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -150,7 +120,6 @@ LineChartTypeTemplate::LineChartTypeTemplate(
bool bHasLines /* = true */,
sal_Int32 nDim /* = 2 */ ) :
ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex ),
m_eStackMode( eStackMode ),
m_bHasSymbols( bSymbols ),
m_bHasLines( bHasLines ),
@@ -162,25 +131,27 @@ LineChartTypeTemplate::LineChartTypeTemplate(
LineChartTypeTemplate::~LineChartTypeTemplate()
{}
+
// ____ OPropertySet ____
-uno::Any LineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void LineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticLineChartTypeTemplateDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticLineChartTypeTemplateDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL LineChartTypeTemplate::getInfoHelper()
{
- return *StaticLineChartTypeTemplateInfoHelper::get();
+ return StaticLineChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL LineChartTypeTemplate::getPropertySetInfo()
{
- return *StaticLineChartTypeTemplateInfo::get();
+ return StaticLineChartTypeTemplateInfo();
}
sal_Int32 LineChartTypeTemplate::getDimension() const
@@ -193,12 +164,12 @@ StackMode LineChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ )
return m_eStackMode;
}
-// ____ XChartTypeTemplate ____
-sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
- const uno::Reference< chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties )
+// ____ ChartTypeTemplate ____
+bool LineChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties )
{
- bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
+ bool bResult = ChartTypeTemplate::matchesTemplate2( xDiagram, bAdaptProperties );
// check symbol-style and line-style
// for a template with symbols (or with lines) it is ok, if there is at least one series
@@ -208,8 +179,8 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
bool bSymbolFound = false;
bool bLineFound = false;
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ xDiagram->getDataSeries();
for (auto const& series : aSeriesVec)
{
@@ -217,9 +188,8 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
{
chart2::Symbol aSymbProp;
drawing::LineStyle eLineStyle;
- Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY_THROW);
- bool bCurrentHasSymbol = (xProp->getPropertyValue( "Symbol") >>= aSymbProp) &&
+ bool bCurrentHasSymbol = (series->getPropertyValue( "Symbol") >>= aSymbProp) &&
(aSymbProp.Style != chart2::SymbolStyle_NONE);
if( bCurrentHasSymbol )
@@ -231,7 +201,7 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
break;
}
- bool bCurrentHasLine = (xProp->getPropertyValue( "LineStyle") >>= eLineStyle) &&
+ bool bCurrentHasLine = (series->getPropertyValue( "LineStyle") >>= eLineStyle) &&
( eLineStyle != drawing::LineStyle_NONE );
if( bCurrentHasLine )
@@ -265,12 +235,10 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
{
try
{
- uno::Reference< beans::XPropertySet > xChartTypeProp(
- DiagramHelper::getChartTypeByIndex( xDiagram, 0 ),
- uno::UNO_QUERY_THROW );
- setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_STYLE) );
- setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) );
- setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartTypeProp->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) );
+ rtl::Reference< ChartType > xChartType = xDiagram->getChartTypeByIndex( 0 );
+ setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, xChartType->getPropertyValue(CHART_UNONAME_CURVE_STYLE) );
+ setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartType->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) );
+ setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartType->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) );
}
catch( const uno::Exception & )
{
@@ -281,27 +249,20 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< chart2::XChartType > LineChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+rtl::Reference< ChartType > LineChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
-
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ));
- }
+ xResult = new LineChartType();
+
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ));
}
catch( const uno::Exception & )
{
@@ -311,30 +272,23 @@ Reference< chart2::XChartType > LineChartTypeTemplate::getChartTypeForIndex( sal
return xResult;
}
-Reference< chart2::XChartType > SAL_CALL LineChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > LineChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
+ xResult = new LineChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ));
- }
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ));
}
catch( const uno::Exception & )
{
@@ -344,21 +298,19 @@ Reference< chart2::XChartType > SAL_CALL LineChartTypeTemplate::getChartTypeForN
return xResult;
}
-void SAL_CALL LineChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void LineChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
try
{
- Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
-
- DataSeriesHelper::switchSymbolsOnOrOff( xProp, m_bHasSymbols, nSeriesIndex );
- DataSeriesHelper::switchLinesOnOrOff( xProp, m_bHasLines );
- DataSeriesHelper::makeLinesThickOrThin( xProp, m_nDim==2 );
+ DataSeriesHelper::switchSymbolsOnOrOff( xSeries, m_bHasSymbols, nSeriesIndex );
+ DataSeriesHelper::switchLinesOnOrOff( xSeries, m_bHasLines );
+ DataSeriesHelper::makeLinesThickOrThin( xSeries, m_nDim==2 );
}
catch( const uno::Exception & )
{
diff --git a/chart2/source/model/template/LineChartTypeTemplate.hxx b/chart2/source/model/template/LineChartTypeTemplate.hxx
index 216961fa3fc1..a634fb390aae 100644
--- a/chart2/source/model/template/LineChartTypeTemplate.hxx
+++ b/chart2/source/model/template/LineChartTypeTemplate.hxx
@@ -18,9 +18,8 @@
*/
#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <StackMode.hxx>
#include <comphelper/uno3.hxx>
@@ -28,7 +27,6 @@ namespace chart
{
class LineChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -49,27 +47,26 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ // ____ ChartTypeTemplate ____
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
-
- // ____ ChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual sal_Int32 getDimension() const override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
diff --git a/chart2/source/model/template/NetChartType.cxx b/chart2/source/model/template/NetChartType.cxx
index 95de304b6ae1..cb4512c74884 100644
--- a/chart2/source/model/template/NetChartType.cxx
+++ b/chart2/source/model/template/NetChartType.cxx
@@ -22,6 +22,7 @@
#include <servicenames_charttypes.hxx>
#include <AxisIndexDefines.hxx>
#include <AxisHelper.hxx>
+#include <Axis.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/chart2/AxisType.hpp>
@@ -47,18 +48,18 @@ NetChartType_Base::NetChartType_Base( const NetChartType_Base & rOther ) :
NetChartType_Base::~NetChartType_Base()
{}
-Reference< XCoordinateSystem > SAL_CALL
- NetChartType_Base::createCoordinateSystem( ::sal_Int32 DimensionCount )
+rtl::Reference< ::chart::BaseCoordinateSystem >
+ NetChartType_Base::createCoordinateSystem2( sal_Int32 DimensionCount )
{
if( DimensionCount != 2 )
throw lang::IllegalArgumentException(
"NetChart must be two-dimensional",
static_cast< ::cppu::OWeakObject* >( this ), 0 );
- Reference< XCoordinateSystem > xResult(
- new PolarCoordinateSystem( DimensionCount ));
+ rtl::Reference< PolarCoordinateSystem > xResult =
+ new PolarCoordinateSystem( DimensionCount );
- Reference< XAxis > xAxis( xResult->getAxisByDimension( 0, MAIN_AXIS_INDEX ) );
+ rtl::Reference< Axis > xAxis = xResult->getAxisByDimension2( 0, MAIN_AXIS_INDEX );
if( xAxis.is() )
{
ScaleData aScaleData = xAxis->getScaleData();
@@ -68,7 +69,7 @@ Reference< XCoordinateSystem > SAL_CALL
xAxis->setScaleData( aScaleData );
}
- xAxis = xResult->getAxisByDimension( 1, MAIN_AXIS_INDEX );
+ xAxis = xResult->getAxisByDimension2( 1, MAIN_AXIS_INDEX );
if( xAxis.is() )
{
ScaleData aScaleData = xAxis->getScaleData();
@@ -81,53 +82,39 @@ Reference< XCoordinateSystem > SAL_CALL
}
// ____ OPropertySet ____
-uno::Any NetChartType_Base::GetDefaultValue( sal_Int32 /*nHandle*/ ) const
+void NetChartType_Base::GetDefaultValue( sal_Int32 /*nHandle*/, uno::Any& rAny ) const
{
- return uno::Any();
+ rAny.clear();
}
namespace
{
-struct StaticNetChartTypeInfoHelper_Initializer
+::cppu::OPropertyArrayHelper& StaticNetChartTypeInfoHelper()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper(Sequence< beans::Property >{});
- return &aPropHelper;
- }
-};
-
-struct StaticNetChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticNetChartTypeInfoHelper_Initializer >
-{
-};
-
-struct StaticNetChartTypeInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticNetChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper(Sequence< beans::Property >{});
+ return aPropHelper;
+}
-struct StaticNetChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticNetChartTypeInfo_Initializer >
+uno::Reference< beans::XPropertySetInfo >& StaticNetChartTypeInfo()
{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticNetChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
+}
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL NetChartType_Base::getInfoHelper()
{
- return *StaticNetChartTypeInfoHelper::get();
+ return StaticNetChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL NetChartType_Base::getPropertySetInfo()
{
- return *StaticNetChartTypeInfo::get();
+ return StaticNetChartTypeInfo();
}
NetChartType::NetChartType()
@@ -147,6 +134,11 @@ uno::Reference< util::XCloneable > SAL_CALL NetChartType::createClone()
return uno::Reference< util::XCloneable >( new NetChartType( *this ));
}
+rtl::Reference< ChartType > NetChartType::cloneChartType() const
+{
+ return new NetChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL NetChartType::getChartType()
{
diff --git a/chart2/source/model/template/NetChartType.hxx b/chart2/source/model/template/NetChartType.hxx
index f675af0c94ba..ae414a27c4e1 100644
--- a/chart2/source/model/template/NetChartType.hxx
+++ b/chart2/source/model/template/NetChartType.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -32,18 +32,17 @@ public:
protected:
explicit NetChartType_Base( const NetChartType_Base & rOther );
- // ____ XChartType ____
- virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL
- createCoordinateSystem( ::sal_Int32 DimensionCount ) override;
-
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
+
+ virtual rtl::Reference< ::chart::BaseCoordinateSystem >
+ createCoordinateSystem2( sal_Int32 DimensionCount ) override;
};
class NetChartType final : public NetChartType_Base
@@ -59,6 +58,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit NetChartType( const NetChartType & rOther );
diff --git a/chart2/source/model/template/NetChartTypeTemplate.cxx b/chart2/source/model/template/NetChartTypeTemplate.cxx
index fed499cb3970..0acd07d7b928 100644
--- a/chart2/source/model/template/NetChartTypeTemplate.cxx
+++ b/chart2/source/model/template/NetChartTypeTemplate.cxx
@@ -18,20 +18,21 @@
*/
#include "NetChartTypeTemplate.hxx"
-#include <DiagramHelper.hxx>
-#include <servicenames_charttypes.hxx>
+#include "FilledNetChartType.hxx"
+#include "NetChartType.hxx"
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <ChartType.hxx>
#include <com/sun/star/chart2/SymbolStyle.hpp>
#include <com/sun/star/chart2/Symbol.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
namespace chart
{
@@ -58,21 +59,19 @@ StackMode NetChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ )
return m_eStackMode;
}
-void SAL_CALL NetChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void NetChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
try
{
- Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
-
- DataSeriesHelper::switchSymbolsOnOrOff( xProp, m_bHasSymbols, nSeriesIndex );
- DataSeriesHelper::switchLinesOnOrOff( xProp, m_bHasLines );
- DataSeriesHelper::makeLinesThickOrThin( xProp, true );
+ DataSeriesHelper::switchSymbolsOnOrOff( xSeries, m_bHasSymbols, nSeriesIndex );
+ DataSeriesHelper::switchLinesOnOrOff( xSeries, m_bHasLines );
+ DataSeriesHelper::makeLinesThickOrThin( xSeries, true );
}
catch( const uno::Exception & )
{
@@ -80,15 +79,12 @@ void SAL_CALL NetChartTypeTemplate::applyStyle(
}
}
-// ____ XChartTypeTemplate ____
-sal_Bool SAL_CALL NetChartTypeTemplate::matchesTemplate(
- const Reference< chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties )
+// ____ ChartTypeTemplate ____
+bool NetChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties )
{
- bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
-
- uno::Reference< beans::XPropertySet > xChartTypeProp(
- DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), uno::UNO_QUERY_THROW );
+ bool bResult = ChartTypeTemplate::matchesTemplate2( xDiagram, bAdaptProperties );
if( bResult )
{
@@ -102,8 +98,8 @@ sal_Bool SAL_CALL NetChartTypeTemplate::matchesTemplate(
bool bSymbolFound = false;
bool bLineFound = false;
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ xDiagram->getDataSeries();
for (auto const& series : aSeriesVec)
{
@@ -111,9 +107,8 @@ sal_Bool SAL_CALL NetChartTypeTemplate::matchesTemplate(
{
chart2::Symbol aSymbProp;
drawing::LineStyle eLineStyle;
- Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY_THROW);
- bool bCurrentHasSymbol = (xProp->getPropertyValue( "Symbol") >>= aSymbProp) &&
+ bool bCurrentHasSymbol = (series->getPropertyValue( "Symbol") >>= aSymbProp) &&
(aSymbProp.Style != chart2::SymbolStyle_NONE);
if( bCurrentHasSymbol )
@@ -125,7 +120,7 @@ sal_Bool SAL_CALL NetChartTypeTemplate::matchesTemplate(
break;
}
- bool bCurrentHasLine = (xProp->getPropertyValue( "LineStyle") >>= eLineStyle) &&
+ bool bCurrentHasLine = (series->getPropertyValue( "LineStyle") >>= eLineStyle) &&
( eLineStyle != drawing::LineStyle_NONE );
if( bCurrentHasLine )
@@ -157,34 +152,18 @@ sal_Bool SAL_CALL NetChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< chart2::XChartType > NetChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+rtl::Reference< ChartType > NetChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
{
- Reference< chart2::XChartType > xResult;
-
- try
- {
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
-
- if( m_bHasFilledArea )
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET ), uno::UNO_QUERY_THROW );
- else
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_NET ), uno::UNO_QUERY_THROW );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
- return xResult;
+ if( m_bHasFilledArea )
+ return new FilledNetChartType();
+ else
+ return new NetChartType();
}
-Reference< chart2::XChartType > SAL_CALL NetChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > NetChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult( getChartTypeForIndex( 0 ) );
+ rtl::Reference< ChartType > xResult( getChartTypeForIndex( 0 ) );
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
return xResult;
}
diff --git a/chart2/source/model/template/NetChartTypeTemplate.hxx b/chart2/source/model/template/NetChartTypeTemplate.hxx
index deef73ff2a48..b1f5ac9dbd83 100644
--- a/chart2/source/model/template/NetChartTypeTemplate.hxx
+++ b/chart2/source/model/template/NetChartTypeTemplate.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <StackMode.hxx>
namespace chart
@@ -38,20 +38,21 @@ public:
virtual ~NetChartTypeTemplate() override;
protected:
- // ____ XChartTypeTemplate ____
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ // ____ ChartTypeTemplate ____
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
// ____ ChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
diff --git a/chart2/source/model/template/PieChartType.cxx b/chart2/source/model/template/PieChartType.cxx
index eb7c10a5e834..a835f6357f6c 100644
--- a/chart2/source/model/template/PieChartType.cxx
+++ b/chart2/source/model/template/PieChartType.cxx
@@ -20,12 +20,14 @@
#include "PieChartType.hxx"
#include <PropertyHelper.hxx>
#include <PolarCoordinateSystem.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
#include <servicenames_charttypes.hxx>
#include <AxisIndexDefines.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/chart2/AxisType.hpp>
+#include <com/sun/star/chart2/PieChartSubType.hpp>
using namespace ::com::sun::star;
@@ -36,85 +38,54 @@ using ::com::sun::star::uno::Reference;
namespace
{
-enum
+::chart::tPropertyValueMap& StaticPieChartTypeDefaults()
{
- PROP_PIECHARTTYPE_USE_RINGS,
- PROP_PIECHARTTYPE_3DRELATIVEHEIGHT
-};
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ []()
+ {
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, ::chart::PROP_PIECHARTTYPE_USE_RINGS, false );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, ::chart::PROP_PIECHARTTYPE_3DRELATIVEHEIGHT, 100 );
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, ::chart::PROP_PIECHARTTYPE_SUBTYPE, chart2::PieChartSubType_NONE );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
+}
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+::cppu::OPropertyArrayHelper& StaticPieChartTypeInfoHelper()
{
- rOutProperties.emplace_back( "UseRings",
- PROP_PIECHARTTYPE_USE_RINGS,
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { "UseRings",
+ ::chart::PROP_PIECHARTTYPE_USE_RINGS,
cppu::UnoType<bool>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( "3DRelativeHeight",
- PROP_PIECHARTTYPE_3DRELATIVEHEIGHT,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { "3DRelativeHeight",
+ ::chart::PROP_PIECHARTTYPE_3DRELATIVEHEIGHT,
cppu::UnoType<sal_Int32>::get(),
- beans::PropertyAttribute::MAYBEVOID );
+ beans::PropertyAttribute::MAYBEVOID },
+ { "SubPieType",
+ ::chart::PROP_PIECHARTTYPE_SUBTYPE,
+ cppu::UnoType<chart2::PieChartSubType>::get(),
+ beans::PropertyAttribute::MAYBEDEFAULT }
+ };
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }());
+ return aPropHelper;
}
-struct StaticPieChartTypeDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_PIECHARTTYPE_USE_RINGS, false );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_PIECHARTTYPE_3DRELATIVEHEIGHT, 100 );
- }
-};
-
-struct StaticPieChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPieChartTypeDefaults_Initializer >
-{
-};
-
-struct StaticPieChartTypeInfoHelper_Initializer
+uno::Reference< beans::XPropertySetInfo >& StaticPieChartTypeInfo()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static 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 StaticPieChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticPieChartTypeInfoHelper_Initializer >
-{
-};
-
-struct StaticPieChartTypeInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPieChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticPieChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPieChartTypeInfo_Initializer >
-{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo( StaticPieChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -139,21 +110,26 @@ uno::Reference< util::XCloneable > SAL_CALL PieChartType::createClone()
return uno::Reference< util::XCloneable >( new PieChartType( *this ));
}
+rtl::Reference< ChartType > PieChartType::cloneChartType() const
+{
+ return new PieChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL PieChartType::getChartType()
{
return CHART2_SERVICE_NAME_CHARTTYPE_PIE;
}
-Reference< chart2::XCoordinateSystem > SAL_CALL
- PieChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
+rtl::Reference< ::chart::BaseCoordinateSystem >
+ PieChartType::createCoordinateSystem2( sal_Int32 DimensionCount )
{
- Reference< chart2::XCoordinateSystem > xResult(
- new PolarCoordinateSystem( DimensionCount ));
+ rtl::Reference< PolarCoordinateSystem > xResult =
+ new PolarCoordinateSystem( DimensionCount );
for( sal_Int32 i=0; i<DimensionCount; ++i )
{
- Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
+ rtl::Reference< Axis > xAxis = xResult->getAxisByDimension2( i, MAIN_AXIS_INDEX );
if( !xAxis.is() )
{
OSL_FAIL("a created coordinate system should have an axis for each dimension");
@@ -186,25 +162,26 @@ uno::Sequence< OUString > PieChartType::getSupportedPropertyRoles()
}
// ____ OPropertySet ____
-uno::Any PieChartType::GetDefaultValue( sal_Int32 nHandle ) const
+void PieChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticPieChartTypeDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticPieChartTypeDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL PieChartType::getInfoHelper()
{
- return *StaticPieChartTypeInfoHelper::get();
+ return StaticPieChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL PieChartType::getPropertySetInfo()
{
- return *StaticPieChartTypeInfo::get();
+ return StaticPieChartTypeInfo();
}
OUString SAL_CALL PieChartType::getImplementationName()
diff --git a/chart2/source/model/template/PieChartType.hxx b/chart2/source/model/template/PieChartType.hxx
index f00793119507..083bd78facd3 100644
--- a/chart2/source/model/template/PieChartType.hxx
+++ b/chart2/source/model/template/PieChartType.hxx
@@ -18,7 +18,8 @@
*/
#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
+#include <com/sun/star/chart2/PieChartSubType.hpp>
namespace chart
{
@@ -36,18 +37,18 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit PieChartType( const PieChartType & rOther );
// ____ XChartType ____
virtual OUString SAL_CALL getChartType() override;
- virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL
- createCoordinateSystem( ::sal_Int32 DimensionCount ) override;
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedPropertyRoles() override;
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
// ____ OPropertySet ____
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -58,6 +59,9 @@ private:
// ____ XCloneable ____
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+
+ virtual rtl::Reference< ::chart::BaseCoordinateSystem >
+ createCoordinateSystem2( sal_Int32 DimensionCount ) override;
};
} // namespace chart
diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx
index 0848f0e98239..df97c53aaef9 100644
--- a/chart2/source/model/template/PieChartTypeTemplate.cxx
+++ b/chart2/source/model/template/PieChartTypeTemplate.cxx
@@ -18,28 +18,29 @@
*/
#include "PieChartTypeTemplate.hxx"
+#include "PieChartType.hxx"
+#include <BaseCoordinateSystem.hxx>
#include <CommonConverters.hxx>
-#include <DiagramHelper.hxx>
-#include <servicenames_charttypes.hxx>
+#include <ChartType.hxx>
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
+#include <DataSeriesProperties.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
-#include <ThreeDHelper.hxx>
#include <PropertyHelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <officecfg/Office/Compatibility.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <rtl/math.hxx>
#include <algorithm>
using namespace ::com::sun::star;
+using namespace ::chart::DataSeriesProperties;
using ::com::sun::star::beans::Property;
using ::com::sun::star::uno::Sequence;
@@ -53,95 +54,72 @@ enum
PROP_PIE_TEMPLATE_DEFAULT_OFFSET,
PROP_PIE_TEMPLATE_OFFSET_MODE,
PROP_PIE_TEMPLATE_DIMENSION,
- PROP_PIE_TEMPLATE_USE_RINGS
+ PROP_PIE_TEMPLATE_USE_RINGS,
+ PROP_PIE_TEMPLATE_SUB_PIE_TYPE
};
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+::chart::tPropertyValueMap& StaticPieChartTypeTemplateDefaults()
{
- rOutProperties.emplace_back( "OffsetMode",
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ []{
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_PIE_TEMPLATE_OFFSET_MODE, chart2::PieChartOffsetMode_NONE );
+ ::chart::PropertyHelper::setPropertyValueDefault< double >( aOutMap, PROP_PIE_TEMPLATE_DEFAULT_OFFSET, 0.5 );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_PIE_TEMPLATE_DIMENSION, 2 );
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_PIE_TEMPLATE_USE_RINGS, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_PIE_TEMPLATE_SUB_PIE_TYPE, chart2::PieChartSubType_NONE );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
+}
+
+::cppu::OPropertyArrayHelper& StaticPieChartTypeTemplateInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { "OffsetMode",
PROP_PIE_TEMPLATE_OFFSET_MODE,
cppu::UnoType<chart2::PieChartOffsetMode>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( "DefaultOffset",
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { "DefaultOffset",
PROP_PIE_TEMPLATE_DEFAULT_OFFSET,
cppu::UnoType<double>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( "Dimension",
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { "Dimension",
PROP_PIE_TEMPLATE_DIMENSION,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( "UseRings",
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { "UseRings",
PROP_PIE_TEMPLATE_USE_RINGS,
cppu::UnoType<bool>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
-}
-
-struct StaticPieChartTypeTemplateDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_PIE_TEMPLATE_OFFSET_MODE, chart2::PieChartOffsetMode_NONE );
- ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_PIE_TEMPLATE_DEFAULT_OFFSET, 0.5 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_PIE_TEMPLATE_DIMENSION, 2 );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_PIE_TEMPLATE_USE_RINGS, false );
- }
-};
-
-struct StaticPieChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPieChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticPieChartTypeTemplateInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static uno::Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { "SubPieType",
+ PROP_PIE_TEMPLATE_SUB_PIE_TYPE,
+ cppu::UnoType<chart2::PieChartSubType>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT }
+ };
- return comphelper::containerToSequence( aProperties );
- }
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-};
-
-struct StaticPieChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticPieChartTypeTemplateInfoHelper_Initializer >
-{
-};
-
-struct StaticPieChartTypeTemplateInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPieChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ return comphelper::containerToSequence( aProperties );
+ }() );
+ return aPropHelper;
+}
-struct StaticPieChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPieChartTypeTemplateInfo_Initializer >
+uno::Reference< beans::XPropertySetInfo >& StaticPieChartTypeTemplateInfo()
{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticPieChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -153,38 +131,40 @@ PieChartTypeTemplate::PieChartTypeTemplate(
uno::XComponentContext > const & xContext,
const OUString & rServiceName,
chart2::PieChartOffsetMode eMode,
- bool bRings /* = false */,
+ bool bRings,
+ chart2::PieChartSubType eSubType,
sal_Int32 nDim /* = 2 */ ) :
- ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex )
+ ChartTypeTemplate( xContext, rServiceName )
{
setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_OFFSET_MODE, uno::Any( eMode ));
setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_DIMENSION, uno::Any( nDim ));
setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_USE_RINGS, uno::Any( bRings ));
+ setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_SUB_PIE_TYPE, uno::Any( eSubType ));
}
PieChartTypeTemplate::~PieChartTypeTemplate()
{}
// ____ OPropertySet ____
-uno::Any PieChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void PieChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticPieChartTypeTemplateDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticPieChartTypeTemplateDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL PieChartTypeTemplate::getInfoHelper()
{
- return *StaticPieChartTypeTemplateInfoHelper::get();
+ return StaticPieChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL PieChartTypeTemplate::getPropertySetInfo()
{
- return *StaticPieChartTypeTemplateInfo::get();
+ return StaticPieChartTypeTemplateInfo();
}
// ____ ChartTypeTemplate ____
@@ -211,14 +191,14 @@ sal_Int32 PieChartTypeTemplate::getAxisCountByDimension( sal_Int32 /*nDimension*
}
void PieChartTypeTemplate::adaptAxes(
- const uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > & /*rCoordSys*/ )
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & /*rCoordSys*/ )
{
// hide existing axes
//hhhh todo
}
void PieChartTypeTemplate::adaptScales(
- const Sequence< Reference< chart2::XCoordinateSystem > > & aCooSysSeq,
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & aCooSysSeq,
const Reference< chart2::data::XLabeledDataSequence > & xCategories //@todo: in future there may be more than one sequence of categories (e.g. charttype with categories at x and y axis )
)
{
@@ -227,12 +207,12 @@ void PieChartTypeTemplate::adaptScales(
//remove explicit scalings from radius axis
//and ensure correct orientation of scales for donuts
- for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq )
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : aCooSysSeq )
{
try
{
- Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 1 /*nDimensionIndex*/,0 /*nAxisIndex*/
- , coords ) );
+ rtl::Reference< Axis > xAxis = AxisHelper::getAxis( 1 /*nDimensionIndex*/,0 /*nAxisIndex*/
+ , coords );
if( xAxis.is() )
{
chart2::ScaleData aScaleData( xAxis->getScaleData() );
@@ -271,35 +251,26 @@ void PieChartTypeTemplate::adaptScales(
}
void PieChartTypeTemplate::createChartTypes(
- const Sequence< Sequence< Reference< chart2::XDataSeries > > > & aSeriesSeq,
- const Sequence< Reference< chart2::XCoordinateSystem > > & rCoordSys,
- const Sequence< Reference< chart2::XChartType > >& /* aOldChartTypesSeq */ )
+ const std::vector< std::vector< rtl::Reference< DataSeries > > > & aSeriesSeq,
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > >& /* aOldChartTypesSeq */ )
{
- if( ! rCoordSys.hasElements() ||
- ! rCoordSys[0].is() )
+ if( rCoordSys.empty() )
return;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
-
- Reference< chart2::XChartType > xCT(
- xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_PIE ), uno::UNO_QUERY_THROW );
- Reference< beans::XPropertySet > xCTProp( xCT, uno::UNO_QUERY );
- if( xCTProp.is())
+ rtl::Reference< ChartType > xCT = new PieChartType();
+ xCT->setFastPropertyValue(
+ PROP_PIECHARTTYPE_USE_RINGS, getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS )); // "UseRings"
+ xCT->setFastPropertyValue(
+ PROP_PIECHARTTYPE_SUBTYPE, getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE )); // "SubType"
+ rCoordSys[0]->setChartTypes( std::vector{xCT} );
+
+ if( !aSeriesSeq.empty() )
{
- xCTProp->setPropertyValue(
- "UseRings", getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ));
- }
- Reference< chart2::XChartTypeContainer > xCTCnt( rCoordSys[0], uno::UNO_QUERY_THROW );
- xCTCnt->setChartTypes( Sequence< Reference< chart2::XChartType > >( &xCT, 1 ));
-
- if( aSeriesSeq.hasElements() )
- {
- Reference< chart2::XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- Sequence< Reference< chart2::XDataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq ));
- xDSCnt->setDataSeries( aFlatSeriesSeq );
+ std::vector< rtl::Reference< DataSeries > > aFlatSeriesSeq = FlattenSequence( aSeriesSeq );
+ xCT->setDataSeries( aFlatSeriesSeq );
DataSeriesHelper::setStackModeAtSeries(
aFlatSeriesSeq, rCoordSys[0], getStackMode( 0 ));
@@ -312,16 +283,18 @@ void PieChartTypeTemplate::createChartTypes(
}
// ____ XChartTypeTemplate ____
-sal_Bool SAL_CALL PieChartTypeTemplate::matchesTemplate(
- const uno::Reference< chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties )
+bool PieChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties )
{
- bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
+ bool bResult = ChartTypeTemplate::matchesTemplate2( xDiagram, bAdaptProperties );
bool bTemplateUsesRings = false;
getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ) >>= bTemplateUsesRings;
chart2::PieChartOffsetMode ePieOffsetMode;
getFastPropertyValue( PROP_PIE_TEMPLATE_OFFSET_MODE ) >>= ePieOffsetMode;
+ chart2::PieChartSubType eTemplateSubType;
+ getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE ) >>= eTemplateSubType;
//check offset-mode
if( bResult )
@@ -332,8 +305,8 @@ sal_Bool SAL_CALL PieChartTypeTemplate::matchesTemplate(
bool bAllOffsetsEqual = true;
sal_Int32 nOuterSeriesIndex = 0;
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ xDiagram->getDataSeries();
//tdf#108067 The outer series is the last series in OOXML-heavy environments
if( !officecfg::Office::Compatibility::View::ReverseXAxisOrientationDoughnutChart::get() )
@@ -343,13 +316,12 @@ sal_Bool SAL_CALL PieChartTypeTemplate::matchesTemplate(
if( !aSeriesVec.empty() )
{
//@todo in future this will depend on Orientation of the radius axis scale
- Reference< chart2::XDataSeries > xSeries( aSeriesVec[nOuterSeriesIndex] );
- Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
- xProp->getPropertyValue( "Offset") >>= fOffset;
+ rtl::Reference< DataSeries > xSeries( aSeriesVec[nOuterSeriesIndex] );
+ xSeries->getPropertyValue( "Offset") >>= fOffset;
- //get AttributedDataPoints
+ // "AttributedDataPoints"
uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- if( xProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
+ if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList )
{
for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
{
@@ -357,7 +329,7 @@ sal_Bool SAL_CALL PieChartTypeTemplate::matchesTemplate(
if(xPointProp.is())
{
double fPointOffset=0.0;
- if( xProp->getPropertyValue( "Offset") >>= fPointOffset )
+ if( xSeries->getPropertyValue( "Offset") >>= fPointOffset )
{
if( ! ::rtl::math::approxEqual( fPointOffset, fOffset ) )
{
@@ -390,35 +362,37 @@ sal_Bool SAL_CALL PieChartTypeTemplate::matchesTemplate(
//check UseRings
if( bResult )
{
- uno::Reference< beans::XPropertySet > xCTProp(
- DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), uno::UNO_QUERY_THROW );
+ rtl::Reference< ChartType > xCTProp = xDiagram->getChartTypeByIndex( 0 );
bool bUseRings = false;
- if( xCTProp->getPropertyValue( "UseRings") >>= bUseRings )
+ if( xCTProp->getFastPropertyValue( PROP_PIECHARTTYPE_USE_RINGS ) >>= bUseRings ) // "UseRings"
{
bResult = ( bTemplateUsesRings == bUseRings );
}
}
+ if( bResult )
+ {
+ rtl::Reference< ChartType > xCTProp = xDiagram->getChartTypeByIndex( 0 );
+ chart2::PieChartSubType eSubType = chart2::PieChartSubType_NONE;
+ if( xCTProp->getFastPropertyValue( PROP_PIECHARTTYPE_SUBTYPE ) >>= eSubType )
+ {
+ bResult = ( eTemplateSubType == eSubType );
+ }
+ }
return bResult;
}
-Reference< chart2::XChartType > PieChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+rtl::Reference< ChartType > PieChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_PIE ), uno::UNO_QUERY_THROW );
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- "UseRings", getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ));
- }
-
+ xResult = new PieChartType();
+ xResult->setFastPropertyValue(
+ PROP_PIECHARTTYPE_USE_RINGS, getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS )); // "UseRings"
+ xResult->setFastPropertyValue(
+ PROP_PIECHARTTYPE_SUBTYPE, getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE ));
}
catch( const uno::Exception & )
{
@@ -428,25 +402,19 @@ Reference< chart2::XChartType > PieChartTypeTemplate::getChartTypeForIndex( sal_
return xResult;
}
-Reference< chart2::XChartType > SAL_CALL PieChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > PieChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_PIE ), uno::UNO_QUERY_THROW );
+ xResult = new PieChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- "UseRings", getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ));
- }
-
+ xResult->setFastPropertyValue(
+ PROP_PIECHARTTYPE_USE_RINGS, getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS )); // "UseRings"
+ xResult->setFastPropertyValue(
+ PROP_PIECHARTTYPE_SUBTYPE, getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE ));
}
catch( const uno::Exception & )
{
@@ -456,18 +424,16 @@ Reference< chart2::XChartType > SAL_CALL PieChartTypeTemplate::getChartTypeForNe
return xResult;
}
-void SAL_CALL PieChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void PieChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
try
{
- uno::Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
-
bool bTemplateUsesRings = false;
sal_Int32 nOuterSeriesIndex = 0;
getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ) >>= bTemplateUsesRings;
@@ -478,7 +444,7 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
if( nSeriesIndex == nOuterSeriesIndex ) //@todo in future this will depend on Orientation of the radius axis scale
{
- static const OUStringLiteral aOffsetPropName( u"Offset" );
+ static constexpr OUString aOffsetPropName( u"Offset"_ustr );
// get offset mode
chart2::PieChartOffsetMode ePieOffsetMode;
getFastPropertyValue( PROP_PIE_TEMPLATE_OFFSET_MODE ) >>= ePieOffsetMode;
@@ -489,7 +455,8 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
double fOffsetToSet = fDefaultOffset;
uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- xProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList;
+ // "AttributedDataPoints"
+ xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList;
// determine whether to set the new offset
bool bSetOffset = ( ePieOffsetMode == chart2::PieChartOffsetMode_ALL_EXPLODED );
@@ -499,12 +466,12 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
// set offset to 0 if the offset was exactly "all exploded"
// before (individual offsets are kept)
double fOffset = 0.0;
- if( (xProp->getPropertyValue( aOffsetPropName ) >>= fOffset) &&
+ if( (xSeries->getPropertyValue( aOffsetPropName ) >>= fOffset) &&
::rtl::math::approxEqual( fOffset, fDefaultOffset ))
{
fOffsetToSet = 0.0;
bSetOffset = true;
- for( auto const & pointIndex : std::as_const(aAttributedDataPointIndexList) )
+ for (auto const& pointIndex : aAttributedDataPointIndexList)
{
uno::Reference< beans::XPropertySet > xPointProp(
xSeries->getDataPointByIndex( pointIndex ));
@@ -526,10 +493,10 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
if( bSetOffset )
{
// set the offset to the series and to the attributed data points
- xProp->setPropertyValue( aOffsetPropName, uno::Any( fOffsetToSet ));
+ xSeries->setPropertyValue( aOffsetPropName, uno::Any( fOffsetToSet ));
// remove hard attributes from data points
- for( auto const & pointIndex : std::as_const(aAttributedDataPointIndexList) )
+ for (auto const& pointIndex : aAttributedDataPointIndexList)
{
uno::Reference< beans::XPropertyState > xPointState(
xSeries->getDataPointByIndex( pointIndex ), uno::UNO_QUERY );
@@ -543,7 +510,7 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
// vary colors by point
- xProp->setPropertyValue( "VaryColorsByPoint", uno::Any( true ));
+ xSeries->setFastPropertyValue( PROP_DATASERIES_VARY_COLORS_BY_POINT, uno::Any( true )); // "VaryColorsByPoint"
}
catch( const uno::Exception & )
{
@@ -551,22 +518,21 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
}
}
-void SAL_CALL PieChartTypeTemplate::resetStyles( const Reference< chart2::XDiagram >& xDiagram )
+void PieChartTypeTemplate::resetStyles2( const rtl::Reference< ::chart::Diagram >& xDiagram )
{
// reset axes and grids
- Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY );
- if( xCooSysCnt.is())
+ if( xDiagram.is())
{
- const Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > aCooSysSeq( xDiagram->getBaseCoordinateSystems());
ChartTypeTemplate::createAxes( aCooSysSeq );
//reset scale orientation
- for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq )
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : aCooSysSeq )
{
try
{
- Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 0 /*nDimensionIndex*/,0 /*nAxisIndex*/
- , coords ) );
+ rtl::Reference< Axis > xAxis = AxisHelper::getAxis( 0 /*nDimensionIndex*/,0 /*nAxisIndex*/
+ , coords );
if( xAxis.is() )
{
chart2::ScaleData aScaleData( xAxis->getScaleData() );
@@ -589,40 +555,34 @@ void SAL_CALL PieChartTypeTemplate::resetStyles( const Reference< chart2::XDiagr
}
}
- ChartTypeTemplate::resetStyles( xDiagram );
+ ChartTypeTemplate::resetStyles2( xDiagram );
// vary colors by point,
// line style
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ xDiagram->getDataSeries();
uno::Any aLineStyleAny( drawing::LineStyle_NONE );
for (auto const& series : aSeriesVec)
{
- Reference< beans::XPropertyState > xState(series, uno::UNO_QUERY);
- if( xState.is())
+ series->setPropertyToDefault( "VaryColorsByPoint");
+ if( series->getPropertyValue( "BorderStyle") == aLineStyleAny )
{
- xState->setPropertyToDefault( "VaryColorsByPoint");
- Reference< beans::XPropertySet > xProp( xState, uno::UNO_QUERY );
- if( xProp.is() &&
- xProp->getPropertyValue( "BorderStyle") == aLineStyleAny )
- {
- xState->setPropertyToDefault( "BorderStyle");
- }
+ series->setPropertyToDefault( "BorderStyle");
}
}
//reset scene properties
- ThreeDHelper::setDefaultRotation( uno::Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY ), false );
+ xDiagram->setDefaultRotation( false );
}
// ____ XChartTypeTemplate ____
-void PieChartTypeTemplate::adaptDiagram( const uno::Reference< chart2::XDiagram >& xDiagram )
+void PieChartTypeTemplate::adaptDiagram( const rtl::Reference< ::chart::Diagram >& xDiagram )
{
if( !xDiagram.is() )
return;
//different default for scene geometry:
- ThreeDHelper::setDefaultRotation( uno::Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY ), true );
+ xDiagram->setDefaultRotation( true );
}
IMPLEMENT_FORWARD_XINTERFACE2( PieChartTypeTemplate, ChartTypeTemplate, OPropertySet )
diff --git a/chart2/source/model/template/PieChartTypeTemplate.hxx b/chart2/source/model/template/PieChartTypeTemplate.hxx
index 863fb2219705..b603392e7009 100644
--- a/chart2/source/model/template/PieChartTypeTemplate.hxx
+++ b/chart2/source/model/template/PieChartTypeTemplate.hxx
@@ -19,17 +19,16 @@
#pragma once
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <com/sun/star/chart2/PieChartOffsetMode.hpp>
+#include <com/sun/star/chart2/PieChartSubType.hpp>
namespace chart
{
class PieChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -39,6 +38,7 @@ public:
const OUString & rServiceName,
css::chart2::PieChartOffsetMode eMode,
bool bRings,
+ css::chart2::PieChartSubType eSubType,
sal_Int32 nDim = 2 );
virtual ~PieChartTypeTemplate() override;
@@ -49,57 +49,55 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence<
- css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ // ____ ChartTypeTemplate ____
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
- virtual void SAL_CALL resetStyles(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override;
+ virtual void resetStyles2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram ) override;
// ____ ChartTypeTemplate ____
virtual sal_Int32 getDimension() const override;
virtual void adaptDiagram(
- const css::uno::Reference< css::chart2::XDiagram > & xDiagram ) override;
+ const rtl::Reference< ::chart::Diagram > & xDiagram ) override;
virtual sal_Int32 getAxisCountByDimension( sal_Int32 nDimension ) override;
virtual void adaptAxes(
- const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & rCoordSys ) override;
+ const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > & rCoordSys ) override;
virtual void adaptScales(
- const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & aCooSysSeq,
+ const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > & aCooSysSeq,
const css::uno::Reference< css::chart2::data::XLabeledDataSequence > & xCategories ) override;
virtual void createChartTypes(
- const css::uno::Sequence<
- css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XDataSeries > > >& aSeriesSeq,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XCoordinateSystem > > & rCoordSys,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XChartType > > & aOldChartTypesSeq
+ const std::vector<
+ std::vector<
+ rtl::Reference<
+ ::chart::DataSeries > > >& aSeriesSeq,
+ const std::vector<
+ rtl::Reference<
+ ::chart::BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq
) override;
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
};
diff --git a/chart2/source/model/template/ScatterChartType.cxx b/chart2/source/model/template/ScatterChartType.cxx
index a68c9eaee1cf..cee026913b7f 100644
--- a/chart2/source/model/template/ScatterChartType.cxx
+++ b/chart2/source/model/template/ScatterChartType.cxx
@@ -21,6 +21,7 @@
#include <PropertyHelper.hxx>
#include <servicenames_charttypes.hxx>
#include <CartesianCoordinateSystem.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
#include <AxisIndexDefines.hxx>
#include <unonames.hxx>
@@ -46,90 +47,57 @@ enum
PROP_SCATTERCHARTTYPE_SPLINE_ORDER
};
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+::chart::tPropertyValueMap& StaticScatterChartTypeDefaults()
{
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_STYLE,
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ []()
+ {
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_SCATTERCHARTTYPE_CURVE_STYLE, chart2::CurveStyle_LINES );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION, 20 );
+
+ // todo: check whether order 3 means polygons of order 3 or 2. (see
+ // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_SCATTERCHARTTYPE_SPLINE_ORDER, 3 );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
+}
+
+::cppu::OPropertyArrayHelper& StaticScatterChartTypeInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { CHART_UNONAME_CURVE_STYLE,
PROP_SCATTERCHARTTYPE_CURVE_STYLE,
cppu::UnoType<chart2::CurveStyle>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
-
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_RESOLUTION,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_CURVE_RESOLUTION,
PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_SPLINE_ORDER,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_SPLINE_ORDER,
PROP_SCATTERCHARTTYPE_SPLINE_ORDER,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
+ | beans::PropertyAttribute::MAYBEDEFAULT } };
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+ return comphelper::containerToSequence( aProperties );
+ }() );
+ return aPropHelper;
}
-struct StaticScatterChartTypeDefaults_Initializer
+const uno::Reference< beans::XPropertySetInfo >& StaticScatterChartTypeInfo()
{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCATTERCHARTTYPE_CURVE_STYLE, chart2::CurveStyle_LINES );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION, 20 );
-
- // todo: check whether order 3 means polygons of order 3 or 2. (see
- // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_SPLINE_ORDER, 3 );
- }
-};
-
-struct StaticScatterChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticScatterChartTypeDefaults_Initializer >
-{
-};
-
-struct StaticScatterChartTypeInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static 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 StaticScatterChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticScatterChartTypeInfoHelper_Initializer >
-{
-};
-
-struct StaticScatterChartTypeInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticScatterChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticScatterChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticScatterChartTypeInfo_Initializer >
-{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticScatterChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -154,16 +122,21 @@ uno::Reference< util::XCloneable > SAL_CALL ScatterChartType::createClone()
return uno::Reference< util::XCloneable >( new ScatterChartType( *this ));
}
+rtl::Reference< ChartType > ScatterChartType::cloneChartType() const
+{
+ return new ScatterChartType( *this );
+}
+
// ____ XChartType ____
-Reference< chart2::XCoordinateSystem > SAL_CALL
- ScatterChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
+rtl::Reference< ::chart::BaseCoordinateSystem >
+ ScatterChartType::createCoordinateSystem2( sal_Int32 DimensionCount )
{
- Reference< chart2::XCoordinateSystem > xResult(
- new CartesianCoordinateSystem( DimensionCount ));
+ rtl::Reference< CartesianCoordinateSystem > xResult =
+ new CartesianCoordinateSystem( DimensionCount );
for( sal_Int32 i=0; i<DimensionCount; ++i )
{
- Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
+ rtl::Reference< Axis > xAxis = xResult->getAxisByDimension2( i, MAIN_AXIS_INDEX );
if( !xAxis.is() )
{
OSL_FAIL("a created coordinate system should have an axis for each dimension");
@@ -196,25 +169,26 @@ uno::Sequence< OUString > SAL_CALL ScatterChartType::getSupportedMandatoryRoles(
}
// ____ OPropertySet ____
-uno::Any ScatterChartType::GetDefaultValue( sal_Int32 nHandle ) const
+void ScatterChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticScatterChartTypeDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticScatterChartTypeDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL ScatterChartType::getInfoHelper()
{
- return *StaticScatterChartTypeInfoHelper::get();
+ return StaticScatterChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL ScatterChartType::getPropertySetInfo()
{
- return *StaticScatterChartTypeInfo::get();
+ return StaticScatterChartTypeInfo();
}
OUString SAL_CALL ScatterChartType::getImplementationName()
diff --git a/chart2/source/model/template/ScatterChartType.hxx b/chart2/source/model/template/ScatterChartType.hxx
index faefa3a872fe..f490c108ca56 100644
--- a/chart2/source/model/template/ScatterChartType.hxx
+++ b/chart2/source/model/template/ScatterChartType.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -36,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit ScatterChartType( const ScatterChartType & rOther );
@@ -43,11 +45,9 @@ private:
virtual OUString SAL_CALL getChartType() override;
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedMandatoryRoles() override;
- virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL
- createCoordinateSystem( ::sal_Int32 DimensionCount ) override;
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
// ____ OPropertySet ____
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -58,6 +58,9 @@ private:
// ____ XCloneable ____
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+
+ virtual rtl::Reference< ::chart::BaseCoordinateSystem >
+ createCoordinateSystem2( sal_Int32 DimensionCount ) override;
};
} // namespace chart
diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.cxx b/chart2/source/model/template/ScatterChartTypeTemplate.cxx
index e0dc1cd1183a..3457bfa00126 100644
--- a/chart2/source/model/template/ScatterChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ScatterChartTypeTemplate.cxx
@@ -18,9 +18,11 @@
*/
#include "ScatterChartTypeTemplate.hxx"
+#include "ScatterChartType.hxx"
#include "XYDataInterpreter.hxx"
-#include <DiagramHelper.hxx>
-#include <servicenames_charttypes.hxx>
+#include <ChartType.hxx>
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <PropertyHelper.hxx>
#include <unonames.hxx>
@@ -31,8 +33,7 @@
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -53,89 +54,58 @@ enum
};
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+const ::chart::tPropertyValueMap& StaticScatterChartTypeTemplateDefaults()
{
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_STYLE,
- PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE,
- cppu::UnoType<chart2::CurveStyle>::get(),
- beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_RESOLUTION,
- PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION,
- cppu::UnoType<sal_Int32>::get(),
- beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_SPLINE_ORDER,
- PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER,
- cppu::UnoType<sal_Int32>::get(),
- beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
+ static const ::chart::tPropertyValueMap aStaticDefaults =
+ []()
+ {
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 );
+
+ // todo: check whether order 3 means polygons of order 3 or 2. (see
+ // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
}
-struct StaticScatterChartTypeTemplateDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 );
-
- // todo: check whether order 3 means polygons of order 3 or 2. (see
- // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 );
- }
-};
-
-struct StaticScatterChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticScatterChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticScatterChartTypeTemplateInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static 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 StaticScatterChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticScatterChartTypeTemplateInfoHelper_Initializer >
-{
-};
-struct StaticScatterChartTypeTemplateInfo_Initializer
+::cppu::OPropertyArrayHelper& StaticScatterChartTypeTemplateInfoHelper()
{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticScatterChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { CHART_UNONAME_CURVE_STYLE,
+ PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE,
+ cppu::UnoType<chart2::CurveStyle>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_CURVE_RESOLUTION,
+ PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_SPLINE_ORDER,
+ PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT } };
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+ return comphelper::containerToSequence( aProperties );
+ }() );
+ return aPropHelper;
+}
-struct StaticScatterChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticScatterChartTypeTemplateInfo_Initializer >
+const uno::Reference< beans::XPropertySetInfo >& StaticScatterChartTypeTemplateInfo()
{
-};
+ static const uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticScatterChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -150,7 +120,6 @@ ScatterChartTypeTemplate::ScatterChartTypeTemplate(
bool bHasLines /* = true */,
sal_Int32 nDim /* = 2 */ ) :
ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex ),
m_bHasSymbols( bSymbols ),
m_bHasLines( bHasLines ),
m_nDim( nDim )
@@ -163,24 +132,25 @@ ScatterChartTypeTemplate::~ScatterChartTypeTemplate()
{}
// ____ OPropertySet ____
-uno::Any ScatterChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void ScatterChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticScatterChartTypeTemplateDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticScatterChartTypeTemplateDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL ScatterChartTypeTemplate::getInfoHelper()
{
- return *StaticScatterChartTypeTemplateInfoHelper::get();
+ return StaticScatterChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL ScatterChartTypeTemplate::getPropertySetInfo()
{
- return *StaticScatterChartTypeTemplateInfo::get();
+ return StaticScatterChartTypeTemplateInfo();
}
sal_Int32 ScatterChartTypeTemplate::getDimension() const
@@ -195,21 +165,19 @@ StackMode ScatterChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex *
return StackMode::NONE;
}
-void SAL_CALL ScatterChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void ScatterChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
try
{
- Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
-
- DataSeriesHelper::switchSymbolsOnOrOff( xProp, m_bHasSymbols, nSeriesIndex );
- DataSeriesHelper::switchLinesOnOrOff( xProp, m_bHasLines );
- DataSeriesHelper::makeLinesThickOrThin( xProp, m_nDim==2 );
+ DataSeriesHelper::switchSymbolsOnOrOff( xSeries, m_bHasSymbols, nSeriesIndex );
+ DataSeriesHelper::switchLinesOnOrOff( xSeries, m_bHasLines );
+ DataSeriesHelper::makeLinesThickOrThin( xSeries, m_nDim==2 );
if( m_nDim==3 )
DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
}
@@ -225,11 +193,11 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::supportsCategories()
return false;
}
-sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
- const Reference< chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties )
+bool ScatterChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties )
{
- bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
+ bool bResult = ChartTypeTemplate::matchesTemplate2( xDiagram, bAdaptProperties );
// check symbol-style and line-style
// for a template with symbols (or with lines) it is ok, if there is at least one series
@@ -239,8 +207,8 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
bool bSymbolFound = false;
bool bLineFound = false;
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ xDiagram->getDataSeries();
for (auto const& series : aSeriesVec)
{
@@ -248,9 +216,8 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
{
chart2::Symbol aSymbProp;
drawing::LineStyle eLineStyle;
- Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY_THROW);
- bool bCurrentHasSymbol = (xProp->getPropertyValue( "Symbol") >>= aSymbProp) &&
+ bool bCurrentHasSymbol = (series->getPropertyValue( "Symbol") >>= aSymbProp) &&
(aSymbProp.Style != chart2::SymbolStyle_NONE);
if( bCurrentHasSymbol )
@@ -262,7 +229,7 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
break;
}
- bool bCurrentHasLine = (xProp->getPropertyValue( "LineStyle") >>= eLineStyle) &&
+ bool bCurrentHasLine = (series->getPropertyValue( "LineStyle") >>= eLineStyle) &&
( eLineStyle != drawing::LineStyle_NONE );
if( bCurrentHasLine )
@@ -296,9 +263,8 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
{
try
{
- uno::Reference< beans::XPropertySet > xChartTypeProp(
- DiagramHelper::getChartTypeByIndex( xDiagram, 0 ),
- uno::UNO_QUERY_THROW );
+ rtl::Reference< ChartType > xChartTypeProp =
+ xDiagram->getChartTypeByIndex(0);
setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_STYLE) );
setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) );
setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartTypeProp->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) );
@@ -312,27 +278,20 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< chart2::XChartType > ScatterChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+rtl::Reference< ChartType > ScatterChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_SCATTER ), uno::UNO_QUERY_THROW );
-
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER ));
- }
+ xResult = new ScatterChartType();
+
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER ));
}
catch( const uno::Exception & )
{
@@ -342,30 +301,23 @@ Reference< chart2::XChartType > ScatterChartTypeTemplate::getChartTypeForIndex(
return xResult;
}
-Reference< chart2::XChartType > SAL_CALL ScatterChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > ScatterChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_SCATTER ), uno::UNO_QUERY_THROW );
+ xResult = new ScatterChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER ));
- }
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER ));
}
catch( const uno::Exception & )
{
@@ -375,7 +327,7 @@ Reference< chart2::XChartType > SAL_CALL ScatterChartTypeTemplate::getChartTypeF
return xResult;
}
-Reference< chart2::XDataInterpreter > SAL_CALL ScatterChartTypeTemplate::getDataInterpreter()
+rtl::Reference< DataInterpreter > ScatterChartTypeTemplate::getDataInterpreter2()
{
if( ! m_xDataInterpreter.is())
m_xDataInterpreter.set( new XYDataInterpreter );
diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.hxx b/chart2/source/model/template/ScatterChartTypeTemplate.hxx
index f0a676cc5dc2..0d7aec7ad188 100644
--- a/chart2/source/model/template/ScatterChartTypeTemplate.hxx
+++ b/chart2/source/model/template/ScatterChartTypeTemplate.hxx
@@ -18,16 +18,14 @@
*/
#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
namespace chart
{
class ScatterChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -47,30 +45,30 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
+ // ____ ChartTypeTemplate ____
virtual sal_Bool SAL_CALL supportsCategories() override;
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence<
- css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual css::uno::Reference< css::chart2::XDataInterpreter > SAL_CALL getDataInterpreter() override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual rtl::Reference< ::chart::DataInterpreter > getDataInterpreter2() override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
// ____ ChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual sal_Int32 getDimension() const override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx b/chart2/source/model/template/StockChartTypeTemplate.cxx
index 464325ef10d1..b0ff53d2a2c3 100644
--- a/chart2/source/model/template/StockChartTypeTemplate.cxx
+++ b/chart2/source/model/template/StockChartTypeTemplate.cxx
@@ -18,25 +18,25 @@
*/
#include "StockChartTypeTemplate.hxx"
+#include "ColumnChartType.hxx"
+#include "CandleStickChartType.hxx"
+#include "LineChartType.hxx"
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include "StockDataInterpreter.hxx"
-#include <DiagramHelper.hxx>
+#include <Diagram.hxx>
+#include <BaseCoordinateSystem.hxx>
#include <servicenames_charttypes.hxx>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <PropertyHelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
-#include <vector>
#include <algorithm>
+#include <cstddef>
using namespace ::com::sun::star;
-using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -127,7 +127,6 @@ StockChartTypeTemplate::StockChartTypeTemplate(
StockVariant eVariant,
bool bJapaneseStyle ) :
ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex ),
m_eStockVariant( eVariant )
{
setFastPropertyValue_NoBroadcast(
@@ -145,14 +144,16 @@ StockChartTypeTemplate::StockChartTypeTemplate(
StockChartTypeTemplate::~StockChartTypeTemplate()
{}
+
// ____ OPropertySet ____
-uno::Any StockChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void StockChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
const tPropertyValueMap& rStaticDefaults = GetStaticStockChartTypeTemplateDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL StockChartTypeTemplate::getInfoHelper()
@@ -182,13 +183,13 @@ sal_Int32 StockChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension
return bHasVolume ? 2 : 1;
}
-void SAL_CALL StockChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void StockChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
try
{
sal_Int32 nNewAxisIndex = 0;
@@ -198,9 +199,7 @@ void SAL_CALL StockChartTypeTemplate::applyStyle(
if( bHasVolume && nChartTypeIndex != 0 )
nNewAxisIndex = 1;
- Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY );
- if( xProp.is() )
- xProp->setPropertyValue( "AttachedAxisIndex", uno::Any( nNewAxisIndex ) );
+ xSeries->setPropertyValue( "AttachedAxisIndex", uno::Any( nNewAxisIndex ) );
if( bHasVolume && nChartTypeIndex==0 )
{
@@ -210,13 +209,10 @@ void SAL_CALL StockChartTypeTemplate::applyStyle(
else
{
//ensure that lines are on
- if( xProp.is() )
- {
- drawing::LineStyle eStyle = drawing::LineStyle_NONE;
- xProp->getPropertyValue( "LineStyle" ) >>= eStyle;
- if( eStyle == drawing::LineStyle_NONE )
- xProp->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_SOLID ));
- }
+ drawing::LineStyle eStyle = drawing::LineStyle_NONE;
+ xSeries->getPropertyValue( "LineStyle" ) >>= eStyle;
+ if( eStyle == drawing::LineStyle_NONE )
+ xSeries->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_SOLID ));
}
}
@@ -226,66 +222,57 @@ void SAL_CALL StockChartTypeTemplate::applyStyle(
}
}
-void SAL_CALL StockChartTypeTemplate::resetStyles(
- const Reference< chart2::XDiagram >& xDiagram )
+void StockChartTypeTemplate::resetStyles2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram )
{
- ChartTypeTemplate::resetStyles( xDiagram );
+ ChartTypeTemplate::resetStyles2( xDiagram );
if( getDimension() == 3 )
{
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ xDiagram->getDataSeries();
for (auto const& series : aSeriesVec)
{
- Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY);
- if( xProp.is() )
- xProp->setPropertyValue( "AttachedAxisIndex", uno::Any( sal_Int32(0) ) );
+ series->setPropertyValue( "AttachedAxisIndex", uno::Any( sal_Int32(0) ) );
}
}
- DiagramHelper::setVertical( xDiagram, false );
+ xDiagram->setVertical( false );
}
-Reference< XChartType > StockChartTypeTemplate::getChartTypeForIndex( sal_Int32 nChartTypeIndex )
+rtl::Reference< ChartType > StockChartTypeTemplate::getChartTypeForIndex( sal_Int32 nChartTypeIndex )
{
- Reference< XChartType > xCT;
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY );
- if(xFact.is())
+ rtl::Reference< ChartType > xCT;
+ bool bHasVolume = false;
+ getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME ) >>= bHasVolume;
+ if( bHasVolume )
{
- bool bHasVolume = false;
- getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME ) >>= bHasVolume;
- if( bHasVolume )
- {
- if( nChartTypeIndex == 0 )
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY );
- else if( nChartTypeIndex == 1 )
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ), uno::UNO_QUERY );
- else
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY );
- }
+ if( nChartTypeIndex == 0 )
+ xCT = new ColumnChartType();
+ else if( nChartTypeIndex == 1 )
+ xCT = new CandleStickChartType();
else
- {
- if( nChartTypeIndex == 0 )
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ), uno::UNO_QUERY );
- else
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY );
- }
+ xCT = new LineChartType();
+ }
+ else
+ {
+ if( nChartTypeIndex == 0 )
+ xCT = new CandleStickChartType();
+ else
+ xCT = new LineChartType();
}
return xCT;
}
void StockChartTypeTemplate::createChartTypes(
- const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq,
- const Sequence< Reference< XCoordinateSystem > > & rCoordSys,
- const Sequence< Reference< XChartType > >& /* aOldChartTypesSeq */ )
+ const std::vector< std::vector< rtl::Reference< DataSeries > > > & aSeriesSeq,
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > >& /* aOldChartTypesSeq */ )
{
- if( !rCoordSys.hasElements() )
+ if( rCoordSys.empty() )
return;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
bool bHasVolume = false;
bool bShowFirst = false;
bool bJapaneseStyle = false;
@@ -296,63 +283,49 @@ void StockChartTypeTemplate::createChartTypes(
getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE ) >>= bJapaneseStyle;
getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH ) >>= bShowHighLow;
- sal_Int32 nSeriesIndex = 0;
+ std::size_t nSeriesIndex = 0;
- std::vector< Reference< chart2::XChartType > > aChartTypeVec;
+ std::vector< rtl::Reference< ChartType > > aChartTypeVec;
// Bars (Volume)
if( bHasVolume )
{
// chart type
- Reference< XChartType > xCT(
- xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY_THROW );
+ rtl::Reference< ChartType > xCT = new ColumnChartType();
aChartTypeVec.push_back( xCT );
- if( aSeriesSeq.getLength() > nSeriesIndex &&
- aSeriesSeq[nSeriesIndex].hasElements() )
+ if( aSeriesSeq.size() > nSeriesIndex &&
+ !aSeriesSeq[nSeriesIndex].empty() )
{
- Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- xDSCnt->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
+ xCT->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
}
++nSeriesIndex;
}
- Reference< XChartType > xCT(
- xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ), uno::UNO_QUERY_THROW );
+ rtl::Reference< ChartType > xCT = new CandleStickChartType();
aChartTypeVec.push_back( xCT );
- Reference< beans::XPropertySet > xCTProp( xCT, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue( "Japanese", uno::Any( bJapaneseStyle ));
- xCTProp->setPropertyValue( "ShowFirst", uno::Any( bShowFirst ));
- xCTProp->setPropertyValue( "ShowHighLow", uno::Any( bShowHighLow ));
- }
+ xCT->setPropertyValue( "Japanese", uno::Any( bJapaneseStyle ));
+ xCT->setPropertyValue( "ShowFirst", uno::Any( bShowFirst ));
+ xCT->setPropertyValue( "ShowHighLow", uno::Any( bShowHighLow ));
- if( aSeriesSeq.getLength() > nSeriesIndex &&
- aSeriesSeq[ nSeriesIndex ].hasElements() )
+ if( aSeriesSeq.size() > nSeriesIndex &&
+ !aSeriesSeq[ nSeriesIndex ].empty() )
{
- Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- xDSCnt->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
+ xCT->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
}
++nSeriesIndex;
// Lines (remaining series)
- if( aSeriesSeq.getLength() > nSeriesIndex &&
- aSeriesSeq[ nSeriesIndex ].hasElements() )
+ if( aSeriesSeq.size() > nSeriesIndex &&
+ !aSeriesSeq[ nSeriesIndex ].empty() )
{
- xCT.set(
- xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
+ xCT = new LineChartType();
aChartTypeVec.push_back( xCT );
- Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- xDSCnt->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
+ xCT->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
}
- Reference< XChartTypeContainer > xCTCnt( rCoordSys[ 0 ], uno::UNO_QUERY_THROW );
- xCTCnt->setChartTypes( comphelper::containerToSequence(aChartTypeVec) );
+ rCoordSys[ 0 ]->setChartTypes( aChartTypeVec );
}
catch( const uno::Exception & )
{
@@ -360,10 +333,10 @@ void StockChartTypeTemplate::createChartTypes(
}
}
-// ____ XChartTypeTemplate ____
-sal_Bool SAL_CALL StockChartTypeTemplate::matchesTemplate(
- const uno::Reference< XDiagram >& xDiagram,
- sal_Bool /* bAdaptProperties */ )
+// ____ ChartTypeTemplate ____
+bool StockChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool /* bAdaptProperties */ )
{
bool bResult = false;
@@ -378,34 +351,25 @@ sal_Bool SAL_CALL StockChartTypeTemplate::matchesTemplate(
getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_OPEN ) >>= bHasOpenValue;
getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE ) >>= bHasJapaneseStyle;
- Reference< chart2::XChartType > xVolumeChartType;
- Reference< chart2::XChartType > xCandleStickChartType;
- Reference< chart2::XChartType > xLineChartType;
+ rtl::Reference< ChartType > xVolumeChartType;
+ rtl::Reference< ChartType > xCandleStickChartType;
+ rtl::Reference< ChartType > xLineChartType;
sal_Int32 nNumberOfChartTypes = 0;
- Reference< XCoordinateSystemContainer > xCooSysCnt(
- xDiagram, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
- xCooSysCnt->getCoordinateSystems());
- for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : xDiagram->getBaseCoordinateSystems() )
{
- Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
- for( Reference< XChartType > const & chartType : aChartTypeSeq )
+ for( rtl::Reference< ChartType > const & chartType : coords->getChartTypes2() )
{
- if( chartType.is())
- {
- ++nNumberOfChartTypes;
- if( nNumberOfChartTypes > 3 )
- break;
- OUString aCTService = chartType->getChartType();
- if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
- xVolumeChartType.set( chartType );
- else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
- xCandleStickChartType.set( chartType );
- else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
- xLineChartType.set( chartType );
- }
+ ++nNumberOfChartTypes;
+ if( nNumberOfChartTypes > 3 )
+ break;
+ OUString aCTService = chartType->getChartType();
+ if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
+ xVolumeChartType = chartType;
+ else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
+ xCandleStickChartType = chartType;
+ else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
+ xLineChartType = chartType;
}
if( nNumberOfChartTypes > 3 )
break;
@@ -416,18 +380,14 @@ sal_Bool SAL_CALL StockChartTypeTemplate::matchesTemplate(
bResult = true;
// check for japanese style
- Reference< beans::XPropertySet > xCTProp( xCandleStickChartType, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- bool bJapaneseProp = false;
- xCTProp->getPropertyValue( "Japanese") >>= bJapaneseProp;
- bResult = bResult && ( bHasJapaneseStyle == bJapaneseProp );
-
- // in old chart japanese == showFirst
- bool bShowFirstProp = false;
- xCTProp->getPropertyValue( "ShowFirst") >>= bShowFirstProp;
- bResult = bResult && ( bHasOpenValue == bShowFirstProp );
- }
+ bool bJapaneseProp = false;
+ xCandleStickChartType->getPropertyValue( "Japanese") >>= bJapaneseProp;
+ bResult = bResult && ( bHasJapaneseStyle == bJapaneseProp );
+
+ // in old chart japanese == showFirst
+ bool bShowFirstProp = false;
+ xCandleStickChartType->getPropertyValue( "ShowFirst") >>= bShowFirstProp;
+ bResult = bResult && ( bHasOpenValue == bShowFirstProp );
}
}
catch( const uno::Exception & )
@@ -438,17 +398,14 @@ sal_Bool SAL_CALL StockChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< XChartType > SAL_CALL StockChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > StockChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
+ xResult = new LineChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
}
catch( const uno::Exception & )
@@ -459,7 +416,7 @@ Reference< XChartType > SAL_CALL StockChartTypeTemplate::getChartTypeForNewSerie
return xResult;
}
-Reference< XDataInterpreter > SAL_CALL StockChartTypeTemplate::getDataInterpreter()
+rtl::Reference< DataInterpreter > StockChartTypeTemplate::getDataInterpreter2()
{
if( ! m_xDataInterpreter.is())
m_xDataInterpreter.set( new StockDataInterpreter( m_eStockVariant ) );
diff --git a/chart2/source/model/template/StockChartTypeTemplate.hxx b/chart2/source/model/template/StockChartTypeTemplate.hxx
index 01bd6f089797..aed35a000919 100644
--- a/chart2/source/model/template/StockChartTypeTemplate.hxx
+++ b/chart2/source/model/template/StockChartTypeTemplate.hxx
@@ -18,16 +18,14 @@
*/
#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
namespace chart
{
class StockChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -62,7 +60,7 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
@@ -70,40 +68,37 @@ protected:
getPropertySetInfo() override;
// ____ XChartTypeTemplate ____
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual css::uno::Reference< css::chart2::XDataInterpreter > SAL_CALL getDataInterpreter() override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual rtl::Reference< ::chart::DataInterpreter > getDataInterpreter2() override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
- virtual void SAL_CALL resetStyles(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override;
+ virtual void resetStyles2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram ) override;
// ChartTypeTemplate
virtual sal_Int32 getAxisCountByDimension( sal_Int32 nDimension ) override;
// ____ ChartTypeTemplate ____
virtual void createChartTypes(
- const css::uno::Sequence<
- css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XDataSeries > > >& aSeriesSeq,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XCoordinateSystem > > & rCoordSys,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XChartType > > & aOldChartTypesSeq
+ const std::vector<
+ std::vector<
+ rtl::Reference<
+ ::chart::DataSeries > > >& aSeriesSeq,
+ const std::vector<
+ rtl::Reference<
+ ::chart::BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq
) override;
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
private:
diff --git a/chart2/source/model/template/StockDataInterpreter.cxx b/chart2/source/model/template/StockDataInterpreter.cxx
index 7647f475f1f8..1575bba1b223 100644
--- a/chart2/source/model/template/StockDataInterpreter.cxx
+++ b/chart2/source/model/template/StockDataInterpreter.cxx
@@ -17,15 +17,17 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cstddef>
+
#include "StockDataInterpreter.hxx"
#include "StockChartTypeTemplate.hxx"
#include <DataSeries.hxx>
-#include <com/sun/star/chart2/data/XDataSink.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
-using namespace ::std;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -43,17 +45,17 @@ StockDataInterpreter::~StockDataInterpreter()
{}
// ____ XDataInterpreter ____
-InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
+InterpretedData StockDataInterpreter::interpretDataSource(
const Reference< data::XDataSource >& xSource,
const Sequence< beans::PropertyValue >& rArguments,
- const Sequence< Reference< XDataSeries > >& rSeriesToReUse )
+ const std::vector< rtl::Reference< ::chart::DataSeries > >& rSeriesToReUse )
{
if( ! xSource.is())
return InterpretedData();
- Reference< data::XLabeledDataSequence > xCategories;
- Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
- const sal_Int32 nDataCount( aData.getLength());
+ uno::Reference< chart2::data::XLabeledDataSequence > xCategories;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aData = DataInterpreter::getDataSequences(xSource);
+ const sal_Int32 nDataCount( aData.size());
// sub-type properties
const StockChartTypeTemplate::StockVariant eVar( GetStockVariant());
@@ -87,16 +89,15 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
sal_Int32 nNumberOfGroups( bHasVolume ? 2 : 1 );
// sequences of data::XLabeledDataSequence per series per group
- Sequence< Sequence< Sequence< Reference< data::XLabeledDataSequence > > > > aSequences( nNumberOfGroups );
- auto pSequences = aSequences.getArray();
+ std::vector< std::vector< std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > > > aSequences( nNumberOfGroups );
const sal_Int32 nBarGroupIndex( 0 );
const sal_Int32 nCandleStickGroupIndex( nNumberOfGroups - 1 );
// allocate space for labeled sequences
if( nRemaining > 0 )
++nCandleStickSeries;
- pSequences[nCandleStickGroupIndex].realloc( nCandleStickSeries );
- auto pCandleStickGroup = pSequences[nCandleStickGroupIndex].getArray();
+ aSequences[nCandleStickGroupIndex].resize( nCandleStickSeries );
+ auto & pCandleStickGroup = aSequences[nCandleStickGroupIndex];
if( bHasVolume )
{
// if there are remaining sequences, the first one is taken for
@@ -104,9 +105,9 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
// is used
if( nRemaining > 1 )
++nVolumeSeries;
- pSequences[nBarGroupIndex].realloc( nVolumeSeries );
+ aSequences[nBarGroupIndex].resize( nVolumeSeries );
}
- auto pBarGroup = pSequences[nBarGroupIndex].getArray();
+ auto & pBarGroup = aSequences[nBarGroupIndex];
// create data
sal_Int32 nSourceIndex = 0; // index into aData sequence
@@ -114,7 +115,7 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
// 1. categories
if( bHasCategories )
{
- xCategories.set( aData[nSourceIndex] );
+ xCategories = aData[nSourceIndex];
++nSourceIndex;
}
@@ -124,8 +125,8 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
// bar
if( bHasVolume )
{
- pBarGroup[nLabeledSeqIdx].realloc( 1 );
- pBarGroup[nLabeledSeqIdx].getArray()[0].set( aData[nSourceIndex] );
+ pBarGroup[nLabeledSeqIdx].resize( 1 );
+ pBarGroup[nLabeledSeqIdx][0] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
SetRole( aData[nSourceIndex]->getValues(), "values-y");
++nSourceIndex;
@@ -134,30 +135,30 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
sal_Int32 nSeqIdx = 0;
if( bHasOpenValues )
{
- pCandleStickGroup[nLabeledSeqIdx].realloc( 4 );
- pCandleStickGroup[nLabeledSeqIdx].getArray()[nSeqIdx].set( aData[nSourceIndex] );
+ pCandleStickGroup[nLabeledSeqIdx].resize( 4 );
+ pCandleStickGroup[nLabeledSeqIdx][nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
SetRole( aData[nSourceIndex]->getValues(), "values-first");
++nSourceIndex;
++nSeqIdx;
}
else
- pCandleStickGroup[nLabeledSeqIdx].realloc( 3 );
- auto pLabeledSeq = pCandleStickGroup[nLabeledSeqIdx].getArray();
+ pCandleStickGroup[nLabeledSeqIdx].resize( 3 );
+ auto & pLabeledSeq = pCandleStickGroup[nLabeledSeqIdx];
- pLabeledSeq[nSeqIdx].set( aData[nSourceIndex] );
+ pLabeledSeq[nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
SetRole( aData[nSourceIndex]->getValues(), "values-min");
++nSourceIndex;
++nSeqIdx;
- pLabeledSeq[nSeqIdx].set( aData[nSourceIndex] );
+ pLabeledSeq[nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
SetRole( aData[nSourceIndex]->getValues(), "values-max");
++nSourceIndex;
++nSeqIdx;
- pLabeledSeq[nSeqIdx].set( aData[nSourceIndex] );
+ pLabeledSeq[nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
SetRole( aData[nSourceIndex]->getValues(), "values-last");
++nSourceIndex;
@@ -168,11 +169,11 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
if( bHasVolume && nRemaining > 1 )
{
OSL_ASSERT( nVolumeSeries > nNumOfFullSeries );
- pBarGroup[nVolumeSeries - 1].realloc( 1 );
+ pBarGroup[nVolumeSeries - 1].resize( 1 );
OSL_ASSERT( nDataCount > nSourceIndex );
if( aData[nSourceIndex].is())
SetRole( aData[nSourceIndex]->getValues(), "values-y");
- pBarGroup[nVolumeSeries - 1].getArray()[0].set( aData[nSourceIndex] );
+ pBarGroup[nVolumeSeries - 1][0] = aData[nSourceIndex];
++nSourceIndex;
--nRemaining;
OSL_ENSURE( nRemaining, "additional bar should only be used if there is at least one more sequence for a candle stick" );
@@ -183,13 +184,13 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
{
OSL_ASSERT( nCandleStickSeries > nNumOfFullSeries );
const sal_Int32 nSeriesIndex = nCandleStickSeries - 1;
- pCandleStickGroup[nSeriesIndex].realloc( nRemaining );
- auto pLabeledSeq = pCandleStickGroup[nSeriesIndex].getArray();
+ pCandleStickGroup[nSeriesIndex].resize( nRemaining );
+ auto & pLabeledSeq = pCandleStickGroup[nSeriesIndex];
OSL_ASSERT( nDataCount > nSourceIndex );
// 1. low
sal_Int32 nSeqIdx( 0 );
- pLabeledSeq[nSeqIdx].set( aData[nSourceIndex] );
+ pLabeledSeq[nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
SetRole( aData[nSourceIndex]->getValues(), "values-min");
++nSourceIndex;
@@ -198,7 +199,7 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
// 2. high
if( nSeqIdx < nRemaining )
{
- pLabeledSeq[nSeqIdx].set( aData[nSourceIndex] );
+ pLabeledSeq[nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
SetRole( aData[nSourceIndex]->getValues(), "values-max");
++nSourceIndex;
@@ -209,7 +210,7 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
OSL_ENSURE( bHasOpenValues || nSeqIdx >= nRemaining, "could have created full series" );
if( nSeqIdx < nRemaining )
{
- pLabeledSeq[nSeqIdx].set( aData[nSourceIndex] );
+ pLabeledSeq[nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
SetRole( aData[nSourceIndex]->getValues(), "values-last");
++nSourceIndex;
@@ -221,27 +222,26 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
}
// create DataSeries
- Sequence< Sequence< Reference< XDataSeries > > > aResultSeries( nNumberOfGroups );
- auto pResultSeries = aResultSeries.getArray();
- sal_Int32 nGroupIndex, nReUsedSeriesIdx = 0;
+ std::vector< std::vector< rtl::Reference< DataSeries > > > aResultSeries( nNumberOfGroups );
+ sal_Int32 nGroupIndex;
+ std::size_t nReUsedSeriesIdx = 0;
for( nGroupIndex=0; nGroupIndex<nNumberOfGroups; ++nGroupIndex )
{
- const sal_Int32 nNumSeriesData = aSequences[nGroupIndex].getLength();
- pResultSeries[nGroupIndex].realloc( nNumSeriesData );
- auto pResultSerie = pResultSeries[nGroupIndex].getArray();
+ const sal_Int32 nNumSeriesData = aSequences[nGroupIndex].size();
+ aResultSeries[nGroupIndex].resize( nNumSeriesData );
+ auto & pResultSerie = aResultSeries[nGroupIndex];
for( sal_Int32 nSeriesIdx = 0; nSeriesIdx < nNumSeriesData; ++nSeriesIdx, ++nReUsedSeriesIdx )
{
try
{
- Reference< XDataSeries > xSeries;
- if( nReUsedSeriesIdx < rSeriesToReUse.getLength())
- xSeries.set( rSeriesToReUse[nReUsedSeriesIdx] );
+ rtl::Reference< DataSeries > xSeries;
+ if( nReUsedSeriesIdx < rSeriesToReUse.size())
+ xSeries = rSeriesToReUse[nReUsedSeriesIdx];
else
- xSeries.set( new DataSeries );
- OSL_ASSERT( xSeries.is() );
- Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY_THROW );
- xSink->setData( aSequences[nGroupIndex][nSeriesIdx] );
- pResultSerie[nSeriesIdx].set( xSeries );
+ xSeries = new DataSeries;
+ assert( xSeries.is() );
+ xSeries->setData( aSequences[nGroupIndex][nSeriesIdx] );
+ pResultSerie[nSeriesIdx] = xSeries;
}
catch( const uno::Exception & )
{
@@ -250,7 +250,7 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
}
}
- return InterpretedData( aResultSeries, xCategories );
+ return { aResultSeries, xCategories };
}
// criterion: there must be two groups for stock-charts with volume and all
@@ -258,11 +258,11 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
// todo: skip first criterion? (to allow easy switch from stock-chart without
// volume to one with volume)
-sal_Bool SAL_CALL StockDataInterpreter::isDataCompatible(
+bool StockDataInterpreter::isDataCompatible(
const InterpretedData& aInterpretedData )
{
// high/low/close
- sal_Int32 nNumberOfNecessarySequences = 3;
+ std::size_t nNumberOfNecessarySequences = 3;
// open
StockChartTypeTemplate::StockVariant eVar( GetStockVariant());
if( ( eVar == StockChartTypeTemplate::StockVariant::Open ) ||
@@ -273,32 +273,30 @@ sal_Bool SAL_CALL StockDataInterpreter::isDataCompatible(
( eVar == StockChartTypeTemplate::StockVariant::VolumeOpen ));
// 1. correct number of sub-types
- if( aInterpretedData.Series.getLength() < (bHasVolume ? 2 : 1 ))
+ if( aInterpretedData.Series.size() < (bHasVolume ? 2U : 1U ))
return false;
// 2. a. volume -- use default check
if( bHasVolume )
{
if( ! DataInterpreter::isDataCompatible(
- InterpretedData( Sequence< Sequence< Reference< XDataSeries > > >(
- aInterpretedData.Series.getConstArray(), 1 ),
- aInterpretedData.Categories )))
+ { std::vector< std::vector< rtl::Reference< DataSeries > > >{
+ aInterpretedData.Series[0] },
+ aInterpretedData.Categories }))
return false;
}
// 2. b. candlestick
{
- OSL_ASSERT( aInterpretedData.Series.getLength() > (bHasVolume ? 1 : 0));
- const Sequence< Reference< XDataSeries > > aSeries( aInterpretedData.Series[(bHasVolume ? 1 : 0)] );
- if(!aSeries.hasElements())
+ OSL_ASSERT( aInterpretedData.Series.size() > (bHasVolume ? 1U : 0U));
+ const std::vector< rtl::Reference< DataSeries > > & aSeries = aInterpretedData.Series[(bHasVolume ? 1 : 0)];
+ if(aSeries.empty())
return false;
- for( Reference< XDataSeries > const & dataSeries : aSeries )
+ for( rtl::Reference< DataSeries > const & dataSeries : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
- if( aSeq.getLength() != nNumberOfNecessarySequences )
+ if( dataSeries->getDataSequences2().size() != nNumberOfNecessarySequences )
return false;
}
catch( const uno::Exception & )
@@ -314,14 +312,14 @@ sal_Bool SAL_CALL StockDataInterpreter::isDataCompatible(
return true;
}
-InterpretedData SAL_CALL StockDataInterpreter::reinterpretDataSeries(
+InterpretedData StockDataInterpreter::reinterpretDataSeries(
const InterpretedData& aInterpretedData )
{
// prerequisite: StockDataInterpreter::isDataCompatible() returned true
return aInterpretedData;
}
-uno::Any SAL_CALL StockDataInterpreter::getChartTypeSpecificData(
+uno::Any StockDataInterpreter::getChartTypeSpecificData(
const OUString& sKey )
{
if( sKey == "stock variant" )
diff --git a/chart2/source/model/template/StockDataInterpreter.hxx b/chart2/source/model/template/StockDataInterpreter.hxx
index ba2d5ee79111..4617da5974a9 100644
--- a/chart2/source/model/template/StockDataInterpreter.hxx
+++ b/chart2/source/model/template/StockDataInterpreter.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "DataInterpreter.hxx"
+#include <DataInterpreter.hxx>
#include "StockChartTypeTemplate.hxx"
@@ -34,15 +34,15 @@ public:
protected:
// ____ XDataInterpreter ____
- virtual css::chart2::InterpretedData SAL_CALL interpretDataSource(
+ virtual InterpretedData interpretDataSource(
const css::uno::Reference< css::chart2::data::XDataSource >& xSource,
const css::uno::Sequence< css::beans::PropertyValue >& aArguments,
- const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > >& aSeriesToReUse ) override;
- virtual sal_Bool SAL_CALL isDataCompatible(
- const css::chart2::InterpretedData& aInterpretedData ) override;
- virtual css::chart2::InterpretedData SAL_CALL reinterpretDataSeries(
- const css::chart2::InterpretedData& aInterpretedData ) override;
- virtual css::uno::Any SAL_CALL getChartTypeSpecificData(
+ const std::vector< rtl::Reference< ::chart::DataSeries > >& aSeriesToReUse ) override;
+ virtual bool isDataCompatible(
+ const InterpretedData& aInterpretedData ) override;
+ virtual InterpretedData reinterpretDataSeries(
+ const InterpretedData& aInterpretedData ) override;
+ virtual css::uno::Any getChartTypeSpecificData(
const OUString& sKey ) override;
private:
diff --git a/chart2/source/model/template/XYDataInterpreter.cxx b/chart2/source/model/template/XYDataInterpreter.cxx
index 1f0480a28c39..1fc053f14c24 100644
--- a/chart2/source/model/template/XYDataInterpreter.cxx
+++ b/chart2/source/model/template/XYDataInterpreter.cxx
@@ -17,18 +17,20 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cstddef>
+
#include "XYDataInterpreter.hxx"
#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <CommonConverters.hxx>
-#include <com/sun/star/chart2/data/XDataSink.hpp>
#include <com/sun/star/util/XCloneable.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
-using namespace ::std;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -45,33 +47,33 @@ XYDataInterpreter::~XYDataInterpreter()
}
// ____ XDataInterpreter ____
-chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
+InterpretedData XYDataInterpreter::interpretDataSource(
const Reference< chart2::data::XDataSource >& xSource,
const Sequence< beans::PropertyValue >& aArguments,
- const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+ const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
{
if( ! xSource.is())
return InterpretedData();
- const Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aData = DataInterpreter::getDataSequences(xSource);
- Reference< data::XLabeledDataSequence > xValuesX;
- vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesX;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSequencesVec;
- Reference< data::XLabeledDataSequence > xCategories;
+ uno::Reference< chart2::data::XLabeledDataSequence > xCategories;
bool bHasCategories = HasCategories( aArguments, aData );
bool bUseCategoriesAsX = UseCategoriesAsX( aArguments );
// parse data
bool bCategoriesUsed = false;
- bool bSetXValues = aData.getLength()>1;
- for( Reference< data::XLabeledDataSequence > const & labelData : aData )
+ bool bSetXValues = aData.size()>1;
+ for( uno::Reference< chart2::data::XLabeledDataSequence > const & labelData : aData )
{
try
{
if( bHasCategories && ! bCategoriesUsed )
{
- xCategories.set( labelData );
+ xCategories = labelData;
if( xCategories.is())
{
SetRole( xCategories->getValues(), "categories");
@@ -82,7 +84,7 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
}
else if( !xValuesX.is() && bSetXValues )
{
- xValuesX.set( labelData );
+ xValuesX = labelData;
if( xValuesX.is())
SetRole( xValuesX->getValues(), "values-x");
}
@@ -100,16 +102,16 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
}
// create DataSeries
- vector< Reference< XDataSeries > > aSeriesVec;
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec;
aSeriesVec.reserve( aSequencesVec.size());
Reference< data::XLabeledDataSequence > xClonedXValues = xValuesX;
Reference< util::XCloneable > xCloneable( xValuesX, uno::UNO_QUERY );
- sal_Int32 nSeriesIndex = 0;
+ std::size_t nSeriesIndex = 0;
for (auto const& elem : aSequencesVec)
{
- vector< Reference< data::XLabeledDataSequence > > aNewData;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewData;
if( nSeriesIndex && xCloneable.is() )
xClonedXValues.set( xCloneable->createClone(), uno::UNO_QUERY );
@@ -118,50 +120,47 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
aNewData.push_back(elem);
- Reference< XDataSeries > xSeries;
- if( nSeriesIndex < aSeriesToReUse.getLength())
- xSeries.set( aSeriesToReUse[nSeriesIndex] );
+ rtl::Reference< DataSeries > xSeries;
+ if( nSeriesIndex < aSeriesToReUse.size())
+ xSeries = aSeriesToReUse[nSeriesIndex];
else
- xSeries.set( new DataSeries );
- OSL_ASSERT( xSeries.is() );
- Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
- OSL_ASSERT( xSink.is() );
- xSink->setData( comphelper::containerToSequence( aNewData ) );
+ xSeries = new DataSeries;
+ assert( xSeries.is() );
+ xSeries->setData( aNewData );
aSeriesVec.push_back( xSeries );
++nSeriesIndex;
}
- return InterpretedData( { comphelper::containerToSequence( aSeriesVec ) }, xCategories );
+ return { { aSeriesVec }, xCategories };
}
-chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
- const chart2::InterpretedData& aInterpretedData )
+InterpretedData XYDataInterpreter::reinterpretDataSeries(
+ const InterpretedData& aInterpretedData )
{
InterpretedData aResult( aInterpretedData );
sal_Int32 i=0;
- Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- const sal_Int32 nCount = aSeries.getLength();
+ std::vector< rtl::Reference< DataSeries > > aSeries = FlattenSequence( aInterpretedData.Series );
+ const sal_Int32 nCount = aSeries.size();
for( ; i<nCount; ++i )
{
try
{
- Reference< data::XDataSource > xSeriesSource( aSeries[i], uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aNewSequences;
+ std::vector< uno::Reference< data::XLabeledDataSequence > > aNewSequences;
// values-y
- Reference< data::XLabeledDataSequence > xValuesY(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-y" ));
- Reference< data::XLabeledDataSequence > xValuesX(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-x" ));
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesY(
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values-y" ));
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesX(
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], "values-x" ));
// re-use values-... as values-x/values-y
if( ! xValuesX.is() ||
! xValuesY.is())
{
- vector< Reference< data::XLabeledDataSequence > > aValueSeqVec(
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aValueSeqVec(
DataSeriesHelper::getAllDataSequencesByRole(
- xSeriesSource->getDataSequences(), "values" ));
+ aSeries[i]->getDataSequences2(), "values" ));
if( xValuesX.is())
aValueSeqVec.erase( find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesX ));
if( xValuesY.is())
@@ -171,7 +170,7 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
if( ! xValuesY.is() &&
aValueSeqVec.size() > nIndex )
{
- xValuesY.set( aValueSeqVec[nIndex++] );
+ xValuesY = aValueSeqVec[nIndex++];
if( xValuesY.is())
SetRole( xValuesY->getValues(), "values-y");
}
@@ -179,7 +178,7 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
if( ! xValuesX.is() &&
aValueSeqVec.size() > nIndex )
{
- xValuesX.set( aValueSeqVec[nIndex++] );
+ xValuesX = aValueSeqVec[nIndex++];
if( xValuesX.is())
SetRole( xValuesY->getValues(), "values-x");
}
@@ -196,8 +195,8 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
}
}
- const Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
- if( aSeqs.getLength() != aNewSequences.getLength() )
+ const std::vector< uno::Reference< data::XLabeledDataSequence > > & aSeqs = aSeries[i]->getDataSequences2();
+ if( aSeqs.size() != aNewSequences.size() )
{
#ifdef DBG_UTIL
for( auto const & j : aSeqs )
@@ -205,8 +204,7 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
SAL_WARN_IF((j == xValuesY || j == xValuesX), "chart2.template", "All sequences should be used" );
}
#endif
- Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
- xSink->setData( aNewSequences );
+ aSeries[i]->setData( aNewSequences );
}
}
catch( const uno::Exception & )
@@ -219,17 +217,15 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
}
// criterion: all series must have exactly two data::XLabeledDataSequences
-sal_Bool SAL_CALL XYDataInterpreter::isDataCompatible(
- const chart2::InterpretedData& aInterpretedData )
+bool XYDataInterpreter::isDataCompatible(
+ const InterpretedData& aInterpretedData )
{
- const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- for( Reference< XDataSeries > const & dataSeries : aSeries )
+ const std::vector< rtl::Reference< DataSeries > > aSeries = FlattenSequence( aInterpretedData.Series );
+ for( rtl::Reference< DataSeries > const & dataSeries : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
- if( aSeq.getLength() != 2 )
+ if( dataSeries->getDataSequences2().size() != 2 )
return false;
}
catch( const uno::Exception & )
diff --git a/chart2/source/model/template/XYDataInterpreter.hxx b/chart2/source/model/template/XYDataInterpreter.hxx
index 24f640c143f6..56343013da08 100644
--- a/chart2/source/model/template/XYDataInterpreter.hxx
+++ b/chart2/source/model/template/XYDataInterpreter.hxx
@@ -18,7 +18,7 @@
*/
#pragma once
-#include "DataInterpreter.hxx"
+#include <DataInterpreter.hxx>
namespace chart
{
@@ -30,15 +30,15 @@ public:
virtual ~XYDataInterpreter() override;
protected:
- // ____ XDataInterpreter ____
- virtual css::chart2::InterpretedData SAL_CALL interpretDataSource(
+ // ____ DataInterpreter ____
+ virtual InterpretedData interpretDataSource(
const css::uno::Reference< css::chart2::data::XDataSource >& xSource,
const css::uno::Sequence< css::beans::PropertyValue >& aArguments,
- const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > >& aSeriesToReUse ) override;
- virtual css::chart2::InterpretedData SAL_CALL reinterpretDataSeries(
- const css::chart2::InterpretedData& aInterpretedData ) override;
- virtual sal_Bool SAL_CALL isDataCompatible(
- const css::chart2::InterpretedData& aInterpretedData ) override;
+ const std::vector< rtl::Reference< ::chart::DataSeries > >& aSeriesToReUse ) override;
+ virtual InterpretedData reinterpretDataSeries(
+ const InterpretedData& aInterpretedData ) override;
+ virtual bool isDataCompatible(
+ const InterpretedData& aInterpretedData ) override;
};
} // namespace chart