summaryrefslogtreecommitdiffstats
path: root/chart2/source/model
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /chart2/source/model
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'chart2/source/model')
-rw-r--r--chart2/source/model/filter/XMLFilter.cxx786
-rw-r--r--chart2/source/model/inc/BaseCoordinateSystem.hxx129
-rw-r--r--chart2/source/model/inc/CartesianCoordinateSystem.hxx76
-rw-r--r--chart2/source/model/inc/ChartTypeManager.hxx74
-rw-r--r--chart2/source/model/inc/DataSeries.hxx172
-rw-r--r--chart2/source/model/inc/Diagram.hxx186
-rw-r--r--chart2/source/model/inc/PolarCoordinateSystem.hxx76
-rw-r--r--chart2/source/model/inc/StockBar.hxx96
-rw-r--r--chart2/source/model/inc/XMLFilter.hxx171
-rw-r--r--chart2/source/model/main/Axis.cxx632
-rw-r--r--chart2/source/model/main/Axis.hxx138
-rw-r--r--chart2/source/model/main/BaseCoordinateSystem.cxx361
-rw-r--r--chart2/source/model/main/CartesianCoordinateSystem.cxx160
-rw-r--r--chart2/source/model/main/ChartModel.cxx1301
-rw-r--r--chart2/source/model/main/ChartModel_Persistence.cxx809
-rw-r--r--chart2/source/model/main/DataPoint.cxx293
-rw-r--r--chart2/source/model/main/DataPoint.hxx116
-rw-r--r--chart2/source/model/main/DataPointProperties.cxx540
-rw-r--r--chart2/source/model/main/DataPointProperties.hxx107
-rw-r--r--chart2/source/model/main/DataSeries.cxx565
-rw-r--r--chart2/source/model/main/DataSeriesProperties.cxx92
-rw-r--r--chart2/source/model/main/DataSeriesProperties.hxx55
-rw-r--r--chart2/source/model/main/Diagram.cxx704
-rw-r--r--chart2/source/model/main/FormattedString.cxx284
-rw-r--r--chart2/source/model/main/FormattedString.hxx140
-rw-r--r--chart2/source/model/main/GridProperties.cxx249
-rw-r--r--chart2/source/model/main/GridProperties.hxx105
-rw-r--r--chart2/source/model/main/Legend.cxx315
-rw-r--r--chart2/source/model/main/Legend.hxx107
-rw-r--r--chart2/source/model/main/PageBackground.cxx230
-rw-r--r--chart2/source/model/main/PageBackground.hxx104
-rw-r--r--chart2/source/model/main/PolarCoordinateSystem.cxx157
-rw-r--r--chart2/source/model/main/StockBar.cxx213
-rw-r--r--chart2/source/model/main/Title.cxx390
-rw-r--r--chart2/source/model/main/Title.hxx115
-rw-r--r--chart2/source/model/main/UndoManager.cxx350
-rw-r--r--chart2/source/model/main/UndoManager.hxx94
-rw-r--r--chart2/source/model/main/Wall.cxx201
-rw-r--r--chart2/source/model/main/Wall.hxx99
-rw-r--r--chart2/source/model/template/AreaChartType.cxx79
-rw-r--r--chart2/source/model/template/AreaChartType.hxx55
-rw-r--r--chart2/source/model/template/AreaChartTypeTemplate.cxx237
-rw-r--r--chart2/source/model/template/AreaChartTypeTemplate.hxx86
-rw-r--r--chart2/source/model/template/BarChartType.cxx89
-rw-r--r--chart2/source/model/template/BarChartType.hxx57
-rw-r--r--chart2/source/model/template/BarChartTypeTemplate.cxx311
-rw-r--r--chart2/source/model/template/BarChartTypeTemplate.hxx102
-rw-r--r--chart2/source/model/template/BubbleChartType.cxx220
-rw-r--r--chart2/source/model/template/BubbleChartType.hxx72
-rw-r--r--chart2/source/model/template/BubbleChartTypeTemplate.cxx211
-rw-r--r--chart2/source/model/template/BubbleChartTypeTemplate.hxx78
-rw-r--r--chart2/source/model/template/BubbleDataInterpreter.cxx290
-rw-r--r--chart2/source/model/template/BubbleDataInterpreter.hxx50
-rw-r--r--chart2/source/model/template/CandleStickChartType.cxx342
-rw-r--r--chart2/source/model/template/CandleStickChartType.hxx75
-rw-r--r--chart2/source/model/template/ChartType.cxx308
-rw-r--r--chart2/source/model/template/ChartType.hxx141
-rw-r--r--chart2/source/model/template/ChartTypeManager.cxx606
-rw-r--r--chart2/source/model/template/ChartTypeTemplate.cxx877
-rw-r--r--chart2/source/model/template/ChartTypeTemplate.hxx256
-rw-r--r--chart2/source/model/template/ColumnChartType.cxx206
-rw-r--r--chart2/source/model/template/ColumnChartType.hxx65
-rw-r--r--chart2/source/model/template/ColumnLineChartTypeTemplate.cxx410
-rw-r--r--chart2/source/model/template/ColumnLineChartTypeTemplate.hxx101
-rw-r--r--chart2/source/model/template/ColumnLineDataInterpreter.cxx80
-rw-r--r--chart2/source/model/template/ColumnLineDataInterpreter.hxx50
-rw-r--r--chart2/source/model/template/DataInterpreter.cxx441
-rw-r--r--chart2/source/model/template/DataInterpreter.hxx79
-rw-r--r--chart2/source/model/template/FilledNetChartType.cxx84
-rw-r--r--chart2/source/model/template/FilledNetChartType.hxx55
-rw-r--r--chart2/source/model/template/LineChartType.cxx208
-rw-r--r--chart2/source/model/template/LineChartType.hxx63
-rw-r--r--chart2/source/model/template/LineChartTypeTemplate.cxx374
-rw-r--r--chart2/source/model/template/LineChartTypeTemplate.hxx90
-rw-r--r--chart2/source/model/template/NetChartType.cxx183
-rw-r--r--chart2/source/model/template/NetChartType.hxx78
-rw-r--r--chart2/source/model/template/NetChartTypeTemplate.cxx194
-rw-r--r--chart2/source/model/template/NetChartTypeTemplate.hxx71
-rw-r--r--chart2/source/model/template/PieChartType.cxx241
-rw-r--r--chart2/source/model/template/PieChartType.hxx69
-rw-r--r--chart2/source/model/template/PieChartTypeTemplate.cxx608
-rw-r--r--chart2/source/model/template/PieChartTypeTemplate.hxx112
-rw-r--r--chart2/source/model/template/ScatterChartType.cxx251
-rw-r--r--chart2/source/model/template/ScatterChartType.hxx69
-rw-r--r--chart2/source/model/template/ScatterChartTypeTemplate.cxx391
-rw-r--r--chart2/source/model/template/ScatterChartTypeTemplate.hxx90
-rw-r--r--chart2/source/model/template/StockChartTypeTemplate.cxx499
-rw-r--r--chart2/source/model/template/StockChartTypeTemplate.hxx120
-rw-r--r--chart2/source/model/template/StockDataInterpreter.cxx319
-rw-r--r--chart2/source/model/template/StockDataInterpreter.hxx58
-rw-r--r--chart2/source/model/template/XYDataInterpreter.cxx252
-rw-r--r--chart2/source/model/template/XYDataInterpreter.hxx50
92 files changed, 21295 insertions, 0 deletions
diff --git a/chart2/source/model/filter/XMLFilter.cxx b/chart2/source/model/filter/XMLFilter.cxx
new file mode 100644
index 000000000..a8633cc2d
--- /dev/null
+++ b/chart2/source/model/filter/XMLFilter.cxx
@@ -0,0 +1,786 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <XMLFilter.hxx>
+#include <MediaDescriptorHelper.hxx>
+
+#include <svtools/sfxecode.hxx>
+#include <unotools/saveopt.hxx>
+#include <comphelper/genericpropertyset.hxx>
+#include <comphelper/propertysetinfo.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <comphelper/documentconstants.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <comphelper/sequence.hxx>
+
+#include <osl/diagnose.h>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/xml/sax/Writer.hpp>
+#include <com/sun/star/xml/sax/FastToken.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/StorageFactory.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/xml/sax/Parser.hpp>
+#include <com/sun/star/xml/sax/SAXParseException.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#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 <sal/log.hxx>
+#include <xmloff/xmlnmspe.hxx>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::osl::MutexGuard;
+
+namespace
+{
+char const sXML_metaStreamName[] = "meta.xml";
+char const sXML_styleStreamName[] = "styles.xml";
+char const sXML_contentStreamName[] = "content.xml";
+
+
+uno::Reference< embed::XStorage > lcl_getWriteStorage(
+ const Sequence< beans::PropertyValue >& rMediaDescriptor,
+ const uno::Reference< uno::XComponentContext >& xContext,const OUString& _sMediaType)
+{
+ uno::Reference< embed::XStorage > xStorage;
+ try
+ {
+ apphelper::MediaDescriptorHelper aMDHelper( rMediaDescriptor );
+ if( aMDHelper.ISSET_Storage )
+ {
+ xStorage = aMDHelper.Storage;
+ }
+ else
+ {
+ Reference< lang::XSingleServiceFactory > xStorageFact( embed::StorageFactory::create( xContext ) );
+
+ std::vector< beans::PropertyValue > aPropertiesForStorage;
+
+ for( sal_Int32 i=rMediaDescriptor.getLength(); i--; )
+ {
+ // properties understood by storage factory
+ // (see package/source/xstor/xfactory.cxx for details)
+ if ( rMediaDescriptor[i].Name == "InteractionHandler" || rMediaDescriptor[i].Name == "Password" || rMediaDescriptor[i].Name == "RepairPackage" )
+ {
+ aPropertiesForStorage.push_back( rMediaDescriptor[i] );
+ }
+ }
+
+ if( aMDHelper.ISSET_Storage )
+ xStorage.set( aMDHelper.Storage );
+ else
+ {
+ Sequence< uno::Any > aStorageArgs( 3 );
+ if( aMDHelper.ISSET_OutputStream )
+ aStorageArgs[0] <<= aMDHelper.OutputStream;
+ else
+ aStorageArgs[0] <<= aMDHelper.URL;
+ aStorageArgs[1] <<= (embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE);
+ aStorageArgs[2] <<= comphelper::containerToSequence( aPropertiesForStorage );
+
+ xStorage.set(
+ xStorageFact->createInstanceWithArguments( aStorageArgs ),
+ uno::UNO_QUERY_THROW );
+ }
+ }
+
+ // set correct media type at storage
+ uno::Reference<beans::XPropertySet> xProp(xStorage,uno::UNO_QUERY);
+ OUString aMediaType;
+ if ( ! xProp.is() ||
+ ! ( xProp->getPropertyValue( "MediaType") >>= aMediaType ) ||
+ ( aMediaType.isEmpty() ))
+ {
+ xProp->setPropertyValue( "MediaType", uno::Any( _sMediaType ));
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return xStorage;
+}
+
+uno::Reference< embed::XStorage > lcl_getReadStorage(
+ const Sequence< beans::PropertyValue >& rMediaDescriptor,
+ const uno::Reference< uno::XComponentContext >& xContext)
+{
+ uno::Reference< embed::XStorage > xStorage;
+
+ try
+ {
+ apphelper::MediaDescriptorHelper aMDHelper( rMediaDescriptor );
+ if( aMDHelper.ISSET_Storage )
+ {
+ xStorage = aMDHelper.Storage;
+ }
+ else
+ {
+ // get XStream from MediaDescriptor
+ uno::Reference< io::XInputStream > xStream;
+ std::vector< beans::PropertyValue > aPropertiesForStorage;
+ for( sal_Int32 i=rMediaDescriptor.getLength(); i--; )
+ {
+ if( rMediaDescriptor[i].Name == "InputStream" )
+ xStream.set( rMediaDescriptor[i].Value, uno::UNO_QUERY );
+
+ // properties understood by storage factory
+ // (see package/source/xstor/xfactory.cxx for details)
+ if ( rMediaDescriptor[i].Name == "InteractionHandler" || rMediaDescriptor[i].Name == "Password" || rMediaDescriptor[i].Name == "RepairPackage" )
+ {
+ aPropertiesForStorage.push_back( rMediaDescriptor[i] );
+ }
+ }
+ OSL_ENSURE( xStream.is(), "No Stream" );
+ if( ! xStream.is())
+ return xStorage;
+
+ // convert XInputStream to XStorage via the storage factory
+ Reference< lang::XSingleServiceFactory > xStorageFact( embed::StorageFactory::create( xContext ) );
+ Sequence< uno::Any > aStorageArgs( 3 );
+ aStorageArgs[0] <<= xStream;
+ aStorageArgs[1] <<= (embed::ElementModes::READ | embed::ElementModes::NOCREATE);
+ aStorageArgs[2] <<= comphelper::containerToSequence( aPropertiesForStorage );
+ xStorage.set(
+ xStorageFact->createInstanceWithArguments( aStorageArgs ), uno::UNO_QUERY_THROW );
+ }
+
+ OSL_ENSURE( xStorage.is(), "No Storage" );
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xStorage;
+}
+
+} // anonymous namespace
+
+namespace chart
+{
+
+XMLFilter::XMLFilter( Reference< uno::XComponentContext > const & xContext ) :
+ m_xContext( xContext ),
+ m_bCancelOperation( false )
+{}
+
+XMLFilter::~XMLFilter()
+{}
+
+// ____ XFilter ____
+sal_Bool SAL_CALL XMLFilter::filter(
+ const Sequence< beans::PropertyValue >& aDescriptor )
+{
+ bool bResult = false;
+
+ 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" );
+ if( impl_Export( m_xSourceDoc,
+ aDescriptor ) == ERRCODE_NONE )
+ {
+ m_xSourceDoc = nullptr;
+ bResult = true;
+ }
+ }
+ else if( m_xTargetDoc.is())
+ {
+ if( impl_Import( m_xTargetDoc,
+ aDescriptor ) == ERRCODE_NONE )
+ {
+ m_xTargetDoc = nullptr;
+ bResult = true;
+ }
+ }
+ else
+ {
+ OSL_FAIL( "filter() called with no document set" );
+ }
+
+ return bResult;
+}
+
+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 ____
+void SAL_CALL XMLFilter::setTargetDocument(
+ const Reference< lang::XComponent >& Document )
+{
+ MutexGuard aGuard( m_aMutex );
+ OSL_ENSURE( ! m_xSourceDoc.is(), "Setting target doc while source doc is set" );
+
+ m_xTargetDoc = Document;
+}
+
+// ____ XExporter ____
+void SAL_CALL XMLFilter::setSourceDocument(
+ const Reference< lang::XComponent >& Document )
+{
+ MutexGuard aGuard( m_aMutex );
+ OSL_ENSURE( ! m_xTargetDoc.is(), "Setting source doc while target doc is set" );
+
+ m_xSourceDoc = Document;
+}
+
+ErrCode XMLFilter::impl_Import(
+ const Reference< lang::XComponent > & xDocumentComp,
+ const Sequence< beans::PropertyValue > & rMediaDescriptor )
+{
+ ErrCode nWarning = ERRCODE_NONE;
+
+ OSL_ENSURE( xDocumentComp.is(), "Import: No Model" );
+ OSL_ENSURE( m_xContext.is(), "Import: No ComponentContext" );
+
+ if( ! (xDocumentComp.is() &&
+ m_xContext.is()))
+ return nWarning;
+
+ try
+ {
+ Reference< lang::XServiceInfo > xServInfo( xDocumentComp, uno::UNO_QUERY_THROW );
+ if( ! xServInfo->supportsService( "com.sun.star.chart2.ChartDocument"))
+ {
+ OSL_FAIL( "Import: No ChartDocument" );
+ return ERRCODE_SFX_GENERAL;
+ }
+
+ Reference< lang::XMultiComponentFactory > xFactory( m_xContext->getServiceManager());
+ OSL_ENSURE( xFactory.is(), "Import: No Factory" );
+ if( ! xFactory.is())
+ return ERRCODE_SFX_GENERAL;
+
+ bool bOasis = true;
+ isOasisFormat( rMediaDescriptor, bOasis );
+ Reference< embed::XStorage > xStorage( lcl_getReadStorage( rMediaDescriptor, m_xContext));
+ if( ! xStorage.is())
+ return ERRCODE_SFX_GENERAL;
+
+ uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler;
+ uno::Reference<lang::XMultiServiceFactory> xServiceFactory(xFactory, uno::UNO_QUERY);
+ if (xServiceFactory.is())
+ {
+ uno::Sequence<uno::Any> aArgs(1);
+ aArgs[0] <<= xStorage;
+ xGraphicStorageHandler.set(
+ xServiceFactory->createInstanceWithArguments(
+ "com.sun.star.comp.Svx.GraphicImportHelper", aArgs), uno::UNO_QUERY);
+ }
+
+ // create XPropertySet with extra information for the filter
+ /** property map for import info set */
+ 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},
+ { OUString("ProgressMax"), 0, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
+ { OUString("ProgressCurrent"), 0, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
+ { OUString("PrivateData"), 0, cppu::UnoType<XInterface>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
+ { OUString("BaseURI"), 0, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
+ { 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(
+ new comphelper::PropertySetInfo( aImportInfoMap ) ) );
+
+ // Set base URI and Hierarchical Name
+ OUString aHierarchName, aBaseUri;
+ // why retrieve this from the model when it's available as rMediaDescriptor?
+ uno::Reference<frame::XModel> const xModel(m_xTargetDoc, uno::UNO_QUERY);
+ if( xModel.is() )
+ {
+ const uno::Sequence< beans::PropertyValue > aModProps = xModel->getArgs();
+ for( beans::PropertyValue const & prop : aModProps )
+ {
+ if( prop.Name == "HierarchicalDocumentName" )
+ {
+ // Actually this argument only has meaning for embedded documents
+ prop.Value >>= aHierarchName;
+ }
+ else if( prop.Name == "DocumentBaseURL" )
+ {
+ prop.Value >>= aBaseUri;
+ }
+ }
+ }
+
+ // needed for relative URLs, but in clipboard copy/paste there may be none
+ SAL_INFO_IF(aBaseUri.isEmpty(), "chart2", "chart::XMLFilter: no base URL");
+ if( !aBaseUri.isEmpty() )
+ xImportInfo->setPropertyValue( "BaseURI", uno::Any( aBaseUri ) );
+
+ if( !aHierarchName.isEmpty() )
+ xImportInfo->setPropertyValue( "StreamRelPath", uno::Any( aHierarchName ) );
+
+ // import meta information
+ if( bOasis )
+ nWarning = impl_ImportStream(
+ sXML_metaStreamName,
+ "com.sun.star.comp.Chart.XMLOasisMetaImporter",
+ xStorage, xFactory, xGraphicStorageHandler, xImportInfo );
+
+ // import styles
+ ErrCode nTmpErr = impl_ImportStream(
+ sXML_styleStreamName,
+ bOasis
+ ? OUString("com.sun.star.comp.Chart.XMLOasisStylesImporter")
+ : OUString("com.sun.star.comp.Chart.XMLStylesImporter"),
+ xStorage, xFactory, xGraphicStorageHandler, xImportInfo );
+ nWarning = nWarning != ERRCODE_NONE ? nWarning : nTmpErr;
+
+ // import content
+ ErrCode nContentWarning = impl_ImportStream(
+ sXML_contentStreamName,
+ bOasis
+ ? OUString("com.sun.star.comp.Chart.XMLOasisContentImporter")
+ : OUString("com.sun.star.comp.Chart.XMLContentImporter"),
+ xStorage, xFactory, xGraphicStorageHandler, xImportInfo );
+ nWarning = nWarning != ERRCODE_NONE ? nWarning : nContentWarning;
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+
+ // something went awry
+ nWarning = ERRCODE_SFX_GENERAL;
+ }
+
+ return nWarning;
+}
+
+ErrCode XMLFilter::impl_ImportStream(
+ const OUString & rStreamName,
+ const OUString & rServiceName,
+ const Reference< embed::XStorage > & xStorage,
+ const Reference< lang::XMultiComponentFactory > & xFactory,
+ const Reference< document::XGraphicStorageHandler > & xGraphicStorageHandler,
+ uno::Reference< beans::XPropertySet > const & xImportInfo )
+{
+ ErrCode nWarning = ERRCODE_SFX_GENERAL;
+
+ if( ! (xStorage.is() &&
+ xStorage->hasByName( rStreamName )))
+ return ERRCODE_NONE;
+
+ if( xImportInfo.is() )
+ xImportInfo->setPropertyValue( "StreamName", uno::Any( rStreamName ) );
+
+ if( xStorage.is() &&
+ xStorage->isStreamElement( rStreamName ) )
+ {
+ try
+ {
+ auto xInputStream =
+ xStorage->openStreamElement(
+ rStreamName,
+ embed::ElementModes::READ | embed::ElementModes::NOCREATE );
+
+ // todo: encryption
+
+ if( xInputStream.is())
+ {
+ sal_Int32 nArgs = 0;
+ if( xGraphicStorageHandler.is())
+ nArgs++;
+ if( xImportInfo.is())
+ nArgs++;
+
+ uno::Sequence< uno::Any > aFilterCompArgs( nArgs );
+
+ nArgs = 0;
+ if( xGraphicStorageHandler.is())
+ aFilterCompArgs[nArgs++] <<= xGraphicStorageHandler;
+ if( xImportInfo.is())
+ aFilterCompArgs[ nArgs++ ] <<= xImportInfo;
+
+ // the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler
+ Reference< xml::sax::XDocumentHandler > xDocHandler(
+ xFactory->createInstanceWithArgumentsAndContext( rServiceName, aFilterCompArgs, m_xContext ),
+ uno::UNO_QUERY_THROW );
+
+ Reference< document::XImporter > xImporter( xDocHandler, uno::UNO_QUERY_THROW );
+ xImporter->setTargetDocument( Reference< lang::XComponent >( m_xTargetDoc, uno::UNO_SET_THROW ));
+
+ if ( !m_sDocumentHandler.isEmpty() )
+ {
+ try
+ {
+ uno::Sequence< uno::Any > aArgs(2);
+ beans::NamedValue aValue;
+ aValue.Name = "DocumentHandler";
+ aValue.Value <<= xDocHandler;
+ aArgs[0] <<= aValue;
+ aValue.Name = "Model";
+ aValue.Value <<= m_xTargetDoc;
+ aArgs[1] <<= aValue;
+
+ xDocHandler.set(xFactory->createInstanceWithArgumentsAndContext(m_sDocumentHandler,aArgs,m_xContext), uno::UNO_QUERY_THROW );
+ }
+ catch (const uno::Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "");
+ }
+ }
+ xml::sax::InputSource aParserInput;
+ aParserInput.aInputStream.set(xInputStream, uno::UNO_QUERY_THROW);
+
+ // the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler
+ Reference< xml::sax::XFastParser > xFastParser(xDocHandler, uno::UNO_QUERY);
+ if (xFastParser.is())
+ xFastParser->parseStream(aParserInput);
+ else
+ {
+ Reference<xml::sax::XParser> xParser = xml::sax::Parser::create(m_xContext);
+ xParser->setDocumentHandler( xDocHandler );
+ xParser->parseStream(aParserInput);
+ }
+ }
+
+ // load was successful
+ nWarning = ERRCODE_NONE;
+ }
+ catch (const xml::sax::SAXParseException&)
+ {
+ // todo: if encrypted: ERRCODE_SFX_WRONGPASSWORD
+ }
+ catch (const xml::sax::SAXException&)
+ {
+ // todo: if encrypted: ERRCODE_SFX_WRONGPASSWORD
+ }
+ catch (const packages::zip::ZipIOException&)
+ {
+ nWarning = ERRCODE_IO_BROKENPACKAGE;
+ }
+ catch (const io::IOException&)
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "");
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return nWarning;
+}
+
+ErrCode XMLFilter::impl_Export(
+ const Reference< lang::XComponent > & xDocumentComp,
+ const Sequence< beans::PropertyValue > & rMediaDescriptor )
+{
+ m_aMediaDescriptor = rMediaDescriptor;
+ //save
+
+ ErrCode nWarning = ERRCODE_NONE;
+
+ OSL_ENSURE( xDocumentComp.is(), "Export: No Model" );
+ OSL_ENSURE( m_xContext.is(), "Export: No ComponentContext" );
+
+ if( !xDocumentComp.is() || !m_xContext.is() )
+ return nWarning;
+
+ try
+ {
+ Reference< lang::XServiceInfo > xServInfo( xDocumentComp, uno::UNO_QUERY_THROW );
+ if( ! xServInfo->supportsService( "com.sun.star.chart2.ChartDocument"))
+ {
+ OSL_FAIL( "Export: No ChartDocument" );
+ return ERRCODE_SFX_GENERAL;
+ }
+
+ Reference< lang::XMultiComponentFactory > xFactory( m_xContext->getServiceManager());
+ OSL_ENSURE( xFactory.is(), "Export: No Factory" );
+ if( ! xFactory.is())
+ return ERRCODE_SFX_GENERAL;
+ uno::Reference< lang::XMultiServiceFactory > xServiceFactory( m_xContext->getServiceManager(), uno::UNO_QUERY);
+ if( ! xServiceFactory.is())
+ return ERRCODE_SFX_GENERAL;
+
+ uno::Reference< xml::sax::XWriter > xSaxWriter = xml::sax::Writer::create(m_xContext);
+
+ bool bOasis = true;
+ isOasisFormat( rMediaDescriptor, bOasis );
+
+ uno::Reference< embed::XStorage > xStorage( lcl_getWriteStorage( rMediaDescriptor, m_xContext, getMediaType(bOasis) ) );
+ OSL_ENSURE( xStorage.is(), "No Storage" );
+ if( ! xStorage.is())
+ return ERRCODE_SFX_GENERAL;
+
+ uno::Reference< xml::sax::XDocumentHandler> xDocHandler = xSaxWriter;
+
+ if ( !m_sDocumentHandler.isEmpty() )
+ {
+ try
+ {
+ uno::Sequence< uno::Any > aArgs(2);
+ beans::NamedValue aValue;
+ aValue.Name = "DocumentHandler";
+ aValue.Value <<= xDocHandler;
+ aArgs[0] <<= aValue;
+ aValue.Name = "Model";
+ aValue.Value <<= xDocumentComp;
+ aArgs[1] <<= aValue;
+
+ xDocHandler.set(xServiceFactory->createInstanceWithArguments(m_sDocumentHandler,aArgs), uno::UNO_QUERY );
+ xSaxWriter.set(xDocHandler,uno::UNO_QUERY);
+ }
+ catch (const uno::Exception&)
+ {
+ OSL_FAIL("Exception caught!");
+ }
+ }
+
+ Reference<document::XGraphicStorageHandler> xGraphicStorageHandler;
+ xGraphicStorageHandler.set(document::GraphicStorageHandler::createWithStorage(m_xContext, xStorage));
+
+ // property map for export info set
+ 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 =
+ comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) );
+
+ SvtSaveOptions aSaveOpt;
+ bool bUsePrettyPrinting( aSaveOpt.IsPrettyPrinting() );
+ xInfoSet->setPropertyValue( "UsePrettyPrinting", uno::Any( bUsePrettyPrinting ) );
+ if( ! bOasis )
+ xInfoSet->setPropertyValue( "ExportTableNumberList", uno::Any( true ));
+
+ sal_Int32 nArgs = 2;
+ if( xGraphicStorageHandler.is())
+ nArgs++;
+
+ uno::Sequence< uno::Any > aFilterProperties( nArgs );
+ {
+ nArgs = 0;
+ aFilterProperties[ nArgs++ ] <<= xInfoSet;
+ aFilterProperties[ nArgs++ ] <<= xDocHandler;
+ if( xGraphicStorageHandler.is())
+ aFilterProperties[ nArgs++ ] <<= xGraphicStorageHandler;
+ }
+
+ // export meta information
+ if( bOasis )
+ nWarning = impl_ExportStream(
+ sXML_metaStreamName,
+ "com.sun.star.comp.Chart.XMLOasisMetaExporter",
+ xStorage, xSaxWriter, xServiceFactory, aFilterProperties );
+
+ // export styles
+ ErrCode nTmp = impl_ExportStream(
+ sXML_styleStreamName,
+ bOasis
+ ? OUString("com.sun.star.comp.Chart.XMLOasisStylesExporter")
+ : OUString("com.sun.star.comp.Chart.XMLStylesExporter"), // soffice 6/7
+ xStorage, xSaxWriter, xServiceFactory, aFilterProperties );
+ nWarning = nWarning != ERRCODE_NONE ? nWarning : nTmp;
+
+ // export content
+ ErrCode nContentWarning = impl_ExportStream(
+ sXML_contentStreamName,
+ bOasis
+ ? OUString("com.sun.star.comp.Chart.XMLOasisContentExporter")
+ : OUString("com.sun.star.comp.Chart.XMLContentExporter"),
+ xStorage, xSaxWriter, xServiceFactory, aFilterProperties );
+ nWarning = nWarning != ERRCODE_NONE ? nWarning : nContentWarning;
+
+ Reference< lang::XComponent > xComp(xGraphicStorageHandler, uno::UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+
+ uno::Reference<embed::XTransactedObject> xTransact( xStorage ,uno::UNO_QUERY);
+ if ( xTransact.is() )
+ xTransact->commit();
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+
+ // something went awry
+ nWarning = ERRCODE_SFX_GENERAL;
+ }
+
+ return nWarning;
+}
+
+ErrCode XMLFilter::impl_ExportStream(
+ const OUString & rStreamName,
+ const OUString & rServiceName,
+ const Reference< embed::XStorage > & xStorage,
+ const uno::Reference< xml::sax::XWriter >& xActiveDataSource,
+ const Reference< lang::XMultiServiceFactory >& xServiceFactory,
+ const Sequence< uno::Any > & rFilterProperties )
+{
+ try
+ {
+ if( !xServiceFactory.is() )
+ return ERRCODE_SFX_GENERAL;
+ if( !xStorage.is() )
+ return ERRCODE_SFX_GENERAL;
+ if ( !xActiveDataSource.is() )
+ return ERRCODE_SFX_GENERAL;
+
+ uno::Reference< io::XStream > xStream( xStorage->openStreamElement(
+ rStreamName, embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE ) );
+ if ( !xStream.is() )
+ return ERRCODE_SFX_GENERAL;
+ uno::Reference< io::XOutputStream > xOutputStream( xStream->getOutputStream() );
+ if ( !xOutputStream.is() )
+ return ERRCODE_SFX_GENERAL;
+
+ uno::Reference< beans::XPropertySet > xStreamProp( xOutputStream, uno::UNO_QUERY );
+ if(xStreamProp.is()) try
+ {
+ xStreamProp->setPropertyValue( "MediaType", uno::Any( OUString("text/xml") ) );
+ xStreamProp->setPropertyValue( "Compressed", uno::Any( true ) );//@todo?
+ xStreamProp->setPropertyValue( "UseCommonStoragePasswordEncryption", uno::Any( true ) );
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ xActiveDataSource->setOutputStream(xOutputStream);
+
+ // set Base URL
+ {
+ uno::Reference< beans::XPropertySet > xInfoSet;
+ if( rFilterProperties.hasElements() )
+ rFilterProperties.getConstArray()[0] >>= xInfoSet;
+ OSL_ENSURE( xInfoSet.is(), "missing infoset for export" );
+ if( xInfoSet.is() )
+ xInfoSet->setPropertyValue( "StreamName", uno::Any( rStreamName ) );
+ }
+
+ Reference< XExporter > xExporter( xServiceFactory->createInstanceWithArguments(
+ rServiceName, rFilterProperties ), uno::UNO_QUERY);
+ if ( !xExporter.is() )
+ return ERRCODE_SFX_GENERAL;
+
+ xExporter->setSourceDocument( m_xSourceDoc );
+
+ uno::Reference< document::XFilter > xFilter( xExporter, uno::UNO_QUERY );
+ if ( !xFilter.is() )
+ return ERRCODE_SFX_GENERAL;
+
+ xFilter->filter(m_aMediaDescriptor);
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return ERRCODE_NONE;
+}
+
+void XMLFilter::isOasisFormat(const Sequence< beans::PropertyValue >& _rMediaDescriptor, bool & rOutOASIS )
+{
+ apphelper::MediaDescriptorHelper aMDHelper( _rMediaDescriptor );
+ if( aMDHelper.ISSET_FilterName )
+ rOutOASIS = aMDHelper.FilterName == "chart8";
+}
+OUString XMLFilter::getMediaType(bool _bOasis)
+{
+ return _bOasis ? OUString(MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII) : OUString(MIMETYPE_VND_SUN_XML_CHART_ASCII);
+}
+
+OUString SAL_CALL XMLFilter::getImplementationName()
+{
+ return "com.sun.star.comp.chart2.XMLFilter";
+}
+
+sal_Bool SAL_CALL XMLFilter::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL XMLFilter::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.document.ImportFilter",
+ "com.sun.star.document.ExportFilter"
+ };
+ // todo: services are incomplete. Missing:
+ // XInitialization, XNamed
+}
+
+void XMLReportFilterHelper::isOasisFormat(const Sequence< beans::PropertyValue >& _rMediaDescriptor, bool & rOutOASIS )
+{
+ apphelper::MediaDescriptorHelper aMDHelper( _rMediaDescriptor );
+ if( aMDHelper.ISSET_FilterName )
+ rOutOASIS = aMDHelper.FilterName == "StarOffice XML (Base) Report Chart";
+}
+OUString XMLReportFilterHelper::getMediaType(bool )
+{
+ return MIMETYPE_OASIS_OPENDOCUMENT_REPORT_CHART_ASCII;
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_XMLFilter_get_implementation(css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::XMLFilter(context));
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_report_XMLFilter_get_implementation(css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::XMLReportFilterHelper(context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/BaseCoordinateSystem.hxx b/chart2/source/model/inc/BaseCoordinateSystem.hxx
new file mode 100644
index 000000000..1f20e83a0
--- /dev/null
+++ b/chart2/source/model/inc/BaseCoordinateSystem.hxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_INC_BASECOORDINATESYSTEM_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_INC_BASECOORDINATESYSTEM_HXX
+
+#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
+
+// INCLUDED_CHART2_SOURCE_MODEL_INC_BASECOORDINATESYSTEM_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/CartesianCoordinateSystem.hxx b/chart2/source/model/inc/CartesianCoordinateSystem.hxx
new file mode 100644
index 000000000..7b2847cd8
--- /dev/null
+++ b/chart2/source/model/inc/CartesianCoordinateSystem.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_INC_CARTESIANCOORDINATESYSTEM_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_INC_CARTESIANCOORDINATESYSTEM_HXX
+
+#include "BaseCoordinateSystem.hxx"
+
+namespace chart
+{
+
+class CartesianCoordinateSystem : public BaseCoordinateSystem
+{
+public:
+ explicit CartesianCoordinateSystem( sal_Int32 nDimensionCount );
+ explicit CartesianCoordinateSystem( const CartesianCoordinateSystem & rSource );
+ virtual ~CartesianCoordinateSystem() override;
+
+ // ____ XCoordinateSystem ____
+ virtual OUString SAL_CALL getCoordinateSystemType() override;
+ virtual OUString SAL_CALL getViewServiceName() override;
+
+ // ____ XCloneable ____
+ virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+
+ // ____ XServiceInfo ____
+ 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;
+};
+
+class CartesianCoordinateSystem2d : public CartesianCoordinateSystem
+{
+public:
+ explicit CartesianCoordinateSystem2d();
+ virtual ~CartesianCoordinateSystem2d() override;
+
+ // ____ XServiceInfo ____
+ 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;
+};
+
+class CartesianCoordinateSystem3d : public CartesianCoordinateSystem
+{
+public:
+ explicit CartesianCoordinateSystem3d();
+ virtual ~CartesianCoordinateSystem3d() override;
+
+ // ____ XServiceInfo ____
+ 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;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_INC_CARTESIANCOORDINATESYSTEM_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/ChartTypeManager.hxx b/chart2/source/model/inc/ChartTypeManager.hxx
new file mode 100644
index 000000000..176681564
--- /dev/null
+++ b/chart2/source/model/inc/ChartTypeManager.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_INC_CHARTTYPEMANAGER_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_INC_CHARTTYPEMANAGER_HXX
+
+#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
+
+// INCLUDED_CHART2_SOURCE_MODEL_INC_CHARTTYPEMANAGER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/DataSeries.hxx b/chart2/source/model/inc/DataSeries.hxx
new file mode 100644
index 000000000..7a571f1eb
--- /dev/null
+++ b/chart2/source/model/inc/DataSeries.hxx
@@ -0,0 +1,172 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_INC_DATASERIES_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_INC_DATASERIES_HXX
+
+// 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
+
+// INCLUDED_CHART2_SOURCE_MODEL_INC_DATASERIES_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/Diagram.hxx b/chart2/source/model/inc/Diagram.hxx
new file mode 100644
index 000000000..c909f183f
--- /dev/null
+++ b/chart2/source/model/inc/Diagram.hxx
@@ -0,0 +1,186 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_INC_DIAGRAM_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_INC_DIAGRAM_HXX
+
+#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
+
+// INCLUDED_CHART2_SOURCE_MODEL_INC_DIAGRAM_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/PolarCoordinateSystem.hxx b/chart2/source/model/inc/PolarCoordinateSystem.hxx
new file mode 100644
index 000000000..4572201f5
--- /dev/null
+++ b/chart2/source/model/inc/PolarCoordinateSystem.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_INC_POLARCOORDINATESYSTEM_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_INC_POLARCOORDINATESYSTEM_HXX
+
+#include "BaseCoordinateSystem.hxx"
+
+namespace chart
+{
+
+class PolarCoordinateSystem : public BaseCoordinateSystem
+{
+public:
+ explicit PolarCoordinateSystem( sal_Int32 nDimensionCount );
+ explicit PolarCoordinateSystem( const PolarCoordinateSystem & rSource );
+ virtual ~PolarCoordinateSystem() override;
+
+ // ____ XCoordinateSystem ____
+ virtual OUString SAL_CALL getCoordinateSystemType() override;
+ virtual OUString SAL_CALL getViewServiceName() override;
+
+ // ____ XCloneable ____
+ virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+
+ // ____ XServiceInfo ____
+ 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;
+};
+
+class PolarCoordinateSystem2d : public PolarCoordinateSystem
+{
+public:
+ explicit PolarCoordinateSystem2d();
+ virtual ~PolarCoordinateSystem2d() override;
+
+ // ____ XServiceInfo ____
+ 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;
+};
+
+class PolarCoordinateSystem3d : public PolarCoordinateSystem
+{
+public:
+ explicit PolarCoordinateSystem3d();
+ virtual ~PolarCoordinateSystem3d() override;
+
+ // ____ XServiceInfo ____
+ 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;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_INC_POLARCOORDINATESYSTEM_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/StockBar.hxx b/chart2/source/model/inc/StockBar.hxx
new file mode 100644
index 000000000..b1247e584
--- /dev/null
+++ b/chart2/source/model/inc/StockBar.hxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_INC_STOCKBAR_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_INC_STOCKBAR_HXX
+
+#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>
+
+namespace chart
+{
+
+namespace impl
+{
+typedef ::cppu::WeakImplHelper<
+ css::util::XCloneable,
+ css::util::XModifyBroadcaster,
+ css::util::XModifyListener >
+ StockBar_Base;
+}
+
+class StockBar final :
+ public MutexContainer,
+ public impl::StockBar_Base,
+ public ::property::OPropertySet
+{
+public:
+ explicit StockBar( bool bRisingCourse );
+ virtual ~StockBar() override;
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+
+private:
+ explicit StockBar( const StockBar & 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
+
+// INCLUDED_CHART2_SOURCE_MODEL_INC_STOCKBAR_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/XMLFilter.hxx b/chart2/source/model/inc/XMLFilter.hxx
new file mode 100644
index 000000000..4f4ba101a
--- /dev/null
+++ b/chart2/source/model/inc/XMLFilter.hxx
@@ -0,0 +1,171 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_INC_XMLFILTER_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_INC_XMLFILTER_HXX
+
+#include <cppuhelper/implbase.hxx>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#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>
+
+namespace com::sun::star::beans { class XPropertySet; }
+namespace com::sun::star::uno { class XComponentContext; }
+namespace com::sun::star::xml::sax { class XWriter; }
+namespace com::sun::star::lang { class XMultiComponentFactory; }
+
+namespace com::sun::star {
+ namespace embed {
+ class XStorage;
+ }
+ namespace xml::sax {
+ class XFastParser;
+ }
+ namespace document {
+ class XGraphicStorageHandler;
+ }
+}
+
+namespace chart
+{
+
+class XMLFilter : public
+ ::cppu::WeakImplHelper<
+ css::document::XFilter,
+ css::document::XExporter,
+ css::document::XImporter,
+ css::lang::XServiceInfo >
+{
+public:
+ explicit XMLFilter( css::uno::Reference< css::uno::XComponentContext > const & xContext );
+ virtual ~XMLFilter() 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;
+
+protected:
+ // ____ XFilter ____
+ virtual sal_Bool SAL_CALL filter(
+ const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
+ virtual void SAL_CALL cancel() override;
+
+ // ____ XImporter ____
+ virtual void SAL_CALL setTargetDocument(
+ const css::uno::Reference< css::lang::XComponent >& Document ) override;
+
+ // ____ XExporter ____
+ virtual void SAL_CALL setSourceDocument(
+ const css::uno::Reference< css::lang::XComponent >& Document ) override;
+
+ void setDocumentHandler(const OUString& _sDocumentHandler) { m_sDocumentHandler = _sDocumentHandler; }
+
+ virtual OUString getMediaType(bool _bOasis);
+
+ /** fills the oasis flag only when a filtername was set
+ *
+ * \param _rMediaDescriptor
+ * \param _rOutOASIS
+ */
+ virtual void isOasisFormat(const css::uno::Sequence< css::beans::PropertyValue >& _rMediaDescriptor, bool & _rOutOASIS );
+
+private:
+ // methods
+
+ /// @return a warning code, or 0 for successful operation
+ ErrCode impl_Import( const css::uno::Reference< css::lang::XComponent > & xDocumentComp,
+ const css::uno::Sequence< css::beans::PropertyValue > & aMediaDescriptor );
+ /// @return a warning code, or 0 for successful operation
+ ErrCode impl_ImportStream(
+ const OUString & rStreamName,
+ const OUString & rServiceName,
+ const css::uno::Reference< css::embed::XStorage > & xStorage,
+ const css::uno::Reference< css::lang::XMultiComponentFactory > & xFactory,
+ const css::uno::Reference<css::document::XGraphicStorageHandler> & xGraphicStorageHandler,
+ css::uno::Reference< css::beans::XPropertySet > const & xPropSet );
+
+ /// @return a warning code, or 0 for successful operation
+ ErrCode impl_Export( const css::uno::Reference< css::lang::XComponent > & xDocumentComp,
+ const css::uno::Sequence< css::beans::PropertyValue > & aMediaDescriptor );
+ /// @return a warning code, or 0 for successful operation
+ ErrCode impl_ExportStream(
+ const OUString & rStreamName,
+ const OUString & rServiceName,
+ const css::uno::Reference< css::embed::XStorage > & xStorage,
+ const css::uno::Reference< css::xml::sax::XWriter >& xActiveDataSource,
+ const css::uno::Reference< css::lang::XMultiServiceFactory > & xFactory,
+ const css::uno::Sequence< css::uno::Any > & rFilterProperties );
+
+ // members
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+ css::uno::Reference< css::lang::XComponent > m_xTargetDoc;
+ css::uno::Reference< css::lang::XComponent > m_xSourceDoc;
+
+ 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
+{
+ virtual void isOasisFormat(const css::uno::Sequence< css::beans::PropertyValue >& _rMediaDescriptor,
+ bool & _rOutOASIS ) override;
+public:
+ explicit XMLReportFilterHelper( css::uno::Reference< css::uno::XComponentContext > const & _xContext )
+ :XMLFilter(_xContext)
+ {}
+protected:
+ virtual OUString SAL_CALL
+ getImplementationName() override
+ {
+ return "com.sun.star.comp.chart2.report.XMLFilter";
+ }
+ // ____ XImporter ____
+ virtual void SAL_CALL setTargetDocument(
+ const css::uno::Reference< css::lang::XComponent >& Document ) override
+ {
+ setDocumentHandler( "com.sun.star.comp.report.ImportDocumentHandler" );
+ XMLFilter::setTargetDocument(Document);
+ }
+
+ // ____ XExporter ____
+ virtual void SAL_CALL setSourceDocument(
+ const css::uno::Reference< css::lang::XComponent >& Document ) override
+ {
+ setDocumentHandler( "com.sun.star.comp.report.ExportDocumentHandler" );
+ XMLFilter::setSourceDocument(Document);
+ }
+
+ virtual OUString getMediaType(bool _bOasis) override;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_INC_XMLFILTER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/Axis.cxx b/chart2/source/model/main/Axis.cxx
new file mode 100644
index 000000000..ff42899d0
--- /dev/null
+++ b/chart2/source/model/main/Axis.cxx
@@ -0,0 +1,632 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "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 <unonames.hxx>
+
+#include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
+#include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
+#include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
+#include <com/sun/star/chart/ChartAxisPosition.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <cppuhelper/supportsservice.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <vector>
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans::PropertyAttribute;
+
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::beans::Property;
+using ::osl::MutexGuard;
+
+namespace
+{
+
+enum
+{
+ PROP_AXIS_SHOW,
+ PROP_AXIS_CROSSOVER_POSITION,
+ PROP_AXIS_CROSSOVER_VALUE,
+ PROP_AXIS_DISPLAY_LABELS,
+ PROP_AXIS_NUMBERFORMAT,
+ PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
+ PROP_AXIS_LABEL_POSITION,
+ PROP_AXIS_TEXT_ROTATION,
+ PROP_AXIS_TEXT_BREAK,
+ PROP_AXIS_TEXT_OVERLAP,
+ PROP_AXIS_TEXT_STACKED,
+ PROP_AXIS_TEXT_ARRANGE_ORDER,
+ PROP_AXIS_REFERENCE_DIAGRAM_SIZE,
+
+ PROP_AXIS_MAJOR_TICKMARKS,
+ PROP_AXIS_MINOR_TICKMARKS,
+ PROP_AXIS_MARK_POSITION,
+
+ PROP_AXIS_DISPLAY_UNITS,
+ PROP_AXIS_BUILTINUNIT,
+
+ PROP_AXIS_TRY_STAGGERING_FIRST,
+ PROP_AXIS_MAJOR_ORIGIN
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "Show",
+ PROP_AXIS_SHOW,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "CrossoverPosition",
+ PROP_AXIS_CROSSOVER_POSITION,
+ cppu::UnoType<css::chart::ChartAxisPosition>::get(),
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "CrossoverValue",
+ PROP_AXIS_CROSSOVER_VALUE,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "DisplayLabels",
+ PROP_AXIS_DISPLAY_LABELS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_NUMFMT,
+ PROP_AXIS_NUMBERFORMAT,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_LINK_TO_SRC_NUMFMT,
+ PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "LabelPosition",
+ PROP_AXIS_LABEL_POSITION,
+ cppu::UnoType<css::chart::ChartAxisLabelPosition>::get(),
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "TextRotation",
+ PROP_AXIS_TEXT_ROTATION,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "TextBreak",
+ PROP_AXIS_TEXT_BREAK,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "TextOverlap",
+ PROP_AXIS_TEXT_OVERLAP,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "StackCharacters",
+ PROP_AXIS_TEXT_STACKED,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "ArrangeOrder",
+ PROP_AXIS_TEXT_ARRANGE_ORDER,
+ cppu::UnoType<css::chart::ChartAxisArrangeOrderType>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "ReferencePageSize",
+ PROP_AXIS_REFERENCE_DIAGRAM_SIZE,
+ cppu::UnoType<awt::Size>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "MajorTickmarks",
+ PROP_AXIS_MAJOR_TICKMARKS,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "MinorTickmarks",
+ PROP_AXIS_MINOR_TICKMARKS,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "MarkPosition",
+ PROP_AXIS_MARK_POSITION,
+ cppu::UnoType<css::chart::ChartAxisMarkPosition>::get(),
+ beans::PropertyAttribute::MAYBEDEFAULT );
+
+ //Properties for display units:
+ rOutProperties.emplace_back( "DisplayUnits",
+ PROP_AXIS_DISPLAY_UNITS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ //Properties for labels:
+ rOutProperties.emplace_back( "BuiltInUnit",
+ PROP_AXIS_BUILTINUNIT,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // Compatibility option: starting from LibreOffice 5.1 the rotated
+ // layout is preferred to staggering for axis labels.
+ rOutProperties.emplace_back( "TryStaggeringFirst",
+ PROP_AXIS_TRY_STAGGERING_FIRST,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "MajorOrigin",
+ PROP_AXIS_MAJOR_ORIGIN,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+}
+
+struct StaticAxisDefaults_Initializer
+{
+ ::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 >
+{
+};
+
+struct StaticAxisInfoHelper_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::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 >
+{
+};
+
+struct StaticAxisInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAxisInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+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 );
+}
+
+} // anonymous namespace
+
+namespace chart
+{
+
+Axis::Axis() :
+ ::property::OPropertySet( m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_aScaleData( AxisHelper::createDefaultScale() ),
+ m_xGrid( new GridProperties() ),
+ m_aSubGridProperties(),
+ m_xTitle()
+{
+ osl_atomic_increment(&m_refCount);
+ setFastPropertyValue_NoBroadcast(
+ ::chart::LinePropertiesHelper::PROP_LINE_COLOR, uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
+
+ if( m_xGrid.is())
+ ModifyListenerHelper::addListener( m_xGrid, m_xModifyEventForwarder );
+ if( m_aScaleData.Categories.is())
+ ModifyListenerHelper::addListener( m_aScaleData.Categories, m_xModifyEventForwarder );
+
+ AllocateSubGrids();
+ osl_atomic_decrement(&m_refCount);
+}
+
+Axis::Axis( const Axis & rOther ) :
+ impl::Axis_Base(rOther),
+ ::property::OPropertySet( rOther, m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_aScaleData( rOther.m_aScaleData )
+{
+ m_xGrid.set( CloneHelper::CreateRefClone< beans::XPropertySet >()( 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 );
+
+ m_xTitle.set( CloneHelper::CreateRefClone< chart2::XTitle >()( rOther.m_xTitle ));
+ if( m_xTitle.is())
+ ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
+}
+
+// late initialization to call after copy-constructing
+void Axis::Init()
+{
+ if( m_aScaleData.Categories.is())
+ EventListenerHelper::addListener( m_aScaleData.Categories, this );
+}
+
+Axis::~Axis()
+{
+ try
+ {
+ ModifyListenerHelper::removeListener( m_xGrid, m_xModifyEventForwarder );
+ ModifyListenerHelper::removeListenerFromAllSequenceElements( 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);
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ m_aSubGridProperties.realloc(0);
+ m_xGrid = nullptr;
+ m_xTitle = nullptr;
+}
+
+void Axis::AllocateSubGrids()
+{
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ Reference< lang::XEventListener > xEventListener;
+ std::vector< Reference< beans::XPropertySet > > aOldBroadcasters;
+ std::vector< Reference< beans::XPropertySet > > aNewBroadcasters;
+ {
+ MutexGuard aGuard( m_aMutex );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ xEventListener = this;
+
+ sal_Int32 nNewSubIncCount = m_aScaleData.IncrementData.SubIncrements.getLength();
+ sal_Int32 nOldSubIncCount = m_aSubGridProperties.getLength();
+
+ if( nOldSubIncCount > nNewSubIncCount )
+ {
+ // remove superfluous entries
+ for( sal_Int32 i = nNewSubIncCount; i < nOldSubIncCount; ++i )
+ aOldBroadcasters.push_back( m_aSubGridProperties[ i ] );
+ m_aSubGridProperties.realloc( nNewSubIncCount );
+ }
+ else if( nOldSubIncCount < nNewSubIncCount )
+ {
+ m_aSubGridProperties.realloc( nNewSubIncCount );
+
+ // allocate new entries
+ for( sal_Int32 i = nOldSubIncCount; i < nNewSubIncCount; ++i )
+ {
+ 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 ] );
+ }
+ }
+ }
+ //don't keep the mutex locked while calling out
+ for (auto const& oldBroadcaster : aOldBroadcasters)
+ ModifyListenerHelper::removeListener(oldBroadcaster, xModifyEventForwarder );
+ for (auto const& newBroadcaster : aNewBroadcasters)
+ ModifyListenerHelper::addListener( newBroadcaster, xModifyEventForwarder );
+}
+
+// ____ XAxis ____
+void SAL_CALL Axis::setScaleData( const chart2::ScaleData& rScaleData )
+{
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ Reference< lang::XEventListener > xEventListener;
+ Reference< chart2::data::XLabeledDataSequence > xOldCategories;
+ Reference< chart2::data::XLabeledDataSequence > xNewCategories = rScaleData.Categories;
+ {
+ MutexGuard aGuard( m_aMutex );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ xEventListener = this;
+ xOldCategories = m_aScaleData.Categories;
+ m_aScaleData = rScaleData;
+ }
+ AllocateSubGrids();
+
+ //don't keep the mutex locked while calling out
+ if( xOldCategories.is() && xOldCategories != xNewCategories )
+ {
+ ModifyListenerHelper::removeListener( xOldCategories, xModifyEventForwarder );
+ EventListenerHelper::removeListener( xOldCategories, xEventListener );
+ }
+ if( xNewCategories.is() && xOldCategories != xNewCategories )
+ {
+ ModifyListenerHelper::addListener( xNewCategories, m_xModifyEventForwarder );
+ EventListenerHelper::addListener( xNewCategories, xEventListener );
+ }
+ fireModifyEvent();
+}
+
+chart2::ScaleData SAL_CALL Axis::getScaleData()
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_aScaleData;
+}
+
+Reference< beans::XPropertySet > SAL_CALL Axis::getGridProperties()
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xGrid;
+}
+Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubGridProperties()
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_aSubGridProperties;
+}
+
+Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubTickProperties()
+{
+ OSL_FAIL( "Not implemented yet" );
+ return Sequence< Reference< beans::XPropertySet > >();
+}
+
+// ____ XTitled ____
+Reference< chart2::XTitle > SAL_CALL Axis::getTitleObject()
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xTitle;
+}
+
+void SAL_CALL Axis::setTitleObject( const Reference< chart2::XTitle >& xNewTitle )
+{
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ Reference< chart2::XTitle > xOldTitle;
+ {
+ MutexGuard aGuard( m_aMutex );
+ xOldTitle = m_xTitle;
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ m_xTitle = xNewTitle;
+ }
+
+ //don't keep the mutex locked while calling out
+ if( xOldTitle.is() && xOldTitle != xNewTitle )
+ ModifyListenerHelper::removeListener( xOldTitle, xModifyEventForwarder );
+ if( xNewTitle.is() && xOldTitle != xNewTitle )
+ ModifyListenerHelper::addListener( xNewTitle, xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+// ____ XCloneable ____
+Reference< util::XCloneable > SAL_CALL Axis::createClone()
+{
+ Axis * pNewAxis( new Axis( *this ));
+ // hold a reference to the clone
+ Reference< util::XCloneable > xResult( pNewAxis );
+ // do initialization that uses uno references to the clone
+ pNewAxis->Init();
+ return xResult;
+}
+
+// ____ 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");
+ }
+}
+
+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");
+ }
+}
+
+// ____ XModifyListener ____
+void SAL_CALL Axis::modified( const lang::EventObject& aEvent )
+{
+ m_xModifyEventForwarder->modified( aEvent );
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL Axis::disposing( const lang::EventObject& Source )
+{
+ if( Source.Source == m_aScaleData.Categories )
+ m_aScaleData.Categories = nullptr;
+}
+
+// ____ OPropertySet ____
+void Axis::firePropertyChangeEvent()
+{
+ fireModifyEvent();
+}
+
+void Axis::fireModifyEvent()
+{
+ m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
+}
+
+// ____ OPropertySet ____
+uno::Any Axis::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticAxisDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL Axis::getInfoHelper()
+{
+ return *StaticAxisInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+Reference< beans::XPropertySetInfo > SAL_CALL Axis::getPropertySetInfo()
+{
+ return *StaticAxisInfo::get();
+}
+
+using impl::Axis_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( Axis, Axis_Base, ::property::OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( Axis, Axis_Base, ::property::OPropertySet )
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+OUString SAL_CALL Axis::getImplementationName()
+{
+ return "com.sun.star.comp.chart2.Axis";
+}
+
+sal_Bool SAL_CALL Axis::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL Axis::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart2.Axis",
+ "com.sun.star.beans.PropertySet" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_Axis_get_implementation(css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::Axis);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/Axis.hxx b/chart2/source/model/main/Axis.hxx
new file mode 100644
index 000000000..49f4003bb
--- /dev/null
+++ b/chart2/source/model/main/Axis.hxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_MAIN_AXIS_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_MAIN_AXIS_HXX
+
+#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
+
+// INCLUDED_CHART2_SOURCE_MODEL_MAIN_AXIS_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/BaseCoordinateSystem.cxx b/chart2/source/model/main/BaseCoordinateSystem.cxx
new file mode 100644
index 000000000..7075f2ed6
--- /dev/null
+++ b/chart2/source/model/main/BaseCoordinateSystem.cxx
@@ -0,0 +1,361 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <BaseCoordinateSystem.hxx>
+#include <PropertyHelper.hxx>
+#include <UserDefinedProperties.hxx>
+#include <CloneHelper.hxx>
+#include <ModifyListenerHelper.hxx>
+#include "Axis.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 <algorithm>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::Property;
+
+namespace
+{
+enum
+{
+ PROP_COORDINATESYSTEM_SWAPXANDYAXIS
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "SwapXAndYAxis",
+ PROP_COORDINATESYSTEM_SWAPXANDYAXIS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+}
+
+struct StaticCooSysDefaults_Initializer
+{
+ ::chart::tPropertyValueMap* operator()()
+ {
+ static ::chart::tPropertyValueMap aStaticDefaults;
+ ::chart::PropertyHelper::setPropertyValueDefault( aStaticDefaults, PROP_COORDINATESYSTEM_SWAPXANDYAXIS, false );
+ return &aStaticDefaults;
+ }
+};
+
+struct StaticCooSysDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticCooSysDefaults_Initializer >
+{
+};
+
+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 );
+ }
+};
+
+struct StaticCooSysInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticCooSysInfoHelper_Initializer >
+{
+};
+
+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 >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+BaseCoordinateSystem::BaseCoordinateSystem(
+ sal_Int32 nDimensionCount /* = 2 */ ) :
+ ::property::OPropertySet( m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ 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 );
+ m_aAllAxis[nN][0] = xAxis;
+
+ ModifyListenerHelper::addListenerToAllElements( m_aAllAxis[nN], m_xModifyEventForwarder );
+ chart2::ScaleData aScaleData( xAxis->getScaleData() );
+ if(nN==0)
+ {
+ aScaleData.AxisType = chart2::AxisType::CATEGORY;
+ }
+ else if( nN==1)
+ {
+ aScaleData.AxisType = chart2::AxisType::REALNUMBER;
+ }
+ else if( nN==2)
+ {
+ aScaleData.AxisType = chart2::AxisType::SERIES;
+ }
+ xAxis->setScaleData( aScaleData );
+ }
+
+ setFastPropertyValue_NoBroadcast( PROP_COORDINATESYSTEM_SWAPXANDYAXIS, uno::Any( false ));
+}
+
+// explicit
+BaseCoordinateSystem::BaseCoordinateSystem(
+ const BaseCoordinateSystem & rSource ) :
+ impl::BaseCoordinateSystem_Base(rSource),
+ ::property::OPropertySet( rSource, m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ 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 );
+
+ for( nN=0; nN<m_aAllAxis.size(); nN++ )
+ ModifyListenerHelper::addListenerToAllElements( m_aAllAxis[nN], m_xModifyEventForwarder );
+ ModifyListenerHelper::addListenerToAllElements( m_aChartTypes, m_xModifyEventForwarder );
+}
+
+BaseCoordinateSystem::~BaseCoordinateSystem()
+{
+ try
+ {
+ for(const tAxisVecVecType::value_type & i : m_aAllAxis)
+ ModifyListenerHelper::removeListenerFromAllElements( i, m_xModifyEventForwarder );
+ ModifyListenerHelper::removeListenerFromAllElements( m_aChartTypes, m_xModifyEventForwarder );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2" );
+ }
+}
+
+// ____ XCoordinateSystem ____
+sal_Int32 SAL_CALL BaseCoordinateSystem::getDimension()
+{
+ return m_nDimensionCount;
+}
+
+void SAL_CALL BaseCoordinateSystem::setAxisByDimension(
+ sal_Int32 nDimensionIndex,
+ const Reference< chart2::XAxis >& 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] );
+ if( xOldAxis.is())
+ ModifyListenerHelper::removeListener( xOldAxis, m_xModifyEventForwarder );
+ m_aAllAxis[ nDimensionIndex ][nIndex] = xAxis;
+ if( xAxis.is())
+ ModifyListenerHelper::addListener( xAxis, m_xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+Reference< chart2::XAxis > SAL_CALL BaseCoordinateSystem::getAxisByDimension(
+ sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
+{
+ if( nDimensionIndex < 0 || nDimensionIndex >= getDimension() )
+ throw lang::IndexOutOfBoundsException();
+
+ OSL_ASSERT( m_aAllAxis.size() == static_cast< size_t >( getDimension()));
+
+ if( nAxisIndex < 0 || nAxisIndex > getMaximumAxisIndexByDimension(nDimensionIndex) )
+ throw lang::IndexOutOfBoundsException();
+
+ return m_aAllAxis[ nDimensionIndex ][nAxisIndex];
+}
+
+sal_Int32 SAL_CALL BaseCoordinateSystem::getMaximumAxisIndexByDimension( sal_Int32 nDimensionIndex )
+{
+ if( nDimensionIndex < 0 || nDimensionIndex >= getDimension() )
+ throw lang::IndexOutOfBoundsException();
+
+ OSL_ASSERT( m_aAllAxis.size() == static_cast< size_t >( getDimension()));
+
+ sal_Int32 nRet = m_aAllAxis[ nDimensionIndex ].size();
+ if(nRet)
+ nRet-=1;
+
+ return nRet;
+}
+
+// ____ XChartTypeContainer ____
+void SAL_CALL BaseCoordinateSystem::addChartType( const Reference< chart2::XChartType >& aChartType )
+{
+ if( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), aChartType )
+ != m_aChartTypes.end())
+ throw lang::IllegalArgumentException();
+
+ m_aChartTypes.push_back( aChartType );
+ 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 ));
+ if( aIt == m_aChartTypes.end())
+ throw container::NoSuchElementException(
+ "The given chart type is no element of the container",
+ static_cast< uno::XWeak * >( this ));
+
+ m_aChartTypes.erase( aIt );
+ ModifyListenerHelper::removeListener( aChartType, m_xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+Sequence< Reference< chart2::XChartType > > SAL_CALL BaseCoordinateSystem::getChartTypes()
+{
+ return comphelper::containerToSequence( 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 );
+ 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" );
+ }
+}
+
+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" );
+ }
+}
+
+// ____ XModifyListener ____
+void SAL_CALL BaseCoordinateSystem::modified( const lang::EventObject& aEvent )
+{
+ m_xModifyEventForwarder->modified( aEvent );
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL BaseCoordinateSystem::disposing( const lang::EventObject& /* Source */ )
+{
+ // nothing
+}
+
+// ____ OPropertySet ____
+void BaseCoordinateSystem::firePropertyChangeEvent()
+{
+ fireModifyEvent();
+}
+
+void BaseCoordinateSystem::fireModifyEvent()
+{
+ m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
+}
+
+// ____ OPropertySet ____
+uno::Any BaseCoordinateSystem::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticCooSysDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+// ____ OPropertySet ____
+::cppu::IPropertyArrayHelper & SAL_CALL BaseCoordinateSystem::getInfoHelper()
+{
+ return *StaticCooSysInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+Reference< beans::XPropertySetInfo > SAL_CALL BaseCoordinateSystem::getPropertySetInfo()
+{
+ return *StaticCooSysInfo::get();
+}
+
+using impl::BaseCoordinateSystem_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( BaseCoordinateSystem, BaseCoordinateSystem_Base, ::property::OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( BaseCoordinateSystem, BaseCoordinateSystem_Base, ::property::OPropertySet )
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/CartesianCoordinateSystem.cxx b/chart2/source/model/main/CartesianCoordinateSystem.cxx
new file mode 100644
index 000000000..288749d85
--- /dev/null
+++ b/chart2/source/model/main/CartesianCoordinateSystem.cxx
@@ -0,0 +1,160 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <CartesianCoordinateSystem.hxx>
+#include <servicenames_coosystems.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+namespace com::sun::star::uno { class XComponentContext; }
+
+namespace
+{
+
+static const char CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME[] = "com.sun.star.chart2.CoordinateSystems.Cartesian";
+
+}
+
+namespace chart
+{
+
+// explicit
+CartesianCoordinateSystem::CartesianCoordinateSystem(
+ sal_Int32 nDimensionCount /* = 2 */ ) :
+ BaseCoordinateSystem( nDimensionCount )
+{}
+
+CartesianCoordinateSystem::CartesianCoordinateSystem(
+ const CartesianCoordinateSystem & rSource ) :
+ BaseCoordinateSystem( rSource )
+{}
+
+CartesianCoordinateSystem::~CartesianCoordinateSystem()
+{}
+
+// ____ XCoordinateSystem ____
+OUString SAL_CALL CartesianCoordinateSystem::getCoordinateSystemType()
+{
+ return CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME;
+}
+
+OUString SAL_CALL CartesianCoordinateSystem::getViewServiceName()
+{
+ return CHART2_COOSYSTEM_CARTESIAN_VIEW_SERVICE_NAME;
+}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL CartesianCoordinateSystem::createClone()
+{
+ return Reference< util::XCloneable >( new CartesianCoordinateSystem( *this ));
+}
+
+// ____ XServiceInfo ____
+OUString SAL_CALL CartesianCoordinateSystem::getImplementationName()
+{
+ return "com.sun.star.comp.chart.CartesianCoordinateSystem";
+}
+
+sal_Bool SAL_CALL CartesianCoordinateSystem::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL CartesianCoordinateSystem::getSupportedServiceNames()
+{
+ return { CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME };
+}
+
+// ==== CartesianCoordinateSystem2d ====
+
+CartesianCoordinateSystem2d::CartesianCoordinateSystem2d() :
+ CartesianCoordinateSystem( 2 )
+{}
+
+CartesianCoordinateSystem2d::~CartesianCoordinateSystem2d()
+{}
+
+// ____ XServiceInfo ____
+OUString SAL_CALL CartesianCoordinateSystem2d::getImplementationName()
+{
+ return "com.sun.star.comp.chart2.CartesianCoordinateSystem2d";
+}
+
+sal_Bool SAL_CALL CartesianCoordinateSystem2d::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL CartesianCoordinateSystem2d::getSupportedServiceNames()
+{
+ return {
+ CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME,
+ "com.sun.star.chart2.CartesianCoordinateSystem2d"
+ };
+}
+
+// ==== CartesianCoordinateSystem3d ====
+
+CartesianCoordinateSystem3d::CartesianCoordinateSystem3d() :
+ CartesianCoordinateSystem( 3 )
+{}
+
+CartesianCoordinateSystem3d::~CartesianCoordinateSystem3d()
+{}
+
+// ____ XServiceInfo ____
+OUString SAL_CALL CartesianCoordinateSystem3d::getImplementationName()
+{
+ return "com.sun.star.comp.chart2.CartesianCoordinateSystem3d";
+}
+
+sal_Bool SAL_CALL CartesianCoordinateSystem3d::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL CartesianCoordinateSystem3d::getSupportedServiceNames()
+{
+ return {
+ CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME,
+ "com.sun.star.chart2.CartesianCoordinateSystem3d"
+ };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_CartesianCoordinateSystem2d_get_implementation(css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::CartesianCoordinateSystem2d);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_CartesianCoordinateSystem3d_get_implementation(css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::CartesianCoordinateSystem3d);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
new file mode 100644
index 000000000..96c49fb56
--- /dev/null
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -0,0 +1,1301 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <ChartModel.hxx>
+#include <servicenames.hxx>
+#include <DataSourceHelper.hxx>
+#include <ChartModelHelper.hxx>
+#include <DisposeHelper.hxx>
+#include <ControllerLockGuard.hxx>
+#include <ObjectIdentifier.hxx>
+#include "PageBackground.hxx"
+#include <CloneHelper.hxx>
+#include <NameContainer.hxx>
+#include "UndoManager.hxx"
+#include <ChartView.hxx>
+#include <PopupRequest.hxx>
+#include <ModifyListenerHelper.hxx>
+
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <cppuhelper/supportsservice.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>
+#include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp>
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#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>
+
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Any;
+using ::osl::MutexGuard;
+
+using namespace ::com::sun::star;
+using namespace ::apphelper;
+using namespace ::chart::CloneHelper;
+
+namespace
+{
+const OUString lcl_aGDIMetaFileMIMEType(
+ "application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"");
+const OUString lcl_aGDIMetaFileMIMETypeHighContrast(
+ "application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\"");
+
+} // anonymous namespace
+
+// ChartModel Constructor and Destructor
+
+namespace chart
+{
+
+ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
+ : m_aLifeTimeManager( this, this )
+ , m_bReadOnly( false )
+ , m_bModified( false )
+ , m_nInLoad(0)
+ , m_bUpdateNotificationsPending(false)
+ , mbTimeBased(false)
+ , m_aControllers( m_aModelMutex )
+ , m_nControllerLockCount(0)
+ , m_xContext( 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" ) )
+ , mnStart(0)
+ , mnEnd(0)
+{
+ osl_atomic_increment(&m_refCount);
+ {
+ m_xOldModelAgg.set(
+ m_xContext->getServiceManager()->createInstanceWithContext(
+ CHART_CHARTAPIWRAPPER_SERVICE_NAME,
+ m_xContext ), uno::UNO_QUERY_THROW );
+ m_xOldModelAgg->setDelegator( *this );
+ }
+
+ {
+ ModifyListenerHelper::addListener( m_xPageBackground, this );
+ m_xChartTypeManager.set( xContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.chart2.ChartTypeManager", m_xContext ), uno::UNO_QUERY );
+ }
+ osl_atomic_decrement(&m_refCount);
+}
+
+ChartModel::ChartModel( const ChartModel & rOther )
+ : impl::ChartModel_Base(rOther)
+ , m_aLifeTimeManager( this, this )
+ , m_bReadOnly( rOther.m_bReadOnly )
+ , m_bModified( rOther.m_bModified )
+ , m_nInLoad(0)
+ , m_bUpdateNotificationsPending(false)
+ , mbTimeBased(rOther.mbTimeBased)
+ , m_aResource( rOther.m_aResource )
+ , m_aMediaDescriptor( rOther.m_aMediaDescriptor )
+ , m_aControllers( m_aModelMutex )
+ , m_nControllerLockCount(0)
+ , m_xContext( rOther.m_xContext )
+ // @note: the old model aggregate must not be shared with other models if it
+ // is, you get mutex deadlocks
+ //, m_xOldModelAgg( nullptr ) //rOther.m_xOldModelAgg )
+ // m_xStorage( nullptr ) //rOther.m_xStorage )
+ , m_aVisualAreaSize( rOther.m_aVisualAreaSize )
+ , m_aGraphicObjectVector( rOther.m_aGraphicObjectVector )
+ , m_xDataProvider( rOther.m_xDataProvider )
+ , m_xInternalDataProvider( rOther.m_xInternalDataProvider )
+ , mnStart(rOther.mnStart)
+ , mnEnd(rOther.mnEnd)
+{
+ osl_atomic_increment(&m_refCount);
+ {
+ m_xOldModelAgg.set(
+ m_xContext->getServiceManager()->createInstanceWithContext(
+ CHART_CHARTAPIWRAPPER_SERVICE_NAME,
+ m_xContext ), uno::UNO_QUERY_THROW );
+ 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 );
+
+ {
+ MutexGuard aGuard( m_aModelMutex );
+ xListener = this;
+ m_xTitle = xNewTitle;
+ m_xDiagram = xNewDiagram;
+ m_xPageBackground = xNewPageBackground;
+ m_xChartTypeManager = xChartTypeManager;
+ m_xXMLNamespaceMap = xXMLNamespaceMap;
+ }
+
+ ModifyListenerHelper::addListener( xNewTitle, xListener );
+ ModifyListenerHelper::addListener( xNewDiagram, xListener );
+ ModifyListenerHelper::addListener( xNewPageBackground, xListener );
+ xListener.clear();
+ }
+ osl_atomic_decrement(&m_refCount);
+}
+
+ChartModel::~ChartModel()
+{
+ if( m_xOldModelAgg.is())
+ m_xOldModelAgg->setDelegator( nullptr );
+}
+
+void SAL_CALL ChartModel::initialize( const Sequence< Any >& /*rArguments*/ )
+{
+ //#i113722# avoid duplicate creation
+
+ //maybe additional todo?:
+ //support argument "EmbeddedObject"?
+ //support argument "EmbeddedScriptSupport"?
+ //support argument "DocumentRecoverySupport"?
+}
+
+css::uno::Reference< css::uno::XInterface > ChartModel::getChartView() const
+{
+ return static_cast< ::cppu::OWeakObject* >( mxChartView.get() );
+}
+
+// private methods
+
+OUString ChartModel::impl_g_getLocation()
+{
+
+ LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall())
+ return OUString(); //behave passive if already disposed or closed or throw exception @todo?
+ //mutex is acquired
+ return m_aResource;
+}
+
+bool ChartModel::impl_isControllerConnected( const uno::Reference< frame::XController >& xController )
+{
+ try
+ {
+ std::vector< uno::Reference<uno::XInterface> > aSeq = m_aControllers.getElements();
+ for( const auto & r : aSeq )
+ {
+ if( r == xController )
+ return true;
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ return false;
+}
+
+uno::Reference< frame::XController > ChartModel::impl_getCurrentController()
+{
+ //@todo? hold only weak references to controllers
+
+ // get the last active controller of this model
+ if( m_xCurrentController.is() )
+ return m_xCurrentController;
+
+ // get the first controller of this model
+ if( m_aControllers.getLength() )
+ {
+ uno::Reference<uno::XInterface> xI = m_aControllers.getElements()[0];
+ return uno::Reference<frame::XController>( xI, uno::UNO_QUERY );
+ }
+
+ //return nothing if no controllers are connected at all
+ return uno::Reference< frame::XController > ();
+}
+
+void ChartModel::impl_notifyCloseListeners()
+{
+ ::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer
+ .getContainer( cppu::UnoType<util::XCloseListener>::get());
+ if( pIC )
+ {
+ lang::EventObject aEvent( static_cast< lang::XComponent*>(this) );
+ ::cppu::OInterfaceIteratorHelper aIt( *pIC );
+ while( aIt.hasMoreElements() )
+ {
+ uno::Reference< util::XCloseListener > xListener( aIt.next(), uno::UNO_QUERY );
+ if( xListener.is() )
+ xListener->notifyClosing( aEvent );
+ }
+ }
+}
+
+void ChartModel::impl_adjustAdditionalShapesPositionAndSize( const awt::Size& aVisualAreaSize )
+{
+ uno::Reference< beans::XPropertySet > xProperties( static_cast< ::cppu::OWeakObject* >( this ), uno::UNO_QUERY );
+ if ( !xProperties.is() )
+ return;
+
+ uno::Reference< drawing::XShapes > xShapes;
+ xProperties->getPropertyValue( "AdditionalShapes" ) >>= xShapes;
+ if ( !xShapes.is() )
+ return;
+
+ sal_Int32 nCount = xShapes->getCount();
+ for ( sal_Int32 i = 0; i < nCount; ++i )
+ {
+ Reference< drawing::XShape > xShape;
+ if ( xShapes->getByIndex( i ) >>= xShape )
+ {
+ if ( xShape.is() )
+ {
+ awt::Point aPos( xShape->getPosition() );
+ awt::Size aSize( xShape->getSize() );
+
+ double fWidth = static_cast< double >( aVisualAreaSize.Width ) / m_aVisualAreaSize.Width;
+ double fHeight = static_cast< double >( aVisualAreaSize.Height ) / m_aVisualAreaSize.Height;
+
+ aPos.X = static_cast< long >( aPos.X * fWidth );
+ aPos.Y = static_cast< long >( aPos.Y * fHeight );
+ aSize.Width = static_cast< long >( aSize.Width * fWidth );
+ aSize.Height = static_cast< long >( aSize.Height * fHeight );
+
+ xShape->setPosition( aPos );
+ xShape->setSize( aSize );
+ }
+ }
+ }
+}
+
+// lang::XServiceInfo
+
+OUString SAL_CALL ChartModel::getImplementationName()
+{
+ return CHART_MODEL_SERVICE_IMPLEMENTATION_NAME;
+}
+
+sal_Bool SAL_CALL ChartModel::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL ChartModel::getSupportedServiceNames()
+{
+ return {
+ CHART_MODEL_SERVICE_NAME,
+ "com.sun.star.document.OfficeDocument",
+ "com.sun.star.chart.ChartDocument"
+ };
+}
+
+// frame::XModel (required interface)
+
+sal_Bool SAL_CALL ChartModel::attachResource( const OUString& rURL
+ , const uno::Sequence< beans::PropertyValue >& rMediaDescriptor )
+{
+ /*
+ The method attachResource() is used by the frame loader implementations
+ to inform the model about its URL and MediaDescriptor.
+ */
+
+ LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall())
+ return false; //behave passive if already disposed or closed or throw exception @todo?
+ //mutex is acquired
+
+ if(!m_aResource.isEmpty())//we have a resource already //@todo? or is setting a new resource allowed?
+ return false;
+ m_aResource = rURL;
+ m_aMediaDescriptor = rMediaDescriptor;
+
+ //@todo ? check rURL ??
+ //@todo ? evaluate m_aMediaDescriptor;
+ //@todo ? ... ??? --> nothing, this method is only for setting information
+
+ return true;
+}
+
+OUString SAL_CALL ChartModel::getURL()
+{
+ return impl_g_getLocation();
+}
+
+uno::Sequence< beans::PropertyValue > SAL_CALL ChartModel::getArgs()
+{
+ /*
+ The method getArgs() returns a sequence of property values
+ that report the resource description according to com.sun.star.document.MediaDescriptor,
+ specified on loading or saving with storeAsURL.
+ */
+
+ LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall())
+ return uno::Sequence< beans::PropertyValue >(); //behave passive if already disposed or closed or throw exception @todo?
+ //mutex is acquired
+
+ return m_aMediaDescriptor;
+}
+
+void SAL_CALL ChartModel::connectController( const uno::Reference< frame::XController >& xController )
+{
+ //@todo? this method is declared as oneway -> ...?
+
+ LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall())
+ return ; //behave passive if already disposed or closed
+ //mutex is acquired
+
+ //--add controller
+ m_aControllers.addInterface(xController);
+}
+
+void SAL_CALL ChartModel::disconnectController( const uno::Reference< frame::XController >& xController )
+{
+ //@todo? this method is declared as oneway -> ...?
+
+ LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall())
+ return; //behave passive if already disposed or closed
+
+ //--remove controller
+ m_aControllers.removeInterface(xController);
+
+ //case: current controller is disconnected:
+ if( m_xCurrentController == xController )
+ m_xCurrentController.clear();
+
+ DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
+ DisposeHelper::DisposeAndClear(m_xPopupRequest);
+}
+
+void SAL_CALL ChartModel::lockControllers()
+{
+ /*
+ suspends some notifications to the controllers which are used for display updates.
+
+ The calls to lockControllers() and unlockControllers() may be nested
+ and even overlapping, but they must be in pairs. While there is at least one lock
+ remaining, some notifications for display updates are not broadcasted.
+ */
+
+ //@todo? this method is declared as oneway -> ...?
+
+ LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall())
+ return; //behave passive if already disposed or closed or throw exception @todo?
+ ++m_nControllerLockCount;
+}
+
+void SAL_CALL ChartModel::unlockControllers()
+{
+ /*
+ resumes the notifications which were suspended by lockControllers() .
+
+ The calls to lockControllers() and unlockControllers() may be nested
+ and even overlapping, but they must be in pairs. While there is at least one lock
+ remaining, some notifications for display updates are not broadcasted.
+ */
+
+ //@todo? this method is declared as oneway -> ...?
+
+ LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall())
+ return; //behave passive if already disposed or closed or throw exception @todo?
+ if( m_nControllerLockCount == 0 )
+ {
+ SAL_WARN("chart2", "ChartModel: unlockControllers called with m_nControllerLockCount == 0" );
+ return;
+ }
+ --m_nControllerLockCount;
+ if( m_nControllerLockCount == 0 && m_bUpdateNotificationsPending )
+ {
+ aGuard.clear();
+ impl_notifyModifiedListeners();
+ }
+}
+
+sal_Bool SAL_CALL ChartModel::hasControllersLocked()
+{
+ LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall())
+ return false; //behave passive if already disposed or closed or throw exception @todo?
+ return ( m_nControllerLockCount != 0 ) ;
+}
+
+uno::Reference< frame::XController > SAL_CALL ChartModel::getCurrentController()
+{
+ LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall())
+ throw lang::DisposedException(
+ "getCurrentController was called on an already disposed or closed model",
+ static_cast< ::cppu::OWeakObject* >(this) );
+
+ return impl_getCurrentController();
+}
+
+void SAL_CALL ChartModel::setCurrentController( const uno::Reference< frame::XController >& xController )
+{
+ LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall())
+ throw lang::DisposedException(
+ "setCurrentController was called on an already disposed or closed model",
+ static_cast< ::cppu::OWeakObject* >(this) );
+
+ //OSL_ENSURE( impl_isControllerConnected(xController), "setCurrentController is called with a Controller which is not connected" );
+ if(!impl_isControllerConnected(xController))
+ throw container::NoSuchElementException(
+ "setCurrentController is called with a Controller which is not connected",
+ static_cast< ::cppu::OWeakObject* >(this) );
+
+ m_xCurrentController = xController;
+
+ DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
+ DisposeHelper::DisposeAndClear(m_xPopupRequest);
+}
+
+uno::Reference< uno::XInterface > SAL_CALL ChartModel::getCurrentSelection()
+{
+ LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall())
+ throw lang::DisposedException(
+ "getCurrentSelection was called on an already disposed or closed model",
+ static_cast< ::cppu::OWeakObject* >(this) );
+
+ uno::Reference< uno::XInterface > xReturn;
+ uno::Reference< frame::XController > xController = impl_getCurrentController();
+
+ aGuard.clear();
+ if( xController.is() )
+ {
+ uno::Reference< view::XSelectionSupplier > xSelectionSupl( xController, uno::UNO_QUERY );
+ if ( xSelectionSupl.is() )
+ {
+ uno::Any aSel = xSelectionSupl->getSelection();
+ OUString aObjectCID;
+ if( aSel >>= aObjectCID )
+ xReturn.set( ObjectIdentifier::getObjectPropertySet( aObjectCID, Reference< XChartDocument >(this)));
+ }
+ }
+ return xReturn;
+}
+
+// lang::XComponent (base of XModel)
+void SAL_CALL ChartModel::dispose()
+{
+ Reference< XInterface > xKeepAlive( *this );
+
+ //This object should release all resources and references in the
+ //easiest possible manner
+ //This object must notify all registered listeners using the method
+ //<member>XEventListener::disposing</member>
+
+ //hold no mutex
+ if( !m_aLifeTimeManager.dispose() )
+ return;
+
+ //--release all resources and references
+ //// @todo
+
+ if ( m_xDiagram.is() )
+ ModifyListenerHelper::removeListener( m_xDiagram, this );
+
+ if ( m_xDataProvider.is() )
+ {
+ Reference<util::XModifyBroadcaster> xModifyBroadcaster( m_xDataProvider, uno::UNO_QUERY );
+ if ( xModifyBroadcaster.is() )
+ xModifyBroadcaster->removeModifyListener( this );
+ }
+
+ 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_xStorage.clear();
+ // just clear, don't dispose - we're not the owner
+
+ if ( m_pUndoManager.is() )
+ m_pUndoManager->disposing();
+ m_pUndoManager.clear();
+ // that's important, since the UndoManager implementation delegates its ref counting to ourself.
+
+ if( m_xOldModelAgg.is()) // #i120828#, to release cyclic reference to ChartModel object
+ m_xOldModelAgg->setDelegator( nullptr );
+
+ m_aControllers.disposeAndClear( lang::EventObject( static_cast< cppu::OWeakObject * >( this )));
+ m_xCurrentController.clear();
+
+ DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
+ DisposeHelper::DisposeAndClear(m_xPopupRequest);
+
+ if( m_xOldModelAgg.is())
+ m_xOldModelAgg->setDelegator( nullptr );
+}
+
+void SAL_CALL ChartModel::addEventListener( const uno::Reference< lang::XEventListener > & xListener )
+{
+ if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
+ return; //behave passive if already disposed or closed
+
+ m_aLifeTimeManager.m_aListenerContainer.addInterface( cppu::UnoType<lang::XEventListener>::get(), xListener );
+}
+
+void SAL_CALL ChartModel::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
+{
+ 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 );
+}
+
+// util::XCloseBroadcaster (base of XCloseable)
+void SAL_CALL ChartModel::addCloseListener( const uno::Reference< util::XCloseListener > & xListener )
+{
+ m_aLifeTimeManager.g_addCloseListener( xListener );
+}
+
+void SAL_CALL ChartModel::removeCloseListener( const uno::Reference< util::XCloseListener > & xListener )
+{
+ 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 );
+}
+
+// util::XCloseable
+void SAL_CALL ChartModel::close( sal_Bool bDeliverOwnership )
+{
+ //hold no mutex
+
+ if( !m_aLifeTimeManager.g_close_startTryClose( bDeliverOwnership ) )
+ return;
+ //no mutex is acquired
+
+ // At the end of this method may we must dispose ourself ...
+ // and may nobody from outside hold a reference to us ...
+ // then it's a good idea to do that by ourself.
+ uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >(this) );
+
+ //the listeners have had no veto
+ //check whether we self can close
+ {
+ util::CloseVetoException aVetoException(
+ "the model itself could not be closed",
+ static_cast< ::cppu::OWeakObject* >(this) );
+
+ m_aLifeTimeManager.g_close_isNeedToCancelLongLastingCalls( bDeliverOwnership, aVetoException );
+ }
+ m_aLifeTimeManager.g_close_endTryClose_doClose();
+
+ // BM @todo: is it ok to call the listeners here?
+ impl_notifyCloseListeners();
+}
+
+// lang::XTypeProvider
+uno::Sequence< uno::Type > SAL_CALL ChartModel::getTypes()
+{
+ uno::Reference< lang::XTypeProvider > xAggTypeProvider;
+ if( (m_xOldModelAgg->queryAggregation( cppu::UnoType<decltype(xAggTypeProvider)>::get()) >>= xAggTypeProvider)
+ && xAggTypeProvider.is())
+ {
+ return comphelper::concatSequences(
+ impl::ChartModel_Base::getTypes(),
+ xAggTypeProvider->getTypes());
+ }
+
+ return impl::ChartModel_Base::getTypes();
+}
+
+// document::XDocumentPropertiesSupplier
+uno::Reference< document::XDocumentProperties > SAL_CALL
+ ChartModel::getDocumentProperties()
+{
+ ::osl::MutexGuard aGuard( m_aModelMutex );
+ if ( !m_xDocumentProperties.is() )
+ {
+ m_xDocumentProperties.set( document::DocumentProperties::create( ::comphelper::getProcessComponentContext() ) );
+ }
+ return m_xDocumentProperties;
+}
+
+// document::XDocumentPropertiesSupplier
+Reference< document::XUndoManager > SAL_CALL ChartModel::getUndoManager( )
+{
+ ::osl::MutexGuard aGuard( m_aModelMutex );
+ if ( !m_pUndoManager.is() )
+ m_pUndoManager.set( new UndoManager( *this, m_aModelMutex ) );
+ return m_pUndoManager.get();
+}
+
+// chart2::XChartDocument
+
+uno::Reference< chart2::XDiagram > SAL_CALL ChartModel::getFirstDiagram()
+{
+ MutexGuard aGuard( m_aModelMutex );
+ return m_xDiagram;
+}
+
+void SAL_CALL ChartModel::setFirstDiagram( const uno::Reference< chart2::XDiagram >& xDiagram )
+{
+ Reference< chart2::XDiagram > xOldDiagram;
+ Reference< util::XModifyListener > xListener;
+ {
+ MutexGuard aGuard( m_aModelMutex );
+ if( xDiagram == m_xDiagram )
+ return;
+ xOldDiagram = m_xDiagram;
+ m_xDiagram = xDiagram;
+ xListener = this;
+ }
+ //don't keep the mutex locked while calling out
+ ModifyListenerHelper::removeListener( xOldDiagram, xListener );
+ ModifyListenerHelper::addListener( xDiagram, xListener );
+ setModified( true );
+}
+
+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
+ {
+ uno::Sequence< uno::Any > aArgs(1);
+ beans::NamedValue aParam( "CreateDefaultData" ,uno::Any(true) );
+ aArgs[0] <<= 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 );
+ }
+ }
+ return xDataSource;
+}
+
+void SAL_CALL ChartModel::createInternalDataProvider( sal_Bool bCloneExistingData )
+{
+ // don't lock the mutex, because this call calls out to code that tries to
+ // lock the solar mutex. On the other hand, a paint locks the solar mutex
+ // and calls to the model lock the model's mutex => deadlock
+ // @todo: lock a separate mutex in the InternalData class
+ if( !hasInternalDataProvider() )
+ {
+ if( bCloneExistingData )
+ m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( this, true );
+ else
+ m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( Reference<XChartDocument>(), true );
+ m_xDataProvider.set( m_xInternalDataProvider );
+ }
+ setModified( true );
+}
+
+void ChartModel::removeDataProviders()
+{
+ if (m_xInternalDataProvider.is())
+ m_xInternalDataProvider.clear();
+ if (m_xDataProvider.is())
+ m_xDataProvider.clear();
+}
+
+sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
+{
+ return m_xDataProvider.is() && m_xInternalDataProvider.is();
+}
+
+uno::Reference< chart2::data::XDataProvider > SAL_CALL ChartModel::getDataProvider()
+{
+ MutexGuard aGuard( m_aModelMutex );
+ return m_xDataProvider;
+}
+
+// ____ XDataReceiver ____
+
+void SAL_CALL ChartModel::attachDataProvider( const uno::Reference< chart2::data::XDataProvider >& xDataProvider )
+{
+ {
+ MutexGuard aGuard( m_aModelMutex );
+ uno::Reference< beans::XPropertySet > xProp( xDataProvider, uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ try
+ {
+ bool bIncludeHiddenCells = ChartModelHelper::isIncludeHiddenCells( Reference< frame::XModel >(this) );
+ xProp->setPropertyValue("IncludeHiddenCells", uno::Any(bIncludeHiddenCells));
+ }
+ catch (const beans::UnknownPropertyException&)
+ {
+ }
+ }
+
+ uno::Reference<util::XModifyBroadcaster> xModifyBroadcaster(xDataProvider, uno::UNO_QUERY);
+ if (xModifyBroadcaster.is())
+ {
+ xModifyBroadcaster->addModifyListener(this);
+ }
+
+ m_xDataProvider.set( xDataProvider );
+ m_xInternalDataProvider.clear();
+
+ //the numberformatter is kept independent of the data provider!
+ }
+ setModified( true );
+}
+
+void SAL_CALL ChartModel::attachNumberFormatsSupplier( const uno::Reference< util::XNumberFormatsSupplier >& xNewSupplier )
+{
+ {
+ MutexGuard aGuard( m_aModelMutex );
+ if( xNewSupplier==m_xNumberFormatsSupplier )
+ return;
+ if( xNewSupplier==m_xOwnNumberFormatsSupplier )
+ return;
+ if( m_xOwnNumberFormatsSupplier.is() && xNewSupplier.is() )
+ {
+ //@todo
+ //merge missing numberformats from own to new formatter
+ }
+ else if( !xNewSupplier.is() )
+ {
+ if( m_xNumberFormatsSupplier.is() )
+ {
+ //@todo
+ //merge missing numberformats from old numberformatter to own numberformatter
+ //create own numberformatter if necessary
+ }
+ }
+
+ m_xNumberFormatsSupplier.set( xNewSupplier );
+ m_xOwnNumberFormatsSupplier.clear();
+ }
+ setModified( true );
+}
+
+void SAL_CALL ChartModel::setArguments( const Sequence< beans::PropertyValue >& aArguments )
+{
+ {
+ MutexGuard aGuard( m_aModelMutex );
+ if( !m_xDataProvider.is() )
+ return;
+ lockControllers();
+
+ try
+ {
+ Reference< chart2::data::XDataSource > xDataSource( m_xDataProvider->createDataSource( aArguments ) );
+ if( xDataSource.is() )
+ {
+ Reference< chart2::XDiagram > xDia( getFirstDiagram() );
+ if( !xDia.is() )
+ {
+ Reference< chart2::XChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() );
+ if( xTemplate.is())
+ setFirstDiagram( xTemplate->createDiagramByDataSource( xDataSource, aArguments ) );
+ }
+ else
+ xDia->setDiagramData( xDataSource, aArguments );
+ }
+ }
+ catch (const lang::IllegalArgumentException&)
+ {
+ throw;
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ unlockControllers();
+ }
+ setModified( true );
+}
+
+Sequence< OUString > SAL_CALL ChartModel::getUsedRangeRepresentations()
+{
+ return DataSourceHelper::getUsedDataRanges( Reference< frame::XModel >(this));
+}
+
+Reference< chart2::data::XDataSource > SAL_CALL ChartModel::getUsedData()
+{
+ return DataSourceHelper::getUsedData( Reference< chart2::XChartDocument >(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 ));
+ }
+ return m_xRangeHighlighter;
+}
+
+Reference<awt::XRequestCallback> SAL_CALL ChartModel::getPopupRequest()
+{
+ if (!m_xPopupRequest.is())
+ m_xPopupRequest.set(new PopupRequest);
+ return m_xPopupRequest;
+}
+
+Reference< chart2::XChartTypeTemplate > 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 );
+ return xTemplate;
+}
+
+void SAL_CALL ChartModel::setChartTypeManager( const uno::Reference< chart2::XChartTypeManager >& xNewManager )
+{
+ {
+ MutexGuard aGuard( m_aModelMutex );
+ m_xChartTypeManager = xNewManager;
+ }
+ setModified( true );
+}
+
+uno::Reference< chart2::XChartTypeManager > SAL_CALL ChartModel::getChartTypeManager()
+{
+ MutexGuard aGuard( m_aModelMutex );
+ return m_xChartTypeManager;
+}
+
+uno::Reference< beans::XPropertySet > SAL_CALL ChartModel::getPageBackground()
+{
+ MutexGuard aGuard( m_aModelMutex );
+ return m_xPageBackground;
+}
+
+void SAL_CALL ChartModel::createDefaultChart()
+{
+ insertDefaultChart();
+}
+
+// ____ XTitled ____
+uno::Reference< chart2::XTitle > SAL_CALL ChartModel::getTitleObject()
+{
+ MutexGuard aGuard( m_aModelMutex );
+ return m_xTitle;
+}
+
+void SAL_CALL ChartModel::setTitleObject( const uno::Reference< chart2::XTitle >& xTitle )
+{
+ {
+ MutexGuard aGuard( m_aModelMutex );
+ if( m_xTitle.is() )
+ ModifyListenerHelper::removeListener( m_xTitle, this );
+ m_xTitle = xTitle;
+ ModifyListenerHelper::addListener( m_xTitle, this );
+ }
+ setModified( true );
+}
+
+// ____ XInterface (for old API wrapper) ____
+uno::Any SAL_CALL ChartModel::queryInterface( const uno::Type& aType )
+{
+ uno::Any aResult( impl::ChartModel_Base::queryInterface( aType ));
+
+ if( ! aResult.hasValue())
+ {
+ // try old API wrapper
+ try
+ {
+ if( m_xOldModelAgg.is())
+ aResult = m_xOldModelAgg->queryAggregation( aType );
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return aResult;
+}
+
+// ____ XCloneable ____
+Reference< util::XCloneable > SAL_CALL ChartModel::createClone()
+{
+ return Reference< util::XCloneable >( new ChartModel( *this ));
+}
+
+// ____ XVisualObject ____
+void SAL_CALL ChartModel::setVisualAreaSize( ::sal_Int64 nAspect, const awt::Size& aSize )
+{
+ if( nAspect == embed::Aspects::MSOLE_CONTENT )
+ {
+ ControllerLockGuard aLockGuard( *this );
+ bool bChanged =
+ (m_aVisualAreaSize.Width != aSize.Width ||
+ m_aVisualAreaSize.Height != aSize.Height);
+
+ // #i12587# support for shapes in chart
+ if ( bChanged )
+ {
+ impl_adjustAdditionalShapesPositionAndSize( aSize );
+ }
+
+ m_aVisualAreaSize = aSize;
+ if( bChanged )
+ setModified( true );
+ }
+ else
+ {
+ OSL_FAIL( "setVisualAreaSize: Aspect not implemented yet.");
+ }
+}
+
+awt::Size SAL_CALL ChartModel::getVisualAreaSize( ::sal_Int64 nAspect )
+{
+ OSL_ENSURE( nAspect == embed::Aspects::MSOLE_CONTENT,
+ "No aspects other than content are supported" );
+ // other possible aspects are MSOLE_THUMBNAIL, MSOLE_ICON and MSOLE_DOCPRINT
+
+ return m_aVisualAreaSize;
+}
+
+embed::VisualRepresentation SAL_CALL ChartModel::getPreferredVisualRepresentation( ::sal_Int64 nAspect )
+{
+ OSL_ENSURE( nAspect == embed::Aspects::MSOLE_CONTENT,
+ "No aspects other than content are supported" );
+
+ embed::VisualRepresentation aResult;
+
+ try
+ {
+ Sequence< sal_Int8 > aMetafile;
+
+ //get view from old api wrapper
+ Reference< datatransfer::XTransferable > xTransferable(
+ createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
+ if( xTransferable.is() )
+ {
+ datatransfer::DataFlavor aDataFlavor( lcl_aGDIMetaFileMIMEType,
+ "GDIMetaFile",
+ cppu::UnoType<uno::Sequence< sal_Int8 >>::get() );
+
+ uno::Any aData( xTransferable->getTransferData( aDataFlavor ) );
+ aData >>= aMetafile;
+ }
+
+ aResult.Flavor.MimeType = lcl_aGDIMetaFileMIMEType;
+ aResult.Flavor.DataType = cppu::UnoType<decltype(aMetafile)>::get();
+
+ aResult.Data <<= aMetafile;
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return aResult;
+}
+
+::sal_Int32 SAL_CALL ChartModel::getMapUnit( ::sal_Int64 nAspect )
+{
+ OSL_ENSURE( nAspect == embed::Aspects::MSOLE_CONTENT,
+ "No aspects other than content are supported" );
+ return embed::EmbedMapUnits::ONE_100TH_MM;
+}
+
+// ____ datatransfer::XTransferable ____
+uno::Any SAL_CALL ChartModel::getTransferData( const datatransfer::DataFlavor& aFlavor )
+{
+ uno::Any aResult;
+ if( !isDataFlavorSupported( aFlavor ) )
+ throw datatransfer::UnsupportedFlavorException(
+ aFlavor.MimeType, static_cast< ::cppu::OWeakObject* >( this ));
+
+ try
+ {
+ //get view from old api wrapper
+ Reference< datatransfer::XTransferable > xTransferable(
+ createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
+ if( xTransferable.is() &&
+ xTransferable->isDataFlavorSupported( aFlavor ))
+ {
+ aResult = xTransferable->getTransferData( aFlavor );
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return aResult;
+}
+
+Sequence< datatransfer::DataFlavor > SAL_CALL ChartModel::getTransferDataFlavors()
+{
+ uno::Sequence< datatransfer::DataFlavor > aRet(1);
+
+ aRet[0] = datatransfer::DataFlavor( lcl_aGDIMetaFileMIMETypeHighContrast,
+ "GDIMetaFile",
+ cppu::UnoType<uno::Sequence< sal_Int8 >>::get() );
+
+ return aRet;
+}
+
+sal_Bool SAL_CALL ChartModel::isDataFlavorSupported( const datatransfer::DataFlavor& aFlavor )
+{
+ return aFlavor.MimeType == lcl_aGDIMetaFileMIMETypeHighContrast;
+}
+
+namespace
+{
+enum eServiceType
+{
+ SERVICE_DASH_TABLE,
+ SERVICE_GRADIENT_TABLE,
+ SERVICE_HATCH_TABLE,
+ SERVICE_BITMAP_TABLE,
+ SERVICE_TRANSP_GRADIENT_TABLE,
+ SERVICE_MARKER_TABLE,
+ SERVICE_NAMESPACE_MAP
+};
+
+typedef std::map< OUString, enum eServiceType > tServiceNameMap;
+
+tServiceNameMap & lcl_getStaticServiceNameMap()
+{
+ static tServiceNameMap aServiceNameMap{
+ {"com.sun.star.drawing.DashTable", SERVICE_DASH_TABLE},
+ {"com.sun.star.drawing.GradientTable", SERVICE_GRADIENT_TABLE},
+ {"com.sun.star.drawing.HatchTable", SERVICE_HATCH_TABLE},
+ {"com.sun.star.drawing.BitmapTable", SERVICE_BITMAP_TABLE},
+ {"com.sun.star.drawing.TransparencyGradientTable", SERVICE_TRANSP_GRADIENT_TABLE},
+ {"com.sun.star.drawing.MarkerTable", SERVICE_MARKER_TABLE},
+ {"com.sun.star.xml.NamespaceMap", SERVICE_NAMESPACE_MAP}};
+ return aServiceNameMap;
+}
+}
+// ____ XMultiServiceFactory ____
+Reference< uno::XInterface > SAL_CALL ChartModel::createInstance( const OUString& rServiceSpecifier )
+{
+ tServiceNameMap & rMap = lcl_getStaticServiceNameMap();
+
+ tServiceNameMap::const_iterator aIt( rMap.find( rServiceSpecifier ));
+ if( aIt != rMap.end())
+ {
+ switch( (*aIt).second )
+ {
+ case SERVICE_DASH_TABLE:
+ case SERVICE_GRADIENT_TABLE:
+ case SERVICE_HATCH_TABLE:
+ case SERVICE_BITMAP_TABLE:
+ case SERVICE_TRANSP_GRADIENT_TABLE:
+ case SERVICE_MARKER_TABLE:
+ {
+ if(!mxChartView.is())
+ {
+ mxChartView = new ChartView( m_xContext, *this);
+ }
+ return mxChartView->createInstance( rServiceSpecifier );
+ }
+ break;
+ case SERVICE_NAMESPACE_MAP:
+ return Reference< uno::XInterface >( m_xXMLNamespaceMap );
+ }
+ }
+ else if(rServiceSpecifier == CHART_VIEW_SERVICE_NAME)
+ {
+ if(!mxChartView.is())
+ {
+ mxChartView = new ChartView( m_xContext, *this);
+ }
+
+ return static_cast< ::cppu::OWeakObject* >( mxChartView.get() );
+ }
+ else
+ {
+ if( m_xOldModelAgg.is() )
+ {
+ Any aAny = m_xOldModelAgg->queryAggregation( cppu::UnoType<lang::XMultiServiceFactory>::get());
+ uno::Reference< lang::XMultiServiceFactory > xOldModelFactory;
+ if( (aAny >>= xOldModelFactory) && xOldModelFactory.is() )
+ {
+ return xOldModelFactory->createInstance( rServiceSpecifier );
+ }
+ }
+ }
+ return nullptr;
+}
+
+Reference< uno::XInterface > SAL_CALL ChartModel::createInstanceWithArguments(
+ const OUString& rServiceSpecifier , const Sequence< Any >& Arguments )
+{
+ OSL_ENSURE( Arguments.hasElements(), "createInstanceWithArguments: Warning: Arguments are ignored" );
+ return createInstance( rServiceSpecifier );
+}
+
+Sequence< OUString > SAL_CALL ChartModel::getAvailableServiceNames()
+{
+ uno::Sequence< OUString > aResult;
+
+ if( m_xOldModelAgg.is())
+ {
+ Any aAny = m_xOldModelAgg->queryAggregation( cppu::UnoType<lang::XMultiServiceFactory>::get());
+ uno::Reference< lang::XMultiServiceFactory > xOldModelFactory;
+ if( (aAny >>= xOldModelFactory) && xOldModelFactory.is() )
+ {
+ return xOldModelFactory->getAvailableServiceNames();
+ }
+ }
+ return aResult;
+}
+
+Reference< util::XNumberFormatsSupplier > const & ChartModel::getNumberFormatsSupplier()
+{
+ if( !m_xNumberFormatsSupplier.is() )
+ {
+ if( !m_xOwnNumberFormatsSupplier.is() )
+ {
+ m_apSvNumberFormatter.reset( new SvNumberFormatter( m_xContext, LANGUAGE_SYSTEM ) );
+ m_xOwnNumberFormatsSupplier = new SvNumberFormatsSupplierObj( m_apSvNumberFormatter.get() );
+ //pOwnNumberFormatter->ChangeStandardPrec( 15 ); todo?
+ }
+ m_xNumberFormatsSupplier = m_xOwnNumberFormatsSupplier;
+ }
+ return m_xNumberFormatsSupplier;
+}
+
+// ____ XUnoTunnel ___
+::sal_Int64 SAL_CALL ChartModel::getSomething( const Sequence< ::sal_Int8 >& aIdentifier )
+{
+ if( isUnoTunnelId<SvNumberFormatsSupplierObj>(aIdentifier) )
+ {
+ Reference< lang::XUnoTunnel > xTunnel( getNumberFormatsSupplier(), uno::UNO_QUERY );
+ if( xTunnel.is() )
+ return xTunnel->getSomething( aIdentifier );
+ }
+ return 0;
+}
+
+// ____ XNumberFormatsSupplier ____
+uno::Reference< beans::XPropertySet > SAL_CALL ChartModel::getNumberFormatSettings()
+{
+ Reference< util::XNumberFormatsSupplier > xSupplier( getNumberFormatsSupplier() );
+ if( xSupplier.is() )
+ return xSupplier->getNumberFormatSettings();
+ return uno::Reference< beans::XPropertySet >();
+}
+
+uno::Reference< util::XNumberFormats > SAL_CALL ChartModel::getNumberFormats()
+{
+ Reference< util::XNumberFormatsSupplier > xSupplier( getNumberFormatsSupplier() );
+ if( xSupplier.is() )
+ return xSupplier->getNumberFormats();
+ return uno::Reference< util::XNumberFormats >();
+}
+
+// ____ XChild ____
+Reference< uno::XInterface > SAL_CALL ChartModel::getParent()
+{
+ return Reference< uno::XInterface >(m_xParent,uno::UNO_QUERY);
+}
+
+void SAL_CALL ChartModel::setParent( const Reference< uno::XInterface >& Parent )
+{
+ if( Parent != m_xParent )
+ m_xParent.set( Parent, uno::UNO_QUERY );
+}
+
+// ____ XDataSource ____
+uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL ChartModel::getDataSequences()
+{
+ Reference< chart2::data::XDataSource > xSource(
+ DataSourceHelper::getUsedData( uno::Reference< frame::XModel >(this) ) );
+ if( xSource.is())
+ return xSource->getDataSequences();
+
+ return uno::Sequence< Reference< chart2::data::XLabeledDataSequence > >();
+}
+
+//XDumper
+OUString SAL_CALL ChartModel::dump()
+{
+ uno::Reference< qa::XDumper > xDumper(
+ createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
+ if (xDumper.is())
+ return xDumper->dump();
+
+ return OUString();
+}
+
+void ChartModel::setTimeBasedRange(sal_Int32 nStart, sal_Int32 nEnd)
+{
+ mnStart = nStart;
+ mnEnd = nEnd;
+ mbTimeBased = true;
+}
+
+void ChartModel::update()
+{
+ if(!mxChartView.is())
+ {
+ mxChartView = new ChartView( m_xContext, *this);
+ }
+ mxChartView->setViewDirty();
+ mxChartView->update();
+}
+
+bool ChartModel::isDataFromSpreadsheet()
+{
+ return !isDataFromPivotTable() && !hasInternalDataProvider();
+}
+
+bool ChartModel::isDataFromPivotTable() const
+{
+ uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(m_xDataProvider, uno::UNO_QUERY);
+ return xPivotTableDataProvider.is();
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_ChartModel_get_implementation(css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::ChartModel(context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
new file mode 100644
index 000000000..b3dd7a7cf
--- /dev/null
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -0,0 +1,809 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <memory>
+#include <ChartModel.hxx>
+#include <MediaDescriptorHelper.hxx>
+#include <ChartViewHelper.hxx>
+#include <ChartModelHelper.hxx>
+#include <DataSourceHelper.hxx>
+#include <AxisHelper.hxx>
+#include <ThreeDHelper.hxx>
+#include <DiagramHelper.hxx>
+
+#include <com/sun/star/chart2/LegendPosition.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/drawing/ProjectionMode.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/StorageFactory.hpp>
+#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>
+
+#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp>
+
+#include <ucbhelper/content.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#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 <sal/log.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::osl::MutexGuard;
+
+namespace
+{
+struct lcl_PropNameEquals
+{
+ explicit lcl_PropNameEquals( const OUString & rStrToCompareWith ) :
+ m_aStr( rStrToCompareWith )
+ {}
+ bool operator() ( const beans::PropertyValue & rProp )
+ {
+ return rProp.Name == m_aStr;
+ }
+private:
+ OUString m_aStr;
+};
+
+template< typename T >
+T lcl_getProperty(
+ const Sequence< beans::PropertyValue > & rMediaDescriptor,
+ const OUString & rPropName )
+{
+ T aResult;
+ if( rMediaDescriptor.hasElements())
+ {
+ const beans::PropertyValue * pIt = rMediaDescriptor.getConstArray();
+ const beans::PropertyValue * pEndIt = pIt + + rMediaDescriptor.getLength();
+ pIt = std::find_if( pIt, pEndIt, lcl_PropNameEquals( rPropName ));
+ if( pIt != pEndIt )
+ (*pIt).Value >>= aResult;
+ }
+ return aResult;
+}
+
+void lcl_addStorageToMediaDescriptor(
+ Sequence< beans::PropertyValue > & rOutMD,
+ const Reference< embed::XStorage > & xStorage )
+{
+ rOutMD.realloc( rOutMD.getLength() + 1 );
+ rOutMD[rOutMD.getLength() - 1] = beans::PropertyValue(
+ "Storage", -1, uno::Any( xStorage ), beans::PropertyState_DIRECT_VALUE );
+}
+
+Reference< embed::XStorage > lcl_createStorage(
+ const OUString & rURL,
+ const Reference< uno::XComponentContext > & xContext,
+ const Sequence< beans::PropertyValue > & rMediaDescriptor )
+{
+ // create new storage
+ Reference< embed::XStorage > xStorage;
+ if( !xContext.is())
+ return xStorage;
+
+ try
+ {
+ Reference< io::XStream > xStream(
+ ::ucbhelper::Content( rURL, Reference< css::ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext()).openStream(),
+ uno::UNO_QUERY );
+
+ Reference< lang::XSingleServiceFactory > xStorageFact( embed::StorageFactory::create( xContext ) );
+ Sequence< uno::Any > aStorageArgs( 3 );
+ aStorageArgs[0] <<= xStream;
+ aStorageArgs[1] <<= embed::ElementModes::READWRITE;
+ aStorageArgs[2] <<= rMediaDescriptor;
+ xStorage.set(
+ xStorageFact->createInstanceWithArguments( aStorageArgs ), uno::UNO_QUERY_THROW );
+ }
+ catch(const css::ucb::ContentCreationException&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ catch(const css::ucb::CommandFailedException&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xStorage;
+}
+
+} // anonymous namespace
+
+namespace chart
+{
+
+Reference< document::XFilter > ChartModel::impl_createFilter(
+ const Sequence< beans::PropertyValue > & rMediaDescriptor )
+{
+ Reference< document::XFilter > xFilter;
+
+ // find FilterName in MediaDescriptor
+ OUString aFilterName(
+ lcl_getProperty< OUString >( rMediaDescriptor, "FilterName" ) );
+
+ // if FilterName was found, get Filter from factory
+ if( !aFilterName.isEmpty() )
+ {
+ try
+ {
+ Reference< container::XNameAccess > xFilterFact(
+ m_xContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.document.FilterFactory", m_xContext ),
+ uno::UNO_QUERY_THROW );
+ uno::Any aFilterProps( xFilterFact->getByName( aFilterName ));
+ Sequence< beans::PropertyValue > aProps;
+
+ if( aFilterProps.hasValue() &&
+ (aFilterProps >>= aProps))
+ {
+ OUString aFilterServiceName(
+ lcl_getProperty< OUString >( aProps, "FilterService" ) );
+
+ if( !aFilterServiceName.isEmpty())
+ {
+ xFilter.set(
+ m_xContext->getServiceManager()->createInstanceWithContext(
+ aFilterServiceName, m_xContext ), uno::UNO_QUERY_THROW );
+ SAL_INFO("chart2", "Filter found for service " << aFilterServiceName );
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ OSL_ENSURE( xFilter.is(), "Filter not found via factory" );
+ }
+
+ // fall-back: create XML-Filter
+ 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 );
+ }
+
+ return xFilter;
+}
+
+// frame::XStorable2
+
+void SAL_CALL ChartModel::storeSelf( const Sequence< beans::PropertyValue >& rMediaDescriptor )
+{
+ // only some parameters are allowed (see also SfxBaseModel)
+ // "VersionComment", "Author", "InteractionHandler", "StatusIndicator"
+ // However, they are ignored here. They would become interesting when
+ // charts support a standalone format again.
+ impl_store( rMediaDescriptor, m_xStorage );
+}
+
+// frame::XStorable (base of XStorable2)
+sal_Bool SAL_CALL ChartModel::hasLocation()
+{
+ //@todo guard
+ return !m_aResource.isEmpty();
+}
+
+OUString SAL_CALL ChartModel::getLocation()
+{
+ return impl_g_getLocation();
+}
+
+sal_Bool SAL_CALL ChartModel::isReadonly()
+{
+ //@todo guard
+ return m_bReadOnly;
+}
+
+void SAL_CALL ChartModel::store()
+{
+ apphelper::LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall(true)) //start LongLastingCall
+ return; //behave passive if already disposed or closed or throw exception @todo?
+
+ OUString aLocation = m_aResource;
+
+ if( aLocation.isEmpty() )
+ throw io::IOException( "no location specified", static_cast< ::cppu::OWeakObject* >(this));
+ //@todo check whether aLocation is something like private:factory...
+ if( m_bReadOnly )
+ throw io::IOException( "document is read only", static_cast< ::cppu::OWeakObject* >(this));
+
+ aGuard.clear();
+
+ // store
+ impl_store( m_aMediaDescriptor, m_xStorage );
+}
+
+void SAL_CALL ChartModel::storeAsURL(
+ const OUString& rURL,
+ const uno::Sequence< beans::PropertyValue >& rMediaDescriptor )
+{
+ apphelper::LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall(true)) //start LongLastingCall
+ return; //behave passive if already disposed or closed or throw exception @todo?
+
+ apphelper::MediaDescriptorHelper aMediaDescriptorHelper(rMediaDescriptor);
+ uno::Sequence< beans::PropertyValue > aReducedMediaDescriptor(
+ aMediaDescriptorHelper.getReducedForModel() );
+
+ m_bReadOnly = false;
+ aGuard.clear();
+
+ // create new storage
+ Reference< embed::XStorage > xStorage( lcl_createStorage( rURL, m_xContext, aReducedMediaDescriptor ));
+
+ if( xStorage.is())
+ {
+ impl_store( aReducedMediaDescriptor, xStorage );
+ attachResource( rURL, aReducedMediaDescriptor );
+ }
+}
+
+void SAL_CALL ChartModel::storeToURL(
+ const OUString& rURL,
+ const uno::Sequence< beans::PropertyValue >& rMediaDescriptor )
+{
+ apphelper::LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall(true)) //start LongLastingCall
+ return; //behave passive if already disposed or closed or throw exception @todo?
+ //do not change the internal state of the document here
+
+ aGuard.clear();
+
+ apphelper::MediaDescriptorHelper aMediaDescriptorHelper(rMediaDescriptor);
+ uno::Sequence< beans::PropertyValue > aReducedMediaDescriptor(
+ aMediaDescriptorHelper.getReducedForModel() );
+
+ if ( rURL == "private:stream" )
+ {
+ try
+ {
+ if( m_xContext.is() && aMediaDescriptorHelper.ISSET_OutputStream )
+ {
+ Reference< io::XStream > xStream(
+ io::TempFile::create(m_xContext), uno::UNO_QUERY_THROW );
+ Reference< io::XInputStream > xInputStream( xStream->getInputStream());
+
+ Reference< embed::XStorage > xStorage(
+ ::comphelper::OStorageHelper::GetStorageFromStream( xStream, embed::ElementModes::READWRITE, m_xContext ));
+ if( xStorage.is())
+ {
+ impl_store( aReducedMediaDescriptor, xStorage );
+
+ Reference< io::XSeekable > xSeekable( xStream, uno::UNO_QUERY_THROW );
+ xSeekable->seek( 0 );
+ ::comphelper::OStorageHelper::CopyInputToOutput( xInputStream, aMediaDescriptorHelper.OutputStream );
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+ else
+ {
+ // create new storage
+ Reference< embed::XStorage > xStorage( lcl_createStorage( rURL, m_xContext, aReducedMediaDescriptor ));
+
+ if( xStorage.is())
+ impl_store( aReducedMediaDescriptor, xStorage );
+ }
+}
+
+void ChartModel::impl_store(
+ const Sequence< beans::PropertyValue >& rMediaDescriptor,
+ const Reference< embed::XStorage > & xStorage )
+{
+ Reference< document::XFilter > xFilter( impl_createFilter( rMediaDescriptor));
+ if( xFilter.is() && xStorage.is())
+ {
+ Sequence< beans::PropertyValue > aMD( rMediaDescriptor );
+ lcl_addStorageToMediaDescriptor( aMD, xStorage );
+ try
+ {
+ Reference< document::XExporter > xExporter( xFilter, uno::UNO_QUERY_THROW );
+ xExporter->setSourceDocument( Reference< lang::XComponent >( this ));
+ xFilter->filter( aMD );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+ else
+ {
+ OSL_FAIL( "No filter" );
+ }
+
+ setModified( false );
+
+ //#i66865#
+ //for data change notification during chart is not loaded:
+ //notify parent data provider after saving thus the parent document can store
+ //the ranges for which a load and update of the chart will be necessary
+ Reference< beans::XPropertySet > xPropSet( m_xParent, uno::UNO_QUERY );
+ if ( !(!hasInternalDataProvider() && xPropSet.is()) )
+ return;
+
+ apphelper::MediaDescriptorHelper aMDHelper(rMediaDescriptor);
+ try
+ {
+ xPropSet->setPropertyValue(
+ "SavedObject",
+ uno::Any( aMDHelper.HierarchicalDocumentName ) );
+ }
+ catch ( const uno::Exception& )
+ {
+ }
+}
+
+void ChartModel::insertDefaultChart()
+{
+ lockControllers();
+ createInternalDataProvider( false );
+ try
+ {
+ // create default chart
+ Reference< chart2::XChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() );
+ if( xTemplate.is())
+ {
+ try
+ {
+ Reference< chart2::data::XDataSource > xDataSource( impl_createDefaultData() );
+ Sequence< beans::PropertyValue > aParam;
+
+ bool bSupportsCategories = xTemplate->supportsCategories();
+ if( bSupportsCategories )
+ {
+ aParam.realloc( 1 );
+ aParam[0] = beans::PropertyValue( "HasCategories", -1, uno::Any( true ),
+ beans::PropertyState_DIRECT_VALUE );
+ }
+
+ Reference< chart2::XDiagram > xDiagram( xTemplate->createDiagramByDataSource( xDataSource, aParam ) );
+
+ setFirstDiagram( xDiagram );
+
+ bool bIsRTL = AllSettings::GetMathLayoutRTL();
+ //reverse x axis for rtl charts
+ if( bIsRTL )
+ 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
+
+ if( bIsRTL )
+ xLegendProperties->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() )
+ {
+ xDiagramProperties->setPropertyValue( "RightAngledAxes", uno::Any( true ));
+ xDiagramProperties->setPropertyValue( "D3DScenePerspective", uno::Any( drawing::ProjectionMode_PARALLEL ));
+ ThreeDHelper::setScheme( xDiagram, ThreeDLookScheme_Realistic );
+ }
+
+ //set some new 'defaults' for wall and floor
+ if( xDiagram.is() )
+ {
+ Reference< beans::XPropertySet > xWall( xDiagram->getWall() );
+ if( xWall.is() )
+ {
+ xWall->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_SOLID ) );
+ xWall->setPropertyValue( "FillStyle", uno::Any( drawing::FillStyle_NONE ) );
+ xWall->setPropertyValue( "LineColor", uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
+ xWall->setPropertyValue( "FillColor", uno::Any( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
+ }
+ Reference< beans::XPropertySet > xFloor( xDiagram->getFloor() );
+ if( xFloor.is() )
+ {
+ xFloor->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE ) );
+ xFloor->setPropertyValue( "FillStyle", uno::Any( drawing::FillStyle_SOLID ) );
+ xFloor->setPropertyValue( "LineColor", uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
+ xFloor->setPropertyValue( "FillColor", uno::Any( static_cast< sal_Int32 >( 0xcccccc ) ) ); // gray20
+ }
+
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+ ChartModelHelper::setIncludeHiddenCells( false, *this );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ setModified( false );
+ unlockControllers();
+}
+
+// frame::XLoadable
+void SAL_CALL ChartModel::initNew()
+{
+}
+
+void SAL_CALL ChartModel::load(
+ const Sequence< beans::PropertyValue >& rMediaDescriptor )
+{
+ Reference< embed::XStorage > xStorage;
+ OUString aURL;
+ try
+ {
+ apphelper::MediaDescriptorHelper aMDHelper( rMediaDescriptor );
+ if( aMDHelper.ISSET_Storage )
+ {
+ xStorage = aMDHelper.Storage;
+ }
+ else if( aMDHelper.ISSET_Stream ||
+ aMDHelper.ISSET_InputStream )
+ {
+ if( aMDHelper.ISSET_FilterName &&
+ (aMDHelper.FilterName == "StarChart 5.0" ||
+ aMDHelper.FilterName == "StarChart 4.0" ||
+ aMDHelper.FilterName == "StarChart 3.0" ))
+ {
+ attachResource( aMDHelper.URL, rMediaDescriptor );
+ impl_load( rMediaDescriptor, nullptr ); // cannot create a storage from binary streams, but I do not need the storage here anyhow
+ m_bReadOnly = true;
+ return;
+ }
+
+ Reference< lang::XSingleServiceFactory > xStorageFact( embed::StorageFactory::create(m_xContext) );
+
+ if( aMDHelper.ISSET_Stream )
+ {
+ // convert XStream to XStorage via the storage factory
+ Sequence< uno::Any > aStorageArgs( 2 );
+ aStorageArgs[0] <<= aMDHelper.Stream;
+ // todo: check if stream is read-only
+ aStorageArgs[1] <<= embed::ElementModes::READ; //WRITE | embed::ElementModes::NOCREATE);
+
+ xStorage.set( xStorageFact->createInstanceWithArguments( aStorageArgs ),
+ uno::UNO_QUERY_THROW );
+ }
+ else
+ {
+ OSL_ASSERT( aMDHelper.ISSET_InputStream );
+ // convert XInputStream to XStorage via the storage factory
+ Sequence< uno::Any > aStorageArgs( 2 );
+ aStorageArgs[0] <<= aMDHelper.InputStream;
+ aStorageArgs[1] <<= embed::ElementModes::READ;
+
+ xStorage.set( xStorageFact->createInstanceWithArguments( aStorageArgs ),
+ uno::UNO_QUERY_THROW );
+ }
+ }
+
+ if( aMDHelper.ISSET_URL )
+ aURL = aMDHelper.URL;
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ if( xStorage.is())
+ {
+ attachResource( aURL, rMediaDescriptor );
+ impl_load( rMediaDescriptor, xStorage );
+ }
+}
+
+void ChartModel::impl_load(
+ const Sequence< beans::PropertyValue >& rMediaDescriptor,
+ const Reference< embed::XStorage >& xStorage )
+{
+ {
+ MutexGuard aGuard( m_aModelMutex );
+ m_nInLoad++;
+ }
+
+ Reference< document::XFilter > xFilter( impl_createFilter( rMediaDescriptor ));
+
+ if( xFilter.is())
+ {
+ Reference< document::XImporter > xImporter( xFilter, uno::UNO_QUERY_THROW );
+ xImporter->setTargetDocument( this );
+ Sequence< beans::PropertyValue > aMD( rMediaDescriptor );
+ lcl_addStorageToMediaDescriptor( aMD, xStorage );
+
+ xFilter->filter( aMD );
+ xFilter.clear();
+ }
+ else
+ {
+ OSL_FAIL( "loadFromStorage cannot create filter" );
+ }
+
+ if( xStorage.is() )
+ impl_loadGraphics( xStorage );
+
+ setModified( false );
+
+ // switchToStorage without notifying listeners (which shouldn't exist at
+ // this time, anyway)
+ m_xStorage = xStorage;
+
+ {
+ MutexGuard aGuard( m_aModelMutex );
+ m_nInLoad--;
+ }
+}
+
+void ChartModel::impl_loadGraphics(
+ const Reference< embed::XStorage >& xStorage )
+{
+ try
+ {
+ const Reference< embed::XStorage >& xGraphicsStorage(
+ xStorage->openStorageElement( "Pictures",
+ embed::ElementModes::READ ) );
+
+ if( xGraphicsStorage.is() )
+ {
+ const uno::Sequence< OUString > aElementNames(
+ xGraphicsStorage->getElementNames() );
+
+ for( OUString const & streamName : aElementNames )
+ {
+ if( xGraphicsStorage->isStreamElement( streamName ) )
+ {
+ uno::Reference< io::XStream > xElementStream(
+ xGraphicsStorage->openStreamElement(
+ streamName,
+ embed::ElementModes::READ ) );
+
+ if( xElementStream.is() )
+ {
+ std::unique_ptr< SvStream > apIStm(
+ ::utl::UcbStreamHelper::CreateStream(
+ xElementStream, true ) );
+
+ if (apIStm)
+ {
+ SolarMutexGuard aGuard;
+ Graphic aGraphic;
+ if (!GraphicConverter::Import(*apIStm, aGraphic))
+ {
+ m_aGraphicObjectVector.emplace_back(aGraphic );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ catch ( const uno::Exception& )
+ {
+ }
+}
+
+// util::XModifiable
+void ChartModel::impl_notifyModifiedListeners()
+{
+ {
+ MutexGuard aGuard( m_aModelMutex );
+ m_bUpdateNotificationsPending = false;
+ }
+
+ //always notify the view first!
+ ChartViewHelper::setViewToDirtyState( this );
+
+ ::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer
+ .getContainer( cppu::UnoType<util::XModifyListener>::get());
+ if( pIC )
+ {
+ lang::EventObject aEvent( static_cast< lang::XComponent*>(this) );
+ ::cppu::OInterfaceIteratorHelper aIt( *pIC );
+ while( aIt.hasMoreElements() )
+ {
+ uno::Reference< util::XModifyListener > xListener( aIt.next(), uno::UNO_QUERY );
+ if( xListener.is() )
+ xListener->modified( aEvent );
+ }
+ }
+}
+
+sal_Bool SAL_CALL ChartModel::isModified()
+{
+ //@todo guard
+ return m_bModified;
+}
+
+void SAL_CALL ChartModel::setModified( sal_Bool bModified )
+{
+ apphelper::LifeTimeGuard aGuard(m_aLifeTimeManager);
+ if(!aGuard.startApiCall())//@todo ? is this a long lasting call??
+ return; //behave passive if already disposed or closed or throw exception @todo?
+ m_bModified = bModified;
+
+ if( m_nControllerLockCount > 0 )
+ {
+ m_bUpdateNotificationsPending = true;
+ return;//don't call listeners if controllers are locked
+ }
+ aGuard.clear();
+
+ if(bModified)
+ impl_notifyModifiedListeners();
+}
+
+// util::XModifyBroadcaster (base of XModifiable)
+void SAL_CALL ChartModel::addModifyListener(
+ const uno::Reference< util::XModifyListener >& xListener )
+{
+ if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
+ return; //behave passive if already disposed or closed
+
+ m_aLifeTimeManager.m_aListenerContainer.addInterface(
+ cppu::UnoType<util::XModifyListener>::get(), xListener );
+}
+
+void SAL_CALL ChartModel::removeModifyListener(
+ const uno::Reference< util::XModifyListener >& xListener )
+{
+ 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 );
+}
+
+// util::XModifyListener
+void SAL_CALL ChartModel::modified( const lang::EventObject& rEvenObject)
+{
+ uno::Reference<chart2::data::XPivotTableDataProvider> xPivotTableDataProvider(rEvenObject.Source, uno::UNO_QUERY);
+ if (xPivotTableDataProvider.is())
+ {
+ lockControllers();
+ uno::Reference<chart2::data::XDataProvider> xDataProvider(xPivotTableDataProvider, uno::UNO_QUERY);
+ try
+ {
+ uno::Sequence<beans::PropertyValue> aArguments =
+ 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());
+
+ DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram(xDiagram, xFactory);
+ css::uno::Reference<css::chart2::XChartTypeTemplate> xChartTypeTemplate(aTemplateAndService.first);
+ xChartTypeTemplate->changeDiagramData(xDiagram, xDataSource, aArguments);
+ }
+ catch (const uno::Exception &)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ unlockControllers();
+ }
+
+ if (m_nInLoad == 0)
+ setModified(true);
+}
+
+// lang::XEventListener (base of util::XModifyListener)
+void SAL_CALL ChartModel::disposing( const lang::EventObject& )
+{
+ // child was disposed -- should not happen from outside
+}
+
+// document::XStorageBasedDocument
+void SAL_CALL ChartModel::loadFromStorage(
+ const Reference< embed::XStorage >& xStorage,
+ const Sequence< beans::PropertyValue >& rMediaDescriptor )
+{
+ attachResource( OUString(), rMediaDescriptor );
+ impl_load( rMediaDescriptor, xStorage );
+}
+
+void SAL_CALL ChartModel::storeToStorage(
+ const Reference< embed::XStorage >& xStorage,
+ const Sequence< beans::PropertyValue >& rMediaDescriptor )
+{
+ impl_store( rMediaDescriptor, xStorage );
+}
+
+void SAL_CALL ChartModel::switchToStorage( const Reference< embed::XStorage >& xStorage )
+{
+ m_xStorage = xStorage;
+ impl_notifyStorageChangeListeners();
+}
+
+Reference< embed::XStorage > SAL_CALL ChartModel::getDocumentStorage()
+{
+ return m_xStorage;
+}
+
+void ChartModel::impl_notifyStorageChangeListeners()
+{
+ ::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer
+ .getContainer( cppu::UnoType<document::XStorageChangeListener>::get());
+ if( pIC )
+ {
+ ::cppu::OInterfaceIteratorHelper aIt( *pIC );
+ while( aIt.hasMoreElements() )
+ {
+ uno::Reference< document::XStorageChangeListener > xListener( aIt.next(), uno::UNO_QUERY );
+ if( xListener.is() )
+ xListener->notifyStorageChange( static_cast< ::cppu::OWeakObject* >( this ), m_xStorage );
+ }
+ }
+}
+
+void SAL_CALL ChartModel::addStorageChangeListener( const Reference< document::XStorageChangeListener >& xListener )
+{
+ if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
+ return; //behave passive if already disposed or closed
+
+ m_aLifeTimeManager.m_aListenerContainer.addInterface(
+ cppu::UnoType<document::XStorageChangeListener>::get(), xListener );
+}
+
+void SAL_CALL ChartModel::removeStorageChangeListener( const Reference< document::XStorageChangeListener >& xListener )
+{
+ 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 );
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/DataPoint.cxx b/chart2/source/model/main/DataPoint.cxx
new file mode 100644
index 000000000..6e9f6d483
--- /dev/null
+++ b/chart2/source/model/main/DataPoint.cxx
@@ -0,0 +1,293 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "DataPoint.hxx"
+#include "DataPointProperties.hxx"
+#include <CharacterProperties.hxx>
+#include <UserDefinedProperties.hxx>
+#include <PropertyHelper.hxx>
+#include <ModifyListenerHelper.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::Property;
+
+namespace
+{
+
+struct StaticDataPointInfoHelper_Initializer
+{
+ ::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 );
+ }
+};
+
+struct StaticDataPointInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDataPointInfoHelper_Initializer >
+{
+};
+
+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 >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+DataPoint::DataPoint( const uno::Reference< beans::XPropertySet > & rParentProperties ) :
+ ::property::OPropertySet( m_aMutex ),
+ m_xParentProperties( rParentProperties ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_bNoParentPropAllowed( false )
+{
+ SetNewValuesExplicitlyEvenIfTheyEqualDefault();
+}
+
+DataPoint::DataPoint( const DataPoint & rOther ) :
+ impl::DataPoint_Base(rOther),
+ ::property::OPropertySet( rOther, m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_bNoParentPropAllowed( true )
+{
+ SetNewValuesExplicitlyEvenIfTheyEqualDefault();
+
+ // m_xParentProperties has to be set from outside, like in the method
+ // DataSeries::createClone
+
+ // add as listener to XPropertySet properties
+ Reference< beans::XPropertySet > xPropertySet;
+ uno::Any aValue;
+
+ getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_X );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ ModifyListenerHelper::addListener( xPropertySet, m_xModifyEventForwarder );
+
+ getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_Y );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ ModifyListenerHelper::addListener( xPropertySet, m_xModifyEventForwarder );
+
+ m_bNoParentPropAllowed = false;
+}
+
+DataPoint::~DataPoint()
+{
+ try
+ {
+ // remove listener from XPropertySet properties
+ Reference< beans::XPropertySet > xPropertySet;
+ uno::Any aValue;
+
+ getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_X );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ ModifyListenerHelper::removeListener( xPropertySet, m_xModifyEventForwarder );
+
+ getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_Y );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ ModifyListenerHelper::removeListener( xPropertySet, m_xModifyEventForwarder );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL DataPoint::createClone()
+{
+ return uno::Reference< util::XCloneable >( new DataPoint( *this ));
+}
+
+// ____ XChild ____
+Reference< uno::XInterface > SAL_CALL DataPoint::getParent()
+{
+ return Reference< uno::XInterface >( m_xParentProperties.get(), uno::UNO_QUERY );
+}
+
+void SAL_CALL DataPoint::setParent(
+ const Reference< uno::XInterface >& Parent )
+{
+ m_xParentProperties = Reference< beans::XPropertySet >( Parent, uno::UNO_QUERY );
+}
+
+// ____ OPropertySet ____
+uno::Any DataPoint::GetDefaultValue( sal_Int32 nHandle ) 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();
+ }
+
+ return xFast->getFastPropertyValue( nHandle );
+}
+
+void SAL_CALL DataPoint::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle, const uno::Any& rValue )
+{
+ if( nHandle == DataPointProperties::PROP_DATAPOINT_ERROR_BAR_Y
+ || nHandle == DataPointProperties::PROP_DATAPOINT_ERROR_BAR_X )
+ {
+ uno::Any aOldValue;
+ Reference< util::XModifyBroadcaster > xBroadcaster;
+ getFastPropertyValue( aOldValue, nHandle );
+ if( aOldValue.hasValue() &&
+ (aOldValue >>= xBroadcaster) &&
+ xBroadcaster.is())
+ {
+ ModifyListenerHelper::removeListener( xBroadcaster, m_xModifyEventForwarder );
+ }
+
+ OSL_ASSERT( rValue.getValueType().getTypeClass() == uno::TypeClass_INTERFACE );
+ if( rValue.hasValue() &&
+ (rValue >>= xBroadcaster) &&
+ xBroadcaster.is())
+ {
+ ModifyListenerHelper::addListener( xBroadcaster, m_xModifyEventForwarder );
+ }
+ }
+
+ ::property::OPropertySet::setFastPropertyValue_NoBroadcast( nHandle, rValue );
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL DataPoint::getInfoHelper()
+{
+ return *StaticDataPointInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+Reference< beans::XPropertySetInfo > SAL_CALL DataPoint::getPropertySetInfo()
+{
+ return *StaticDataPointInfo::get();
+}
+
+// ____ 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");
+ }
+}
+
+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");
+ }
+}
+
+// ____ XModifyListener ____
+void SAL_CALL DataPoint::modified( const lang::EventObject& aEvent )
+{
+ m_xModifyEventForwarder->modified( aEvent );
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL DataPoint::disposing( const lang::EventObject& )
+{
+ // nothing
+}
+
+// ____ OPropertySet ____
+void DataPoint::firePropertyChangeEvent()
+{
+ m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
+}
+
+// needed by MSC compiler
+using impl::DataPoint_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( DataPoint, DataPoint_Base, ::property::OPropertySet )
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+OUString SAL_CALL DataPoint::getImplementationName()
+{
+ return "com.sun.star.comp.chart.DataPoint" ;
+}
+
+sal_Bool SAL_CALL DataPoint::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL DataPoint::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.drawing.FillProperties",
+ "com.sun.star.chart2.DataPoint",
+ "com.sun.star.chart2.DataPointProperties",
+ "com.sun.star.beans.PropertySet"
+ };
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/DataPoint.hxx b/chart2/source/model/main/DataPoint.hxx
new file mode 100644
index 000000000..de3e50203
--- /dev/null
+++ b/chart2/source/model/main/DataPoint.hxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_MAIN_DATAPOINT_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_MAIN_DATAPOINT_HXX
+
+#include <cppuhelper/implbase.hxx>
+#include <cppuhelper/weakref.hxx>
+#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>
+
+namespace chart
+{
+
+namespace impl
+{
+typedef ::cppu::WeakImplHelper<
+ css::container::XChild,
+ css::util::XCloneable,
+ css::util::XModifyBroadcaster,
+ css::util::XModifyListener,
+ css::lang::XServiceInfo >
+ DataPoint_Base;
+}
+
+class DataPoint final :
+ public MutexContainer,
+ public impl::DataPoint_Base,
+ public ::property::OPropertySet
+{
+public:
+ explicit DataPoint( const css::uno::Reference< css::beans::XPropertySet > & rParentProperties );
+ virtual ~DataPoint() override;
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// XServiceInfo declarations
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+private:
+ explicit DataPoint( const DataPoint & rOther );
+
+ // ____ OPropertySet ____
+ virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast
+ ( sal_Int32 nHandle,
+ const css::uno::Any& rValue ) override;
+
+ // ____ XPropertySet ____
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo() override;
+
+ // ____ XCloneable ____
+ // Note: m_xParentProperties are not cloned!
+ virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+
+ // ____ XChild ____
+ virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override;
+ virtual void SAL_CALL setParent(
+ const css::uno::Reference< css::uno::XInterface >& Parent ) 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::WeakReference< css::beans::XPropertySet > m_xParentProperties;
+
+ css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
+ bool m_bNoParentPropAllowed;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_MAIN_DATAPOINT_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/DataPointProperties.cxx b/chart2/source/model/main/DataPointProperties.cxx
new file mode 100644
index 000000000..dba488fdd
--- /dev/null
+++ b/chart2/source/model/main/DataPointProperties.cxx
@@ -0,0 +1,540 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "DataPointProperties.hxx"
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <unonames.hxx>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/drawing/LineDash.hpp>
+#include <com/sun/star/drawing/LineCap.hpp>
+#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/XDataPointCustomLabelField.hpp>
+#include <com/sun/star/chart2/DataPointGeometry3D.hpp>
+#include <com/sun/star/chart2/DataPointLabel.hpp>
+#include <com/sun/star/chart2/Symbol.hpp>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+
+namespace chart
+{
+
+void DataPointProperties::AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ // DataPointProperties
+
+ // Common
+
+ rOutProperties.emplace_back( "Color",
+ PROP_DATAPOINT_COLOR,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID // "maybe auto"
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "FillColor",
+ PROP_DATAPOINT_COLOR,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID // "maybe auto"
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "Transparency",
+ PROP_DATAPOINT_TRANSPARENCY,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "FillTransparence",
+ PROP_DATAPOINT_TRANSPARENCY,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // Fill Properties
+ rOutProperties.emplace_back( "FillStyle",
+ PROP_DATAPOINT_FILL_STYLE,
+ cppu::UnoType<drawing::FillStyle>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "TransparencyGradientName",
+ PROP_DATAPOINT_TRANSPARENCY_GRADIENT_NAME,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "FillTransparenceGradientName",
+ PROP_DATAPOINT_TRANSPARENCY_GRADIENT_NAME,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "GradientName",
+ PROP_DATAPOINT_GRADIENT_NAME,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "FillGradientName",
+ PROP_DATAPOINT_GRADIENT_NAME,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "GradientStepCount",
+ PROP_DATAPOINT_GRADIENT_STEPCOUNT,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "FillGradientStepCount",
+ PROP_DATAPOINT_GRADIENT_STEPCOUNT,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "HatchName",
+ PROP_DATAPOINT_HATCH_NAME,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "FillHatchName",
+ PROP_DATAPOINT_HATCH_NAME,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "FillBitmapName",
+ PROP_DATAPOINT_FILL_BITMAP_NAME,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "FillBackground",
+ PROP_DATAPOINT_FILL_BACKGROUND,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ // border for filled objects
+ rOutProperties.emplace_back( "BorderColor",
+ PROP_DATAPOINT_BORDER_COLOR,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID // "maybe auto"
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "BorderStyle",
+ PROP_DATAPOINT_BORDER_STYLE,
+ cppu::UnoType<drawing::LineStyle>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "BorderWidth",
+ PROP_DATAPOINT_BORDER_WIDTH,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "BorderDashName",
+ PROP_DATAPOINT_BORDER_DASH_NAME,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "BorderTransparency",
+ PROP_DATAPOINT_BORDER_TRANSPARENCY,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ // Line Properties
+
+ rOutProperties.emplace_back( "LineColor",
+ PROP_DATAPOINT_BORDER_COLOR,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "LineStyle",
+ LinePropertiesHelper::PROP_LINE_STYLE,
+ cppu::UnoType<drawing::LineStyle>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "LineWidth",
+ LinePropertiesHelper::PROP_LINE_WIDTH,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "LineDash",
+ LinePropertiesHelper::PROP_LINE_DASH,
+ cppu::UnoType<drawing::LineDash>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "LineDashName",
+ LinePropertiesHelper::PROP_LINE_DASH_NAME,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "LineTransparence",
+ PROP_DATAPOINT_BORDER_TRANSPARENCY,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "LineCap",
+ ::chart::LinePropertiesHelper::PROP_LINE_CAP,
+ cppu::UnoType<drawing::LineCap>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // FillProperties
+ // bitmap properties
+ rOutProperties.emplace_back( "FillBitmapOffsetX",
+ FillProperties::PROP_FILL_BITMAP_OFFSETX,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "FillBitmapOffsetY",
+ FillProperties::PROP_FILL_BITMAP_OFFSETY,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "FillBitmapPositionOffsetX",
+ FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETX,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "FillBitmapPositionOffsetY",
+ FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETY,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "FillBitmapRectanglePoint",
+ FillProperties::PROP_FILL_BITMAP_RECTANGLEPOINT,
+ cppu::UnoType<drawing::RectanglePoint>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "FillBitmapLogicalSize",
+ FillProperties::PROP_FILL_BITMAP_LOGICALSIZE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "FillBitmapSizeX",
+ FillProperties::PROP_FILL_BITMAP_SIZEX,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "FillBitmapSizeY",
+ FillProperties::PROP_FILL_BITMAP_SIZEY,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "FillBitmapMode",
+ FillProperties::PROP_FILL_BITMAP_MODE,
+ cppu::UnoType<drawing::BitmapMode>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // others
+ rOutProperties.emplace_back( "Symbol",
+ PROP_DATAPOINT_SYMBOL_PROP,
+ cppu::UnoType<chart2::Symbol>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "Offset",
+ PROP_DATAPOINT_OFFSET,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "Geometry3D",
+ PROP_DATAPOINT_GEOMETRY3D,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_NUMFMT,
+ PROP_DATAPOINT_NUMBER_FORMAT,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_LINK_TO_SRC_NUMFMT,
+ PROP_DATAPOINT_LINK_NUMBERFORMAT_TO_SOURCE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ //additional 'PercentageNumberFormat'
+ rOutProperties.emplace_back( "PercentageNumberFormat",
+ PROP_DATAPOINT_PERCENTAGE_NUMBER_FORMAT,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "LabelPlacement",
+ PROP_DATAPOINT_LABEL_PLACEMENT,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "ReferencePageSize",
+ PROP_DATAPOINT_REFERENCE_DIAGRAM_SIZE,
+ cppu::UnoType<awt::Size>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "TextRotation",
+ PROP_DATAPOINT_TEXT_ROTATION,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ // statistics
+ rOutProperties.emplace_back( CHART_UNONAME_ERRORBAR_X,
+ PROP_DATAPOINT_ERROR_BAR_X,
+ // XPropertySet supporting service ErrorBar
+ cppu::UnoType<beans::XPropertySet>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( CHART_UNONAME_ERRORBAR_Y,
+ PROP_DATAPOINT_ERROR_BAR_Y,
+ // XPropertySet supporting service ErrorBar
+ cppu::UnoType<beans::XPropertySet>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( "ShowErrorBox",
+ PROP_DATAPOINT_SHOW_ERROR_BOX,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( "PercentDiagonal",
+ PROP_DATAPOINT_PERCENT_DIAGONAL,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ // Properties specific to data label.
+
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL,
+ PROP_DATAPOINT_LABEL,
+ cppu::UnoType<chart2::DataPointLabel>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "TextWordWrap",
+ PROP_DATAPOINT_TEXT_WORD_WRAP,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_SEP,
+ PROP_DATAPOINT_LABEL_SEPARATOR,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_STYLE,
+ PROP_DATAPOINT_LABEL_BORDER_STYLE,
+ cppu::UnoType<drawing::LineStyle>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_COLOR,
+ PROP_DATAPOINT_LABEL_BORDER_COLOR,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID // "maybe auto"
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_FILL_STYLE,
+ PROP_DATAPOINT_LABEL_FILL_STYLE,
+ cppu::UnoType<drawing::FillStyle>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_FILL_COLOR,
+ PROP_DATAPOINT_LABEL_FILL_COLOR,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_FILL_BACKGROUND,
+ PROP_DATAPOINT_LABEL_FILL_BACKGROUND,
+ cppu::UnoType<sal_Bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_FILL_HATCH_NAME,
+ PROP_DATAPOINT_LABEL_FILL_HATCH_NAME,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_WIDTH,
+ PROP_DATAPOINT_LABEL_BORDER_WIDTH,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_DASH,
+ PROP_DATAPOINT_LABEL_BORDER_DASH,
+ cppu::UnoType<drawing::LineDash>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_DASHNAME,
+ PROP_DATAPOINT_LABEL_BORDER_DASH_NAME,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( CHART_UNONAME_LABEL_BORDER_TRANS,
+ PROP_DATAPOINT_LABEL_BORDER_TRANS,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_CUSTOM_LABEL_FIELDS,
+ PROP_DATAPOINT_CUSTOM_LABEL_FIELDS,
+ cppu::UnoType<uno::Sequence<uno::Reference<chart2::XDataPointCustomLabelField>>>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT);
+
+ rOutProperties.emplace_back( "CustomLabelPosition",
+ PROP_DATAPOINT_LABEL_CUSTOM_POS,
+ cppu::UnoType<chart2::RelativePosition>::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 );
+
+ //fill
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_FILL_STYLE, drawing::FillStyle_SOLID );
+ PropertyHelper::setEmptyPropertyValueDefault( rOutMap, PROP_DATAPOINT_TRANSPARENCY_GRADIENT_NAME );
+ PropertyHelper::setEmptyPropertyValueDefault( rOutMap, PROP_DATAPOINT_GRADIENT_NAME );
+ PropertyHelper::setEmptyPropertyValueDefault( rOutMap, PROP_DATAPOINT_HATCH_NAME );
+ PropertyHelper::setEmptyPropertyValueDefault( rOutMap, PROP_DATAPOINT_FILL_BITMAP_NAME );
+ 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_STYLE, drawing::LineStyle_SOLID ); // drawing::LineStyle_NONE
+ PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DATAPOINT_BORDER_WIDTH, 0 );
+ PropertyHelper::setEmptyPropertyValueDefault( rOutMap, PROP_DATAPOINT_BORDER_DASH_NAME );
+ PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_DATAPOINT_BORDER_TRANSPARENCY, 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_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_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_MODE, drawing::BitmapMode_REPEAT );
+
+ //others
+ chart2::Symbol aSymbProp;
+ 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.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_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< double >( rOutMap, PROP_DATAPOINT_TEXT_ROTATION, 0.0 );
+
+ PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LINK_NUMBERFORMAT_TO_SOURCE, true);
+
+ // data label
+ PropertyHelper::setPropertyValueDefault(
+ rOutMap, PROP_DATAPOINT_LABEL,
+ chart2::DataPointLabel(
+ false, // ShowNumber
+ false, // ShowNumberInPercent
+ false, // ShowCategoryName
+ false // ShowLegendSymbol
+ ));
+
+ 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::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_DASH, drawing::LineDash());
+ PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_DASH_NAME);
+ PropertyHelper::setPropertyValueDefault<sal_Int16>(rOutMap, PROP_DATAPOINT_LABEL_BORDER_TRANS, 0);
+
+ uno::Sequence<uno::Reference<chart2::XDataPointCustomLabelField>> aFields(0);
+ PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_CUSTOM_LABEL_FIELDS, aFields);
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/DataPointProperties.hxx b/chart2/source/model/main/DataPointProperties.hxx
new file mode 100644
index 000000000..1998c4e20
--- /dev/null
+++ b/chart2/source/model/main/DataPointProperties.hxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_MAIN_DATAPOINTPROPERTIES_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_MAIN_DATAPOINTPROPERTIES_HXX
+
+#include <PropertyHelper.hxx>
+#include <FastPropertyIdRanges.hxx>
+
+#include <vector>
+
+namespace com::sun::star::beans { struct Property; }
+
+namespace chart
+{
+
+// implements service DataPointProperties
+namespace DataPointProperties
+{
+ // FastProperty Ids for properties
+ enum
+ {
+ PROP_DATAPOINT_LABEL_FILL_STYLE,
+ PROP_DATAPOINT_LABEL_FILL_COLOR,
+ PROP_DATAPOINT_LABEL_FILL_BACKGROUND,
+ PROP_DATAPOINT_LABEL_FILL_HATCH_NAME,
+
+ // common
+ PROP_DATAPOINT_COLOR = FAST_PROPERTY_ID_START_DATA_POINT,
+ PROP_DATAPOINT_TRANSPARENCY,
+
+ // fill
+ PROP_DATAPOINT_FILL_STYLE,
+ PROP_DATAPOINT_TRANSPARENCY_GRADIENT_NAME,
+ PROP_DATAPOINT_GRADIENT_NAME,
+ PROP_DATAPOINT_GRADIENT_STEPCOUNT,
+ PROP_DATAPOINT_HATCH_NAME,
+ PROP_DATAPOINT_FILL_BITMAP_NAME,
+ PROP_DATAPOINT_FILL_BACKGROUND,
+
+ // border (of filled objects)
+ PROP_DATAPOINT_BORDER_COLOR,
+ PROP_DATAPOINT_BORDER_STYLE,
+ PROP_DATAPOINT_BORDER_WIDTH,
+ PROP_DATAPOINT_BORDER_DASH_NAME,
+ PROP_DATAPOINT_BORDER_TRANSPARENCY,
+
+ // others
+ PROP_DATAPOINT_SYMBOL_PROP,
+ PROP_DATAPOINT_OFFSET,
+ PROP_DATAPOINT_GEOMETRY3D,
+ PROP_DATAPOINT_NUMBER_FORMAT,
+ PROP_DATAPOINT_LINK_NUMBERFORMAT_TO_SOURCE,
+ PROP_DATAPOINT_PERCENTAGE_NUMBER_FORMAT,
+ PROP_DATAPOINT_LABEL_PLACEMENT,
+ PROP_DATAPOINT_REFERENCE_DIAGRAM_SIZE,
+ PROP_DATAPOINT_TEXT_ROTATION,
+
+ // statistics
+ PROP_DATAPOINT_ERROR_BAR_X,
+ PROP_DATAPOINT_ERROR_BAR_Y,
+ PROP_DATAPOINT_SHOW_ERROR_BOX,
+ PROP_DATAPOINT_PERCENT_DIAGONAL,
+
+ // label
+ PROP_DATAPOINT_LABEL,
+ PROP_DATAPOINT_LABEL_SEPARATOR,
+ PROP_DATAPOINT_TEXT_WORD_WRAP,
+ PROP_DATAPOINT_LABEL_BORDER_STYLE,
+ PROP_DATAPOINT_LABEL_BORDER_COLOR,
+ PROP_DATAPOINT_LABEL_BORDER_WIDTH,
+ PROP_DATAPOINT_LABEL_BORDER_DASH,
+ PROP_DATAPOINT_LABEL_BORDER_DASH_NAME,
+ PROP_DATAPOINT_LABEL_BORDER_TRANS,
+ PROP_DATAPOINT_CUSTOM_LABEL_FIELDS,
+ PROP_DATAPOINT_LABEL_CUSTOM_POS
+
+ // additionally some properties from ::chart::LineProperties
+ };
+
+ void AddPropertiesToVector(
+ std::vector< css::beans::Property > & rOutProperties );
+
+ void AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap );
+}
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_MAIN_DATAPOINTPROPERTIES_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/DataSeries.cxx b/chart2/source/model/main/DataSeries.cxx
new file mode 100644
index 000000000..5c0ded40c
--- /dev/null
+++ b/chart2/source/model/main/DataSeries.cxx
@@ -0,0 +1,565 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <DataSeries.hxx>
+#include "DataSeriesProperties.hxx"
+#include "DataPointProperties.hxx"
+#include <CharacterProperties.hxx>
+#include <UserDefinedProperties.hxx>
+#include "DataPoint.hxx"
+#include <DataSeriesHelper.hxx>
+#include <CloneHelper.hxx>
+#include <ModifyListenerHelper.hxx>
+#include <EventListenerHelper.hxx>
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <cppuhelper/supportsservice.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <algorithm>
+
+namespace com::sun::star::uno { class XComponentContext; }
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+using ::osl::MutexGuard;
+
+namespace
+{
+
+struct StaticDataSeriesDefaults : public rtl::StaticWithInit< ::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;
+ }
+};
+
+struct StaticDataSeriesInfoHelper : public rtl::StaticWithInit< ::cppu::OPropertyArrayHelper, StaticDataSeriesInfoHelper, StaticDataSeriesInfoHelper, uno::Sequence< Property > >
+{
+ 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() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+};
+
+struct StaticDataSeriesInfo : public rtl::StaticWithInit< uno::Reference< beans::XPropertySetInfo >, StaticDataSeriesInfo >
+{
+ uno::Reference< beans::XPropertySetInfo > operator()()
+ {
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDataSeriesInfoHelper::get() );
+ }
+};
+
+void lcl_SetParent(
+ const uno::Reference< uno::XInterface > & xChildInterface,
+ const uno::Reference< uno::XInterface > & xParentInterface )
+{
+ uno::Reference< container::XChild > xChild( xChildInterface, uno::UNO_QUERY );
+ if( xChild.is())
+ xChild->setParent( xParentInterface );
+}
+
+typedef std::map< sal_Int32, css::uno::Reference< css::beans::XPropertySet > >
+ lcl_tDataPointMap;
+
+void lcl_CloneAttributedDataPoints(
+ const lcl_tDataPointMap & rSource, lcl_tDataPointMap & rDestination,
+ const uno::Reference< uno::XInterface > & xSeries )
+{
+ for (auto const& elem : rSource)
+ {
+ Reference< beans::XPropertySet > xPoint( elem.second );
+ if( xPoint.is())
+ {
+ Reference< util::XCloneable > xCloneable( xPoint, uno::UNO_QUERY );
+ if( xCloneable.is())
+ {
+ xPoint.set( xCloneable->createClone(), uno::UNO_QUERY );
+ if( xPoint.is())
+ {
+ lcl_SetParent( xPoint, xSeries );
+ rDestination.emplace( elem.first, xPoint );
+ }
+ }
+ }
+ }
+}
+
+} // anonymous namespace
+
+namespace chart
+{
+
+DataSeries::DataSeries() :
+ ::property::OPropertySet( m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{
+}
+
+DataSeries::DataSeries( const DataSeries & rOther ) :
+ impl::DataSeries_Base(rOther),
+ ::property::OPropertySet( rOther, m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{
+ if( ! rOther.m_aDataSequences.empty())
+ {
+ CloneHelper::CloneRefVector<css::chart2::data::XLabeledDataSequence>(
+ rOther.m_aDataSequences, m_aDataSequences );
+ ModifyListenerHelper::addListenerToAllElements( m_aDataSequences, m_xModifyEventForwarder );
+ }
+
+ CloneHelper::CloneRefVector< chart2::XRegressionCurve >( rOther.m_aRegressionCurves, m_aRegressionCurves );
+ ModifyListenerHelper::addListenerToAllElements( m_aRegressionCurves, m_xModifyEventForwarder );
+
+ // add as listener to XPropertySet properties
+ Reference< beans::XPropertySet > xPropertySet;
+ uno::Any aValue;
+
+ getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_X );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ ModifyListenerHelper::addListener( xPropertySet, m_xModifyEventForwarder );
+
+ getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_Y );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ ModifyListenerHelper::addListener( xPropertySet, m_xModifyEventForwarder );
+}
+
+// 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())
+ {
+ lcl_CloneAttributedDataPoints(
+ rOther.m_aAttributedDataPoints, m_aAttributedDataPoints, xThisInterface );
+ ModifyListenerHelper::addListenerToAllMapElements( m_aAttributedDataPoints, m_xModifyEventForwarder );
+ }
+
+ // add as parent to error bars
+ Reference< beans::XPropertySet > xPropertySet;
+ uno::Any aValue;
+
+ getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_X );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ lcl_SetParent( xPropertySet, xThisInterface );
+
+ getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_Y );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ lcl_SetParent( xPropertySet, xThisInterface );
+}
+
+DataSeries::~DataSeries()
+{
+ try
+ {
+ ModifyListenerHelper::removeListenerFromAllMapElements( m_aAttributedDataPoints, m_xModifyEventForwarder );
+ ModifyListenerHelper::removeListenerFromAllElements( m_aRegressionCurves, m_xModifyEventForwarder );
+ ModifyListenerHelper::removeListenerFromAllElements( m_aDataSequences, m_xModifyEventForwarder );
+
+ // remove listener from XPropertySet properties
+ Reference< beans::XPropertySet > xPropertySet;
+ uno::Any aValue;
+
+ getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_X );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ ModifyListenerHelper::removeListener( xPropertySet, m_xModifyEventForwarder );
+
+ getFastPropertyValue( aValue, DataPointProperties::PROP_DATAPOINT_ERROR_BAR_Y );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ ModifyListenerHelper::removeListener( xPropertySet, m_xModifyEventForwarder );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL DataSeries::createClone()
+{
+ DataSeries * pNewSeries( new DataSeries( *this ));
+ // hold a reference to the clone
+ uno::Reference< util::XCloneable > xResult( pNewSeries );
+ // do initialization that uses uno references to the clone
+ pNewSeries->Init( *this );
+
+ return xResult;
+}
+
+// ____ OPropertySet ____
+uno::Any DataSeries::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = StaticDataSeriesDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+// ____ OPropertySet ____
+::cppu::IPropertyArrayHelper & SAL_CALL DataSeries::getInfoHelper()
+{
+ return StaticDataSeriesInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL DataSeries::getPropertySetInfo()
+{
+ return StaticDataSeriesInfo::get();
+}
+
+void SAL_CALL DataSeries::getFastPropertyValue
+ ( uno::Any& rValue,
+ sal_Int32 nHandle ) const
+{
+ // special handling for get. set is not possible for this property
+ if( nHandle == DataSeriesProperties::PROP_DATASERIES_ATTRIBUTED_DATA_POINTS )
+ {
+ // TODO: only add those property sets that are really modified
+
+ rValue <<= comphelper::mapKeysToSequence(m_aAttributedDataPoints);
+ }
+ else
+ OPropertySet::getFastPropertyValue( rValue, nHandle );
+}
+
+void SAL_CALL DataSeries::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle, const uno::Any& rValue )
+{
+ if( nHandle == DataPointProperties::PROP_DATAPOINT_ERROR_BAR_Y
+ || nHandle == DataPointProperties::PROP_DATAPOINT_ERROR_BAR_X )
+ {
+ uno::Any aOldValue;
+ Reference< util::XModifyBroadcaster > xBroadcaster;
+ getFastPropertyValue( aOldValue, nHandle );
+ if( aOldValue.hasValue() &&
+ (aOldValue >>= xBroadcaster) &&
+ xBroadcaster.is())
+ {
+ ModifyListenerHelper::removeListener( xBroadcaster, m_xModifyEventForwarder );
+ }
+
+ OSL_ASSERT( rValue.getValueType().getTypeClass() == uno::TypeClass_INTERFACE );
+ if( rValue.hasValue() &&
+ (rValue >>= xBroadcaster) &&
+ xBroadcaster.is())
+ {
+ ModifyListenerHelper::addListener( xBroadcaster, m_xModifyEventForwarder );
+ }
+ }
+
+ ::property::OPropertySet::setFastPropertyValue_NoBroadcast( nHandle, rValue );
+}
+
+Reference< beans::XPropertySet >
+ SAL_CALL DataSeries::getDataPointByIndex( sal_Int32 nIndex )
+{
+ Reference< beans::XPropertySet > xResult;
+
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences;
+ {
+ MutexGuard aGuard( m_aMutex );
+ aSequences = comphelper::containerToSequence( m_aDataSequences );
+ }
+
+ std::vector< Reference< chart2::data::XLabeledDataSequence > > aValuesSeries(
+ DataSeriesHelper::getAllDataSequencesByRole( aSequences , "values" ) );
+
+ if (aValuesSeries.empty())
+ throw lang::IndexOutOfBoundsException();
+
+ Reference< chart2::data::XDataSequence > xSeq( aValuesSeries.front()->getValues() );
+ if( 0 <= nIndex && nIndex < xSeq->getData().getLength() )
+ {
+ {
+ MutexGuard aGuard( m_aMutex );
+ tDataPointAttributeContainer::iterator aIt( m_aAttributedDataPoints.find( nIndex ) );
+ if( aIt != m_aAttributedDataPoints.end() )
+ xResult = (*aIt).second;
+ }
+ if( !xResult.is() )
+ {
+ Reference< beans::XPropertySet > xParentProperties;
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ {
+ MutexGuard aGuard( m_aMutex );
+ xParentProperties = this;
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ }
+
+ // create a new XPropertySet for this data point
+ xResult.set( new DataPoint( xParentProperties ) );
+ {
+ MutexGuard aGuard( m_aMutex );
+ m_aAttributedDataPoints[ nIndex ] = xResult;
+ }
+ ModifyListenerHelper::addListener( xResult, xModifyEventForwarder );
+ }
+ }
+
+ return xResult;
+}
+
+void SAL_CALL DataSeries::resetDataPoint( sal_Int32 nIndex )
+{
+ Reference< beans::XPropertySet > xDataPointProp;
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ {
+ MutexGuard aGuard( m_aMutex );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ tDataPointAttributeContainer::iterator aIt( m_aAttributedDataPoints.find( nIndex ));
+ if( aIt != m_aAttributedDataPoints.end())
+ {
+ xDataPointProp = (*aIt).second;
+ m_aAttributedDataPoints.erase(aIt);
+ }
+
+ }
+ if( xDataPointProp.is() )
+ {
+ Reference< util::XModifyBroadcaster > xBroadcaster( xDataPointProp, uno::UNO_QUERY );
+ if( xBroadcaster.is() && xModifyEventForwarder.is())
+ xBroadcaster->removeModifyListener( xModifyEventForwarder );
+ fireModifyEvent();
+ }
+}
+
+void SAL_CALL DataSeries::resetAllDataPoints()
+{
+ tDataPointAttributeContainer aOldAttributedDataPoints;
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ {
+ MutexGuard aGuard( m_aMutex );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ std::swap( aOldAttributedDataPoints, m_aAttributedDataPoints );
+ }
+ ModifyListenerHelper::removeListenerFromAllMapElements( aOldAttributedDataPoints, xModifyEventForwarder );
+ aOldAttributedDataPoints.clear();
+ fireModifyEvent();
+}
+
+// ____ XDataSink ____
+void SAL_CALL DataSeries::setData( const uno::Sequence< Reference< chart2::data::XLabeledDataSequence > >& aData )
+{
+ 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 );
+ m_aDataSequences = aNewDataSequences;
+ }
+ ModifyListenerHelper::removeListenerFromAllElements( aOldDataSequences, xModifyEventForwarder );
+ EventListenerHelper::removeListenerFromAllElements( aOldDataSequences, xListener );
+ EventListenerHelper::addListenerToAllElements( aNewDataSequences, xListener );
+ ModifyListenerHelper::addListenerToAllElements( aNewDataSequences, xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+// ____ XDataSource ____
+Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL DataSeries::getDataSequences()
+{
+ MutexGuard aGuard( m_aMutex );
+ return comphelper::containerToSequence( m_aDataSequences );
+}
+
+// ____ XRegressionCurveContainer ____
+void SAL_CALL DataSeries::addRegressionCurve(
+ const uno::Reference< chart2::XRegressionCurve >& xRegressionCurve )
+{
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ {
+ MutexGuard aGuard( m_aMutex );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ if( std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), xRegressionCurve )
+ != m_aRegressionCurves.end())
+ throw lang::IllegalArgumentException();
+ m_aRegressionCurves.push_back( xRegressionCurve );
+ }
+ ModifyListenerHelper::addListener( xRegressionCurve, xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+void SAL_CALL DataSeries::removeRegressionCurve(
+ const uno::Reference< chart2::XRegressionCurve >& xRegressionCurve )
+{
+ if( !xRegressionCurve.is() )
+ throw container::NoSuchElementException();
+
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ {
+ MutexGuard aGuard( m_aMutex );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ tRegressionCurveContainerType::iterator aIt(
+ std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), xRegressionCurve ) );
+ if( aIt == m_aRegressionCurves.end())
+ throw container::NoSuchElementException(
+ "The given regression curve is no element of this series",
+ static_cast< uno::XWeak * >( this ));
+ m_aRegressionCurves.erase( aIt );
+ }
+
+ ModifyListenerHelper::removeListener( xRegressionCurve, xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+uno::Sequence< uno::Reference< chart2::XRegressionCurve > > SAL_CALL DataSeries::getRegressionCurves()
+{
+ MutexGuard aGuard( m_aMutex );
+ return comphelper::containerToSequence( m_aRegressionCurves );
+}
+
+void SAL_CALL DataSeries::setRegressionCurves(
+ const Sequence< Reference< chart2::XRegressionCurve > >& aRegressionCurves )
+{
+ tRegressionCurveContainerType aOldCurves;
+ auto aNewCurves( comphelper::sequenceToContainer<tRegressionCurveContainerType>( aRegressionCurves ) );
+ Reference< util::XModifyListener > xModifyEventForwarder;
+ {
+ MutexGuard aGuard( m_aMutex );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ std::swap( aOldCurves, m_aRegressionCurves );
+ m_aRegressionCurves = aNewCurves;
+ }
+ ModifyListenerHelper::removeListenerFromAllElements( aOldCurves, xModifyEventForwarder );
+ ModifyListenerHelper::addListenerToAllElements( aNewCurves, xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+// ____ 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");
+ }
+}
+
+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");
+ }
+}
+
+// ____ XModifyListener ____
+void SAL_CALL DataSeries::modified( const lang::EventObject& aEvent )
+{
+ m_xModifyEventForwarder->modified( aEvent );
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL DataSeries::disposing( const lang::EventObject& rEventObject )
+{
+ // 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 ____
+void DataSeries::firePropertyChangeEvent()
+{
+ fireModifyEvent();
+}
+
+void DataSeries::fireModifyEvent()
+{
+ m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
+}
+
+using impl::DataSeries_Base;
+using ::property::OPropertySet;
+
+IMPLEMENT_FORWARD_XINTERFACE2( DataSeries, DataSeries_Base, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( DataSeries, DataSeries_Base, OPropertySet )
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+OUString SAL_CALL DataSeries::getImplementationName()
+{
+ return "com.sun.star.comp.chart.DataSeries";
+}
+
+sal_Bool SAL_CALL DataSeries::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL DataSeries::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart2.DataSeries",
+ "com.sun.star.chart2.DataPointProperties",
+ "com.sun.star.beans.PropertySet" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart_DataSeries_get_implementation(css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::DataSeries );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/DataSeriesProperties.cxx b/chart2/source/model/main/DataSeriesProperties.cxx
new file mode 100644
index 000000000..5d0cb777e
--- /dev/null
+++ b/chart2/source/model/main/DataSeriesProperties.cxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "DataSeriesProperties.hxx"
+#include "DataPointProperties.hxx"
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/chart2/StackingDirection.hpp>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+
+namespace chart
+{
+
+void DataSeriesProperties::AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "AttributedDataPoints",
+ PROP_DATASERIES_ATTRIBUTED_DATA_POINTS,
+ cppu::UnoType<uno::Sequence< sal_Int32 >>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "StackingDirection",
+ PROP_DATASERIES_STACKING_DIRECTION,
+ cppu::UnoType<chart2::StackingDirection>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "VaryColorsByPoint",
+ PROP_DATASERIES_VARY_COLORS_BY_POINT,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "AttachedAxisIndex",
+ PROP_DATASERIES_ATTACHED_AXIS_INDEX,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "ShowLegendEntry",
+ PROP_DATASERIES_SHOW_LEGEND_ENTRY,
+ cppu::UnoType<sal_Bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "DeletedLegendEntries",
+ PROP_DATASERIES_DELETED_LEGEND_ENTRIES,
+ cppu::UnoType<uno::Sequence<sal_Int32>>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ // add properties of service DataPointProperties
+ DataPointProperties::AddPropertiesToVector( rOutProperties );
+}
+
+void DataSeriesProperties::AddDefaultsToMap(
+ tPropertyValueMap & rOutMap )
+{
+ 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_SHOW_LEGEND_ENTRY, true );
+
+ // PROP_DATASERIES_ATTRIBUTED_DATA_POINTS has no default
+
+ // add properties of service DataPointProperties
+ DataPointProperties::AddDefaultsToMap( rOutMap );
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/DataSeriesProperties.hxx b/chart2/source/model/main/DataSeriesProperties.hxx
new file mode 100644
index 000000000..331396b49
--- /dev/null
+++ b/chart2/source/model/main/DataSeriesProperties.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_MAIN_DATASERIESPROPERTIES_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_MAIN_DATASERIESPROPERTIES_HXX
+
+#include <PropertyHelper.hxx>
+#include <FastPropertyIdRanges.hxx>
+
+#include <vector>
+
+namespace com::sun::star::beans { struct Property; }
+
+namespace chart
+{
+
+namespace 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
+ };
+
+ void AddPropertiesToVector(
+ std::vector< css::beans::Property > & rOutProperties );
+
+ void AddDefaultsToMap( tPropertyValueMap & rOutMap );
+}
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_MAIN_DATASERIESPROPERTIES_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx
new file mode 100644
index 000000000..0b9efc80f
--- /dev/null
+++ b/chart2/source/model/main/Diagram.cxx
@@ -0,0 +1,704 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <Diagram.hxx>
+#include <PropertyHelper.hxx>
+#include "Wall.hxx"
+#include <ModifyListenerHelper.hxx>
+#include <UserDefinedProperties.hxx>
+#include <ConfigColorScheme.hxx>
+#include <DiagramHelper.hxx>
+#include <ThreeDHelper.hxx>
+#include <CloneHelper.hxx>
+#include <SceneProperties.hxx>
+#include <unonames.hxx>
+
+#include <basegfx/numeric/ftools.hxx>
+#include <rtl/instance.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/chart2/RelativePosition.hpp>
+#include <com/sun/star/chart2/RelativeSize.hpp>
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include <cppuhelper/supportsservice.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans::PropertyAttribute;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Any;
+using ::osl::MutexGuard;
+
+namespace
+{
+
+enum
+{
+ PROP_DIAGRAM_REL_POS,
+ PROP_DIAGRAM_REL_SIZE,
+ PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS,
+ PROP_DIAGRAM_SORT_BY_X_VALUES,
+ PROP_DIAGRAM_CONNECT_BARS,
+ PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
+ PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS,
+ PROP_DIAGRAM_STARTING_ANGLE,
+ PROP_DIAGRAM_RIGHT_ANGLED_AXES,
+ PROP_DIAGRAM_PERSPECTIVE,
+ PROP_DIAGRAM_ROTATION_HORIZONTAL,
+ PROP_DIAGRAM_ROTATION_VERTICAL,
+ PROP_DIAGRAM_MISSING_VALUE_TREATMENT,
+ PROP_DIAGRAM_3DRELATIVEHEIGHT,
+ PROP_DIAGRAM_DATATABLEHBORDER,
+ PROP_DIAGRAM_DATATABLEVBORDER,
+ PROP_DIAGRAM_DATATABLEOUTLINE,
+ PROP_DIAGRAM_EXTERNALDATA
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "RelativePosition",
+ PROP_DIAGRAM_REL_POS,
+ cppu::UnoType<chart2::RelativePosition>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "RelativeSize",
+ PROP_DIAGRAM_REL_SIZE,
+ cppu::UnoType<chart2::RelativeSize>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "PosSizeExcludeAxes",
+ PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( CHART_UNONAME_SORT_BY_XVALUES,
+ PROP_DIAGRAM_SORT_BY_X_VALUES,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "ConnectBars",
+ PROP_DIAGRAM_CONNECT_BARS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "GroupBarsPerAxis",
+ PROP_DIAGRAM_GROUP_BARS_PER_AXIS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "IncludeHiddenCells",
+ PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "StartingAngle",
+ PROP_DIAGRAM_STARTING_ANGLE,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "RightAngledAxes",
+ PROP_DIAGRAM_RIGHT_ANGLED_AXES,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "Perspective",
+ PROP_DIAGRAM_PERSPECTIVE,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "RotationHorizontal",
+ PROP_DIAGRAM_ROTATION_HORIZONTAL,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "RotationVertical",
+ PROP_DIAGRAM_ROTATION_VERTICAL,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "MissingValueTreatment",
+ PROP_DIAGRAM_MISSING_VALUE_TREATMENT,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( "3DRelativeHeight",
+ 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( "ExternalData",
+ PROP_DIAGRAM_EXTERNALDATA,
+ cppu::UnoType<OUString>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
+}
+
+struct StaticDiagramDefaults_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_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_CONNECT_BARS, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEHBORDER, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEVBORDER, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEOUTLINE, false );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_STARTING_ANGLE, 90 );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_3DRELATIVEHEIGHT, 100 );
+ ::chart::SceneProperties::AddDefaultsToMap( rOutMap );
+ }
+};
+
+struct StaticDiagramDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticDiagramDefaults_Initializer >
+{
+};
+
+struct StaticDiagramInfoHelper_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::SceneProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+};
+
+struct StaticDiagramInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDiagramInfoHelper_Initializer >
+{
+};
+
+struct StaticDiagramInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDiagramInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+struct StaticDiagramInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticDiagramInfo_Initializer >
+{
+};
+
+/// 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 )
+{
+ for( auto 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 );
+ }
+}
+
+} // anonymous namespace
+
+namespace chart
+{
+
+Diagram::Diagram( uno::Reference< uno::XComponentContext > const & xContext ) :
+ ::property::OPropertySet( m_aMutex ),
+ m_xContext( xContext ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{
+ // 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(
+ ThreeDHelper::getDefaultCameraGeometry()));
+}
+
+Diagram::Diagram( const Diagram & rOther ) :
+ impl::Diagram_Base(rOther),
+ ::property::OPropertySet( rOther, m_aMutex ),
+ m_xContext( rOther.m_xContext ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{
+ lcl_CloneCoordinateSystems( rOther.m_aCoordSystems, m_aCoordSystems );
+ ModifyListenerHelper::addListenerToAllElements( m_aCoordSystems, m_xModifyEventForwarder );
+
+ m_xWall.set( CloneHelper::CreateRefClone< beans::XPropertySet >()( rOther.m_xWall ));
+ m_xFloor.set( CloneHelper::CreateRefClone< beans::XPropertySet >()( 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 );
+ ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
+ ModifyListenerHelper::addListener( m_xLegend, m_xModifyEventForwarder );
+}
+
+Diagram::~Diagram()
+{
+ try
+ {
+ ModifyListenerHelper::removeListenerFromAllElements( m_aCoordSystems, m_xModifyEventForwarder );
+
+ ModifyListenerHelper::removeListener( m_xWall, m_xModifyEventForwarder );
+ ModifyListenerHelper::removeListener( m_xFloor, m_xModifyEventForwarder );
+ ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
+ ModifyListenerHelper::removeListener( m_xLegend, m_xModifyEventForwarder );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+// ____ XDiagram ____
+uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getWall()
+{
+ uno::Reference< beans::XPropertySet > xRet;
+ bool bAddListener = false;
+ {
+ MutexGuard aGuard( m_aMutex );
+ if( !m_xWall.is() )
+ {
+ m_xWall.set( new Wall() );
+ bAddListener = true;
+ }
+ xRet = m_xWall;
+ }
+ if(bAddListener)
+ ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
+ return xRet;
+}
+
+uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getFloor()
+{
+ uno::Reference< beans::XPropertySet > xRet;
+ bool bAddListener = false;
+ {
+ MutexGuard aGuard( m_aMutex );
+ if( !m_xFloor.is() )
+ {
+ m_xFloor.set( new Wall() );
+ bAddListener = true;
+ }
+ xRet = m_xFloor;
+ }
+ if(bAddListener)
+ ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
+ return xRet;
+}
+
+uno::Reference< chart2::XLegend > SAL_CALL Diagram::getLegend()
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xLegend;
+}
+
+void SAL_CALL Diagram::setLegend( const uno::Reference< chart2::XLegend >& xNewLegend )
+{
+ Reference< chart2::XLegend > xOldLegend;
+ {
+ MutexGuard aGuard( m_aMutex );
+ if( m_xLegend == xNewLegend )
+ return;
+ xOldLegend = m_xLegend;
+ m_xLegend = xNewLegend;
+ }
+ if( xOldLegend.is())
+ ModifyListenerHelper::removeListener( xOldLegend, m_xModifyEventForwarder );
+ if( xNewLegend.is())
+ ModifyListenerHelper::addListener( xNewLegend, m_xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+Reference< chart2::XColorScheme > SAL_CALL Diagram::getDefaultColorScheme()
+{
+ Reference< chart2::XColorScheme > xRet;
+ {
+ MutexGuard aGuard( m_aMutex );
+ xRet = m_xColorScheme;
+ }
+
+ if( !xRet.is())
+ {
+ xRet.set( createConfigColorScheme( m_xContext ));
+ MutexGuard aGuard( m_aMutex );
+ m_xColorScheme = xRet;
+ }
+ return xRet;
+}
+
+void SAL_CALL Diagram::setDefaultColorScheme( const Reference< chart2::XColorScheme >& xColorScheme )
+{
+ {
+ MutexGuard aGuard( m_aMutex );
+ m_xColorScheme.set( xColorScheme );
+ }
+ fireModifyEvent();
+}
+
+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 );
+ if( !xTemplate.is() )
+ xTemplate.set( xChartTypeManager->createInstance( "com.sun.star.chart2.template.Column" ), uno::UNO_QUERY );
+ if(!xTemplate.is())
+ return;
+ xTemplate->changeDiagramData( this, xDataSource, aArguments );
+}
+
+// ____ XTitled ____
+uno::Reference< chart2::XTitle > SAL_CALL Diagram::getTitleObject()
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xTitle;
+}
+
+void SAL_CALL Diagram::setTitleObject( const uno::Reference< chart2::XTitle >& xNewTitle )
+{
+ Reference< chart2::XTitle > xOldTitle;
+ {
+ MutexGuard aGuard( m_aMutex );
+ if( m_xTitle == xNewTitle )
+ return;
+ xOldTitle = m_xTitle;
+ m_xTitle = xNewTitle;
+ }
+ if( xOldTitle.is())
+ ModifyListenerHelper::removeListener( xOldTitle, m_xModifyEventForwarder );
+ if( xNewTitle.is())
+ ModifyListenerHelper::addListener( xNewTitle, m_xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+// ____ X3DDefaultSetter ____
+void SAL_CALL Diagram::set3DSettingsToDefault()
+{
+ ThreeDHelper::set3DSettingsToDefault( this );
+}
+
+void SAL_CALL Diagram::setDefaultRotation()
+{
+ ThreeDHelper::setDefaultRotation( this );
+}
+
+void SAL_CALL Diagram::setDefaultIllumination()
+{
+ ThreeDHelper::setDefaultIllumination( this );
+}
+
+// ____ XCoordinateSystemContainer ____
+void SAL_CALL Diagram::addCoordinateSystem(
+ const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
+{
+ {
+ MutexGuard aGuard( m_aMutex );
+ if( std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys )
+ != m_aCoordSystems.end())
+ throw lang::IllegalArgumentException();
+
+ if( !m_aCoordSystems.empty() )
+ {
+ OSL_FAIL( "more than one coordinatesystem is not supported yet by the fileformat" );
+ return;
+ }
+ m_aCoordSystems.push_back( aCoordSys );
+ }
+ ModifyListenerHelper::addListener( aCoordSys, m_xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+void SAL_CALL Diagram::removeCoordinateSystem(
+ const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
+{
+ {
+ MutexGuard aGuard( m_aMutex );
+ std::vector< uno::Reference< chart2::XCoordinateSystem > >::iterator
+ aIt( std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys ));
+ if( aIt == m_aCoordSystems.end())
+ throw container::NoSuchElementException(
+ "The given coordinate-system is no element of the container",
+ static_cast< uno::XWeak * >( this ));
+ m_aCoordSystems.erase( aIt );
+ }
+ ModifyListenerHelper::removeListener( aCoordSys, m_xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > SAL_CALL Diagram::getCoordinateSystems()
+{
+ MutexGuard aGuard( m_aMutex );
+ return comphelper::containerToSequence( m_aCoordSystems );
+}
+
+void SAL_CALL Diagram::setCoordinateSystems(
+ const Sequence< Reference< chart2::XCoordinateSystem > >& aCoordinateSystems )
+{
+ tCoordinateSystemContainerType aNew;
+ tCoordinateSystemContainerType aOld;
+ if( aCoordinateSystems.hasElements() )
+ {
+ OSL_ENSURE( aCoordinateSystems.getLength()<=1, "more than one coordinatesystem is not supported yet by the fileformat" );
+ aNew.push_back( aCoordinateSystems[0] );
+ }
+ {
+ MutexGuard aGuard( m_aMutex );
+ std::swap( aOld, m_aCoordSystems );
+ m_aCoordSystems = aNew;
+ }
+ ModifyListenerHelper::removeListenerFromAllElements( aOld, m_xModifyEventForwarder );
+ ModifyListenerHelper::addListenerToAllElements( aNew, m_xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+// ____ XCloneable ____
+Reference< util::XCloneable > SAL_CALL Diagram::createClone()
+{
+ MutexGuard aGuard( m_aMutex );
+ return Reference< util::XCloneable >( new Diagram( *this ));
+}
+
+// ____ 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");
+ }
+}
+
+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");
+ }
+}
+
+// ____ XModifyListener ____
+void SAL_CALL Diagram::modified( const lang::EventObject& aEvent )
+{
+ m_xModifyEventForwarder->modified( aEvent );
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL Diagram::disposing( const lang::EventObject& /* Source */ )
+{
+ // nothing
+}
+
+// ____ OPropertySet ____
+void Diagram::firePropertyChangeEvent()
+{
+ fireModifyEvent();
+}
+
+void Diagram::fireModifyEvent()
+{
+ m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
+}
+
+// ____ OPropertySet ____
+uno::Any Diagram::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticDiagramDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+// ____ OPropertySet ____
+::cppu::IPropertyArrayHelper & SAL_CALL Diagram::getInfoHelper()
+{
+ return *StaticDiagramInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL Diagram::getPropertySetInfo()
+{
+ return *StaticDiagramInfo::get();
+}
+
+// ____ XFastPropertySet ____
+void SAL_CALL Diagram::setFastPropertyValue( 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 ) );
+ }
+ else if( nHandle == PROP_DIAGRAM_ROTATION_HORIZONTAL
+ || nHandle == PROP_DIAGRAM_ROTATION_VERTICAL )
+ {
+ sal_Int32 nNewAngleDegree = 0;
+ if( rValue >>=nNewAngleDegree )
+ {
+ sal_Int32 nHorizontal, nVertical;
+ ThreeDHelper::getRotationFromDiagram( this, nHorizontal, nVertical );
+ if( nHandle == PROP_DIAGRAM_ROTATION_HORIZONTAL )
+ nHorizontal = nNewAngleDegree;
+ else
+ nVertical = nNewAngleDegree;
+ ThreeDHelper::setRotationToDiagram( this, nHorizontal, nVertical );
+ }
+ }
+ else
+ ::property::OPropertySet::setFastPropertyValue( nHandle, rValue );
+}
+
+void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
+{
+ //special treatment for some 3D properties
+ if( nHandle == PROP_DIAGRAM_PERSPECTIVE )
+ {
+ sal_Int32 nPerspective = ::basegfx::fround( ThreeDHelper::CameraDistanceToPerspective(
+ ThreeDHelper::getCameraDistance( const_cast< Diagram* >( this ) ) ) );
+ 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 );
+ sal_Int32 nAngleDegree = 0;
+ if( nHandle == PROP_DIAGRAM_ROTATION_HORIZONTAL )
+ nAngleDegree = nHorizontal;
+ else
+ nAngleDegree = nVertical;
+ rValue <<= nAngleDegree;
+ }
+ else
+ ::property::OPropertySet::getFastPropertyValue( rValue,nHandle );
+}
+
+using impl::Diagram_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( Diagram, Diagram_Base, ::property::OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( Diagram, Diagram_Base, ::property::OPropertySet )
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+OUString SAL_CALL Diagram::getImplementationName()
+{
+ return "com.sun.star.comp.chart2.Diagram";
+}
+
+sal_Bool SAL_CALL Diagram::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL Diagram::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart2.Diagram",
+ "com.sun.star.layout.LayoutElement",
+ "com.sun.star.beans.PropertySet" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_Diagram_get_implementation(css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::Diagram(context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/FormattedString.cxx b/chart2/source/model/main/FormattedString.cxx
new file mode 100644
index 000000000..0d6e733a2
--- /dev/null
+++ b/chart2/source/model/main/FormattedString.cxx
@@ -0,0 +1,284 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "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; }
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Sequence;
+using ::osl::MutexGuard;
+
+namespace
+{
+
+struct StaticFormattedStringDefaults_Initializer
+{
+ ::chart::tPropertyValueMap* operator()()
+ {
+ static ::chart::tPropertyValueMap aStaticDefaults;
+ ::chart::CharacterProperties::AddDefaultsToMap( aStaticDefaults );
+ return &aStaticDefaults;
+ }
+};
+
+struct StaticFormattedStringDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticFormattedStringDefaults_Initializer >
+{
+};
+
+struct StaticFormattedStringInfoHelper_Initializer
+{
+ ::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 >
+{
+};
+
+struct StaticFormattedStringInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticFormattedStringInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+struct StaticFormattedStringInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticFormattedStringInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+FormattedString::FormattedString() :
+ ::property::OPropertySet( m_aMutex ),
+ m_aString(),
+ m_aType(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT),
+ m_aGuid(),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{}
+
+FormattedString::FormattedString( const FormattedString & rOther ) :
+ impl::FormattedString_Base(rOther),
+ ::property::OPropertySet( rOther, m_aMutex ),
+ m_aString( rOther.m_aString ),
+ m_aType(rOther.m_aType),
+ m_aGuid(rOther.m_aGuid),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{}
+
+FormattedString::~FormattedString()
+{}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL FormattedString::createClone()
+{
+ return uno::Reference< util::XCloneable >( new FormattedString( *this ));
+}
+
+// ____ XFormattedString ____
+OUString SAL_CALL FormattedString::getString()
+{
+ MutexGuard aGuard( m_aMutex);
+ return m_aString;
+}
+
+void SAL_CALL FormattedString::setString( const OUString& String )
+{
+ {
+ MutexGuard aGuard( m_aMutex);
+ m_aString = String;
+ }
+ //don't keep the mutex locked while calling out
+ fireModifyEvent();
+
+}
+
+// ____ XDataPointCustomLabelField ____
+css::chart2::DataPointCustomLabelFieldType SAL_CALL FormattedString::getFieldType()
+{
+ MutexGuard aGuard(m_aMutex);
+ return m_aType;
+}
+
+void SAL_CALL
+FormattedString::setFieldType(const css::chart2::DataPointCustomLabelFieldType Type)
+{
+ {
+ MutexGuard aGuard(m_aMutex);
+ m_aType = Type;
+ }
+ //don't keep the mutex locked while calling out
+ fireModifyEvent();
+}
+
+OUString SAL_CALL FormattedString::getGuid()
+{
+ MutexGuard aGuard( m_aMutex);
+ return m_aGuid;
+}
+
+void SAL_CALL FormattedString::setGuid( const OUString& guid )
+{
+ {
+ MutexGuard aGuard( m_aMutex);
+ m_aGuid= guid;
+ }
+ //don't keep the mutex locked while calling out
+ fireModifyEvent();
+
+}
+
+// ____ 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");
+ }
+}
+
+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");
+ }
+}
+
+// ____ XModifyListener ____
+void SAL_CALL FormattedString::modified( const lang::EventObject& aEvent )
+{
+ m_xModifyEventForwarder->modified( aEvent );
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL FormattedString::disposing( const lang::EventObject& /* Source */ )
+{
+ // nothing
+}
+
+// ____ OPropertySet ____
+void FormattedString::firePropertyChangeEvent()
+{
+ fireModifyEvent();
+}
+
+void FormattedString::fireModifyEvent()
+{
+ m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
+}
+
+// ____ OPropertySet ____
+uno::Any FormattedString::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticFormattedStringDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+// ____ OPropertySet ____
+::cppu::IPropertyArrayHelper & SAL_CALL FormattedString::getInfoHelper()
+{
+ return *StaticFormattedStringInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL FormattedString::getPropertySetInfo()
+{
+ return *StaticFormattedStringInfo::get();
+}
+
+using impl::FormattedString_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( FormattedString, FormattedString_Base, ::property::OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( FormattedString, FormattedString_Base, ::property::OPropertySet )
+
+// do this in derived classes!
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+OUString SAL_CALL FormattedString::getImplementationName()
+{
+ return "com.sun.star.comp.chart.FormattedString";
+}
+
+sal_Bool SAL_CALL FormattedString::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL FormattedString::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart2.DataPointCustomLabelField",
+ "com.sun.star.chart2.FormattedString",
+ "com.sun.star.beans.PropertySet" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart_FormattedString_get_implementation(css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::FormattedString);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/FormattedString.hxx b/chart2/source/model/main/FormattedString.hxx
new file mode 100644
index 000000000..9d17d5f38
--- /dev/null
+++ b/chart2/source/model/main/FormattedString.hxx
@@ -0,0 +1,140 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_MAIN_FORMATTEDSTRING_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_MAIN_FORMATTEDSTRING_HXX
+
+#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;
+
+ // ____ 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;
+
+ css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_MAIN_FORMATTEDSTRING_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/GridProperties.cxx b/chart2/source/model/main/GridProperties.cxx
new file mode 100644
index 000000000..44d3fffd8
--- /dev/null
+++ b/chart2/source/model/main/GridProperties.cxx
@@ -0,0 +1,249 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "GridProperties.hxx"
+#include <LinePropertiesHelper.hxx>
+#include <UserDefinedProperties.hxx>
+#include <PropertyHelper.hxx>
+#include <ModifyListenerHelper.hxx>
+#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; }
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::Property;
+
+namespace
+{
+
+enum
+{
+ PROP_GRID_SHOW
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "Show",
+ PROP_GRID_SHOW,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | 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
+{
+ ::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 );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+
+};
+
+struct StaticGridInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticGridInfoHelper_Initializer >
+{
+};
+
+struct StaticGridInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticGridInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+struct StaticGridInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticGridInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+GridProperties::GridProperties() :
+ ::property::OPropertySet( m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{}
+
+GridProperties::GridProperties( const GridProperties & rOther ) :
+ impl::GridProperties_Base(rOther),
+ ::property::OPropertySet( rOther, m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{
+}
+
+GridProperties::~GridProperties()
+{}
+
+// ____ OPropertySet ____
+uno::Any GridProperties::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticGridDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL GridProperties::getInfoHelper()
+{
+ return *StaticGridInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+Reference< beans::XPropertySetInfo > SAL_CALL GridProperties::getPropertySetInfo()
+{
+ return *StaticGridInfo::get();
+}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL GridProperties::createClone()
+{
+ return uno::Reference< util::XCloneable >( new GridProperties( *this ));
+}
+
+// ____ 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");
+ }
+}
+
+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");
+ }
+}
+
+// ____ XModifyListener ____
+void SAL_CALL GridProperties::modified( const lang::EventObject& aEvent )
+{
+ m_xModifyEventForwarder->modified( aEvent );
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL GridProperties::disposing( const lang::EventObject& /* Source */ )
+{
+ // nothing
+}
+
+// ____ OPropertySet ____
+void GridProperties::firePropertyChangeEvent()
+{
+ m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
+}
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+OUString SAL_CALL GridProperties::getImplementationName()
+{
+ return "com.sun.star.comp.chart2.GridProperties";
+}
+
+sal_Bool SAL_CALL GridProperties::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL GridProperties::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart2.GridProperties",
+ "com.sun.star.beans.PropertySet" };
+}
+
+// needed by MSC compiler
+using impl::GridProperties_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( GridProperties, GridProperties_Base, ::property::OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( GridProperties, GridProperties_Base, ::property::OPropertySet )
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_GridProperties_get_implementation(css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::GridProperties);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/GridProperties.hxx b/chart2/source/model/main/GridProperties.hxx
new file mode 100644
index 000000000..38d1f9a74
--- /dev/null
+++ b/chart2/source/model/main/GridProperties.hxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_MAIN_GRIDPROPERTIES_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_MAIN_GRIDPROPERTIES_HXX
+
+#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
+
+// INCLUDED_CHART2_SOURCE_MODEL_MAIN_GRIDPROPERTIES_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/Legend.cxx b/chart2/source/model/main/Legend.cxx
new file mode 100644
index 000000000..4c3b9f0e5
--- /dev/null
+++ b/chart2/source/model/main/Legend.cxx
@@ -0,0 +1,315 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "Legend.hxx"
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <CharacterProperties.hxx>
+#include <UserDefinedProperties.hxx>
+#include <ModifyListenerHelper.hxx>
+#include <PropertyHelper.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/chart2/LegendPosition.hpp>
+#include <com/sun/star/chart/ChartLegendExpansion.hpp>
+#include <com/sun/star/chart2/RelativePosition.hpp>
+#include <com/sun/star/chart2/RelativeSize.hpp>
+#include <cppuhelper/supportsservice.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <algorithm>
+
+namespace com::sun::star::uno { class XComponentContext; }
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans::PropertyAttribute;
+
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::beans::Property;
+
+namespace
+{
+
+enum
+{
+ PROP_LEGEND_ANCHOR_POSITION,
+ PROP_LEGEND_EXPANSION,
+ PROP_LEGEND_SHOW,
+ PROP_LEGEND_OVERLAY,
+ PROP_LEGEND_REF_PAGE_SIZE,
+ PROP_LEGEND_REL_POS,
+ PROP_LEGEND_REL_SIZE
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "AnchorPosition",
+ PROP_LEGEND_ANCHOR_POSITION,
+ cppu::UnoType<chart2::LegendPosition>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "Expansion",
+ PROP_LEGEND_EXPANSION,
+ cppu::UnoType<css::chart::ChartLegendExpansion>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "Show",
+ PROP_LEGEND_SHOW,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "Overlay",
+ PROP_LEGEND_OVERLAY,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "ReferencePageSize",
+ PROP_LEGEND_REF_PAGE_SIZE,
+ cppu::UnoType<awt::Size>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "RelativePosition",
+ PROP_LEGEND_REL_POS,
+ cppu::UnoType<chart2::RelativePosition>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "RelativeSize",
+ PROP_LEGEND_REL_SIZE,
+ cppu::UnoType<chart2::RelativeSize>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+}
+
+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 );
+ }
+};
+
+struct StaticLegendDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLegendDefaults_Initializer >
+{
+};
+
+struct StaticLegendInfoHelper_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::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 );
+ }
+};
+
+struct StaticLegendInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLegendInfoHelper_Initializer >
+{
+};
+
+struct StaticLegendInfo_Initializer
+{
+ 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 >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+Legend::Legend() :
+ ::property::OPropertySet( m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{
+}
+
+Legend::Legend( const Legend & rOther ) :
+ impl::Legend_Base(rOther),
+ ::property::OPropertySet( rOther, m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{
+}
+
+Legend::~Legend()
+{
+}
+
+// ____ XCloneable ____
+Reference< util::XCloneable > SAL_CALL Legend::createClone()
+{
+ return Reference< util::XCloneable >( new Legend( *this ));
+}
+
+// ____ 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");
+ }
+}
+
+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");
+ }
+}
+
+// ____ XModifyListener ____
+void SAL_CALL Legend::modified( const lang::EventObject& aEvent )
+{
+ m_xModifyEventForwarder->modified( aEvent );
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL Legend::disposing( const lang::EventObject& /* Source */ )
+{
+ // nothing
+}
+
+// ____ OPropertySet ____
+void Legend::firePropertyChangeEvent()
+{
+ m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
+}
+
+// ____ OPropertySet ____
+Any Legend::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticLegendDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL Legend::getInfoHelper()
+{
+ return *StaticLegendInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+Reference< beans::XPropertySetInfo > SAL_CALL Legend::getPropertySetInfo()
+{
+ return *StaticLegendInfo::get();
+}
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+OUString SAL_CALL Legend::getImplementationName()
+{
+ return "com.sun.star.comp.chart2.Legend";
+}
+
+sal_Bool SAL_CALL Legend::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL Legend::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart2.Legend",
+ "com.sun.star.beans.PropertySet",
+ "com.sun.star.drawing.FillProperties",
+ "com.sun.star.drawing.LineProperties",
+ "com.sun.star.style.CharacterProperties",
+ "com.sun.star.layout.LayoutElement"
+ };
+}
+
+// needed by MSC compiler
+using impl::Legend_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( Legend, Legend_Base, ::property::OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( Legend, Legend_Base, ::property::OPropertySet )
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_Legend_get_implementation(css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::Legend);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/Legend.hxx b/chart2/source/model/main/Legend.hxx
new file mode 100644
index 000000000..516324f2e
--- /dev/null
+++ b/chart2/source/model/main/Legend.hxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_MAIN_LEGEND_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_MAIN_LEGEND_HXX
+
+#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
+
+// INCLUDED_CHART2_SOURCE_MODEL_MAIN_LEGEND_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/PageBackground.cxx b/chart2/source/model/main/PageBackground.cxx
new file mode 100644
index 000000000..5dda4cb5a
--- /dev/null
+++ b/chart2/source/model/main/PageBackground.cxx
@@ -0,0 +1,230 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "PageBackground.hxx"
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <UserDefinedProperties.hxx>
+#include <PropertyHelper.hxx>
+#include <ModifyListenerHelper.hxx>
+
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <cppuhelper/supportsservice.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <vector>
+#include <algorithm>
+
+namespace com::sun::star::uno { class XComponentContext; }
+
+using namespace ::com::sun::star;
+
+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 );
+ }
+};
+
+struct StaticPageBackgroundDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPageBackgroundDefaults_Initializer >
+{
+};
+
+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() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+
+};
+
+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 >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+PageBackground::PageBackground() :
+ ::property::OPropertySet( m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{}
+
+PageBackground::PageBackground( const PageBackground & rOther ) :
+ impl::PageBackground_Base(rOther),
+ ::property::OPropertySet( rOther, m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{}
+
+PageBackground::~PageBackground()
+{}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL PageBackground::createClone()
+{
+ return uno::Reference< util::XCloneable >( new PageBackground( *this ));
+}
+
+// ____ OPropertySet ____
+uno::Any PageBackground::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticPageBackgroundDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL PageBackground::getInfoHelper()
+{
+ return *StaticPageBackgroundInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL PageBackground::getPropertySetInfo()
+{
+ return *StaticPageBackgroundInfo::get();
+}
+
+// ____ 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");
+ }
+}
+
+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");
+ }
+}
+
+// ____ XModifyListener ____
+void SAL_CALL PageBackground::modified( const lang::EventObject& aEvent )
+{
+ m_xModifyEventForwarder->modified( aEvent );
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL PageBackground::disposing( const lang::EventObject& /* Source */ )
+{
+ // nothing
+}
+
+// ____ OPropertySet ____
+void PageBackground::firePropertyChangeEvent()
+{
+ m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
+}
+
+OUString SAL_CALL PageBackground::getImplementationName()
+{
+ return "com.sun.star.comp.chart2.PageBackground";
+}
+
+sal_Bool SAL_CALL PageBackground::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL PageBackground::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart2.PageBackground",
+ "com.sun.star.beans.PropertySet" };
+}
+
+using impl::PageBackground_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( PageBackground, PageBackground_Base, ::property::OPropertySet )
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_PageBackground_get_implementation(css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::PageBackground );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/PageBackground.hxx b/chart2/source/model/main/PageBackground.hxx
new file mode 100644
index 000000000..9157eb9d9
--- /dev/null
+++ b/chart2/source/model/main/PageBackground.hxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_MAIN_PAGEBACKGROUND_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_MAIN_PAGEBACKGROUND_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 <MutexContainer.hxx>
+#include <OPropertySet.hxx>
+#include <cppuhelper/implbase.hxx>
+
+#include <comphelper/uno3.hxx>
+
+namespace chart
+{
+
+namespace impl
+{
+typedef ::cppu::WeakImplHelper<
+ css::util::XCloneable,
+ css::util::XModifyBroadcaster,
+ css::util::XModifyListener,
+ css::lang::XServiceInfo >
+ PageBackground_Base;
+}
+
+class PageBackground final :
+ public MutexContainer,
+ public impl::PageBackground_Base,
+ public ::property::OPropertySet
+{
+public:
+ explicit PageBackground();
+ virtual ~PageBackground() 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()
+
+private:
+ explicit PageBackground( const PageBackground & 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
+
+// INCLUDED_CHART2_SOURCE_MODEL_MAIN_PAGEBACKGROUND_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/PolarCoordinateSystem.cxx b/chart2/source/model/main/PolarCoordinateSystem.cxx
new file mode 100644
index 000000000..f6780bbb5
--- /dev/null
+++ b/chart2/source/model/main/PolarCoordinateSystem.cxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <PolarCoordinateSystem.hxx>
+#include <servicenames_coosystems.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+namespace com::sun::star::uno { class XComponentContext; }
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+namespace
+{
+
+static const char CHART2_COOSYSTEM_POLAR_SERVICE_NAME[] = "com.sun.star.chart2.CoordinateSystems.Polar";
+
+}
+
+namespace chart
+{
+
+// explicit
+PolarCoordinateSystem::PolarCoordinateSystem( sal_Int32 nDimensionCount /* = 2 */ ) :
+ BaseCoordinateSystem( nDimensionCount )
+{}
+
+PolarCoordinateSystem::PolarCoordinateSystem(
+ const PolarCoordinateSystem & rSource ) :
+ BaseCoordinateSystem( rSource )
+{}
+
+PolarCoordinateSystem::~PolarCoordinateSystem()
+{}
+
+// ____ XCoordinateSystem ____
+OUString SAL_CALL PolarCoordinateSystem::getCoordinateSystemType()
+{
+ return CHART2_COOSYSTEM_POLAR_SERVICE_NAME;
+}
+
+OUString SAL_CALL PolarCoordinateSystem::getViewServiceName()
+{
+ return CHART2_COOSYSTEM_POLAR_VIEW_SERVICE_NAME;
+}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL PolarCoordinateSystem::createClone()
+{
+ return Reference< util::XCloneable >( new PolarCoordinateSystem( *this ));
+}
+
+// ____ XServiceInfo ____
+OUString SAL_CALL PolarCoordinateSystem::getImplementationName()
+{
+ return "com.sun.star.comp.chart.PolarCoordinateSystem";
+}
+
+sal_Bool SAL_CALL PolarCoordinateSystem::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL PolarCoordinateSystem::getSupportedServiceNames()
+{
+ return { CHART2_COOSYSTEM_POLAR_SERVICE_NAME };
+}
+
+// ==== PolarCoordinateSystem2d ====
+
+PolarCoordinateSystem2d::PolarCoordinateSystem2d() :
+ PolarCoordinateSystem( 2 )
+{}
+
+PolarCoordinateSystem2d::~PolarCoordinateSystem2d()
+{}
+
+// ____ XServiceInfo ____
+OUString SAL_CALL PolarCoordinateSystem2d::getImplementationName()
+{
+ return "com.sun.star.comp.chart2.PolarCoordinateSystem2d" ;
+}
+
+sal_Bool SAL_CALL PolarCoordinateSystem2d::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL PolarCoordinateSystem2d::getSupportedServiceNames()
+{
+ return {
+ CHART2_COOSYSTEM_POLAR_SERVICE_NAME,
+ "com.sun.star.chart2.PolarCoordinateSystem2d" };
+}
+
+// ==== PolarCoordinateSystem3d ====
+
+PolarCoordinateSystem3d::PolarCoordinateSystem3d() :
+ PolarCoordinateSystem( 3 )
+{}
+
+PolarCoordinateSystem3d::~PolarCoordinateSystem3d()
+{}
+
+// ____ XServiceInfo ____
+OUString SAL_CALL PolarCoordinateSystem3d::getImplementationName()
+{
+ return "com.sun.star.comp.chart2.PolarCoordinateSystem3d";
+}
+
+sal_Bool SAL_CALL PolarCoordinateSystem3d::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL PolarCoordinateSystem3d::getSupportedServiceNames()
+{
+ return {
+ CHART2_COOSYSTEM_POLAR_SERVICE_NAME,
+ "com.sun.star.chart2.PolarCoordinateSystem3d" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_PolarCoordinateSystem2d_get_implementation(css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::PolarCoordinateSystem2d);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_PolarCoordinateSystem3d_get_implementation(css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::PolarCoordinateSystem3d);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/StockBar.cxx b/chart2/source/model/main/StockBar.cxx
new file mode 100644
index 000000000..22e082ad0
--- /dev/null
+++ b/chart2/source/model/main/StockBar.cxx
@@ -0,0 +1,213 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <StockBar.hxx>
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <UserDefinedProperties.hxx>
+#include <PropertyHelper.hxx>
+#include <ModifyListenerHelper.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <algorithm>
+
+namespace com::sun::star::beans { class XPropertySetInfo; }
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::beans::Property;
+
+namespace
+{
+
+struct StaticStockBarInfoHelper_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 StaticStockBarInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticStockBarInfoHelper_Initializer >
+{
+};
+
+struct StaticStockBarInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticStockBarInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+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 >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+StockBar::StockBar( bool bRisingCourse ) :
+ ::property::OPropertySet( m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{
+ if( ! bRisingCourse )
+ {
+ setFastPropertyValue_NoBroadcast(
+ ::chart::FillProperties::PROP_FILL_COLOR,
+ uno::Any( sal_Int32( 0x000000 ))); // black
+ setFastPropertyValue_NoBroadcast(
+ ::chart::LinePropertiesHelper::PROP_LINE_COLOR,
+ uno::Any( sal_Int32( 0xb3b3b3 ))); // gray30
+ }
+}
+
+StockBar::StockBar( const StockBar & rOther ) :
+ impl::StockBar_Base(rOther),
+ ::property::OPropertySet( rOther, m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{}
+
+StockBar::~StockBar()
+{}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL StockBar::createClone()
+{
+ return uno::Reference< util::XCloneable >( new StockBar( *this ));
+}
+
+// ____ OPropertySet ____
+uno::Any StockBar::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticStockBarDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL StockBar::getInfoHelper()
+{
+ return *StaticStockBarInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+Reference< beans::XPropertySetInfo > SAL_CALL StockBar::getPropertySetInfo()
+{
+ return *StaticStockBarInfo::get();
+}
+
+// ____ 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");
+ }
+}
+
+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");
+ }
+}
+
+// ____ XModifyListener ____
+void SAL_CALL StockBar::modified( const lang::EventObject& aEvent )
+{
+ m_xModifyEventForwarder->modified( aEvent );
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL StockBar::disposing( const lang::EventObject& /* Source */ )
+{
+ // nothing
+}
+
+// ____ OPropertySet ____
+void StockBar::firePropertyChangeEvent()
+{
+ m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
+}
+
+using impl::StockBar_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( StockBar, StockBar_Base, ::property::OPropertySet )
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/Title.cxx b/chart2/source/model/main/Title.cxx
new file mode 100644
index 000000000..a42374ce5
--- /dev/null
+++ b/chart2/source/model/main/Title.cxx
@@ -0,0 +1,390 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "Title.hxx"
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <CloneHelper.hxx>
+#include <PropertyHelper.hxx>
+#include <ModifyListenerHelper.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#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>
+
+namespace com::sun::star::uno { class XComponentContext; }
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans::PropertyAttribute;
+
+using ::com::sun::star::beans::Property;
+using ::osl::MutexGuard;
+
+namespace
+{
+
+enum
+{
+ PROP_TITLE_PARA_ADJUST,
+ PROP_TITLE_PARA_LAST_LINE_ADJUST,
+ PROP_TITLE_PARA_LEFT_MARGIN,
+ PROP_TITLE_PARA_RIGHT_MARGIN,
+ PROP_TITLE_PARA_TOP_MARGIN,
+ PROP_TITLE_PARA_BOTTOM_MARGIN,
+ PROP_TITLE_PARA_IS_HYPHENATION,
+ PROP_TITLE_VISIBLE,
+
+ PROP_TITLE_TEXT_ROTATION,
+ PROP_TITLE_TEXT_STACKED,
+ PROP_TITLE_REL_POS,
+
+ PROP_TITLE_REF_PAGE_SIZE
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "ParaAdjust",
+ PROP_TITLE_PARA_ADJUST,
+ cppu::UnoType<css::style::ParagraphAdjust>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "ParaLastLineAdjust",
+ PROP_TITLE_PARA_LAST_LINE_ADJUST,
+ cppu::UnoType<sal_Int16>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "ParaLeftMargin",
+ PROP_TITLE_PARA_LEFT_MARGIN,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "ParaRightMargin",
+ PROP_TITLE_PARA_RIGHT_MARGIN,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "ParaTopMargin",
+ PROP_TITLE_PARA_TOP_MARGIN,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "ParaBottomMargin",
+ PROP_TITLE_PARA_BOTTOM_MARGIN,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "ParaIsHyphenation",
+ PROP_TITLE_PARA_IS_HYPHENATION,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+
+ rOutProperties.emplace_back( "Visible",
+ PROP_TITLE_VISIBLE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "TextRotation",
+ PROP_TITLE_TEXT_ROTATION,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "StackCharacters",
+ PROP_TITLE_TEXT_STACKED,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "RelativePosition",
+ PROP_TITLE_REL_POS,
+ cppu::UnoType<chart2::RelativePosition>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "ReferencePageSize",
+ PROP_TITLE_REF_PAGE_SIZE,
+ cppu::UnoType<awt::Size>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+}
+
+struct StaticTitleDefaults_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 );
+
+ // 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;
+ }
+};
+
+struct StaticTitleInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticTitleInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+Title::Title() :
+ ::property::OPropertySet( m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{}
+
+Title::Title( const Title & rOther ) :
+ impl::Title_Base(rOther),
+ ::property::OPropertySet( rOther, m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{
+ CloneHelper::CloneRefSequence<chart2::XFormattedString>(
+ rOther.m_aStrings, m_aStrings );
+ ModifyListenerHelper::addListenerToAllElements(
+ comphelper::sequenceToContainer<std::vector<uno::Reference< chart2::XFormattedString > > >( m_aStrings ),
+ m_xModifyEventForwarder );
+}
+
+Title::~Title()
+{
+ ModifyListenerHelper::removeListenerFromAllElements(
+ comphelper::sequenceToContainer<std::vector<uno::Reference< chart2::XFormattedString > > >( m_aStrings ),
+ m_xModifyEventForwarder );
+}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL Title::createClone()
+{
+ return uno::Reference< util::XCloneable >( new Title( *this ));
+}
+
+// ____ XTitle ____
+uno::Sequence< uno::Reference< chart2::XFormattedString > > SAL_CALL Title::getText()
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_aStrings;
+}
+
+void SAL_CALL Title::setText( const uno::Sequence< uno::Reference< chart2::XFormattedString > >& rNewStrings )
+{
+ uno::Sequence< uno::Reference< chart2::XFormattedString > > aOldStrings;
+ {
+ MutexGuard aGuard( m_aMutex );
+ std::swap( m_aStrings, aOldStrings );
+ m_aStrings = rNewStrings;
+ }
+ //don't keep the mutex locked while calling out
+ ModifyListenerHelper::removeListenerFromAllElements(
+ comphelper::sequenceToContainer<std::vector<uno::Reference< chart2::XFormattedString > > >( aOldStrings ),
+ m_xModifyEventForwarder );
+ ModifyListenerHelper::addListenerToAllElements(
+ comphelper::sequenceToContainer<std::vector<uno::Reference< chart2::XFormattedString > > >( rNewStrings ),
+ m_xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+// ____ OPropertySet ____
+uno::Any Title::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticTitleDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL Title::getInfoHelper()
+{
+ return *StaticTitleInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL Title::getPropertySetInfo()
+{
+ return *StaticTitleInfo::get();
+}
+
+// ____ 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");
+ }
+}
+
+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");
+ }
+}
+
+// ____ XModifyListener ____
+void SAL_CALL Title::modified( const lang::EventObject& aEvent )
+{
+ m_xModifyEventForwarder->modified( aEvent );
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL Title::disposing( const lang::EventObject& /* Source */ )
+{
+ // nothing
+}
+
+// ____ OPropertySet ____
+void Title::firePropertyChangeEvent()
+{
+ fireModifyEvent();
+}
+
+void Title::fireModifyEvent()
+{
+ m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
+}
+
+OUString SAL_CALL Title::getImplementationName()
+{
+ return "com.sun.star.comp.chart2.Title";
+}
+
+sal_Bool SAL_CALL Title::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL Title::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart2.Title",
+ "com.sun.star.style.ParagraphProperties",
+ "com.sun.star.beans.PropertySet",
+ "com.sun.star.layout.LayoutElement" };
+}
+
+// needed by MSC compiler
+using impl::Title_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( Title, Title_Base, ::property::OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( Title, Title_Base, ::property::OPropertySet )
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart2_Title_get_implementation(css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::Title);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/Title.hxx b/chart2/source/model/main/Title.hxx
new file mode 100644
index 000000000..9326b54b2
--- /dev/null
+++ b/chart2/source/model/main/Title.hxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_MAIN_TITLE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_MAIN_TITLE_HXX
+
+#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
+
+// INCLUDED_CHART2_SOURCE_MODEL_MAIN_TITLE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/UndoManager.cxx b/chart2/source/model/main/UndoManager.cxx
new file mode 100644
index 000000000..f295bc288
--- /dev/null
+++ b/chart2/source/model/main/UndoManager.cxx
@@ -0,0 +1,350 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "UndoManager.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>
+
+#include <framework/undomanagerhelper.hxx>
+#include <framework/imutex.hxx>
+#include <officecfg/Office/Common.hxx>
+#include <svl/undo.hxx>
+
+namespace chart
+{
+
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::document::XUndoManager;
+ using ::com::sun::star::document::XUndoAction;
+ using ::com::sun::star::document::XUndoManagerListener;
+ using ::com::sun::star::lang::NoSupportException;
+ using ::com::sun::star::util::XModifyListener;
+ using ::com::sun::star::frame::XModel;
+
+ namespace impl
+ {
+ class UndoManager_Impl : public ::framework::IUndoManagerImplementation
+ {
+ public:
+ UndoManager_Impl( UndoManager& i_antiImpl, ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ :m_rAntiImpl( i_antiImpl )
+ ,m_rParent( i_parent )
+ ,m_rMutex( i_mutex )
+ ,m_bDisposed( false )
+ ,m_aUndoManager()
+ ,m_aUndoHelper( *this )
+ {
+ m_aUndoManager.SetMaxUndoActionCount(
+ officecfg::Office::Common::Undo::Steps::get());
+ }
+
+ virtual ~UndoManager_Impl()
+ {
+ }
+
+ ::osl::Mutex& getMutex();
+ // IUndoManagerImplementation
+ virtual SfxUndoManager& getImplUndoManager() override;
+ virtual Reference< XUndoManager > getThis() override;
+
+ // attribute access
+ ::cppu::OWeakObject& getParent() { return m_rParent; }
+ ::framework::UndoManagerHelper& getUndoHelper() { return m_aUndoHelper; }
+
+ // public interface
+
+ /// is called when the owner of the UndoManager is being disposed
+ void disposing();
+
+ /// checks whether we're already disposed, throws a DisposedException if so
+ void checkDisposed_lck();
+
+ private:
+ UndoManager& m_rAntiImpl;
+ ::cppu::OWeakObject& m_rParent;
+ ::osl::Mutex& m_rMutex;
+ bool m_bDisposed;
+
+ SfxUndoManager m_aUndoManager;
+ ::framework::UndoManagerHelper m_aUndoHelper;
+ };
+
+ ::osl::Mutex& UndoManager_Impl::getMutex()
+ {
+ return m_rMutex;
+ }
+
+ SfxUndoManager& UndoManager_Impl::getImplUndoManager()
+ {
+ return m_aUndoManager;
+ }
+
+ Reference< XUndoManager > UndoManager_Impl::getThis()
+ {
+ return &m_rAntiImpl;
+ }
+
+ void UndoManager_Impl::disposing()
+ {
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ m_bDisposed = true;
+ }
+ m_aUndoHelper.disposing();
+ }
+
+ void UndoManager_Impl::checkDisposed_lck()
+ {
+ if ( m_bDisposed )
+ throw DisposedException( OUString(), getThis() );
+ }
+
+ namespace {
+
+ /** guard for public UNO methods of the UndoManager
+
+ The only purpose of this guard is to check for the instance being disposed already. Everything else,
+ in particular the IMutexGuard functionality required by the UndoManagerHelper class, is a dummy only,
+ as all involved classes (means we ourselves, the UndoManagerHelper, the SfxUndoManager, and the Undo actions
+ we create) are inherently thread-safe, thus need no external lock (in particular no SolarMutex!).
+ */
+ class UndoManagerMethodGuard : public ::framework::IMutexGuard
+ {
+ public:
+ explicit UndoManagerMethodGuard( UndoManager_Impl& i_impl )
+ {
+ ::osl::MutexGuard aGuard( i_impl.getMutex() );
+ // throw if the instance is already disposed
+ i_impl.checkDisposed_lck();
+ }
+ virtual ~UndoManagerMethodGuard()
+ {
+ }
+
+ // IMutexGuard
+ virtual void clear() override;
+ virtual ::framework::IMutex& getGuardedMutex() override;
+ };
+
+ class DummyMutex : public ::framework::IMutex
+ {
+ public:
+ virtual ~DummyMutex() {}
+ virtual void acquire() override { }
+ virtual void release() override { }
+ };
+
+ }
+
+ ::framework::IMutex& UndoManagerMethodGuard::getGuardedMutex()
+ {
+ static DummyMutex s_aDummyMutex;
+ return s_aDummyMutex;
+ }
+
+ void UndoManagerMethodGuard::clear()
+ {
+ // nothing to do. This interface implementation is a dummy.
+ }
+ }
+
+ using impl::UndoManagerMethodGuard;
+
+ UndoManager::UndoManager( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ :m_pImpl( new impl::UndoManager_Impl( *this, i_parent, i_mutex ) )
+ {
+ }
+
+ UndoManager::~UndoManager()
+ {
+ }
+
+ void SAL_CALL UndoManager::acquire() throw ()
+ {
+ m_pImpl->getParent().acquire();
+ }
+
+ void SAL_CALL UndoManager::release() throw ()
+ {
+ m_pImpl->getParent().release();
+ }
+
+ void UndoManager::disposing()
+ {
+ m_pImpl->disposing();
+ }
+
+ void SAL_CALL UndoManager::enterUndoContext( const OUString& i_title )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().enterUndoContext( i_title, aGuard );
+ }
+
+ void SAL_CALL UndoManager::enterHiddenUndoContext( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().enterHiddenUndoContext( aGuard );
+ }
+
+ void SAL_CALL UndoManager::leaveUndoContext( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().leaveUndoContext( aGuard );
+ }
+
+ void SAL_CALL UndoManager::addUndoAction( const Reference< XUndoAction >& i_action )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().addUndoAction( i_action, aGuard );
+ }
+
+ void SAL_CALL UndoManager::undo( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().undo( aGuard );
+
+ ChartViewHelper::setViewToDirtyState( Reference< XModel >( getParent(), UNO_QUERY ) );
+ }
+
+ void SAL_CALL UndoManager::redo( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().redo( aGuard );
+
+ ChartViewHelper::setViewToDirtyState( Reference< XModel >( getParent(), UNO_QUERY ) );
+ }
+
+ sal_Bool SAL_CALL UndoManager::isUndoPossible( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().isUndoPossible();
+ }
+
+ sal_Bool SAL_CALL UndoManager::isRedoPossible( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().isRedoPossible();
+ }
+
+ OUString SAL_CALL UndoManager::getCurrentUndoActionTitle( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().getCurrentUndoActionTitle();
+ }
+
+ OUString SAL_CALL UndoManager::getCurrentRedoActionTitle( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().getCurrentRedoActionTitle();
+ }
+
+ Sequence< OUString > SAL_CALL UndoManager::getAllUndoActionTitles( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().getAllUndoActionTitles();
+ }
+
+ Sequence< OUString > SAL_CALL UndoManager::getAllRedoActionTitles( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().getAllRedoActionTitles();
+ }
+
+ void SAL_CALL UndoManager::clear( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().clear( aGuard );
+ }
+
+ void SAL_CALL UndoManager::clearRedo( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().clearRedo( aGuard );
+ }
+
+ void SAL_CALL UndoManager::reset( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().reset( aGuard );
+ }
+
+ void SAL_CALL UndoManager::addUndoManagerListener( const Reference< XUndoManagerListener >& i_listener )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().addUndoManagerListener( i_listener );
+ }
+
+ void SAL_CALL UndoManager::removeUndoManagerListener( const Reference< XUndoManagerListener >& i_listener )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().removeUndoManagerListener( i_listener );
+ }
+
+ void SAL_CALL UndoManager::lock( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().lock();
+ }
+
+ void SAL_CALL UndoManager::unlock( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().unlock();
+ }
+
+ sal_Bool SAL_CALL UndoManager::isLocked( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().isLocked();
+ }
+
+ Reference< XInterface > SAL_CALL UndoManager::getParent( )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getParent();
+ }
+
+ void SAL_CALL UndoManager::setParent( const Reference< XInterface >& )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ throw NoSupportException( OUString(), m_pImpl->getThis() );
+ }
+
+ void SAL_CALL UndoManager::addModifyListener( const Reference< XModifyListener >& i_listener )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().addModifyListener( i_listener );
+ }
+
+ void SAL_CALL UndoManager::removeModifyListener( const Reference< XModifyListener >& i_listener )
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().removeModifyListener( i_listener );
+ }
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/UndoManager.hxx b/chart2/source/model/main/UndoManager.hxx
new file mode 100644
index 000000000..c599113d4
--- /dev/null
+++ b/chart2/source/model/main/UndoManager.hxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_MAIN_UNDOMANAGER_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_MAIN_UNDOMANAGER_HXX
+
+#include <com/sun/star/document/XUndoManager.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
+
+#include <cppuhelper/implbase2.hxx>
+
+#include <memory>
+
+namespace chart
+{
+
+ namespace impl
+ {
+ class UndoManager_Impl;
+ typedef ::cppu::ImplHelper2 < css::document::XUndoManager
+ , css::util::XModifyBroadcaster
+ > UndoManager_Base;
+ }
+
+ class UndoManager : public impl::UndoManager_Base
+ {
+ public:
+ UndoManager( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex );
+ virtual ~UndoManager();
+
+ // XInterface
+ virtual void SAL_CALL acquire( ) throw () override;
+ virtual void SAL_CALL release( ) throw () override;
+
+ // XComponent equivalents
+ void disposing();
+
+ // XUndoManager
+ virtual void SAL_CALL enterUndoContext( const OUString& i_title ) override;
+ virtual void SAL_CALL enterHiddenUndoContext( ) override;
+ virtual void SAL_CALL leaveUndoContext( ) override;
+ virtual void SAL_CALL addUndoAction( const css::uno::Reference< css::document::XUndoAction >& i_action ) override;
+ virtual void SAL_CALL undo( ) override;
+ virtual void SAL_CALL redo( ) override;
+ virtual sal_Bool SAL_CALL isUndoPossible( ) override;
+ virtual sal_Bool SAL_CALL isRedoPossible( ) override;
+ virtual OUString SAL_CALL getCurrentUndoActionTitle( ) override;
+ virtual OUString SAL_CALL getCurrentRedoActionTitle( ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getAllUndoActionTitles( ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getAllRedoActionTitles( ) override;
+ virtual void SAL_CALL clear( ) override;
+ virtual void SAL_CALL clearRedo( ) override;
+ virtual void SAL_CALL reset( ) override;
+ virtual void SAL_CALL addUndoManagerListener( const css::uno::Reference< css::document::XUndoManagerListener >& i_listener ) override;
+ virtual void SAL_CALL removeUndoManagerListener( const css::uno::Reference< css::document::XUndoManagerListener >& i_listener ) override;
+
+ // XLockable (base of XUndoManager)
+ virtual void SAL_CALL lock( ) override;
+ virtual void SAL_CALL unlock( ) override;
+ virtual sal_Bool SAL_CALL isLocked( ) override;
+
+ // XChild (base of XUndoManager)
+ virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent( ) override;
+ virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& Parent ) 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;
+
+ private:
+ std::unique_ptr< impl::UndoManager_Impl > m_pImpl;
+ };
+
+} // namespace chart
+
+#endif // INCLUDED_CHART2_SOURCE_MODEL_MAIN_UNDOMANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/Wall.cxx b/chart2/source/model/main/Wall.cxx
new file mode 100644
index 000000000..5ba8aaf18
--- /dev/null
+++ b/chart2/source/model/main/Wall.cxx
@@ -0,0 +1,201 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "Wall.hxx"
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <UserDefinedProperties.hxx>
+#include <PropertyHelper.hxx>
+#include <ModifyListenerHelper.hxx>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <tools/diagnose_ex.h>
+
+#include <vector>
+#include <algorithm>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+
+namespace
+{
+
+struct StaticWallDefaults_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( 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 >
+{
+};
+
+struct StaticWallInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticWallInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+struct StaticWallInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticWallInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+Wall::Wall() :
+ ::property::OPropertySet( m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{}
+
+Wall::Wall( const Wall & rOther ) :
+ impl::Wall_Base(rOther),
+ ::property::OPropertySet( rOther, m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+{}
+
+Wall::~Wall()
+{}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL Wall::createClone()
+{
+ return uno::Reference< util::XCloneable >( new Wall( *this ));
+}
+
+// ____ 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;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL Wall::getInfoHelper()
+{
+ return *StaticWallInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL Wall::getPropertySetInfo()
+{
+ return *StaticWallInfo::get();
+}
+
+// ____ 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");
+ }
+}
+
+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");
+ }
+}
+
+// ____ XModifyListener ____
+void SAL_CALL Wall::modified( const lang::EventObject& aEvent )
+{
+ m_xModifyEventForwarder->modified( aEvent );
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL Wall::disposing( const lang::EventObject& /* Source */ )
+{
+ // nothing
+}
+
+// ____ OPropertySet ____
+void Wall::firePropertyChangeEvent()
+{
+ m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
+}
+
+using impl::Wall_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( Wall, Wall_Base, ::property::OPropertySet )
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/Wall.hxx b/chart2/source/model/main/Wall.hxx
new file mode 100644
index 000000000..a3112a614
--- /dev/null
+++ b/chart2/source/model/main/Wall.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_MAIN_WALL_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_MAIN_WALL_HXX
+
+#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>
+
+namespace chart
+{
+
+namespace impl
+{
+typedef ::cppu::WeakImplHelper<
+ css::util::XCloneable,
+ css::util::XModifyBroadcaster,
+ css::util::XModifyListener >
+ Wall_Base;
+}
+
+class Wall final :
+ public MutexContainer,
+ public impl::Wall_Base,
+ public ::property::OPropertySet
+{
+public:
+ Wall();
+ virtual ~Wall() override;
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+
+private:
+ explicit Wall( const Wall & 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;
+
+private:
+
+ css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_MAIN_WALL_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/AreaChartType.cxx b/chart2/source/model/template/AreaChartType.cxx
new file mode 100644
index 000000000..840bdba03
--- /dev/null
+++ b/chart2/source/model/template/AreaChartType.cxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "AreaChartType.hxx"
+#include <servicenames_charttypes.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+namespace com::sun::star::uno { class XComponentContext; }
+
+using namespace ::com::sun::star;
+
+namespace chart
+{
+
+AreaChartType::AreaChartType()
+{}
+
+AreaChartType::AreaChartType( const AreaChartType & rOther ) :
+ ChartType( rOther )
+{}
+
+AreaChartType::~AreaChartType()
+{}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL AreaChartType::createClone()
+{
+ return uno::Reference< util::XCloneable >( new AreaChartType( *this ));
+}
+
+// ____ XChartType ____
+OUString SAL_CALL AreaChartType::getChartType()
+{
+ return CHART2_SERVICE_NAME_CHARTTYPE_AREA;
+}
+
+OUString SAL_CALL AreaChartType::getImplementationName()
+{
+ return "com.sun.star.comp.chart.AreaChartType";
+}
+
+sal_Bool SAL_CALL AreaChartType::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL AreaChartType::getSupportedServiceNames()
+{
+ return {
+ CHART2_SERVICE_NAME_CHARTTYPE_AREA,
+ "com.sun.star.chart2.ChartType" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart_AreaChartType_get_implementation(css::uno::XComponentContext * /*context*/,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::AreaChartType);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/AreaChartType.hxx b/chart2/source/model/template/AreaChartType.hxx
new file mode 100644
index 000000000..acb76ef10
--- /dev/null
+++ b/chart2/source/model/template/AreaChartType.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_AREACHARTTYPE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_AREACHARTTYPE_HXX
+
+#include "ChartType.hxx"
+
+namespace chart
+{
+
+class AreaChartType final : public ChartType
+{
+public:
+ explicit AreaChartType();
+ virtual ~AreaChartType() 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;
+
+private:
+ explicit AreaChartType( const AreaChartType & rOther );
+
+ // ____ XChartType ____
+ virtual OUString SAL_CALL getChartType() override;
+
+ // ____ XCloneable ____
+ virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_AREACHARTTYPE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/AreaChartTypeTemplate.cxx b/chart2/source/model/template/AreaChartTypeTemplate.cxx
new file mode 100644
index 000000000..401dc6971
--- /dev/null
+++ b/chart2/source/model/template/AreaChartTypeTemplate.cxx
@@ -0,0 +1,237 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "AreaChartTypeTemplate.hxx"
+#include <servicenames_charttypes.hxx>
+#include <DiagramHelper.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 <algorithm>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+
+namespace
+{
+
+enum
+{
+ PROP_AREA_TEMPLATE_DIMENSION
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "Dimension",
+ PROP_AREA_TEMPLATE_DIMENSION,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+struct StaticAreaChartTypeTemplateDefaults_Initializer
+{
+ ::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 >
+{
+};
+
+struct StaticAreaChartTypeTemplateInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAreaChartTypeTemplateInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+struct StaticAreaChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticAreaChartTypeTemplateInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+AreaChartTypeTemplate::AreaChartTypeTemplate(
+ uno::Reference<
+ uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ 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 ));
+}
+
+AreaChartTypeTemplate::~AreaChartTypeTemplate()
+{}
+
+// ____ OPropertySet ____
+uno::Any AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticAreaChartTypeTemplateDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL AreaChartTypeTemplate::getInfoHelper()
+{
+ return *StaticAreaChartTypeTemplateInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL AreaChartTypeTemplate::getPropertySetInfo()
+{
+ return *StaticAreaChartTypeTemplateInfo::get();
+}
+
+sal_Int32 AreaChartTypeTemplate::getDimension() const
+{
+ sal_Int32 nDim = 2;
+ try
+ {
+ // note: UNO-methods are never const
+ const_cast< AreaChartTypeTemplate * >( this )->
+ getFastPropertyValue( PROP_AREA_TEMPLATE_DIMENSION ) >>= nDim;
+ }
+ catch( const beans::UnknownPropertyException & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return nDim;
+}
+
+StackMode AreaChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) const
+{
+ return m_eStackMode;
+}
+
+// ____ XChartTypeTemplate ____
+void SAL_CALL AreaChartTypeTemplate::applyStyle(
+ const Reference< chart2::XDataSeries >& xSeries,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount )
+{
+ ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+}
+
+void SAL_CALL AreaChartTypeTemplate::resetStyles( const Reference< chart2::XDiagram >& xDiagram )
+{
+ ChartTypeTemplate::resetStyles( xDiagram );
+ std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ 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 )
+ {
+ xState->setPropertyToDefault( "BorderStyle");
+ }
+ }
+}
+
+Reference< chart2::XChartType > 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;
+}
+
+Reference< chart2::XChartType > SAL_CALL AreaChartTypeTemplate::getChartTypeForNewSeries(
+ const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+{
+ Reference< chart2::XChartType > xResult( getChartTypeForIndex( 0 ) );
+ ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
+ return xResult;
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2( AreaChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( AreaChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/AreaChartTypeTemplate.hxx b/chart2/source/model/template/AreaChartTypeTemplate.hxx
new file mode 100644
index 000000000..e56be9833
--- /dev/null
+++ b/chart2/source/model/template/AreaChartTypeTemplate.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_AREACHARTTYPETEMPLATE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_AREACHARTTYPETEMPLATE_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
+{
+public:
+ explicit AreaChartTypeTemplate(
+ css::uno::Reference< css::uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ StackMode eStackMode,
+ sal_Int32 nDim = 2 );
+ virtual ~AreaChartTypeTemplate() override;
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ 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;
+
+ // ____ 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,
+ ::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 >
+ getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
+ virtual sal_Int32 getDimension() const override;
+ virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
+
+private:
+ StackMode m_eStackMode;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_AREACHARTTYPETEMPLATE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/BarChartType.cxx b/chart2/source/model/template/BarChartType.cxx
new file mode 100644
index 000000000..87675e3f1
--- /dev/null
+++ b/chart2/source/model/template/BarChartType.cxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "BarChartType.hxx"
+#include <servicenames_charttypes.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+namespace com::sun::star::uno { class XComponentContext; }
+
+using namespace ::com::sun::star;
+
+namespace chart
+{
+
+BarChartType::BarChartType()
+{}
+
+BarChartType::BarChartType( const BarChartType & rOther ) :
+ ChartType( rOther )
+{
+}
+
+BarChartType::~BarChartType()
+{}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL BarChartType::createClone()
+{
+ return uno::Reference< util::XCloneable >( new BarChartType( *this ));
+}
+
+// ____ XChartType ____
+OUString SAL_CALL BarChartType::getChartType()
+{
+ return CHART2_SERVICE_NAME_CHARTTYPE_BAR;
+}
+
+uno::Sequence< OUString > BarChartType::getSupportedPropertyRoles()
+{
+ uno::Sequence< OUString > aPropRoles(2);
+ aPropRoles[0] = "FillColor";
+ aPropRoles[1] = "BorderColor";
+
+ return aPropRoles;
+}
+
+OUString SAL_CALL BarChartType::getImplementationName()
+{
+ return "com.sun.star.comp.chart.BarChartType";
+}
+
+sal_Bool SAL_CALL BarChartType::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL BarChartType::getSupportedServiceNames()
+{
+ return {
+ CHART2_SERVICE_NAME_CHARTTYPE_BAR,
+ "com.sun.star.chart2.ChartType" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart_BarChartType_get_implementation(css::uno::XComponentContext * /*context*/,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::BarChartType);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/BarChartType.hxx b/chart2/source/model/template/BarChartType.hxx
new file mode 100644
index 000000000..4d090c783
--- /dev/null
+++ b/chart2/source/model/template/BarChartType.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BARCHARTTYPE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BARCHARTTYPE_HXX
+
+#include "ChartType.hxx"
+
+namespace chart
+{
+
+class BarChartType final : public ChartType
+{
+public:
+ explicit BarChartType();
+ virtual ~BarChartType() 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;
+
+private:
+ explicit BarChartType( const BarChartType & rOther );
+
+ // ____ XChartType ____
+ virtual OUString SAL_CALL getChartType() override;
+ virtual css::uno::Sequence< OUString > SAL_CALL
+ getSupportedPropertyRoles() override;
+
+ // ____ XCloneable ____
+ virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BARCHARTTYPE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/BarChartTypeTemplate.cxx b/chart2/source/model/template/BarChartTypeTemplate.cxx
new file mode 100644
index 000000000..dce1ffbb0
--- /dev/null
+++ b/chart2/source/model/template/BarChartTypeTemplate.cxx
@@ -0,0 +1,311 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "BarChartTypeTemplate.hxx"
+#include <DiagramHelper.hxx>
+#include <servicenames_charttypes.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 <algorithm>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::Property;
+
+namespace
+{
+
+enum
+{
+ PROP_BAR_TEMPLATE_DIMENSION,
+ PROP_BAR_TEMPLATE_GEOMETRY3D
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "Dimension",
+ PROP_BAR_TEMPLATE_DIMENSION,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "Geometry3D",
+ PROP_BAR_TEMPLATE_GEOMETRY3D,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+struct StaticBarChartTypeTemplateDefaults_Initializer
+{
+ ::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 >
+{
+};
+
+struct StaticBarChartTypeTemplateInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBarChartTypeTemplateInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+struct StaticBarChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBarChartTypeTemplateInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+BarChartTypeTemplate::BarChartTypeTemplate(
+ Reference<
+ uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ StackMode eStackMode,
+ BarDirection eDirection,
+ sal_Int32 nDim /* = 2 */ ) :
+ ChartTypeTemplate( xContext, rServiceName ),
+ ::property::OPropertySet( m_aMutex ),
+ m_eStackMode( eStackMode ),
+ m_eBarDirection( eDirection ),
+ m_nDim( nDim )
+{}
+
+BarChartTypeTemplate::~BarChartTypeTemplate()
+{}
+
+sal_Int32 BarChartTypeTemplate::getDimension() const
+{
+ return m_nDim;
+}
+
+StackMode BarChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) const
+{
+ return m_eStackMode;
+}
+
+bool BarChartTypeTemplate::isSwapXAndY() const
+{
+ return (m_eBarDirection == HORIZONTAL);
+}
+
+// ____ XChartTypeTemplate ____
+sal_Bool SAL_CALL BarChartTypeTemplate::matchesTemplate(
+ const Reference< chart2::XDiagram >& xDiagram,
+ sal_Bool bAdaptProperties )
+{
+ bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
+
+ //check BarDirection
+ if( bResult )
+ {
+ bool bFound = false;
+ bool bAmbiguous = false;
+ bool bVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
+ if( m_eBarDirection == HORIZONTAL )
+ bResult = bVertical;
+ else if( m_eBarDirection == VERTICAL )
+ bResult = !bVertical;
+ }
+
+ // adapt solid-type of template according to values in series
+ if( bAdaptProperties &&
+ bResult &&
+ getDimension() == 3 )
+ {
+
+ bool bGeomFound = false, bGeomAmbiguous = false;
+ sal_Int32 aCommonGeom = DiagramHelper::getGeometry3D( xDiagram, bGeomFound, bGeomAmbiguous );
+
+ if( !bGeomAmbiguous )
+ {
+ setFastPropertyValue_NoBroadcast(
+ PROP_BAR_TEMPLATE_GEOMETRY3D, uno::Any( aCommonGeom ));
+ }
+ }
+
+ 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;
+}
+
+Reference< chart2::XChartType > SAL_CALL BarChartTypeTemplate::getChartTypeForNewSeries(
+ const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+{
+ Reference< chart2::XChartType > xResult( getChartTypeForIndex( 0 ) );
+ ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
+ return xResult;
+}
+
+// ____ OPropertySet ____
+uno::Any BarChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticBarChartTypeTemplateDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL BarChartTypeTemplate::getInfoHelper()
+{
+ return *StaticBarChartTypeTemplateInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+Reference< beans::XPropertySetInfo > SAL_CALL BarChartTypeTemplate::getPropertySetInfo()
+{
+ return *StaticBarChartTypeTemplateInfo::get();
+}
+
+void SAL_CALL BarChartTypeTemplate::applyStyle(
+ const Reference< chart2::XDataSeries >& xSeries,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount )
+{
+ ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+ if( getDimension() != 3 )
+ return;
+
+ try
+ {
+ //apply Geometry3D
+ uno::Any aAGeometry3D;
+ getFastPropertyValue( aAGeometry3D, PROP_BAR_TEMPLATE_GEOMETRY3D );
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "Geometry3D", aAGeometry3D );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+void SAL_CALL BarChartTypeTemplate::resetStyles(
+ const Reference< chart2::XDiagram >& xDiagram )
+{
+ ChartTypeTemplate::resetStyles( xDiagram );
+ std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ 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 )
+ xState->setPropertyToDefault( "Geometry3D");
+ Reference< beans::XPropertySet > xProp( xState, uno::UNO_QUERY );
+ if( xProp.is() &&
+ xProp->getPropertyValue( "BorderStyle") == aLineStyleAny )
+ {
+ xState->setPropertyToDefault( "BorderStyle");
+ }
+ }
+ }
+
+ DiagramHelper::setVertical( xDiagram, false );
+}
+
+void BarChartTypeTemplate::createCoordinateSystems(
+ const Reference< chart2::XCoordinateSystemContainer > & xCooSysCnt )
+{
+ ChartTypeTemplate::createCoordinateSystems( xCooSysCnt );
+
+ Reference< chart2::XDiagram > xDiagram( xCooSysCnt, uno::UNO_QUERY );
+ DiagramHelper::setVertical( xDiagram, m_eBarDirection == HORIZONTAL );
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2( BarChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( BarChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/BarChartTypeTemplate.hxx b/chart2/source/model/template/BarChartTypeTemplate.hxx
new file mode 100644
index 000000000..593a1f7fe
--- /dev/null
+++ b/chart2/source/model/template/BarChartTypeTemplate.hxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BARCHARTTYPETEMPLATE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BARCHARTTYPETEMPLATE_HXX
+
+#include <OPropertySet.hxx>
+#include <MutexContainer.hxx>
+#include <comphelper/uno3.hxx>
+
+#include "ChartTypeTemplate.hxx"
+#include <StackMode.hxx>
+
+namespace chart
+{
+
+class BarChartTypeTemplate :
+ public MutexContainer,
+ public ChartTypeTemplate,
+ public ::property::OPropertySet
+{
+public:
+ enum BarDirection
+ {
+ HORIZONTAL,
+ VERTICAL
+ };
+
+ explicit BarChartTypeTemplate(
+ css::uno::Reference< css::uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ StackMode eStackMode,
+ BarDirection eDirection,
+ sal_Int32 nDim = 2 );
+ virtual ~BarChartTypeTemplate() override;
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ 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;
+
+ // ____ 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,
+ ::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 >
+ 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;
+
+private:
+ StackMode m_eStackMode;
+ BarDirection m_eBarDirection;
+ sal_Int32 m_nDim;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BARCHARTTYPETEMPLATE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/BubbleChartType.cxx b/chart2/source/model/template/BubbleChartType.cxx
new file mode 100644
index 000000000..4abdbb826
--- /dev/null
+++ b/chart2/source/model/template/BubbleChartType.cxx
@@ -0,0 +1,220 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "BubbleChartType.hxx"
+#include <PropertyHelper.hxx>
+#include <servicenames_charttypes.hxx>
+#include <CartesianCoordinateSystem.hxx>
+#include <AxisHelper.hxx>
+#include <AxisIndexDefines.hxx>
+#include <com/sun/star/chart2/AxisType.hpp>
+#include <cppuhelper/supportsservice.hxx>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Sequence;
+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 >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+BubbleChartType::BubbleChartType()
+{
+}
+
+BubbleChartType::BubbleChartType( const BubbleChartType & rOther ) :
+ ChartType( rOther )
+{
+}
+
+BubbleChartType::~BubbleChartType()
+{}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL BubbleChartType::createClone()
+{
+ return uno::Reference< util::XCloneable >( new BubbleChartType( *this ));
+}
+
+// ____ XChartType ____
+Reference< chart2::XCoordinateSystem > SAL_CALL
+ BubbleChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
+{
+ Reference< chart2::XCoordinateSystem > xResult(
+ new CartesianCoordinateSystem( DimensionCount ));
+
+ for( sal_Int32 i=0; i<DimensionCount; ++i )
+ {
+ Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
+ if( !xAxis.is() )
+ {
+ OSL_FAIL("a created coordinate system should have an axis for each dimension");
+ continue;
+ }
+
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
+ aScaleData.Scaling = AxisHelper::createLinearScaling();
+
+ if( i == 2 )
+ aScaleData.AxisType = chart2::AxisType::SERIES;
+ else
+ aScaleData.AxisType = chart2::AxisType::REALNUMBER;
+
+ xAxis->setScaleData( aScaleData );
+ }
+
+ return xResult;
+}
+
+OUString SAL_CALL BubbleChartType::getChartType()
+{
+ return CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE;
+}
+
+uno::Sequence< OUString > SAL_CALL BubbleChartType::getSupportedMandatoryRoles()
+{
+ uno::Sequence< OUString > aMandRolesSeq(4);
+ aMandRolesSeq[0] = "label";
+ aMandRolesSeq[1] = "values-x";
+ aMandRolesSeq[2] = "values-y";
+ aMandRolesSeq[3] = "values-size";
+ return aMandRolesSeq;
+}
+
+uno::Sequence< OUString > SAL_CALL BubbleChartType::getSupportedPropertyRoles()
+{
+ uno::Sequence< OUString > aPropertyRoles(2);
+ aPropertyRoles[0] = "FillColor";
+ aPropertyRoles[1] = "BorderColor";
+ return aPropertyRoles;
+}
+
+OUString SAL_CALL BubbleChartType::getRoleOfSequenceForSeriesLabel()
+{
+ return "values-size";
+}
+
+// ____ 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;
+}
+
+// ____ OPropertySet ____
+::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartType::getInfoHelper()
+{
+ return *StaticBubbleChartTypeInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartType::getPropertySetInfo()
+{
+ return *StaticBubbleChartTypeInfo::get();
+}
+
+OUString SAL_CALL BubbleChartType::getImplementationName()
+{
+ return "com.sun.star.comp.chart.BubbleChartType";
+}
+
+sal_Bool SAL_CALL BubbleChartType::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL BubbleChartType::getSupportedServiceNames()
+{
+ return {
+ CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE,
+ "com.sun.star.chart2.ChartType",
+ "com.sun.star.beans.PropertySet" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart_BubbleChartType_get_implementation(css::uno::XComponentContext * /*context*/,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::BubbleChartType);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/BubbleChartType.hxx b/chart2/source/model/template/BubbleChartType.hxx
new file mode 100644
index 000000000..e37a01ac2
--- /dev/null
+++ b/chart2/source/model/template/BubbleChartType.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BUBBLECHARTTYPE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BUBBLECHARTTYPE_HXX
+
+#include "ChartType.hxx"
+
+namespace chart
+{
+
+class BubbleChartType final : public ChartType
+{
+public:
+ explicit BubbleChartType();
+ virtual ~BubbleChartType() 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;
+
+private:
+ explicit BubbleChartType( const BubbleChartType & rOther );
+
+ // ____ XChartType ____
+ virtual OUString SAL_CALL getChartType() override;
+ virtual css::uno::Sequence< OUString > SAL_CALL
+ 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;
+
+ // ____ 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;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BUBBLECHARTTYPE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.cxx b/chart2/source/model/template/BubbleChartTypeTemplate.cxx
new file mode 100644
index 000000000..90ec1a75d
--- /dev/null
+++ b/chart2/source/model/template/BubbleChartTypeTemplate.cxx
@@ -0,0 +1,211 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "BubbleChartTypeTemplate.hxx"
+#include "BubbleDataInterpreter.hxx"
+#include <servicenames_charttypes.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 <algorithm>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+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 >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+BubbleChartTypeTemplate::BubbleChartTypeTemplate(
+ Reference<
+ uno::XComponentContext > const & xContext,
+ const OUString & rServiceName ) :
+ ChartTypeTemplate( xContext, rServiceName ),
+ ::property::OPropertySet( m_aMutex )
+{
+}
+
+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;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartTypeTemplate::getInfoHelper()
+{
+ return *StaticBubbleChartTypeTemplateInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartTypeTemplate::getPropertySetInfo()
+{
+ return *StaticBubbleChartTypeTemplateInfo::get();
+}
+
+sal_Int32 BubbleChartTypeTemplate::getDimension() const
+{
+ return 2;
+}
+
+StackMode BubbleChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) const
+{
+ return StackMode::NONE;
+}
+
+void SAL_CALL BubbleChartTypeTemplate::applyStyle(
+ const Reference< chart2::XDataSeries >& xSeries,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount )
+{
+ ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+}
+
+// ____ XChartTypeTemplate ____
+sal_Bool SAL_CALL BubbleChartTypeTemplate::supportsCategories()
+{
+ return false;
+}
+
+Reference< chart2::XChartType > 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;
+}
+
+Reference< chart2::XChartType > SAL_CALL BubbleChartTypeTemplate::getChartTypeForNewSeries(
+ const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+{
+ 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 );
+
+ ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xResult;
+}
+
+Reference< chart2::XDataInterpreter > SAL_CALL BubbleChartTypeTemplate::getDataInterpreter()
+{
+ if( ! m_xDataInterpreter.is())
+ m_xDataInterpreter.set( new BubbleDataInterpreter );
+
+ return m_xDataInterpreter;
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2( BubbleChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( BubbleChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.hxx b/chart2/source/model/template/BubbleChartTypeTemplate.hxx
new file mode 100644
index 000000000..b771d6f57
--- /dev/null
+++ b/chart2/source/model/template/BubbleChartTypeTemplate.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BUBBLECHARTTYPETEMPLATE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BUBBLECHARTTYPETEMPLATE_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
+{
+public:
+ explicit BubbleChartTypeTemplate(
+ css::uno::Reference< css::uno::XComponentContext > const & xContext,
+ const OUString & rServiceName );
+ virtual ~BubbleChartTypeTemplate() override;
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ 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;
+
+ // ____ XChartTypeTemplate ____
+ 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,
+ ::sal_Int32 nChartTypeGroupIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount ) override;
+
+ // ____ ChartTypeTemplate ____
+ virtual css::uno::Reference< css::chart2::XChartType >
+ getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
+ virtual sal_Int32 getDimension() const override;
+ virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BUBBLECHARTTYPETEMPLATE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/BubbleDataInterpreter.cxx b/chart2/source/model/template/BubbleDataInterpreter.cxx
new file mode 100644
index 000000000..3078d3590
--- /dev/null
+++ b/chart2/source/model/template/BubbleDataInterpreter.cxx
@@ -0,0 +1,290 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "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>
+
+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;
+
+namespace chart
+{
+
+BubbleDataInterpreter::BubbleDataInterpreter() :
+ DataInterpreter()
+{
+}
+
+BubbleDataInterpreter::~BubbleDataInterpreter()
+{
+}
+
+// ____ XDataInterpreter ____
+chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
+ const Reference< chart2::data::XDataSource >& xSource,
+ const Sequence< beans::PropertyValue >& aArguments,
+ const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+{
+ if( ! xSource.is())
+ return InterpretedData();
+
+ Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
+
+ Reference< data::XLabeledDataSequence > xValuesX;
+ vector< Reference< data::XLabeledDataSequence > > aYValuesVector;
+ vector< Reference< data::XLabeledDataSequence > > aSizeValuesVector;
+
+ Reference< data::XLabeledDataSequence > xCategories;
+ bool bHasCategories = HasCategories( aArguments, aData );
+ bool bUseCategoriesAsX = UseCategoriesAsX( aArguments );
+
+ sal_Int32 nDataSeqCount = aData.getLength();
+
+ bool bSetXValues = bHasCategories ? ( (nDataSeqCount-1) > 2 && (nDataSeqCount-1) % 2 != 0 )
+ :( nDataSeqCount > 2 && nDataSeqCount % 2 != 0 );
+
+ bool bCategoriesUsed = false;
+ bool bNextIsYValues = bHasCategories ? nDataSeqCount>2 : nDataSeqCount>1;
+ for( sal_Int32 nDataIdx = 0; nDataIdx < nDataSeqCount; ++nDataIdx )
+ {
+ try
+ {
+ if( bHasCategories && !bCategoriesUsed )
+ {
+ xCategories.set( aData[nDataIdx] );
+ if( xCategories.is())
+ {
+ SetRole( xCategories->getValues(), "categories");
+ if( bUseCategoriesAsX )
+ {
+ bSetXValues = false;
+ bNextIsYValues = nDataSeqCount > 2;
+ }
+ }
+ bCategoriesUsed = true;
+ }
+ else if( !xValuesX.is() && bSetXValues )
+ {
+ xValuesX.set( aData[nDataIdx] );
+ if( xValuesX.is())
+ SetRole( xValuesX->getValues(), "values-x");
+ }
+ else if( bNextIsYValues )
+ {
+ aYValuesVector.push_back( aData[nDataIdx] );
+ if( aData[nDataIdx].is())
+ SetRole( aData[nDataIdx]->getValues(), "values-y");
+ bNextIsYValues = false;
+ }
+ else if( !bNextIsYValues )
+ {
+ aSizeValuesVector.push_back( aData[nDataIdx] );
+ if( aData[nDataIdx].is())
+ SetRole( aData[nDataIdx]->getValues(), "values-size");
+ bNextIsYValues = (nDataSeqCount-(nDataIdx+1)) >= 2;//two or more left
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ // create DataSeries
+ sal_Int32 nSeriesIndex = 0;
+ vector< Reference< XDataSeries > > aSeriesVec;
+ aSeriesVec.reserve( aSizeValuesVector.size());
+
+ Reference< data::XLabeledDataSequence > xClonedXValues = xValuesX;
+ Reference< util::XCloneable > xCloneableX( xValuesX, uno::UNO_QUERY );
+
+ for( size_t nN = 0; nN < aSizeValuesVector.size(); ++nN, ++nSeriesIndex )
+ {
+ vector< Reference< data::XLabeledDataSequence > > aNewData;
+ if( xValuesX.is() )
+ {
+ if( nN > 0 && xCloneableX.is() )
+ xClonedXValues.set( xCloneableX->createClone(), uno::UNO_QUERY );
+ aNewData.push_back( xClonedXValues );
+ }
+ if( aYValuesVector.size() > nN )
+ aNewData.push_back( aYValuesVector[nN] );
+ aNewData.push_back(aSizeValuesVector[nN]);
+
+ Reference< XDataSeries > xSeries;
+ if( nSeriesIndex < aSeriesToReUse.getLength())
+ xSeries.set( 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 ) );
+
+ aSeriesVec.push_back( xSeries );
+ }
+
+ Sequence< Sequence< Reference< XDataSeries > > > aSeries(1);
+ aSeries[0] = comphelper::containerToSequence( aSeriesVec );
+ return InterpretedData( aSeries, xCategories );
+}
+
+chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
+ const chart2::InterpretedData& aInterpretedData )
+{
+ InterpretedData aResult( aInterpretedData );
+
+ sal_Int32 i=0;
+ Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ const sal_Int32 nCount = aSeries.getLength();
+ for( ; i<nCount; ++i )
+ {
+ try
+ {
+ Reference< data::XDataSource > xSeriesSource( aSeries[i], uno::UNO_QUERY_THROW );
+ Sequence< Reference< 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" ));
+
+ if( ! xValuesX.is() ||
+ ! xValuesY.is() ||
+ ! xValuesSize.is() )
+ {
+ vector< Reference< data::XLabeledDataSequence > > aValueSeqVec(
+ DataSeriesHelper::getAllDataSequencesByRole(
+ xSeriesSource->getDataSequences(), "values" ));
+ if( xValuesX.is())
+ aValueSeqVec.erase( find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesX ));
+ if( xValuesY.is())
+ aValueSeqVec.erase( find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesY ));
+ if( xValuesSize.is())
+ aValueSeqVec.erase( find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesSize ));
+
+ size_t nIndex = 0;
+
+ if( ! xValuesSize.is() &&
+ aValueSeqVec.size() > nIndex )
+ {
+ xValuesSize.set( aValueSeqVec[nIndex++] );
+ if( xValuesSize.is())
+ SetRole( xValuesSize->getValues(), "values-size");
+ }
+
+ if( ! xValuesY.is() &&
+ aValueSeqVec.size() > nIndex )
+ {
+ xValuesY.set( aValueSeqVec[nIndex++] );
+ if( xValuesY.is())
+ SetRole( xValuesY->getValues(), "values-y");
+ }
+
+ if( ! xValuesX.is() &&
+ aValueSeqVec.size() > nIndex )
+ {
+ xValuesX.set( aValueSeqVec[nIndex++] );
+ if( xValuesX.is())
+ SetRole( xValuesY->getValues(), "values-x");
+ }
+ }
+ if( xValuesSize.is())
+ {
+ if( xValuesY.is() )
+ {
+ if( xValuesX.is() )
+ {
+ aNewSequences.realloc(3);
+ aNewSequences[0] = xValuesX;
+ aNewSequences[1] = xValuesY;
+ aNewSequences[2] = xValuesSize;
+ }
+ else
+ {
+ aNewSequences.realloc(2);
+ aNewSequences[0] = xValuesY;
+ aNewSequences[1] = xValuesSize;
+ }
+ }
+ else
+ {
+ aNewSequences.realloc(1);
+ aNewSequences[0] = xValuesSize;
+ }
+ }
+
+ const Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
+ if( aSeqs.getLength() != aNewSequences.getLength() )
+ {
+#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
+ for( auto const & j : aSeqs )
+ {
+ 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 );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return aResult;
+}
+
+sal_Bool SAL_CALL BubbleDataInterpreter::isDataCompatible(
+ const chart2::InterpretedData& aInterpretedData )
+{
+ const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ for( Reference< XDataSeries > const & dataSeries : aSeries )
+ {
+ try
+ {
+ Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
+ Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
+ if( aSeq.getLength() != 3 )
+ return false;
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return true;
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/BubbleDataInterpreter.hxx b/chart2/source/model/template/BubbleDataInterpreter.hxx
new file mode 100644
index 000000000..43921262e
--- /dev/null
+++ b/chart2/source/model/template/BubbleDataInterpreter.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BUBBLEDATAINTERPRETER_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BUBBLEDATAINTERPRETER_HXX
+
+#include "DataInterpreter.hxx"
+
+namespace chart
+{
+
+class BubbleDataInterpreter : public DataInterpreter
+{
+public:
+ explicit BubbleDataInterpreter();
+ virtual ~BubbleDataInterpreter() override;
+
+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;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_BUBBLEDATAINTERPRETER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/CandleStickChartType.cxx b/chart2/source/model/template/CandleStickChartType.cxx
new file mode 100644
index 000000000..af0c1f04f
--- /dev/null
+++ b/chart2/source/model/template/CandleStickChartType.cxx
@@ -0,0 +1,342 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "CandleStickChartType.hxx"
+#include <PropertyHelper.hxx>
+#include <StockBar.hxx>
+#include <ModifyListenerHelper.hxx>
+#include <servicenames_charttypes.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <cppuhelper/supportsservice.hxx>
+#include <tools/diagnose_ex.h>
+
+namespace com::sun::star::uno { class XComponentContext; }
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+
+namespace
+{
+
+enum
+{
+ PROP_CANDLESTICKCHARTTYPE_JAPANESE,
+ PROP_CANDLESTICKCHARTTYPE_WHITE_DAY,
+ PROP_CANDLESTICKCHARTTYPE_BLACK_DAY,
+
+ PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST,
+ PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "Japanese",
+ PROP_CANDLESTICKCHARTTYPE_JAPANESE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "WhiteDay",
+ PROP_CANDLESTICKCHARTTYPE_WHITE_DAY,
+ cppu::UnoType<beans::XPropertySet>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( "BlackDay",
+ PROP_CANDLESTICKCHARTTYPE_BLACK_DAY,
+ cppu::UnoType<beans::XPropertySet>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back( "ShowFirst",
+ PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "ShowHighLow",
+ PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | 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 >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+CandleStickChartType::CandleStickChartType()
+{
+ Reference< beans::XPropertySet > xWhiteDayProps( new ::chart::StockBar( true ));
+ Reference< beans::XPropertySet > xBlackDayProps( new ::chart::StockBar( false ));
+
+ ModifyListenerHelper::addListener( xWhiteDayProps, m_xModifyEventForwarder );
+ ModifyListenerHelper::addListener( xBlackDayProps, m_xModifyEventForwarder );
+
+ setFastPropertyValue_NoBroadcast(
+ PROP_CANDLESTICKCHARTTYPE_WHITE_DAY, uno::Any( xWhiteDayProps ));
+ setFastPropertyValue_NoBroadcast(
+ PROP_CANDLESTICKCHARTTYPE_BLACK_DAY, uno::Any( xBlackDayProps ));
+}
+
+CandleStickChartType::CandleStickChartType( const CandleStickChartType & rOther ) :
+ ChartType( rOther )
+{
+ Reference< beans::XPropertySet > xPropertySet;
+ uno::Any aValue;
+
+ getFastPropertyValue( aValue, PROP_CANDLESTICKCHARTTYPE_WHITE_DAY );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ ModifyListenerHelper::addListener( xPropertySet, m_xModifyEventForwarder );
+
+ getFastPropertyValue( aValue, PROP_CANDLESTICKCHARTTYPE_BLACK_DAY );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ ModifyListenerHelper::addListener( xPropertySet, m_xModifyEventForwarder );
+}
+
+CandleStickChartType::~CandleStickChartType()
+{
+ try
+ {
+ Reference< beans::XPropertySet > xPropertySet;
+ uno::Any aValue;
+
+ getFastPropertyValue( aValue, PROP_CANDLESTICKCHARTTYPE_WHITE_DAY );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ ModifyListenerHelper::removeListener( xPropertySet, m_xModifyEventForwarder );
+
+ getFastPropertyValue( aValue, PROP_CANDLESTICKCHARTTYPE_BLACK_DAY );
+ if( ( aValue >>= xPropertySet )
+ && xPropertySet.is())
+ ModifyListenerHelper::removeListener( xPropertySet, m_xModifyEventForwarder );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL CandleStickChartType::createClone()
+{
+ return uno::Reference< util::XCloneable >( new CandleStickChartType( *this ));
+}
+
+// ____ XChartType ____
+OUString SAL_CALL CandleStickChartType::getChartType()
+{
+ return CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK;
+}
+
+uno::Sequence< OUString > SAL_CALL CandleStickChartType::getSupportedMandatoryRoles()
+{
+ bool bShowFirst = true;
+ bool bShowHiLow = false;
+ getFastPropertyValue( PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST ) >>= bShowFirst;
+ getFastPropertyValue( PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW ) >>= bShowHiLow;
+
+ std::vector< OUString > aMandRoles;
+
+ aMandRoles.emplace_back("label");
+ if( bShowFirst )
+ aMandRoles.emplace_back("values-first");
+
+ if( bShowHiLow )
+ {
+ aMandRoles.emplace_back("values-min");
+ aMandRoles.emplace_back("values-max");
+ }
+
+ aMandRoles.emplace_back("values-last");
+
+ return comphelper::containerToSequence( aMandRoles );
+}
+
+Sequence< OUString > SAL_CALL CandleStickChartType::getSupportedOptionalRoles()
+{
+ bool bShowFirst = true;
+ bool bShowHiLow = false;
+ getFastPropertyValue( PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST ) >>= bShowFirst;
+ getFastPropertyValue( PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW ) >>= bShowHiLow;
+
+ std::vector< OUString > aOptRoles;
+
+ if( ! bShowFirst )
+ aOptRoles.emplace_back("values-first");
+
+ if( ! bShowHiLow )
+ {
+ aOptRoles.emplace_back("values-min");
+ aOptRoles.emplace_back("values-max");
+ }
+
+ return comphelper::containerToSequence( aOptRoles );
+}
+
+OUString SAL_CALL CandleStickChartType::getRoleOfSequenceForSeriesLabel()
+{
+ return "values-last";
+}
+
+// ____ OPropertySet ____
+uno::Any CandleStickChartType::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticCandleStickChartTypeDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+// ____ OPropertySet ____
+::cppu::IPropertyArrayHelper & SAL_CALL CandleStickChartType::getInfoHelper()
+{
+ return *StaticCandleStickChartTypeInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+Reference< beans::XPropertySetInfo > SAL_CALL CandleStickChartType::getPropertySetInfo()
+{
+ return *StaticCandleStickChartTypeInfo::get();
+}
+
+void SAL_CALL CandleStickChartType::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle, const uno::Any& rValue )
+{
+ if( nHandle == PROP_CANDLESTICKCHARTTYPE_WHITE_DAY
+ || nHandle == PROP_CANDLESTICKCHARTTYPE_BLACK_DAY )
+ {
+ uno::Any aOldValue;
+ Reference< util::XModifyBroadcaster > xBroadcaster;
+ getFastPropertyValue( aOldValue, nHandle );
+ if( aOldValue.hasValue() &&
+ (aOldValue >>= xBroadcaster) &&
+ xBroadcaster.is())
+ {
+ ModifyListenerHelper::removeListener( xBroadcaster, m_xModifyEventForwarder );
+ }
+
+ OSL_ASSERT( rValue.getValueType().getTypeClass() == uno::TypeClass_INTERFACE );
+ if( rValue.hasValue() &&
+ (rValue >>= xBroadcaster) &&
+ xBroadcaster.is())
+ {
+ ModifyListenerHelper::addListener( xBroadcaster, m_xModifyEventForwarder );
+ }
+ }
+
+ ::property::OPropertySet::setFastPropertyValue_NoBroadcast( nHandle, rValue );
+}
+
+OUString SAL_CALL CandleStickChartType::getImplementationName()
+{
+ return "com.sun.star.comp.chart.CandleStickChartType" ;
+}
+
+sal_Bool SAL_CALL CandleStickChartType::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL CandleStickChartType::getSupportedServiceNames()
+{
+ return {
+ CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK,
+ "com.sun.star.chart2.ChartType",
+ "com.sun.star.beans.PropertySet" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart_CandleStickChartType_get_implementation(css::uno::XComponentContext * /*context*/,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::CandleStickChartType);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/CandleStickChartType.hxx b/chart2/source/model/template/CandleStickChartType.hxx
new file mode 100644
index 000000000..b3f8d37ec
--- /dev/null
+++ b/chart2/source/model/template/CandleStickChartType.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_CANDLESTICKCHARTTYPE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_CANDLESTICKCHARTTYPE_HXX
+
+#include "ChartType.hxx"
+
+namespace chart
+{
+
+class CandleStickChartType final : public ChartType
+{
+public:
+ explicit CandleStickChartType();
+ virtual ~CandleStickChartType() 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;
+
+private:
+ explicit CandleStickChartType( const CandleStickChartType & rOther );
+
+ // ____ XChartType ____
+ virtual OUString SAL_CALL getChartType() 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;
+
+ // ____ OPropertySet ____
+ virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+
+ // ____ OPropertySet ____
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
+
+ // ____ OPropertySet ____
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast
+ ( sal_Int32 nHandle,
+ const css::uno::Any& rValue ) 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;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_CANDLESTICKCHARTTYPE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ChartType.cxx b/chart2/source/model/template/ChartType.cxx
new file mode 100644
index 000000000..999f7c1ed
--- /dev/null
+++ b/chart2/source/model/template/ChartType.cxx
@@ -0,0 +1,308 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "ChartType.hxx"
+#include <CartesianCoordinateSystem.hxx>
+#include <AxisHelper.hxx>
+#include <CloneHelper.hxx>
+#include <AxisIndexDefines.hxx>
+#include <ModifyListenerHelper.hxx>
+#include <vcl/svapp.hxx>
+#include <com/sun/star/chart2/AxisType.hpp>
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+
+namespace chart
+{
+
+ChartType::ChartType() :
+ ::property::OPropertySet( m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_bNotifyChanges( true )
+{}
+
+ChartType::ChartType( const ChartType & rOther ) :
+ impl::ChartType_Base(rOther),
+ ::property::OPropertySet( rOther, m_aMutex ),
+ m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_bNotifyChanges( true )
+{
+ {
+ SolarMutexGuard g; // access to rOther.m_aDataSeries
+ CloneHelper::CloneRefVector<css::chart2::XDataSeries>(
+ rOther.m_aDataSeries, m_aDataSeries);
+ }
+ ModifyListenerHelper::addListenerToAllElements( m_aDataSeries, m_xModifyEventForwarder );
+}
+
+ChartType::~ChartType()
+{
+ ModifyListenerHelper::removeListenerFromAllElements( m_aDataSeries, m_xModifyEventForwarder );
+ m_aDataSeries.clear();
+}
+
+// ____ XChartType ____
+Reference< chart2::XCoordinateSystem > SAL_CALL
+ ChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
+{
+ Reference< chart2::XCoordinateSystem > xResult(
+ new CartesianCoordinateSystem( DimensionCount ));
+
+ for( sal_Int32 i=0; i<DimensionCount; ++i )
+ {
+ Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
+ if( !xAxis.is() )
+ {
+ OSL_FAIL("a created coordinate system should have an axis for each dimension");
+ continue;
+ }
+
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
+ aScaleData.Scaling = AxisHelper::createLinearScaling();
+
+ switch( i )
+ {
+ case 0: aScaleData.AxisType = chart2::AxisType::CATEGORY; break;
+ case 2: aScaleData.AxisType = chart2::AxisType::SERIES; break;
+ default: aScaleData.AxisType = chart2::AxisType::REALNUMBER; break;
+ }
+
+ xAxis->setScaleData( aScaleData );
+ }
+
+ return xResult;
+}
+
+Sequence< OUString > SAL_CALL ChartType::getSupportedMandatoryRoles()
+{
+ Sequence< OUString > aDefaultSeq(2);
+ aDefaultSeq[0] = "label";
+ aDefaultSeq[1] = "values-y";
+ return aDefaultSeq;
+}
+
+Sequence< OUString > SAL_CALL ChartType::getSupportedOptionalRoles()
+{
+ return Sequence< OUString >();
+}
+
+Sequence< OUString > SAL_CALL ChartType::getSupportedPropertyRoles()
+{
+ return Sequence< OUString >();
+}
+
+OUString SAL_CALL ChartType::getRoleOfSequenceForSeriesLabel()
+{
+ return "values-y";
+}
+
+void ChartType::impl_addDataSeriesWithoutNotification(
+ const Reference< chart2::XDataSeries >& xDataSeries )
+{
+ if( std::find( m_aDataSeries.begin(), m_aDataSeries.end(), xDataSeries )
+ != m_aDataSeries.end())
+ throw lang::IllegalArgumentException();
+
+ m_aDataSeries.push_back( xDataSeries );
+ ModifyListenerHelper::addListener( xDataSeries, m_xModifyEventForwarder );
+}
+
+// ____ XDataSeriesContainer ____
+void SAL_CALL ChartType::addDataSeries( const Reference< chart2::XDataSeries >& xDataSeries )
+{
+ SolarMutexGuard g;
+
+ impl_addDataSeriesWithoutNotification( xDataSeries );
+ fireModifyEvent();
+}
+
+void SAL_CALL ChartType::removeDataSeries( const Reference< chart2::XDataSeries >& xDataSeries )
+{
+ if( !xDataSeries.is())
+ throw container::NoSuchElementException();
+
+ SolarMutexGuard g;
+
+ tDataSeriesContainerType::iterator aIt(
+ std::find( m_aDataSeries.begin(), m_aDataSeries.end(), xDataSeries ) );
+
+ if( aIt == m_aDataSeries.end())
+ throw container::NoSuchElementException(
+ "The given series is no element of this charttype",
+ static_cast< uno::XWeak * >( this ));
+
+ ModifyListenerHelper::removeListener( xDataSeries, m_xModifyEventForwarder );
+ m_aDataSeries.erase( aIt );
+ fireModifyEvent();
+}
+
+Sequence< Reference< chart2::XDataSeries > > SAL_CALL ChartType::getDataSeries()
+{
+ SolarMutexGuard g;
+
+ return comphelper::containerToSequence( m_aDataSeries );
+}
+
+void SAL_CALL ChartType::setDataSeries( const Sequence< Reference< chart2::XDataSeries > >& aDataSeries )
+{
+ SolarMutexGuard g;
+
+ m_bNotifyChanges = false;
+ try
+ {
+ const Sequence< Reference< chart2::XDataSeries > > aOldSeries( getDataSeries() );
+ for( auto const & i : aOldSeries )
+ ModifyListenerHelper::removeListener( i, m_xModifyEventForwarder );
+ m_aDataSeries.clear();
+
+ for( auto const & i : aDataSeries )
+ impl_addDataSeriesWithoutNotification( i );
+ }
+ catch( ... )
+ {
+ m_bNotifyChanges = true;
+ throw;
+ }
+ m_bNotifyChanges = true;
+ fireModifyEvent();
+}
+
+// ____ OPropertySet ____
+uno::Any ChartType::GetDefaultValue( sal_Int32 /* nHandle */ ) const
+{
+ return uno::Any();
+}
+
+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 >
+{
+};
+
+}
+
+// ____ OPropertySet ____
+::cppu::IPropertyArrayHelper & SAL_CALL ChartType::getInfoHelper()
+{
+ return *StaticChartTypeInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL ChartType::getPropertySetInfo()
+{
+ return *StaticChartTypeInfo::get();
+}
+
+// ____ XModifyBroadcaster ____
+void SAL_CALL ChartType::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");
+ }
+}
+
+void SAL_CALL ChartType::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");
+ }
+}
+
+// ____ XModifyListener ____
+void SAL_CALL ChartType::modified( const lang::EventObject& aEvent )
+{
+ m_xModifyEventForwarder->modified( aEvent );
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL ChartType::disposing( const lang::EventObject& /* Source */ )
+{
+ // nothing
+}
+
+// ____ OPropertySet ____
+void ChartType::firePropertyChangeEvent()
+{
+ fireModifyEvent();
+}
+
+void ChartType::fireModifyEvent()
+{
+ bool bNotifyChanges;
+
+ {
+ SolarMutexGuard g;
+ bNotifyChanges = m_bNotifyChanges;
+ }
+
+ if (bNotifyChanges)
+ m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
+}
+
+using impl::ChartType_Base;
+
+IMPLEMENT_FORWARD_XINTERFACE2( ChartType, ChartType_Base, ::property::OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( ChartType, ChartType_Base, ::property::OPropertySet )
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ChartType.hxx b/chart2/source/model/template/ChartType.hxx
new file mode 100644
index 000000000..3274d5660
--- /dev/null
+++ b/chart2/source/model/template/ChartType.hxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_CHARTTYPE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_CHARTTYPE_HXX
+
+#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
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_CHARTTYPE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ChartTypeManager.cxx b/chart2/source/model/template/ChartTypeManager.cxx
new file mode 100644
index 000000000..c0bcc0a03
--- /dev/null
+++ b/chart2/source/model/template/ChartTypeManager.cxx
@@ -0,0 +1,606 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <ChartTypeManager.hxx>
+#include <StackMode.hxx>
+
+#include "LineChartTypeTemplate.hxx"
+#include "BarChartTypeTemplate.hxx"
+#include "ColumnLineChartTypeTemplate.hxx"
+#include "AreaChartTypeTemplate.hxx"
+#include "PieChartTypeTemplate.hxx"
+#include "ScatterChartTypeTemplate.hxx"
+#include "StockChartTypeTemplate.hxx"
+#include "NetChartTypeTemplate.hxx"
+#include "BubbleChartTypeTemplate.hxx"
+#include <cppuhelper/supportsservice.hxx>
+#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>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Sequence;
+
+namespace
+{
+
+enum TemplateId
+{
+ TEMPLATE_SYMBOL,
+ TEMPLATE_STACKEDSYMBOL,
+ TEMPLATE_PERCENTSTACKEDSYMBOL,
+ TEMPLATE_LINE,
+ TEMPLATE_STACKEDLINE,
+ TEMPLATE_PERCENTSTACKEDLINE,
+ TEMPLATE_LINESYMBOL,
+ TEMPLATE_STACKEDLINESYMBOL,
+ TEMPLATE_PERCENTSTACKEDLINESYMBOL,
+ TEMPLATE_THREEDLINE,
+ TEMPLATE_STACKEDTHREEDLINE,
+ TEMPLATE_PERCENTSTACKEDTHREEDLINE,
+ TEMPLATE_THREEDLINEDEEP,
+ TEMPLATE_COLUMN,
+ TEMPLATE_STACKEDCOLUMN,
+ TEMPLATE_PERCENTSTACKEDCOLUMN,
+ TEMPLATE_BAR,
+ TEMPLATE_STACKEDBAR,
+ TEMPLATE_PERCENTSTACKEDBAR,
+ TEMPLATE_THREEDCOLUMNDEEP,
+ TEMPLATE_THREEDCOLUMNFLAT,
+ TEMPLATE_STACKEDTHREEDCOLUMNFLAT,
+ TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT,
+ TEMPLATE_THREEDBARDEEP,
+ TEMPLATE_THREEDBARFLAT,
+ TEMPLATE_STACKEDTHREEDBARFLAT,
+ TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT,
+ TEMPLATE_COLUMNWITHLINE,
+ TEMPLATE_STACKEDCOLUMNWITHLINE,
+ TEMPLATE_AREA,
+ TEMPLATE_STACKEDAREA,
+ TEMPLATE_PERCENTSTACKEDAREA,
+ TEMPLATE_THREEDAREA,
+ TEMPLATE_STACKEDTHREEDAREA,
+ TEMPLATE_PERCENTSTACKEDTHREEDAREA,
+ TEMPLATE_PIE,
+ TEMPLATE_PIEALLEXPLODED,
+ TEMPLATE_DONUT,
+ TEMPLATE_DONUTALLEXPLODED,
+ TEMPLATE_THREEDPIE,
+ TEMPLATE_THREEDPIEALLEXPLODED,
+ TEMPLATE_THREEDDONUT,
+ TEMPLATE_THREEDDONUTALLEXPLODED,
+ TEMPLATE_SCATTERLINESYMBOL,
+ TEMPLATE_SCATTERLINE,
+ TEMPLATE_SCATTERSYMBOL,
+ TEMPLATE_THREEDSCATTER,
+ TEMPLATE_NET,
+ TEMPLATE_NETSYMBOL,
+ TEMPLATE_NETLINE,
+ TEMPLATE_STACKEDNET,
+ TEMPLATE_STACKEDNETSYMBOL,
+ TEMPLATE_STACKEDNETLINE,
+ TEMPLATE_PERCENTSTACKEDNET,
+ TEMPLATE_PERCENTSTACKEDNETSYMBOL,
+ TEMPLATE_PERCENTSTACKEDNETLINE,
+ TEMPLATE_FILLEDNET,
+ TEMPLATE_STACKEDFILLEDNET,
+ TEMPLATE_PERCENTSTACKEDFILLEDNET,
+ TEMPLATE_STOCKLOWHIGHCLOSE,
+ TEMPLATE_STOCKOPENLOWHIGHCLOSE,
+ TEMPLATE_STOCKVOLUMELOWHIGHCLOSE,
+ TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE,
+ TEMPLATE_BUBBLE,
+// TEMPLATE_SURFACE,
+// TEMPLATE_ADDIN,
+ TEMPLATE_NOT_FOUND = 0xffff
+};
+
+typedef std::map< OUString, TemplateId > tTemplateMapType;
+
+const tTemplateMapType & lcl_DefaultChartTypeMap()
+{
+ static const tTemplateMapType aMap{
+ {"com.sun.star.chart2.template.Symbol", TEMPLATE_SYMBOL},
+ {"com.sun.star.chart2.template.StackedSymbol", TEMPLATE_STACKEDSYMBOL},
+ {"com.sun.star.chart2.template.PercentStackedSymbol", TEMPLATE_PERCENTSTACKEDSYMBOL},
+ {"com.sun.star.chart2.template.Line", TEMPLATE_LINE},
+ {"com.sun.star.chart2.template.StackedLine", TEMPLATE_STACKEDLINE},
+ {"com.sun.star.chart2.template.PercentStackedLine", TEMPLATE_PERCENTSTACKEDLINE},
+ {"com.sun.star.chart2.template.LineSymbol", TEMPLATE_LINESYMBOL},
+ {"com.sun.star.chart2.template.StackedLineSymbol", TEMPLATE_STACKEDLINESYMBOL},
+ {"com.sun.star.chart2.template.PercentStackedLineSymbol", TEMPLATE_PERCENTSTACKEDLINESYMBOL},
+ {"com.sun.star.chart2.template.ThreeDLine", TEMPLATE_THREEDLINE},
+ {"com.sun.star.chart2.template.StackedThreeDLine", TEMPLATE_STACKEDTHREEDLINE},
+ {"com.sun.star.chart2.template.PercentStackedThreeDLine", TEMPLATE_PERCENTSTACKEDTHREEDLINE},
+ {"com.sun.star.chart2.template.ThreeDLineDeep", TEMPLATE_THREEDLINEDEEP},
+ {"com.sun.star.chart2.template.Column", TEMPLATE_COLUMN},
+ {"com.sun.star.chart2.template.StackedColumn", TEMPLATE_STACKEDCOLUMN},
+ {"com.sun.star.chart2.template.PercentStackedColumn", TEMPLATE_PERCENTSTACKEDCOLUMN},
+ {"com.sun.star.chart2.template.Bar", TEMPLATE_BAR},
+ {"com.sun.star.chart2.template.StackedBar", TEMPLATE_STACKEDBAR},
+ {"com.sun.star.chart2.template.PercentStackedBar", TEMPLATE_PERCENTSTACKEDBAR},
+ {"com.sun.star.chart2.template.ThreeDColumnDeep", TEMPLATE_THREEDCOLUMNDEEP},
+ {"com.sun.star.chart2.template.ThreeDColumnFlat", TEMPLATE_THREEDCOLUMNFLAT},
+ {"com.sun.star.chart2.template.StackedThreeDColumnFlat", TEMPLATE_STACKEDTHREEDCOLUMNFLAT},
+ {"com.sun.star.chart2.template.PercentStackedThreeDColumnFlat", TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT},
+ {"com.sun.star.chart2.template.ThreeDBarDeep", TEMPLATE_THREEDBARDEEP},
+ {"com.sun.star.chart2.template.ThreeDBarFlat", TEMPLATE_THREEDBARFLAT},
+ {"com.sun.star.chart2.template.StackedThreeDBarFlat", TEMPLATE_STACKEDTHREEDBARFLAT},
+ {"com.sun.star.chart2.template.PercentStackedThreeDBarFlat", TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT},
+ {"com.sun.star.chart2.template.ColumnWithLine", TEMPLATE_COLUMNWITHLINE},
+ {"com.sun.star.chart2.template.StackedColumnWithLine", TEMPLATE_STACKEDCOLUMNWITHLINE},
+ {"com.sun.star.chart2.template.Area", TEMPLATE_AREA},
+ {"com.sun.star.chart2.template.StackedArea", TEMPLATE_STACKEDAREA},
+ {"com.sun.star.chart2.template.PercentStackedArea", TEMPLATE_PERCENTSTACKEDAREA},
+ {"com.sun.star.chart2.template.ThreeDArea", TEMPLATE_THREEDAREA},
+ {"com.sun.star.chart2.template.StackedThreeDArea", TEMPLATE_STACKEDTHREEDAREA},
+ {"com.sun.star.chart2.template.PercentStackedThreeDArea", TEMPLATE_PERCENTSTACKEDTHREEDAREA},
+ {"com.sun.star.chart2.template.Pie", TEMPLATE_PIE},
+ {"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.ThreeDPie", TEMPLATE_THREEDPIE},
+ {"com.sun.star.chart2.template.ThreeDPieAllExploded", TEMPLATE_THREEDPIEALLEXPLODED},
+ {"com.sun.star.chart2.template.ThreeDDonut", TEMPLATE_THREEDDONUT},
+ {"com.sun.star.chart2.template.ThreeDDonutAllExploded", TEMPLATE_THREEDDONUTALLEXPLODED},
+ {"com.sun.star.chart2.template.ScatterLineSymbol", TEMPLATE_SCATTERLINESYMBOL},
+ {"com.sun.star.chart2.template.ScatterLine", TEMPLATE_SCATTERLINE},
+ {"com.sun.star.chart2.template.ScatterSymbol", TEMPLATE_SCATTERSYMBOL},
+ {"com.sun.star.chart2.template.ThreeDScatter", TEMPLATE_THREEDSCATTER},
+ {"com.sun.star.chart2.template.Net", TEMPLATE_NET},
+ {"com.sun.star.chart2.template.NetSymbol", TEMPLATE_NETSYMBOL},
+ {"com.sun.star.chart2.template.NetLine", TEMPLATE_NETLINE},
+ {"com.sun.star.chart2.template.StackedNet", TEMPLATE_STACKEDNET},
+ {"com.sun.star.chart2.template.StackedNetSymbol", TEMPLATE_STACKEDNETSYMBOL},
+ {"com.sun.star.chart2.template.StackedNetLine", TEMPLATE_STACKEDNETLINE},
+ {"com.sun.star.chart2.template.PercentStackedNet", TEMPLATE_PERCENTSTACKEDNET},
+ {"com.sun.star.chart2.template.PercentStackedNetSymbol", TEMPLATE_PERCENTSTACKEDNETSYMBOL},
+ {"com.sun.star.chart2.template.PercentStackedNetLine", TEMPLATE_PERCENTSTACKEDNETLINE},
+ {"com.sun.star.chart2.template.FilledNet", TEMPLATE_FILLEDNET},
+ {"com.sun.star.chart2.template.StackedFilledNet", TEMPLATE_STACKEDFILLEDNET},
+ {"com.sun.star.chart2.template.PercentStackedFilledNet", TEMPLATE_PERCENTSTACKEDFILLEDNET},
+ {"com.sun.star.chart2.template.StockLowHighClose", TEMPLATE_STOCKLOWHIGHCLOSE},
+ {"com.sun.star.chart2.template.StockOpenLowHighClose", TEMPLATE_STOCKOPENLOWHIGHCLOSE},
+ {"com.sun.star.chart2.template.StockVolumeLowHighClose", TEMPLATE_STOCKVOLUMELOWHIGHCLOSE},
+ {"com.sun.star.chart2.template.StockVolumeOpenLowHighClose", TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE},
+ {"com.sun.star.chart2.template.Bubble", TEMPLATE_BUBBLE},
+// {"com.sun.star.chart2.template.Surface", TEMPLATE_SURFACE},
+// {"com.sun.star.chart2.template.Addin", TEMPLATE_ADDIN},
+ };
+ return aMap;
+}
+
+TemplateId lcl_GetTemplateIdForService( const OUString & rServiceName )
+{
+ TemplateId eResult = TEMPLATE_NOT_FOUND;
+ const tTemplateMapType & rMap = lcl_DefaultChartTypeMap();
+ tTemplateMapType::const_iterator aIt( rMap.find( rServiceName ));
+
+ if( aIt != rMap.end())
+ eResult = (*aIt).second;
+
+ return eResult;
+}
+
+} // anonymous namespace
+
+namespace chart
+{
+
+ChartTypeManager::ChartTypeManager(
+ uno::Reference<
+ uno::XComponentContext > const & xContext ) :
+ m_xContext( xContext )
+{}
+
+ChartTypeManager::~ChartTypeManager()
+{}
+
+// ____ XMultiServiceFactory ____
+uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance(
+ const OUString& aServiceSpecifier )
+{
+ uno::Reference< uno::XInterface > xResult;
+ TemplateId nId = lcl_GetTemplateIdForService( aServiceSpecifier );
+
+ if( nId == TEMPLATE_NOT_FOUND )
+ {
+ try
+ {
+ xResult = m_xContext->getServiceManager()->createInstanceWithContext(
+ aServiceSpecifier, m_xContext );
+ }
+// catch( registry::InvalidValueException & ex )
+ catch( const uno::Exception & )
+ {
+ // couldn't create service via factory
+
+ // 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 );
+ }
+ }
+ 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;
+
+ xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, aServiceSpecifier, eMode, 1 ));
+ }
+ 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_SURFACE:
+// case TEMPLATE_ADDIN:
+// break;
+
+ case TEMPLATE_NOT_FOUND:
+ OSL_ASSERT( false );
+ break;
+ }
+ xResult.set( xTemplate, uno::UNO_QUERY );
+ }
+
+ return xResult;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstanceWithArguments(
+ const OUString& ServiceSpecifier,
+ const uno::Sequence< uno::Any >& /* Arguments */ )
+{
+ OSL_FAIL( "createInstanceWithArguments: No arguments supported" );
+ return createInstance( ServiceSpecifier );
+}
+
+uno::Sequence< OUString > SAL_CALL ChartTypeManager::getAvailableServiceNames()
+{
+ std::vector< OUString > aServices;
+ const tTemplateMapType & rMap = lcl_DefaultChartTypeMap();
+ aServices.reserve( rMap.size());
+
+ // get own default templates
+ std::transform( rMap.begin(), rMap.end(), std::back_inserter( aServices ),
+ ::o3tl::select1st< tTemplateMapType::value_type >() );
+
+ // add components that were registered in the context's factory
+ uno::Reference< container::XContentEnumerationAccess > xEnumAcc(
+ m_xContext->getServiceManager(), uno::UNO_QUERY );
+ if( xEnumAcc.is())
+ {
+ uno::Reference< container::XEnumeration > xEnum(
+ xEnumAcc->createContentEnumeration( "com.sun.star.chart2.ChartTypeTemplate" ));
+ if( xEnum.is())
+ {
+ uno::Reference< uno::XInterface > xFactIntf;
+
+ while( xEnum->hasMoreElements())
+ {
+ if( xEnum->nextElement() >>= xFactIntf )
+ {
+ uno::Reference< lang::XServiceName > xServiceName( xFactIntf, uno::UNO_QUERY );
+ if( xServiceName.is())
+ aServices.push_back( xServiceName->getServiceName());
+ }
+ }
+ }
+ }
+
+ return comphelper::containerToSequence( aServices );
+}
+
+// ____ XServiceInfo ____
+OUString SAL_CALL ChartTypeManager::getImplementationName()
+{
+ return "com.sun.star.comp.chart.ChartTypeManager";
+}
+
+sal_Bool SAL_CALL ChartTypeManager::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL ChartTypeManager::getSupportedServiceNames()
+{
+ return {
+ "com.sun.star.chart2.ChartTypeManager",
+ "com.sun.star.lang.MultiServiceFactory" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart_ChartTypeManager_get_implementation(css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::ChartTypeManager(context));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx
new file mode 100644
index 000000000..8aafc1fd1
--- /dev/null
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -0,0 +1,877 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "ChartTypeTemplate.hxx"
+#include "DataInterpreter.hxx"
+#include <CommonConverters.hxx>
+#include <ChartTypeHelper.hxx>
+
+#include <AxisHelper.hxx>
+#include <DiagramHelper.hxx>
+#include <AxisIndexDefines.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 <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+
+namespace
+{
+
+void lcl_applyDefaultStyle(
+ const Reference< XDataSeries > & xSeries,
+ sal_Int32 nIndex,
+ const Reference< XDiagram > & 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(
+ "Color",
+ uno::Any( xColorScheme->getColorByIndex( nIndex )));
+ }
+}
+
+void lcl_ensureCorrectLabelPlacement( const Reference< beans::XPropertySet >& xProp, const uno::Sequence < sal_Int32 >& rAvailablePlacements )
+{
+ sal_Int32 nLabelPlacement=0;
+ if( !(xProp.is() && (xProp->getPropertyValue( "LabelPlacement" ) >>= nLabelPlacement)) )
+ return;
+
+ bool bValid = false;
+ for( sal_Int32 i : rAvailablePlacements )
+ {
+ if( i == nLabelPlacement )
+ {
+ bValid = true;
+ break;
+ }
+ }
+ if( !bValid )
+ {
+ uno::Any aNewValue;
+ //otherwise use the first supported one
+ if( rAvailablePlacements.hasElements() )
+ aNewValue <<=rAvailablePlacements[0];
+ xProp->setPropertyValue( "LabelPlacement", aNewValue );
+ }
+}
+
+void lcl_resetLabelPlacementIfDefault( const Reference< beans::XPropertySet >& xProp, sal_Int32 nDefaultPlacement )
+{
+
+ sal_Int32 nLabelPlacement=0;
+ if( xProp.is() && (xProp->getPropertyValue( "LabelPlacement" ) >>= nLabelPlacement) )
+ {
+ if( nDefaultPlacement == nLabelPlacement )
+ xProp->setPropertyValue( "LabelPlacement", uno::Any() );
+ }
+}
+
+void lcl_ensureCorrectMissingValueTreatment( const Reference< chart2::XDiagram >& xDiagram, const Reference< XChartType >& xChartType )
+{
+ Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY );
+ if( xDiaProp.is() )
+ {
+ uno::Sequence < sal_Int32 > aAvailableMissingValueTreatment(
+ ::chart::ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ) );
+
+ if( aAvailableMissingValueTreatment.hasElements() )
+ xDiaProp->setPropertyValue( "MissingValueTreatment", uno::Any( aAvailableMissingValueTreatment[0] ) );
+ else
+ xDiaProp->setPropertyValue( "MissingValueTreatment", uno::Any() );
+ }
+}
+
+} // anonymous namespace
+
+namespace chart
+{
+
+ChartTypeTemplate::ChartTypeTemplate(
+ Reference< uno::XComponentContext > const & xContext,
+ const OUString & rServiceName ) :
+ m_xContext( xContext ),
+ m_aServiceName( rServiceName )
+{
+}
+
+ChartTypeTemplate::~ChartTypeTemplate()
+{}
+
+// ____ XChartTypeTemplate ____
+uno::Reference< XDiagram > SAL_CALL ChartTypeTemplate::createDiagramByDataSource(
+ const uno::Reference< data::XDataSource >& xDataSource,
+ const uno::Sequence< beans::PropertyValue >& aArguments )
+{
+ Reference< XDiagram > xDia;
+
+ try
+ {
+ // create diagram
+ xDia.set(
+ GetComponentContext()->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.chart2.Diagram",
+ GetComponentContext() ),
+ uno::UNO_QUERY_THROW );
+
+ // modify diagram
+ Reference< chart2::XDataInterpreter > xInterpreter( getDataInterpreter());
+ chart2::InterpretedData aData(
+ xInterpreter->interpretDataSource(
+ xDataSource, aArguments, Sequence< Reference< XDataSeries > >() ));
+
+ const Sequence< Sequence< Reference< XDataSeries > > > aSeries( aData.Series );
+ sal_Int32 nCount = 0;
+ for( auto const & i : aSeries )
+ for( auto const & j : i )
+ lcl_applyDefaultStyle( j, nCount++, xDia );
+
+ Sequence< Reference< XChartType > > aOldChartTypesSeq;
+ FillDiagram( xDia, aData.Series, aData.Categories, aOldChartTypesSeq );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xDia;
+}
+
+sal_Bool SAL_CALL ChartTypeTemplate::supportsCategories()
+{
+ return true;
+}
+
+void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >& 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();
+
+ // chart-type specific interpretation of existing data series
+ Reference< chart2::XDataInterpreter > xInterpreter( getDataInterpreter());
+ chart2::InterpretedData aData;
+ aData.Series = aSeriesSeq;
+ aData.Categories = DiagramHelper::getCategoriesFromDiagram( xDiagram );
+
+ if( xInterpreter->isDataCompatible( aData ) )
+ {
+ aData = xInterpreter->reinterpretDataSeries( aData );
+ }
+ else
+ {
+ Reference< data::XDataSource > xSource( xInterpreter->mergeInterpretedData( aData ));
+ // todo: get a "range-union" from the data provider by calling
+ // OUString aRange = getRangeRepresentationByData( xSource );
+ // xSource.set( getDataByRangeRepresentation( aRange, aParam ));
+ // where aParam == ??
+ Sequence< beans::PropertyValue > aParam;
+ if( aData.Categories.is())
+ {
+ aParam.realloc( 1 );
+ aParam[0] = beans::PropertyValue( "HasCategories", -1, uno::Any( true ),
+ beans::PropertyState_DIRECT_VALUE );
+ }
+ aData = xInterpreter->interpretDataSource( xSource, aParam, aFlatSeriesSeq );
+ }
+ aSeriesSeq = aData.Series;
+
+ sal_Int32 nIndex = 0;
+ for( auto const & i : std::as_const(aSeriesSeq) )
+ for( auto const & j : i )
+ {
+ if( nIndex >= nFormerSeriesCount )
+ lcl_applyDefaultStyle( j, nIndex++, xDiagram );
+ }
+
+ // remove charttype groups from all coordinate systems
+ Sequence< Reference< XChartType > > aOldChartTypesSeq(
+ DiagramHelper::getChartTypesFromDiagram(xDiagram) );
+
+ Reference< XCoordinateSystemContainer > xCoordSysCnt( xDiagram, uno::UNO_QUERY );
+ OSL_ASSERT( xCoordSysCnt.is());
+ if( xCoordSysCnt.is())
+ {
+ 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 > >() );
+ }
+ }
+
+ FillDiagram( xDiagram, aSeriesSeq, aData.Categories, aOldChartTypesSeq );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+void SAL_CALL ChartTypeTemplate::changeDiagramData(
+ const Reference< chart2::XDiagram >& xDiagram,
+ const Reference< chart2::data::XDataSource >& xDataSource,
+ const Sequence< beans::PropertyValue >& aArguments )
+{
+ if( ! (xDiagram.is() &&
+ xDataSource.is()) )
+ return;
+
+ 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 =
+ 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 )
+ {
+ if( nIndex >= nFormerSeriesCount )
+ {
+ lcl_applyDefaultStyle( aSeriesSeq[i][j], nIndex, xDiagram );
+ applyStyle( aSeriesSeq[i][j], i, j, aSeriesSeq[i].getLength() );
+ }
+ }
+
+ // categories
+ DiagramHelper::setCategoriesToDiagram( aData.Categories, xDiagram, true, supportsCategories() );
+
+ Sequence< Reference< XChartType > > aChartTypes(
+ DiagramHelper::getChartTypesFromDiagram( xDiagram ));
+ sal_Int32 nMax = std::min( aChartTypes.getLength(), aSeriesSeq.getLength());
+ for( i=0; i<nMax; ++i )
+ {
+ Reference< XDataSeriesContainer > xDSCnt( aChartTypes[i], uno::UNO_QUERY_THROW );
+ xDSCnt->setDataSeries( aSeriesSeq[i] );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+sal_Bool SAL_CALL ChartTypeTemplate::matchesTemplate(
+ const Reference< chart2::XDiagram >& xDiagram,
+ sal_Bool /* bAdaptProperties */ )
+{
+ bool bResult = false;
+
+ if( ! xDiagram.is())
+ return bResult;
+
+ try
+ {
+ Reference< XCoordinateSystemContainer > xCooSysCnt(
+ xDiagram, uno::UNO_QUERY_THROW );
+ Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
+ xCooSysCnt->getCoordinateSystems());
+
+ // need to have at least one coordinate system
+ bResult = aCooSysSeq.hasElements();
+ if( bResult )
+ {
+ Sequence< Reference< XChartType > > aFormerlyUsedChartTypes;
+ Reference<XChartType> xOldCT = getChartTypeForNewSeries(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 )
+ {
+ // 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 )
+ {
+ if (!aChartTypeSeq[nCTIdx].is())
+ return false;
+
+ // match chart type
+ bResult = bResult && aChartTypeSeq[nCTIdx]->getChartType() == aChartTypeToMatch;
+ bool bFound=false;
+ bool bAmbiguous=false;
+ // match stacking mode
+ bResult = bResult &&
+ ( DiagramHelper::getStackModeFromChartType(
+ aChartTypeSeq[nCTIdx], bFound, bAmbiguous,
+ aCooSysSeq[nCooSysIdx] )
+ == getStackMode( nCTIdx ) );
+ }
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return bResult;
+}
+
+Reference< chart2::XDataInterpreter > SAL_CALL ChartTypeTemplate::getDataInterpreter()
+{
+ if( ! m_xDataInterpreter.is())
+ m_xDataInterpreter.set( new DataInterpreter );
+
+ return m_xDataInterpreter;
+}
+
+void SAL_CALL ChartTypeTemplate::applyStyle(
+ const Reference< chart2::XDataSeries >& xSeries,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 /* nSeriesIndex */,
+ ::sal_Int32 /* nSeriesCount */ )
+{
+ // sset stacking mode
+ Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
+ if( !xSeriesProp.is())
+ return;
+
+ try
+ {
+ StackMode eStackMode = getStackMode( nChartTypeIndex );
+ const uno::Any aPropValue(
+ ( (eStackMode == StackMode::YStacked) ||
+ (eStackMode == StackMode::YStackedPercent) )
+ ? chart2::StackingDirection_Y_STACKING
+ : (eStackMode == StackMode::ZStacked )
+ ? chart2::StackingDirection_Z_STACKING
+ : chart2::StackingDirection_NO_STACKING );
+ xSeriesProp->setPropertyValue( "StackingDirection", aPropValue );
+
+ //ensure valid label placement
+ {
+ uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements(
+ getChartTypeForIndex( nChartTypeIndex ), isSwapXAndY(), xSeries ) );
+ lcl_ensureCorrectLabelPlacement( xSeriesProp, aAvailablePlacements );
+
+ uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
+ if( xSeriesProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
+ for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
+ lcl_ensureCorrectLabelPlacement( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]), aAvailablePlacements );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+void ChartTypeTemplate::applyStyles( const Reference< chart2::XDiagram >& 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 )
+ {
+ const sal_Int32 nNumSeries = aNewSeriesSeq[i].getLength();
+ for( sal_Int32 j=0; j<nNumSeries; ++j )
+ applyStyle( 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 )
+{
+ // 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 )
+ {
+ 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());
+ }
+ }
+ }
+ }
+
+ //reset label placement if default
+ {
+ uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
+ if( xCooSysContainer.is() )
+ {
+ const uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
+ for( uno::Reference< XCoordinateSystem > const & xCooSys : aCooSysList )
+ {
+ //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() )
+ 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];
+
+ 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 );
+ }
+ }
+ }
+ }
+ }
+
+}
+
+// ____ XServiceName ____
+ OUString SAL_CALL ChartTypeTemplate::getServiceName()
+{
+ return m_aServiceName;
+}
+
+sal_Int32 ChartTypeTemplate::getDimension() const
+{
+ return 2;
+}
+
+StackMode ChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) const
+{
+ return StackMode::NONE;
+}
+
+bool ChartTypeTemplate::isSwapXAndY() const
+{
+ return false;
+}
+
+void ChartTypeTemplate::createCoordinateSystems(
+ const Reference< chart2::XCoordinateSystemContainer > & xOutCooSysCnt )
+{
+ if( ! xOutCooSysCnt.is())
+ return;
+ Sequence< Reference< XChartType > > aFormerlyUsedChartTypes;
+ Reference< XChartType > xChartType( getChartTypeForNewSeries(aFormerlyUsedChartTypes));
+ if( ! xChartType.is())
+ return;
+ Reference< XCoordinateSystem > xCooSys( xChartType->createCoordinateSystem( getDimension()));
+ if( ! xCooSys.is())
+ {
+ // chart type wants no coordinate systems
+ xOutCooSysCnt->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 ));
+ if( xAxis.is())
+ AxisHelper::makeGridVisible( xAxis->getGridProperties() );
+ }
+
+ Sequence< Reference< XCoordinateSystem > > aCoordinateSystems(
+ xOutCooSysCnt->getCoordinateSystems());
+
+ if( aCoordinateSystems.hasElements())
+ {
+ bool bOk = true;
+ for( sal_Int32 i=0; bOk && i<aCoordinateSystems.getLength(); ++i )
+ bOk = bOk && ( xCooSys->getCoordinateSystemType() == aCoordinateSystems[i]->getCoordinateSystemType() &&
+ (xCooSys->getDimension() == aCoordinateSystems[i]->getDimension()) );
+ // coordinate systems are ok
+ if( bOk )
+ return;
+ // there are coordinate systems but they do not fit. So overwrite them.
+ }
+
+ //copy as much info from former coordinate system as possible:
+ if( aCoordinateSystems.hasElements() )
+ {
+ Reference< XCoordinateSystem > xOldCooSys( aCoordinateSystems[0] );
+ sal_Int32 nMaxDimensionCount = std::min( xCooSys->getDimension(), xOldCooSys->getDimension() );
+
+ for(sal_Int32 nDimensionIndex=0; nDimensionIndex<nMaxDimensionCount; nDimensionIndex++)
+ {
+ const sal_Int32 nMaximumAxisIndex = xOldCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
+ for(sal_Int32 nAxisIndex=0; nAxisIndex<=nMaximumAxisIndex; ++nAxisIndex)
+ {
+ uno::Reference< XAxis > xAxis( xOldCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) );
+ if( xAxis.is())
+ {
+ xCooSys->setAxisByDimension( nDimensionIndex, xAxis, nAxisIndex );
+ }
+ }
+ }
+ }
+
+ // set new coordinate systems
+ aCoordinateSystems.realloc( 1 );
+ aCoordinateSystems[0] = xCooSys;
+
+ xOutCooSysCnt->setCoordinateSystems( aCoordinateSystems );
+}
+
+void ChartTypeTemplate::adaptScales(
+ const Sequence< Reference< chart2::XCoordinateSystem > > & 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 )
+ {
+ try
+ {
+ if( !xCooSys.is() )
+ continue;
+
+ // attach categories to first axis
+ sal_Int32 nDim( xCooSys->getDimension());
+ if( nDim > 0 )
+ {
+ const sal_Int32 nDimensionX = 0;
+ const sal_Int32 nMaxIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionX);
+ for(sal_Int32 nI=0; nI<=nMaxIndex; ++nI)
+ {
+ Reference< XAxis > xAxis( xCooSys->getAxisByDimension(nDimensionX,nI) );
+ if( xAxis.is())
+ {
+ ScaleData aData( xAxis->getScaleData() );
+ aData.Categories = xCategories;
+ if(bSupportsCategories)
+ {
+ Reference< XChartType > xChartType(getChartTypeForNewSeries(Sequence< Reference< XChartType > >()));
+ if( aData.AxisType == AxisType::CATEGORY )
+ {
+ aData.ShiftedCategoryPosition = m_aServiceName.indexOf("Column") != -1 || m_aServiceName.indexOf("Bar") != -1 || m_aServiceName.endsWith("Close");
+ }
+ bool bSupportsDates = ::chart::ChartTypeHelper::isSupportingDateAxis( xChartType, nDimensionX );
+ if( aData.AxisType != AxisType::CATEGORY && ( aData.AxisType != AxisType::DATE || !bSupportsDates) )
+ {
+ aData.AxisType = AxisType::CATEGORY;
+ aData.AutoDateAxis = true;
+ AxisHelper::removeExplicitScaling( aData );
+ }
+ }
+ else
+ aData.AxisType = AxisType::REALNUMBER;
+
+ xAxis->setScaleData( aData );
+ }
+ }
+ }
+ // set percent stacking mode at second axis
+ if( nDim > 1 )
+ {
+ const sal_Int32 nMaxIndex = xCooSys->getMaximumAxisIndexByDimension(1);
+ for(sal_Int32 nI=0; nI<=nMaxIndex; ++nI)
+ {
+ Reference< chart2::XAxis > xAxis( xCooSys->getAxisByDimension( 1,nI ));
+ if( xAxis.is())
+ {
+ bool bPercent = (getStackMode(0) == StackMode::YStackedPercent);
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+
+ if( bPercent != (aScaleData.AxisType==AxisType::PERCENT) )
+ {
+ if( bPercent )
+ aScaleData.AxisType = AxisType::PERCENT;
+ else
+ aScaleData.AxisType = AxisType::REALNUMBER;
+ xAxis->setScaleData( aScaleData );
+ }
+ }
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+}
+
+void ChartTypeTemplate::adaptDiagram( const Reference< XDiagram > & /* xDiagram */ )
+{
+ }
+
+void ChartTypeTemplate::createAxes(
+ const Sequence< Reference< XCoordinateSystem > > & rCoordSys )
+{
+ //create missing axes
+ if( !rCoordSys.hasElements() )
+ return;
+
+ Reference< XCoordinateSystem > xCooSys( rCoordSys[0] );
+ if(!xCooSys.is())
+ return;
+
+ //create main axis in first coordinate system
+ sal_Int32 nDimCount = xCooSys->getDimension();
+ sal_Int32 nDim=0;
+ for( nDim=0; nDim<nDimCount; ++nDim )
+ {
+ sal_Int32 nAxisCount = getAxisCountByDimension( nDim );
+ if( nDim == 1 &&
+ nAxisCount < 2 && AxisHelper::isSecondaryYAxisNeeded( xCooSys ))
+ nAxisCount = 2;
+ for( sal_Int32 nAxisIndex = 0; nAxisIndex < nAxisCount; ++nAxisIndex )
+ {
+ Reference< XAxis > xAxis = AxisHelper::getAxis( nDim, nAxisIndex, xCooSys );
+ if( !xAxis.is())
+ {
+ // create and add axis
+ xAxis.set( AxisHelper::createAxis(
+ nDim, nAxisIndex, xCooSys, GetComponentContext() ));
+ }
+ }
+ }
+}
+
+void ChartTypeTemplate::adaptAxes(
+ const Sequence< Reference< XCoordinateSystem > > & rCoordSys )
+{
+ //adapt properties of existing axes and remove superfluous axes
+
+ if( !rCoordSys.hasElements() )
+ return;
+
+ for( Reference< XCoordinateSystem > const & xCooSys : rCoordSys )
+ {
+ if( !xCooSys.is() )
+ continue;
+ sal_Int32 nDimCount = xCooSys->getDimension();
+ for( sal_Int32 nDim=0; nDim<nDimCount; ++nDim )
+ {
+ sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension( nDim );
+ for( sal_Int32 nAxisIndex=0; nAxisIndex<=nMaxAxisIndex; nAxisIndex++ )
+ {
+ Reference< XAxis > xAxis( AxisHelper::getAxis( nDim, nAxisIndex, xCooSys ) );
+ if( !xAxis.is() )
+ continue;
+
+ if( nAxisIndex == MAIN_AXIS_INDEX || nAxisIndex == SECONDARY_AXIS_INDEX )
+ {
+ // adapt scales
+ 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());
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+sal_Int32 ChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension )
+{
+ return (nDimension < getDimension()) ? 1 : 0;
+}
+
+void ChartTypeTemplate::FillDiagram(
+ const Reference< XDiagram >& xDiagram,
+ const Sequence< Sequence< Reference< XDataSeries > > >& aSeriesSeq,
+ const Reference< data::XLabeledDataSequence >& xCategories,
+ const Sequence< Reference< XChartType > >& 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());
+ createAxes( aCoordinateSystems );
+ adaptAxes( aCoordinateSystems );
+ adaptScales( aCoordinateSystems, xCategories );
+
+ // chart types
+ createChartTypes( aSeriesSeq, aCoordinateSystems, aOldChartTypesSeq );
+ applyStyles( xDiagram );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+void ChartTypeTemplate::createChartTypes(
+ const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq,
+ const Sequence< Reference< XCoordinateSystem > > & rCoordSys,
+ const Sequence< Reference< XChartType > >& aOldChartTypesSeq )
+{
+ if( ! rCoordSys.hasElements() ||
+ ! rCoordSys[0].is() )
+ return;
+
+ try
+ {
+ sal_Int32 nCooSysIdx=0;
+ Reference< XChartType > xCT;
+ if( !aSeriesSeq.hasElements() )
+ {
+ // 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());
+ aCTSeq.realloc( 1 );
+ aCTSeq[0] = xCT;
+ xCTCnt->setChartTypes( aCTSeq );
+ }
+ else
+ {
+ for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++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())
+ {
+ aCTSeq[0] = xCT;
+ xCTCnt->setChartTypes( aCTSeq );
+ }
+ else
+ xCTCnt->addChartType( xCT );
+
+ Reference< chart2::XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
+ xDSCnt->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::copy( aSeriesSeq[nSeriesIdx].begin(),
+ aSeriesSeq[nSeriesIdx].end(),
+ aNewSeriesSeq.getArray() + nNewStartIndex );
+ xDSCnt->setDataSeries( aNewSeriesSeq );
+ }
+
+ // spread the series over the available coordinate systems
+ if( rCoordSys.getLength() > (nCooSysIdx + 1) )
+ ++nCooSysIdx;
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+void ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(
+ const Sequence< Reference< XChartType > > & rOldChartTypesSeq,
+ const Reference< XChartType > & xNewChartType )
+{
+ Reference< beans::XPropertySet > xDestination( xNewChartType, uno::UNO_QUERY );
+ if( !xDestination.is() )
+ return;
+
+ OUString aNewChartType( xNewChartType->getChartType() );
+
+ Reference< beans::XPropertySet > xSource;
+ for( Reference< XChartType > const & xOldType : rOldChartTypesSeq )
+ {
+ if( xOldType.is() && xOldType->getChartType() == aNewChartType )
+ {
+ xSource.set( Reference< beans::XPropertySet >(xOldType, uno::UNO_QUERY ) );
+ if( xSource.is() )
+ break;
+ }
+ }
+ if( xSource.is() )
+ comphelper::copyProperties( xSource, xDestination );
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ChartTypeTemplate.hxx b/chart2/source/model/template/ChartTypeTemplate.hxx
new file mode 100644
index 000000000..0fe236ce1
--- /dev/null
+++ b/chart2/source/model/template/ChartTypeTemplate.hxx
@@ -0,0 +1,256 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_CHARTTYPETEMPLATE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_CHARTTYPETEMPLATE_HXX
+
+#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
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_CHARTTYPETEMPLATE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ColumnChartType.cxx b/chart2/source/model/template/ColumnChartType.cxx
new file mode 100644
index 000000000..4c95b1c1b
--- /dev/null
+++ b/chart2/source/model/template/ColumnChartType.cxx
@@ -0,0 +1,206 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "ColumnChartType.hxx"
+#include <servicenames_charttypes.hxx>
+#include <PropertyHelper.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <cppuhelper/supportsservice.hxx>
+
+namespace com::sun::star::uno { class XComponentContext; }
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::Property;
+
+namespace
+{
+
+enum
+{
+ PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
+ PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "OverlapSequence",
+ PROP_BARCHARTTYPE_OVERLAP_SEQUENCE,
+ cppu::UnoType<Sequence< sal_Int32 >>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "GapwidthSequence",
+ PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE,
+ cppu::UnoType<Sequence< sal_Int32 >>::get(),
+ beans::PropertyAttribute::BOUND
+ | 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(2);
+
+ aSeq[0] = aSeq[1] = 0;
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq );
+
+ aSeq[0] = aSeq[1] = 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 >
+{
+};
+
+struct StaticColumnChartTypeInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnChartTypeInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+struct StaticColumnChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnChartTypeInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+ColumnChartType::ColumnChartType()
+{}
+
+ColumnChartType::ColumnChartType( const ColumnChartType & rOther ) :
+ ChartType( rOther )
+{
+}
+
+ColumnChartType::~ColumnChartType()
+{}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone()
+{
+ return uno::Reference< util::XCloneable >( new ColumnChartType( *this ));
+}
+
+// ____ XChartType ____
+OUString SAL_CALL ColumnChartType::getChartType()
+{
+ return CHART2_SERVICE_NAME_CHARTTYPE_COLUMN;
+}
+
+uno::Sequence< OUString > ColumnChartType::getSupportedPropertyRoles()
+{
+ uno::Sequence< OUString > aPropRoles(2);
+ aPropRoles[0] = "FillColor";
+ aPropRoles[1] = "BorderColor";
+
+ return aPropRoles;
+}
+
+// ____ 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;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL ColumnChartType::getInfoHelper()
+{
+ return *StaticColumnChartTypeInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnChartType::getPropertySetInfo()
+{
+ return *StaticColumnChartTypeInfo::get();
+}
+
+OUString SAL_CALL ColumnChartType::getImplementationName()
+{
+ return "com.sun.star.comp.chart.ColumnChartType";
+}
+
+sal_Bool SAL_CALL ColumnChartType::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL ColumnChartType::getSupportedServiceNames()
+{
+ return {
+ CHART2_SERVICE_NAME_CHARTTYPE_COLUMN,
+ "com.sun.star.chart2.ChartType" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart_ColumnChartType_get_implementation(css::uno::XComponentContext * /*context*/,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::ColumnChartType());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ColumnChartType.hxx b/chart2/source/model/template/ColumnChartType.hxx
new file mode 100644
index 000000000..d7b879479
--- /dev/null
+++ b/chart2/source/model/template/ColumnChartType.hxx
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_COLUMNCHARTTYPE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_COLUMNCHARTTYPE_HXX
+
+#include "ChartType.hxx"
+
+namespace chart
+{
+
+class ColumnChartType final : public ChartType
+{
+public:
+ explicit ColumnChartType();
+ virtual ~ColumnChartType() 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;
+
+private:
+ explicit ColumnChartType( const ColumnChartType & rOther );
+
+ // ____ XChartType ____
+ virtual OUString SAL_CALL getChartType() override;
+ virtual css::uno::Sequence< OUString > SAL_CALL
+ getSupportedPropertyRoles() 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;
+
+ // ____ XCloneable ____
+ virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_COLUMNCHARTTYPE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
new file mode 100644
index 000000000..560332b81
--- /dev/null
+++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
@@ -0,0 +1,410 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "ColumnLineChartTypeTemplate.hxx"
+#include <CommonConverters.hxx>
+#include <DiagramHelper.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 <algorithm>
+
+using namespace ::com::sun::star::chart2;
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::Property;
+
+namespace
+{
+
+enum
+{
+ PROP_COL_LINE_NUMBER_OF_LINES
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "NumberOfLines",
+ PROP_COL_LINE_NUMBER_OF_LINES,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+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* 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 StaticColumnLineChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticColumnLineChartTypeTemplateInfoHelper_Initializer >
+{
+};
+
+struct StaticColumnLineChartTypeTemplateInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnLineChartTypeTemplateInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+struct StaticColumnLineChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnLineChartTypeTemplateInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+ColumnLineChartTypeTemplate::ColumnLineChartTypeTemplate(
+ Reference<
+ uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ 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 ));
+}
+
+ColumnLineChartTypeTemplate::~ColumnLineChartTypeTemplate()
+{}
+
+// ____ OPropertySet ____
+uno::Any ColumnLineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticColumnLineChartTypeTemplateDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL ColumnLineChartTypeTemplate::getInfoHelper()
+{
+ return *StaticColumnLineChartTypeTemplateInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnLineChartTypeTemplate::getPropertySetInfo()
+{
+ return *StaticColumnLineChartTypeTemplateInfo::get();
+}
+
+void ColumnLineChartTypeTemplate::createChartTypes(
+ const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq,
+ const Sequence< Reference< XCoordinateSystem > > & rCoordSys,
+ const Sequence< Reference< XChartType > >& aOldChartTypesSeq )
+{
+ if( ! rCoordSys.hasElements() ||
+ ! rCoordSys[0].is() )
+ return;
+
+ try
+ {
+ Reference< lang::XMultiServiceFactory > xFact(
+ GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
+ Sequence< Reference< XDataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq ));
+ sal_Int32 nNumberOfSeries = aFlatSeriesSeq.getLength();
+ sal_Int32 nNumberOfLines = 0;
+ sal_Int32 nNumberOfColumns = 0;
+
+ getFastPropertyValue( PROP_COL_LINE_NUMBER_OF_LINES ) >>= nNumberOfLines;
+ OSL_ENSURE( nNumberOfLines>=0, "number of lines should be not negative" );
+ if( nNumberOfLines < 0 )
+ nNumberOfLines = 0;
+
+ if( nNumberOfLines >= nNumberOfSeries )
+ {
+ if( nNumberOfSeries > 0 )
+ {
+ nNumberOfLines = nNumberOfSeries - 1;
+ nNumberOfColumns = 1;
+ }
+ else
+ nNumberOfLines = 0;
+ }
+ else
+ nNumberOfColumns = nNumberOfSeries - nNumberOfLines;
+
+ // Columns
+
+ Reference< XChartType > xCT(
+ xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY_THROW );
+
+ ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aOldChartTypesSeq, xCT );
+
+ Reference< XChartTypeContainer > xCTCnt( rCoordSys[ 0 ], uno::UNO_QUERY_THROW );
+ xCTCnt->setChartTypes( Sequence< Reference< chart2::XChartType > >( &xCT, 1 ));
+
+ if( nNumberOfColumns > 0 )
+ {
+ Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
+ Sequence< Reference< XDataSeries > > aColumnSeq( nNumberOfColumns );
+ std::copy( aFlatSeriesSeq.begin(),
+ aFlatSeriesSeq.begin() + nNumberOfColumns,
+ aColumnSeq.getArray());
+ xDSCnt->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 );
+
+ if( nNumberOfLines > 0 )
+ {
+ Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
+ Sequence< Reference< XDataSeries > > aLineSeq( nNumberOfLines );
+ std::copy( aFlatSeriesSeq.begin() + nNumberOfColumns,
+ aFlatSeriesSeq.end(),
+ aLineSeq.getArray());
+ xDSCnt->setDataSeries( aLineSeq );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+void SAL_CALL ColumnLineChartTypeTemplate::applyStyle(
+ const Reference< chart2::XDataSeries >& xSeries,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount )
+{
+ ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+
+ if( nChartTypeIndex==0 ) // columns
+ {
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+ }
+ 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 );
+ }
+ }
+}
+
+StackMode ColumnLineChartTypeTemplate::getStackMode( sal_Int32 nChartTypeIndex ) const
+{
+ if( nChartTypeIndex == 0 )
+ return m_eStackMode;
+ return StackMode::NONE;
+}
+
+// ____ XChartTypeTemplate ____
+sal_Bool SAL_CALL ColumnLineChartTypeTemplate::matchesTemplate(
+ const uno::Reference< XDiagram >& xDiagram,
+ sal_Bool bAdaptProperties )
+{
+ bool bResult = false;
+
+ if( ! xDiagram.is())
+ return bResult;
+
+ try
+ {
+ Reference< chart2::XChartType > xColumnChartType;
+ Reference< XCoordinateSystem > xColumnChartCooSys;
+ Reference< chart2::XChartType > 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 )
+ {
+ Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW );
+ const Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
+ for( Reference< XChartType > const & chartType : aChartTypeSeq )
+ {
+ if( chartType.is())
+ {
+ ++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 );
+ }
+ }
+ if( nNumberOfChartTypes > 2 )
+ break;
+ }
+
+ if( nNumberOfChartTypes == 2 &&
+ xColumnChartType.is() &&
+ xLineChartType.is())
+ {
+ OSL_ASSERT( xColumnChartCooSys.is());
+
+ // check stackmode of bars
+ bResult = (xColumnChartCooSys->getDimension() == getDimension());
+ if( bResult )
+ {
+ bool bFound=false;
+ bool bAmbiguous=false;
+ bResult = ( DiagramHelper::getStackModeFromChartType(
+ xColumnChartType, bFound, bAmbiguous,
+ xColumnChartCooSys )
+ == getStackMode( 0 ) );
+
+ if( bResult && bAdaptProperties )
+ {
+ Reference< XDataSeriesContainer > xSeriesContainer( xLineChartType, uno::UNO_QUERY );
+ if( xSeriesContainer.is() )
+ {
+ sal_Int32 nNumberOfLines = xSeriesContainer->getDataSeries().getLength();
+ setFastPropertyValue_NoBroadcast( PROP_COL_LINE_NUMBER_OF_LINES, uno::Any( nNumberOfLines ));
+ }
+ }
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return bResult;
+}
+
+Reference< chart2::XChartType > 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;
+}
+
+Reference< XChartType > SAL_CALL ColumnLineChartTypeTemplate::getChartTypeForNewSeries(
+ const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+{
+ Reference< chart2::XChartType > 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 );
+ ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xResult;
+}
+
+Reference< XDataInterpreter > SAL_CALL ColumnLineChartTypeTemplate::getDataInterpreter()
+{
+ if( ! m_xDataInterpreter.is())
+ {
+ sal_Int32 nNumberOfLines = 1;
+ getFastPropertyValue( PROP_COL_LINE_NUMBER_OF_LINES ) >>= nNumberOfLines;
+ m_xDataInterpreter.set( new ColumnLineDataInterpreter( nNumberOfLines ) );
+ }
+ else
+ {
+ //todo...
+ OSL_FAIL( "number of lines may not be valid anymore in the datainterpreter" );
+
+ }
+
+ return m_xDataInterpreter;
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2( ColumnLineChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( ColumnLineChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx
new file mode 100644
index 000000000..9f04b633d
--- /dev/null
+++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_COLUMNLINECHARTTYPETEMPLATE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_COLUMNLINECHARTTYPETEMPLATE_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
+{
+public:
+ explicit ColumnLineChartTypeTemplate(
+ css::uno::Reference< css::uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ StackMode eStackMode,
+ sal_Int32 nNumberOfLines );
+ virtual ~ColumnLineChartTypeTemplate() override;
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ 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;
+
+ // ____ 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,
+ ::sal_Int32 nChartTypeGroupIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount ) override;
+ virtual css::uno::Reference< css::chart2::XDataInterpreter > SAL_CALL getDataInterpreter() 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
+ ) override;
+
+ virtual css::uno::Reference< css::chart2::XChartType >
+ getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
+
+ virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
+
+private:
+ StackMode m_eStackMode;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_COLUMNLINECHARTTYPETEMPLATE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ColumnLineDataInterpreter.cxx b/chart2/source/model/template/ColumnLineDataInterpreter.cxx
new file mode 100644
index 000000000..b99324d27
--- /dev/null
+++ b/chart2/source/model/template/ColumnLineDataInterpreter.cxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "ColumnLineDataInterpreter.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;
+
+namespace chart
+{
+
+// explicit
+ColumnLineDataInterpreter::ColumnLineDataInterpreter(
+ sal_Int32 nNumberOfLines ) :
+ DataInterpreter(),
+ m_nNumberOfLines( nNumberOfLines )
+{}
+
+ColumnLineDataInterpreter::~ColumnLineDataInterpreter()
+{}
+
+// ____ XDataInterpreter ____
+InterpretedData SAL_CALL ColumnLineDataInterpreter::interpretDataSource(
+ const Reference< data::XDataSource >& xSource,
+ const Sequence< beans::PropertyValue >& aArguments,
+ const Sequence< Reference< XDataSeries > >& 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 )
+ {
+ sal_Int32 nNumberOfSeries = aResult.Series[0].getLength();
+
+ // 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);
+
+ Sequence< Reference< XDataSeries > > & rColumnDataSeries = aResult.Series[0];
+ Sequence< Reference< XDataSeries > > & rLineDataSeries = aResult.Series[1];
+ rLineDataSeries.realloc( nNumOfLines );
+ std::copy( rColumnDataSeries.begin() + nNumberOfSeries - nNumOfLines,
+ rColumnDataSeries.begin() + nNumberOfSeries,
+ rLineDataSeries.getArray() );
+ rColumnDataSeries.realloc( nNumberOfSeries - nNumOfLines );
+ }
+ }
+
+ return aResult;
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ColumnLineDataInterpreter.hxx b/chart2/source/model/template/ColumnLineDataInterpreter.hxx
new file mode 100644
index 000000000..e6956db4c
--- /dev/null
+++ b/chart2/source/model/template/ColumnLineDataInterpreter.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_COLUMNLINEDATAINTERPRETER_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_COLUMNLINEDATAINTERPRETER_HXX
+
+#include "DataInterpreter.hxx"
+
+namespace chart
+{
+
+class ColumnLineDataInterpreter : public DataInterpreter
+{
+public:
+ explicit ColumnLineDataInterpreter(
+ sal_Int32 nNumberOfLines );
+ virtual ~ColumnLineDataInterpreter() override;
+
+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;
+
+private:
+ sal_Int32 m_nNumberOfLines;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_COLUMNLINEDATAINTERPRETER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/DataInterpreter.cxx b/chart2/source/model/template/DataInterpreter.cxx
new file mode 100644
index 000000000..7e85e0b36
--- /dev/null
+++ b/chart2/source/model/template/DataInterpreter.cxx
@@ -0,0 +1,441 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "DataInterpreter.hxx"
+#include <DataSeries.hxx>
+#include <DataSourceHelper.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 <vector>
+#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;
+
+#ifdef DEBUG_CHART2_TEMPLATE
+namespace
+{
+void lcl_ShowDataSource( const Reference< data::XDataSource > & xSource );
+}
+#endif
+
+namespace chart
+{
+
+DataInterpreter::DataInterpreter()
+{}
+
+DataInterpreter::~DataInterpreter()
+{}
+
+// ____ XDataInterpreter ____
+InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
+ const Reference< data::XDataSource >& xSource,
+ const Sequence< beans::PropertyValue >& aArguments,
+ const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+{
+ if( ! xSource.is())
+ return InterpretedData();
+
+#ifdef DEBUG_CHART2_TEMPLATE
+ lcl_ShowDataSource( xSource );
+#endif
+
+ const Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
+
+ Reference< data::XLabeledDataSequence > xCategories;
+ vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
+
+ // check if we should use categories
+
+ bool bHasCategories( HasCategories( aArguments, aData ));
+
+ // parse data
+ bool bCategoriesUsed = false;
+ for( Reference< data::XLabeledDataSequence > const & labeledData : aData )
+ {
+ try
+ {
+ if( bHasCategories && ! bCategoriesUsed )
+ {
+ xCategories.set( labeledData );
+ if( xCategories.is())
+ SetRole( xCategories->getValues(), "categories");
+ bCategoriesUsed = true;
+ }
+ else
+ {
+ aSequencesVec.push_back( labeledData );
+ if( labeledData.is())
+ SetRole( labeledData->getValues(), "values-y");
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ // create DataSeries
+ sal_Int32 nSeriesIndex = 0;
+ vector< Reference< XDataSeries > > 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] );
+ else
+ xSeries.set( new DataSeries );
+ OSL_ASSERT( xSeries.is() );
+ Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
+ OSL_ASSERT( xSink.is() );
+ xSink->setData( aNewData );
+
+ aSeriesVec.push_back( xSeries );
+ ++nSeriesIndex;
+ }
+
+ Sequence< Sequence< Reference< XDataSeries > > > aSeries(1);
+ aSeries[0] = comphelper::containerToSequence( aSeriesVec );
+ return InterpretedData( aSeries, xCategories );
+}
+
+InterpretedData SAL_CALL 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();
+ for( ; i<nCount; ++i )
+ {
+ try
+ {
+ Reference< data::XDataSource > xSeriesSource( aSeries[i], uno::UNO_QUERY_THROW );
+ Sequence< Reference< data::XLabeledDataSequence > > aNewSequences;
+
+ // values-y
+ Reference< data::XLabeledDataSequence > xValuesY(
+ DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-y" ));
+ // re-use values-... as values-y
+ if( ! xValuesY.is())
+ {
+ xValuesY.set(
+ DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values", true ));
+ if( xValuesY.is())
+ SetRole( xValuesY->getValues(), "values-y");
+ }
+ if( xValuesY.is())
+ {
+ aNewSequences.realloc(1);
+ aNewSequences[0] = xValuesY;
+ }
+
+ Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
+ if( aSeqs.getLength() != aNewSequences.getLength() )
+ {
+#ifdef DEBUG_CHART2_TEMPLATE
+ sal_Int32 j=0;
+ for( ; j<aSeqs.(); ++j )
+ {
+ assert( aSeqs[j] == xValuesY && "All sequences should be used" );
+ }
+#endif
+ Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
+ xSink->setData( aNewSequences );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return aResult;
+}
+
+// criterion: all series must have exactly one data::XLabeledDataSequence
+sal_Bool SAL_CALL DataInterpreter::isDataCompatible(
+ const chart2::InterpretedData& aInterpretedData )
+{
+ const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ for( Reference< XDataSeries > const & i : aSeries )
+ {
+ try
+ {
+ Reference< data::XDataSource > xSrc( i, uno::UNO_QUERY_THROW );
+ Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
+ if( aSeq.getLength() != 1 )
+ return false;
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return true;
+}
+
+namespace
+{
+
+struct lcl_LabeledSequenceEquals
+{
+ explicit lcl_LabeledSequenceEquals( const Reference< data::XLabeledDataSequence > & xLSeqToCmp ) :
+ m_bHasLabels ( false ),
+ m_bHasValues ( false )
+ {
+ if( !xLSeqToCmp.is())
+ return;
+
+ Reference< data::XDataSequence > xSeq( xLSeqToCmp->getValues());
+ if( xSeq.is())
+ {
+ m_bHasValues = true;
+ m_aValuesRangeRep = xSeq->getSourceRangeRepresentation();
+ }
+
+ xSeq.set( xLSeqToCmp->getLabel());
+ if( xSeq.is())
+ {
+ m_bHasLabels = true;
+ m_aLabelRangeRep = xSeq->getSourceRangeRepresentation();
+ }
+ }
+
+ bool operator() ( const Reference< data::XLabeledDataSequence > & xSeq )
+ {
+ if( ! xSeq.is())
+ return false;
+
+ Reference< data::XDataSequence > xSeqValues( xSeq->getValues() );
+ Reference< data::XDataSequence > xSeqLabels( xSeq->getLabel() );
+ bool bHasValues = xSeqValues.is();
+ bool bHasLabels = xSeqLabels.is();
+
+ return ( ( (m_bHasValues == bHasValues) &&
+ (!bHasValues || m_aValuesRangeRep == xSeqValues->getSourceRangeRepresentation()) ) &&
+ ( (m_bHasLabels == bHasLabels) &&
+ (!bHasLabels || m_aLabelRangeRep == xSeqLabels->getSourceRangeRepresentation()) )
+ );
+ }
+
+private:
+ bool m_bHasLabels;
+ bool m_bHasValues;
+ OUString m_aValuesRangeRep;
+ OUString m_aLabelRangeRep;
+};
+
+} // anonymous namespace
+
+Reference< data::XDataSource > SAL_CALL DataInterpreter::mergeInterpretedData(
+ const InterpretedData& aInterpretedData )
+{
+ vector< Reference< data::XLabeledDataSequence > > aResultVec;
+ aResultVec.reserve( aInterpretedData.Series.getLength() +
+ 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 )
+ {
+ 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 )
+ {
+ // only add if sequence is not yet in the result
+ if( none_of( aResultVec.begin(), aResultVec.end(),
+ lcl_LabeledSequenceEquals( xAdd )) )
+ {
+ aResultVec.push_back( xAdd );
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return DataSourceHelper::createDataSource( comphelper::containerToSequence( aResultVec ) );
+}
+
+// convenience methods
+
+OUString DataInterpreter::GetRole( const Reference< data::XDataSequence > & xSeq )
+{
+ OUString aResult;
+ if( ! xSeq.is())
+ return aResult;
+
+ try
+ {
+ Reference< beans::XPropertySet > xProp( xSeq, uno::UNO_QUERY_THROW );
+ xProp->getPropertyValue( "Role") >>= aResult;
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return aResult;
+}
+
+void DataInterpreter::SetRole( const Reference< data::XDataSequence > & xSeq, const OUString & rRole )
+{
+ if( ! xSeq.is())
+ return;
+ try
+ {
+ Reference< beans::XPropertySet > xProp( xSeq, uno::UNO_QUERY_THROW );
+ xProp->setPropertyValue( "Role", uno::Any( rRole ));
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+uno::Any DataInterpreter::GetProperty(
+ const Sequence< beans::PropertyValue > & aArguments,
+ const OUString & rName )
+{
+ for( sal_Int32 i=aArguments.getLength(); i--; )
+ {
+ if( aArguments[i].Name == rName )
+ return aArguments[i].Value;
+ }
+ return uno::Any();
+}
+
+bool DataInterpreter::HasCategories(
+ const Sequence< beans::PropertyValue > & rArguments,
+ const Sequence< Reference< data::XLabeledDataSequence > > & rData )
+{
+ bool bHasCategories = false;
+
+ if( rArguments.hasElements() )
+ GetProperty( rArguments, "HasCategories" ) >>= bHasCategories;
+
+ for( sal_Int32 nLSeqIdx=0; ! bHasCategories && nLSeqIdx<rData.getLength(); ++nLSeqIdx )
+ bHasCategories = ( rData[nLSeqIdx].is() && GetRole( rData[nLSeqIdx]->getValues() ) == "categories");
+
+ return bHasCategories;
+}
+
+bool DataInterpreter::UseCategoriesAsX( const Sequence< beans::PropertyValue > & rArguments )
+{
+ bool bUseCategoriesAsX = true;
+ if( rArguments.hasElements() )
+ GetProperty( rArguments, "UseCategoriesAsX" ) >>= bUseCategoriesAsX;
+ return bUseCategoriesAsX;
+}
+
+OUString SAL_CALL DataInterpreter::getImplementationName()
+{
+ return "com.sun.star.comp.chart2.DataInterpreter";
+}
+
+sal_Bool SAL_CALL DataInterpreter::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL DataInterpreter::getSupportedServiceNames()
+{
+ return { "com.sun.star.chart2.DataInterpreter" };
+}
+
+} // namespace chart
+
+#ifdef DEBUG_CHART2_TEMPLATE
+namespace
+{
+
+void lcl_ShowDataSource( const Reference< data::XDataSource > & xSource )
+{
+ if( ! xSource.is())
+ return;
+
+ SAL_INFO("chart2", "DataSource in DataInterpreter:" );
+ Sequence< Reference< data::XLabeledDataSequence > > aSequences( xSource->getDataSequences());
+ Reference< beans::XPropertySet > xProp;
+ OUString aId;
+ const sal_Int32 nMax = aSequences.getLength();
+ for( sal_Int32 k = 0; k < nMax; ++k )
+ {
+ if( aSequences[k].is())
+ {
+ OUString aSourceRepr("<none>");
+ if( aSequences[k]->getValues().is())
+ aSourceRepr = aSequences[k]->getValues()->getSourceRangeRepresentation();
+ xProp.set( aSequences[k]->getValues(), uno::UNO_QUERY );
+ if( xProp.is() &&
+ ( xProp->getPropertyValue( "Role") >>= aId ))
+ {
+ SAL_INFO("chart2", " <data sequence " << k << "> Role: " << aId << ", Source: "<< aSourceRepr);
+ }
+ else
+ {
+ SAL_INFO("chart2", " <data sequence " << k << "> unknown Role, Source: " << aSourceRepr );
+ }
+
+ aSourceRepr = "<none>";
+ if( aSequences[k]->getLabel().is())
+ aSourceRepr = aSequences[k]->getLabel()->getSourceRangeRepresentation();
+ xProp.set( aSequences[k]->getLabel(), uno::UNO_QUERY );
+ if( xProp.is() &&
+ ( xProp->getPropertyValue( "Role") >>= aId ))
+ {
+ SAL_INFO("chart2", " <data sequence label " << k << "> Role: " << aId
+ << ", Source: " << aSourceRepr );
+ }
+ else
+ {
+ SAL_INFO("chart2", " <data sequence label " << k << "> unknown Role, Source: " << aSourceRepr );
+ }
+ }
+ }
+}
+
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/DataInterpreter.hxx b/chart2/source/model/template/DataInterpreter.hxx
new file mode 100644
index 000000000..72d3d61e4
--- /dev/null
+++ b/chart2/source/model/template/DataInterpreter.hxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_DATAINTERPRETER_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_DATAINTERPRETER_HXX
+
+#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,
+ const OUString & 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;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_DATAINTERPRETER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/FilledNetChartType.cxx b/chart2/source/model/template/FilledNetChartType.cxx
new file mode 100644
index 000000000..3179317da
--- /dev/null
+++ b/chart2/source/model/template/FilledNetChartType.cxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "FilledNetChartType.hxx"
+#include <servicenames_charttypes.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+namespace com::sun::star::uno { class XComponentContext; }
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+
+using ::com::sun::star::uno::Sequence;
+
+namespace chart
+{
+
+FilledNetChartType::FilledNetChartType()
+{}
+
+FilledNetChartType::FilledNetChartType( const FilledNetChartType & rOther ) :
+ NetChartType_Base( rOther )
+{
+}
+
+FilledNetChartType::~FilledNetChartType()
+{}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL FilledNetChartType::createClone()
+{
+ return uno::Reference< util::XCloneable >( new FilledNetChartType( *this ));
+}
+
+// ____ XChartType ____
+OUString SAL_CALL FilledNetChartType::getChartType()
+{
+ return CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET;
+}
+
+OUString SAL_CALL FilledNetChartType::getImplementationName()
+{
+ return "com.sun.star.comp.chart.FilledNetChartType";
+}
+
+sal_Bool SAL_CALL FilledNetChartType::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL FilledNetChartType::getSupportedServiceNames()
+{
+ return {
+ CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET,
+ "com.sun.star.chart2.ChartType",
+ "com.sun.star.beans.PropertySet" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart_FilledNetChartType_get_implementation(css::uno::XComponentContext * /*context*/,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::FilledNetChartType);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/FilledNetChartType.hxx b/chart2/source/model/template/FilledNetChartType.hxx
new file mode 100644
index 000000000..baa2b9efb
--- /dev/null
+++ b/chart2/source/model/template/FilledNetChartType.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_FILLEDNETCHARTTYPE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_FILLEDNETCHARTTYPE_HXX
+
+#include "NetChartType.hxx"
+
+namespace chart
+{
+
+class FilledNetChartType final : public NetChartType_Base
+{
+public:
+ explicit FilledNetChartType();
+ virtual ~FilledNetChartType() 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;
+
+private:
+ explicit FilledNetChartType( const FilledNetChartType & rOther );
+
+ // ____ XChartType ____
+ virtual OUString SAL_CALL getChartType() override;
+
+ // ____ XCloneable ____
+ virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_FILLEDNETCHARTTYPE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/LineChartType.cxx b/chart2/source/model/template/LineChartType.cxx
new file mode 100644
index 000000000..64b2fe9c1
--- /dev/null
+++ b/chart2/source/model/template/LineChartType.cxx
@@ -0,0 +1,208 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "LineChartType.hxx"
+#include <PropertyHelper.hxx>
+#include <servicenames_charttypes.hxx>
+#include <unonames.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/chart2/CurveStyle.hpp>
+
+namespace com::sun::star::uno { class XComponentContext; }
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Sequence;
+
+namespace
+{
+
+enum
+{
+ PROP_LINECHARTTYPE_CURVE_STYLE,
+ PROP_LINECHARTTYPE_CURVE_RESOLUTION,
+ PROP_LINECHARTTYPE_SPLINE_ORDER
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( 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,
+ PROP_LINECHARTTYPE_CURVE_RESOLUTION,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( 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() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+
+};
+
+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;
+ }
+};
+
+struct StaticLineChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLineChartTypeInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+LineChartType::LineChartType()
+{
+}
+
+LineChartType::LineChartType( const LineChartType & rOther ) :
+ ChartType( rOther )
+{
+}
+
+LineChartType::~LineChartType()
+{}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL LineChartType::createClone()
+{
+ return uno::Reference< util::XCloneable >( new LineChartType( *this ));
+}
+
+// ____ XChartType ____
+OUString SAL_CALL LineChartType::getChartType()
+{
+ return CHART2_SERVICE_NAME_CHARTTYPE_LINE;
+}
+
+// ____ OPropertySet ____
+uno::Any LineChartType::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticLineChartTypeDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL LineChartType::getInfoHelper()
+{
+ return *StaticLineChartTypeInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL LineChartType::getPropertySetInfo()
+{
+ return *StaticLineChartTypeInfo::get();
+}
+
+OUString SAL_CALL LineChartType::getImplementationName()
+{
+ return "com.sun.star.comp.chart.LineChartType";
+}
+
+sal_Bool SAL_CALL LineChartType::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL LineChartType::getSupportedServiceNames()
+{
+ return {
+ CHART2_SERVICE_NAME_CHARTTYPE_LINE,
+ "com.sun.star.chart2.ChartType",
+ "com.sun.star.beans.PropertySet" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart_LineChartType_get_implementation(css::uno::XComponentContext * /*context*/,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::LineChartType);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/LineChartType.hxx b/chart2/source/model/template/LineChartType.hxx
new file mode 100644
index 000000000..27ebc7ffb
--- /dev/null
+++ b/chart2/source/model/template/LineChartType.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_LINECHARTTYPE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_LINECHARTTYPE_HXX
+
+#include "ChartType.hxx"
+
+namespace chart
+{
+
+class LineChartType final : public ChartType
+{
+public:
+ explicit LineChartType();
+ virtual ~LineChartType() 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;
+
+private:
+ explicit LineChartType( const LineChartType & rOther );
+
+ // ____ XChartType ____
+ virtual OUString SAL_CALL getChartType() 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;
+
+ // ____ XCloneable ____
+ virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_LINECHARTTYPE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/LineChartTypeTemplate.cxx b/chart2/source/model/template/LineChartTypeTemplate.cxx
new file mode 100644
index 000000000..7989a7435
--- /dev/null
+++ b/chart2/source/model/template/LineChartTypeTemplate.cxx
@@ -0,0 +1,374 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "LineChartTypeTemplate.hxx"
+#include <DiagramHelper.hxx>
+#include <servicenames_charttypes.hxx>
+#include <DataSeriesHelper.hxx>
+#include <PropertyHelper.hxx>
+#include <unonames.hxx>
+
+#include <com/sun/star/chart2/CurveStyle.hpp>
+#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/beans/PropertyAttribute.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <tools/diagnose_ex.h>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::Property;
+
+namespace
+{
+
+enum
+{
+ PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE,
+ PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION,
+ PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER
+
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( 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,
+ PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( 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 );
+
+ 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;
+ }
+};
+
+struct StaticLineChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLineChartTypeTemplateInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+LineChartTypeTemplate::LineChartTypeTemplate(
+ uno::Reference<
+ uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ StackMode eStackMode,
+ bool bSymbols,
+ bool bHasLines /* = true */,
+ sal_Int32 nDim /* = 2 */ ) :
+ ChartTypeTemplate( xContext, rServiceName ),
+ ::property::OPropertySet( m_aMutex ),
+ m_eStackMode( eStackMode ),
+ m_bHasSymbols( bSymbols ),
+ m_bHasLines( bHasLines ),
+ m_nDim( nDim )
+{
+ if( nDim == 3 )
+ m_bHasSymbols = false;
+}
+
+LineChartTypeTemplate::~LineChartTypeTemplate()
+{}
+// ____ OPropertySet ____
+uno::Any LineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticLineChartTypeTemplateDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL LineChartTypeTemplate::getInfoHelper()
+{
+ return *StaticLineChartTypeTemplateInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL LineChartTypeTemplate::getPropertySetInfo()
+{
+ return *StaticLineChartTypeTemplateInfo::get();
+}
+
+sal_Int32 LineChartTypeTemplate::getDimension() const
+{
+ return m_nDim;
+}
+
+StackMode LineChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) const
+{
+ return m_eStackMode;
+}
+
+// ____ XChartTypeTemplate ____
+sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
+ const uno::Reference< chart2::XDiagram >& xDiagram,
+ sal_Bool bAdaptProperties )
+{
+ bool bResult = ChartTypeTemplate::matchesTemplate( 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
+ // with symbols (or with lines)
+ if( bResult )
+ {
+ bool bSymbolFound = false;
+ bool bLineFound = false;
+
+ std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+
+ for (auto const& series : aSeriesVec)
+ {
+ try
+ {
+ chart2::Symbol aSymbProp;
+ drawing::LineStyle eLineStyle;
+ Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY_THROW);
+
+ bool bCurrentHasSymbol = (xProp->getPropertyValue( "Symbol") >>= aSymbProp) &&
+ (aSymbProp.Style != chart2::SymbolStyle_NONE);
+
+ if( bCurrentHasSymbol )
+ bSymbolFound = true;
+
+ if( bCurrentHasSymbol && (!m_bHasSymbols) )
+ {
+ bResult = false;
+ break;
+ }
+
+ bool bCurrentHasLine = (xProp->getPropertyValue( "LineStyle") >>= eLineStyle) &&
+ ( eLineStyle != drawing::LineStyle_NONE );
+
+ if( bCurrentHasLine )
+ bLineFound = true;
+
+ if( bCurrentHasLine && (!m_bHasLines) )
+ {
+ bResult = false;
+ break;
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ if(bResult)
+ {
+ if( !bLineFound && m_bHasLines && bSymbolFound )
+ bResult = false;
+ else if( !bSymbolFound && m_bHasSymbols && bLineFound )
+ bResult = false;
+ else if( !bLineFound && !bSymbolFound )
+ return m_bHasLines && m_bHasSymbols;
+ }
+ }
+
+ // adapt curve style, spline order and resolution
+ if( bResult && bAdaptProperties )
+ {
+ 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) );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return bResult;
+}
+
+Reference< chart2::XChartType > LineChartTypeTemplate::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_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 ));
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xResult;
+}
+
+Reference< chart2::XChartType > SAL_CALL LineChartTypeTemplate::getChartTypeForNewSeries(
+ const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+{
+ Reference< chart2::XChartType > 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 );
+
+ 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 ));
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xResult;
+}
+
+void SAL_CALL LineChartTypeTemplate::applyStyle(
+ const Reference< chart2::XDataSeries >& xSeries,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount )
+{
+ ChartTypeTemplate::applyStyle( 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 );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2( LineChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( LineChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/LineChartTypeTemplate.hxx b/chart2/source/model/template/LineChartTypeTemplate.hxx
new file mode 100644
index 000000000..2663fb113
--- /dev/null
+++ b/chart2/source/model/template/LineChartTypeTemplate.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_LINECHARTTYPETEMPLATE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_LINECHARTTYPETEMPLATE_HXX
+
+#include "ChartTypeTemplate.hxx"
+#include <OPropertySet.hxx>
+#include <MutexContainer.hxx>
+#include <StackMode.hxx>
+#include <comphelper/uno3.hxx>
+
+namespace chart
+{
+
+class LineChartTypeTemplate :
+ public MutexContainer,
+ public ChartTypeTemplate,
+ public ::property::OPropertySet
+{
+public:
+ explicit LineChartTypeTemplate(
+ css::uno::Reference< css::uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ StackMode eStackMode,
+ bool bSymbols,
+ bool bHasLines = true,
+ sal_Int32 nDim = 2 );
+ virtual ~LineChartTypeTemplate() override;
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ 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;
+
+ // ____ 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,
+ ::sal_Int32 nChartTypeGroupIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount ) override;
+
+ // ____ ChartTypeTemplate ____
+ virtual css::uno::Reference< css::chart2::XChartType >
+ getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
+ virtual sal_Int32 getDimension() const override;
+ virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
+
+private:
+ StackMode m_eStackMode;
+ bool m_bHasSymbols;
+ bool m_bHasLines;
+ sal_Int32 m_nDim;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_LINECHARTTYPETEMPLATE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/NetChartType.cxx b/chart2/source/model/template/NetChartType.cxx
new file mode 100644
index 000000000..95de304b6
--- /dev/null
+++ b/chart2/source/model/template/NetChartType.cxx
@@ -0,0 +1,183 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "NetChartType.hxx"
+#include <PolarCoordinateSystem.hxx>
+#include <servicenames_charttypes.hxx>
+#include <AxisIndexDefines.hxx>
+#include <AxisHelper.hxx>
+
+#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/chart2/AxisType.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+
+namespace chart
+{
+
+NetChartType_Base::NetChartType_Base()
+{}
+
+NetChartType_Base::NetChartType_Base( const NetChartType_Base & rOther ) :
+ ChartType( rOther )
+{
+}
+
+NetChartType_Base::~NetChartType_Base()
+{}
+
+Reference< XCoordinateSystem > SAL_CALL
+ NetChartType_Base::createCoordinateSystem( ::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 ));
+
+ Reference< XAxis > xAxis( xResult->getAxisByDimension( 0, MAIN_AXIS_INDEX ) );
+ if( xAxis.is() )
+ {
+ ScaleData aScaleData = xAxis->getScaleData();
+ aScaleData.Scaling = AxisHelper::createLinearScaling();
+ aScaleData.AxisType = AxisType::CATEGORY;
+ aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
+ xAxis->setScaleData( aScaleData );
+ }
+
+ xAxis = xResult->getAxisByDimension( 1, MAIN_AXIS_INDEX );
+ if( xAxis.is() )
+ {
+ ScaleData aScaleData = xAxis->getScaleData();
+ aScaleData.Orientation = AxisOrientation_MATHEMATICAL;
+ aScaleData.AxisType = AxisType::REALNUMBER;
+ xAxis->setScaleData( aScaleData );
+ }
+
+ return xResult;
+}
+
+// ____ OPropertySet ____
+uno::Any NetChartType_Base::GetDefaultValue( sal_Int32 /*nHandle*/ ) const
+{
+ return uno::Any();
+}
+
+namespace
+{
+
+struct StaticNetChartTypeInfoHelper_Initializer
+{
+ ::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;
+ }
+};
+
+struct StaticNetChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticNetChartTypeInfo_Initializer >
+{
+};
+
+}
+
+// ____ OPropertySet ____
+::cppu::IPropertyArrayHelper & SAL_CALL NetChartType_Base::getInfoHelper()
+{
+ return *StaticNetChartTypeInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL NetChartType_Base::getPropertySetInfo()
+{
+ return *StaticNetChartTypeInfo::get();
+}
+
+NetChartType::NetChartType()
+{}
+
+NetChartType::NetChartType( const NetChartType & rOther ) :
+ NetChartType_Base( rOther )
+{
+}
+
+NetChartType::~NetChartType()
+{}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL NetChartType::createClone()
+{
+ return uno::Reference< util::XCloneable >( new NetChartType( *this ));
+}
+
+// ____ XChartType ____
+OUString SAL_CALL NetChartType::getChartType()
+{
+ return CHART2_SERVICE_NAME_CHARTTYPE_NET;
+}
+
+OUString SAL_CALL NetChartType::getImplementationName()
+{
+ return "com.sun.star.comp.chart.NetChartType";
+}
+
+sal_Bool SAL_CALL NetChartType::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL NetChartType::getSupportedServiceNames()
+{
+ return {
+ CHART2_SERVICE_NAME_CHARTTYPE_NET,
+ "com.sun.star.chart2.ChartType",
+ "com.sun.star.beans.PropertySet" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart_NetChartType_get_implementation(css::uno::XComponentContext * /*context*/,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::NetChartType);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/NetChartType.hxx b/chart2/source/model/template/NetChartType.hxx
new file mode 100644
index 000000000..3d3efed8c
--- /dev/null
+++ b/chart2/source/model/template/NetChartType.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_NETCHARTTYPE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_NETCHARTTYPE_HXX
+
+#include "ChartType.hxx"
+
+namespace chart
+{
+
+class NetChartType_Base : public ChartType
+{
+public:
+ explicit NetChartType_Base();
+ virtual ~NetChartType_Base() override;
+
+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 ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
+
+ // ____ XPropertySet ____
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo() override;
+};
+
+class NetChartType final : public NetChartType_Base
+{
+public:
+ explicit NetChartType();
+ virtual ~NetChartType() 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;
+
+private:
+ explicit NetChartType( const NetChartType & rOther );
+
+ // ____ XChartType ____
+ virtual OUString SAL_CALL getChartType() override;
+
+ // ____ XCloneable ____
+ virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_NETCHARTTYPE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/NetChartTypeTemplate.cxx b/chart2/source/model/template/NetChartTypeTemplate.cxx
new file mode 100644
index 000000000..fed499cb3
--- /dev/null
+++ b/chart2/source/model/template/NetChartTypeTemplate.cxx
@@ -0,0 +1,194 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "NetChartTypeTemplate.hxx"
+#include <DiagramHelper.hxx>
+#include <servicenames_charttypes.hxx>
+#include <DataSeriesHelper.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#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>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+
+namespace chart
+{
+
+NetChartTypeTemplate::NetChartTypeTemplate(
+ Reference< uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ StackMode eStackMode,
+ bool bSymbols,
+ bool bHasLines ,
+ bool bHasFilledArea ) :
+ ChartTypeTemplate( xContext, rServiceName ),
+ m_eStackMode( eStackMode ),
+ m_bHasSymbols( bSymbols ),
+ m_bHasLines( bHasLines ),
+ m_bHasFilledArea( bHasFilledArea )
+{}
+
+NetChartTypeTemplate::~NetChartTypeTemplate()
+{}
+
+StackMode NetChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) const
+{
+ return m_eStackMode;
+}
+
+void SAL_CALL NetChartTypeTemplate::applyStyle(
+ const Reference< chart2::XDataSeries >& xSeries,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount )
+{
+ ChartTypeTemplate::applyStyle( 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 );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+// ____ XChartTypeTemplate ____
+sal_Bool SAL_CALL NetChartTypeTemplate::matchesTemplate(
+ const Reference< chart2::XDiagram >& xDiagram,
+ sal_Bool bAdaptProperties )
+{
+ bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
+
+ uno::Reference< beans::XPropertySet > xChartTypeProp(
+ DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), uno::UNO_QUERY_THROW );
+
+ if( bResult )
+ {
+ //filled net chart?:
+ if( m_bHasFilledArea )
+ return true;
+
+ // check symbol-style
+ // for a template with symbols it is ok, if there is at least one series
+ // with symbols, otherwise an unknown template is too easy to achieve
+ bool bSymbolFound = false;
+ bool bLineFound = false;
+
+ std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+
+ for (auto const& series : aSeriesVec)
+ {
+ try
+ {
+ chart2::Symbol aSymbProp;
+ drawing::LineStyle eLineStyle;
+ Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY_THROW);
+
+ bool bCurrentHasSymbol = (xProp->getPropertyValue( "Symbol") >>= aSymbProp) &&
+ (aSymbProp.Style != chart2::SymbolStyle_NONE);
+
+ if( bCurrentHasSymbol )
+ bSymbolFound = true;
+
+ if( bCurrentHasSymbol && (!m_bHasSymbols) )
+ {
+ bResult = false;
+ break;
+ }
+
+ bool bCurrentHasLine = (xProp->getPropertyValue( "LineStyle") >>= eLineStyle) &&
+ ( eLineStyle != drawing::LineStyle_NONE );
+
+ if( bCurrentHasLine )
+ bLineFound = true;
+
+ if( bCurrentHasLine && (!m_bHasLines) )
+ {
+ bResult = false;
+ break;
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ if(bResult)
+ {
+ if( !bLineFound && m_bHasLines && bSymbolFound )
+ bResult = false;
+ else if( !bSymbolFound && m_bHasSymbols && bLineFound )
+ bResult = false;
+ else if( !bLineFound && !bSymbolFound )
+ return m_bHasLines && m_bHasSymbols;
+ }
+ }
+
+ return bResult;
+}
+
+Reference< chart2::XChartType > 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;
+}
+
+Reference< chart2::XChartType > SAL_CALL NetChartTypeTemplate::getChartTypeForNewSeries(
+ const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+{
+ Reference< chart2::XChartType > xResult( getChartTypeForIndex( 0 ) );
+ ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
+ return xResult;
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/NetChartTypeTemplate.hxx b/chart2/source/model/template/NetChartTypeTemplate.hxx
new file mode 100644
index 000000000..369989e6f
--- /dev/null
+++ b/chart2/source/model/template/NetChartTypeTemplate.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_NETCHARTTYPETEMPLATE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_NETCHARTTYPETEMPLATE_HXX
+
+#include "ChartTypeTemplate.hxx"
+#include <StackMode.hxx>
+
+namespace chart
+{
+
+class NetChartTypeTemplate : public ChartTypeTemplate
+{
+public:
+ explicit NetChartTypeTemplate(
+ css::uno::Reference< css::uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ StackMode eStackMode,
+ bool bSymbols,
+ bool bHasLines = true,
+ bool bHasFilledArea = false
+ );
+ 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,
+ ::sal_Int32 nChartTypeGroupIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount ) override;
+
+ // ____ ChartTypeTemplate ____
+ virtual css::uno::Reference< css::chart2::XChartType >
+ getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
+ virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
+
+private:
+ StackMode m_eStackMode;
+ bool m_bHasSymbols;
+ bool m_bHasLines;
+ bool m_bHasFilledArea;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_NETCHARTTYPETEMPLATE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/PieChartType.cxx b/chart2/source/model/template/PieChartType.cxx
new file mode 100644
index 000000000..c18c8d11d
--- /dev/null
+++ b/chart2/source/model/template/PieChartType.cxx
@@ -0,0 +1,241 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "PieChartType.hxx"
+#include <PropertyHelper.hxx>
+#include <PolarCoordinateSystem.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>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+
+namespace
+{
+
+enum
+{
+ PROP_PIECHARTTYPE_USE_RINGS,
+ PROP_PIECHARTTYPE_3DRELATIVEHEIGHT
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "UseRings",
+ PROP_PIECHARTTYPE_USE_RINGS,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "3DRelativeHeight",
+ PROP_PIECHARTTYPE_3DRELATIVEHEIGHT,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
+}
+
+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
+{
+ ::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 >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+PieChartType::PieChartType()
+{
+}
+
+PieChartType::PieChartType( const PieChartType & rOther ) :
+ ChartType( rOther )
+{
+}
+
+PieChartType::~PieChartType()
+{}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL PieChartType::createClone()
+{
+ return uno::Reference< util::XCloneable >( 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 )
+{
+ Reference< chart2::XCoordinateSystem > xResult(
+ new PolarCoordinateSystem( DimensionCount ));
+
+ for( sal_Int32 i=0; i<DimensionCount; ++i )
+ {
+ Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
+ if( !xAxis.is() )
+ {
+ OSL_FAIL("a created coordinate system should have an axis for each dimension");
+ continue;
+ }
+
+ //hhhh todo make axis invisible
+
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ aScaleData.Scaling = AxisHelper::createLinearScaling();
+ aScaleData.AxisType = chart2::AxisType::REALNUMBER;
+
+ if( i == 0 )
+ aScaleData.Orientation = chart2::AxisOrientation_REVERSE;
+ else
+ aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
+
+ //remove explicit scalings from all axes
+ AxisHelper::removeExplicitScaling( aScaleData );
+
+ xAxis->setScaleData( aScaleData );
+ }
+
+ return xResult;
+}
+
+uno::Sequence< OUString > PieChartType::getSupportedPropertyRoles()
+{
+ uno::Sequence< OUString > aPropRoles(2);
+ aPropRoles[0] = "FillColor";
+ aPropRoles[1] = "BorderColor";
+
+ return aPropRoles;
+}
+
+// ____ OPropertySet ____
+uno::Any PieChartType::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticPieChartTypeDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+// ____ OPropertySet ____
+::cppu::IPropertyArrayHelper & SAL_CALL PieChartType::getInfoHelper()
+{
+ return *StaticPieChartTypeInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL PieChartType::getPropertySetInfo()
+{
+ return *StaticPieChartTypeInfo::get();
+}
+
+OUString SAL_CALL PieChartType::getImplementationName()
+{
+ return "com.sun.star.comp.chart.PieChartType";
+}
+
+sal_Bool SAL_CALL PieChartType::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL PieChartType::getSupportedServiceNames()
+{
+ return {
+ CHART2_SERVICE_NAME_CHARTTYPE_PIE,
+ "com.sun.star.chart2.ChartType",
+ "com.sun.star.beans.PropertySet" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart_PieChartType_get_implementation(css::uno::XComponentContext * /*context*/,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::PieChartType);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/PieChartType.hxx b/chart2/source/model/template/PieChartType.hxx
new file mode 100644
index 000000000..897ec9695
--- /dev/null
+++ b/chart2/source/model/template/PieChartType.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_PIECHARTTYPE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_PIECHARTTYPE_HXX
+
+#include "ChartType.hxx"
+
+namespace chart
+{
+
+class PieChartType final: public ChartType
+{
+public:
+ explicit PieChartType();
+ virtual ~PieChartType() 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;
+
+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;
+
+ // ____ 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;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_PIECHARTTYPE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx
new file mode 100644
index 000000000..964b5d96d
--- /dev/null
+++ b/chart2/source/model/template/PieChartTypeTemplate.cxx
@@ -0,0 +1,608 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "PieChartTypeTemplate.hxx"
+#include <CommonConverters.hxx>
+#include <DiagramHelper.hxx>
+#include <servicenames_charttypes.hxx>
+#include <DataSeriesHelper.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 <tools/diagnose_ex.h>
+
+#include <rtl/math.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+
+namespace
+{
+
+enum
+{
+ PROP_PIE_TEMPLATE_DEFAULT_OFFSET,
+ PROP_PIE_TEMPLATE_OFFSET_MODE,
+ PROP_PIE_TEMPLATE_DIMENSION,
+ PROP_PIE_TEMPLATE_USE_RINGS
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "OffsetMode",
+ PROP_PIE_TEMPLATE_OFFSET_MODE,
+ cppu::UnoType<chart2::PieChartOffsetMode>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "DefaultOffset",
+ PROP_PIE_TEMPLATE_DEFAULT_OFFSET,
+ cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "Dimension",
+ PROP_PIE_TEMPLATE_DIMENSION,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "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() );
+
+ return comphelper::containerToSequence( aProperties );
+ }
+
+};
+
+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;
+ }
+};
+
+struct StaticPieChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPieChartTypeTemplateInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+PieChartTypeTemplate::PieChartTypeTemplate(
+ uno::Reference<
+ uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ chart2::PieChartOffsetMode eMode,
+ bool bRings /* = false */,
+ sal_Int32 nDim /* = 2 */ ) :
+ ChartTypeTemplate( xContext, rServiceName ),
+ ::property::OPropertySet( m_aMutex )
+{
+ 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 ));
+}
+
+PieChartTypeTemplate::~PieChartTypeTemplate()
+{}
+
+// ____ OPropertySet ____
+uno::Any PieChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticPieChartTypeTemplateDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL PieChartTypeTemplate::getInfoHelper()
+{
+ return *StaticPieChartTypeTemplateInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL PieChartTypeTemplate::getPropertySetInfo()
+{
+ return *StaticPieChartTypeTemplateInfo::get();
+}
+
+// ____ ChartTypeTemplate ____
+sal_Int32 PieChartTypeTemplate::getDimension() const
+{
+ sal_Int32 nDim = 2;
+ try
+ {
+ // note: UNO-methods are never const
+ const_cast< PieChartTypeTemplate * >( this )->
+ getFastPropertyValue( PROP_PIE_TEMPLATE_DIMENSION ) >>= nDim;
+ }
+ catch( const beans::UnknownPropertyException & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return nDim;
+}
+
+sal_Int32 PieChartTypeTemplate::getAxisCountByDimension( sal_Int32 /*nDimension*/ )
+{
+ return 0;
+}
+
+void PieChartTypeTemplate::adaptAxes(
+ const uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > & /*rCoordSys*/ )
+{
+ // hide existing axes
+ //hhhh todo
+}
+
+void PieChartTypeTemplate::adaptScales(
+ const Sequence< Reference< chart2::XCoordinateSystem > > & 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 )
+ )
+{
+ ChartTypeTemplate::adaptScales( aCooSysSeq, xCategories );
+
+ //remove explicit scalings from radius axis
+ //and ensure correct orientation of scales for donuts
+
+ for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq )
+ {
+ try
+ {
+ Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 1 /*nDimensionIndex*/,0 /*nAxisIndex*/
+ , coords ) );
+ if( xAxis.is() )
+ {
+ chart2::ScaleData aScaleData( xAxis->getScaleData() );
+ AxisHelper::removeExplicitScaling( aScaleData );
+ aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
+ xAxis->setScaleData( aScaleData );
+ }
+
+ xAxis = AxisHelper::getAxis( 0 /*nDimensionIndex*/,0 /*nAxisIndex*/
+ , coords );
+ if( xAxis.is() )
+ {
+ chart2::ScaleData aScaleData( xAxis->getScaleData() );
+ aScaleData.Orientation = chart2::AxisOrientation_REVERSE;
+ xAxis->setScaleData( aScaleData );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+}
+
+void PieChartTypeTemplate::createChartTypes(
+ const Sequence< Sequence< Reference< chart2::XDataSeries > > > & aSeriesSeq,
+ const Sequence< Reference< chart2::XCoordinateSystem > > & rCoordSys,
+ const Sequence< Reference< chart2::XChartType > >& /* aOldChartTypesSeq */ )
+{
+ if( ! rCoordSys.hasElements() ||
+ ! rCoordSys[0].is() )
+ 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())
+ {
+ 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 );
+
+ DataSeriesHelper::setStackModeAtSeries(
+ aFlatSeriesSeq, rCoordSys[0], getStackMode( 0 ));
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+// ____ XChartTypeTemplate ____
+sal_Bool SAL_CALL PieChartTypeTemplate::matchesTemplate(
+ const uno::Reference< chart2::XDiagram >& xDiagram,
+ sal_Bool bAdaptProperties )
+{
+ bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
+
+ bool bTemplateUsesRings = false;
+ getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ) >>= bTemplateUsesRings;
+ chart2::PieChartOffsetMode ePieOffsetMode;
+ getFastPropertyValue( PROP_PIE_TEMPLATE_OFFSET_MODE ) >>= ePieOffsetMode;
+
+ //check offset-mode
+ if( bResult )
+ {
+ try
+ {
+ double fOffset=0.0;
+ bool bAllOffsetsEqual = true;
+
+ std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+
+ //check offset of outer series
+ if( !aSeriesVec.empty() )
+ {
+ //@todo in future this will depend on Orientation of the radius axis scale
+ Reference< chart2::XDataSeries > xSeries( aSeriesVec[0] );
+ Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
+ xProp->getPropertyValue( "Offset") >>= fOffset;
+
+ //get AttributedDataPoints
+ uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
+ if( xProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
+ {
+ for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
+ {
+ uno::Reference< beans::XPropertySet > xPointProp( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]) );
+ if(xPointProp.is())
+ {
+ double fPointOffset=0.0;
+ if( xProp->getPropertyValue( "Offset") >>= fPointOffset )
+ {
+ if( ! ::rtl::math::approxEqual( fPointOffset, fOffset ) )
+ {
+ bAllOffsetsEqual = false;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ chart2::PieChartOffsetMode eOffsetMode = chart2::PieChartOffsetMode_NONE;
+ if( bAllOffsetsEqual && fOffset > 0.0 )
+ {
+ eOffsetMode = chart2::PieChartOffsetMode_ALL_EXPLODED;
+ if( bAdaptProperties )
+ setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_DEFAULT_OFFSET, uno::Any( fOffset ));
+ }
+
+ bResult = ( eOffsetMode == ePieOffsetMode );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ bResult = false;
+ }
+ }
+
+ //check UseRings
+ if( bResult )
+ {
+ uno::Reference< beans::XPropertySet > xCTProp(
+ DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), uno::UNO_QUERY_THROW );
+ bool bUseRings = false;
+ if( xCTProp->getPropertyValue( "UseRings") >>= bUseRings )
+ {
+ bResult = ( bTemplateUsesRings == bUseRings );
+ }
+ }
+
+ return bResult;
+}
+
+Reference< chart2::XChartType > PieChartTypeTemplate::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_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 ));
+ }
+
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xResult;
+}
+
+Reference< chart2::XChartType > SAL_CALL PieChartTypeTemplate::getChartTypeForNewSeries(
+ const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+{
+ Reference< chart2::XChartType > 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 );
+ ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
+ Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
+ if( xCTProp.is())
+ {
+ xCTProp->setPropertyValue(
+ "UseRings", getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ));
+ }
+
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xResult;
+}
+
+void SAL_CALL PieChartTypeTemplate::applyStyle(
+ const Reference< chart2::XDataSeries >& xSeries,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount )
+{
+ ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+
+ try
+ {
+ uno::Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
+
+ bool bTemplateUsesRings = false;
+ getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ) >>= bTemplateUsesRings;
+ if( nSeriesIndex == 0 ) //@todo in future this will depend on Orientation of the radius axis scale
+ {
+ const OUString aOffsetPropName( "Offset" );
+ // get offset mode
+ chart2::PieChartOffsetMode ePieOffsetMode;
+ getFastPropertyValue( PROP_PIE_TEMPLATE_OFFSET_MODE ) >>= ePieOffsetMode;
+
+ // get default offset
+ double fDefaultOffset = 0.5;
+ getFastPropertyValue( PROP_PIE_TEMPLATE_DEFAULT_OFFSET ) >>= fDefaultOffset;
+ double fOffsetToSet = fDefaultOffset;
+
+ uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
+ xProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList;
+
+ // determine whether to set the new offset
+ bool bSetOffset = ( ePieOffsetMode == chart2::PieChartOffsetMode_ALL_EXPLODED );
+ if( !bSetOffset &&
+ (ePieOffsetMode == chart2::PieChartOffsetMode_NONE) )
+ {
+ // 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) &&
+ ::rtl::math::approxEqual( fOffset, fDefaultOffset ))
+ {
+ fOffsetToSet = 0.0;
+ bSetOffset = true;
+ for( auto const & pointIndex : std::as_const(aAttributedDataPointIndexList) )
+ {
+ uno::Reference< beans::XPropertySet > xPointProp(
+ xSeries->getDataPointByIndex( pointIndex ));
+ uno::Reference< beans::XPropertyState > xPointState( xPointProp, uno::UNO_QUERY );
+ double fPointOffset = 0.0;
+ if( xPointState.is() &&
+ (xPointState->getPropertyState( aOffsetPropName ) == beans::PropertyState_DIRECT_VALUE) &&
+ xPointProp.is() &&
+ (xPointProp->getPropertyValue( aOffsetPropName ) >>= fPointOffset ) &&
+ ! ::rtl::math::approxEqual( fPointOffset, fDefaultOffset ) )
+ {
+ bSetOffset = false;
+ break;
+ }
+ }
+ }
+ }
+
+ if( bSetOffset )
+ {
+ // set the offset to the series and to the attributed data points
+ xProp->setPropertyValue( aOffsetPropName, uno::Any( fOffsetToSet ));
+
+ // remove hard attributes from data points
+ for( auto const & pointIndex : std::as_const(aAttributedDataPointIndexList) )
+ {
+ uno::Reference< beans::XPropertyState > xPointState(
+ xSeries->getDataPointByIndex( pointIndex ), uno::UNO_QUERY );
+ if( xPointState.is())
+ xPointState->setPropertyToDefault( aOffsetPropName );
+ }
+ }
+ }
+
+ // line style
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+
+ // vary colors by point
+ xProp->setPropertyValue( "VaryColorsByPoint", uno::Any( true ));
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+void SAL_CALL PieChartTypeTemplate::resetStyles( const Reference< chart2::XDiagram >& xDiagram )
+{
+ // reset axes and grids
+ Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY );
+ if( xCooSysCnt.is())
+ {
+ const Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
+ ChartTypeTemplate::createAxes( aCooSysSeq );
+
+ //reset scale orientation
+ for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq )
+ {
+ try
+ {
+ Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 0 /*nDimensionIndex*/,0 /*nAxisIndex*/
+ , coords ) );
+ if( xAxis.is() )
+ {
+ chart2::ScaleData aScaleData( xAxis->getScaleData() );
+ aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
+ xAxis->setScaleData( aScaleData );
+ }
+
+ xAxis = AxisHelper::getAxis( 1, 0, coords );
+ if( xAxis.is() )
+ {
+ chart2::ScaleData aScaleData( xAxis->getScaleData() );
+ aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
+ xAxis->setScaleData( aScaleData );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+ }
+
+ ChartTypeTemplate::resetStyles( xDiagram );
+
+ // vary colors by point,
+ // line style
+ std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ uno::Any aLineStyleAny( drawing::LineStyle_NONE );
+ for (auto const& series : aSeriesVec)
+ {
+ Reference< beans::XPropertyState > xState(series, uno::UNO_QUERY);
+ if( xState.is())
+ {
+ xState->setPropertyToDefault( "VaryColorsByPoint");
+ Reference< beans::XPropertySet > xProp( xState, uno::UNO_QUERY );
+ if( xProp.is() &&
+ xProp->getPropertyValue( "BorderStyle") == aLineStyleAny )
+ {
+ xState->setPropertyToDefault( "BorderStyle");
+ }
+ }
+ }
+
+ //reset scene properties
+ ThreeDHelper::setDefaultRotation( uno::Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY ), false );
+}
+
+// ____ XChartTypeTemplate ____
+void PieChartTypeTemplate::adaptDiagram( const uno::Reference< chart2::XDiagram >& xDiagram )
+{
+ if( !xDiagram.is() )
+ return;
+
+ //different default for scene geometry:
+ ThreeDHelper::setDefaultRotation( uno::Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY ), true );
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2( PieChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( PieChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/PieChartTypeTemplate.hxx b/chart2/source/model/template/PieChartTypeTemplate.hxx
new file mode 100644
index 000000000..f11099fdd
--- /dev/null
+++ b/chart2/source/model/template/PieChartTypeTemplate.hxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_PIECHARTTYPETEMPLATE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_PIECHARTTYPETEMPLATE_HXX
+
+#include <OPropertySet.hxx>
+#include <MutexContainer.hxx>
+#include <comphelper/uno3.hxx>
+
+#include "ChartTypeTemplate.hxx"
+#include <com/sun/star/chart2/PieChartOffsetMode.hpp>
+
+namespace chart
+{
+
+class PieChartTypeTemplate :
+ public MutexContainer,
+ public ChartTypeTemplate,
+ public ::property::OPropertySet
+{
+public:
+ PieChartTypeTemplate(
+ css::uno::Reference< css::uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ css::chart2::PieChartOffsetMode eMode,
+ bool bRings,
+ sal_Int32 nDim = 2 );
+ virtual ~PieChartTypeTemplate() override;
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ 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;
+
+ // ____ 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,
+ ::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 sal_Int32 getDimension() const override;
+
+ virtual void adaptDiagram(
+ const css::uno::Reference< css::chart2::XDiagram > & 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;
+
+ virtual void adaptScales(
+ const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & 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
+ ) override;
+
+ virtual css::uno::Reference< css::chart2::XChartType >
+ getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_PIECHARTTYPETEMPLATE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ScatterChartType.cxx b/chart2/source/model/template/ScatterChartType.cxx
new file mode 100644
index 000000000..10798f9bd
--- /dev/null
+++ b/chart2/source/model/template/ScatterChartType.cxx
@@ -0,0 +1,251 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "ScatterChartType.hxx"
+#include <PropertyHelper.hxx>
+#include <servicenames_charttypes.hxx>
+#include <CartesianCoordinateSystem.hxx>
+#include <AxisHelper.hxx>
+#include <AxisIndexDefines.hxx>
+#include <unonames.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/chart2/AxisType.hpp>
+#include <com/sun/star/chart2/CurveStyle.hpp>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+
+namespace
+{
+
+enum
+{
+ PROP_SCATTERCHARTTYPE_CURVE_STYLE,
+ PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION,
+ PROP_SCATTERCHARTTYPE_SPLINE_ORDER
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( 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,
+ PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( CHART_UNONAME_SPLINE_ORDER,
+ PROP_SCATTERCHARTTYPE_SPLINE_ORDER,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+struct StaticScatterChartTypeDefaults_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_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 >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+ScatterChartType::ScatterChartType()
+{
+}
+
+ScatterChartType::ScatterChartType( const ScatterChartType & rOther ) :
+ ChartType( rOther )
+{
+}
+
+ScatterChartType::~ScatterChartType()
+{}
+
+// ____ XCloneable ____
+uno::Reference< util::XCloneable > SAL_CALL ScatterChartType::createClone()
+{
+ return uno::Reference< util::XCloneable >( new ScatterChartType( *this ));
+}
+
+// ____ XChartType ____
+Reference< chart2::XCoordinateSystem > SAL_CALL
+ ScatterChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
+{
+ Reference< chart2::XCoordinateSystem > xResult(
+ new CartesianCoordinateSystem( DimensionCount ));
+
+ for( sal_Int32 i=0; i<DimensionCount; ++i )
+ {
+ Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
+ if( !xAxis.is() )
+ {
+ OSL_FAIL("a created coordinate system should have an axis for each dimension");
+ continue;
+ }
+
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
+ aScaleData.Scaling = AxisHelper::createLinearScaling();
+
+ if( i == 2 )
+ aScaleData.AxisType = chart2::AxisType::SERIES;
+ else
+ aScaleData.AxisType = chart2::AxisType::REALNUMBER;
+
+ xAxis->setScaleData( aScaleData );
+ }
+
+ return xResult;
+}
+
+OUString SAL_CALL ScatterChartType::getChartType()
+{
+ return CHART2_SERVICE_NAME_CHARTTYPE_SCATTER;
+}
+
+uno::Sequence< OUString > SAL_CALL ScatterChartType::getSupportedMandatoryRoles()
+{
+ uno::Sequence< OUString > aMandRolesSeq(3);
+ aMandRolesSeq[0] = "label";
+ aMandRolesSeq[1] = "values-x";
+ aMandRolesSeq[2] = "values-y";
+ return aMandRolesSeq;
+}
+
+// ____ OPropertySet ____
+uno::Any ScatterChartType::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticScatterChartTypeDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+// ____ OPropertySet ____
+::cppu::IPropertyArrayHelper & SAL_CALL ScatterChartType::getInfoHelper()
+{
+ return *StaticScatterChartTypeInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL ScatterChartType::getPropertySetInfo()
+{
+ return *StaticScatterChartTypeInfo::get();
+}
+
+OUString SAL_CALL ScatterChartType::getImplementationName()
+{
+ return "com.sun.star.comp.chart.ScatterChartType";
+}
+
+sal_Bool SAL_CALL ScatterChartType::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence< OUString > SAL_CALL ScatterChartType::getSupportedServiceNames()
+{
+ return {
+ CHART2_SERVICE_NAME_CHARTTYPE_SCATTER,
+ "com.sun.star.chart2.ChartType",
+ "com.sun.star.beans.PropertySet" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
+com_sun_star_comp_chart_ScatterChartType_get_implementation(css::uno::XComponentContext * /*context*/,
+ css::uno::Sequence<css::uno::Any> const &)
+{
+ return cppu::acquire(new ::chart::ScatterChartType);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ScatterChartType.hxx b/chart2/source/model/template/ScatterChartType.hxx
new file mode 100644
index 000000000..e7f1e24de
--- /dev/null
+++ b/chart2/source/model/template/ScatterChartType.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_SCATTERCHARTTYPE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_SCATTERCHARTTYPE_HXX
+
+#include "ChartType.hxx"
+
+namespace chart
+{
+
+class ScatterChartType final : public ChartType
+{
+public:
+ ScatterChartType();
+ virtual ~ScatterChartType() 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;
+
+private:
+ explicit ScatterChartType( const ScatterChartType & rOther );
+
+ // ____ XChartType ____
+ 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;
+
+ // ____ 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;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_SCATTERCHARTTYPE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.cxx b/chart2/source/model/template/ScatterChartTypeTemplate.cxx
new file mode 100644
index 000000000..e0dc1cd11
--- /dev/null
+++ b/chart2/source/model/template/ScatterChartTypeTemplate.cxx
@@ -0,0 +1,391 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "ScatterChartTypeTemplate.hxx"
+#include "XYDataInterpreter.hxx"
+#include <DiagramHelper.hxx>
+#include <servicenames_charttypes.hxx>
+#include <DataSeriesHelper.hxx>
+#include <PropertyHelper.hxx>
+#include <unonames.hxx>
+
+#include <com/sun/star/chart2/CurveStyle.hpp>
+#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/beans/PropertyAttribute.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <tools/diagnose_ex.h>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::Property;
+
+namespace
+{
+
+enum
+{
+ PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE,
+ PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION,
+ PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER
+
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ 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 );
+}
+
+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
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticScatterChartTypeTemplateInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+struct StaticScatterChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticScatterChartTypeTemplateInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+ScatterChartTypeTemplate::ScatterChartTypeTemplate(
+ Reference<
+ uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ bool bSymbols,
+ bool bHasLines /* = true */,
+ sal_Int32 nDim /* = 2 */ ) :
+ ChartTypeTemplate( xContext, rServiceName ),
+ ::property::OPropertySet( m_aMutex ),
+ m_bHasSymbols( bSymbols ),
+ m_bHasLines( bHasLines ),
+ m_nDim( nDim )
+{
+ if( nDim == 3 )
+ m_bHasSymbols = false;
+}
+
+ScatterChartTypeTemplate::~ScatterChartTypeTemplate()
+{}
+
+// ____ OPropertySet ____
+uno::Any ScatterChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticScatterChartTypeTemplateDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL ScatterChartTypeTemplate::getInfoHelper()
+{
+ return *StaticScatterChartTypeTemplateInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL ScatterChartTypeTemplate::getPropertySetInfo()
+{
+ return *StaticScatterChartTypeTemplateInfo::get();
+}
+
+sal_Int32 ScatterChartTypeTemplate::getDimension() const
+{
+ return m_nDim;
+}
+
+StackMode ScatterChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ ) const
+{
+ if( m_nDim == 3 )
+ return StackMode::ZStacked;
+ return StackMode::NONE;
+}
+
+void SAL_CALL ScatterChartTypeTemplate::applyStyle(
+ const Reference< chart2::XDataSeries >& xSeries,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount )
+{
+ ChartTypeTemplate::applyStyle( 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 );
+ if( m_nDim==3 )
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+// ____ XChartTypeTemplate ____
+sal_Bool SAL_CALL ScatterChartTypeTemplate::supportsCategories()
+{
+ return false;
+}
+
+sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
+ const Reference< chart2::XDiagram >& xDiagram,
+ sal_Bool bAdaptProperties )
+{
+ bool bResult = ChartTypeTemplate::matchesTemplate( 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
+ // with symbols (or with lines)
+ if( bResult )
+ {
+ bool bSymbolFound = false;
+ bool bLineFound = false;
+
+ std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+
+ for (auto const& series : aSeriesVec)
+ {
+ try
+ {
+ chart2::Symbol aSymbProp;
+ drawing::LineStyle eLineStyle;
+ Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY_THROW);
+
+ bool bCurrentHasSymbol = (xProp->getPropertyValue( "Symbol") >>= aSymbProp) &&
+ (aSymbProp.Style != chart2::SymbolStyle_NONE);
+
+ if( bCurrentHasSymbol )
+ bSymbolFound = true;
+
+ if( bCurrentHasSymbol && (!m_bHasSymbols) )
+ {
+ bResult = false;
+ break;
+ }
+
+ bool bCurrentHasLine = (xProp->getPropertyValue( "LineStyle") >>= eLineStyle) &&
+ ( eLineStyle != drawing::LineStyle_NONE );
+
+ if( bCurrentHasLine )
+ bLineFound = true;
+
+ if( bCurrentHasLine && (!m_bHasLines) )
+ {
+ bResult = false;
+ break;
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ if(bResult)
+ {
+ if( !bLineFound && m_bHasLines && bSymbolFound )
+ bResult = false;
+ else if( !bSymbolFound && m_bHasSymbols && bLineFound )
+ bResult = false;
+ else if( !bLineFound && !bSymbolFound )
+ return m_bHasLines && m_bHasSymbols;
+ }
+ }
+
+ // adapt curve style, spline order and resolution
+ if( bResult && bAdaptProperties )
+ {
+ try
+ {
+ uno::Reference< beans::XPropertySet > xChartTypeProp(
+ DiagramHelper::getChartTypeByIndex( xDiagram, 0 ),
+ uno::UNO_QUERY_THROW );
+ 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) );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return bResult;
+}
+
+Reference< chart2::XChartType > ScatterChartTypeTemplate::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_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 ));
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xResult;
+}
+
+Reference< chart2::XChartType > SAL_CALL ScatterChartTypeTemplate::getChartTypeForNewSeries(
+ const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+{
+ Reference< chart2::XChartType > 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 );
+
+ 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 ));
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xResult;
+}
+
+Reference< chart2::XDataInterpreter > SAL_CALL ScatterChartTypeTemplate::getDataInterpreter()
+{
+ if( ! m_xDataInterpreter.is())
+ m_xDataInterpreter.set( new XYDataInterpreter );
+
+ return m_xDataInterpreter;
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2( ScatterChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( ScatterChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.hxx b/chart2/source/model/template/ScatterChartTypeTemplate.hxx
new file mode 100644
index 000000000..ee32e200f
--- /dev/null
+++ b/chart2/source/model/template/ScatterChartTypeTemplate.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_SCATTERCHARTTYPETEMPLATE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_SCATTERCHARTTYPETEMPLATE_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
+{
+public:
+ explicit ScatterChartTypeTemplate(
+ css::uno::Reference< css::uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ bool bSymbols,
+ bool bHasLines = true,
+ sal_Int32 nDim = 2 );
+ virtual ~ScatterChartTypeTemplate() override;
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ 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;
+
+ // ____ XChartTypeTemplate ____
+ 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,
+ ::sal_Int32 nChartTypeGroupIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount ) override;
+
+ // ____ ChartTypeTemplate ____
+ virtual css::uno::Reference< css::chart2::XChartType >
+ getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
+ virtual sal_Int32 getDimension() const override;
+ virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
+
+private:
+ bool m_bHasSymbols;
+ bool m_bHasLines;
+ sal_Int32 m_nDim;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_SCATTERCHARTTYPETEMPLATE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/StockChartTypeTemplate.cxx b/chart2/source/model/template/StockChartTypeTemplate.cxx
new file mode 100644
index 000000000..7eb0e1ca5
--- /dev/null
+++ b/chart2/source/model/template/StockChartTypeTemplate.cxx
@@ -0,0 +1,499 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "StockChartTypeTemplate.hxx"
+#include <DataSeriesHelper.hxx>
+#include "StockDataInterpreter.hxx"
+#include <DiagramHelper.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 <vector>
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::chart2;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::Property;
+
+namespace
+{
+
+enum
+{
+ PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME,
+ PROP_STOCKCHARTTYPE_TEMPLATE_OPEN,
+ PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH,
+ PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE
+};
+
+void lcl_AddPropertiesToVector(
+ std::vector< Property > & rOutProperties )
+{
+ rOutProperties.emplace_back( "Volume",
+ PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "Open",
+ PROP_STOCKCHARTTYPE_TEMPLATE_OPEN,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "LowHigh",
+ PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "Japanese",
+ PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+}
+
+struct StaticStockChartTypeTemplateDefaults_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_STOCKCHARTTYPE_TEMPLATE_VOLUME, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_OPEN, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE, false );
+ }
+};
+
+struct StaticStockChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticStockChartTypeTemplateDefaults_Initializer >
+{
+};
+
+struct StaticStockChartTypeTemplateInfoHelper_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 StaticStockChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticStockChartTypeTemplateInfoHelper_Initializer >
+{
+};
+
+struct StaticStockChartTypeTemplateInfo_Initializer
+{
+ uno::Reference< beans::XPropertySetInfo >* operator()()
+ {
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticStockChartTypeTemplateInfoHelper::get() ) );
+ return &xPropertySetInfo;
+ }
+};
+
+struct StaticStockChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticStockChartTypeTemplateInfo_Initializer >
+{
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+
+StockChartTypeTemplate::StockChartTypeTemplate(
+ uno::Reference<
+ uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ StockVariant eVariant,
+ bool bJapaneseStyle ) :
+ ChartTypeTemplate( xContext, rServiceName ),
+ ::property::OPropertySet( m_aMutex ),
+ m_eStockVariant( eVariant )
+{
+ setFastPropertyValue_NoBroadcast(
+ PROP_STOCKCHARTTYPE_TEMPLATE_OPEN,
+ uno::Any( ( eVariant == StockVariant::Open ||
+ eVariant == StockVariant::VolumeOpen )));
+ setFastPropertyValue_NoBroadcast(
+ PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME,
+ uno::Any( ( eVariant == StockVariant::Volume ||
+ eVariant == StockVariant::VolumeOpen )));
+ setFastPropertyValue_NoBroadcast(
+ PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE,
+ uno::Any( bJapaneseStyle ));
+}
+
+StockChartTypeTemplate::~StockChartTypeTemplate()
+{}
+// ____ OPropertySet ____
+uno::Any StockChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+{
+ const tPropertyValueMap& rStaticDefaults = *StaticStockChartTypeTemplateDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
+ return uno::Any();
+ return (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper & SAL_CALL StockChartTypeTemplate::getInfoHelper()
+{
+ return *StaticStockChartTypeTemplateInfoHelper::get();
+}
+
+// ____ XPropertySet ____
+uno::Reference< beans::XPropertySetInfo > SAL_CALL StockChartTypeTemplate::getPropertySetInfo()
+{
+ return *StaticStockChartTypeTemplateInfo::get();
+}
+
+sal_Int32 StockChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension )
+{
+ // one x-axis
+ if( nDimension <= 0 )
+ return 1;
+ // no further axes
+ if( nDimension >= 2 )
+ return 0;
+
+ // one or two y-axes depending on volume
+ OSL_ASSERT( nDimension == 1 );
+ bool bHasVolume = false;
+ getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME ) >>= bHasVolume;
+ return bHasVolume ? 2 : 1;
+}
+
+void SAL_CALL StockChartTypeTemplate::applyStyle(
+ const Reference< chart2::XDataSeries >& xSeries,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount )
+{
+ ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ try
+ {
+ sal_Int32 nNewAxisIndex = 0;
+
+ bool bHasVolume = false;
+ getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME ) >>= bHasVolume;
+ if( bHasVolume && nChartTypeIndex != 0 )
+ nNewAxisIndex = 1;
+
+ Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY );
+ if( xProp.is() )
+ xProp->setPropertyValue( "AttachedAxisIndex", uno::Any( nNewAxisIndex ) );
+
+ if( bHasVolume && nChartTypeIndex==0 )
+ {
+ //switch lines off for volume bars
+ DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+ }
+ 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 ));
+ }
+ }
+
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+void SAL_CALL StockChartTypeTemplate::resetStyles(
+ const Reference< chart2::XDiagram >& xDiagram )
+{
+ ChartTypeTemplate::resetStyles( xDiagram );
+ if( getDimension() == 3 )
+ {
+ std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
+ DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ for (auto const& series : aSeriesVec)
+ {
+ Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY);
+ if( xProp.is() )
+ xProp->setPropertyValue( "AttachedAxisIndex", uno::Any( sal_Int32(0) ) );
+ }
+ }
+
+ DiagramHelper::setVertical( xDiagram, false );
+}
+
+Reference< XChartType > StockChartTypeTemplate::getChartTypeForIndex( sal_Int32 nChartTypeIndex )
+{
+ Reference< XChartType > xCT;
+ Reference< lang::XMultiServiceFactory > xFact(
+ GetComponentContext()->getServiceManager(), uno::UNO_QUERY );
+ if(xFact.is())
+ {
+ 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 );
+ }
+ 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 );
+ }
+ }
+ return xCT;
+}
+
+void StockChartTypeTemplate::createChartTypes(
+ const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq,
+ const Sequence< Reference< XCoordinateSystem > > & rCoordSys,
+ const Sequence< Reference< XChartType > >& /* aOldChartTypesSeq */ )
+{
+ if( !rCoordSys.hasElements() )
+ return;
+
+ try
+ {
+ Reference< lang::XMultiServiceFactory > xFact(
+ GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
+ bool bHasVolume = false;
+ bool bShowFirst = false;
+ bool bJapaneseStyle = false;
+ bool bShowHighLow = true;
+
+ getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME ) >>= bHasVolume;
+ getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_OPEN ) >>= bShowFirst;
+ getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE ) >>= bJapaneseStyle;
+ getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH ) >>= bShowHighLow;
+
+ sal_Int32 nSeriesIndex = 0;
+
+ std::vector< Reference< chart2::XChartType > > aChartTypeVec;
+ // Bars (Volume)
+ if( bHasVolume )
+ {
+ // chart type
+ Reference< XChartType > xCT(
+ xFact->createInstance(
+ CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY_THROW );
+ aChartTypeVec.push_back( xCT );
+
+ if( aSeriesSeq.getLength() > nSeriesIndex &&
+ aSeriesSeq[nSeriesIndex].hasElements() )
+ {
+ Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
+ xDSCnt->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
+ }
+ ++nSeriesIndex;
+ }
+
+ Reference< XChartType > xCT(
+ xFact->createInstance(
+ CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ), uno::UNO_QUERY_THROW );
+ 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 ));
+ }
+
+ if( aSeriesSeq.getLength() > nSeriesIndex &&
+ aSeriesSeq[ nSeriesIndex ].hasElements() )
+ {
+ Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
+ xDSCnt->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
+ }
+ ++nSeriesIndex;
+
+ // Lines (remaining series)
+ if( aSeriesSeq.getLength() > nSeriesIndex &&
+ aSeriesSeq[ nSeriesIndex ].hasElements() )
+ {
+ xCT.set(
+ xFact->createInstance(
+ CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
+ aChartTypeVec.push_back( xCT );
+
+ Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
+ xDSCnt->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
+ }
+
+ Reference< XChartTypeContainer > xCTCnt( rCoordSys[ 0 ], uno::UNO_QUERY_THROW );
+ xCTCnt->setChartTypes( comphelper::containerToSequence(aChartTypeVec) );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+// ____ XChartTypeTemplate ____
+sal_Bool SAL_CALL StockChartTypeTemplate::matchesTemplate(
+ const uno::Reference< XDiagram >& xDiagram,
+ sal_Bool /* bAdaptProperties */ )
+{
+ bool bResult = false;
+
+ if( ! xDiagram.is())
+ return bResult;
+
+ try
+ {
+ bool bHasVolume = false, bHasOpenValue = false, bHasJapaneseStyle = false;
+
+ getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME ) >>= bHasVolume;
+ getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_OPEN ) >>= bHasOpenValue;
+ getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE ) >>= bHasJapaneseStyle;
+
+ Reference< chart2::XChartType > xVolumeChartType;
+ Reference< chart2::XChartType > xCandleStickChartType;
+ Reference< chart2::XChartType > 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 )
+ {
+ Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW );
+ const Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
+ for( Reference< XChartType > const & chartType : aChartTypeSeq )
+ {
+ 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 );
+ }
+ }
+ if( nNumberOfChartTypes > 3 )
+ break;
+ }
+
+ if (xCandleStickChartType.is() && bHasVolume == xVolumeChartType.is())
+ {
+ 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 );
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return bResult;
+}
+
+Reference< XChartType > SAL_CALL StockChartTypeTemplate::getChartTypeForNewSeries(
+ const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+{
+ Reference< chart2::XChartType > 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 );
+ ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xResult;
+}
+
+Reference< XDataInterpreter > SAL_CALL StockChartTypeTemplate::getDataInterpreter()
+{
+ if( ! m_xDataInterpreter.is())
+ m_xDataInterpreter.set( new StockDataInterpreter( m_eStockVariant ) );
+
+ return m_xDataInterpreter;
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2( StockChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( StockChartTypeTemplate, ChartTypeTemplate, OPropertySet )
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/StockChartTypeTemplate.hxx b/chart2/source/model/template/StockChartTypeTemplate.hxx
new file mode 100644
index 000000000..6a05450f8
--- /dev/null
+++ b/chart2/source/model/template/StockChartTypeTemplate.hxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_STOCKCHARTTYPETEMPLATE_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_STOCKCHARTTYPETEMPLATE_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
+{
+public:
+ enum class StockVariant
+ {
+ NONE,
+ Open,
+ Volume,
+ VolumeOpen
+ };
+
+ /** CTOR
+
+ @param bJapaneseStyle
+ If true, the candlesticks are drawn as solid white or black boxes
+ depending on rising or falling stock-values. Otherwise the
+ open-value will be drawn as a small line at the left side of a
+ straight vertical line, and the close-value on the right hand side.
+ */
+ explicit StockChartTypeTemplate(
+ css::uno::Reference< css::uno::XComponentContext > const & xContext,
+ const OUString & rServiceName,
+ StockVariant eVariant,
+ bool bJapaneseStyle );
+ virtual ~StockChartTypeTemplate() override;
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ 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;
+
+ // ____ 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,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount ) override;
+ virtual void SAL_CALL resetStyles(
+ const css::uno::Reference< css::chart2::XDiagram >& 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
+ ) override;
+
+ virtual css::uno::Reference< css::chart2::XChartType >
+ getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
+
+private:
+ // todo: deprecate this variable
+ StockVariant m_eStockVariant;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_STOCKCHARTTYPETEMPLATE_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/StockDataInterpreter.cxx b/chart2/source/model/template/StockDataInterpreter.cxx
new file mode 100644
index 000000000..15c289197
--- /dev/null
+++ b/chart2/source/model/template/StockDataInterpreter.cxx
@@ -0,0 +1,319 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "StockDataInterpreter.hxx"
+#include <DataSeries.hxx>
+#include <com/sun/star/chart2/data/XDataSink.hpp>
+#include <tools/diagnose_ex.h>
+
+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;
+
+namespace chart
+{
+
+// explicit
+StockDataInterpreter::StockDataInterpreter(
+ StockChartTypeTemplate::StockVariant eVariant ) :
+ DataInterpreter(),
+ m_eStockVariant( eVariant )
+{}
+
+StockDataInterpreter::~StockDataInterpreter()
+{}
+
+// ____ XDataInterpreter ____
+InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
+ const Reference< data::XDataSource >& xSource,
+ const Sequence< beans::PropertyValue >& rArguments,
+ const Sequence< Reference< XDataSeries > >& rSeriesToReUse )
+{
+ if( ! xSource.is())
+ return InterpretedData();
+
+ Reference< data::XLabeledDataSequence > xCategories;
+ Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
+ const sal_Int32 nDataCount( aData.getLength());
+
+ // sub-type properties
+ const StockChartTypeTemplate::StockVariant eVar( GetStockVariant());
+ const bool bHasOpenValues (( eVar == StockChartTypeTemplate::StockVariant::Open ) ||
+ ( eVar == StockChartTypeTemplate::StockVariant::VolumeOpen ));
+ const bool bHasVolume (( eVar == StockChartTypeTemplate::StockVariant::Volume ) ||
+ ( eVar == StockChartTypeTemplate::StockVariant::VolumeOpen ));
+ const bool bHasCategories( HasCategories( rArguments, aData ));
+
+ // necessary roles for "full series"
+ // low/high/close
+ sal_Int32 nNumberOfNecessarySequences( 3 );
+ if( bHasOpenValues )
+ ++nNumberOfNecessarySequences;
+ if( bHasVolume )
+ ++nNumberOfNecessarySequences;
+
+ // calculate number of full series (nNumOfFullSeries) and the number of remaining
+ // sequences used for additional "incomplete series" (nRemaining)
+ sal_Int32 nNumOfFullSeries( 0 );
+ sal_Int32 nRemaining( 0 );
+ {
+ sal_Int32 nAvailableSequences( nDataCount );
+ if( bHasCategories )
+ --nAvailableSequences;
+ nNumOfFullSeries = nAvailableSequences / nNumberOfNecessarySequences;
+ nRemaining = nAvailableSequences % nNumberOfNecessarySequences;
+ }
+ sal_Int32 nCandleStickSeries = nNumOfFullSeries;
+ sal_Int32 nVolumeSeries = nNumOfFullSeries;
+
+ sal_Int32 nNumberOfGroups( bHasVolume ? 2 : 1 );
+ // sequences of data::XLabeledDataSequence per series per group
+ Sequence< Sequence< Sequence< Reference< data::XLabeledDataSequence > > > > aSequences( nNumberOfGroups );
+ sal_Int32 nBarGroupIndex( 0 );
+ sal_Int32 nCandleStickGroupIndex( nNumberOfGroups - 1 );
+
+ // allocate space for labeled sequences
+ if( nRemaining > 0 )
+ ++nCandleStickSeries;
+ aSequences[nCandleStickGroupIndex].realloc( nCandleStickSeries );
+ if( bHasVolume )
+ {
+ // if there are remaining sequences, the first one is taken for
+ // additional close values, the second one is taken as volume, if volume
+ // is used
+ if( nRemaining > 1 )
+ ++nVolumeSeries;
+ aSequences[nBarGroupIndex].realloc( nVolumeSeries );
+ }
+
+ // create data
+ sal_Int32 nSourceIndex = 0; // index into aData sequence
+
+ // 1. categories
+ if( bHasCategories )
+ {
+ xCategories.set( aData[nSourceIndex] );
+ ++nSourceIndex;
+ }
+
+ // 2. create "full" series
+ for( sal_Int32 nLabeledSeqIdx=0; nLabeledSeqIdx<nNumOfFullSeries; ++nLabeledSeqIdx )
+ {
+ // bar
+ if( bHasVolume )
+ {
+ aSequences[nBarGroupIndex][nLabeledSeqIdx].realloc( 1 );
+ aSequences[nBarGroupIndex][nLabeledSeqIdx][0].set( aData[nSourceIndex] );
+ if( aData[nSourceIndex].is())
+ SetRole( aData[nSourceIndex]->getValues(), "values-y");
+ ++nSourceIndex;
+ }
+
+ sal_Int32 nSeqIdx = 0;
+ if( bHasOpenValues )
+ {
+ aSequences[nCandleStickGroupIndex][nLabeledSeqIdx].realloc( 4 );
+ aSequences[nCandleStickGroupIndex][nLabeledSeqIdx][nSeqIdx].set( aData[nSourceIndex] );
+ if( aData[nSourceIndex].is())
+ SetRole( aData[nSourceIndex]->getValues(), "values-first");
+ ++nSourceIndex;
+ ++nSeqIdx;
+ }
+ else
+ aSequences[nCandleStickGroupIndex][nLabeledSeqIdx].realloc( 3 );
+
+ aSequences[nCandleStickGroupIndex][nLabeledSeqIdx][nSeqIdx].set( aData[nSourceIndex] );
+ if( aData[nSourceIndex].is())
+ SetRole( aData[nSourceIndex]->getValues(), "values-min");
+ ++nSourceIndex;
+ ++nSeqIdx;
+
+ aSequences[nCandleStickGroupIndex][nLabeledSeqIdx][nSeqIdx].set( aData[nSourceIndex] );
+ if( aData[nSourceIndex].is())
+ SetRole( aData[nSourceIndex]->getValues(), "values-max");
+ ++nSourceIndex;
+ ++nSeqIdx;
+
+ aSequences[nCandleStickGroupIndex][nLabeledSeqIdx][nSeqIdx].set( aData[nSourceIndex] );
+ if( aData[nSourceIndex].is())
+ SetRole( aData[nSourceIndex]->getValues(), "values-last");
+ ++nSourceIndex;
+ ++nSeqIdx;
+ }
+
+ // 3. create series with remaining sequences
+ if( bHasVolume && nRemaining > 1 )
+ {
+ OSL_ASSERT( nVolumeSeries > nNumOfFullSeries );
+ aSequences[nBarGroupIndex][nVolumeSeries - 1].realloc( 1 );
+ OSL_ASSERT( nDataCount > nSourceIndex );
+ if( aData[nSourceIndex].is())
+ SetRole( aData[nSourceIndex]->getValues(), "values-y");
+ aSequences[nBarGroupIndex][nVolumeSeries - 1][0].set( 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" );
+ }
+
+ // candle-stick
+ if( nRemaining > 0 )
+ {
+ OSL_ASSERT( nCandleStickSeries > nNumOfFullSeries );
+ const sal_Int32 nSeriesIndex = nCandleStickSeries - 1;
+ aSequences[nCandleStickGroupIndex][nSeriesIndex].realloc( nRemaining );
+ OSL_ASSERT( nDataCount > nSourceIndex );
+
+ // 1. low
+ sal_Int32 nSeqIdx( 0 );
+ aSequences[nCandleStickGroupIndex][nSeriesIndex][nSeqIdx].set( aData[nSourceIndex] );
+ if( aData[nSourceIndex].is())
+ SetRole( aData[nSourceIndex]->getValues(), "values-min");
+ ++nSourceIndex;
+ ++nSeqIdx;
+
+ // 2. high
+ if( nSeqIdx < nRemaining )
+ {
+ aSequences[nCandleStickGroupIndex][nSeriesIndex][nSeqIdx].set( aData[nSourceIndex] );
+ if( aData[nSourceIndex].is())
+ SetRole( aData[nSourceIndex]->getValues(), "values-max");
+ ++nSourceIndex;
+ ++nSeqIdx;
+ }
+
+ // 3. close
+ OSL_ENSURE( bHasOpenValues || nSeqIdx >= nRemaining, "could have created full series" );
+ if( nSeqIdx < nRemaining )
+ {
+ aSequences[nCandleStickGroupIndex][nSeriesIndex][nSeqIdx].set( aData[nSourceIndex] );
+ if( aData[nSourceIndex].is())
+ SetRole( aData[nSourceIndex]->getValues(), "values-last");
+ ++nSourceIndex;
+ ++nSeqIdx;
+ }
+
+ // 4. open
+ OSL_ENSURE( nSeqIdx >= nRemaining, "could have created full series" );
+ }
+
+ // create DataSeries
+ Sequence< Sequence< Reference< XDataSeries > > > aResultSeries( nNumberOfGroups );
+ sal_Int32 nGroupIndex, nReUsedSeriesIdx = 0;
+ for( nGroupIndex=0; nGroupIndex<nNumberOfGroups; ++nGroupIndex )
+ {
+ const sal_Int32 nNumSeriesData = aSequences[nGroupIndex].getLength();
+ aResultSeries[nGroupIndex].realloc( nNumSeriesData );
+ for( sal_Int32 nSeriesIdx = 0; nSeriesIdx < nNumSeriesData; ++nSeriesIdx, ++nReUsedSeriesIdx )
+ {
+ try
+ {
+ Reference< XDataSeries > xSeries;
+ if( nReUsedSeriesIdx < rSeriesToReUse.getLength())
+ xSeries.set( 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] );
+ aResultSeries[nGroupIndex][nSeriesIdx].set( xSeries );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+ }
+
+ return InterpretedData( aResultSeries, xCategories );
+}
+
+// criterion: there must be two groups for stock-charts with volume and all
+// series must have the correct number of data::XLabeledDataSequences
+
+// todo: skip first criterion? (to allow easy switch from stock-chart without
+// volume to one with volume)
+sal_Bool SAL_CALL StockDataInterpreter::isDataCompatible(
+ const InterpretedData& aInterpretedData )
+{
+ // high/low/close
+ sal_Int32 nNumberOfNecessarySequences = 3;
+ // open
+ StockChartTypeTemplate::StockVariant eVar( GetStockVariant());
+ if( ( eVar == StockChartTypeTemplate::StockVariant::Open ) ||
+ ( eVar == StockChartTypeTemplate::StockVariant::VolumeOpen ))
+ ++nNumberOfNecessarySequences;
+ // volume
+ bool bHasVolume = (( eVar == StockChartTypeTemplate::StockVariant::Volume ) ||
+ ( eVar == StockChartTypeTemplate::StockVariant::VolumeOpen ));
+
+ // 1. correct number of sub-types
+ if( aInterpretedData.Series.getLength() < (bHasVolume ? 2 : 1 ))
+ return false;
+
+ // 2. a. volume -- use default check
+ if( bHasVolume )
+ {
+ if( ! DataInterpreter::isDataCompatible(
+ InterpretedData( Sequence< Sequence< Reference< XDataSeries > > >(
+ aInterpretedData.Series.getConstArray(), 1 ),
+ 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())
+ return false;
+ for( Reference< XDataSeries > const & dataSeries : aSeries )
+ {
+ try
+ {
+ Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
+ Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
+ if( aSeq.getLength() != nNumberOfNecessarySequences )
+ return false;
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+ }
+
+ // 2. c. additional series
+ // ignore
+
+ return true;
+}
+
+InterpretedData SAL_CALL StockDataInterpreter::reinterpretDataSeries(
+ const InterpretedData& aInterpretedData )
+{
+ // prerequisite: StockDataInterpreter::isDataCompatible() returned true
+ return aInterpretedData;
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/StockDataInterpreter.hxx b/chart2/source/model/template/StockDataInterpreter.hxx
new file mode 100644
index 000000000..2bd5b2b61
--- /dev/null
+++ b/chart2/source/model/template/StockDataInterpreter.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_STOCKDATAINTERPRETER_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_STOCKDATAINTERPRETER_HXX
+
+#include "DataInterpreter.hxx"
+
+#include "StockChartTypeTemplate.hxx"
+
+namespace chart
+{
+
+class StockDataInterpreter : public DataInterpreter
+{
+public:
+ explicit StockDataInterpreter(
+ StockChartTypeTemplate::StockVariant eVariant );
+ virtual ~StockDataInterpreter() override;
+
+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 sal_Bool SAL_CALL isDataCompatible(
+ const css::chart2::InterpretedData& aInterpretedData ) override;
+ virtual css::chart2::InterpretedData SAL_CALL reinterpretDataSeries(
+ const css::chart2::InterpretedData& aInterpretedData ) override;
+
+private:
+ StockChartTypeTemplate::StockVariant m_eStockVariant;
+
+ StockChartTypeTemplate::StockVariant GetStockVariant() const { return m_eStockVariant;}
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_STOCKDATAINTERPRETER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/XYDataInterpreter.cxx b/chart2/source/model/template/XYDataInterpreter.cxx
new file mode 100644
index 000000000..a3fb67fa9
--- /dev/null
+++ b/chart2/source/model/template/XYDataInterpreter.cxx
@@ -0,0 +1,252 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "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 <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;
+
+namespace chart
+{
+
+XYDataInterpreter::XYDataInterpreter() :
+ DataInterpreter()
+{
+}
+
+XYDataInterpreter::~XYDataInterpreter()
+{
+}
+
+// ____ XDataInterpreter ____
+chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
+ const Reference< chart2::data::XDataSource >& xSource,
+ const Sequence< beans::PropertyValue >& aArguments,
+ const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+{
+ if( ! xSource.is())
+ return InterpretedData();
+
+ const Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
+
+ Reference< data::XLabeledDataSequence > xValuesX;
+ vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
+
+ Reference< 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 )
+ {
+ try
+ {
+ if( bHasCategories && ! bCategoriesUsed )
+ {
+ xCategories.set( labelData );
+ if( xCategories.is())
+ {
+ SetRole( xCategories->getValues(), "categories");
+ if( bUseCategoriesAsX )
+ bSetXValues = false;
+ }
+ bCategoriesUsed = true;
+ }
+ else if( !xValuesX.is() && bSetXValues )
+ {
+ xValuesX.set( labelData );
+ if( xValuesX.is())
+ SetRole( xValuesX->getValues(), "values-x");
+ }
+ else
+ {
+ aSequencesVec.push_back( labelData );
+ if( labelData.is())
+ SetRole( labelData->getValues(), "values-y");
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ // create DataSeries
+ vector< Reference< XDataSeries > > aSeriesVec;
+ aSeriesVec.reserve( aSequencesVec.size());
+
+ Reference< data::XLabeledDataSequence > xClonedXValues = xValuesX;
+ Reference< util::XCloneable > xCloneable( xValuesX, uno::UNO_QUERY );
+
+ sal_Int32 nSeriesIndex = 0;
+ for (auto const& elem : aSequencesVec)
+ {
+ vector< Reference< data::XLabeledDataSequence > > aNewData;
+
+ if( nSeriesIndex && xCloneable.is() )
+ xClonedXValues.set( xCloneable->createClone(), uno::UNO_QUERY );
+ if( xValuesX.is() )
+ aNewData.push_back( xClonedXValues );
+
+ aNewData.push_back(elem);
+
+ Reference< XDataSeries > xSeries;
+ if( nSeriesIndex < aSeriesToReUse.getLength())
+ xSeries.set( 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 ) );
+
+ aSeriesVec.push_back( xSeries );
+ ++nSeriesIndex;
+ }
+
+ Sequence< Sequence< Reference< XDataSeries > > > aSeries(1);
+ aSeries[0] = comphelper::containerToSequence( aSeriesVec );
+ return InterpretedData( aSeries, xCategories );
+}
+
+chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
+ const chart2::InterpretedData& aInterpretedData )
+{
+ InterpretedData aResult( aInterpretedData );
+
+ sal_Int32 i=0;
+ Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ const sal_Int32 nCount = aSeries.getLength();
+ for( ; i<nCount; ++i )
+ {
+ try
+ {
+ Reference< data::XDataSource > xSeriesSource( aSeries[i], uno::UNO_QUERY_THROW );
+ Sequence< Reference< data::XLabeledDataSequence > > aNewSequences;
+
+ // values-y
+ Reference< data::XLabeledDataSequence > xValuesY(
+ DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-y" ));
+ Reference< data::XLabeledDataSequence > xValuesX(
+ DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-x" ));
+ // re-use values-... as values-x/values-y
+ if( ! xValuesX.is() ||
+ ! xValuesY.is())
+ {
+ vector< Reference< data::XLabeledDataSequence > > aValueSeqVec(
+ DataSeriesHelper::getAllDataSequencesByRole(
+ xSeriesSource->getDataSequences(), "values" ));
+ if( xValuesX.is())
+ aValueSeqVec.erase( find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesX ));
+ if( xValuesY.is())
+ aValueSeqVec.erase( find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesY ));
+
+ size_t nIndex = 0;
+ if( ! xValuesY.is() &&
+ aValueSeqVec.size() > nIndex )
+ {
+ xValuesY.set( aValueSeqVec[nIndex++] );
+ if( xValuesY.is())
+ SetRole( xValuesY->getValues(), "values-y");
+ }
+
+ if( ! xValuesX.is() &&
+ aValueSeqVec.size() > nIndex )
+ {
+ xValuesX.set( aValueSeqVec[nIndex++] );
+ if( xValuesX.is())
+ SetRole( xValuesY->getValues(), "values-x");
+ }
+ }
+ if( xValuesY.is())
+ {
+ if( xValuesX.is())
+ {
+ aNewSequences.realloc(2);
+ aNewSequences[0] = xValuesX;
+ aNewSequences[1] = xValuesY;
+ }
+ else
+ {
+ aNewSequences.realloc(1);
+ aNewSequences[0] = xValuesY;
+ }
+ }
+
+ const Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
+ if( aSeqs.getLength() != aNewSequences.getLength() )
+ {
+#ifdef DBG_UTIL
+ for( auto const & j : aSeqs )
+ {
+ 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 );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return aResult;
+}
+
+// criterion: all series must have exactly two data::XLabeledDataSequences
+sal_Bool SAL_CALL XYDataInterpreter::isDataCompatible(
+ const chart2::InterpretedData& aInterpretedData )
+{
+ const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ for( Reference< XDataSeries > const & dataSeries : aSeries )
+ {
+ try
+ {
+ Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
+ Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
+ if( aSeq.getLength() != 2 )
+ return false;
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return true;
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/XYDataInterpreter.hxx b/chart2/source/model/template/XYDataInterpreter.hxx
new file mode 100644
index 000000000..c57889ce8
--- /dev/null
+++ b/chart2/source/model/template/XYDataInterpreter.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_XYDATAINTERPRETER_HXX
+#define INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_XYDATAINTERPRETER_HXX
+
+#include "DataInterpreter.hxx"
+
+namespace chart
+{
+
+class XYDataInterpreter : public DataInterpreter
+{
+public:
+ explicit XYDataInterpreter();
+ virtual ~XYDataInterpreter() override;
+
+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;
+};
+
+} // namespace chart
+
+// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_XYDATAINTERPRETER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */