summaryrefslogtreecommitdiff
path: root/chart2/source/model
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/model')
-rw-r--r--chart2/source/model/filter/XMLFilter.cxx214
-rw-r--r--chart2/source/model/inc/BaseCoordinateSystem.hxx129
-rw-r--r--chart2/source/model/inc/CartesianCoordinateSystem.hxx33
-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.hxx33
-rw-r--r--chart2/source/model/inc/StockBar.hxx18
-rw-r--r--chart2/source/model/inc/XMLFilter.hxx22
-rw-r--r--chart2/source/model/main/Axis.cxx282
-rw-r--r--chart2/source/model/main/Axis.hxx138
-rw-r--r--chart2/source/model/main/BaseCoordinateSystem.cxx216
-rw-r--r--chart2/source/model/main/CartesianCoordinateSystem.cxx12
-rw-r--r--chart2/source/model/main/ChartModel.cxx604
-rw-r--r--chart2/source/model/main/ChartModel_Persistence.cxx227
-rw-r--r--chart2/source/model/main/DataPoint.cxx102
-rw-r--r--chart2/source/model/main/DataPoint.hxx15
-rw-r--r--chart2/source/model/main/DataPointProperties.cxx67
-rw-r--r--chart2/source/model/main/DataPointProperties.hxx10
-rw-r--r--chart2/source/model/main/DataSeries.cxx707
-rw-r--r--chart2/source/model/main/DataSeriesProperties.cxx18
-rw-r--r--chart2/source/model/main/DataSeriesProperties.hxx55
-rw-r--r--chart2/source/model/main/DataTable.cxx210
-rw-r--r--chart2/source/model/main/Diagram.cxx1921
-rw-r--r--chart2/source/model/main/FormattedString.cxx152
-rw-r--r--chart2/source/model/main/FormattedString.hxx140
-rw-r--r--chart2/source/model/main/GridProperties.cxx133
-rw-r--r--chart2/source/model/main/GridProperties.hxx105
-rw-r--r--chart2/source/model/main/Legend.cxx164
-rw-r--r--chart2/source/model/main/Legend.hxx107
-rw-r--r--chart2/source/model/main/PageBackground.cxx155
-rw-r--r--chart2/source/model/main/PageBackground.hxx22
-rw-r--r--chart2/source/model/main/PolarCoordinateSystem.cxx13
-rw-r--r--chart2/source/model/main/StockBar.cxx133
-rw-r--r--chart2/source/model/main/Title.cxx178
-rw-r--r--chart2/source/model/main/Title.hxx115
-rw-r--r--chart2/source/model/main/UndoManager.cxx21
-rw-r--r--chart2/source/model/main/UndoManager.hxx12
-rw-r--r--chart2/source/model/main/Wall.cxx138
-rw-r--r--chart2/source/model/main/Wall.hxx20
-rw-r--r--chart2/source/model/template/AreaChartType.cxx9
-rw-r--r--chart2/source/model/template/AreaChartType.hxx10
-rw-r--r--chart2/source/model/template/AreaChartTypeTemplate.cxx142
-rw-r--r--chart2/source/model/template/AreaChartTypeTemplate.hxx30
-rw-r--r--chart2/source/model/template/BarChartType.cxx15
-rw-r--r--chart2/source/model/template/BarChartType.hxx10
-rw-r--r--chart2/source/model/template/BarChartTypeTemplate.cxx182
-rw-r--r--chart2/source/model/template/BarChartTypeTemplate.hxx40
-rw-r--r--chart2/source/model/template/BubbleChartType.cxx114
-rw-r--r--chart2/source/model/template/BubbleChartType.hxx17
-rw-r--r--chart2/source/model/template/BubbleChartTypeTemplate.cxx127
-rw-r--r--chart2/source/model/template/BubbleChartTypeTemplate.hxx27
-rw-r--r--chart2/source/model/template/BubbleDataInterpreter.cxx133
-rw-r--r--chart2/source/model/template/BubbleDataInterpreter.hxx22
-rw-r--r--chart2/source/model/template/CandleStickChartType.cxx113
-rw-r--r--chart2/source/model/template/CandleStickChartType.hxx12
-rw-r--r--chart2/source/model/template/ChartType.cxx471
-rw-r--r--chart2/source/model/template/ChartType.hxx141
-rw-r--r--chart2/source/model/template/ChartTypeManager.cxx620
-rw-r--r--chart2/source/model/template/ChartTypeTemplate.cxx515
-rw-r--r--chart2/source/model/template/ChartTypeTemplate.hxx256
-rw-r--r--chart2/source/model/template/ColumnChartType.cxx114
-rw-r--r--chart2/source/model/template/ColumnChartType.hxx12
-rw-r--r--chart2/source/model/template/ColumnLineChartTypeTemplate.cxx250
-rw-r--r--chart2/source/model/template/ColumnLineChartTypeTemplate.hxx52
-rw-r--r--chart2/source/model/template/ColumnLineDataInterpreter.cxx31
-rw-r--r--chart2/source/model/template/ColumnLineDataInterpreter.hxx22
-rw-r--r--chart2/source/model/template/DataInterpreter.cxx149
-rw-r--r--chart2/source/model/template/DataInterpreter.hxx79
-rw-r--r--chart2/source/model/template/FilledNetChartType.cxx12
-rw-r--r--chart2/source/model/template/FilledNetChartType.hxx22
-rw-r--r--chart2/source/model/template/FunnelChartType.cxx75
-rw-r--r--chart2/source/model/template/FunnelChartType.hxx40
-rw-r--r--chart2/source/model/template/FunnelChartTypeTemplate.cxx192
-rw-r--r--chart2/source/model/template/FunnelChartTypeTemplate.hxx61
-rw-r--r--chart2/source/model/template/HistogramCalculator.cxx122
-rw-r--r--chart2/source/model/template/HistogramCalculator.hxx36
-rw-r--r--chart2/source/model/template/HistogramChartType.cxx295
-rw-r--r--chart2/source/model/template/HistogramChartType.hxx52
-rw-r--r--chart2/source/model/template/HistogramChartTypeTemplate.cxx160
-rw-r--r--chart2/source/model/template/HistogramChartTypeTemplate.hxx67
-rw-r--r--chart2/source/model/template/HistogramDataInterpreter.cxx63
-rw-r--r--chart2/source/model/template/HistogramDataInterpreter.hxx35
-rw-r--r--chart2/source/model/template/LineChartType.cxx133
-rw-r--r--chart2/source/model/template/LineChartType.hxx12
-rw-r--r--chart2/source/model/template/LineChartTypeTemplate.cxx230
-rw-r--r--chart2/source/model/template/LineChartTypeTemplate.hxx33
-rw-r--r--chart2/source/model/template/NetChartType.cxx66
-rw-r--r--chart2/source/model/template/NetChartType.hxx19
-rw-r--r--chart2/source/model/template/NetChartTypeTemplate.cxx79
-rw-r--r--chart2/source/model/template/NetChartTypeTemplate.hxx27
-rw-r--r--chart2/source/model/template/PieChartType.cxx156
-rw-r--r--chart2/source/model/template/PieChartType.hxx18
-rw-r--r--chart2/source/model/template/PieChartTypeTemplate.cxx388
-rw-r--r--chart2/source/model/template/PieChartTypeTemplate.hxx65
-rw-r--r--chart2/source/model/template/ScatterChartType.cxx150
-rw-r--r--chart2/source/model/template/ScatterChartType.hxx17
-rw-r--r--chart2/source/model/template/ScatterChartTypeTemplate.cxx238
-rw-r--r--chart2/source/model/template/ScatterChartTypeTemplate.hxx34
-rw-r--r--chart2/source/model/template/StockChartTypeTemplate.cxx323
-rw-r--r--chart2/source/model/template/StockChartTypeTemplate.hxx55
-rw-r--r--chart2/source/model/template/StockDataInterpreter.cxx152
-rw-r--r--chart2/source/model/template/StockDataInterpreter.hxx22
-rw-r--r--chart2/source/model/template/XYDataInterpreter.cxx118
-rw-r--r--chart2/source/model/template/XYDataInterpreter.hxx22
105 files changed, 7901 insertions, 6476 deletions
diff --git a/chart2/source/model/filter/XMLFilter.cxx b/chart2/source/model/filter/XMLFilter.cxx
index a8633cc2d3d3..f68081330347 100644
--- a/chart2/source/model/filter/XMLFilter.cxx
+++ b/chart2/source/model/filter/XMLFilter.cxx
@@ -20,11 +20,10 @@
#include <XMLFilter.hxx>
#include <MediaDescriptorHelper.hxx>
+#include <officecfg/Office/Common.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>
@@ -35,7 +34,6 @@
#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>
@@ -49,9 +47,8 @@
#include <com/sun/star/xml/sax/XFastParser.hpp>
#include <com/sun/star/packages/zip/ZipIOException.hpp>
#include <com/sun/star/document/GraphicStorageHandler.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
-#include <xmloff/xmlnmspe.hxx>
using namespace ::com::sun::star;
@@ -61,9 +58,9 @@ using ::osl::MutexGuard;
namespace
{
-char const sXML_metaStreamName[] = "meta.xml";
-char const sXML_styleStreamName[] = "styles.xml";
-char const sXML_contentStreamName[] = "content.xml";
+constexpr OUString sXML_metaStreamName = u"meta.xml"_ustr;
+constexpr OUString sXML_styleStreamName = u"styles.xml"_ustr;
+constexpr OUString sXML_contentStreamName = u"content.xml"_ustr;
uno::Reference< embed::XStorage > lcl_getWriteStorage(
@@ -94,32 +91,26 @@ uno::Reference< embed::XStorage > lcl_getWriteStorage(
}
}
- 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 );
+ Sequence< uno::Any > aStorageArgs{
+ aMDHelper.ISSET_OutputStream ? uno::Any(aMDHelper.OutputStream)
+ : uno::Any(aMDHelper.URL),
+ uno::Any(embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE),
+ uno::Any(comphelper::containerToSequence( aPropertiesForStorage ))
+ };
- xStorage.set(
- xStorageFact->createInstanceWithArguments( aStorageArgs ),
- uno::UNO_QUERY_THROW );
- }
+ 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 ) ||
+ ! ( xProp->getPropertyValue( u"MediaType"_ustr) >>= aMediaType ) ||
( aMediaType.isEmpty() ))
{
- xProp->setPropertyValue( "MediaType", uno::Any( _sMediaType ));
+ xProp->setPropertyValue( u"MediaType"_ustr, uno::Any( _sMediaType ));
}
}
catch (const uno::Exception&)
@@ -165,10 +156,11 @@ uno::Reference< embed::XStorage > lcl_getReadStorage(
// 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 );
+ Sequence< uno::Any > aStorageArgs{
+ uno::Any(xStream),
+ uno::Any(embed::ElementModes::READ | embed::ElementModes::NOCREATE),
+ uno::Any(comphelper::containerToSequence( aPropertiesForStorage ))
+ };
xStorage.set(
xStorageFact->createInstanceWithArguments( aStorageArgs ), uno::UNO_QUERY_THROW );
}
@@ -189,8 +181,7 @@ namespace chart
{
XMLFilter::XMLFilter( Reference< uno::XComponentContext > const & xContext ) :
- m_xContext( xContext ),
- m_bCancelOperation( false )
+ m_xContext( xContext )
{}
XMLFilter::~XMLFilter()
@@ -204,11 +195,6 @@ sal_Bool SAL_CALL XMLFilter::filter(
MutexGuard aGuard( m_aMutex );
- // ignore cancel flag at start of function
- // note: is currently ignored during import/export
- if( m_bCancelOperation )
- m_bCancelOperation = false;
-
if( m_xSourceDoc.is())
{
OSL_ENSURE( ! m_xTargetDoc.is(), "source doc is set -> target document should not be set" );
@@ -238,12 +224,6 @@ sal_Bool SAL_CALL XMLFilter::filter(
void SAL_CALL XMLFilter::cancel()
{
- // if mutex is locked set "cancel state"
- // note: is currently ignored in filter-method
- if( ! m_aMutex.tryToAcquire())
- {
- m_bCancelOperation = true;
- }
}
// ____ XImporter ____
@@ -282,7 +262,7 @@ ErrCode XMLFilter::impl_Import(
try
{
Reference< lang::XServiceInfo > xServInfo( xDocumentComp, uno::UNO_QUERY_THROW );
- if( ! xServInfo->supportsService( "com.sun.star.chart2.ChartDocument"))
+ if( ! xServInfo->supportsService( u"com.sun.star.chart2.ChartDocument"_ustr))
{
OSL_FAIL( "Import: No ChartDocument" );
return ERRCODE_SFX_GENERAL;
@@ -303,27 +283,25 @@ ErrCode XMLFilter::impl_Import(
uno::Reference<lang::XMultiServiceFactory> xServiceFactory(xFactory, uno::UNO_QUERY);
if (xServiceFactory.is())
{
- uno::Sequence<uno::Any> aArgs(1);
- aArgs[0] <<= xStorage;
+ uno::Sequence<uno::Any> aArgs{ uno::Any(xStorage) };
xGraphicStorageHandler.set(
xServiceFactory->createInstanceWithArguments(
- "com.sun.star.comp.Svx.GraphicImportHelper", aArgs), uno::UNO_QUERY);
+ u"com.sun.star.comp.Svx.GraphicImportHelper"_ustr, aArgs), uno::UNO_QUERY);
}
// create XPropertySet with extra information for the filter
/** property map for import info set */
- comphelper::PropertyMapEntry const aImportInfoMap[] =
+ static comphelper::PropertyMapEntry const aImportInfoMap[] =
{
// necessary properties for XML progress bar at load time
- { OUString("ProgressRange"), 0, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
- { 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 }
+ { u"ProgressRange"_ustr, 0, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
+ { u"ProgressMax"_ustr, 0, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
+ { u"ProgressCurrent"_ustr, 0, cppu::UnoType<sal_Int32>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},
+ { u"PrivateData"_ustr, 0, cppu::UnoType<XInterface>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
+ { u"BaseURI"_ustr, 0, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
+ { u"StreamRelPath"_ustr, 0, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
+ { u"StreamName"_ustr, 0, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
+ { u"BuildId"_ustr, 0, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 },
};
uno::Reference< beans::XPropertySet > xImportInfo(
comphelper::GenericPropertySet_CreateInstance(
@@ -353,24 +331,24 @@ ErrCode XMLFilter::impl_Import(
// 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 ) );
+ xImportInfo->setPropertyValue( u"BaseURI"_ustr, uno::Any( aBaseUri ) );
if( !aHierarchName.isEmpty() )
- xImportInfo->setPropertyValue( "StreamRelPath", uno::Any( aHierarchName ) );
+ xImportInfo->setPropertyValue( u"StreamRelPath"_ustr, uno::Any( aHierarchName ) );
// import meta information
if( bOasis )
nWarning = impl_ImportStream(
sXML_metaStreamName,
- "com.sun.star.comp.Chart.XMLOasisMetaImporter",
+ u"com.sun.star.comp.Chart.XMLOasisMetaImporter"_ustr,
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"),
+ ? u"com.sun.star.comp.Chart.XMLOasisStylesImporter"_ustr
+ : u"com.sun.star.comp.Chart.XMLStylesImporter"_ustr,
xStorage, xFactory, xGraphicStorageHandler, xImportInfo );
nWarning = nWarning != ERRCODE_NONE ? nWarning : nTmpErr;
@@ -378,8 +356,8 @@ ErrCode XMLFilter::impl_Import(
ErrCode nContentWarning = impl_ImportStream(
sXML_contentStreamName,
bOasis
- ? OUString("com.sun.star.comp.Chart.XMLOasisContentImporter")
- : OUString("com.sun.star.comp.Chart.XMLContentImporter"),
+ ? u"com.sun.star.comp.Chart.XMLOasisContentImporter"_ustr
+ : u"com.sun.star.comp.Chart.XMLContentImporter"_ustr,
xStorage, xFactory, xGraphicStorageHandler, xImportInfo );
nWarning = nWarning != ERRCODE_NONE ? nWarning : nContentWarning;
}
@@ -409,7 +387,7 @@ ErrCode XMLFilter::impl_ImportStream(
return ERRCODE_NONE;
if( xImportInfo.is() )
- xImportInfo->setPropertyValue( "StreamName", uno::Any( rStreamName ) );
+ xImportInfo->setPropertyValue( u"StreamName"_ustr, uno::Any( rStreamName ) );
if( xStorage.is() &&
xStorage->isStreamElement( rStreamName ) )
@@ -432,52 +410,49 @@ ErrCode XMLFilter::impl_ImportStream(
nArgs++;
uno::Sequence< uno::Any > aFilterCompArgs( nArgs );
+ auto aFilterCompArgsRange = asNonConstRange(aFilterCompArgs);
nArgs = 0;
if( xGraphicStorageHandler.is())
- aFilterCompArgs[nArgs++] <<= xGraphicStorageHandler;
+ aFilterCompArgsRange[nArgs++] <<= xGraphicStorageHandler;
if( xImportInfo.is())
- aFilterCompArgs[ nArgs++ ] <<= xImportInfo;
+ aFilterCompArgsRange[ 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 );
+ Reference< XInterface > xFilter =
+ xFactory->createInstanceWithArgumentsAndContext( rServiceName, aFilterCompArgs, m_xContext );
+ assert(xFilter);
+ Reference< document::XImporter > xImporter( xFilter, uno::UNO_QUERY );
+ assert(xImporter);
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 );
+ uno::Sequence< uno::Any > aArgs{
+ uno::Any(beans::NamedValue(u"DocumentHandler"_ustr, uno::Any(xFilter))),
+ uno::Any(beans::NamedValue(u"Model"_ustr, uno::Any(m_xTargetDoc)))
+ };
+
+ xFilter = xFactory->createInstanceWithArgumentsAndContext(m_sDocumentHandler,aArgs,m_xContext);
}
catch (const uno::Exception&)
{
- TOOLS_WARN_EXCEPTION("chart2", "");
+ TOOLS_WARN_EXCEPTION("chart2", "failed to instantiate " << m_sDocumentHandler);
}
}
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);
+ Reference< xml::sax::XFastParser > xFastParser(xFilter, 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->setDocumentHandler( uno::Reference<xml::sax::XDocumentHandler>(xFilter, uno::UNO_QUERY_THROW) );
xParser->parseStream(aParserInput);
}
}
@@ -528,7 +503,7 @@ ErrCode XMLFilter::impl_Export(
try
{
Reference< lang::XServiceInfo > xServInfo( xDocumentComp, uno::UNO_QUERY_THROW );
- if( ! xServInfo->supportsService( "com.sun.star.chart2.ChartDocument"))
+ if( ! xServInfo->supportsService( u"com.sun.star.chart2.ChartDocument"_ustr))
{
OSL_FAIL( "Export: No ChartDocument" );
return ERRCODE_SFX_GENERAL;
@@ -558,21 +533,17 @@ ErrCode XMLFilter::impl_Export(
{
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;
+ uno::Sequence< uno::Any > aArgs{
+ uno::Any(beans::NamedValue(u"DocumentHandler"_ustr, uno::Any(xDocHandler))),
+ uno::Any(beans::NamedValue(u"Model"_ustr, uno::Any(xDocumentComp)))
+ };
xDocHandler.set(xServiceFactory->createInstanceWithArguments(m_sDocumentHandler,aArgs), uno::UNO_QUERY );
xSaxWriter.set(xDocHandler,uno::UNO_QUERY);
}
catch (const uno::Exception&)
{
- OSL_FAIL("Exception caught!");
+ TOOLS_WARN_EXCEPTION( "chart2", "Exception caught!");
}
}
@@ -580,24 +551,22 @@ ErrCode XMLFilter::impl_Export(
xGraphicStorageHandler.set(document::GraphicStorageHandler::createWithStorage(m_xContext, xStorage));
// property map for export info set
- comphelper::PropertyMapEntry const aExportInfoMap[] =
+ static comphelper::PropertyMapEntry const aExportInfoMap[] =
{
- { OUString("UsePrettyPrinting"), 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::MAYBEVOID, 0},
- { OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
- { OUString("StreamRelPath"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
- { OUString("StreamName"), 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
- { OUString("ExportTableNumberList"), 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
- { OUString(), 0, css::uno::Type(), 0, 0 }
+ { u"UsePrettyPrinting"_ustr, 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::MAYBEVOID, 0},
+ { u"BaseURI"_ustr, 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
+ { u"StreamRelPath"_ustr, 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
+ { u"StreamName"_ustr, 0, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
+ { u"ExportTableNumberList"_ustr, 0, cppu::UnoType<bool>::get(), beans::PropertyAttribute::MAYBEVOID, 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 ) );
+ bool bUsePrettyPrinting( officecfg::Office::Common::Save::Document::PrettyPrinting::get() );
+ xInfoSet->setPropertyValue( u"UsePrettyPrinting"_ustr, uno::Any( bUsePrettyPrinting ) );
if( ! bOasis )
- xInfoSet->setPropertyValue( "ExportTableNumberList", uno::Any( true ));
+ xInfoSet->setPropertyValue( u"ExportTableNumberList"_ustr, uno::Any( true ));
sal_Int32 nArgs = 2;
if( xGraphicStorageHandler.is())
@@ -605,26 +574,27 @@ ErrCode XMLFilter::impl_Export(
uno::Sequence< uno::Any > aFilterProperties( nArgs );
{
+ auto pFilterProperties = aFilterProperties.getArray();
nArgs = 0;
- aFilterProperties[ nArgs++ ] <<= xInfoSet;
- aFilterProperties[ nArgs++ ] <<= xDocHandler;
+ pFilterProperties[ nArgs++ ] <<= xInfoSet;
+ pFilterProperties[ nArgs++ ] <<= xDocHandler;
if( xGraphicStorageHandler.is())
- aFilterProperties[ nArgs++ ] <<= xGraphicStorageHandler;
+ pFilterProperties[ nArgs++ ] <<= xGraphicStorageHandler;
}
// export meta information
if( bOasis )
nWarning = impl_ExportStream(
sXML_metaStreamName,
- "com.sun.star.comp.Chart.XMLOasisMetaExporter",
+ u"com.sun.star.comp.Chart.XMLOasisMetaExporter"_ustr,
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
+ ? u"com.sun.star.comp.Chart.XMLOasisStylesExporter"_ustr
+ : u"com.sun.star.comp.Chart.XMLStylesExporter"_ustr, // soffice 6/7
xStorage, xSaxWriter, xServiceFactory, aFilterProperties );
nWarning = nWarning != ERRCODE_NONE ? nWarning : nTmp;
@@ -632,8 +602,8 @@ ErrCode XMLFilter::impl_Export(
ErrCode nContentWarning = impl_ExportStream(
sXML_contentStreamName,
bOasis
- ? OUString("com.sun.star.comp.Chart.XMLOasisContentExporter")
- : OUString("com.sun.star.comp.Chart.XMLContentExporter"),
+ ? u"com.sun.star.comp.Chart.XMLOasisContentExporter"_ustr
+ : u"com.sun.star.comp.Chart.XMLContentExporter"_ustr,
xStorage, xSaxWriter, xServiceFactory, aFilterProperties );
nWarning = nWarning != ERRCODE_NONE ? nWarning : nContentWarning;
@@ -684,9 +654,9 @@ ErrCode XMLFilter::impl_ExportStream(
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 ) );
+ xStreamProp->setPropertyValue( u"MediaType"_ustr, uno::Any( u"text/xml"_ustr ) );
+ xStreamProp->setPropertyValue( u"Compressed"_ustr, uno::Any( true ) );//@todo?
+ xStreamProp->setPropertyValue( u"UseCommonStoragePasswordEncryption"_ustr, uno::Any( true ) );
}
catch (const uno::Exception&)
{
@@ -699,10 +669,10 @@ ErrCode XMLFilter::impl_ExportStream(
{
uno::Reference< beans::XPropertySet > xInfoSet;
if( rFilterProperties.hasElements() )
- rFilterProperties.getConstArray()[0] >>= xInfoSet;
+ rFilterProperties[0] >>= xInfoSet;
OSL_ENSURE( xInfoSet.is(), "missing infoset for export" );
if( xInfoSet.is() )
- xInfoSet->setPropertyValue( "StreamName", uno::Any( rStreamName ) );
+ xInfoSet->setPropertyValue( u"StreamName"_ustr, uno::Any( rStreamName ) );
}
Reference< XExporter > xExporter( xServiceFactory->createInstanceWithArguments(
@@ -733,12 +703,12 @@ void XMLFilter::isOasisFormat(const Sequence< beans::PropertyValue >& _rMediaDes
}
OUString XMLFilter::getMediaType(bool _bOasis)
{
- return _bOasis ? OUString(MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII) : OUString(MIMETYPE_VND_SUN_XML_CHART_ASCII);
+ return _bOasis ? MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII : MIMETYPE_VND_SUN_XML_CHART_ASCII;
}
OUString SAL_CALL XMLFilter::getImplementationName()
{
- return "com.sun.star.comp.chart2.XMLFilter";
+ return u"com.sun.star.comp.chart2.XMLFilter"_ustr;
}
sal_Bool SAL_CALL XMLFilter::supportsService( const OUString& rServiceName )
@@ -749,8 +719,8 @@ sal_Bool SAL_CALL XMLFilter::supportsService( const OUString& rServiceName )
css::uno::Sequence< OUString > SAL_CALL XMLFilter::getSupportedServiceNames()
{
return {
- "com.sun.star.document.ImportFilter",
- "com.sun.star.document.ExportFilter"
+ u"com.sun.star.document.ImportFilter"_ustr,
+ u"com.sun.star.document.ExportFilter"_ustr
};
// todo: services are incomplete. Missing:
// XInitialization, XNamed
diff --git a/chart2/source/model/inc/BaseCoordinateSystem.hxx b/chart2/source/model/inc/BaseCoordinateSystem.hxx
deleted file mode 100644
index 1f20e83a02dc..000000000000
--- a/chart2/source/model/inc/BaseCoordinateSystem.hxx
+++ /dev/null
@@ -1,129 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#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
index 7b2847cd8b84..d84f53bf5719 100644
--- a/chart2/source/model/inc/CartesianCoordinateSystem.hxx
+++ b/chart2/source/model/inc/CartesianCoordinateSystem.hxx
@@ -16,19 +16,17 @@
* 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
+#pragma once
-#include "BaseCoordinateSystem.hxx"
+#include <BaseCoordinateSystem.hxx>
namespace chart
{
-
class CartesianCoordinateSystem : public BaseCoordinateSystem
{
public:
- explicit CartesianCoordinateSystem( sal_Int32 nDimensionCount );
- explicit CartesianCoordinateSystem( const CartesianCoordinateSystem & rSource );
+ explicit CartesianCoordinateSystem(sal_Int32 nDimensionCount);
+ explicit CartesianCoordinateSystem(const CartesianCoordinateSystem& rSource);
virtual ~CartesianCoordinateSystem() override;
// ____ XCoordinateSystem ____
@@ -36,15 +34,15 @@ public:
virtual OUString SAL_CALL getViewServiceName() override;
// ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+ 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;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
};
-class CartesianCoordinateSystem2d : public CartesianCoordinateSystem
+class CartesianCoordinateSystem2d final : public CartesianCoordinateSystem
{
public:
explicit CartesianCoordinateSystem2d();
@@ -52,11 +50,11 @@ public:
// ____ 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;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
};
-class CartesianCoordinateSystem3d : public CartesianCoordinateSystem
+class CartesianCoordinateSystem3d final : public CartesianCoordinateSystem
{
public:
explicit CartesianCoordinateSystem3d();
@@ -64,13 +62,10 @@ public:
// ____ 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;
+ 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
+} // namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/ChartTypeManager.hxx b/chart2/source/model/inc/ChartTypeManager.hxx
deleted file mode 100644
index 176681564344..000000000000
--- a/chart2/source/model/inc/ChartTypeManager.hxx
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#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
deleted file mode 100644
index 7a571f1eb423..000000000000
--- a/chart2/source/model/inc/DataSeries.hxx
+++ /dev/null
@@ -1,172 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#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
deleted file mode 100644
index c909f183f174..000000000000
--- a/chart2/source/model/inc/Diagram.hxx
+++ /dev/null
@@ -1,186 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#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
index 4572201f5ce9..43eaefa5b0d6 100644
--- a/chart2/source/model/inc/PolarCoordinateSystem.hxx
+++ b/chart2/source/model/inc/PolarCoordinateSystem.hxx
@@ -16,19 +16,17 @@
* 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
+#pragma once
-#include "BaseCoordinateSystem.hxx"
+#include <BaseCoordinateSystem.hxx>
namespace chart
{
-
class PolarCoordinateSystem : public BaseCoordinateSystem
{
public:
- explicit PolarCoordinateSystem( sal_Int32 nDimensionCount );
- explicit PolarCoordinateSystem( const PolarCoordinateSystem & rSource );
+ explicit PolarCoordinateSystem(sal_Int32 nDimensionCount);
+ explicit PolarCoordinateSystem(const PolarCoordinateSystem& rSource);
virtual ~PolarCoordinateSystem() override;
// ____ XCoordinateSystem ____
@@ -36,15 +34,15 @@ public:
virtual OUString SAL_CALL getViewServiceName() override;
// ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+ 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;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
};
-class PolarCoordinateSystem2d : public PolarCoordinateSystem
+class PolarCoordinateSystem2d final : public PolarCoordinateSystem
{
public:
explicit PolarCoordinateSystem2d();
@@ -52,11 +50,11 @@ public:
// ____ 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;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
};
-class PolarCoordinateSystem3d : public PolarCoordinateSystem
+class PolarCoordinateSystem3d final : public PolarCoordinateSystem
{
public:
explicit PolarCoordinateSystem3d();
@@ -64,13 +62,10 @@ public:
// ____ 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;
+ 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
+} // namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/inc/StockBar.hxx b/chart2/source/model/inc/StockBar.hxx
index b1247e584a63..38f5c2629b4a 100644
--- a/chart2/source/model/inc/StockBar.hxx
+++ b/chart2/source/model/inc/StockBar.hxx
@@ -16,17 +16,14 @@
* 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
+#pragma once
#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-#include <MutexContainer.hxx>
#include <OPropertySet.hxx>
#include <cppuhelper/implbase.hxx>
#include <comphelper/uno3.hxx>
+#include <ModifyListenerHelper.hxx>
namespace chart
{
@@ -41,7 +38,6 @@ typedef ::cppu::WeakImplHelper<
}
class StockBar final :
- public MutexContainer,
public impl::StockBar_Base,
public ::property::OPropertySet
{
@@ -55,8 +51,11 @@ public:
private:
explicit StockBar( const StockBar & rOther );
+ // ____ XTypeProvider ____
+ virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
+
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -85,12 +84,9 @@ private:
virtual void firePropertyChangeEvent() override;
using OPropertySet::disposing;
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
+ rtl::Reference<ModifyEventForwarder> 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
index 4f4ba101a24b..d1eea04da653 100644
--- a/chart2/source/model/inc/XMLFilter.hxx
+++ b/chart2/source/model/inc/XMLFilter.hxx
@@ -16,8 +16,7 @@
* 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
+#pragma once
#include <cppuhelper/implbase.hxx>
#include <com/sun/star/document/XFilter.hpp>
@@ -25,9 +24,8 @@
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/io/XActiveDataSource.hpp>
#include <osl/mutex.hxx>
-#include <vcl/errcode.hxx>
+#include <comphelper/errcode.hxx>
namespace com::sun::star::beans { class XPropertySet; }
namespace com::sun::star::uno { class XComponentContext; }
@@ -38,9 +36,6 @@ namespace com::sun::star {
namespace embed {
class XStorage;
}
- namespace xml::sax {
- class XFastParser;
- }
namespace document {
class XGraphicStorageHandler;
}
@@ -125,12 +120,10 @@ private:
css::uno::Sequence<css::beans::PropertyValue> m_aMediaDescriptor;
OUString m_sDocumentHandler; // when set it will be set as doc handler
-
- volatile bool m_bCancelOperation;
::osl::Mutex m_aMutex;
};
-class XMLReportFilterHelper : public XMLFilter
+class XMLReportFilterHelper final : public XMLFilter
{
virtual void isOasisFormat(const css::uno::Sequence< css::beans::PropertyValue >& _rMediaDescriptor,
bool & _rOutOASIS ) override;
@@ -142,13 +135,13 @@ protected:
virtual OUString SAL_CALL
getImplementationName() override
{
- return "com.sun.star.comp.chart2.report.XMLFilter";
+ return u"com.sun.star.comp.chart2.report.XMLFilter"_ustr;
}
// ____ XImporter ____
virtual void SAL_CALL setTargetDocument(
const css::uno::Reference< css::lang::XComponent >& Document ) override
{
- setDocumentHandler( "com.sun.star.comp.report.ImportDocumentHandler" );
+ setDocumentHandler( u"com.sun.star.comp.report.ImportDocumentHandler"_ustr );
XMLFilter::setTargetDocument(Document);
}
@@ -156,7 +149,7 @@ protected:
virtual void SAL_CALL setSourceDocument(
const css::uno::Reference< css::lang::XComponent >& Document ) override
{
- setDocumentHandler( "com.sun.star.comp.report.ExportDocumentHandler" );
+ setDocumentHandler( u"com.sun.star.comp.report.ExportDocumentHandler"_ustr );
XMLFilter::setSourceDocument(Document);
}
@@ -165,7 +158,4 @@ protected:
} // 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
index ff42899d0c18..9fe2333776bf 100644
--- a/chart2/source/model/main/Axis.cxx
+++ b/chart2/source/model/main/Axis.cxx
@@ -17,16 +17,16 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "Axis.hxx"
-#include "GridProperties.hxx"
+#include <Axis.hxx>
+#include <GridProperties.hxx>
#include <CharacterProperties.hxx>
#include <LinePropertiesHelper.hxx>
#include <UserDefinedProperties.hxx>
#include <PropertyHelper.hxx>
-#include <CloneHelper.hxx>
#include <AxisHelper.hxx>
#include <EventListenerHelper.hxx>
#include <ModifyListenerHelper.hxx>
+#include <Title.hxx>
#include <unonames.hxx>
#include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
@@ -36,7 +36,8 @@
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/awt/Size.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <rtl/ref.hxx>
#include <vector>
#include <algorithm>
@@ -203,116 +204,75 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEVOID );
}
+} // namespace
-struct StaticAxisDefaults_Initializer
+namespace chart
{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
- ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
-
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_SHOW, true );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_CROSSOVER_POSITION, css::chart::ChartAxisPosition_ZERO );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_DISPLAY_LABELS, true );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE, true );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_LABEL_POSITION, css::chart::ChartAxisLabelPosition_NEAR_AXIS );
- ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_AXIS_TEXT_ROTATION, 0.0 );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_BREAK, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_OVERLAP, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_STACKED, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TEXT_ARRANGE_ORDER, css::chart::ChartAxisArrangeOrderType_AUTO );
-
- float fDefaultCharHeight = 10.0;
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
-
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MAJOR_TICKMARKS, 2 /* CHAXIS_MARK_OUTER */ );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_AXIS_MINOR_TICKMARKS, 0 /* CHAXIS_MARK_NONE */ );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_MARK_POSITION, css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_DISPLAY_UNITS, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_AXIS_TRY_STAGGERING_FIRST, false );
- }
-};
-
-struct StaticAxisDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticAxisDefaults_Initializer >
+const ::chart::tPropertyValueMap & StaticAxisDefaults()
{
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aMap;
+ ::chart::CharacterProperties::AddDefaultsToMap( aMap );
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aMap );
+
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_SHOW, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_CROSSOVER_POSITION, css::chart::ChartAxisPosition_ZERO );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_DISPLAY_LABELS, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_LABEL_POSITION, css::chart::ChartAxisLabelPosition_NEAR_AXIS );
+ ::chart::PropertyHelper::setPropertyValueDefault< double >( aMap, PROP_AXIS_TEXT_ROTATION, 0.0 );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TEXT_BREAK, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TEXT_OVERLAP, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TEXT_STACKED, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TEXT_ARRANGE_ORDER, css::chart::ChartAxisArrangeOrderType_AUTO );
+
+ float fDefaultCharHeight = 10.0;
+ ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
+
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_AXIS_MAJOR_TICKMARKS, 2 /* CHAXIS_MARK_OUTER */ );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_AXIS_MINOR_TICKMARKS, 0 /* CHAXIS_MARK_NONE */ );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_MARK_POSITION, css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_DISPLAY_UNITS, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_AXIS_TRY_STAGGERING_FIRST, false );
+ return aMap;
+ }();
+ return aStaticDefaults;
};
+} // namespace chart
-struct StaticAxisInfoHelper_Initializer
+namespace
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
- ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
- ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-};
-
-struct StaticAxisInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticAxisInfoHelper_Initializer >
+::cppu::OPropertyArrayHelper& StaticAxisInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
-struct StaticAxisInfo_Initializer
+std::vector< rtl::Reference< ::chart::GridProperties > > lcl_CloneSubGrids(
+ const std::vector< rtl::Reference< ::chart::GridProperties > > & rSource )
{
- uno::Reference< beans::XPropertySetInfo >* operator()()
+ std::vector< rtl::Reference< ::chart::GridProperties > > aDestination;
+ aDestination.reserve( rSource.size());
+ for( rtl::Reference< ::chart::GridProperties > const & i : rSource )
{
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAxisInfoHelper::get() ) );
- return &xPropertySetInfo;
+ aDestination.push_back(new ::chart::GridProperties(*i));
}
-};
-
-struct StaticAxisInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticAxisInfo_Initializer >
-{
-};
-
-typedef uno::Reference< beans::XPropertySet > lcl_tSubGridType;
-
-void lcl_CloneSubGrids(
- const uno::Sequence< lcl_tSubGridType > & rSource, uno::Sequence< lcl_tSubGridType > & rDestination )
-{
- rDestination.realloc( rSource.getLength());
- lcl_tSubGridType * pDestBegin = rDestination.getArray();
- lcl_tSubGridType * pDestEnd = pDestBegin + rDestination.getLength();
- lcl_tSubGridType * pDestIt = pDestBegin;
-
- for( Reference< beans::XPropertySet > const & i : rSource )
- {
- Reference< beans::XPropertySet > xSubGrid( i );
- if( xSubGrid.is())
- {
- Reference< util::XCloneable > xCloneable( xSubGrid, uno::UNO_QUERY );
- if( xCloneable.is())
- xSubGrid.set( xCloneable->createClone(), uno::UNO_QUERY );
- }
-
- (*pDestIt) = xSubGrid;
- OSL_ASSERT( pDestIt != pDestEnd );
- ++pDestIt;
- }
- OSL_ASSERT( pDestIt == pDestEnd );
+ return aDestination;
}
} // anonymous namespace
@@ -321,12 +281,9 @@ namespace chart
{
Axis::Axis() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_aScaleData( AxisHelper::createDefaultScale() ),
- m_xGrid( new GridProperties() ),
- m_aSubGridProperties(),
- m_xTitle()
+ m_xGrid( new GridProperties() )
{
osl_atomic_increment(&m_refCount);
setFastPropertyValue_NoBroadcast(
@@ -343,22 +300,24 @@ Axis::Axis() :
Axis::Axis( const Axis & rOther ) :
impl::Axis_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_aScaleData( rOther.m_aScaleData )
{
- m_xGrid.set( CloneHelper::CreateRefClone< beans::XPropertySet >()( rOther.m_xGrid ));
+ if (rOther.m_xGrid)
+ m_xGrid = new ::chart::GridProperties(*rOther.m_xGrid);
if( m_xGrid.is())
ModifyListenerHelper::addListener( m_xGrid, m_xModifyEventForwarder );
if( m_aScaleData.Categories.is())
ModifyListenerHelper::addListener( m_aScaleData.Categories, m_xModifyEventForwarder );
- if( rOther.m_aSubGridProperties.hasElements() )
- lcl_CloneSubGrids( rOther.m_aSubGridProperties, m_aSubGridProperties );
- ModifyListenerHelper::addListenerToAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder );
+ if( !rOther.m_aSubGridProperties.empty() )
+ m_aSubGridProperties = lcl_CloneSubGrids( rOther.m_aSubGridProperties );
+ ModifyListenerHelper::addListenerToAllElements( m_aSubGridProperties, m_xModifyEventForwarder );
- m_xTitle.set( CloneHelper::CreateRefClone< chart2::XTitle >()( rOther.m_xTitle ));
+ if ( rOther.m_xTitle )
+ m_xTitle = new Title( *rOther.m_xTitle );
if( m_xTitle.is())
ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
}
@@ -375,12 +334,12 @@ Axis::~Axis()
try
{
ModifyListenerHelper::removeListener( m_xGrid, m_xModifyEventForwarder );
- ModifyListenerHelper::removeListenerFromAllSequenceElements( m_aSubGridProperties, m_xModifyEventForwarder );
+ ModifyListenerHelper::removeListenerFromAllElements( m_aSubGridProperties, m_xModifyEventForwarder );
ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
if( m_aScaleData.Categories.is())
{
ModifyListenerHelper::removeListener( m_aScaleData.Categories, m_xModifyEventForwarder );
- m_aScaleData.Categories.set(nullptr);
+ m_aScaleData.Categories.clear();
}
}
catch( const uno::Exception & )
@@ -388,35 +347,35 @@ Axis::~Axis()
DBG_UNHANDLED_EXCEPTION("chart2");
}
- m_aSubGridProperties.realloc(0);
+ m_aSubGridProperties.clear();
m_xGrid = nullptr;
m_xTitle = nullptr;
}
void Axis::AllocateSubGrids()
{
- Reference< util::XModifyListener > xModifyEventForwarder;
+ rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
Reference< lang::XEventListener > xEventListener;
- std::vector< Reference< beans::XPropertySet > > aOldBroadcasters;
- std::vector< Reference< beans::XPropertySet > > aNewBroadcasters;
+ std::vector< rtl::Reference< GridProperties > > aOldBroadcasters;
+ std::vector< rtl::Reference< GridProperties > > aNewBroadcasters;
{
MutexGuard aGuard( m_aMutex );
xModifyEventForwarder = m_xModifyEventForwarder;
xEventListener = this;
sal_Int32 nNewSubIncCount = m_aScaleData.IncrementData.SubIncrements.getLength();
- sal_Int32 nOldSubIncCount = m_aSubGridProperties.getLength();
+ sal_Int32 nOldSubIncCount = m_aSubGridProperties.size();
if( nOldSubIncCount > nNewSubIncCount )
{
// remove superfluous entries
for( sal_Int32 i = nNewSubIncCount; i < nOldSubIncCount; ++i )
aOldBroadcasters.push_back( m_aSubGridProperties[ i ] );
- m_aSubGridProperties.realloc( nNewSubIncCount );
+ m_aSubGridProperties.resize( nNewSubIncCount );
}
else if( nOldSubIncCount < nNewSubIncCount )
{
- m_aSubGridProperties.realloc( nNewSubIncCount );
+ m_aSubGridProperties.resize( nNewSubIncCount );
// allocate new entries
for( sal_Int32 i = nOldSubIncCount; i < nNewSubIncCount; ++i )
@@ -438,7 +397,7 @@ void Axis::AllocateSubGrids()
// ____ XAxis ____
void SAL_CALL Axis::setScaleData( const chart2::ScaleData& rScaleData )
{
- Reference< util::XModifyListener > xModifyEventForwarder;
+ rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
Reference< lang::XEventListener > xEventListener;
Reference< chart2::data::XLabeledDataSequence > xOldCategories;
Reference< chart2::data::XLabeledDataSequence > xNewCategories = rScaleData.Categories;
@@ -476,9 +435,20 @@ Reference< beans::XPropertySet > SAL_CALL Axis::getGridProperties()
MutexGuard aGuard( m_aMutex );
return m_xGrid;
}
+rtl::Reference< ::chart::GridProperties > Axis::getGridProperties2()
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xGrid;
+}
Sequence< Reference< beans::XPropertySet > > SAL_CALL Axis::getSubGridProperties()
{
MutexGuard aGuard( m_aMutex );
+ return comphelper::containerToSequence<Reference< beans::XPropertySet >>(m_aSubGridProperties);
+}
+
+std::vector< rtl::Reference< GridProperties > > Axis::getSubGridProperties2()
+{
+ MutexGuard aGuard( m_aMutex );
return m_aSubGridProperties;
}
@@ -495,10 +465,23 @@ Reference< chart2::XTitle > SAL_CALL Axis::getTitleObject()
return m_xTitle;
}
+rtl::Reference< Title > Axis::getTitleObject2() const
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xTitle;
+}
+
void SAL_CALL Axis::setTitleObject( const Reference< chart2::XTitle >& xNewTitle )
{
- Reference< util::XModifyListener > xModifyEventForwarder;
- Reference< chart2::XTitle > xOldTitle;
+ rtl::Reference<Title> xTitle = dynamic_cast<Title*>(xNewTitle.get());
+ assert(!xNewTitle || xTitle);
+ setTitleObject(xTitle);
+}
+
+void Axis::setTitleObject( const rtl::Reference< Title >& xNewTitle )
+{
+ rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
+ rtl::Reference< Title > xOldTitle;
{
MutexGuard aGuard( m_aMutex );
xOldTitle = m_xTitle;
@@ -517,39 +500,21 @@ void SAL_CALL Axis::setTitleObject( const Reference< chart2::XTitle >& xNewTitle
// ____ XCloneable ____
Reference< util::XCloneable > SAL_CALL Axis::createClone()
{
- Axis * pNewAxis( new Axis( *this ));
- // hold a reference to the clone
- Reference< util::XCloneable > xResult( pNewAxis );
+ rtl::Reference<Axis> pNewAxis( new Axis( *this ));
// do initialization that uses uno references to the clone
pNewAxis->Init();
- return xResult;
+ return pNewAxis;
}
// ____ XModifyBroadcaster ____
void SAL_CALL Axis::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception &)
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL Axis::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -577,24 +542,27 @@ void Axis::fireModifyEvent()
}
// ____ OPropertySet ____
-uno::Any Axis::GetDefaultValue( sal_Int32 nHandle ) const
+void Axis::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticAxisDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticAxisDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL Axis::getInfoHelper()
{
- return *StaticAxisInfoHelper::get();
+ return StaticAxisInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL Axis::getPropertySetInfo()
{
- return *StaticAxisInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticAxisInfoHelper() ) );
+ return xPropertySetInfo;
}
using impl::Axis_Base;
@@ -605,7 +573,7 @@ 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";
+ return u"com.sun.star.comp.chart2.Axis"_ustr;
}
sal_Bool SAL_CALL Axis::supportsService( const OUString& rServiceName )
@@ -616,8 +584,8 @@ sal_Bool SAL_CALL Axis::supportsService( const OUString& rServiceName )
css::uno::Sequence< OUString > SAL_CALL Axis::getSupportedServiceNames()
{
return {
- "com.sun.star.chart2.Axis",
- "com.sun.star.beans.PropertySet" };
+ u"com.sun.star.chart2.Axis"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/main/Axis.hxx b/chart2/source/model/main/Axis.hxx
deleted file mode 100644
index 49f4003bbb4f..000000000000
--- a/chart2/source/model/main/Axis.hxx
+++ /dev/null
@@ -1,138 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#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
index 7075f2ed6f26..607c04af0073 100644
--- a/chart2/source/model/main/BaseCoordinateSystem.cxx
+++ b/chart2/source/model/main/BaseCoordinateSystem.cxx
@@ -22,12 +22,14 @@
#include <UserDefinedProperties.hxx>
#include <CloneHelper.hxx>
#include <ModifyListenerHelper.hxx>
-#include "Axis.hxx"
+#include <Axis.hxx>
+#include <ChartType.hxx>
+#include <ExplicitCategoriesProvider.hxx>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/container/NoSuchElementException.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <o3tl/safeint.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -55,58 +57,31 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEVOID );
}
-struct StaticCooSysDefaults_Initializer
+const ::chart::tPropertyValueMap & StaticCooSysDefaults()
{
- ::chart::tPropertyValueMap* operator()()
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
{
- static ::chart::tPropertyValueMap aStaticDefaults;
- ::chart::PropertyHelper::setPropertyValueDefault( aStaticDefaults, PROP_COORDINATESYSTEM_SWAPXANDYAXIS, false );
- return &aStaticDefaults;
- }
+ ::chart::tPropertyValueMap aMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_COORDINATESYSTEM_SWAPXANDYAXIS, false );
+ return aMap;
+ }();
+ return aStaticDefaults;
};
-struct StaticCooSysDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticCooSysDefaults_Initializer >
+::cppu::OPropertyArrayHelper& StaticCooSysInfoHelper()
{
-};
-
-struct StaticCooSysInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-struct StaticCooSysInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticCooSysInfoHelper_Initializer >
-{
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticCooSysInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticCooSysInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticCooSysInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticCooSysInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -116,15 +91,14 @@ namespace chart
BaseCoordinateSystem::BaseCoordinateSystem(
sal_Int32 nDimensionCount /* = 2 */ ) :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_nDimensionCount( nDimensionCount )
{
m_aAllAxis.resize( m_nDimensionCount );
for( sal_Int32 nN=0; nN<m_nDimensionCount; nN++ )
{
m_aAllAxis[nN].resize( 1 );
- Reference< chart2::XAxis > xAxis( new Axis );
+ rtl::Reference< Axis > xAxis( new Axis );
m_aAllAxis[nN][0] = xAxis;
ModifyListenerHelper::addListenerToAllElements( m_aAllAxis[nN], m_xModifyEventForwarder );
@@ -151,19 +125,21 @@ BaseCoordinateSystem::BaseCoordinateSystem(
BaseCoordinateSystem::BaseCoordinateSystem(
const BaseCoordinateSystem & rSource ) :
impl::BaseCoordinateSystem_Base(rSource),
- ::property::OPropertySet( rSource, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ ::property::OPropertySet( rSource ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_nDimensionCount( rSource.m_nDimensionCount )
{
m_aAllAxis.resize(rSource.m_aAllAxis.size());
tAxisVecVecType::size_type nN=0;
for( nN=0; nN<m_aAllAxis.size(); nN++ )
- CloneHelper::CloneRefVector<chart2::XAxis>( rSource.m_aAllAxis[nN], m_aAllAxis[nN] );
- CloneHelper::CloneRefVector<chart2::XChartType>( rSource.m_aChartTypes, m_aChartTypes );
+ CloneHelper::CloneRefVector( rSource.m_aAllAxis[nN], m_aAllAxis[nN] );
+ for (const auto & rxChartType : rSource.m_aChartTypes)
+ m_aChartTypes.push_back(rxChartType->cloneChartType());
for( nN=0; nN<m_aAllAxis.size(); nN++ )
ModifyListenerHelper::addListenerToAllElements( m_aAllAxis[nN], m_xModifyEventForwarder );
- ModifyListenerHelper::addListenerToAllElements( m_aChartTypes, m_xModifyEventForwarder );
+ for (const auto & rxChartType : m_aChartTypes)
+ rxChartType->addModifyListener( m_xModifyEventForwarder );
}
BaseCoordinateSystem::~BaseCoordinateSystem()
@@ -172,7 +148,8 @@ BaseCoordinateSystem::~BaseCoordinateSystem()
{
for(const tAxisVecVecType::value_type & i : m_aAllAxis)
ModifyListenerHelper::removeListenerFromAllElements( i, m_xModifyEventForwarder );
- ModifyListenerHelper::removeListenerFromAllElements( m_aChartTypes, m_xModifyEventForwarder );
+ for (const auto & rxChartType : m_aChartTypes)
+ rxChartType->removeModifyListener( m_xModifyEventForwarder );
}
catch( const uno::Exception & )
{
@@ -197,13 +174,41 @@ void SAL_CALL BaseCoordinateSystem::setAxisByDimension(
if( nIndex < 0 )
throw lang::IndexOutOfBoundsException();
+ assert(!xAxis || dynamic_cast<Axis*>(xAxis.get()));
+
if( m_aAllAxis[ nDimensionIndex ].size() < o3tl::make_unsigned( nIndex+1 ))
{
m_aAllAxis[ nDimensionIndex ].resize( nIndex+1 );
m_aAllAxis[ nDimensionIndex ][nIndex] = nullptr;
}
- Reference< chart2::XAxis > xOldAxis( m_aAllAxis[ nDimensionIndex ][nIndex] );
+ rtl::Reference< Axis > xOldAxis( m_aAllAxis[ nDimensionIndex ][nIndex] );
+ if( xOldAxis.is())
+ ModifyListenerHelper::removeListener( xOldAxis, m_xModifyEventForwarder );
+ m_aAllAxis[ nDimensionIndex ][nIndex] = dynamic_cast<Axis*>(xAxis.get());
+ if( xAxis.is())
+ ModifyListenerHelper::addListener( xAxis, m_xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+void BaseCoordinateSystem::setAxisByDimension(
+ sal_Int32 nDimensionIndex,
+ const rtl::Reference< Axis >& xAxis,
+ sal_Int32 nIndex )
+{
+ if( nDimensionIndex < 0 || nDimensionIndex >= getDimension() )
+ throw lang::IndexOutOfBoundsException();
+
+ if( nIndex < 0 )
+ throw lang::IndexOutOfBoundsException();
+
+ if( m_aAllAxis[ nDimensionIndex ].size() < o3tl::make_unsigned( nIndex+1 ))
+ {
+ m_aAllAxis[ nDimensionIndex ].resize( nIndex+1 );
+ m_aAllAxis[ nDimensionIndex ][nIndex] = nullptr;
+ }
+
+ rtl::Reference< Axis > xOldAxis( m_aAllAxis[ nDimensionIndex ][nIndex] );
if( xOldAxis.is())
ModifyListenerHelper::removeListener( xOldAxis, m_xModifyEventForwarder );
m_aAllAxis[ nDimensionIndex ][nIndex] = xAxis;
@@ -226,6 +231,20 @@ Reference< chart2::XAxis > SAL_CALL BaseCoordinateSystem::getAxisByDimension(
return m_aAllAxis[ nDimensionIndex ][nAxisIndex];
}
+const rtl::Reference< Axis > & BaseCoordinateSystem::getAxisByDimension2(
+ sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
+{
+ if( nDimensionIndex < 0 || nDimensionIndex >= m_nDimensionCount )
+ throw lang::IndexOutOfBoundsException();
+
+ OSL_ASSERT( m_aAllAxis.size() == static_cast< size_t >( m_nDimensionCount));
+
+ if( nAxisIndex < 0 || o3tl::make_unsigned(nAxisIndex) > m_aAllAxis[ nDimensionIndex ].size() )
+ throw lang::IndexOutOfBoundsException();
+
+ return m_aAllAxis[ nDimensionIndex ][nAxisIndex];
+}
+
sal_Int32 SAL_CALL BaseCoordinateSystem::getMaximumAxisIndexByDimension( sal_Int32 nDimensionIndex )
{
if( nDimensionIndex < 0 || nDimensionIndex >= getDimension() )
@@ -243,22 +262,26 @@ sal_Int32 SAL_CALL BaseCoordinateSystem::getMaximumAxisIndexByDimension( sal_Int
// ____ XChartTypeContainer ____
void SAL_CALL BaseCoordinateSystem::addChartType( const Reference< chart2::XChartType >& aChartType )
{
- if( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), aChartType )
+ auto pChartType = dynamic_cast<ChartType*>(aChartType.get());
+ assert(pChartType);
+
+ if( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), pChartType )
!= m_aChartTypes.end())
- throw lang::IllegalArgumentException();
+ throw lang::IllegalArgumentException(u"type not found"_ustr, static_cast<cppu::OWeakObject*>(this), 1);
- m_aChartTypes.push_back( aChartType );
+ m_aChartTypes.push_back( pChartType );
ModifyListenerHelper::addListener( aChartType, m_xModifyEventForwarder );
fireModifyEvent();
}
void SAL_CALL BaseCoordinateSystem::removeChartType( const Reference< chart2::XChartType >& aChartType )
{
- std::vector< uno::Reference< chart2::XChartType > >::iterator
- aIt( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), aChartType ));
+ auto pChartType = dynamic_cast<ChartType*>(aChartType.get());
+ assert(pChartType);
+ auto aIt( std::find( m_aChartTypes.begin(), m_aChartTypes.end(), pChartType ));
if( aIt == m_aChartTypes.end())
throw container::NoSuchElementException(
- "The given chart type is no element of the container",
+ u"The given chart type is no element of the container"_ustr,
static_cast< uno::XWeak * >( this ));
m_aChartTypes.erase( aIt );
@@ -268,42 +291,50 @@ void SAL_CALL BaseCoordinateSystem::removeChartType( const Reference< chart2::XC
Sequence< Reference< chart2::XChartType > > SAL_CALL BaseCoordinateSystem::getChartTypes()
{
- return comphelper::containerToSequence( m_aChartTypes );
+ return comphelper::containerToSequence< Reference< chart2::XChartType > >( m_aChartTypes );
}
void SAL_CALL BaseCoordinateSystem::setChartTypes( const Sequence< Reference< chart2::XChartType > >& aChartTypes )
{
- ModifyListenerHelper::removeListenerFromAllElements( m_aChartTypes, m_xModifyEventForwarder );
- m_aChartTypes = comphelper::sequenceToContainer<std::vector< css::uno::Reference< css::chart2::XChartType > >>( aChartTypes );
- ModifyListenerHelper::addListenerToAllElements( m_aChartTypes, m_xModifyEventForwarder );
+ for (auto const & aChartType : m_aChartTypes)
+ aChartType->removeModifyListener( m_xModifyEventForwarder );
+ m_aChartTypes.clear();
+ for (auto const & aChartType : aChartTypes)
+ {
+ auto pChartType = dynamic_cast<ChartType*>(aChartType.get());
+ assert(pChartType);
+ m_aChartTypes.push_back(pChartType);
+ pChartType->addModifyListener( m_xModifyEventForwarder );
+ }
+ fireModifyEvent();
+}
+
+void BaseCoordinateSystem::setChartTypes( const std::vector< rtl::Reference< ChartType > >& aChartTypes )
+{
+ for (auto const & aChartType : m_aChartTypes)
+ aChartType->removeModifyListener( m_xModifyEventForwarder );
+ m_aChartTypes = aChartTypes;
+ for (auto const & aChartType : m_aChartTypes)
+ aChartType->addModifyListener( m_xModifyEventForwarder );
fireModifyEvent();
}
+ExplicitCategoriesProvider& BaseCoordinateSystem::getExplicitCategoriesProvider(ChartModel& rModel)
+{
+ if (!mxExplicitCategoriesProvider)
+ mxExplicitCategoriesProvider = std::make_unique<ExplicitCategoriesProvider>(this, rModel);
+ return *mxExplicitCategoriesProvider;
+}
+
// ____ XModifyBroadcaster ____
void SAL_CALL BaseCoordinateSystem::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2" );
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL BaseCoordinateSystem::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2" );
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -330,25 +361,28 @@ void BaseCoordinateSystem::fireModifyEvent()
}
// ____ OPropertySet ____
-uno::Any BaseCoordinateSystem::GetDefaultValue( sal_Int32 nHandle ) const
+void BaseCoordinateSystem::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticCooSysDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticCooSysDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL BaseCoordinateSystem::getInfoHelper()
{
- return *StaticCooSysInfoHelper::get();
+ return StaticCooSysInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL BaseCoordinateSystem::getPropertySetInfo()
{
- return *StaticCooSysInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticCooSysInfoHelper() ) );
+ return xPropertySetInfo;
}
using impl::BaseCoordinateSystem_Base;
diff --git a/chart2/source/model/main/CartesianCoordinateSystem.cxx b/chart2/source/model/main/CartesianCoordinateSystem.cxx
index dd0f77b40e58..a655ee14aa7a 100644
--- a/chart2/source/model/main/CartesianCoordinateSystem.cxx
+++ b/chart2/source/model/main/CartesianCoordinateSystem.cxx
@@ -31,7 +31,7 @@ namespace com::sun::star::uno { class XComponentContext; }
namespace
{
-const char CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME[] = "com.sun.star.chart2.CoordinateSystems.Cartesian";
+constexpr OUString CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME = u"com.sun.star.chart2.CoordinateSystems.Cartesian"_ustr;
}
@@ -72,7 +72,7 @@ uno::Reference< util::XCloneable > SAL_CALL CartesianCoordinateSystem::createClo
// ____ XServiceInfo ____
OUString SAL_CALL CartesianCoordinateSystem::getImplementationName()
{
- return "com.sun.star.comp.chart.CartesianCoordinateSystem";
+ return u"com.sun.star.comp.chart.CartesianCoordinateSystem"_ustr;
}
sal_Bool SAL_CALL CartesianCoordinateSystem::supportsService( const OUString& rServiceName )
@@ -97,7 +97,7 @@ CartesianCoordinateSystem2d::~CartesianCoordinateSystem2d()
// ____ XServiceInfo ____
OUString SAL_CALL CartesianCoordinateSystem2d::getImplementationName()
{
- return "com.sun.star.comp.chart2.CartesianCoordinateSystem2d";
+ return u"com.sun.star.comp.chart2.CartesianCoordinateSystem2d"_ustr;
}
sal_Bool SAL_CALL CartesianCoordinateSystem2d::supportsService( const OUString& rServiceName )
@@ -109,7 +109,7 @@ css::uno::Sequence< OUString > SAL_CALL CartesianCoordinateSystem2d::getSupporte
{
return {
CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME,
- "com.sun.star.chart2.CartesianCoordinateSystem2d"
+ u"com.sun.star.chart2.CartesianCoordinateSystem2d"_ustr
};
}
@@ -125,7 +125,7 @@ CartesianCoordinateSystem3d::~CartesianCoordinateSystem3d()
// ____ XServiceInfo ____
OUString SAL_CALL CartesianCoordinateSystem3d::getImplementationName()
{
- return "com.sun.star.comp.chart2.CartesianCoordinateSystem3d";
+ return u"com.sun.star.comp.chart2.CartesianCoordinateSystem3d"_ustr;
}
sal_Bool SAL_CALL CartesianCoordinateSystem3d::supportsService( const OUString& rServiceName )
@@ -137,7 +137,7 @@ css::uno::Sequence< OUString > SAL_CALL CartesianCoordinateSystem3d::getSupporte
{
return {
CHART2_COOSYSTEM_CARTESIAN_SERVICE_NAME,
- "com.sun.star.chart2.CartesianCoordinateSystem3d"
+ u"com.sun.star.chart2.CartesianCoordinateSystem3d"_ustr
};
}
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index 4f1d055f6a13..ee6c483a09e6 100644
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -18,19 +18,30 @@
*/
#include <ChartModel.hxx>
+#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
#include <servicenames.hxx>
+#include <DataSource.hxx>
#include <DataSourceHelper.hxx>
-#include <ChartModelHelper.hxx>
+#include <ChartType.hxx>
#include <DisposeHelper.hxx>
#include <ControllerLockGuard.hxx>
+#include <InternalDataProvider.hxx>
#include <ObjectIdentifier.hxx>
+#include <BaseCoordinateSystem.hxx>
#include "PageBackground.hxx"
#include <CloneHelper.hxx>
#include <NameContainer.hxx>
#include "UndoManager.hxx"
+
+#include <ChartColorPaletteHelper.hxx>
#include <ChartView.hxx>
#include <PopupRequest.hxx>
#include <ModifyListenerHelper.hxx>
+#include <RangeHighlighter.hxx>
+#include <Diagram.hxx>
+#include <ChartDocumentWrapper.hxx>
+#include <comphelper/dumpxmltostring.hxx>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
#include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp>
@@ -39,25 +50,33 @@
#include <comphelper/propertysequence.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <svl/numformat.hxx>
#include <svl/numuno.hxx>
#include <com/sun/star/lang/DisposedException.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/embed/EmbedMapUnits.hpp>
#include <com/sun/star/embed/Aspects.hpp>
#include <com/sun/star/datatransfer/UnsupportedFlavorException.hpp>
#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/document/DocumentProperties.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/util/CloseVetoException.hpp>
#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/chart2/XChartTypeTemplate.hpp>
#include <sal/log.hxx>
-#include <svl/zforlist.hxx>
-#include <tools/diagnose_ex.h>
+#include <utility>
+#include <comphelper/diagnose_ex.hxx>
#include <libxml/xmlwriter.h>
+#include <sfx2/objsh.hxx>
+#include <com/sun/star/util/XTheme.hpp>
+#include <docmodel/uno/UnoTheme.hxx>
+#include <docmodel/theme/Theme.hxx>
+
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Any;
@@ -65,14 +84,13 @@ 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\"");
+constexpr OUString lcl_aGDIMetaFileMIMEType(
+ u"application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\""_ustr);
+constexpr OUString lcl_aGDIMetaFileMIMETypeHighContrast(
+ u"application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\""_ustr);
} // anonymous namespace
@@ -81,7 +99,20 @@ const OUString lcl_aGDIMetaFileMIMETypeHighContrast(
namespace chart
{
-ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
+namespace
+{
+SfxObjectShell* getParentShell(const uno::Reference<frame::XModel>& xDocModel)
+{
+ uno::Reference<lang::XUnoTunnel> xUnoTunnel(xDocModel, uno::UNO_QUERY);
+ if (xUnoTunnel.is())
+ {
+ return comphelper::getFromUnoTunnel<SfxObjectShell>(xUnoTunnel);
+ }
+ return nullptr;
+}
+}
+
+ChartModel::ChartModel(uno::Reference<uno::XComponentContext > xContext)
: m_aLifeTimeManager( this, this )
, m_bReadOnly( false )
, m_bModified( false )
@@ -90,33 +121,32 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
, mbTimeBased(false)
, m_aControllers( m_aModelMutex )
, m_nControllerLockCount(0)
- , m_xContext( xContext )
- , m_aVisualAreaSize( ChartModelHelper::getDefaultPageSize() )
+ , m_xContext(std::move( xContext ))
+ , m_aVisualAreaSize( ChartModel::getDefaultPageSize() )
, m_xPageBackground( new PageBackground )
- , m_xXMLNamespaceMap( createNameContainer( ::cppu::UnoType<OUString>::get(),
- "com.sun.star.xml.NamespaceMap", "com.sun.star.comp.chart.XMLNameSpaceMap" ) )
+ , m_xXMLNamespaceMap( new NameContainer() )
+ , m_eColorPaletteType(ChartColorPaletteType::Unknown)
+ , m_nColorPaletteIndex(0)
, 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 = new wrapper::ChartDocumentWrapper(m_xContext);
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 );
+ m_xPageBackground->addModifyListener( this );
+ m_xChartTypeManager = new ::chart::ChartTypeManager( m_xContext );
}
osl_atomic_decrement(&m_refCount);
}
ChartModel::ChartModel( const ChartModel & rOther )
: impl::ChartModel_Base(rOther)
+ // not copy the listener
+ , SfxListener()
, m_aLifeTimeManager( this, this )
, m_bReadOnly( rOther.m_bReadOnly )
, m_bModified( rOther.m_bModified )
@@ -136,37 +166,45 @@ ChartModel::ChartModel( const ChartModel & rOther )
, m_aGraphicObjectVector( rOther.m_aGraphicObjectVector )
, m_xDataProvider( rOther.m_xDataProvider )
, m_xInternalDataProvider( rOther.m_xInternalDataProvider )
+ , m_eColorPaletteType(ChartColorPaletteType::Unknown)
+ , m_nColorPaletteIndex(0)
, 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 = new wrapper::ChartDocumentWrapper(m_xContext);
m_xOldModelAgg->setDelegator( *this );
Reference< util::XModifyListener > xListener;
- Reference< chart2::XTitle > xNewTitle = CreateRefClone< chart2::XTitle >()( rOther.m_xTitle );
- Reference< chart2::XDiagram > xNewDiagram = CreateRefClone< chart2::XDiagram >()( rOther.m_xDiagram );
- Reference< beans::XPropertySet > xNewPageBackground = CreateRefClone< beans::XPropertySet >()( rOther.m_xPageBackground );
- Reference< chart2::XChartTypeManager > xChartTypeManager = CreateRefClone< chart2::XChartTypeManager >()( rOther.m_xChartTypeManager );
- Reference< container::XNameAccess > xXMLNamespaceMap = CreateRefClone< container::XNameAccess >()( rOther.m_xXMLNamespaceMap );
+ rtl::Reference< Title > xNewTitle;
+ if ( rOther.m_xTitle )
+ xNewTitle = new Title(*rOther.m_xTitle);
+ rtl::Reference< ::chart::Diagram > xNewDiagram;
+ if (rOther.m_xDiagram.is())
+ xNewDiagram = new ::chart::Diagram( *rOther.m_xDiagram );
+ rtl::Reference< ::chart::PageBackground > xNewPageBackground = new PageBackground( *rOther.m_xPageBackground );
{
- MutexGuard aGuard( m_aModelMutex );
- xListener = this;
- m_xTitle = xNewTitle;
- m_xDiagram = xNewDiagram;
- m_xPageBackground = xNewPageBackground;
- m_xChartTypeManager = xChartTypeManager;
- m_xXMLNamespaceMap = xXMLNamespaceMap;
+ rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager; // does not implement XCloneable
+ rtl::Reference< ::chart::NameContainer > xXMLNamespaceMap = new NameContainer( *rOther.m_xXMLNamespaceMap );
+
+ {
+ MutexGuard aGuard( m_aModelMutex );
+ xListener = this;
+ m_xTitle = xNewTitle;
+ m_xDiagram = xNewDiagram;
+ m_xPageBackground = xNewPageBackground;
+ m_xChartTypeManager = std::move(xChartTypeManager);
+ m_xXMLNamespaceMap = std::move(xXMLNamespaceMap);
+ }
}
ModifyListenerHelper::addListener( xNewTitle, xListener );
- ModifyListenerHelper::addListener( xNewDiagram, xListener );
- ModifyListenerHelper::addListener( xNewPageBackground, xListener );
+ if( xNewDiagram && xListener)
+ xNewDiagram->addModifyListener( xListener );
+ if( xNewPageBackground && xListener)
+ xNewPageBackground->addModifyListener( xListener );
xListener.clear();
}
osl_atomic_decrement(&m_refCount);
@@ -174,6 +212,8 @@ ChartModel::ChartModel( const ChartModel & rOther )
ChartModel::~ChartModel()
{
+ if (SfxObjectShell* pShell = getParentShell(m_xParent))
+ EndListening(*pShell);
if( m_xOldModelAgg.is())
m_xOldModelAgg->setDelegator( nullptr );
}
@@ -188,9 +228,9 @@ void SAL_CALL ChartModel::initialize( const Sequence< Any >& /*rArguments*/ )
//support argument "DocumentRecoverySupport"?
}
-css::uno::Reference< css::uno::XInterface > ChartModel::getChartView() const
+ChartView* ChartModel::getChartView() const
{
- return static_cast< ::cppu::OWeakObject* >( mxChartView.get() );
+ return mxChartView.get();
}
// private methods
@@ -233,7 +273,7 @@ uno::Reference< frame::XController > ChartModel::impl_getCurrentController()
// get the first controller of this model
if( m_aControllers.getLength() )
{
- uno::Reference<uno::XInterface> xI = m_aControllers.getElements()[0];
+ uno::Reference<uno::XInterface> xI = m_aControllers.getInterface(0);
return uno::Reference<frame::XController>( xI, uno::UNO_QUERY );
}
@@ -243,18 +283,11 @@ uno::Reference< frame::XController > ChartModel::impl_getCurrentController()
void ChartModel::impl_notifyCloseListeners()
{
- ::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer
- .getContainer( cppu::UnoType<util::XCloseListener>::get());
- if( pIC )
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ if( m_aLifeTimeManager.m_aCloseListeners.getLength(aGuard) )
{
lang::EventObject aEvent( static_cast< lang::XComponent*>(this) );
- ::cppu::OInterfaceIteratorHelper aIt( *pIC );
- while( aIt.hasMoreElements() )
- {
- uno::Reference< util::XCloseListener > xListener( aIt.next(), uno::UNO_QUERY );
- if( xListener.is() )
- xListener->notifyClosing( aEvent );
- }
+ m_aLifeTimeManager.m_aCloseListeners.notifyEach(aGuard, &util::XCloseListener::notifyClosing, aEvent);
}
}
@@ -265,7 +298,7 @@ void ChartModel::impl_adjustAdditionalShapesPositionAndSize( const awt::Size& aV
return;
uno::Reference< drawing::XShapes > xShapes;
- xProperties->getPropertyValue( "AdditionalShapes" ) >>= xShapes;
+ xProperties->getPropertyValue( u"AdditionalShapes"_ustr ) >>= xShapes;
if ( !xShapes.is() )
return;
@@ -283,10 +316,10 @@ void ChartModel::impl_adjustAdditionalShapesPositionAndSize( const awt::Size& aV
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 );
+ aPos.X = static_cast< tools::Long >( aPos.X * fWidth );
+ aPos.Y = static_cast< tools::Long >( aPos.Y * fHeight );
+ aSize.Width = static_cast< tools::Long >( aSize.Width * fWidth );
+ aSize.Height = static_cast< tools::Long >( aSize.Height * fHeight );
xShape->setPosition( aPos );
xShape->setSize( aSize );
@@ -299,7 +332,7 @@ void ChartModel::impl_adjustAdditionalShapesPositionAndSize( const awt::Size& aV
OUString SAL_CALL ChartModel::getImplementationName()
{
- return CHART_MODEL_SERVICE_IMPLEMENTATION_NAME;
+ return u"com.sun.star.comp.chart2.ChartModel"_ustr;
}
sal_Bool SAL_CALL ChartModel::supportsService( const OUString& rServiceName )
@@ -310,9 +343,9 @@ sal_Bool SAL_CALL ChartModel::supportsService( const OUString& rServiceName )
css::uno::Sequence< OUString > SAL_CALL ChartModel::getSupportedServiceNames()
{
return {
- CHART_MODEL_SERVICE_NAME,
- "com.sun.star.document.OfficeDocument",
- "com.sun.star.chart.ChartDocument"
+ u"com.sun.star.chart2.ChartDocument"_ustr,
+ u"com.sun.star.document.OfficeDocument"_ustr,
+ u"com.sun.star.chart.ChartDocument"_ustr
};
}
@@ -392,7 +425,11 @@ void SAL_CALL ChartModel::disconnectController( const uno::Reference< frame::XCo
if( m_xCurrentController == xController )
m_xCurrentController.clear();
- DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
+ if (m_xRangeHighlighter)
+ {
+ m_xRangeHighlighter->dispose();
+ m_xRangeHighlighter.clear();
+ }
DisposeHelper::DisposeAndClear(m_xPopupRequest);
}
@@ -455,7 +492,7 @@ 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",
+ u"getCurrentController was called on an already disposed or closed model"_ustr,
static_cast< ::cppu::OWeakObject* >(this) );
return impl_getCurrentController();
@@ -466,18 +503,22 @@ void SAL_CALL ChartModel::setCurrentController( const uno::Reference< frame::XCo
LifeTimeGuard aGuard(m_aLifeTimeManager);
if(!aGuard.startApiCall())
throw lang::DisposedException(
- "setCurrentController was called on an already disposed or closed model",
+ u"setCurrentController was called on an already disposed or closed model"_ustr,
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",
+ u"setCurrentController is called with a Controller which is not connected"_ustr,
static_cast< ::cppu::OWeakObject* >(this) );
m_xCurrentController = xController;
- DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
+ if (m_xRangeHighlighter)
+ {
+ m_xRangeHighlighter->dispose();
+ m_xRangeHighlighter.clear();
+ }
DisposeHelper::DisposeAndClear(m_xPopupRequest);
}
@@ -486,7 +527,7 @@ 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",
+ u"getCurrentSelection was called on an already disposed or closed model"_ustr,
static_cast< ::cppu::OWeakObject* >(this) );
uno::Reference< uno::XInterface > xReturn;
@@ -501,7 +542,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartModel::getCurrentSelection()
uno::Any aSel = xSelectionSupl->getSelection();
OUString aObjectCID;
if( aSel >>= aObjectCID )
- xReturn.set( ObjectIdentifier::getObjectPropertySet( aObjectCID, Reference< XChartDocument >(this)));
+ xReturn.set( ObjectIdentifier::getObjectPropertySet( aObjectCID, this));
}
}
return xReturn;
@@ -525,7 +566,7 @@ void SAL_CALL ChartModel::dispose()
//// @todo
if ( m_xDiagram.is() )
- ModifyListenerHelper::removeListener( m_xDiagram, this );
+ m_xDiagram->removeModifyListener( this );
if ( m_xDataProvider.is() )
{
@@ -537,12 +578,12 @@ void SAL_CALL ChartModel::dispose()
m_xDataProvider.clear();
m_xInternalDataProvider.clear();
m_xNumberFormatsSupplier.clear();
- DisposeHelper::DisposeAndClear( m_xOwnNumberFormatsSupplier );
- DisposeHelper::DisposeAndClear( m_xChartTypeManager );
- DisposeHelper::DisposeAndClear( m_xDiagram );
- DisposeHelper::DisposeAndClear( m_xTitle );
- DisposeHelper::DisposeAndClear( m_xPageBackground );
- DisposeHelper::DisposeAndClear( m_xXMLNamespaceMap );
+ m_xOwnNumberFormatsSupplier.clear();
+ m_xChartTypeManager.clear();
+ m_xDiagram.clear();
+ m_xTitle.clear();
+ m_xPageBackground.clear();
+ m_xXMLNamespaceMap.clear();
m_xStorage.clear();
// just clear, don't dispose - we're not the owner
@@ -558,7 +599,11 @@ void SAL_CALL ChartModel::dispose()
m_aControllers.disposeAndClear( lang::EventObject( static_cast< cppu::OWeakObject * >( this )));
m_xCurrentController.clear();
- DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
+ if (m_xRangeHighlighter)
+ {
+ m_xRangeHighlighter->dispose();
+ m_xRangeHighlighter.clear();
+ }
DisposeHelper::DisposeAndClear(m_xPopupRequest);
if( m_xOldModelAgg.is())
@@ -570,7 +615,8 @@ void SAL_CALL ChartModel::addEventListener( const uno::Reference< lang::XEventLi
if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.addInterface( cppu::UnoType<lang::XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aEventListeners.addInterface( aGuard, xListener );
}
void SAL_CALL ChartModel::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
@@ -578,7 +624,8 @@ void SAL_CALL ChartModel::removeEventListener( const uno::Reference< lang::XEven
if( m_aLifeTimeManager.impl_isDisposedOrClosed(false) )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.removeInterface( cppu::UnoType<lang::XEventListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aEventListeners.removeInterface( aGuard, xListener );
}
// util::XCloseBroadcaster (base of XCloseable)
@@ -592,7 +639,8 @@ void SAL_CALL ChartModel::removeCloseListener( const uno::Reference< util::XClos
if( m_aLifeTimeManager.impl_isDisposedOrClosed(false) )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.removeInterface( cppu::UnoType<util::XCloseListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aCloseListeners.removeInterface( aGuard, xListener );
}
// util::XCloseable
@@ -613,7 +661,7 @@ void SAL_CALL ChartModel::close( sal_Bool bDeliverOwnership )
//check whether we self can close
{
util::CloseVetoException aVetoException(
- "the model itself could not be closed",
+ u"the model itself could not be closed"_ustr,
static_cast< ::cppu::OWeakObject* >(this) );
m_aLifeTimeManager.g_close_isNeedToCancelLongLastingCalls( bDeliverOwnership, aVetoException );
@@ -657,7 +705,7 @@ 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();
+ return m_pUndoManager;
}
// chart2::XChartDocument
@@ -670,18 +718,20 @@ uno::Reference< chart2::XDiagram > SAL_CALL ChartModel::getFirstDiagram()
void SAL_CALL ChartModel::setFirstDiagram( const uno::Reference< chart2::XDiagram >& xDiagram )
{
- Reference< chart2::XDiagram > xOldDiagram;
+ rtl::Reference< ::chart::Diagram > xOldDiagram;
Reference< util::XModifyListener > xListener;
{
MutexGuard aGuard( m_aModelMutex );
- if( xDiagram == m_xDiagram )
+ if( xDiagram.get() == m_xDiagram.get() )
return;
xOldDiagram = m_xDiagram;
- m_xDiagram = xDiagram;
+ assert(!xDiagram || dynamic_cast<::chart::Diagram*>(xDiagram.get()));
+ m_xDiagram = dynamic_cast<::chart::Diagram*>(xDiagram.get());
xListener = this;
}
//don't keep the mutex locked while calling out
- ModifyListenerHelper::removeListener( xOldDiagram, xListener );
+ if( xOldDiagram && xListener )
+ xOldDiagram->removeModifyListener( xListener );
ModifyListenerHelper::addListener( xDiagram, xListener );
setModified( true );
}
@@ -691,25 +741,20 @@ Reference< chart2::data::XDataSource > ChartModel::impl_createDefaultData()
Reference< chart2::data::XDataSource > xDataSource;
if( hasInternalDataProvider() )
{
- uno::Reference< lang::XInitialization > xIni(m_xInternalDataProvider,uno::UNO_QUERY);
- if( xIni.is() )
+ //init internal dataprovider
{
- //init internal dataprovider
- {
- 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 );
+ beans::NamedValue aParam( u"CreateDefaultData"_ustr ,uno::Any(true) );
+ uno::Sequence< uno::Any > aArgs{ uno::Any(aParam) };
+ m_xInternalDataProvider->initialize(aArgs);
}
+ //create data
+ uno::Sequence<beans::PropertyValue> aArgs( comphelper::InitPropertySequence({
+ { "CellRangeRepresentation", uno::Any( u"all"_ustr ) },
+ { "HasCategories", uno::Any( true ) },
+ { "FirstCellAsLabel", uno::Any( true ) },
+ { "DataRowSource", uno::Any( css::chart::ChartDataRowSource_COLUMNS ) }
+ }));
+ xDataSource = m_xInternalDataProvider->createDataSource( aArgs );
}
return xDataSource;
}
@@ -723,9 +768,12 @@ void SAL_CALL ChartModel::createInternalDataProvider( sal_Bool bCloneExistingDat
if( !hasInternalDataProvider() )
{
if( bCloneExistingData )
- m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( this, true );
+ m_xInternalDataProvider = new InternalDataProvider( this, /*bConnectToModel*/true, /*bDefaultDataInColumns*/ true );
else
- m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( Reference<XChartDocument>(), true );
+ {
+ m_xInternalDataProvider = new InternalDataProvider( nullptr, /*bConnectToModel*/true, /*bDefaultDataInColumns*/ true );
+ m_xInternalDataProvider->setChartModel(this);
+ }
m_xDataProvider.set( m_xInternalDataProvider );
}
setModified( true );
@@ -741,15 +789,15 @@ void ChartModel::removeDataProviders()
void ChartModel::dumpAsXml(xmlTextWriterPtr pWriter) const
{
- xmlTextWriterStartElement(pWriter, BAD_CAST("ChartModel"));
- xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
+ (void)xmlTextWriterStartElement(pWriter, BAD_CAST("ChartModel"));
+ (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
if (mxChartView.is())
{
mxChartView->dumpAsXml(pWriter);
}
- xmlTextWriterEndElement(pWriter);
+ (void)xmlTextWriterEndElement(pWriter);
}
sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
@@ -774,8 +822,8 @@ void SAL_CALL ChartModel::attachDataProvider( const uno::Reference< chart2::data
{
try
{
- bool bIncludeHiddenCells = ChartModelHelper::isIncludeHiddenCells( Reference< frame::XModel >(this) );
- xProp->setPropertyValue("IncludeHiddenCells", uno::Any(bIncludeHiddenCells));
+ bool bIncludeHiddenCells = isIncludeHiddenCells();
+ xProp->setPropertyValue(u"IncludeHiddenCells"_ustr, uno::Any(bIncludeHiddenCells));
}
catch (const beans::UnknownPropertyException&)
{
@@ -799,10 +847,11 @@ void SAL_CALL ChartModel::attachDataProvider( const uno::Reference< chart2::data
void SAL_CALL ChartModel::attachNumberFormatsSupplier( const uno::Reference< util::XNumberFormatsSupplier >& xNewSupplier )
{
{
+ // Mostly the supplier is SvNumberFormatsSupplierObj, but sometimes it is reportdesign::OReportDefinition
MutexGuard aGuard( m_aModelMutex );
- if( xNewSupplier==m_xNumberFormatsSupplier )
+ if( xNewSupplier == m_xNumberFormatsSupplier )
return;
- if( xNewSupplier==m_xOwnNumberFormatsSupplier )
+ if( xNewSupplier == uno::Reference<XNumberFormatsSupplier>(m_xOwnNumberFormatsSupplier) )
return;
if( m_xOwnNumberFormatsSupplier.is() && xNewSupplier.is() )
{
@@ -838,10 +887,10 @@ void SAL_CALL ChartModel::setArguments( const Sequence< beans::PropertyValue >&
Reference< chart2::data::XDataSource > xDataSource( m_xDataProvider->createDataSource( aArguments ) );
if( xDataSource.is() )
{
- Reference< chart2::XDiagram > xDia( getFirstDiagram() );
+ rtl::Reference< Diagram > xDia = getFirstChartDiagram();
if( !xDia.is() )
{
- Reference< chart2::XChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() );
+ rtl::Reference< ::chart::ChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() );
if( xTemplate.is())
setFirstDiagram( xTemplate->createDiagramByDataSource( xDataSource, aArguments ) );
}
@@ -864,22 +913,18 @@ void SAL_CALL ChartModel::setArguments( const Sequence< beans::PropertyValue >&
Sequence< OUString > SAL_CALL ChartModel::getUsedRangeRepresentations()
{
- return DataSourceHelper::getUsedDataRanges( Reference< frame::XModel >(this));
+ return comphelper::containerToSequence(DataSourceHelper::getUsedDataRanges( this ));
}
Reference< chart2::data::XDataSource > SAL_CALL ChartModel::getUsedData()
{
- return DataSourceHelper::getUsedData( Reference< chart2::XChartDocument >(this));
+ return DataSourceHelper::getUsedData( *this );
}
Reference< chart2::data::XRangeHighlighter > SAL_CALL ChartModel::getRangeHighlighter()
{
if( ! m_xRangeHighlighter.is())
- {
- uno::Reference< view::XSelectionSupplier > xSelSupp( getCurrentController(), uno::UNO_QUERY );
- if( xSelSupp.is() )
- m_xRangeHighlighter.set( ChartModelHelper::createRangeHighlighter( xSelSupp ));
- }
+ m_xRangeHighlighter = new RangeHighlighter( this );
return m_xRangeHighlighter;
}
@@ -890,12 +935,11 @@ Reference<awt::XRequestCallback> SAL_CALL ChartModel::getPopupRequest()
return m_xPopupRequest;
}
-Reference< chart2::XChartTypeTemplate > ChartModel::impl_createDefaultChartTypeTemplate()
+rtl::Reference< ::chart::ChartTypeTemplate > ChartModel::impl_createDefaultChartTypeTemplate()
{
- Reference< chart2::XChartTypeTemplate > xTemplate;
- Reference< lang::XMultiServiceFactory > xFact( m_xChartTypeManager, uno::UNO_QUERY );
- if( xFact.is() )
- xTemplate.set( xFact->createInstance( "com.sun.star.chart2.template.Column" ), uno::UNO_QUERY );
+ rtl::Reference< ::chart::ChartTypeTemplate > xTemplate;
+ if( m_xChartTypeManager.is() )
+ xTemplate = m_xChartTypeManager->createTemplate( u"com.sun.star.chart2.template.Column"_ustr );
return xTemplate;
}
@@ -903,7 +947,8 @@ void SAL_CALL ChartModel::setChartTypeManager( const uno::Reference< chart2::XCh
{
{
MutexGuard aGuard( m_aModelMutex );
- m_xChartTypeManager = xNewManager;
+ m_xChartTypeManager = dynamic_cast<::chart::ChartTypeManager*>(xNewManager.get());
+ assert(!xNewManager || m_xChartTypeManager);
}
setModified( true );
}
@@ -932,7 +977,20 @@ uno::Reference< chart2::XTitle > SAL_CALL ChartModel::getTitleObject()
return m_xTitle;
}
-void SAL_CALL ChartModel::setTitleObject( const uno::Reference< chart2::XTitle >& xTitle )
+rtl::Reference< Title > ChartModel::getTitleObject2() const
+{
+ MutexGuard aGuard( m_aModelMutex );
+ return m_xTitle;
+}
+
+void SAL_CALL ChartModel::setTitleObject( const uno::Reference< chart2::XTitle >& xNewTitle )
+{
+ rtl::Reference<Title> xTitle = dynamic_cast<Title*>(xNewTitle.get());
+ assert(!xNewTitle || xTitle);
+ setTitleObject(xTitle);
+}
+
+void ChartModel::setTitleObject( const rtl::Reference< Title >& xTitle )
{
{
MutexGuard aGuard( m_aModelMutex );
@@ -969,6 +1027,7 @@ uno::Any SAL_CALL ChartModel::queryInterface( const uno::Type& aType )
// ____ XCloneable ____
Reference< util::XCloneable > SAL_CALL ChartModel::createClone()
{
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
return Reference< util::XCloneable >( new ChartModel( *this ));
}
@@ -1019,12 +1078,11 @@ embed::VisualRepresentation SAL_CALL ChartModel::getPreferredVisualRepresentatio
Sequence< sal_Int8 > aMetafile;
//get view from old api wrapper
- Reference< datatransfer::XTransferable > xTransferable(
- createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
+ Reference< datatransfer::XTransferable > xTransferable( createChartView() );
if( xTransferable.is() )
{
datatransfer::DataFlavor aDataFlavor( lcl_aGDIMetaFileMIMEType,
- "GDIMetaFile",
+ u"GDIMetaFile"_ustr,
cppu::UnoType<uno::Sequence< sal_Int8 >>::get() );
uno::Any aData( xTransferable->getTransferData( aDataFlavor ) );
@@ -1062,8 +1120,7 @@ uno::Any SAL_CALL ChartModel::getTransferData( const datatransfer::DataFlavor& a
try
{
//get view from old api wrapper
- Reference< datatransfer::XTransferable > xTransferable(
- createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
+ Reference< datatransfer::XTransferable > xTransferable( createChartView() );
if( xTransferable.is() &&
xTransferable->isDataFlavorSupported( aFlavor ))
{
@@ -1080,13 +1137,9 @@ uno::Any SAL_CALL ChartModel::getTransferData( const datatransfer::DataFlavor& a
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;
+ return { datatransfer::DataFlavor( lcl_aGDIMetaFileMIMETypeHighContrast,
+ u"GDIMetaFile"_ustr,
+ cppu::UnoType<uno::Sequence< sal_Int8 >>::get() ) };
}
sal_Bool SAL_CALL ChartModel::isDataFlavorSupported( const datatransfer::DataFlavor& aFlavor )
@@ -1147,17 +1200,12 @@ Reference< uno::XInterface > SAL_CALL ChartModel::createInstance( const OUString
}
break;
case SERVICE_NAMESPACE_MAP:
- return Reference< uno::XInterface >( m_xXMLNamespaceMap );
+ return static_cast<cppu::OWeakObject*>(m_xXMLNamespaceMap.get());
}
}
else if(rServiceSpecifier == CHART_VIEW_SERVICE_NAME)
{
- if(!mxChartView.is())
- {
- mxChartView = new ChartView( m_xContext, *this);
- }
-
- return static_cast< ::cppu::OWeakObject* >( mxChartView.get() );
+ return static_cast< ::cppu::OWeakObject* >( createChartView().get() );
}
else
{
@@ -1174,6 +1222,13 @@ Reference< uno::XInterface > SAL_CALL ChartModel::createInstance( const OUString
return nullptr;
}
+const rtl::Reference<ChartView>& ChartModel::createChartView()
+{
+ if(!mxChartView.is())
+ mxChartView = new ChartView( m_xContext, *this);
+ return mxChartView;
+}
+
Reference< uno::XInterface > SAL_CALL ChartModel::createInstanceWithArguments(
const OUString& rServiceSpecifier , const Sequence< Any >& Arguments )
{
@@ -1215,7 +1270,7 @@ Reference< util::XNumberFormatsSupplier > const & ChartModel::getNumberFormatsSu
// ____ XUnoTunnel ___
::sal_Int64 SAL_CALL ChartModel::getSomething( const Sequence< ::sal_Int8 >& aIdentifier )
{
- if( isUnoTunnelId<SvNumberFormatsSupplierObj>(aIdentifier) )
+ if( comphelper::isUnoTunnelId<SvNumberFormatsSupplierObj>(aIdentifier) )
{
Reference< lang::XUnoTunnel > xTunnel( getNumberFormatsSupplier(), uno::UNO_QUERY );
if( xTunnel.is() )
@@ -1250,14 +1305,19 @@ Reference< uno::XInterface > SAL_CALL ChartModel::getParent()
void SAL_CALL ChartModel::setParent( const Reference< uno::XInterface >& Parent )
{
if( Parent != m_xParent )
+ {
+ if (SfxObjectShell* pShell = getParentShell(m_xParent))
+ EndListening(*pShell);
m_xParent.set( Parent, uno::UNO_QUERY );
+ if (SfxObjectShell* pShell = getParentShell(m_xParent))
+ StartListening(*pShell);
+ }
}
// ____ XDataSource ____
uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL ChartModel::getDataSequences()
{
- Reference< chart2::data::XDataSource > xSource(
- DataSourceHelper::getUsedData( uno::Reference< frame::XModel >(this) ) );
+ rtl::Reference< DataSource > xSource = DataSourceHelper::getUsedData( *this );
if( xSource.is())
return xSource->getDataSequences();
@@ -1265,12 +1325,16 @@ uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL ChartM
}
//XDumper
-OUString SAL_CALL ChartModel::dump()
+OUString SAL_CALL ChartModel::dump(OUString const & kind)
{
- uno::Reference< qa::XDumper > xDumper(
- createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY );
+ if (kind.isEmpty()) {
+ return comphelper::dumpXmlToString([this](auto writer) { return dumpAsXml(writer); });
+ }
+
+ // kind == "shapes":
+ uno::Reference< qa::XDumper > xDumper( createChartView() );
if (xDumper.is())
- return xDumper->dump();
+ return xDumper->dump(kind);
return OUString();
}
@@ -1303,6 +1367,238 @@ bool ChartModel::isDataFromPivotTable() const
return xPivotTableDataProvider.is();
}
+rtl::Reference< BaseCoordinateSystem > ChartModel::getFirstCoordinateSystem()
+{
+ if( m_xDiagram )
+ {
+ auto aCooSysSeq( m_xDiagram->getBaseCoordinateSystems() );
+ if( !aCooSysSeq.empty() )
+ return aCooSysSeq[0];
+ }
+ return nullptr;
+}
+
+std::vector< rtl::Reference< DataSeries > > ChartModel::getDataSeries()
+{
+ if( m_xDiagram)
+ return m_xDiagram->getDataSeries();
+
+ return {};
+}
+
+rtl::Reference< ChartType > ChartModel::getChartTypeOfSeries( const rtl::Reference< DataSeries >& xGivenDataSeries )
+{
+ return m_xDiagram ? m_xDiagram->getChartTypeOfSeries( xGivenDataSeries ) : nullptr;
+}
+
+// static
+awt::Size ChartModel::getDefaultPageSize()
+{
+ return awt::Size( 16000, 9000 );
+}
+
+awt::Size ChartModel::getPageSize()
+{
+ return getVisualAreaSize( embed::Aspects::MSOLE_CONTENT );
+}
+
+void ChartModel::triggerRangeHighlighting()
+{
+ getRangeHighlighter();
+ uno::Reference< view::XSelectionChangeListener > xSelectionChangeListener( m_xRangeHighlighter );
+ //trigger selection of cell range
+ lang::EventObject aEvent( xSelectionChangeListener );
+ xSelectionChangeListener->selectionChanged( aEvent );
+}
+
+bool ChartModel::isIncludeHiddenCells()
+{
+ bool bIncluded = true; // hidden cells are included by default.
+
+ if (!m_xDiagram)
+ return bIncluded;
+
+ try
+ {
+ m_xDiagram->getPropertyValue(u"IncludeHiddenCells"_ustr) >>= bIncluded;
+ }
+ catch( const beans::UnknownPropertyException& )
+ {
+ }
+
+ return bIncluded;
+}
+
+bool ChartModel::setIncludeHiddenCells( bool bIncludeHiddenCells )
+{
+ bool bChanged = false;
+ try
+ {
+ ControllerLockGuard aLockedControllers( *this );
+
+ uno::Reference< beans::XPropertySet > xDiagramProperties( getFirstDiagram(), uno::UNO_QUERY );
+ if (!xDiagramProperties)
+ return false;
+
+ bool bOldValue = bIncludeHiddenCells;
+ xDiagramProperties->getPropertyValue( u"IncludeHiddenCells"_ustr ) >>= bOldValue;
+ if( bOldValue == bIncludeHiddenCells )
+ bChanged = true;
+
+ //set the property on all instances in all cases to get the different objects in sync!
+
+ uno::Any aNewValue(bIncludeHiddenCells);
+
+ try
+ {
+ uno::Reference< beans::XPropertySet > xDataProviderProperties( getDataProvider(), uno::UNO_QUERY );
+ if( xDataProviderProperties.is() )
+ xDataProviderProperties->setPropertyValue(u"IncludeHiddenCells"_ustr, aNewValue );
+ }
+ catch( const beans::UnknownPropertyException& )
+ {
+ //the property is optional!
+ }
+
+ try
+ {
+ rtl::Reference< DataSource > xUsedData = DataSourceHelper::getUsedData( *this );
+ if( xUsedData.is() )
+ {
+ uno::Reference< beans::XPropertySet > xProp;
+ const uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aData( xUsedData->getDataSequences());
+ for( uno::Reference< chart2::data::XLabeledDataSequence > const & labeledData : aData )
+ {
+ xProp.set( uno::Reference< beans::XPropertySet >( labeledData->getValues(), uno::UNO_QUERY ) );
+ if(xProp.is())
+ xProp->setPropertyValue(u"IncludeHiddenCells"_ustr, aNewValue );
+ xProp.set( uno::Reference< beans::XPropertySet >( labeledData->getLabel(), uno::UNO_QUERY ) );
+ if(xProp.is())
+ xProp->setPropertyValue(u"IncludeHiddenCells"_ustr, aNewValue );
+ }
+ }
+ }
+ catch( const beans::UnknownPropertyException& )
+ {
+ //the property is optional!
+ }
+
+ xDiagramProperties->setPropertyValue( u"IncludeHiddenCells"_ustr, aNewValue);
+ }
+ catch (const uno::Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "" );
+ }
+ return bChanged;
+}
+
+void ChartModel::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
+{
+ if (rHint.GetId() == SfxHintId::ThemeColorsChanged)
+ {
+ onDocumentThemeChanged();
+ }
+}
+
+std::shared_ptr<model::Theme> ChartModel::getDocumentTheme() const
+{
+ std::shared_ptr<model::Theme> pTheme;
+ uno::Any aThemeValue;
+
+ auto pParent = const_cast<ChartModel*>(this)->getParent();
+ uno::Reference<frame::XModel> xDocModel(pParent, uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDoc(xDocModel, uno::UNO_QUERY);
+
+ if (!xTextDoc.is()) // Calc, Impress
+ {
+ uno::Reference<beans::XPropertySet> xPropSet(xDocModel, uno::UNO_QUERY);
+ if (xPropSet.is())
+ {
+ aThemeValue = xPropSet->getPropertyValue("Theme");
+ }
+ }
+ else // Writer
+ {
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xDocModel, uno::UNO_QUERY);
+ if (xDrawPageSupplier.is())
+ {
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ if (xDrawPage.is())
+ {
+ uno::Reference<beans::XPropertySet> xPropSet(xDrawPage, uno::UNO_QUERY);
+ if (xPropSet.is())
+ {
+ aThemeValue = xPropSet->getPropertyValue("Theme");
+ }
+ }
+ }
+ }
+
+ uno::Reference<util::XTheme> xTheme(aThemeValue, uno::UNO_QUERY);
+ if (xTheme.is())
+ {
+ if (auto* pUnoTheme = dynamic_cast<UnoTheme*>(xTheme.get()))
+ {
+ pTheme = pUnoTheme->getTheme();
+ }
+ }
+ else
+ {
+ pTheme = model::Theme::FromAny(aThemeValue);
+ }
+
+ return pTheme;
+}
+
+void ChartModel::setColorPalette(ChartColorPaletteType eType, sal_uInt32 nIndex)
+{
+ m_eColorPaletteType = eType;
+ m_nColorPaletteIndex = nIndex;
+}
+
+void ChartModel::clearColorPalette() { setColorPalette(ChartColorPaletteType::Unknown, 0); }
+
+bool ChartModel::usesColorPalette() const
+{
+ return m_eColorPaletteType != ChartColorPaletteType::Unknown;
+}
+
+std::optional<ChartColorPalette> ChartModel::getCurrentColorPalette() const
+{
+ if (!usesColorPalette())
+ {
+ SAL_WARN("chart2", "ChartModel::getCurrentColorPalette: no palette is in use");
+ return std::nullopt;
+ }
+
+ const std::shared_ptr<model::Theme> pTheme = getDocumentTheme();
+ // when pTheme is null, ChartColorPaletteHelper uses a default theme
+ const ChartColorPaletteHelper aColorPaletteHelper(pTheme);
+ return aColorPaletteHelper.getColorPalette(getColorPaletteType(), getColorPaletteIndex());
+}
+
+void ChartModel::applyColorPaletteToDataSeries(const ChartColorPalette& rColorPalette)
+{
+ const rtl::Reference<Diagram> xDiagram = getFirstChartDiagram();
+ const auto xDataSeriesArray = xDiagram->getDataSeries();
+ for (size_t i = 0; i < xDataSeriesArray.size(); ++i)
+ {
+ const uno::Reference<beans::XPropertySet> xPropSet = xDataSeriesArray[i];
+ const size_t nPaletteIndex = i % rColorPalette.size();
+ xPropSet->setPropertyValue("FillStyle", uno::Any(drawing::FillStyle_SOLID));
+ xPropSet->setPropertyValue("FillColor", uno::Any(rColorPalette[nPaletteIndex]));
+ }
+}
+
+void ChartModel::onDocumentThemeChanged()
+{
+ if (const auto oColorPalette = getCurrentColorPalette())
+ {
+ applyColorPaletteToDataSeries(*oColorPalette);
+ setModified(true);
+ }
+}
+
} // namespace chart
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index b3dd7a7cfeeb..c819fab153c2 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -21,11 +21,15 @@
#include <ChartModel.hxx>
#include <MediaDescriptorHelper.hxx>
#include <ChartViewHelper.hxx>
-#include <ChartModelHelper.hxx>
+#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
#include <DataSourceHelper.hxx>
#include <AxisHelper.hxx>
#include <ThreeDHelper.hxx>
-#include <DiagramHelper.hxx>
+#include <Diagram.hxx>
+#include <BaseCoordinateSystem.hxx>
+#include <Legend.hxx>
+#include <XMLFilter.hxx>
#include <com/sun/star/chart2/LegendPosition.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
@@ -41,8 +45,6 @@
#include <com/sun/star/io/IOException.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/io/TempFile.hpp>
-#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/ucb/CommandFailedException.hpp>
#include <com/sun/star/ucb/ContentCreationException.hpp>
@@ -50,13 +52,16 @@
#include <ucbhelper/content.hxx>
#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/tempfile.hxx>
+#include <utility>
#include <vcl/cvtgrf.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/storagehelper.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
+#include <sfx2/objsh.hxx>
#include <algorithm>
@@ -68,19 +73,6 @@ 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,
@@ -89,10 +81,9 @@ T lcl_getProperty(
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 )
+ auto pIt = std::find_if(rMediaDescriptor.begin(), rMediaDescriptor.end(),
+ [&rPropName](auto& prop) { return prop.Name == rPropName; });
+ if (pIt != rMediaDescriptor.end())
(*pIt).Value >>= aResult;
}
return aResult;
@@ -103,8 +94,8 @@ void lcl_addStorageToMediaDescriptor(
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 );
+ rOutMD.getArray()[rOutMD.getLength() - 1] = beans::PropertyValue(
+ u"Storage"_ustr, -1, uno::Any( xStorage ), beans::PropertyState_DIRECT_VALUE );
}
Reference< embed::XStorage > lcl_createStorage(
@@ -124,10 +115,9 @@ Reference< embed::XStorage > lcl_createStorage(
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;
+ Sequence< uno::Any > aStorageArgs{ uno::Any(xStream),
+ uno::Any(embed::ElementModes::READWRITE),
+ uno::Any(rMediaDescriptor) };
xStorage.set(
xStorageFact->createInstanceWithArguments( aStorageArgs ), uno::UNO_QUERY_THROW );
}
@@ -155,7 +145,7 @@ Reference< document::XFilter > ChartModel::impl_createFilter(
// find FilterName in MediaDescriptor
OUString aFilterName(
- lcl_getProperty< OUString >( rMediaDescriptor, "FilterName" ) );
+ lcl_getProperty< OUString >( rMediaDescriptor, u"FilterName"_ustr ) );
// if FilterName was found, get Filter from factory
if( !aFilterName.isEmpty() )
@@ -164,7 +154,7 @@ Reference< document::XFilter > ChartModel::impl_createFilter(
{
Reference< container::XNameAccess > xFilterFact(
m_xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.document.FilterFactory", m_xContext ),
+ u"com.sun.star.document.FilterFactory"_ustr, m_xContext ),
uno::UNO_QUERY_THROW );
uno::Any aFilterProps( xFilterFact->getByName( aFilterName ));
Sequence< beans::PropertyValue > aProps;
@@ -173,7 +163,7 @@ Reference< document::XFilter > ChartModel::impl_createFilter(
(aFilterProps >>= aProps))
{
OUString aFilterServiceName(
- lcl_getProperty< OUString >( aProps, "FilterService" ) );
+ lcl_getProperty< OUString >( aProps, u"FilterService"_ustr ) );
if( !aFilterServiceName.isEmpty())
{
@@ -195,10 +185,7 @@ Reference< document::XFilter > ChartModel::impl_createFilter(
if( ! xFilter.is())
{
SAL_WARN("chart2", "No FilterName passed in MediaDescriptor" );
- xFilter.set(
- m_xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.comp.chart2.XMLFilter", m_xContext ),
- uno::UNO_QUERY_THROW );
+ xFilter = new XMLFilter(m_xContext);
}
return xFilter;
@@ -218,7 +205,7 @@ void SAL_CALL ChartModel::storeSelf( const Sequence< beans::PropertyValue >& rMe
// frame::XStorable (base of XStorable2)
sal_Bool SAL_CALL ChartModel::hasLocation()
{
- //@todo guard
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
return !m_aResource.isEmpty();
}
@@ -242,10 +229,10 @@ void SAL_CALL ChartModel::store()
OUString aLocation = m_aResource;
if( aLocation.isEmpty() )
- throw io::IOException( "no location specified", static_cast< ::cppu::OWeakObject* >(this));
+ throw io::IOException( u"no location specified"_ustr, 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));
+ throw io::IOException( u"document is read only"_ustr, static_cast< ::cppu::OWeakObject* >(this));
aGuard.clear();
@@ -262,7 +249,7 @@ void SAL_CALL ChartModel::storeAsURL(
return; //behave passive if already disposed or closed or throw exception @todo?
apphelper::MediaDescriptorHelper aMediaDescriptorHelper(rMediaDescriptor);
- uno::Sequence< beans::PropertyValue > aReducedMediaDescriptor(
+ const uno::Sequence< beans::PropertyValue >& aReducedMediaDescriptor(
aMediaDescriptorHelper.getReducedForModel() );
m_bReadOnly = false;
@@ -290,7 +277,7 @@ void SAL_CALL ChartModel::storeToURL(
aGuard.clear();
apphelper::MediaDescriptorHelper aMediaDescriptorHelper(rMediaDescriptor);
- uno::Sequence< beans::PropertyValue > aReducedMediaDescriptor(
+ const uno::Sequence< beans::PropertyValue >& aReducedMediaDescriptor(
aMediaDescriptorHelper.getReducedForModel() );
if ( rURL == "private:stream" )
@@ -299,8 +286,7 @@ void SAL_CALL ChartModel::storeToURL(
{
if( m_xContext.is() && aMediaDescriptorHelper.ISSET_OutputStream )
{
- Reference< io::XStream > xStream(
- io::TempFile::create(m_xContext), uno::UNO_QUERY_THROW );
+ rtl::Reference< utl::TempFileFastService > xStream = new utl::TempFileFastService;
Reference< io::XInputStream > xInputStream( xStream->getInputStream());
Reference< embed::XStorage > xStorage(
@@ -309,8 +295,7 @@ void SAL_CALL ChartModel::storeToURL(
{
impl_store( aReducedMediaDescriptor, xStorage );
- Reference< io::XSeekable > xSeekable( xStream, uno::UNO_QUERY_THROW );
- xSeekable->seek( 0 );
+ xStream->seek( 0 );
::comphelper::OStorageHelper::CopyInputToOutput( xInputStream, aMediaDescriptorHelper.OutputStream );
}
}
@@ -362,14 +347,14 @@ void ChartModel::impl_store(
//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()) )
+ if ( hasInternalDataProvider() || !xPropSet.is() )
return;
apphelper::MediaDescriptorHelper aMDHelper(rMediaDescriptor);
try
{
xPropSet->setPropertyValue(
- "SavedObject",
+ u"SavedObject"_ustr,
uno::Any( aMDHelper.HierarchicalDocumentName ) );
}
catch ( const uno::Exception& )
@@ -384,7 +369,7 @@ void ChartModel::insertDefaultChart()
try
{
// create default chart
- Reference< chart2::XChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() );
+ rtl::Reference< ::chart::ChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() );
if( xTemplate.is())
{
try
@@ -395,12 +380,11 @@ void ChartModel::insertDefaultChart()
bool bSupportsCategories = xTemplate->supportsCategories();
if( bSupportsCategories )
{
- aParam.realloc( 1 );
- aParam[0] = beans::PropertyValue( "HasCategories", -1, uno::Any( true ),
- beans::PropertyState_DIRECT_VALUE );
+ aParam = { beans::PropertyValue( u"HasCategories"_ustr, -1, uno::Any( true ),
+ beans::PropertyState_DIRECT_VALUE ) };
}
- Reference< chart2::XDiagram > xDiagram( xTemplate->createDiagramByDataSource( xDataSource, aParam ) );
+ rtl::Reference< Diagram > xDiagram( xTemplate->createDiagramByDataSource2( xDataSource, aParam ) );
setFirstDiagram( xDiagram );
@@ -410,50 +394,39 @@ void ChartModel::insertDefaultChart()
AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
// create and attach legend
- Reference< chart2::XLegend > xLegend(
- m_xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.chart2.Legend", m_xContext ), uno::UNO_QUERY_THROW );
- Reference< beans::XPropertySet > xLegendProperties( xLegend, uno::UNO_QUERY );
- if( xLegendProperties.is() )
- {
- xLegendProperties->setPropertyValue( "FillStyle", uno::Any( drawing::FillStyle_NONE ));
- xLegendProperties->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE ));
- xLegendProperties->setPropertyValue( "LineColor", uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) )); // gray30
- xLegendProperties->setPropertyValue( "FillColor", uno::Any( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
+ rtl::Reference< Legend > xLegend = new Legend();
+ xLegend->setPropertyValue( u"FillStyle"_ustr, uno::Any( drawing::FillStyle_NONE ));
+ xLegend->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_NONE ));
+ xLegend->setPropertyValue( u"LineColor"_ustr, uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) )); // gray30
+ xLegend->setPropertyValue( u"FillColor"_ustr, uno::Any( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
- if( bIsRTL )
- xLegendProperties->setPropertyValue( "AnchorPosition", uno::Any( chart2::LegendPosition_LINE_START ));
- }
+ if( bIsRTL )
+ xLegend->setPropertyValue( u"AnchorPosition"_ustr, 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 simple 3D look
+ xDiagram->setPropertyValue( u"RightAngledAxes"_ustr, uno::Any( true ));
+ xDiagram->setPropertyValue( u"D3DScenePerspective"_ustr, uno::Any( drawing::ProjectionMode_PARALLEL ));
+ xDiagram->setScheme( ThreeDLookScheme::ThreeDLookScheme_Realistic );
- //set some new 'defaults' for wall and floor
- if( xDiagram.is() )
- {
+ //set some new 'defaults' for wall and floor
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
+ xWall->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_SOLID ) );
+ xWall->setPropertyValue( u"FillStyle"_ustr, uno::Any( drawing::FillStyle_NONE ) );
+ xWall->setPropertyValue( u"LineColor"_ustr, uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
+ xWall->setPropertyValue( u"FillColor"_ustr, 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
+ xFloor->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) );
+ xFloor->setPropertyValue( u"FillStyle"_ustr, uno::Any( drawing::FillStyle_SOLID ) );
+ xFloor->setPropertyValue( u"LineColor"_ustr, uno::Any( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
+ xFloor->setPropertyValue( u"FillColor"_ustr, uno::Any( static_cast< sal_Int32 >( 0xcccccc ) ) ); // gray20
}
}
@@ -463,7 +436,7 @@ void ChartModel::insertDefaultChart()
DBG_UNHANDLED_EXCEPTION("chart2");
}
}
- ChartModelHelper::setIncludeHiddenCells( false, *this );
+ setIncludeHiddenCells( false );
}
catch( const uno::Exception & )
{
@@ -509,10 +482,9 @@ void SAL_CALL ChartModel::load(
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);
+ Sequence< uno::Any > aStorageArgs{ uno::Any(aMDHelper.Stream),
+ // todo: check if stream is read-only
+ uno::Any(embed::ElementModes::READ) }; //WRITE | embed::ElementModes::NOCREATE);
xStorage.set( xStorageFact->createInstanceWithArguments( aStorageArgs ),
uno::UNO_QUERY_THROW );
@@ -521,9 +493,8 @@ void SAL_CALL ChartModel::load(
{
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;
+ Sequence< uno::Any > aStorageArgs{ uno::Any(aMDHelper.InputStream),
+ uno::Any(embed::ElementModes::READ) };
xStorage.set( xStorageFact->createInstanceWithArguments( aStorageArgs ),
uno::UNO_QUERY_THROW );
@@ -591,8 +562,8 @@ void ChartModel::impl_loadGraphics(
{
try
{
- const Reference< embed::XStorage >& xGraphicsStorage(
- xStorage->openStorageElement( "Pictures",
+ const Reference< embed::XStorage > xGraphicsStorage(
+ xStorage->openStorageElement( u"Pictures"_ustr,
embed::ElementModes::READ ) );
if( xGraphicsStorage.is() )
@@ -645,18 +616,11 @@ void ChartModel::impl_notifyModifiedListeners()
//always notify the view first!
ChartViewHelper::setViewToDirtyState( this );
- ::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer
- .getContainer( cppu::UnoType<util::XModifyListener>::get());
- if( pIC )
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ if( m_aLifeTimeManager.m_aModifyListeners.getLength(aGuard) )
{
lang::EventObject aEvent( static_cast< lang::XComponent*>(this) );
- ::cppu::OInterfaceIteratorHelper aIt( *pIC );
- while( aIt.hasMoreElements() )
- {
- uno::Reference< util::XModifyListener > xListener( aIt.next(), uno::UNO_QUERY );
- if( xListener.is() )
- xListener->modified( aEvent );
- }
+ m_aLifeTimeManager.m_aModifyListeners.notifyEach(aGuard, &util::XModifyListener::modified, aEvent);
}
}
@@ -668,6 +632,16 @@ sal_Bool SAL_CALL ChartModel::isModified()
void SAL_CALL ChartModel::setModified( sal_Bool bModified )
{
+ // tdf#141914: allow to set *unmodified* when parent does not allow to set modified
+ if (bModified)
+ {
+ // tdf#77007: honor parent's IsEnableSetModified
+ // Check it before LifeTimeGuard, to avoid deadlocking solar mutex and this guard
+ if (auto pParentShell = SfxObjectShell::GetShellFromComponent(getParent());
+ pParentShell && !pParentShell->IsEnableSetModified())
+ return;
+ }
+
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?
@@ -675,7 +649,8 @@ void SAL_CALL ChartModel::setModified( sal_Bool bModified )
if( m_nControllerLockCount > 0 )
{
- m_bUpdateNotificationsPending = true;
+ if (bModified)
+ m_bUpdateNotificationsPending = true; // Maybe !bModified should reset it?
return;//don't call listeners if controllers are locked
}
aGuard.clear();
@@ -691,8 +666,8 @@ void SAL_CALL ChartModel::addModifyListener(
if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.addInterface(
- cppu::UnoType<util::XModifyListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aModifyListeners.addInterface( aGuard, xListener );
}
void SAL_CALL ChartModel::removeModifyListener(
@@ -701,8 +676,8 @@ void SAL_CALL ChartModel::removeModifyListener(
if( m_aLifeTimeManager.impl_isDisposedOrClosed(false) )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.removeInterface(
- cppu::UnoType<util::XModifyListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aModifyListeners.removeInterface( aGuard, xListener );
}
// util::XModifyListener
@@ -716,15 +691,14 @@ void SAL_CALL ChartModel::modified( const lang::EventObject& rEvenObject)
try
{
uno::Sequence<beans::PropertyValue> aArguments =
- DataSourceHelper::createArguments("PivotChart", uno::Sequence<sal_Int32>(), true, true, true);
+ DataSourceHelper::createArguments(u"PivotChart"_ustr, uno::Sequence<sal_Int32>(), true, true, true);
Reference<chart2::data::XDataSource> xDataSource(xDataProvider->createDataSource(aArguments));
- Reference<lang::XMultiServiceFactory> xFactory(getChartTypeManager(), uno::UNO_QUERY);
- Reference<chart2::XDiagram> xDiagram(getFirstDiagram());
+ rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = getTypeManager();
+ rtl::Reference<Diagram> xDiagram(getFirstChartDiagram());
- DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram(xDiagram, xFactory);
- css::uno::Reference<css::chart2::XChartTypeTemplate> xChartTypeTemplate(aTemplateAndService.first);
- xChartTypeTemplate->changeDiagramData(xDiagram, xDataSource, aArguments);
+ Diagram::tTemplateWithServiceName aTemplateAndService = xDiagram->getTemplate(xChartTypeManager);
+ aTemplateAndService.xChartTypeTemplate->changeDiagramData(xDiagram, xDataSource, aArguments);
}
catch (const uno::Exception &)
{
@@ -772,17 +746,14 @@ Reference< embed::XStorage > SAL_CALL ChartModel::getDocumentStorage()
void ChartModel::impl_notifyStorageChangeListeners()
{
- ::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer
- .getContainer( cppu::UnoType<document::XStorageChangeListener>::get());
- if( pIC )
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ if( m_aLifeTimeManager.m_aStorageChangeListeners.getLength(aGuard) )
{
- ::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 );
- }
+ m_aLifeTimeManager.m_aStorageChangeListeners.forEach(aGuard,
+ [this](const uno::Reference<document::XStorageChangeListener>& l)
+ {
+ l->notifyStorageChange( static_cast< ::cppu::OWeakObject* >( this ), m_xStorage );
+ });
}
}
@@ -791,8 +762,8 @@ void SAL_CALL ChartModel::addStorageChangeListener( const Reference< document::X
if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.addInterface(
- cppu::UnoType<document::XStorageChangeListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aStorageChangeListeners.addInterface( aGuard, xListener );
}
void SAL_CALL ChartModel::removeStorageChangeListener( const Reference< document::XStorageChangeListener >& xListener )
@@ -800,8 +771,8 @@ void SAL_CALL ChartModel::removeStorageChangeListener( const Reference< document
if( m_aLifeTimeManager.impl_isDisposedOrClosed(false) )
return; //behave passive if already disposed or closed
- m_aLifeTimeManager.m_aListenerContainer.removeInterface(
- cppu::UnoType<document::XStorageChangeListener>::get(), xListener );
+ std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aStorageChangeListeners.removeInterface(aGuard, xListener );
}
} // namespace chart
diff --git a/chart2/source/model/main/DataPoint.cxx b/chart2/source/model/main/DataPoint.cxx
index 6e9f6d483ccc..3e224d6523de 100644
--- a/chart2/source/model/main/DataPoint.cxx
+++ b/chart2/source/model/main/DataPoint.cxx
@@ -26,7 +26,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -39,45 +39,21 @@ using ::com::sun::star::beans::Property;
namespace
{
-struct StaticDataPointInfoHelper_Initializer
+::cppu::OPropertyArrayHelper& StaticDataPointInfoHelper()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- ::chart::DataPointProperties::AddPropertiesToVector( aProperties );
- ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::DataPointProperties::AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-struct StaticDataPointInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDataPointInfoHelper_Initializer >
-{
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticDataPointInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDataPointInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticDataPointInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticDataPointInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -86,9 +62,8 @@ namespace chart
{
DataPoint::DataPoint( const uno::Reference< beans::XPropertySet > & rParentProperties ) :
- ::property::OPropertySet( m_aMutex ),
m_xParentProperties( rParentProperties ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_bNoParentPropAllowed( false )
{
SetNewValuesExplicitlyEvenIfTheyEqualDefault();
@@ -96,8 +71,8 @@ DataPoint::DataPoint( const uno::Reference< beans::XPropertySet > & rParentPrope
DataPoint::DataPoint( const DataPoint & rOther ) :
impl::DataPoint_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_bNoParentPropAllowed( true )
{
SetNewValuesExplicitlyEvenIfTheyEqualDefault();
@@ -165,17 +140,18 @@ void SAL_CALL DataPoint::setParent(
}
// ____ OPropertySet ____
-uno::Any DataPoint::GetDefaultValue( sal_Int32 nHandle ) const
+void DataPoint::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
// the value set at the data series is the default
uno::Reference< beans::XFastPropertySet > xFast( m_xParentProperties.get(), uno::UNO_QUERY );
if( !xFast.is())
{
OSL_ENSURE( m_bNoParentPropAllowed, "data point needs a parent property set to provide values correctly" );
- return uno::Any();
+ rAny.clear();
+ return;
}
- return xFast->getFastPropertyValue( nHandle );
+ rAny = xFast->getFastPropertyValue( nHandle );
}
void SAL_CALL DataPoint::setFastPropertyValue_NoBroadcast(
@@ -194,7 +170,7 @@ void SAL_CALL DataPoint::setFastPropertyValue_NoBroadcast(
ModifyListenerHelper::removeListener( xBroadcaster, m_xModifyEventForwarder );
}
- OSL_ASSERT( rValue.getValueType().getTypeClass() == uno::TypeClass_INTERFACE );
+ OSL_ASSERT( rValue.getValueTypeClass() == uno::TypeClass_INTERFACE );
if( rValue.hasValue() &&
(rValue >>= xBroadcaster) &&
xBroadcaster.is())
@@ -208,40 +184,26 @@ void SAL_CALL DataPoint::setFastPropertyValue_NoBroadcast(
::cppu::IPropertyArrayHelper & SAL_CALL DataPoint::getInfoHelper()
{
- return *StaticDataPointInfoHelper::get();
+ return StaticDataPointInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL DataPoint::getPropertySetInfo()
{
- return *StaticDataPointInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDataPointInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XModifyBroadcaster ____
void SAL_CALL DataPoint::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL DataPoint::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -270,7 +232,7 @@ IMPLEMENT_FORWARD_XINTERFACE2( DataPoint, DataPoint_Base, ::property::OPropertyS
// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
OUString SAL_CALL DataPoint::getImplementationName()
{
- return "com.sun.star.comp.chart.DataPoint" ;
+ return u"com.sun.star.comp.chart.DataPoint"_ustr ;
}
sal_Bool SAL_CALL DataPoint::supportsService( const OUString& rServiceName )
@@ -281,10 +243,10 @@ sal_Bool SAL_CALL DataPoint::supportsService( const OUString& 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"
+ u"com.sun.star.drawing.FillProperties"_ustr,
+ u"com.sun.star.chart2.DataPoint"_ustr,
+ u"com.sun.star.chart2.DataPointProperties"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr
};
}
diff --git a/chart2/source/model/main/DataPoint.hxx b/chart2/source/model/main/DataPoint.hxx
index de3e5020387c..ba94449fff94 100644
--- a/chart2/source/model/main/DataPoint.hxx
+++ b/chart2/source/model/main/DataPoint.hxx
@@ -16,20 +16,17 @@
* 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
+#pragma once
#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>
+#include <ModifyListenerHelper.hxx>
namespace chart
{
@@ -46,7 +43,6 @@ typedef ::cppu::WeakImplHelper<
}
class DataPoint final :
- public MutexContainer,
public impl::DataPoint_Base,
public ::property::OPropertySet
{
@@ -65,7 +61,7 @@ private:
explicit DataPoint( const DataPoint & rOther );
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
virtual void SAL_CALL setFastPropertyValue_NoBroadcast
( sal_Int32 nHandle,
@@ -104,13 +100,10 @@ private:
css::uno::WeakReference< css::beans::XPropertySet > m_xParentProperties;
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
+ rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder;
bool m_bNoParentPropAllowed;
};
} // 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
index 7bc20bbc30e6..53f88600214f 100644
--- a/chart2/source/model/main/DataPointProperties.cxx
+++ b/chart2/source/model/main/DataPointProperties.cxx
@@ -26,14 +26,18 @@
#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/RelativeSize.hpp>
#include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
#include <com/sun/star/chart2/DataPointGeometry3D.hpp>
#include <com/sun/star/chart2/DataPointLabel.hpp>
#include <com/sun/star/chart2/Symbol.hpp>
+#include <tools/color.hxx>
+
using namespace ::com::sun::star;
using ::com::sun::star::beans::Property;
@@ -220,6 +224,12 @@ void DataPointProperties::AddPropertiesToVector(
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",
@@ -330,6 +340,12 @@ void DataPointProperties::AddPropertiesToVector(
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "InvertNegative",
+ PROP_DATAPOINT_INVERT_NEGATIVE,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
// statistics
rOutProperties.emplace_back( CHART_UNONAME_ERRORBAR_X,
PROP_DATAPOINT_ERROR_BAR_X,
@@ -438,13 +454,18 @@ void DataPointProperties::AddPropertiesToVector(
cppu::UnoType<chart2::RelativePosition>::get(),
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEVOID );
+
+ rOutProperties.emplace_back("CustomLabelSize", PROP_DATAPOINT_LABEL_CUSTOM_SIZE,
+ cppu::UnoType<chart2::RelativeSize>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEVOID);
}
void DataPointProperties::AddDefaultsToMap(
::chart::tPropertyValueMap & rOutMap )
{
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DATAPOINT_COLOR, 0x0099ccff ); // blue 8
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_DATAPOINT_TRANSPARENCY, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_COLOR, Color(0x99, 0xcc, 0xff) ); // blue 8
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_TRANSPARENCY, sal_Int16(0) );
//fill
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_FILL_STYLE, drawing::FillStyle_SOLID );
@@ -455,28 +476,29 @@ void DataPointProperties::AddDefaultsToMap(
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_FILL_BACKGROUND, false );
//border
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DATAPOINT_BORDER_COLOR, 0x000000 ); // black
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_BORDER_COLOR, COL_BLACK );
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_BORDER_STYLE, drawing::LineStyle_SOLID ); // drawing::LineStyle_NONE
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DATAPOINT_BORDER_WIDTH, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_BORDER_WIDTH, sal_Int32(0) );
PropertyHelper::setEmptyPropertyValueDefault( rOutMap, PROP_DATAPOINT_BORDER_DASH_NAME );
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_DATAPOINT_BORDER_TRANSPARENCY, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_BORDER_TRANSPARENCY, sal_Int16(0) );
//line
PropertyHelper::setPropertyValueDefault( rOutMap, LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_SOLID );
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, LinePropertiesHelper::PROP_LINE_WIDTH, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, LinePropertiesHelper::PROP_LINE_WIDTH, sal_Int32(0) );
PropertyHelper::setPropertyValueDefault( rOutMap, LinePropertiesHelper::PROP_LINE_DASH, drawing::LineDash());
PropertyHelper::setEmptyPropertyValueDefault( rOutMap, LinePropertiesHelper::PROP_LINE_DASH_NAME );
+ PropertyHelper::setPropertyValueDefault( rOutMap, LinePropertiesHelper::PROP_LINE_CAP, drawing::LineCap_BUTT);
//fill bitmap
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETX, 0 );
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETY, 0 );
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETX, 0 );
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETY, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETX, sal_Int16(0) );
+ PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETY, sal_Int16(0) );
+ PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETX, sal_Int16(0) );
+ PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETY, sal_Int16(0) );
PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_RECTANGLEPOINT, drawing::RectanglePoint_MIDDLE_MIDDLE );
PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_LOGICALSIZE, true );
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEX, 0 );
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEY, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEX, sal_Int32(0) );
+ PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEY, sal_Int32(0) );
PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_MODE, drawing::BitmapMode_REPEAT );
//others
@@ -484,19 +506,20 @@ void DataPointProperties::AddDefaultsToMap(
aSymbProp.Style = chart2::SymbolStyle_NONE;
aSymbProp.StandardSymbol = 0;
aSymbProp.Size = awt::Size( 250, 250 ); // ca. 7pt x 7pt (7pt=246.94)
- aSymbProp.BorderColor = 0x000000; // Black
+ aSymbProp.BorderColor = sal_Int32(COL_BLACK);
aSymbProp.FillColor = 0xee4000; // OrangeRed2
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_SYMBOL_PROP, aSymbProp );
- PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_DATAPOINT_OFFSET, 0.0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_OFFSET, 0.0 );
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_GEOMETRY3D, chart2::DataPointGeometry3D::CUBOID );
//@todo maybe choose a different one here -> should be dynamically that of the attached axis
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_ERROR_BAR_X, uno::Reference< beans::XPropertySet >());
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_ERROR_BAR_Y, uno::Reference< beans::XPropertySet >());
- PropertyHelper::setPropertyValueDefault< sal_Int16 >( rOutMap, PROP_DATAPOINT_PERCENT_DIAGONAL, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_PERCENT_DIAGONAL, sal_Int16(0) );
- PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_DATAPOINT_TEXT_ROTATION, 0.0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_TEXT_ROTATION, 0.0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_INVERT_NEGATIVE, false );
PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LINK_NUMBERFORMAT_TO_SOURCE, true);
@@ -507,21 +530,23 @@ void DataPointProperties::AddDefaultsToMap(
false, // ShowNumber
false, // ShowNumberInPercent
false, // ShowCategoryName
- false // ShowLegendSymbol
+ false, // ShowLegendSymbol
+ false, // ShowCustomLabel
+ false // ShowSeriesName
));
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_TEXT_WORD_WRAP, false );
- PropertyHelper::setPropertyValueDefault< OUString >( rOutMap, PROP_DATAPOINT_LABEL_SEPARATOR, " " );
- PropertyHelper::setPropertyValueDefault<sal_Int32>(rOutMap, PROP_DATAPOINT_LABEL_BORDER_STYLE, sal_Int32(drawing::LineStyle_NONE));
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATAPOINT_LABEL_SEPARATOR, u" "_ustr );
+ PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_STYLE, drawing::LineStyle_NONE);
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_COLOR);
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_FILL_STYLE);
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_FILL_COLOR);
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_FILL_BACKGROUND);
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_FILL_HATCH_NAME);
- PropertyHelper::setPropertyValueDefault<sal_Int32>(rOutMap, PROP_DATAPOINT_LABEL_BORDER_WIDTH, 0);
+ PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_WIDTH, sal_Int32(0));
PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_DASH, drawing::LineDash());
PropertyHelper::setEmptyPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_DASH_NAME);
- PropertyHelper::setPropertyValueDefault<sal_Int16>(rOutMap, PROP_DATAPOINT_LABEL_BORDER_TRANS, 0);
+ PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_LABEL_BORDER_TRANS, sal_Int16(0));
uno::Sequence<uno::Reference<chart2::XDataPointCustomLabelField>> aFields(0);
PropertyHelper::setPropertyValueDefault(rOutMap, PROP_DATAPOINT_CUSTOM_LABEL_FIELDS, aFields);
diff --git a/chart2/source/model/main/DataPointProperties.hxx b/chart2/source/model/main/DataPointProperties.hxx
index 1998c4e20369..fe1969bc5f15 100644
--- a/chart2/source/model/main/DataPointProperties.hxx
+++ b/chart2/source/model/main/DataPointProperties.hxx
@@ -16,8 +16,7 @@
* 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
+#pragma once
#include <PropertyHelper.hxx>
#include <FastPropertyIdRanges.hxx>
@@ -70,6 +69,7 @@ namespace DataPointProperties
PROP_DATAPOINT_LABEL_PLACEMENT,
PROP_DATAPOINT_REFERENCE_DIAGRAM_SIZE,
PROP_DATAPOINT_TEXT_ROTATION,
+ PROP_DATAPOINT_INVERT_NEGATIVE,
// statistics
PROP_DATAPOINT_ERROR_BAR_X,
@@ -88,7 +88,8 @@ namespace DataPointProperties
PROP_DATAPOINT_LABEL_BORDER_DASH_NAME,
PROP_DATAPOINT_LABEL_BORDER_TRANS,
PROP_DATAPOINT_CUSTOM_LABEL_FIELDS,
- PROP_DATAPOINT_LABEL_CUSTOM_POS
+ PROP_DATAPOINT_LABEL_CUSTOM_POS,
+ PROP_DATAPOINT_LABEL_CUSTOM_SIZE
// additionally some properties from ::chart::LineProperties
};
@@ -101,7 +102,4 @@ namespace DataPointProperties
} // 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
index 5c0ded40cda7..a9843f1d423d 100644
--- a/chart2/source/model/main/DataSeries.cxx
+++ b/chart2/source/model/main/DataSeries.cxx
@@ -18,19 +18,26 @@
*/
#include <DataSeries.hxx>
-#include "DataSeriesProperties.hxx"
+#include <DataSeriesProperties.hxx>
#include "DataPointProperties.hxx"
#include <CharacterProperties.hxx>
#include <UserDefinedProperties.hxx>
#include "DataPoint.hxx"
#include <DataSeriesHelper.hxx>
#include <CloneHelper.hxx>
+#include <RegressionCurveModel.hxx>
#include <ModifyListenerHelper.hxx>
-#include <EventListenerHelper.hxx>
+#include <unonames.hxx>
+#include <com/sun/star/chart2/DataPointLabel.hpp>
+#include <com/sun/star/chart2/Symbol.hpp>
+#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <rtl/ref.hxx>
+#include <rtl/ustrbuf.hxx>
#include <algorithm>
@@ -43,46 +50,43 @@ using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Reference;
using ::osl::MutexGuard;
-namespace
+namespace chart
{
-
-struct StaticDataSeriesDefaults : public rtl::StaticWithInit< ::chart::tPropertyValueMap, StaticDataSeriesDefaults >
+const ::chart::tPropertyValueMap & StaticDataSeriesDefaults()
{
- ::chart::tPropertyValueMap operator()()
- {
- ::chart::tPropertyValueMap aStaticDefaults;
- ::chart::DataSeriesProperties::AddDefaultsToMap( aStaticDefaults );
- ::chart::CharacterProperties::AddDefaultsToMap( aStaticDefaults );
- float fDefaultCharHeight = 10.0;
- ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( aStaticDefaults, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
- return aStaticDefaults;
- }
+ static const ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aMap;
+ ::chart::DataSeriesProperties::AddDefaultsToMap( aMap );
+ ::chart::CharacterProperties::AddDefaultsToMap( aMap );
+ float fDefaultCharHeight = 10.0;
+ ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
+ return aMap;
+ }();
+ return aStaticDefaults;
};
+} // namespace chart
-struct StaticDataSeriesInfoHelper : public rtl::StaticWithInit< ::cppu::OPropertyArrayHelper, StaticDataSeriesInfoHelper, StaticDataSeriesInfoHelper, uno::Sequence< Property > >
+namespace
{
- uno::Sequence< Property > operator()()
- {
- std::vector< css::beans::Property > aProperties;
- ::chart::DataSeriesProperties::AddPropertiesToVector( aProperties );
- ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
+::cppu::OPropertyArrayHelper& StaticDataSeriesInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper oHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::DataSeriesProperties::AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
- return comphelper::containerToSequence( aProperties );
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticDataSeriesInfo : public rtl::StaticWithInit< uno::Reference< beans::XPropertySetInfo >, StaticDataSeriesInfo >
-{
- uno::Reference< beans::XPropertySetInfo > operator()()
- {
- return ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDataSeriesInfoHelper::get() );
- }
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return oHelper;
};
void lcl_SetParent(
@@ -126,24 +130,22 @@ namespace chart
{
DataSeries::DataSeries() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
}
DataSeries::DataSeries( const DataSeries & rOther ) :
impl::DataSeries_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
if( ! rOther.m_aDataSequences.empty())
{
- CloneHelper::CloneRefVector<css::chart2::data::XLabeledDataSequence>(
- rOther.m_aDataSequences, m_aDataSequences );
+ CloneHelper::CloneRefVector(rOther.m_aDataSequences, m_aDataSequences );
ModifyListenerHelper::addListenerToAllElements( m_aDataSequences, m_xModifyEventForwarder );
}
- CloneHelper::CloneRefVector< chart2::XRegressionCurve >( rOther.m_aRegressionCurves, m_aRegressionCurves );
+ CloneHelper::CloneRefVector( rOther.m_aRegressionCurves, m_aRegressionCurves );
ModifyListenerHelper::addListenerToAllElements( m_aRegressionCurves, m_xModifyEventForwarder );
// add as listener to XPropertySet properties
@@ -164,9 +166,6 @@ DataSeries::DataSeries( const DataSeries & rOther ) :
// late initialization to call after copy-constructing
void DataSeries::Init( const DataSeries & rOther )
{
- if( ! rOther.m_aDataSequences.empty())
- EventListenerHelper::addListenerToAllElements( m_aDataSequences, this );
-
Reference< uno::XInterface > xThisInterface( static_cast< ::cppu::OWeakObject * >( this ));
if( ! rOther.m_aAttributedDataPoints.empty())
{
@@ -221,35 +220,36 @@ DataSeries::~DataSeries()
// ____ 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 );
+ rtl::Reference<DataSeries> pNewSeries( new DataSeries( *this ));
// do initialization that uses uno references to the clone
pNewSeries->Init( *this );
- return xResult;
+ return pNewSeries;
}
// ____ OPropertySet ____
-uno::Any DataSeries::GetDefaultValue( sal_Int32 nHandle ) const
+void DataSeries::GetDefaultValue( sal_Int32 nHandle, uno::Any& rDest ) const
{
- const tPropertyValueMap& rStaticDefaults = StaticDataSeriesDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticDataSeriesDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rDest.clear();
+ else
+ rDest = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL DataSeries::getInfoHelper()
{
- return StaticDataSeriesInfoHelper::get();
+ return StaticDataSeriesInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL DataSeries::getPropertySetInfo()
{
- return StaticDataSeriesInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropSetInfo =
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDataSeriesInfoHelper() );
+ return xPropSetInfo;
}
void SAL_CALL DataSeries::getFastPropertyValue
@@ -283,7 +283,7 @@ void SAL_CALL DataSeries::setFastPropertyValue_NoBroadcast(
ModifyListenerHelper::removeListener( xBroadcaster, m_xModifyEventForwarder );
}
- OSL_ASSERT( rValue.getValueType().getTypeClass() == uno::TypeClass_INTERFACE );
+ OSL_ASSERT( rValue.getValueTypeClass() == uno::TypeClass_INTERFACE );
if( rValue.hasValue() &&
(rValue >>= xBroadcaster) &&
xBroadcaster.is())
@@ -300,14 +300,14 @@ Reference< beans::XPropertySet >
{
Reference< beans::XPropertySet > xResult;
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences;
{
MutexGuard aGuard( m_aMutex );
- aSequences = comphelper::containerToSequence( m_aDataSequences );
+ aSequences = m_aDataSequences;
}
- std::vector< Reference< chart2::data::XLabeledDataSequence > > aValuesSeries(
- DataSeriesHelper::getAllDataSequencesByRole( aSequences , "values" ) );
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aValuesSeries(
+ DataSeriesHelper::getAllDataSequencesByRole( aSequences , u"values"_ustr ) );
if (aValuesSeries.empty())
throw lang::IndexOutOfBoundsException();
@@ -324,7 +324,7 @@ Reference< beans::XPropertySet >
if( !xResult.is() )
{
Reference< beans::XPropertySet > xParentProperties;
- Reference< util::XModifyListener > xModifyEventForwarder;
+ rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
{
MutexGuard aGuard( m_aMutex );
xParentProperties = this;
@@ -347,7 +347,7 @@ Reference< beans::XPropertySet >
void SAL_CALL DataSeries::resetDataPoint( sal_Int32 nIndex )
{
Reference< beans::XPropertySet > xDataPointProp;
- Reference< util::XModifyListener > xModifyEventForwarder;
+ rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
{
MutexGuard aGuard( m_aMutex );
xModifyEventForwarder = m_xModifyEventForwarder;
@@ -371,7 +371,7 @@ void SAL_CALL DataSeries::resetDataPoint( sal_Int32 nIndex )
void SAL_CALL DataSeries::resetAllDataPoints()
{
tDataPointAttributeContainer aOldAttributedDataPoints;
- Reference< util::XModifyListener > xModifyEventForwarder;
+ rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
{
MutexGuard aGuard( m_aMutex );
xModifyEventForwarder = m_xModifyEventForwarder;
@@ -387,44 +387,67 @@ void SAL_CALL DataSeries::setData( const uno::Sequence< Reference< chart2::data:
{
tDataSequenceContainer aOldDataSequences;
tDataSequenceContainer aNewDataSequences;
- Reference< util::XModifyListener > xModifyEventForwarder;
- Reference< lang::XEventListener > xListener;
+ rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
{
MutexGuard aGuard( m_aMutex );
xModifyEventForwarder = m_xModifyEventForwarder;
- xListener = this;
std::swap( aOldDataSequences, m_aDataSequences );
- aNewDataSequences = comphelper::sequenceToContainer<tDataSequenceContainer>( aData );
+ for (const auto & i : aData)
+ {
+ aNewDataSequences.push_back(i);
+ }
m_aDataSequences = aNewDataSequences;
}
ModifyListenerHelper::removeListenerFromAllElements( aOldDataSequences, xModifyEventForwarder );
- EventListenerHelper::removeListenerFromAllElements( aOldDataSequences, xListener );
- EventListenerHelper::addListenerToAllElements( aNewDataSequences, xListener );
ModifyListenerHelper::addListenerToAllElements( aNewDataSequences, xModifyEventForwarder );
fireModifyEvent();
}
+void DataSeries::setData( const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > >& aData )
+{
+ tDataSequenceContainer aOldDataSequences;
+ tDataSequenceContainer aNewDataSequences;
+ rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
+ {
+ MutexGuard aGuard( m_aMutex );
+ xModifyEventForwarder = m_xModifyEventForwarder;
+ std::swap( aOldDataSequences, m_aDataSequences );
+ aNewDataSequences = aData;
+ m_aDataSequences = aNewDataSequences;
+ }
+ ModifyListenerHelper::removeListenerFromAllElements( aOldDataSequences, xModifyEventForwarder );
+ ModifyListenerHelper::addListenerToAllElements( aNewDataSequences, xModifyEventForwarder );
+ fireModifyEvent();
+}
+
+void DataSeries::addDataSequence(css::uno::Reference<css::chart2::data::XLabeledDataSequence> const& rSequence)
+{
+ m_aDataSequences.push_back(rSequence);
+}
+
// ____ XDataSource ____
Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL DataSeries::getDataSequences()
{
MutexGuard aGuard( m_aMutex );
- return comphelper::containerToSequence( m_aDataSequences );
+ return comphelper::containerToSequence<Reference< chart2::data::XLabeledDataSequence >>( m_aDataSequences );
}
// ____ XRegressionCurveContainer ____
void SAL_CALL DataSeries::addRegressionCurve(
const uno::Reference< chart2::XRegressionCurve >& xRegressionCurve )
{
- Reference< util::XModifyListener > xModifyEventForwarder;
+ auto pRegressionCurve = dynamic_cast<RegressionCurveModel*>(xRegressionCurve.get());
+ assert(pRegressionCurve);
+ rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
{
MutexGuard aGuard( m_aMutex );
xModifyEventForwarder = m_xModifyEventForwarder;
- if( std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), xRegressionCurve )
+ if( std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), pRegressionCurve )
!= m_aRegressionCurves.end())
- throw lang::IllegalArgumentException();
- m_aRegressionCurves.push_back( xRegressionCurve );
+ throw lang::IllegalArgumentException(u"curve not found"_ustr, static_cast<cppu::OWeakObject*>(this), 1);
+ m_aRegressionCurves.push_back( pRegressionCurve );
}
- ModifyListenerHelper::addListener( xRegressionCurve, xModifyEventForwarder );
+ ModifyListenerHelper::addListener( rtl::Reference<RegressionCurveModel>(pRegressionCurve), xModifyEventForwarder );
fireModifyEvent();
}
@@ -433,36 +456,44 @@ void SAL_CALL DataSeries::removeRegressionCurve(
{
if( !xRegressionCurve.is() )
throw container::NoSuchElementException();
+ auto pRegressionCurve = dynamic_cast<RegressionCurveModel*>(xRegressionCurve.get());
+ assert(pRegressionCurve);
- Reference< util::XModifyListener > xModifyEventForwarder;
+ rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
{
MutexGuard aGuard( m_aMutex );
xModifyEventForwarder = m_xModifyEventForwarder;
tRegressionCurveContainerType::iterator aIt(
- std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), xRegressionCurve ) );
+ std::find( m_aRegressionCurves.begin(), m_aRegressionCurves.end(), pRegressionCurve ) );
if( aIt == m_aRegressionCurves.end())
throw container::NoSuchElementException(
- "The given regression curve is no element of this series",
+ u"The given regression curve is no element of this series"_ustr,
static_cast< uno::XWeak * >( this ));
m_aRegressionCurves.erase( aIt );
}
- ModifyListenerHelper::removeListener( xRegressionCurve, xModifyEventForwarder );
+ ModifyListenerHelper::removeListener( rtl::Reference<RegressionCurveModel>(pRegressionCurve), xModifyEventForwarder );
fireModifyEvent();
}
uno::Sequence< uno::Reference< chart2::XRegressionCurve > > SAL_CALL DataSeries::getRegressionCurves()
{
MutexGuard aGuard( m_aMutex );
- return comphelper::containerToSequence( m_aRegressionCurves );
+ return comphelper::containerToSequence<uno::Reference< chart2::XRegressionCurve >>( m_aRegressionCurves );
}
void SAL_CALL DataSeries::setRegressionCurves(
const Sequence< Reference< chart2::XRegressionCurve > >& aRegressionCurves )
{
tRegressionCurveContainerType aOldCurves;
- auto aNewCurves( comphelper::sequenceToContainer<tRegressionCurveContainerType>( aRegressionCurves ) );
- Reference< util::XModifyListener > xModifyEventForwarder;
+ tRegressionCurveContainerType aNewCurves;
+ for (const auto & i : aRegressionCurves)
+ {
+ auto pRegressionCurve = dynamic_cast<RegressionCurveModel*>(i.get());
+ assert(pRegressionCurve);
+ aNewCurves.push_back(pRegressionCurve);
+ }
+ rtl::Reference< ModifyEventForwarder > xModifyEventForwarder;
{
MutexGuard aGuard( m_aMutex );
xModifyEventForwarder = m_xModifyEventForwarder;
@@ -477,28 +508,12 @@ void SAL_CALL DataSeries::setRegressionCurves(
// ____ XModifyBroadcaster ____
void SAL_CALL DataSeries::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL DataSeries::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -508,13 +523,8 @@ void SAL_CALL DataSeries::modified( const lang::EventObject& aEvent )
}
// ____ XEventListener (base of XModifyListener) ____
-void SAL_CALL DataSeries::disposing( const lang::EventObject& rEventObject )
+void SAL_CALL DataSeries::disposing( const lang::EventObject& )
{
- // forget disposed data sequences
- tDataSequenceContainer::iterator aIt(
- std::find( m_aDataSequences.begin(), m_aDataSequences.end(), rEventObject.Source ));
- if( aIt != m_aDataSequences.end())
- m_aDataSequences.erase( aIt );
}
// ____ OPropertySet ____
@@ -537,7 +547,7 @@ 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";
+ return u"com.sun.star.comp.chart.DataSeries"_ustr;
}
sal_Bool SAL_CALL DataSeries::supportsService( const OUString& rServiceName )
@@ -548,9 +558,486 @@ sal_Bool SAL_CALL DataSeries::supportsService( const OUString& 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" };
+ u"com.sun.star.chart2.DataSeries"_ustr,
+ u"com.sun.star.chart2.DataPointProperties"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr };
+}
+
+static Reference< chart2::data::XLabeledDataSequence > lcl_findLSequenceWithOnlyLabel(
+ const Sequence< Reference< chart2::data::XLabeledDataSequence > > & rDataSequences )
+{
+ Reference< chart2::data::XLabeledDataSequence > xResult;
+
+ for( auto const & labeledData : rDataSequences )
+ {
+ OSL_ENSURE( labeledData.is(), "empty LabeledDataSequence" );
+ // no values are set but a label exists
+ if( labeledData.is() &&
+ ( ! labeledData->getValues().is() &&
+ labeledData->getLabel().is()))
+ {
+ xResult.set( labeledData );
+ break;
+ }
+ }
+
+ return xResult;
+}
+
+static OUString lcl_getDataSequenceLabel( const Reference< chart2::data::XDataSequence > & xSequence )
+{
+ OUString aResult;
+
+ Reference< chart2::data::XTextualDataSequence > xTextSeq( xSequence, uno::UNO_QUERY );
+ if( xTextSeq.is())
+ {
+ Sequence< OUString > aSeq( xTextSeq->getTextualData());
+
+ const sal_Int32 nMax = aSeq.getLength() - 1;
+ OUStringBuffer aBuf;
+
+ for( sal_Int32 i = 0; i <= nMax; ++i )
+ {
+ aBuf.append( aSeq[i] );
+ if( i < nMax )
+ aBuf.append( ' ');
+ }
+ aResult = aBuf.makeStringAndClear();
+ }
+ else if( xSequence.is())
+ {
+ Sequence< uno::Any > aSeq( xSequence->getData());
+
+ const sal_Int32 nMax = aSeq.getLength() - 1;
+ OUString aVal;
+ OUStringBuffer aBuf;
+ double fNum = 0;
+
+ for( sal_Int32 i = 0; i <= nMax; ++i )
+ {
+ if( aSeq[i] >>= aVal )
+ {
+ aBuf.append( aVal );
+ if( i < nMax )
+ aBuf.append( ' ');
+ }
+ else if( aSeq[ i ] >>= fNum )
+ {
+ aBuf.append( fNum );
+ if( i < nMax )
+ aBuf.append( ' ');
+ }
+ }
+ aResult = aBuf.makeStringAndClear();
+ }
+
+ return aResult;
+}
+
+static OUString getLabelForLabeledDataSequence(
+ const Reference< chart2::data::XLabeledDataSequence > & xLabeledSeq )
+{
+ OUString aResult;
+ if( xLabeledSeq.is())
+ {
+ Reference< chart2::data::XDataSequence > xSeq( xLabeledSeq->getLabel());
+ if( xSeq.is() )
+ aResult = lcl_getDataSequenceLabel( xSeq );
+ if( !xSeq.is() || aResult.isEmpty() )
+ {
+ // no label set or label content is empty -> use auto-generated one
+ Reference< chart2::data::XDataSequence > xValueSeq( xLabeledSeq->getValues() );
+ if( xValueSeq.is() )
+ {
+ Sequence< OUString > aLabels( xValueSeq->generateLabel(
+ chart2::data::LabelOrigin_SHORT_SIDE ) );
+ // no labels returned is interpreted as: auto-generation not
+ // supported by sequence
+ if( aLabels.hasElements() )
+ aResult=aLabels[0];
+ else
+ {
+ //todo?: maybe use the index of the series as name
+ //but as the index may change it would be better to have such a name persistent
+ //what is not possible at the moment
+ //--> maybe use the identifier as part of the name ...
+ aResult = lcl_getDataSequenceLabel( xValueSeq );
+ }
+ }
+ }
+ }
+ return aResult;
+}
+
+OUString DataSeries::getLabelForRole( const OUString & rLabelSequenceRole )
+{
+ OUString aResult;
+
+ Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
+ ::chart::DataSeriesHelper::getDataSequenceByRole( this, rLabelSequenceRole ));
+ if( xLabeledSeq.is())
+ aResult = getLabelForLabeledDataSequence( xLabeledSeq );
+ else
+ {
+ // special case: labeled data series with only a label and no values may
+ // serve as label
+ xLabeledSeq.set( lcl_findLSequenceWithOnlyLabel( getDataSequences() ));
+ if( xLabeledSeq.is())
+ {
+ Reference< chart2::data::XDataSequence > xSeq( xLabeledSeq->getLabel());
+ if( xSeq.is())
+ aResult = lcl_getDataSequenceLabel( xSeq );
+ }
+ }
+
+ return aResult;
+}
+
+static bool lcl_SequenceHasUnhiddenData( const uno::Reference< chart2::data::XDataSequence >& xDataSequence )
+{
+ if (!xDataSequence.is())
+ return false;
+ uno::Reference< beans::XPropertySet > xProp( xDataSequence, uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ uno::Sequence< sal_Int32 > aHiddenValues;
+ try
+ {
+ xProp->getPropertyValue( u"HiddenValues"_ustr ) >>= aHiddenValues;
+ if( !aHiddenValues.hasElements() )
+ return true;
+ }
+ catch( const uno::Exception& )
+ {
+ return true;
+ }
+ }
+ return xDataSequence->getData().hasElements();
+}
+
+bool DataSeries::hasUnhiddenData()
+{
+ MutexGuard aGuard( m_aMutex );
+
+ for(uno::Reference< chart2::data::XLabeledDataSequence > const & rDataSequence : m_aDataSequences)
+ {
+ if( !rDataSequence.is() )
+ continue;
+ if( lcl_SequenceHasUnhiddenData( rDataSequence->getValues() ) )
+ return true;
+ }
+ return false;
+}
+
+bool DataSeries::hasPointOwnColor(
+ sal_Int32 nPointIndex
+ , const css::uno::Reference< css::beans::XPropertySet >& xDataPointProperties //may be NULL this is just for performance
+ )
+{
+ if( hasPointOwnProperties( nPointIndex ))
+ {
+ uno::Reference< beans::XPropertyState > xPointState( xDataPointProperties, uno::UNO_QUERY );
+ if( !xPointState.is() )
+ {
+ xPointState.set( getDataPointByIndex( nPointIndex ), uno::UNO_QUERY );
+ }
+ if( !xPointState.is() )
+ return false;
+
+ return (xPointState->getPropertyState( u"Color"_ustr) != beans::PropertyState_DEFAULT_VALUE );
+ }
+
+ return false;
+}
+
+bool DataSeries::hasPointOwnProperties( sal_Int32 nPointIndex )
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_aAttributedDataPoints.find(nPointIndex) != m_aAttributedDataPoints.end();
+}
+
+sal_Int32 DataSeries::getAttachedAxisIndex()
+{
+ sal_Int32 nRet = 0;
+ try
+ {
+ getFastPropertyValue( ::chart::DataSeriesProperties::PROP_DATASERIES_ATTACHED_AXIS_INDEX ) >>= nRet;
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return nRet;
+}
+
+void DataSeries::switchSymbolsOnOrOff( bool bSymbolsOn, sal_Int32 nSeriesIndex )
+{
+ css::chart2::Symbol aSymbProp;
+ if( getPropertyValue( u"Symbol"_ustr) >>= aSymbProp )
+ {
+ if( !bSymbolsOn )
+ aSymbProp.Style = chart2::SymbolStyle_NONE;
+ else if( aSymbProp.Style == chart2::SymbolStyle_NONE )
+ {
+ aSymbProp.Style = chart2::SymbolStyle_STANDARD;
+ aSymbProp.StandardSymbol = nSeriesIndex;
+ }
+ setPropertyValue( u"Symbol"_ustr, uno::Any( aSymbProp ));
+ }
+ //todo: check attributed data points
+}
+
+void DataSeries::switchLinesOnOrOff( bool bLinesOn )
+{
+ if( bLinesOn )
+ {
+ // keep line-styles that are not NONE
+ css::drawing::LineStyle eLineStyle;
+ if( (getPropertyValue( u"LineStyle"_ustr) >>= eLineStyle ) &&
+ eLineStyle == drawing::LineStyle_NONE )
+ {
+ setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_SOLID ) );
+ }
+ }
+ else
+ setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) );
+}
+
+void DataSeries::makeLinesThickOrThin( bool bThick )
+{
+ sal_Int32 nNewValue = bThick ? 80 : 0;
+ sal_Int32 nOldValue = 0;
+ if( (getPropertyValue( u"LineWidth"_ustr) >>= nOldValue ) &&
+ nOldValue != nNewValue )
+ {
+ if( !(bThick && nOldValue>0))
+ setPropertyValue( u"LineWidth"_ustr, uno::Any( nNewValue ) );
+ }
+}
+
+void DataSeries::setPropertyAlsoToAllAttributedDataPoints( const OUString& rPropertyName, const uno::Any& rPropertyValue )
+{
+ setPropertyValue( rPropertyName, rPropertyValue );
+
+ std::vector<sal_Int32> aAttributedDataPointIndexList;
+ {
+ MutexGuard aGuard( m_aMutex );
+ aAttributedDataPointIndexList.reserve(m_aAttributedDataPoints.size());
+ for (const auto & rPair : m_aAttributedDataPoints)
+ aAttributedDataPointIndexList.push_back(rPair.first);
+ }
+
+ for(sal_Int32 nIdx : aAttributedDataPointIndexList)
+ {
+ Reference< beans::XPropertySet > xPointProp( getDataPointByIndex(nIdx) );
+ if(!xPointProp.is())
+ continue;
+ xPointProp->setPropertyValue( rPropertyName, rPropertyValue );
+ if( rPropertyName == "LabelPlacement" )
+ {
+ xPointProp->setPropertyValue(u"CustomLabelPosition"_ustr, uno::Any());
+ xPointProp->setPropertyValue(u"CustomLabelSize"_ustr, uno::Any());
+ }
+ }
+}
+
+bool DataSeries::hasAttributedDataPointDifferentValue(
+ const OUString& rPropertyName, const uno::Any& rPropertyValue )
+{
+ std::vector<sal_Int32> aAttributedDataPointIndexList;
+ {
+ MutexGuard aGuard( m_aMutex );
+ aAttributedDataPointIndexList.reserve(m_aAttributedDataPoints.size());
+ for (const auto & rPair : m_aAttributedDataPoints)
+ aAttributedDataPointIndexList.push_back(rPair.first);
+ }
+
+ for(sal_Int32 nIdx : aAttributedDataPointIndexList)
+ {
+ Reference< beans::XPropertySet > xPointProp( getDataPointByIndex(nIdx) );
+ if(!xPointProp.is())
+ continue;
+ uno::Any aPointValue( xPointProp->getPropertyValue( rPropertyName ) );
+ if( rPropertyValue != aPointValue )
+ return true;
+ }
+
+ return false;
+}
+
+bool DataSeries::hasDataLabelsAtSeries()
+{
+ bool bRet = false;
+ try
+ {
+ chart2::DataPointLabel aLabel;
+ if( getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel )
+ bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent || aLabel.ShowCategoryName
+ || aLabel.ShowSeriesName;
+ }
+ catch(const uno::Exception &)
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "" );
+ }
+ return bRet;
+}
+
+bool DataSeries::hasDataLabelsAtPoints()
+{
+ bool bRet = false;
+ try
+ {
+ std::vector<sal_Int32> aAttributedDataPointIndexList;
+ {
+ MutexGuard aGuard( m_aMutex );
+ aAttributedDataPointIndexList.reserve(m_aAttributedDataPoints.size());
+ for (const auto & rPair : m_aAttributedDataPoints)
+ aAttributedDataPointIndexList.push_back(rPair.first);
+ }
+ for(sal_Int32 nIdx : aAttributedDataPointIndexList)
+ {
+ Reference< beans::XPropertySet > xPointProp( getDataPointByIndex(nIdx) );
+ if( xPointProp.is() )
+ {
+ chart2::DataPointLabel aLabel;
+ if( xPointProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel )
+ bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent
+ || aLabel.ShowCategoryName || aLabel.ShowCustomLabel
+ || aLabel.ShowSeriesName;
+ if( bRet )
+ break;
+ }
+ }
+ }
+ catch(const uno::Exception &)
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "" );
+ }
+ return bRet;
+}
+
+bool DataSeries::hasDataLabelAtPoint( sal_Int32 nPointIndex )
+{
+ bool bRet = false;
+ try
+ {
+ Reference< beans::XPropertySet > xProp;
+ bool bFound = false;
+ {
+ MutexGuard aGuard( m_aMutex );
+ bFound = m_aAttributedDataPoints.find(nPointIndex) != m_aAttributedDataPoints.end();
+ }
+ if (bFound)
+ xProp = getDataPointByIndex(nPointIndex);
+ else
+ xProp = this;
+ if( xProp.is() )
+ {
+ chart2::DataPointLabel aLabel;
+ if( xProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel )
+ bRet = aLabel.ShowNumber || aLabel.ShowNumberInPercent
+ || aLabel.ShowCategoryName || aLabel.ShowCustomLabel
+ || aLabel.ShowSeriesName;
+ }
+ }
+ catch(const uno::Exception &)
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "" );
+ }
+ return bRet;
+}
+
+void DataSeries::insertDataLabelsToSeriesAndAllPoints()
+{
+ impl_insertOrDeleteDataLabelsToSeriesAndAllPoints( true /*bInsert*/ );
+}
+
+void DataSeries::deleteDataLabelsFromSeriesAndAllPoints()
+{
+ impl_insertOrDeleteDataLabelsToSeriesAndAllPoints( false /*bInsert*/ );
+}
+
+void DataSeries::impl_insertOrDeleteDataLabelsToSeriesAndAllPoints( bool bInsert )
+{
+ try
+ {
+ chart2::DataPointLabel aLabelAtSeries;
+ getPropertyValue(CHART_UNONAME_LABEL) >>= aLabelAtSeries;
+ aLabelAtSeries.ShowNumber = bInsert;
+ if( !bInsert )
+ {
+ aLabelAtSeries.ShowNumberInPercent = false;
+ aLabelAtSeries.ShowCategoryName = false;
+ }
+ setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabelAtSeries));
+ std::vector<sal_Int32> aAttributedDataPointIndexList;
+ {
+ MutexGuard aGuard( m_aMutex );
+ aAttributedDataPointIndexList.reserve(m_aAttributedDataPoints.size());
+ for (const auto & rPair : m_aAttributedDataPoints)
+ aAttributedDataPointIndexList.push_back(rPair.first);
+ }
+ for(sal_Int32 nIdx : aAttributedDataPointIndexList)
+ {
+ Reference< beans::XPropertySet > xPointProp( getDataPointByIndex(nIdx) );
+ if( xPointProp.is() )
+ {
+ chart2::DataPointLabel aLabel;
+ xPointProp->getPropertyValue(CHART_UNONAME_LABEL) >>= aLabel;
+ aLabel.ShowNumber = bInsert;
+ if( !bInsert )
+ {
+ aLabel.ShowNumberInPercent = false;
+ aLabel.ShowCategoryName = false;
+ aLabel.ShowCustomLabel = false;
+ aLabel.ShowSeriesName = false;
+ }
+ xPointProp->setPropertyValue(CHART_UNONAME_LABEL, uno::Any(aLabel));
+ xPointProp->setPropertyValue(CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any());
+ }
+ }
+ }
+ catch(const uno::Exception &)
+ {
+ TOOLS_WARN_EXCEPTION("chart2", "" );
+ }
+}
+
+sal_Int32 DataSeries::getExplicitNumberFormatKeyForDataLabel()
+{
+ sal_Int32 nFormat = 0;
+ try
+ {
+ bool bLinkToSource = true;
+ getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkToSource;
+ getPropertyValue(CHART_UNONAME_NUMFMT) >>= nFormat;
+
+ if (bLinkToSource)
+ {
+ MutexGuard aGuard( m_aMutex );
+
+ if (!m_aDataSequences.empty())
+ {
+ Reference<chart2::data::XLabeledDataSequence> xLabeledSeq(m_aDataSequences[0]);
+ if( xLabeledSeq.is() )
+ {
+ Reference< chart2::data::XDataSequence > xSeq( xLabeledSeq->getValues());
+ if( xSeq.is() )
+ {
+ nFormat = xSeq->getNumberFormatKeyByIndex( -1 );
+ }
+ }
+ }
+ }
+ }
+ catch (const beans::UnknownPropertyException&)
+ {
+ }
+
+ if (nFormat < 0)
+ nFormat = 0;
+ return nFormat;
+
}
} // namespace chart
diff --git a/chart2/source/model/main/DataSeriesProperties.cxx b/chart2/source/model/main/DataSeriesProperties.cxx
index 5d0cb777e151..c558b3820cab 100644
--- a/chart2/source/model/main/DataSeriesProperties.cxx
+++ b/chart2/source/model/main/DataSeriesProperties.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "DataSeriesProperties.hxx"
+#include <DataSeriesProperties.hxx>
#include "DataPointProperties.hxx"
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/chart2/StackingDirection.hpp>
@@ -69,6 +69,18 @@ void DataSeriesProperties::AddPropertiesToVector(
beans::PropertyAttribute::BOUND
| beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( "ShowCustomLeaderLines",
+ PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES,
+ cppu::UnoType<sal_Bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
+ rOutProperties.emplace_back( "InvertNegative",
+ PROP_DATASERIES_INVERT_NEGATIVE,
+ cppu::UnoType<sal_Bool>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT );
+
// add properties of service DataPointProperties
DataPointProperties::AddPropertiesToVector( rOutProperties );
}
@@ -78,8 +90,10 @@ void DataSeriesProperties::AddDefaultsToMap(
{
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATASERIES_STACKING_DIRECTION, chart2::StackingDirection_NO_STACKING );
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATASERIES_VARY_COLORS_BY_POINT, false );
- PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DATASERIES_ATTACHED_AXIS_INDEX, 0 );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATASERIES_ATTACHED_AXIS_INDEX, sal_Int32(0) );
PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATASERIES_SHOW_LEGEND_ENTRY, true );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES, true );
+ PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DATASERIES_INVERT_NEGATIVE, false );
// PROP_DATASERIES_ATTRIBUTED_DATA_POINTS has no default
diff --git a/chart2/source/model/main/DataSeriesProperties.hxx b/chart2/source/model/main/DataSeriesProperties.hxx
deleted file mode 100644
index 331396b49f60..000000000000
--- a/chart2/source/model/main/DataSeriesProperties.hxx
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#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/DataTable.cxx b/chart2/source/model/main/DataTable.cxx
new file mode 100644
index 000000000000..01aa023ed977
--- /dev/null
+++ b/chart2/source/model/main/DataTable.cxx
@@ -0,0 +1,210 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <DataTable.hxx>
+
+#include <LinePropertiesHelper.hxx>
+#include <FillProperties.hxx>
+#include <CharacterProperties.hxx>
+#include <ModifyListenerHelper.hxx>
+#include <PropertyHelper.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+
+#include <algorithm>
+
+using namespace css;
+
+namespace
+{
+/** DataTable Properties */
+enum
+{
+ DataTableProperty_HorizontalBorder,
+ DataTableProperty_VerticalBorder,
+ DataTableProperty_Outilne,
+ DataTableProperty_Keys,
+};
+
+void lcl_AddPropertiesToVector(std::vector<beans::Property>& rProps)
+{
+ auto const nBound = beans::PropertyAttribute::BOUND;
+ auto const nMaybeDefault = beans::PropertyAttribute::MAYBEDEFAULT;
+
+ rProps.emplace_back("HBorder", DataTableProperty_HorizontalBorder, cppu::UnoType<bool>::get(),
+ nBound | nMaybeDefault);
+ rProps.emplace_back("VBorder", DataTableProperty_VerticalBorder, cppu::UnoType<bool>::get(),
+ nBound | nMaybeDefault);
+ rProps.emplace_back("Outline", DataTableProperty_Outilne, cppu::UnoType<bool>::get(),
+ nBound | nMaybeDefault);
+ rProps.emplace_back("Keys", DataTableProperty_Keys, cppu::UnoType<bool>::get(),
+ nBound | nMaybeDefault);
+}
+
+const ::chart::tPropertyValueMap& StaticDataTableDefaults()
+{
+ static ::chart::tPropertyValueMap aStaticDefaults = []() {
+ ::chart::tPropertyValueMap aMap;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap(aMap);
+ ::chart::FillProperties::AddDefaultsToMap(aMap);
+ ::chart::CharacterProperties::AddDefaultsToMap(aMap);
+
+ ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_HorizontalBorder,
+ false);
+ ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_VerticalBorder,
+ false);
+ ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Outilne, false);
+ ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Keys, false);
+
+ ::chart::PropertyHelper::setPropertyValue(
+ aMap, ::chart::LinePropertiesHelper::PROP_LINE_WIDTH, uno::Any(sal_Int32(1)));
+
+ ::chart::PropertyHelper::setPropertyValueDefault(
+ aMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE);
+
+ float fDefaultCharHeight = 10.0;
+ ::chart::PropertyHelper::setPropertyValue(
+ aMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight);
+ ::chart::PropertyHelper::setPropertyValue(
+ aMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight);
+ ::chart::PropertyHelper::setPropertyValue(
+ aMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight);
+ return aMap;
+ }();
+ return aStaticDefaults;
+};
+
+cppu::OPropertyArrayHelper& StaticDataTableInfoHelper()
+{
+ static cppu::OPropertyArrayHelper aPropHelper = []() {
+ std::vector<beans::Property> aProperties;
+ lcl_AddPropertiesToVector(aProperties);
+ ::chart::LinePropertiesHelper::AddPropertiesToVector(aProperties);
+ ::chart::FillProperties::AddPropertiesToVector(aProperties);
+ ::chart::CharacterProperties::AddPropertiesToVector(aProperties);
+ std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess());
+
+ return comphelper::containerToSequence(aProperties);
+ }();
+ return aPropHelper;
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+DataTable::DataTable()
+ : m_xModifyEventForwarder(new ModifyEventForwarder())
+{
+}
+
+DataTable::DataTable(const DataTable& rOther)
+ : DataTable_Base(rOther)
+ , ::property::OPropertySet(rOther)
+ , m_xModifyEventForwarder(new ModifyEventForwarder())
+{
+}
+
+DataTable::~DataTable() = default;
+
+// ____ XCloneable ____
+uno::Reference<util::XCloneable> SAL_CALL DataTable::createClone()
+{
+ return uno::Reference<util::XCloneable>(new DataTable(*this));
+}
+
+// ____ XModifyBroadcaster ____
+void SAL_CALL DataTable::addModifyListener(const uno::Reference<util::XModifyListener>& aListener)
+{
+ m_xModifyEventForwarder->addModifyListener(aListener);
+}
+
+void SAL_CALL
+DataTable::removeModifyListener(const uno::Reference<util::XModifyListener>& aListener)
+{
+ m_xModifyEventForwarder->removeModifyListener(aListener);
+}
+
+// ____ XModifyListener ____
+void SAL_CALL DataTable::modified(const lang::EventObject& aEvent)
+{
+ m_xModifyEventForwarder->modified(aEvent);
+}
+
+// ____ XEventListener (base of XModifyListener) ____
+void SAL_CALL DataTable::disposing(const lang::EventObject& /* Source */)
+{
+ // nothing
+}
+
+// ____ OPropertySet ____
+void DataTable::firePropertyChangeEvent()
+{
+ m_xModifyEventForwarder->modified(lang::EventObject(static_cast<uno::XWeak*>(this)));
+}
+
+// ____ OPropertySet ____
+void DataTable::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const
+{
+ const tPropertyValueMap& rStaticDefaults = StaticDataTableDefaults();
+ auto aFound = rStaticDefaults.find(nHandle);
+ if (aFound == rStaticDefaults.end())
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper& SAL_CALL DataTable::getInfoHelper()
+{
+ return StaticDataTableInfoHelper();
+}
+
+// ____ XPropertySet ____
+uno::Reference<beans::XPropertySetInfo> SAL_CALL DataTable::getPropertySetInfo()
+{
+ static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDataTableInfoHelper()));
+ return xPropertySetInfo;
+}
+
+// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
+OUString SAL_CALL DataTable::getImplementationName()
+{
+ return u"com.sun.star.comp.chart2.DataTable"_ustr;
+}
+
+sal_Bool SAL_CALL DataTable::supportsService(const OUString& rServiceName)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+uno::Sequence<OUString> SAL_CALL DataTable::getSupportedServiceNames()
+{
+ return { u"com.sun.star.chart2.DataTable"_ustr, u"com.sun.star.beans.PropertySet"_ustr,
+ u"com.sun.star.drawing.FillProperties"_ustr,
+ u"com.sun.star.drawing.LineProperties"_ustr,
+ u"com.sun.star.style.CharacterProperties"_ustr };
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2(DataTable, DataTable_Base, ::property::OPropertySet)
+IMPLEMENT_FORWARD_XTYPEPROVIDER2(DataTable, DataTable_Base, ::property::OPropertySet)
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
+com_sun_star_comp_chart2_DataTable_get_implementation(
+ css::uno::XComponentContext* /*pComponentContext*/, uno::Sequence<uno::Any> const& /*rAny*/)
+{
+ return cppu::acquire(new ::chart::DataTable);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx
index 0b9efc80f794..d478eec74ba7 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -18,7 +18,16 @@
*/
#include <Diagram.hxx>
+#include <AxisHelper.hxx>
+#include <BaseGFXHelper.hxx>
+#include <ChartTypeHelper.hxx>
+#include <ChartTypeManager.hxx>
+#include <ChartTypeTemplate.hxx>
+#include <ChartType.hxx>
+#include <DataSeriesHelper.hxx>
#include <PropertyHelper.hxx>
+#include <RegressionCurveHelper.hxx>
+#include <RegressionCurveModel.hxx>
#include "Wall.hxx"
#include <ModifyListenerHelper.hxx>
#include <UserDefinedProperties.hxx>
@@ -28,23 +37,39 @@
#include <CloneHelper.hxx>
#include <SceneProperties.hxx>
#include <unonames.hxx>
+#include <BaseCoordinateSystem.hxx>
+#include <Legend.hxx>
+#include <Axis.hxx>
+#include <DataTable.hxx>
+#include <servicenames_charttypes.hxx>
+#include <defines.hxx>
#include <basegfx/numeric/ftools.hxx>
-#include <rtl/instance.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/chart2/AxisType.hpp>
+#include <com/sun/star/chart2/DataPointGeometry3D.hpp>
+#include <com/sun/star/chart2/StackingDirection.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/RelativeSize.hpp>
+#include <com/sun/star/chart2/PieChartSubType.hpp>
+#include <com/sun/star/chart/MissingValueTreatment.hpp>
#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <com/sun/star/drawing/ShadeMode.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/CloseVetoException.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <o3tl/safeint.hxx>
+#include <rtl/math.hxx>
+#include <tools/helpers.hxx>
#include <algorithm>
+#include <utility>
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans::PropertyAttribute;
+using namespace ::chart::SceneProperties;
using ::com::sun::star::beans::Property;
using ::com::sun::star::uno::Sequence;
@@ -72,6 +97,8 @@ enum
PROP_DIAGRAM_MISSING_VALUE_TREATMENT,
PROP_DIAGRAM_3DRELATIVEHEIGHT,
PROP_DIAGRAM_DATATABLEHBORDER,
+ PROP_DIAGRAM_OF_PIE_TYPE,
+ PROP_DIAGRAM_SPLIT_POS,
PROP_DIAGRAM_DATATABLEVBORDER,
PROP_DIAGRAM_DATATABLEOUTLINE,
PROP_DIAGRAM_EXTERNALDATA
@@ -158,67 +185,45 @@ void lcl_AddPropertiesToVector(
PROP_DIAGRAM_3DRELATIVEHEIGHT,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::MAYBEVOID );
- rOutProperties.emplace_back( "DataTableHBorder",
- PROP_DIAGRAM_DATATABLEHBORDER,
- cppu::UnoType<bool>::get(),
- beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( "DataTableVBorder",
- PROP_DIAGRAM_DATATABLEVBORDER,
- cppu::UnoType<bool>::get(),
- beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( "DataTableOutline",
- PROP_DIAGRAM_DATATABLEOUTLINE,
- cppu::UnoType<bool>::get(),
- beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
+ rOutProperties.emplace_back( "SubPieType",
+ PROP_DIAGRAM_OF_PIE_TYPE,
+ cppu::UnoType<chart2::PieChartSubType>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
+ rOutProperties.emplace_back( "SplitPos",
+ PROP_DIAGRAM_SPLIT_POS,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::MAYBEVOID );
rOutProperties.emplace_back( "ExternalData",
PROP_DIAGRAM_EXTERNALDATA,
cppu::UnoType<OUString>::get(),
beans::PropertyAttribute::MAYBEVOID );
}
-struct StaticDiagramDefaults_Initializer
+const ::chart::tPropertyValueMap& StaticDiagramDefaults()
{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
{
- ::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 );
- }
+ ::chart::tPropertyValueMap aMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_CONNECT_BARS, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_STARTING_ANGLE, 90 );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_3DRELATIVEHEIGHT, 100 );
+ ::chart::PropertyHelper::setPropertyValueDefault< chart2::PieChartSubType >( aMap, PROP_DIAGRAM_OF_PIE_TYPE,
+ chart2::PieChartSubType_NONE);
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_SPLIT_POS, 2 );
+ ::chart::SceneProperties::AddDefaultsToMap( aMap );
+ return aMap;
+ }();
+ return aStaticDefaults;
};
-struct StaticDiagramDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticDiagramDefaults_Initializer >
+::cppu::OPropertyArrayHelper& StaticDiagramInfoHelper()
{
-};
-
-struct StaticDiagramInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
{
std::vector< css::beans::Property > aProperties;
lcl_AddPropertiesToVector( aProperties );
@@ -228,49 +233,28 @@ private:
std::sort( aProperties.begin(), aProperties.end(),
::chart::PropertyNameLess() );
- return comphelper::containerToSequence( aProperties );
- }
-};
-
-struct StaticDiagramInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDiagramInfoHelper_Initializer >
-{
+ return ::cppu::OPropertyArrayHelper( aProperties.data(), aProperties.size() );
+ }();
+ return aPropHelper;
};
-struct StaticDiagramInfo_Initializer
+const uno::Reference< beans::XPropertySetInfo >& StaticDiagramInfo()
{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDiagramInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
+ static const uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDiagramInfoHelper() ) );
+ 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 )
+ const ::chart::Diagram::tCoordinateSystemContainerType & rSource,
+ ::chart::Diagram::tCoordinateSystemContainerType & rDestination )
{
- for( auto const & i : rSource )
+ for( rtl::Reference< ::chart::BaseCoordinateSystem > const & i : rSource )
{
- lcl_tCooSysRef xClone;
- css::uno::Reference< css::util::XCloneable > xCloneable( i, css::uno::UNO_QUERY );
- if( xCloneable.is())
- xClone.set( xCloneable->createClone(), css::uno::UNO_QUERY );
-
- if( xClone.is())
- {
- rDestination.push_back( xClone );
- }
- else
- rDestination.push_back( i );
+ auto xClone = i->createClone();
+ ::chart::BaseCoordinateSystem* pClone = dynamic_cast<::chart::BaseCoordinateSystem*>(xClone.get());
+ assert(pClone);
+ rDestination.push_back( pClone );
}
}
@@ -279,36 +263,43 @@ void lcl_CloneCoordinateSystems(
namespace chart
{
-Diagram::Diagram( uno::Reference< uno::XComponentContext > const & xContext ) :
- ::property::OPropertySet( m_aMutex ),
- m_xContext( xContext ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+Diagram::Diagram( uno::Reference< uno::XComponentContext > xContext ) :
+ m_xContext(std::move( xContext )),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
// Set camera position to a default position (that should be set hard, so
// that it will be exported. The property default is a camera looking
// straight ono the scene). These defaults have been acquired from the old
// chart implementation.
setFastPropertyValue_NoBroadcast(
- SceneProperties::PROP_SCENE_CAMERA_GEOMETRY, uno::Any(
+ PROP_SCENE_CAMERA_GEOMETRY, uno::Any(
ThreeDHelper::getDefaultCameraGeometry()));
}
Diagram::Diagram( const Diagram & rOther ) :
impl::Diagram_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
+ ::property::OPropertySet( rOther ),
m_xContext( rOther.m_xContext ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
lcl_CloneCoordinateSystems( rOther.m_aCoordSystems, m_aCoordSystems );
- ModifyListenerHelper::addListenerToAllElements( m_aCoordSystems, m_xModifyEventForwarder );
+ for (auto & xSystem : m_aCoordSystems)
+ xSystem->addModifyListener(m_xModifyEventForwarder);
- m_xWall.set( CloneHelper::CreateRefClone< beans::XPropertySet >()( rOther.m_xWall ));
- m_xFloor.set( CloneHelper::CreateRefClone< beans::XPropertySet >()( rOther.m_xFloor ));
+ if ( rOther.m_xWall )
+ m_xWall = new Wall( *rOther.m_xWall );
+ if ( rOther.m_xFloor )
+ m_xFloor = new Wall( *rOther.m_xFloor );
m_xTitle.set( CloneHelper::CreateRefClone< chart2::XTitle >()( rOther.m_xTitle ));
- m_xLegend.set( CloneHelper::CreateRefClone< chart2::XLegend >()( rOther.m_xLegend ));
-
- ModifyListenerHelper::addListener( m_xWall, m_xModifyEventForwarder );
- ModifyListenerHelper::addListener( m_xFloor, m_xModifyEventForwarder );
+ if (rOther.m_xLegend)
+ m_xLegend = new Legend(*rOther.m_xLegend);
+ if (rOther.m_xDataTable)
+ m_xDataTable = new DataTable(*rOther.m_xDataTable);
+
+ if ( m_xWall )
+ m_xWall->addModifyListener( m_xModifyEventForwarder );
+ if ( m_xFloor )
+ m_xFloor->addModifyListener( m_xModifyEventForwarder );
ModifyListenerHelper::addListener( m_xTitle, m_xModifyEventForwarder );
ModifyListenerHelper::addListener( m_xLegend, m_xModifyEventForwarder );
}
@@ -317,10 +308,13 @@ Diagram::~Diagram()
{
try
{
- ModifyListenerHelper::removeListenerFromAllElements( m_aCoordSystems, m_xModifyEventForwarder );
+ for (auto & xSystem : m_aCoordSystems)
+ xSystem->removeModifyListener(m_xModifyEventForwarder);
- ModifyListenerHelper::removeListener( m_xWall, m_xModifyEventForwarder );
- ModifyListenerHelper::removeListener( m_xFloor, m_xModifyEventForwarder );
+ if ( m_xWall )
+ m_xWall->removeModifyListener( m_xModifyEventForwarder );
+ if ( m_xFloor )
+ m_xFloor->removeModifyListener( m_xModifyEventForwarder );
ModifyListenerHelper::removeListener( m_xTitle, m_xModifyEventForwarder );
ModifyListenerHelper::removeListener( m_xLegend, m_xModifyEventForwarder );
}
@@ -333,7 +327,7 @@ Diagram::~Diagram()
// ____ XDiagram ____
uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getWall()
{
- uno::Reference< beans::XPropertySet > xRet;
+ rtl::Reference< Wall > xRet;
bool bAddListener = false;
{
MutexGuard aGuard( m_aMutex );
@@ -345,13 +339,13 @@ uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getWall()
xRet = m_xWall;
}
if(bAddListener)
- ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
+ xRet->addModifyListener( m_xModifyEventForwarder );
return xRet;
}
uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getFloor()
{
- uno::Reference< beans::XPropertySet > xRet;
+ rtl::Reference< Wall > xRet;
bool bAddListener = false;
{
MutexGuard aGuard( m_aMutex );
@@ -363,7 +357,7 @@ uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getFloor()
xRet = m_xFloor;
}
if(bAddListener)
- ModifyListenerHelper::addListener( xRet, m_xModifyEventForwarder );
+ xRet->addModifyListener( m_xModifyEventForwarder );
return xRet;
}
@@ -373,9 +367,22 @@ uno::Reference< chart2::XLegend > SAL_CALL Diagram::getLegend()
return m_xLegend;
}
+rtl::Reference< ::chart::Legend > Diagram::getLegend2() const
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xLegend;
+}
+
void SAL_CALL Diagram::setLegend( const uno::Reference< chart2::XLegend >& xNewLegend )
{
- Reference< chart2::XLegend > xOldLegend;
+ auto pLegend = dynamic_cast<Legend*>(xNewLegend.get());
+ assert(!xNewLegend || pLegend);
+ setLegend(rtl::Reference< Legend >(pLegend));
+}
+
+void Diagram::setLegend( const rtl::Reference< Legend >& xNewLegend )
+{
+ rtl::Reference< Legend > xOldLegend;
{
MutexGuard aGuard( m_aMutex );
if( m_xLegend == xNewLegend )
@@ -420,15 +427,14 @@ void SAL_CALL Diagram::setDiagramData(
const Reference< chart2::data::XDataSource >& xDataSource,
const Sequence< beans::PropertyValue >& aArguments )
{
- uno::Reference< lang::XMultiServiceFactory > xChartTypeManager( m_xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.chart2.ChartTypeManager", m_xContext ), uno::UNO_QUERY );
- DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram( this, xChartTypeManager );
- uno::Reference< chart2::XChartTypeTemplate > xTemplate( aTemplateAndService.first );
+ rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = new ::chart::ChartTypeManager( m_xContext );
+ Diagram::tTemplateWithServiceName aTemplateAndService = getTemplate( xChartTypeManager );
+ rtl::Reference< ::chart::ChartTypeTemplate > xTemplate( aTemplateAndService.xChartTypeTemplate );
if( !xTemplate.is() )
- xTemplate.set( xChartTypeManager->createInstance( "com.sun.star.chart2.template.Column" ), uno::UNO_QUERY );
+ xTemplate = xChartTypeManager->createTemplate( u"com.sun.star.chart2.template.Column"_ustr );
if(!xTemplate.is())
return;
- xTemplate->changeDiagramData( this, xDataSource, aArguments );
+ xTemplate->changeDiagramData( rtl::Reference< ::chart::Diagram >(this), xDataSource, aArguments );
}
// ____ XTitled ____
@@ -458,35 +464,138 @@ void SAL_CALL Diagram::setTitleObject( const uno::Reference< chart2::XTitle >& x
// ____ X3DDefaultSetter ____
void SAL_CALL Diagram::set3DSettingsToDefault()
{
- ThreeDHelper::set3DSettingsToDefault( this );
+ setPropertyToDefault( u"D3DSceneDistance"_ustr);
+ setPropertyToDefault( u"D3DSceneFocalLength"_ustr);
+ setDefaultRotation();
+ setDefaultIllumination();
}
void SAL_CALL Diagram::setDefaultRotation()
{
- ThreeDHelper::setDefaultRotation( this );
+ bool bPieOrDonut( isPieOrDonutChart() );
+ setDefaultRotation( bPieOrDonut );
+}
+
+static ::basegfx::B3DHomMatrix lcl_getCompleteRotationMatrix( Diagram& rDiagram )
+{
+ ::basegfx::B3DHomMatrix aCompleteRotation;
+ double fXAngleRad=0.0;
+ double fYAngleRad=0.0;
+ double fZAngleRad=0.0;
+ rDiagram.getRotationAngle( fXAngleRad, fYAngleRad, fZAngleRad );
+ aCompleteRotation.rotate( fXAngleRad, fYAngleRad, fZAngleRad );
+ return aCompleteRotation;
+}
+static void lcl_RotateLightSource( Diagram& rDiagram
+ , int nLightSourceDirectionProp
+ , int nLightSourceOnProp
+ , const ::basegfx::B3DHomMatrix& rRotationMatrix )
+{
+ bool bLightOn = false;
+ if( !(rDiagram.getFastPropertyValue( nLightSourceOnProp ) >>= bLightOn) )
+ return;
+
+ if( bLightOn )
+ {
+ drawing::Direction3D aLight;
+ if( rDiagram.getFastPropertyValue( nLightSourceDirectionProp ) >>= aLight )
+ {
+ ::basegfx::B3DVector aLightVector( BaseGFXHelper::Direction3DToB3DVector( aLight ) );
+ aLightVector = rRotationMatrix*aLightVector;
+
+ rDiagram.setFastPropertyValue( nLightSourceDirectionProp
+ , uno::Any( BaseGFXHelper::B3DVectorToDirection3D( aLightVector ) ) );
+ }
+ }
+}
+
+static void lcl_setLightsForScheme( Diagram& rDiagram, const ThreeDLookScheme& rScheme )
+{
+ if( rScheme == ThreeDLookScheme::ThreeDLookScheme_Unknown)
+ return;
+
+ // "D3DSceneLightOn2" / UNO_NAME_3D_SCENE_LIGHTON_2
+ rDiagram.setFastPropertyValue( PROP_SCENE_LIGHT_ON_2, uno::Any( true ) );
+
+ rtl::Reference< ChartType > xChartType( rDiagram.getChartTypeByIndex( 0 ) );
+ uno::Any aADirection( rScheme == ThreeDLookScheme::ThreeDLookScheme_Simple
+ ? ChartTypeHelper::getDefaultSimpleLightDirection(xChartType)
+ : ChartTypeHelper::getDefaultRealisticLightDirection(xChartType) );
+
+ // "D3DSceneLightDirection2" / UNO_NAME_3D_SCENE_LIGHTDIRECTION_2
+ rDiagram.setFastPropertyValue( PROP_SCENE_LIGHT_DIRECTION_2, aADirection );
+ //rotate light direction when right angled axes are off but supported
+ {
+ bool bRightAngledAxes = false;
+ rDiagram.getFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES ) >>= bRightAngledAxes; // "RightAngledAxes"
+ if(!bRightAngledAxes)
+ {
+ if (xChartType.is() ? xChartType->isSupportingRightAngledAxes() : true)
+ {
+ ::basegfx::B3DHomMatrix aRotation( lcl_getCompleteRotationMatrix( rDiagram ) );
+ BaseGFXHelper::ReduceToRotationMatrix( aRotation );
+ // "D3DSceneLightDirection2", "D3DSceneLightOn2"
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_2, PROP_SCENE_LIGHT_ON_2, aRotation );
+ }
+ }
+ }
+
+ sal_Int32 nColor = ::chart::ChartTypeHelper::getDefaultDirectLightColor(
+ rScheme == ThreeDLookScheme::ThreeDLookScheme_Simple, xChartType);
+ // "D3DSceneLightColor2" / UNO_NAME_3D_SCENE_LIGHTCOLOR_2
+ rDiagram.setFastPropertyValue( PROP_SCENE_LIGHT_COLOR_2, uno::Any( nColor ) );
+
+ sal_Int32 nAmbientColor = ::chart::ChartTypeHelper::getDefaultAmbientLightColor(
+ rScheme == ThreeDLookScheme::ThreeDLookScheme_Simple, xChartType);
+ // "D3DSceneAmbientColor" / UNO_NAME_3D_SCENE_AMBIENTCOLOR
+ rDiagram.setFastPropertyValue( PROP_SCENE_AMBIENT_COLOR, uno::Any( nAmbientColor ) );
}
void SAL_CALL Diagram::setDefaultIllumination()
{
- ThreeDHelper::setDefaultIllumination( this );
+ drawing::ShadeMode aShadeMode( drawing::ShadeMode_SMOOTH );
+ try
+ {
+ // "D3DSceneShadeMode"
+ getFastPropertyValue( PROP_SCENE_SHADE_MODE )>>= aShadeMode;
+ // "D3DSceneLightOn1" / UNO_NAME_3D_SCENE_LIGHTON_1
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_1, uno::Any( false ) );
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_3, uno::Any( false ) );
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_4, uno::Any( false ) );
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_5, uno::Any( false ) );
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_6, uno::Any( false ) );
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_7, uno::Any( false ) );
+ setFastPropertyValue( PROP_SCENE_LIGHT_ON_8, uno::Any( false ) );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ ThreeDLookScheme aScheme = (aShadeMode == drawing::ShadeMode_FLAT)
+ ? ThreeDLookScheme::ThreeDLookScheme_Simple
+ : ThreeDLookScheme::ThreeDLookScheme_Realistic;
+ lcl_setLightsForScheme( *this, aScheme );
}
// ____ XCoordinateSystemContainer ____
void SAL_CALL Diagram::addCoordinateSystem(
const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
{
+ ::chart::BaseCoordinateSystem* pCoordSys = dynamic_cast<::chart::BaseCoordinateSystem*>(aCoordSys.get());
+ assert(pCoordSys);
{
MutexGuard aGuard( m_aMutex );
- if( std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys )
+ if( std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), pCoordSys )
!= m_aCoordSystems.end())
- throw lang::IllegalArgumentException();
+ throw lang::IllegalArgumentException(u"coordsys not found"_ustr, static_cast<cppu::OWeakObject*>(this), 1);
if( !m_aCoordSystems.empty() )
{
OSL_FAIL( "more than one coordinatesystem is not supported yet by the fileformat" );
return;
}
- m_aCoordSystems.push_back( aCoordSys );
+ m_aCoordSystems.push_back( pCoordSys );
}
ModifyListenerHelper::addListener( aCoordSys, m_xModifyEventForwarder );
fireModifyEvent();
@@ -495,13 +604,14 @@ void SAL_CALL Diagram::addCoordinateSystem(
void SAL_CALL Diagram::removeCoordinateSystem(
const uno::Reference< chart2::XCoordinateSystem >& aCoordSys )
{
+ ::chart::BaseCoordinateSystem* pCoordSys = dynamic_cast<::chart::BaseCoordinateSystem*>(aCoordSys.get());
+ assert(pCoordSys);
{
MutexGuard aGuard( m_aMutex );
- std::vector< uno::Reference< chart2::XCoordinateSystem > >::iterator
- aIt( std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), aCoordSys ));
+ auto aIt = std::find( m_aCoordSystems.begin(), m_aCoordSystems.end(), pCoordSys );
if( aIt == m_aCoordSystems.end())
throw container::NoSuchElementException(
- "The given coordinate-system is no element of the container",
+ u"The given coordinate-system is no element of the container"_ustr,
static_cast< uno::XWeak * >( this ));
m_aCoordSystems.erase( aIt );
}
@@ -512,7 +622,13 @@ void SAL_CALL Diagram::removeCoordinateSystem(
uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > SAL_CALL Diagram::getCoordinateSystems()
{
MutexGuard aGuard( m_aMutex );
- return comphelper::containerToSequence( m_aCoordSystems );
+ return comphelper::containerToSequence<uno::Reference< chart2::XCoordinateSystem >>( m_aCoordSystems );
+}
+
+Diagram::tCoordinateSystemContainerType Diagram::getBaseCoordinateSystems() const
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_aCoordSystems;
}
void SAL_CALL Diagram::setCoordinateSystems(
@@ -523,6 +639,30 @@ void SAL_CALL Diagram::setCoordinateSystems(
if( aCoordinateSystems.hasElements() )
{
OSL_ENSURE( aCoordinateSystems.getLength()<=1, "more than one coordinatesystem is not supported yet by the fileformat" );
+ ::chart::BaseCoordinateSystem* pCoordSys = dynamic_cast<::chart::BaseCoordinateSystem*>(aCoordinateSystems[0].get());
+ assert(pCoordSys);
+ aNew.push_back( pCoordSys );
+ }
+ {
+ MutexGuard aGuard( m_aMutex );
+ std::swap( aOld, m_aCoordSystems );
+ m_aCoordSystems = aNew;
+ }
+ for (auto & xSystem : aOld)
+ xSystem->removeModifyListener(m_xModifyEventForwarder);
+ for (auto & xSystem : aNew)
+ xSystem->addModifyListener(m_xModifyEventForwarder);
+ fireModifyEvent();
+}
+
+void Diagram::setCoordinateSystems(
+ const std::vector< rtl::Reference< BaseCoordinateSystem > >& aCoordinateSystems )
+{
+ tCoordinateSystemContainerType aNew;
+ tCoordinateSystemContainerType aOld;
+ if( !aCoordinateSystems.empty() )
+ {
+ OSL_ENSURE( aCoordinateSystems.size()<=1, "more than one coordinatesystem is not supported yet by the fileformat" );
aNew.push_back( aCoordinateSystems[0] );
}
{
@@ -530,8 +670,10 @@ void SAL_CALL Diagram::setCoordinateSystems(
std::swap( aOld, m_aCoordSystems );
m_aCoordSystems = aNew;
}
- ModifyListenerHelper::removeListenerFromAllElements( aOld, m_xModifyEventForwarder );
- ModifyListenerHelper::addListenerToAllElements( aNew, m_xModifyEventForwarder );
+ for (auto & xSystem : aOld)
+ xSystem->removeModifyListener(m_xModifyEventForwarder);
+ for (auto & xSystem : aNew)
+ xSystem->addModifyListener(m_xModifyEventForwarder);
fireModifyEvent();
}
@@ -545,28 +687,12 @@ Reference< util::XCloneable > SAL_CALL Diagram::createClone()
// ____ XModifyBroadcaster ____
void SAL_CALL Diagram::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL Diagram::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -593,36 +719,37 @@ void Diagram::fireModifyEvent()
}
// ____ OPropertySet ____
-uno::Any Diagram::GetDefaultValue( sal_Int32 nHandle ) const
+void Diagram::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticDiagramDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticDiagramDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL Diagram::getInfoHelper()
{
- return *StaticDiagramInfoHelper::get();
+ return StaticDiagramInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL Diagram::getPropertySetInfo()
{
- return *StaticDiagramInfo::get();
+ return StaticDiagramInfo();
}
// ____ XFastPropertySet ____
-void SAL_CALL Diagram::setFastPropertyValue( sal_Int32 nHandle, const Any& rValue )
+void SAL_CALL Diagram::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue )
{
//special treatment for some 3D properties
if( nHandle == PROP_DIAGRAM_PERSPECTIVE )
{
sal_Int32 fPerspective = 20;
if( rValue >>=fPerspective )
- ThreeDHelper::setCameraDistance( this, ThreeDHelper::PerspectiveToCameraDistance( fPerspective ) );
+ setCameraDistance( ThreeDHelper::PerspectiveToCameraDistance( fPerspective ) );
}
else if( nHandle == PROP_DIAGRAM_ROTATION_HORIZONTAL
|| nHandle == PROP_DIAGRAM_ROTATION_VERTICAL )
@@ -631,16 +758,16 @@ void SAL_CALL Diagram::setFastPropertyValue( sal_Int32 nHandle, const Any& rValu
if( rValue >>=nNewAngleDegree )
{
sal_Int32 nHorizontal, nVertical;
- ThreeDHelper::getRotationFromDiagram( this, nHorizontal, nVertical );
+ getRotation( nHorizontal, nVertical );
if( nHandle == PROP_DIAGRAM_ROTATION_HORIZONTAL )
nHorizontal = nNewAngleDegree;
else
nVertical = nNewAngleDegree;
- ThreeDHelper::setRotationToDiagram( this, nHorizontal, nVertical );
+ setRotation( nHorizontal, nVertical );
}
}
else
- ::property::OPropertySet::setFastPropertyValue( nHandle, rValue );
+ ::property::OPropertySet::setFastPropertyValue_NoBroadcast( nHandle, rValue );
}
void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
@@ -649,14 +776,14 @@ void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) co
if( nHandle == PROP_DIAGRAM_PERSPECTIVE )
{
sal_Int32 nPerspective = ::basegfx::fround( ThreeDHelper::CameraDistanceToPerspective(
- ThreeDHelper::getCameraDistance( const_cast< Diagram* >( this ) ) ) );
+ const_cast< Diagram* >( this )->getCameraDistance() ) );
rValue <<= nPerspective;
}
else if( nHandle == PROP_DIAGRAM_ROTATION_HORIZONTAL
|| nHandle == PROP_DIAGRAM_ROTATION_VERTICAL )
{
sal_Int32 nHorizontal, nVertical;
- ThreeDHelper::getRotationFromDiagram( const_cast< Diagram* >( this ), nHorizontal, nVertical );
+ const_cast< Diagram* >( this )->getRotation( nHorizontal, nVertical );
sal_Int32 nAngleDegree = 0;
if( nHandle == PROP_DIAGRAM_ROTATION_HORIZONTAL )
nAngleDegree = nHorizontal;
@@ -668,6 +795,42 @@ void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) co
::property::OPropertySet::getFastPropertyValue( rValue,nHandle );
}
+uno::Reference<chart2::XDataTable> SAL_CALL Diagram::getDataTable()
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xDataTable;
+}
+
+rtl::Reference<::chart::DataTable> Diagram::getDataTableRef() const
+{
+ MutexGuard aGuard( m_aMutex );
+ return m_xDataTable;
+}
+
+void SAL_CALL Diagram::setDataTable(const uno::Reference<chart2::XDataTable>& xDataTable)
+{
+ auto* pDataTable = dynamic_cast<DataTable*>(xDataTable.get());
+ assert(!xDataTable || pDataTable);
+ setDataTable(rtl::Reference<DataTable>(pDataTable));
+}
+
+void Diagram::setDataTable(const rtl::Reference<DataTable>& xNewDataTable)
+{
+ rtl::Reference<DataTable> xOldDataTable;
+ {
+ MutexGuard aGuard(m_aMutex);
+ if (m_xDataTable == xNewDataTable)
+ return;
+ xOldDataTable = m_xDataTable;
+ m_xDataTable = xNewDataTable;
+ }
+ if (xOldDataTable.is())
+ ModifyListenerHelper::removeListener(xOldDataTable, m_xModifyEventForwarder);
+ if (xNewDataTable.is())
+ ModifyListenerHelper::addListener(xNewDataTable, m_xModifyEventForwarder);
+ fireModifyEvent();
+}
+
using impl::Diagram_Base;
IMPLEMENT_FORWARD_XINTERFACE2( Diagram, Diagram_Base, ::property::OPropertySet )
@@ -676,7 +839,7 @@ IMPLEMENT_FORWARD_XTYPEPROVIDER2( Diagram, Diagram_Base, ::property::OPropertySe
// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
OUString SAL_CALL Diagram::getImplementationName()
{
- return "com.sun.star.comp.chart2.Diagram";
+ return u"com.sun.star.comp.chart2.Diagram"_ustr;
}
sal_Bool SAL_CALL Diagram::supportsService( const OUString& rServiceName )
@@ -687,9 +850,1441 @@ sal_Bool SAL_CALL Diagram::supportsService( const OUString& 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" };
+ u"com.sun.star.chart2.Diagram"_ustr,
+ u"com.sun.star.layout.LayoutElement"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr };
+}
+
+DiagramPositioningMode Diagram::getDiagramPositioningMode()
+{
+ DiagramPositioningMode eMode = DiagramPositioningMode::Auto;
+ chart2::RelativePosition aRelPos;
+ chart2::RelativeSize aRelSize;
+ if( (getFastPropertyValue(PROP_DIAGRAM_REL_POS) >>= aRelPos ) &&
+ (getFastPropertyValue(PROP_DIAGRAM_REL_SIZE) >>= aRelSize ) )
+ {
+ bool bPosSizeExcludeAxes=false;
+ getFastPropertyValue(PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS) >>= bPosSizeExcludeAxes;
+ if( bPosSizeExcludeAxes )
+ eMode = DiagramPositioningMode::Excluding;
+ else
+ eMode = DiagramPositioningMode::Including;
+ }
+ return eMode;
+}
+
+
+sal_Int32 Diagram::getCorrectedMissingValueTreatment(
+ const rtl::Reference< ChartType >& xChartType )
+{
+ sal_Int32 nResult = css::chart::MissingValueTreatment::LEAVE_GAP;
+ const uno::Sequence < sal_Int32 > aAvailableMissingValueTreatments(
+ ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ) );
+
+ if( getFastPropertyValue( PROP_DIAGRAM_MISSING_VALUE_TREATMENT ) >>= nResult )
+ {
+ //ensure that the set value is supported by this charttype
+ for( sal_Int32 n : aAvailableMissingValueTreatments )
+ if( n == nResult )
+ return nResult; //ok
+ }
+
+ //otherwise use the first supported one
+ if( aAvailableMissingValueTreatments.hasElements() )
+ {
+ nResult = aAvailableMissingValueTreatments[0];
+ return nResult;
+ }
+
+ return nResult;
+}
+
+void Diagram::setGeometry3D( sal_Int32 nNewGeometry )
+{
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ getDataSeries();
+
+ for (auto const& series : aSeriesVec)
+ {
+ series->setPropertyAlsoToAllAttributedDataPoints(
+ u"Geometry3D"_ustr, uno::Any( nNewGeometry ));
+ }
+}
+
+sal_Int32 Diagram::getGeometry3D( bool& rbFound, bool& rbAmbiguous )
+{
+ sal_Int32 nCommonGeom( css::chart2::DataPointGeometry3D::CUBOID );
+ rbFound = false;
+ rbAmbiguous = false;
+
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec = getDataSeries();
+
+ if( aSeriesVec.empty())
+ rbAmbiguous = true;
+
+ for (auto const& series : aSeriesVec)
+ {
+ try
+ {
+ sal_Int32 nGeom = 0;
+ if( series->getPropertyValue( u"Geometry3D"_ustr) >>= nGeom )
+ {
+ if( ! rbFound )
+ {
+ // first series
+ nCommonGeom = nGeom;
+ rbFound = true;
+ }
+ // further series: compare for uniqueness
+ else if( nCommonGeom != nGeom )
+ {
+ rbAmbiguous = true;
+ break;
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return nCommonGeom;
+}
+
+bool Diagram::isPieOrDonutChart()
+{
+ rtl::Reference< ChartType > xChartType = getChartTypeByIndex( 0 );
+
+ if( xChartType .is() )
+ {
+ OUString aChartType = xChartType->getChartType();
+ if( aChartType == CHART2_SERVICE_NAME_CHARTTYPE_PIE )
+ return true;
+ }
+ return false;
+}
+
+bool Diagram::isSupportingFloorAndWall()
+{
+ //pies and donuts currently do not support this because of wrong files from older versions
+ //todo: allow this in future again, if fileversion is available for OLE objects (metastream)
+ //thus the wrong bottom can be removed on import
+
+ const std::vector< rtl::Reference< ChartType > > aTypes = getChartTypes();
+ for( rtl::Reference< ChartType > const & xType : aTypes )
+ {
+ OUString sChartType = xType->getChartType();
+ if( sChartType.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
+ return false;
+ if( sChartType.match(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
+ return false;
+ if( sChartType.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
+ return false;
+ }
+ return true;
+}
+
+ /**
+ * This method implements the logic of checking if a series can be moved
+ * forward/backward. Depending on the "bDoMove" parameter the series will
+ * be moved (bDoMove = true) or the function just will test if the
+ * series can be moved without doing the move (bDoMove = false).
+ *
+ * @param xDiagram
+ * Reference to the diagram that contains the series.
+ *
+ * @param xGivenDataSeries
+ * Reference to the series that should moved or tested for moving.
+ *
+ * @param bForward
+ * Direction in which the series should be moved or tested for moving.
+ *
+ * @param bDoMove
+ * Should this function really move the series (true) or just test if it is
+ * possible (false).
+ *
+ *
+ * @returns
+ * in case of bDoMove == true
+ * - True : if the move was done
+ * - False : the move failed
+ * in case of bDoMove == false
+ * - True : the series can be moved
+ * - False : the series can not be moved
+ *
+ */
+static bool lcl_moveSeriesOrCheckIfMoveIsAllowed(
+ const Diagram& rDiagram,
+ const rtl::Reference< DataSeries >& xGivenDataSeries,
+ bool bForward,
+ bool bDoMove )
+{
+ bool bMovedOrMoveAllowed = false;
+
+ try
+ {
+ if( !xGivenDataSeries.is() )
+ return false;
+
+ //find position of series.
+ bool bFound = false;
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > aCooSysList( rDiagram.getBaseCoordinateSystems() );
+
+ for( std::size_t nCS = 0; !bFound && nCS < aCooSysList.size(); ++nCS )
+ {
+ const rtl::Reference< BaseCoordinateSystem > & xCooSys( aCooSysList[nCS] );
+
+ //iterate through all chart types in the current coordinate system
+ std::vector< rtl::Reference< ChartType > > aChartTypeList( xCooSys->getChartTypes2() );
+ rtl::Reference< ChartType > xFormerChartType;
+
+ for( std::size_t nT = 0; !bFound && nT < aChartTypeList.size(); ++nT )
+ {
+ rtl::Reference< ChartType > xCurrentChartType( aChartTypeList[nT] );
+
+ //iterate through all series in this chart type
+
+ std::vector< rtl::Reference< DataSeries > > aSeriesList = xCurrentChartType->getDataSeries2();
+
+ for( std::size_t nS = 0; !bFound && nS < aSeriesList.size(); ++nS )
+ {
+
+ // We found the series we are interested in!
+ if( xGivenDataSeries==aSeriesList[nS] )
+ {
+ std::size_t nOldSeriesIndex = nS;
+ bFound = true;
+
+ try
+ {
+ sal_Int32 nNewSeriesIndex = nS;
+
+ // tdf#34517 Bringing forward means increasing, backwards means decreasing series position
+ if( !bForward )
+ nNewSeriesIndex--;
+ else
+ nNewSeriesIndex++;
+
+ if( nNewSeriesIndex >= 0 && o3tl::make_unsigned(nNewSeriesIndex) < aSeriesList.size() )
+ {
+ //move series in the same charttype
+ bMovedOrMoveAllowed = true;
+ if( bDoMove )
+ {
+ aSeriesList[ nOldSeriesIndex ] = aSeriesList[ nNewSeriesIndex ];
+ aSeriesList[ nNewSeriesIndex ] = xGivenDataSeries;
+ xCurrentChartType->setDataSeries( aSeriesList );
+ }
+ }
+ else if( nNewSeriesIndex<0 )
+ {
+ //exchange series with former charttype
+ if( xFormerChartType.is() && DiagramHelper::areChartTypesCompatible( xFormerChartType, xCurrentChartType ) )
+ {
+ bMovedOrMoveAllowed = true;
+ if( bDoMove )
+ {
+ std::vector< rtl::Reference< DataSeries > > aOtherSeriesList = xFormerChartType->getDataSeries2();
+ sal_Int32 nOtherSeriesIndex = aOtherSeriesList.size()-1;
+ if( nOtherSeriesIndex >= 0 && o3tl::make_unsigned(nOtherSeriesIndex) < aOtherSeriesList.size() )
+ {
+ rtl::Reference< DataSeries > xExchangeSeries( aOtherSeriesList[nOtherSeriesIndex] );
+ aOtherSeriesList[nOtherSeriesIndex] = xGivenDataSeries;
+ xFormerChartType->setDataSeries(aOtherSeriesList);
+
+ aSeriesList[nOldSeriesIndex] = std::move(xExchangeSeries);
+ xCurrentChartType->setDataSeries(aSeriesList);
+ }
+ }
+ }
+ }
+ else if( nT+1 < aChartTypeList.size() )
+ {
+ //exchange series with next charttype
+ const rtl::Reference< ChartType >& xOtherChartType( aChartTypeList[nT+1] );
+ if( xOtherChartType.is() && DiagramHelper::areChartTypesCompatible( xOtherChartType, xCurrentChartType ) )
+ {
+ bMovedOrMoveAllowed = true;
+ if( bDoMove )
+ {
+ std::vector< rtl::Reference< DataSeries > > aOtherSeriesList = xOtherChartType->getDataSeries2();
+ if( !aOtherSeriesList.empty() )
+ {
+ rtl::Reference<DataSeries> xExchangeSeries(aOtherSeriesList[0]);
+ aOtherSeriesList[0] = xGivenDataSeries;
+ xOtherChartType->setDataSeries(aOtherSeriesList);
+
+ aSeriesList[nOldSeriesIndex] = std::move(xExchangeSeries);
+ xCurrentChartType->setDataSeries(aSeriesList);
+ }
+ }
+ }
+ }
+ }
+ catch( const util::CloseVetoException& )
+ {
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ }
+ }
+ xFormerChartType = std::move(xCurrentChartType);
+ }
+ }
+ }
+ catch( const util::CloseVetoException& )
+ {
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ return bMovedOrMoveAllowed;
+}
+
+bool Diagram::isSeriesMoveable(
+ const rtl::Reference< DataSeries >& xGivenDataSeries,
+ bool bForward )
+{
+ const bool bDoMove = false;
+
+ bool bIsMoveable = lcl_moveSeriesOrCheckIfMoveIsAllowed(
+ *this, xGivenDataSeries, bForward, bDoMove );
+
+ return bIsMoveable;
+}
+
+bool Diagram::moveSeries( const rtl::Reference< DataSeries >& xGivenDataSeries, bool bForward )
+{
+ const bool bDoMove = true;
+
+ bool bMoved = lcl_moveSeriesOrCheckIfMoveIsAllowed(
+ *this, xGivenDataSeries, bForward, bDoMove );
+
+ return bMoved;
+}
+
+std::vector< rtl::Reference< ChartType > > Diagram::getChartTypes()
+{
+ std::vector< rtl::Reference< ChartType > > aResult;
+ try
+ {
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : getBaseCoordinateSystems() )
+ {
+ const std::vector< rtl::Reference< ChartType > > & aChartTypeSeq( coords->getChartTypes2());
+ aResult.insert( aResult.end(), aChartTypeSeq.begin(), aChartTypeSeq.end() );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return aResult;
+}
+
+rtl::Reference< ChartType > Diagram::getChartTypeByIndex( sal_Int32 nIndex )
+{
+ rtl::Reference< ChartType > xChartType;
+
+ //iterate through all coordinate systems
+ sal_Int32 nTypesSoFar = 0;
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : getBaseCoordinateSystems() )
+ {
+ const std::vector< rtl::Reference< ChartType > > & aChartTypeList( coords->getChartTypes2() );
+ if( nIndex >= 0 && o3tl::make_unsigned(nIndex) < nTypesSoFar + aChartTypeList.size() )
+ {
+ xChartType = aChartTypeList[nIndex - nTypesSoFar];
+ break;
+ }
+ nTypesSoFar += aChartTypeList.size();
+ }
+
+ return xChartType;
+}
+
+bool Diagram::isSupportingDateAxis()
+{
+ auto xChartType = getChartTypeByIndex(0);
+ return xChartType.is() ? xChartType->isSupportingDateAxis(0) : true;
+}
+
+static std::vector< rtl::Reference< Axis > > lcl_getAxisHoldingCategoriesFromDiagram(
+ const Diagram& rDiagram )
+{
+ std::vector< rtl::Reference< Axis > > aRet;
+
+ // return first x-axis as fall-back
+ rtl::Reference< Axis > xFallBack;
+ try
+ {
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : rDiagram.getBaseCoordinateSystems() )
+ {
+ OSL_ASSERT( xCooSys.is());
+ for( sal_Int32 nN = xCooSys->getDimension(); nN--; )
+ {
+ const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nN);
+ for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI)
+ {
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2( nN,nI );
+ OSL_ASSERT( xAxis.is());
+ if( xAxis.is())
+ {
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ if( aScaleData.Categories.is() || (aScaleData.AxisType == chart2::AxisType::CATEGORY) )
+ {
+ aRet.push_back(xAxis);
+ }
+ if( (nN == 0) && !xFallBack.is())
+ xFallBack = std::move(xAxis);
+ }
+ }
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2" );
+ }
+
+ if( aRet.empty() )
+ aRet.push_back(xFallBack);
+
+ return aRet;
+}
+
+uno::Reference< chart2::data::XLabeledDataSequence > Diagram::getCategories()
+{
+ uno::Reference< chart2::data::XLabeledDataSequence > xResult;
+
+ try
+ {
+ std::vector< rtl::Reference< Axis > > aCatAxes(
+ lcl_getAxisHoldingCategoriesFromDiagram( *this ));
+ //search for first categories
+ if (aCatAxes.empty())
+ return xResult;
+
+ const rtl::Reference< Axis >& xCatAxis(aCatAxes[0]);
+ if( !xCatAxis.is())
+ return xResult;
+
+ chart2::ScaleData aScaleData( xCatAxis->getScaleData());
+ if( !aScaleData.Categories.is() )
+ return xResult;
+
+ xResult = aScaleData.Categories;
+ uno::Reference<beans::XPropertySet> xProp(xResult->getValues(), uno::UNO_QUERY );
+ if( xProp.is() )
+ {
+ try
+ {
+ xProp->setPropertyValue( u"Role"_ustr, uno::Any( u"categories"_ustr ) );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return xResult;
+}
+
+void Diagram::setCategories(
+ const uno::Reference< chart2::data::XLabeledDataSequence >& xCategories,
+ bool bSetAxisType /* = false */,
+ bool bCategoryAxis /* = true */ )
+{
+ std::vector< rtl::Reference< Axis > > aCatAxes(
+ lcl_getAxisHoldingCategoriesFromDiagram( *this ));
+
+ for (const rtl::Reference< Axis >& xCatAxis : aCatAxes)
+ {
+ if( xCatAxis.is())
+ {
+ chart2::ScaleData aScaleData( xCatAxis->getScaleData());
+ aScaleData.Categories = xCategories;
+ if( bSetAxisType )
+ {
+ if( bCategoryAxis )
+ aScaleData.AxisType = chart2::AxisType::CATEGORY;
+ else if( aScaleData.AxisType == chart2::AxisType::CATEGORY || aScaleData.AxisType == chart2::AxisType::DATE )
+ aScaleData.AxisType = chart2::AxisType::REALNUMBER;
+ }
+ xCatAxis->setScaleData( aScaleData );
+ }
+ }
+}
+
+bool Diagram::isCategory()
+{
+ try
+ {
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() )
+ {
+ for( sal_Int32 nN = xCooSys->getDimension(); nN--; )
+ {
+ const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nN);
+ for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI)
+ {
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2( nN,nI );
+ OSL_ASSERT( xAxis.is());
+ if( xAxis.is())
+ {
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ if( aScaleData.AxisType == chart2::AxisType::CATEGORY || aScaleData.AxisType == chart2::AxisType::DATE )
+ return true;
+ }
+ }
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return false;
+}
+
+std::vector< std::vector< rtl::Reference< DataSeries > > >
+Diagram::getDataSeriesGroups()
+{
+ std::vector< std::vector< rtl::Reference< DataSeries > > > aResult;
+
+ //iterate through all coordinate systems
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : getBaseCoordinateSystems() )
+ {
+ //iterate through all chart types in the current coordinate system
+ for( rtl::Reference< ChartType > const & chartType : coords->getChartTypes2() )
+ {
+ aResult.push_back( chartType->getDataSeries2() );
+ }
+ }
+ return aResult;
+}
+
+std::vector< rtl::Reference< ::chart::DataSeries > >
+ Diagram::getDataSeries()
+{
+ std::vector< rtl::Reference< DataSeries > > aResult;
+ try
+ {
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : getBaseCoordinateSystems() )
+ {
+ for( rtl::Reference< ChartType> const & chartType : coords->getChartTypes2() )
+ {
+ const std::vector< rtl::Reference< DataSeries > > aSeriesSeq( chartType->getDataSeries2() );
+ aResult.insert( aResult.end(), aSeriesSeq.begin(), aSeriesSeq.end() );
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return aResult;
+}
+
+rtl::Reference< ChartType > Diagram::getChartTypeOfSeries(
+ const rtl::Reference< DataSeries >& xGivenDataSeries )
+{
+ if( !xGivenDataSeries.is() )
+ return nullptr;
+
+ //iterate through the model to find the given xSeries
+ //the found parent indicates the charttype
+
+ //iterate through all coordinate systems
+
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() )
+ {
+ //iterate through all chart types in the current coordinate system
+ const std::vector< rtl::Reference< ChartType > > & aChartTypeList( xCooSys->getChartTypes2() );
+ for( rtl::Reference< ChartType > const & xChartType : aChartTypeList )
+ {
+ //iterate through all series in this chart type
+ for( rtl::Reference< DataSeries > const & dataSeries : xChartType->getDataSeries2() )
+ {
+ if( xGivenDataSeries==dataSeries )
+ return xChartType;
+ }
+ }
+ }
+ return nullptr;
+}
+
+rtl::Reference< Axis > Diagram::getAttachedAxis(
+ const rtl::Reference< DataSeries >& xSeries )
+{
+ return AxisHelper::getAxis( 1, !xSeries || xSeries->isAttachedToMainAxis(), this );
+}
+
+bool Diagram::attachSeriesToAxis( bool bAttachToMainAxis
+ , const rtl::Reference< DataSeries >& xDataSeries
+ , const uno::Reference< uno::XComponentContext > & xContext
+ , bool bAdaptAxes )
+{
+ bool bChanged = false;
+
+ //set property at axis
+
+ sal_Int32 nNewAxisIndex = bAttachToMainAxis ? 0 : 1;
+ sal_Int32 nOldAxisIndex = xDataSeries->getAttachedAxisIndex();
+ rtl::Reference< Axis > xOldAxis = getAttachedAxis( xDataSeries );
+
+ if( nOldAxisIndex != nNewAxisIndex )
+ {
+ try
+ {
+ xDataSeries->setPropertyValue( u"AttachedAxisIndex"_ustr, uno::Any( nNewAxisIndex ) );
+ bChanged = true;
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ if( bChanged )
+ {
+ rtl::Reference< Axis > xAxis = AxisHelper::getAxis( 1, bAttachToMainAxis, this );
+ if(!xAxis.is()) //create an axis if necessary
+ xAxis = AxisHelper::createAxis( 1, bAttachToMainAxis, this, xContext );
+ if( bAdaptAxes )
+ {
+ AxisHelper::makeAxisVisible( xAxis );
+ AxisHelper::hideAxisIfNoDataIsAttached( xOldAxis, this );
+ }
+ }
+
+ return bChanged;
+}
+
+void Diagram::replaceCoordinateSystem(
+ const rtl::Reference< BaseCoordinateSystem > & xCooSysToReplace,
+ const rtl::Reference< BaseCoordinateSystem > & xReplacement )
+{
+ // update the coordinate-system container
+ try
+ {
+ uno::Reference< chart2::data::XLabeledDataSequence > xCategories = getCategories();
+
+ // move chart types of xCooSysToReplace to xReplacement
+ xReplacement->setChartTypes( xCooSysToReplace->getChartTypes());
+
+ removeCoordinateSystem( xCooSysToReplace );
+ addCoordinateSystem( xReplacement );
+
+ if( xCategories.is() )
+ setCategories( xCategories );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+sal_Int32 Diagram::getDimension()
+{
+ // -1: not yet set
+ sal_Int32 nResult = -1;
+
+ try
+ {
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() )
+ {
+ if(xCooSys.is())
+ {
+ nResult = xCooSys->getDimension();
+ break;
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ return nResult;
+}
+
+void Diagram::setDimension( sal_Int32 nNewDimensionCount )
+{
+ if( getDimension() == nNewDimensionCount )
+ return;
+
+ try
+ {
+ bool rbFound = false;
+ bool rbAmbiguous = true;
+ StackMode eStackMode = getStackMode( rbFound, rbAmbiguous );
+ bool bIsSupportingOnlyDeepStackingFor3D=false;
+
+ //change all coordinate systems:
+ auto aCoordSystems = getBaseCoordinateSystems();
+ for( rtl::Reference<BaseCoordinateSystem> const & xOldCooSys : aCoordSystems )
+ {
+ rtl::Reference< BaseCoordinateSystem > xNewCooSys;
+
+ const std::vector< rtl::Reference< ChartType > > aChartTypeList( xOldCooSys->getChartTypes2() );
+ for( rtl::Reference< ChartType > const & xChartType : aChartTypeList )
+ {
+ bIsSupportingOnlyDeepStackingFor3D = xChartType.is() ? xChartType->isSupportingOnlyDeepStackingFor3D() : false;
+ if(!xNewCooSys.is())
+ {
+ xNewCooSys = dynamic_cast<BaseCoordinateSystem*>(xChartType->createCoordinateSystem( nNewDimensionCount ).get());
+ assert(xNewCooSys);
+ break;
+ }
+ //@todo make sure that all following charttypes are also capable of the new dimension
+ //otherwise separate them in a different group
+ //BM: might be done in replaceCoordinateSystem()
+ }
+
+ // replace the old coordinate system at all places where it was used
+ replaceCoordinateSystem( xOldCooSys, xNewCooSys );
+ }
+
+ //correct stack mode if necessary
+ if( nNewDimensionCount==3 && eStackMode != StackMode::ZStacked && bIsSupportingOnlyDeepStackingFor3D )
+ setStackMode( StackMode::ZStacked );
+ else if( nNewDimensionCount==2 && eStackMode == StackMode::ZStacked )
+ setStackMode( StackMode::NONE );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+void Diagram::setStackMode( StackMode eStackMode )
+{
+ try
+ {
+ bool bValueFound = false;
+ bool bIsAmbiguous = false;
+ StackMode eOldStackMode = getStackMode( bValueFound, bIsAmbiguous );
+
+ if( eStackMode == eOldStackMode && !bIsAmbiguous )
+ return;
+
+ chart2::StackingDirection eNewDirection = chart2::StackingDirection_NO_STACKING;
+ if( eStackMode == StackMode::YStacked || eStackMode == StackMode::YStackedPercent )
+ eNewDirection = chart2::StackingDirection_Y_STACKING;
+ else if( eStackMode == StackMode::ZStacked )
+ eNewDirection = chart2::StackingDirection_Z_STACKING;
+
+ uno::Any aNewDirection( eNewDirection );
+
+ bool bPercent = false;
+ if( eStackMode == StackMode::YStackedPercent )
+ bPercent = true;
+
+ //iterate through all coordinate systems
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() )
+ {
+ //set correct percent stacking
+ const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(1);
+ for(sal_Int32 nI=0; nI<=nMaximumScaleIndex; ++nI)
+ {
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2( 1,nI );
+ if( xAxis.is())
+ {
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ if( (aScaleData.AxisType==chart2::AxisType::PERCENT) != bPercent )
+ {
+ if( bPercent )
+ aScaleData.AxisType = chart2::AxisType::PERCENT;
+ else
+ aScaleData.AxisType = chart2::AxisType::REALNUMBER;
+ xAxis->setScaleData( aScaleData );
+ }
+ }
+ }
+ //iterate through all chart types in the current coordinate system
+ const std::vector< rtl::Reference< ChartType > > & aChartTypeList( xCooSys->getChartTypes2() );
+ if (aChartTypeList.empty())
+ continue;
+
+ rtl::Reference< ChartType > xChartType( aChartTypeList[0] );
+
+ //iterate through all series in this chart type
+ for( rtl::Reference< DataSeries > const & dataSeries : xChartType->getDataSeries2() )
+ {
+ dataSeries->setPropertyValue( u"StackingDirection"_ustr, aNewDirection );
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+StackMode Diagram::getStackMode( bool& rbFound, bool& rbAmbiguous )
+{
+ rbFound=false;
+ rbAmbiguous=false;
+
+ StackMode eGlobalStackMode = StackMode::NONE;
+
+ //iterate through all coordinate systems
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() )
+ {
+ //iterate through all chart types in the current coordinate system
+ std::vector< rtl::Reference< ChartType > > aChartTypeList( xCooSys->getChartTypes2() );
+ for( std::size_t nT = 0; nT < aChartTypeList.size(); ++nT )
+ {
+ const rtl::Reference< ChartType >& xChartType( aChartTypeList[nT] );
+
+ StackMode eLocalStackMode = DiagramHelper::getStackModeFromChartType(
+ xChartType, rbFound, rbAmbiguous, xCooSys );
+
+ if( rbFound && eLocalStackMode != eGlobalStackMode && nT>0 )
+ {
+ rbAmbiguous = true;
+ return eGlobalStackMode;
+ }
+
+ eGlobalStackMode = eLocalStackMode;
+ }
+ }
+
+ return eGlobalStackMode;
+}
+
+void Diagram::setVertical( bool bVertical /* = true */ )
+{
+ try
+ {
+ uno::Any aValue;
+ aValue <<= bVertical;
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : getBaseCoordinateSystems() )
+ {
+ bool bChanged = false;
+ bool bOldSwap = false;
+ if( !(xCooSys->getPropertyValue(u"SwapXAndYAxis"_ustr) >>= bOldSwap)
+ || bVertical != bOldSwap )
+ bChanged = true;
+
+ if( bChanged )
+ xCooSys->setPropertyValue(u"SwapXAndYAxis"_ustr, aValue);
+
+ const sal_Int32 nDimensionCount = xCooSys->getDimension();
+ sal_Int32 nDimIndex = 0;
+ for (nDimIndex=0; nDimIndex < nDimensionCount; ++nDimIndex)
+ {
+ const sal_Int32 nMaximumScaleIndex = xCooSys->getMaximumAxisIndexByDimension(nDimIndex);
+ for (sal_Int32 nI = 0; nI <= nMaximumScaleIndex; ++nI)
+ {
+ rtl::Reference<Axis> xAxis = xCooSys->getAxisByDimension2(nDimIndex,nI);
+ if (!xAxis.is())
+ continue;
+
+ //adapt title rotation only when axis swapping has changed
+ if (!bChanged)
+ continue;
+
+ Reference< beans::XPropertySet > xTitleProps( xAxis->getTitleObject(), uno::UNO_QUERY );
+ if (!xTitleProps.is())
+ continue;
+
+ double fAngleDegree = 0.0;
+ xTitleProps->getPropertyValue(u"TextRotation"_ustr) >>= fAngleDegree;
+ if (fAngleDegree != 0.0 &&
+ !rtl::math::approxEqual(fAngleDegree, 90.0))
+ continue;
+
+ double fNewAngleDegree = 0.0;
+ if( !bVertical && nDimIndex == 1 )
+ fNewAngleDegree = 90.0;
+ else if( bVertical && nDimIndex == 0 )
+ fNewAngleDegree = 90.0;
+
+ xTitleProps->setPropertyValue(u"TextRotation"_ustr, uno::Any(fNewAngleDegree));
+ }
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+bool Diagram::getVertical( bool& rbFound, bool& rbAmbiguous )
+{
+ bool bValue = false;
+ rbFound = false;
+ rbAmbiguous = false;
+
+ for (rtl::Reference<BaseCoordinateSystem> const & coords : getBaseCoordinateSystems())
+ {
+ bool bCurrent = false;
+ if (coords->getPropertyValue(u"SwapXAndYAxis"_ustr) >>= bCurrent)
+ {
+ if (!rbFound)
+ {
+ bValue = bCurrent;
+ rbFound = true;
+ }
+ else if (bCurrent != bValue)
+ {
+ // ambiguous -> choose always first found
+ rbAmbiguous = true;
+ }
+ }
+ }
+ return bValue;
+}
+
+Diagram::tTemplateWithServiceName
+ Diagram::getTemplate(
+ const rtl::Reference< ::chart::ChartTypeManager > & xChartTypeManager )
+{
+ tTemplateWithServiceName aResult;
+
+ if( !xChartTypeManager )
+ return aResult;
+
+ Sequence< OUString > aServiceNames( xChartTypeManager->getAvailableServiceNames());
+ const sal_Int32 nLength = aServiceNames.getLength();
+
+ bool bTemplateFound = false;
+
+ for( sal_Int32 i = 0; ! bTemplateFound && i < nLength; ++i )
+ {
+ try
+ {
+ rtl::Reference< ::chart::ChartTypeTemplate > xTempl =
+ xChartTypeManager->createTemplate( aServiceNames[ i ] );
+
+ if (xTempl.is() && xTempl->matchesTemplate2(this, true))
+ {
+ aResult.xChartTypeTemplate = std::move(xTempl);
+ aResult.sServiceName = aServiceNames[ i ];
+ bTemplateFound = true;
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ }
+
+ return aResult;
+}
+
+std::vector< rtl::Reference< RegressionCurveModel > >
+ Diagram::getAllRegressionCurvesNotMeanValueLine()
+{
+ std::vector< rtl::Reference< RegressionCurveModel > > aResult;
+ std::vector< rtl::Reference< DataSeries > > aSeries( getDataSeries());
+ for (auto const& elem : aSeries)
+ {
+ for( rtl::Reference< RegressionCurveModel > const & curve : elem->getRegressionCurves2() )
+ {
+ if( ! RegressionCurveHelper::isMeanValueLine( curve ))
+ aResult.push_back( curve );
+ }
+ }
+
+ return aResult;
+}
+
+double Diagram::getCameraDistance()
+{
+ double fCameraDistance = FIXED_SIZE_FOR_3D_CHART_VOLUME;
+
+ try
+ {
+ drawing::CameraGeometry aCG( ThreeDHelper::getDefaultCameraGeometry() );
+ getFastPropertyValue( PROP_SCENE_CAMERA_GEOMETRY ) >>= aCG;
+ ::basegfx::B3DVector aVRP( BaseGFXHelper::Position3DToB3DVector( aCG.vrp ) );
+ fCameraDistance = aVRP.getLength();
+
+ ThreeDHelper::ensureCameraDistanceRange( fCameraDistance );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+ return fCameraDistance;
+}
+
+void Diagram::setCameraDistance(double fCameraDistance )
+{
+ try
+ {
+ if( fCameraDistance <= 0 )
+ fCameraDistance = FIXED_SIZE_FOR_3D_CHART_VOLUME;
+
+ drawing::CameraGeometry aCG( ThreeDHelper::getDefaultCameraGeometry() );
+ getFastPropertyValue( PROP_SCENE_CAMERA_GEOMETRY ) >>= aCG;
+ ::basegfx::B3DVector aVRP( BaseGFXHelper::Position3DToB3DVector( aCG.vrp ) );
+ if( ::basegfx::fTools::equalZero( aVRP.getLength() ) )
+ aVRP = ::basegfx::B3DVector(0,0,1);
+ aVRP.setLength(fCameraDistance);
+ aCG.vrp = BaseGFXHelper::B3DVectorToPosition3D( aVRP );
+
+ setFastPropertyValue( PROP_SCENE_CAMERA_GEOMETRY, uno::Any( aCG ));
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+static bool lcl_isRightAngledAxesSetAndSupported( Diagram& rDiagram )
+{
+ bool bRightAngledAxes = false;
+ rDiagram.getFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES ) >>= bRightAngledAxes; // "RightAngledAxes"
+ if(bRightAngledAxes)
+ {
+ auto xChartType = rDiagram.getChartTypeByIndex(0);
+ if (xChartType.is() ? xChartType->isSupportingRightAngledAxes() : true)
+ return true;
+ }
+ return false;
+}
+
+void Diagram::getRotation( sal_Int32& rnHorizontalAngleDegree, sal_Int32& rnVerticalAngleDegree )
+{
+ double fXAngle, fYAngle, fZAngle;
+ getRotationAngle( fXAngle, fYAngle, fZAngle );
+
+ if( !lcl_isRightAngledAxesSetAndSupported( *this ) )
+ {
+ ThreeDHelper::convertXYZAngleRadToElevationRotationDeg(
+ rnHorizontalAngleDegree, rnVerticalAngleDegree, fXAngle, fYAngle, fZAngle);
+ rnVerticalAngleDegree*=-1;
+ }
+ else
+ {
+ rnHorizontalAngleDegree = basegfx::fround(basegfx::rad2deg(fXAngle));
+ rnVerticalAngleDegree = basegfx::fround(-1.0 * basegfx::rad2deg(fYAngle));
+ // nZRotation = basegfx::fround(-1.0 * basegfx::rad2deg(fZAngle));
+ }
+
+ rnHorizontalAngleDegree = NormAngle180(rnHorizontalAngleDegree);
+ rnVerticalAngleDegree = NormAngle180(rnVerticalAngleDegree);
+}
+
+void Diagram::setRotation( sal_Int32 nHorizontalAngleDegree, sal_Int32 nVerticalYAngleDegree )
+{
+ //todo: x and y is not equal to horz and vert in case of RightAngledAxes==false
+ double fXAngle = basegfx::deg2rad(nHorizontalAngleDegree);
+ double fYAngle = basegfx::deg2rad(-1 * nVerticalYAngleDegree);
+ double fZAngle = 0.0;
+
+ if( !lcl_isRightAngledAxesSetAndSupported( *this ) )
+ ThreeDHelper::convertElevationRotationDegToXYZAngleRad(
+ nHorizontalAngleDegree, -1*nVerticalYAngleDegree, fXAngle, fYAngle, fZAngle );
+
+ setRotationAngle( fXAngle, fYAngle, fZAngle );
+}
+
+static ::basegfx::B3DHomMatrix lcl_getCameraMatrix( Diagram& rDiagram )
+{
+ drawing::HomogenMatrix aCameraMatrix;
+
+ drawing::CameraGeometry aCG( ThreeDHelper::getDefaultCameraGeometry() );
+ rDiagram.getFastPropertyValue( PROP_SCENE_CAMERA_GEOMETRY ) >>= aCG; // "D3DCameraGeometry"
+
+ ::basegfx::B3DVector aVPN( BaseGFXHelper::Direction3DToB3DVector( aCG.vpn ) );
+ ::basegfx::B3DVector aVUP( BaseGFXHelper::Direction3DToB3DVector( aCG.vup ) );
+
+ //normalize vectors:
+ aVPN.normalize();
+ aVUP.normalize();
+
+ ::basegfx::B3DVector aCross = ::basegfx::cross( aVUP, aVPN );
+
+ //first line is VUP x VPN
+ aCameraMatrix.Line1.Column1 = aCross[0];
+ aCameraMatrix.Line1.Column2 = aCross[1];
+ aCameraMatrix.Line1.Column3 = aCross[2];
+ aCameraMatrix.Line1.Column4 = 0.0;
+
+ //second line is VUP
+ aCameraMatrix.Line2.Column1 = aVUP[0];
+ aCameraMatrix.Line2.Column2 = aVUP[1];
+ aCameraMatrix.Line2.Column3 = aVUP[2];
+ aCameraMatrix.Line2.Column4 = 0.0;
+
+ //third line is VPN
+ aCameraMatrix.Line3.Column1 = aVPN[0];
+ aCameraMatrix.Line3.Column2 = aVPN[1];
+ aCameraMatrix.Line3.Column3 = aVPN[2];
+ aCameraMatrix.Line3.Column4 = 0.0;
+
+ //fourth line is 0 0 0 1
+ aCameraMatrix.Line4.Column1 = 0.0;
+ aCameraMatrix.Line4.Column2 = 0.0;
+ aCameraMatrix.Line4.Column3 = 0.0;
+ aCameraMatrix.Line4.Column4 = 1.0;
+
+ return BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aCameraMatrix );
+}
+
+static double lcl_shiftAngleToIntervalMinusPiToPi( double fAngleRad )
+{
+ //valid range: ]-Pi,Pi]
+ while( fAngleRad<=-M_PI )
+ fAngleRad+=(2*M_PI);
+ while( fAngleRad>M_PI )
+ fAngleRad-=(2*M_PI);
+ return fAngleRad;
+}
+
+void Diagram::getRotationAngle( double& rfXAngleRad, double& rfYAngleRad, double& rfZAngleRad )
+{
+ //takes the camera and the transformation matrix into account
+
+ rfXAngleRad = rfYAngleRad = rfZAngleRad = 0.0;
+
+ //get camera rotation
+ ::basegfx::B3DHomMatrix aFixCameraRotationMatrix( lcl_getCameraMatrix( *this ) );
+ BaseGFXHelper::ReduceToRotationMatrix( aFixCameraRotationMatrix );
+
+ //get scene rotation
+ ::basegfx::B3DHomMatrix aSceneRotation;
+ {
+ drawing::HomogenMatrix aHomMatrix;
+ // "D3DTransformMatrix"
+ if( getFastPropertyValue( PROP_SCENE_TRANSF_MATRIX ) >>= aHomMatrix )
+ {
+ aSceneRotation = BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHomMatrix );
+ BaseGFXHelper::ReduceToRotationMatrix( aSceneRotation );
+ }
+ }
+
+ ::basegfx::B3DHomMatrix aResultRotation = aFixCameraRotationMatrix * aSceneRotation;
+ ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix( aResultRotation ) );
+
+ rfXAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(aRotation.getX());
+ rfYAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(aRotation.getY());
+ rfZAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(aRotation.getZ());
+
+ if(rfZAngleRad<-M_PI_2 || rfZAngleRad>M_PI_2)
+ {
+ rfZAngleRad-=M_PI;
+ rfXAngleRad-=M_PI;
+ rfYAngleRad=(M_PI-rfYAngleRad);
+
+ rfXAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(rfXAngleRad);
+ rfYAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(rfYAngleRad);
+ rfZAngleRad = lcl_shiftAngleToIntervalMinusPiToPi(rfZAngleRad);
+ }
+}
+
+static ::basegfx::B3DHomMatrix lcl_getInverseRotationMatrix( Diagram& rDiagram )
+{
+ ::basegfx::B3DHomMatrix aInverseRotation;
+ double fXAngleRad=0.0;
+ double fYAngleRad=0.0;
+ double fZAngleRad=0.0;
+ rDiagram.getRotationAngle( fXAngleRad, fYAngleRad, fZAngleRad );
+ aInverseRotation.rotate( 0.0, 0.0, -fZAngleRad );
+ aInverseRotation.rotate( 0.0, -fYAngleRad, 0.0 );
+ aInverseRotation.rotate( -fXAngleRad, 0.0, 0.0 );
+ return aInverseRotation;
+}
+
+static void lcl_rotateLights( const ::basegfx::B3DHomMatrix& rLightRotation, Diagram& rDiagram )
+{
+ ::basegfx::B3DHomMatrix aLightRotation( rLightRotation );
+ BaseGFXHelper::ReduceToRotationMatrix( aLightRotation );
+
+ // "D3DSceneLightDirection1","D3DSceneLightOn1",
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_1, PROP_SCENE_LIGHT_ON_1, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_2, PROP_SCENE_LIGHT_ON_2, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_3, PROP_SCENE_LIGHT_ON_3, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_4, PROP_SCENE_LIGHT_ON_4, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_5, PROP_SCENE_LIGHT_ON_5, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_6, PROP_SCENE_LIGHT_ON_6, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_7, PROP_SCENE_LIGHT_ON_7, aLightRotation );
+ lcl_RotateLightSource( rDiagram, PROP_SCENE_LIGHT_DIRECTION_8, PROP_SCENE_LIGHT_ON_8, aLightRotation );
+}
+
+void Diagram::setRotationAngle(
+ double fXAngleRad, double fYAngleRad, double fZAngleRad )
+{
+ //the rotation of the camera is not touched but taken into account
+ //the rotation difference is applied to the transformation matrix
+
+ //the light sources will be adapted also
+
+ try
+ {
+ //remind old rotation for adaptation of light directions
+ ::basegfx::B3DHomMatrix aInverseOldRotation( lcl_getInverseRotationMatrix( *this ) );
+
+ ::basegfx::B3DHomMatrix aInverseCameraRotation;
+ {
+ ::basegfx::B3DTuple aR( BaseGFXHelper::GetRotationFromMatrix(
+ lcl_getCameraMatrix( *this ) ) );
+ aInverseCameraRotation.rotate( 0.0, 0.0, -aR.getZ() );
+ aInverseCameraRotation.rotate( 0.0, -aR.getY(), 0.0 );
+ aInverseCameraRotation.rotate( -aR.getX(), 0.0, 0.0 );
+ }
+
+ ::basegfx::B3DHomMatrix aCumulatedRotation;
+ aCumulatedRotation.rotate( fXAngleRad, fYAngleRad, fZAngleRad );
+
+ //calculate new scene matrix
+ ::basegfx::B3DHomMatrix aSceneRotation = aInverseCameraRotation*aCumulatedRotation;
+ BaseGFXHelper::ReduceToRotationMatrix( aSceneRotation );
+
+ //set new rotation to transformation matrix ("D3DTransformMatrix")
+ setFastPropertyValue(
+ PROP_SCENE_TRANSF_MATRIX, uno::Any( BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aSceneRotation )));
+
+ //rotate lights if RightAngledAxes are not set or not supported
+ bool bRightAngledAxes = false;
+ getFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES ) >>= bRightAngledAxes;
+ auto xChartType = getChartTypeByIndex(0);
+ if (!bRightAngledAxes || !(xChartType.is() ? xChartType->isSupportingRightAngledAxes() : true))
+ {
+ ::basegfx::B3DHomMatrix aNewRotation;
+ aNewRotation.rotate( fXAngleRad, fYAngleRad, fZAngleRad );
+ lcl_rotateLights( aNewRotation*aInverseOldRotation, *this );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+static bool lcl_isEqual( const drawing::Direction3D& rA, const drawing::Direction3D& rB )
+{
+ return ::rtl::math::approxEqual(rA.DirectionX, rB.DirectionX)
+ && ::rtl::math::approxEqual(rA.DirectionY, rB.DirectionY)
+ && ::rtl::math::approxEqual(rA.DirectionZ, rB.DirectionZ);
+}
+static bool lcl_isSimpleScheme( drawing::ShadeMode aShadeMode
+ , sal_Int32 nRoundedEdges
+ , sal_Int32 nObjectLines
+ , const rtl::Reference< Diagram >& xDiagram )
+{
+ if(aShadeMode!=drawing::ShadeMode_FLAT)
+ return false;
+ if(nRoundedEdges!=0)
+ return false;
+ if(nObjectLines==0)
+ {
+ rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) );
+ return ChartTypeHelper::noBordersForSimpleScheme( xChartType );
+ }
+ if(nObjectLines!=1)
+ return false;
+ return true;
+}
+static bool lcl_isRealisticScheme( drawing::ShadeMode aShadeMode
+ , sal_Int32 nRoundedEdges
+ , sal_Int32 nObjectLines )
+{
+ if(aShadeMode!=drawing::ShadeMode_SMOOTH)
+ return false;
+ if(nRoundedEdges!=5)
+ return false;
+ if(nObjectLines!=0)
+ return false;
+ return true;
+}
+static bool lcl_isLightScheme( Diagram& rDiagram, bool bRealistic )
+{
+ bool bIsOn = false;
+ // "D3DSceneLightOn2" / UNO_NAME_3D_SCENE_LIGHTON_2
+ rDiagram.getFastPropertyValue( PROP_SCENE_LIGHT_ON_2 ) >>= bIsOn;
+ if(!bIsOn)
+ return false;
+
+ rtl::Reference< ChartType > xChartType( rDiagram.getChartTypeByIndex( 0 ) );
+
+ sal_Int32 nColor = 0;
+ // "D3DSceneLightColor2" / UNO_NAME_3D_SCENE_LIGHTCOLOR_2
+ rDiagram.getFastPropertyValue( PROP_SCENE_LIGHT_COLOR_2 ) >>= nColor;
+ if( nColor != ::chart::ChartTypeHelper::getDefaultDirectLightColor( !bRealistic, xChartType ) )
+ return false;
+
+ sal_Int32 nAmbientColor = 0;
+ // "D3DSceneAmbientColor" / UNO_NAME_3D_SCENE_AMBIENTCOLOR
+ rDiagram.getFastPropertyValue( PROP_SCENE_AMBIENT_COLOR ) >>= nAmbientColor;
+ if( nAmbientColor != ::chart::ChartTypeHelper::getDefaultAmbientLightColor( !bRealistic, xChartType ) )
+ return false;
+
+ drawing::Direction3D aDirection(0,0,0);
+ // "D3DSceneLightDirection2" / UNO_NAME_3D_SCENE_LIGHTDIRECTION_2
+ rDiagram.getFastPropertyValue( PROP_SCENE_LIGHT_DIRECTION_2 ) >>= aDirection;
+
+ drawing::Direction3D aDefaultDirection( bRealistic
+ ? ChartTypeHelper::getDefaultRealisticLightDirection(xChartType)
+ : ChartTypeHelper::getDefaultSimpleLightDirection(xChartType) );
+
+ //rotate default light direction when right angled axes are off but supported
+ {
+ bool bRightAngledAxes = false;
+ rDiagram.getFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES ) >>= bRightAngledAxes; // "RightAngledAxes"
+ if(!bRightAngledAxes)
+ {
+ if (xChartType.is() ? xChartType->isSupportingRightAngledAxes() : true)
+ {
+ ::basegfx::B3DHomMatrix aRotation( lcl_getCompleteRotationMatrix( rDiagram ) );
+ BaseGFXHelper::ReduceToRotationMatrix( aRotation );
+ ::basegfx::B3DVector aLightVector( BaseGFXHelper::Direction3DToB3DVector( aDefaultDirection ) );
+ aLightVector = aRotation*aLightVector;
+ aDefaultDirection = BaseGFXHelper::B3DVectorToDirection3D( aLightVector );
+ }
+ }
+ }
+
+ return lcl_isEqual( aDirection, aDefaultDirection );
+}
+static bool lcl_isRealisticLightScheme( Diagram& rDiagram )
+{
+ return lcl_isLightScheme( rDiagram, true /*bRealistic*/ );
+}
+static bool lcl_isSimpleLightScheme( Diagram& rDiagram )
+{
+ return lcl_isLightScheme( rDiagram, false /*bRealistic*/ );
+}
+
+ThreeDLookScheme Diagram::detectScheme()
+{
+ ThreeDLookScheme aScheme = ThreeDLookScheme::ThreeDLookScheme_Unknown;
+
+ sal_Int32 nRoundedEdges;
+ sal_Int32 nObjectLines;
+ ThreeDHelper::getRoundedEdgesAndObjectLines( this, nRoundedEdges, nObjectLines );
+
+ //get shade mode and light settings:
+ drawing::ShadeMode aShadeMode( drawing::ShadeMode_SMOOTH );
+ try
+ {
+ getFastPropertyValue( PROP_SCENE_SHADE_MODE )>>= aShadeMode; // "D3DSceneShadeMode"
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+ if( lcl_isSimpleScheme( aShadeMode, nRoundedEdges, nObjectLines, this ) )
+ {
+ if( lcl_isSimpleLightScheme(*this) )
+ aScheme = ThreeDLookScheme::ThreeDLookScheme_Simple;
+ }
+ else if( lcl_isRealisticScheme( aShadeMode, nRoundedEdges, nObjectLines ) )
+ {
+ if( lcl_isRealisticLightScheme(*this) )
+ aScheme = ThreeDLookScheme::ThreeDLookScheme_Realistic;
+ }
+
+ return aScheme;
+}
+
+static void lcl_setRealisticScheme( drawing::ShadeMode& rShadeMode
+ , sal_Int32& rnRoundedEdges
+ , sal_Int32& rnObjectLines )
+{
+ rShadeMode = drawing::ShadeMode_SMOOTH;
+ rnRoundedEdges = 5;
+ rnObjectLines = 0;
+}
+
+static void lcl_setSimpleScheme( drawing::ShadeMode& rShadeMode
+ , sal_Int32& rnRoundedEdges
+ , sal_Int32& rnObjectLines
+ , const rtl::Reference< Diagram >& xDiagram )
+{
+ rShadeMode = drawing::ShadeMode_FLAT;
+ rnRoundedEdges = 0;
+
+ rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) );
+ rnObjectLines = ChartTypeHelper::noBordersForSimpleScheme( xChartType ) ? 0 : 1;
+}
+void Diagram::setScheme( ThreeDLookScheme aScheme )
+{
+ if( aScheme == ThreeDLookScheme::ThreeDLookScheme_Unknown )
+ return;
+
+ drawing::ShadeMode aShadeMode;
+ sal_Int32 nRoundedEdges;
+ sal_Int32 nObjectLines;
+
+ if( aScheme == ThreeDLookScheme::ThreeDLookScheme_Simple )
+ lcl_setSimpleScheme(aShadeMode,nRoundedEdges,nObjectLines,this);
+ else
+ lcl_setRealisticScheme(aShadeMode,nRoundedEdges,nObjectLines);
+
+ try
+ {
+ ThreeDHelper::setRoundedEdgesAndObjectLines( this, nRoundedEdges, nObjectLines );
+
+ drawing::ShadeMode aOldShadeMode;
+ if( ! (getFastPropertyValue( PROP_SCENE_SHADE_MODE)>>=aOldShadeMode) ||
+ aOldShadeMode != aShadeMode )
+ {
+ setFastPropertyValue( PROP_SCENE_SHADE_MODE, uno::Any( aShadeMode )); // "D3DSceneShadeMode"
+ }
+
+ lcl_setLightsForScheme( *this, aScheme );
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
+}
+
+void Diagram::setDefaultRotation( bool bPieOrDonut )
+{
+ drawing::CameraGeometry aCameraGeo( ThreeDHelper::getDefaultCameraGeometry( bPieOrDonut ) );
+ // "D3DCameraGeometry"
+ setFastPropertyValue( PROP_SCENE_CAMERA_GEOMETRY, uno::Any( aCameraGeo ));
+
+ ::basegfx::B3DHomMatrix aSceneRotation;
+ if( bPieOrDonut )
+ aSceneRotation.rotate( -M_PI/3.0, 0, 0 );
+ // "D3DTransformMatrix"
+ setFastPropertyValue( PROP_SCENE_TRANSF_MATRIX,
+ uno::Any( BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aSceneRotation )));
+}
+
+void Diagram::switchRightAngledAxes( bool bRightAngledAxes )
+{
+ try
+ {
+ bool bOldRightAngledAxes = false;
+ getFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES ) >>= bOldRightAngledAxes; // "RightAngledAxes"
+ if( bOldRightAngledAxes!=bRightAngledAxes)
+ {
+ setFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES, uno::Any( bRightAngledAxes ));
+ if(bRightAngledAxes)
+ {
+ ::basegfx::B3DHomMatrix aInverseRotation( lcl_getInverseRotationMatrix( *this ) );
+ lcl_rotateLights( aInverseRotation, *this );
+ }
+ else
+ {
+ ::basegfx::B3DHomMatrix aCompleteRotation( lcl_getCompleteRotationMatrix( *this ) );
+ lcl_rotateLights( aCompleteRotation, *this );
+ }
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
}
} // namespace chart
diff --git a/chart2/source/model/main/FormattedString.cxx b/chart2/source/model/main/FormattedString.cxx
index 0d6e733a2c31..8e1842559c7b 100644
--- a/chart2/source/model/main/FormattedString.cxx
+++ b/chart2/source/model/main/FormattedString.cxx
@@ -17,13 +17,12 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "FormattedString.hxx"
+#include <FormattedString.hxx>
#include <CharacterProperties.hxx>
#include <PropertyHelper.hxx>
#include <ModifyListenerHelper.hxx>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
namespace com::sun::star::uno { class XComponentContext; }
@@ -33,61 +32,36 @@ using ::com::sun::star::beans::Property;
using ::com::sun::star::uno::Sequence;
using ::osl::MutexGuard;
-namespace
+namespace chart
{
-
-struct StaticFormattedStringDefaults_Initializer
+const ::chart::tPropertyValueMap & StaticFormattedStringDefaults()
{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- ::chart::CharacterProperties::AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
+ static ::chart::tPropertyValueMap aStaticDefaults = []
+ {
+ ::chart::tPropertyValueMap aMap;
+ ::chart::CharacterProperties::AddDefaultsToMap( aMap );
+ return aMap;
+ }();
+ return aStaticDefaults;
};
+} // namespace chart
-struct StaticFormattedStringDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticFormattedStringDefaults_Initializer >
-{
-};
-
-struct StaticFormattedStringInfoHelper_Initializer
+namespace
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticFormattedStringInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticFormattedStringInfoHelper_Initializer >
+::cppu::OPropertyArrayHelper& StaticFormattedStringInfoHelper()
{
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
-struct StaticFormattedStringInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticFormattedStringInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticFormattedStringInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticFormattedStringInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -96,20 +70,19 @@ namespace chart
{
FormattedString::FormattedString() :
- ::property::OPropertySet( m_aMutex ),
- m_aString(),
m_aType(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT),
- m_aGuid(),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_bDataLabelsRange(false),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
FormattedString::FormattedString( const FormattedString & rOther ) :
impl::FormattedString_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
+ ::property::OPropertySet( rOther ),
m_aString( rOther.m_aString ),
m_aType(rOther.m_aType),
m_aGuid(rOther.m_aGuid),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_bDataLabelsRange(rOther.m_bDataLabelsRange),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
FormattedString::~FormattedString()
@@ -174,31 +147,47 @@ void SAL_CALL FormattedString::setGuid( const OUString& guid )
}
-// ____ XModifyBroadcaster ____
-void SAL_CALL FormattedString::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
+sal_Bool SAL_CALL FormattedString::getDataLabelsRange()
+{
+ MutexGuard aGuard( m_aMutex);
+ return m_bDataLabelsRange;
+}
+
+void SAL_CALL FormattedString::setDataLabelsRange( sal_Bool dataLabelsRange )
{
- try
{
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
+ MutexGuard aGuard( m_aMutex);
+ m_bDataLabelsRange = dataLabelsRange;
}
- catch( const uno::Exception & )
+ //don't keep the mutex locked while calling out
+ fireModifyEvent();
+}
+
+OUString SAL_CALL FormattedString::getCellRange()
+{
+ MutexGuard aGuard( m_aMutex);
+ return m_aCellRange;
+}
+
+void SAL_CALL FormattedString::setCellRange( const OUString& cellRange )
+{
{
- DBG_UNHANDLED_EXCEPTION("chart2");
+ MutexGuard aGuard( m_aMutex);
+ m_aCellRange = cellRange;
}
+ //don't keep the mutex locked while calling out
+ fireModifyEvent();
+}
+
+// ____ XModifyBroadcaster ____
+void SAL_CALL FormattedString::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
+{
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL FormattedString::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -225,25 +214,28 @@ void FormattedString::fireModifyEvent()
}
// ____ OPropertySet ____
-uno::Any FormattedString::GetDefaultValue( sal_Int32 nHandle ) const
+void FormattedString::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticFormattedStringDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticFormattedStringDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL FormattedString::getInfoHelper()
{
- return *StaticFormattedStringInfoHelper::get();
+ return StaticFormattedStringInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL FormattedString::getPropertySetInfo()
{
- return *StaticFormattedStringInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticFormattedStringInfoHelper() ) );
+ return xPropertySetInfo;
}
using impl::FormattedString_Base;
@@ -256,7 +248,7 @@ IMPLEMENT_FORWARD_XTYPEPROVIDER2( FormattedString, FormattedString_Base, ::prope
// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
OUString SAL_CALL FormattedString::getImplementationName()
{
- return "com.sun.star.comp.chart.FormattedString";
+ return u"com.sun.star.comp.chart.FormattedString"_ustr;
}
sal_Bool SAL_CALL FormattedString::supportsService( const OUString& rServiceName )
@@ -267,9 +259,9 @@ sal_Bool SAL_CALL FormattedString::supportsService( const OUString& 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" };
+ u"com.sun.star.chart2.DataPointCustomLabelField"_ustr,
+ u"com.sun.star.chart2.FormattedString"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/main/FormattedString.hxx b/chart2/source/model/main/FormattedString.hxx
deleted file mode 100644
index 9d17d5f3885a..000000000000
--- a/chart2/source/model/main/FormattedString.hxx
+++ /dev/null
@@ -1,140 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#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
index 44d3fffd8c67..2c1cacf86cf3 100644
--- a/chart2/source/model/main/GridProperties.cxx
+++ b/chart2/source/model/main/GridProperties.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "GridProperties.hxx"
+#include <GridProperties.hxx>
#include <LinePropertiesHelper.hxx>
#include <UserDefinedProperties.hxx>
#include <PropertyHelper.hxx>
@@ -25,9 +25,7 @@
#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;
@@ -54,71 +52,38 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEDEFAULT );
}
-struct StaticGridDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
-
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_GRID_SHOW, false );
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue< sal_Int32 >(
- rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_COLOR, 0xb3b3b3 ); // gray30
- }
-};
-
-struct StaticGridDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticGridDefaults_Initializer >
-{
-};
-
-struct StaticGridInfoHelper_Initializer
+const ::chart::tPropertyValueMap & StaticGridDefaults()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
- ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_GRID_SHOW, false );
+ // override other defaults
+ ::chart::PropertyHelper::setPropertyValue< sal_Int32 >(
+ aTmp, ::chart::LinePropertiesHelper::PROP_LINE_COLOR, 0xb3b3b3 ); // gray30
+ return aTmp;
+ }();
+ return aStaticDefaults;
};
-struct StaticGridInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticGridInfoHelper_Initializer >
+::cppu::OPropertyArrayHelper& StaticGridInfoHelper()
{
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-struct StaticGridInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticGridInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticGridInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticGridInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -127,14 +92,13 @@ namespace chart
{
GridProperties::GridProperties() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
GridProperties::GridProperties( const GridProperties & rOther ) :
impl::GridProperties_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
}
@@ -142,24 +106,27 @@ GridProperties::~GridProperties()
{}
// ____ OPropertySet ____
-uno::Any GridProperties::GetDefaultValue( sal_Int32 nHandle ) const
+void GridProperties::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticGridDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticGridDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL GridProperties::getInfoHelper()
{
- return *StaticGridInfoHelper::get();
+ return StaticGridInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL GridProperties::getPropertySetInfo()
{
- return *StaticGridInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticGridInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XCloneable ____
@@ -171,28 +138,12 @@ uno::Reference< util::XCloneable > SAL_CALL GridProperties::createClone()
// ____ XModifyBroadcaster ____
void SAL_CALL GridProperties::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL GridProperties::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -216,7 +167,7 @@ void GridProperties::firePropertyChangeEvent()
// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
OUString SAL_CALL GridProperties::getImplementationName()
{
- return "com.sun.star.comp.chart2.GridProperties";
+ return u"com.sun.star.comp.chart2.GridProperties"_ustr;
}
sal_Bool SAL_CALL GridProperties::supportsService( const OUString& rServiceName )
@@ -227,8 +178,8 @@ sal_Bool SAL_CALL GridProperties::supportsService( const OUString& rServiceName
css::uno::Sequence< OUString > SAL_CALL GridProperties::getSupportedServiceNames()
{
return {
- "com.sun.star.chart2.GridProperties",
- "com.sun.star.beans.PropertySet" };
+ u"com.sun.star.chart2.GridProperties"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr };
}
// needed by MSC compiler
diff --git a/chart2/source/model/main/GridProperties.hxx b/chart2/source/model/main/GridProperties.hxx
deleted file mode 100644
index 38d1f9a74ede..000000000000
--- a/chart2/source/model/main/GridProperties.hxx
+++ /dev/null
@@ -1,105 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#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
index 4c3b9f0e5167..5f6ee67ccaa0 100644
--- a/chart2/source/model/main/Legend.cxx
+++ b/chart2/source/model/main/Legend.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "Legend.hxx"
+#include <Legend.hxx>
#include <LinePropertiesHelper.hxx>
#include <FillProperties.hxx>
#include <CharacterProperties.hxx>
@@ -31,7 +31,6 @@
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/RelativeSize.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
#include <algorithm>
@@ -106,78 +105,53 @@ void lcl_AddPropertiesToVector(
}
-struct StaticLegendDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
- ::chart::FillProperties::AddDefaultsToMap( rOutMap );
- ::chart::CharacterProperties::AddDefaultsToMap( rOutMap );
-
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_ANCHOR_POSITION, chart2::LegendPosition_LINE_END );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_EXPANSION, css::chart::ChartLegendExpansion_HIGH );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_SHOW, true );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_OVERLAY, false );
-
- float fDefaultCharHeight = 10.0;
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
- }
-};
+} // namespace
-struct StaticLegendDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLegendDefaults_Initializer >
+namespace chart
{
-};
-
-struct StaticLegendInfoHelper_Initializer
+const ::chart::tPropertyValueMap& StaticLegendDefaults()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
- ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
- ::chart::FillProperties::AddPropertiesToVector( aProperties );
- ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
+ ::chart::FillProperties::AddDefaultsToMap( aTmp );
+ ::chart::CharacterProperties::AddDefaultsToMap( aTmp );
+
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_LEGEND_ANCHOR_POSITION, chart2::LegendPosition_LINE_END );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_LEGEND_EXPANSION, css::chart::ChartLegendExpansion_HIGH );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_LEGEND_SHOW, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_LEGEND_OVERLAY, false );
+
+ float fDefaultCharHeight = 10.0;
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight );
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight );
+ return aTmp;
+ }();
+ return aStaticDefaults;
};
+} // namespace chart
-struct StaticLegendInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLegendInfoHelper_Initializer >
-{
-};
-
-struct StaticLegendInfo_Initializer
+namespace
{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLegendInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticLegendInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLegendInfo_Initializer >
+::cppu::OPropertyArrayHelper& StaticLegendInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -186,15 +160,14 @@ namespace chart
{
Legend::Legend() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
}
Legend::Legend( const Legend & rOther ) :
impl::Legend_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
}
@@ -211,28 +184,12 @@ Reference< util::XCloneable > SAL_CALL Legend::createClone()
// ____ XModifyBroadcaster ____
void SAL_CALL Legend::addModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL Legend::removeModifyListener( const Reference< util::XModifyListener >& aListener )
{
- try
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -254,30 +211,33 @@ void Legend::firePropertyChangeEvent()
}
// ____ OPropertySet ____
-Any Legend::GetDefaultValue( sal_Int32 nHandle ) const
+void Legend::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticLegendDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticLegendDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL Legend::getInfoHelper()
{
- return *StaticLegendInfoHelper::get();
+ return StaticLegendInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL Legend::getPropertySetInfo()
{
- return *StaticLegendInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticLegendInfoHelper() ) );
+ return xPropertySetInfo;
}
// implement XServiceInfo methods basing upon getSupportedServiceNames_Static
OUString SAL_CALL Legend::getImplementationName()
{
- return "com.sun.star.comp.chart2.Legend";
+ return u"com.sun.star.comp.chart2.Legend"_ustr;
}
sal_Bool SAL_CALL Legend::supportsService( const OUString& rServiceName )
@@ -288,12 +248,12 @@ sal_Bool SAL_CALL Legend::supportsService( const OUString& 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"
+ u"com.sun.star.chart2.Legend"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr,
+ u"com.sun.star.drawing.FillProperties"_ustr,
+ u"com.sun.star.drawing.LineProperties"_ustr,
+ u"com.sun.star.style.CharacterProperties"_ustr,
+ u"com.sun.star.layout.LayoutElement"_ustr
};
}
diff --git a/chart2/source/model/main/Legend.hxx b/chart2/source/model/main/Legend.hxx
deleted file mode 100644
index 516324f2e107..000000000000
--- a/chart2/source/model/main/Legend.hxx
+++ /dev/null
@@ -1,107 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#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
index 5dda4cb5a7b4..2bddc6214ca1 100644
--- a/chart2/source/model/main/PageBackground.cxx
+++ b/chart2/source/model/main/PageBackground.cxx
@@ -18,15 +18,17 @@
*/
#include "PageBackground.hxx"
+#include <comphelper/lok.hxx>
#include <LinePropertiesHelper.hxx>
#include <FillProperties.hxx>
#include <UserDefinedProperties.hxx>
#include <PropertyHelper.hxx>
#include <ModifyListenerHelper.hxx>
+#include <svtools/colorcfg.hxx>
+#include <sfx2/viewsh.hxx>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
#include <vector>
#include <algorithm>
@@ -40,70 +42,47 @@ using ::com::sun::star::beans::Property;
namespace
{
-struct StaticPageBackgroundDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
- ::chart::FillProperties::AddDefaultsToMap( rOutMap );
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
- }
+const ::chart::tPropertyValueMap& StaticPageBackgroundDefaults()
+{
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
+ ::chart::FillProperties::AddDefaultsToMap( aTmp );
+
+ // override other defaults
+ Color aDocColor = COL_WHITE;
+ if (comphelper::LibreOfficeKit::isActive()) {
+ aDocColor = COL_AUTO;
+ } else {
+ if (SfxViewShell* pCurrentSh = SfxViewShell::Current()) {
+ aDocColor = pCurrentSh->GetColorConfigColor(svtools::DOCCOLOR);
+ } else {
+ aDocColor = svtools::ColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
+ }
+ }
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::FillProperties::PROP_FILL_COLOR, aDocColor );
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
+ return aTmp;
+ }();
+ return aStaticDefaults;
};
-struct StaticPageBackgroundDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPageBackgroundDefaults_Initializer >
+::cppu::OPropertyArrayHelper& StaticPageBackgroundInfoHelper()
{
-};
-
-struct StaticPageBackgroundInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static uno::Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
- ::chart::FillProperties::AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
- return comphelper::containerToSequence( aProperties );
- }
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-};
-
-struct StaticPageBackgroundInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticPageBackgroundInfoHelper_Initializer >
-{
-};
-
-struct StaticPageBackgroundInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPageBackgroundInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticPageBackgroundInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPageBackgroundInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -112,19 +91,26 @@ namespace chart
{
PageBackground::PageBackground() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
PageBackground::PageBackground( const PageBackground & rOther ) :
impl::PageBackground_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
PageBackground::~PageBackground()
{}
+// ____ XTypeProvider ____
+uno::Sequence< css::uno::Type > SAL_CALL PageBackground::getTypes()
+{
+ return ::comphelper::concatSequences(
+ impl::PageBackground_Base::getTypes(),
+ ::property::OPropertySet::getTypes());
+}
+
// ____ XCloneable ____
uno::Reference< util::XCloneable > SAL_CALL PageBackground::createClone()
{
@@ -132,51 +118,38 @@ uno::Reference< util::XCloneable > SAL_CALL PageBackground::createClone()
}
// ____ OPropertySet ____
-uno::Any PageBackground::GetDefaultValue( sal_Int32 nHandle ) const
+void PageBackground::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticPageBackgroundDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticPageBackgroundDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL PageBackground::getInfoHelper()
{
- return *StaticPageBackgroundInfoHelper::get();
+ return StaticPageBackgroundInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL PageBackground::getPropertySetInfo()
{
- return *StaticPageBackgroundInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticPageBackgroundInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XModifyBroadcaster ____
void SAL_CALL PageBackground::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL PageBackground::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -199,7 +172,7 @@ void PageBackground::firePropertyChangeEvent()
OUString SAL_CALL PageBackground::getImplementationName()
{
- return "com.sun.star.comp.chart2.PageBackground";
+ return u"com.sun.star.comp.chart2.PageBackground"_ustr;
}
sal_Bool SAL_CALL PageBackground::supportsService( const OUString& rServiceName )
@@ -210,8 +183,8 @@ sal_Bool SAL_CALL PageBackground::supportsService( const OUString& rServiceName
css::uno::Sequence< OUString > SAL_CALL PageBackground::getSupportedServiceNames()
{
return {
- "com.sun.star.chart2.PageBackground",
- "com.sun.star.beans.PropertySet" };
+ u"com.sun.star.chart2.PageBackground"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr };
}
using impl::PageBackground_Base;
diff --git a/chart2/source/model/main/PageBackground.hxx b/chart2/source/model/main/PageBackground.hxx
index 9157eb9d90c9..2aef8bd45ebe 100644
--- a/chart2/source/model/main/PageBackground.hxx
+++ b/chart2/source/model/main/PageBackground.hxx
@@ -16,18 +16,14 @@
* 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
+#pragma once
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-#include <MutexContainer.hxx>
#include <OPropertySet.hxx>
#include <cppuhelper/implbase.hxx>
-
#include <comphelper/uno3.hxx>
+#include <ModifyListenerHelper.hxx>
namespace chart
{
@@ -43,7 +39,6 @@ typedef ::cppu::WeakImplHelper<
}
class PageBackground final :
- public MutexContainer,
public impl::PageBackground_Base,
public ::property::OPropertySet
{
@@ -59,11 +54,13 @@ public:
/// merge XInterface implementations
DECLARE_XINTERFACE()
-private:
explicit PageBackground( const PageBackground & rOther );
+ // ____ XTypeProvider ____
+ virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
+
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
// ____ OPropertySet ____
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -81,6 +78,8 @@ private:
virtual void SAL_CALL removeModifyListener(
const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
+private:
+
// ____ XModifyListener ____
virtual void SAL_CALL modified(
const css::lang::EventObject& aEvent ) override;
@@ -93,12 +92,9 @@ private:
virtual void firePropertyChangeEvent() override;
using OPropertySet::disposing;
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
+ rtl::Reference<ModifyEventForwarder> 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
index 5ec3252ae582..e2581c0a55f2 100644
--- a/chart2/source/model/main/PolarCoordinateSystem.cxx
+++ b/chart2/source/model/main/PolarCoordinateSystem.cxx
@@ -31,7 +31,8 @@ using ::com::sun::star::uno::Sequence;
namespace
{
-const char CHART2_COOSYSTEM_POLAR_SERVICE_NAME[] = "com.sun.star.chart2.CoordinateSystems.Polar";
+constexpr OUString CHART2_COOSYSTEM_POLAR_SERVICE_NAME
+ = u"com.sun.star.chart2.CoordinateSystems.Polar"_ustr;
}
@@ -71,7 +72,7 @@ uno::Reference< util::XCloneable > SAL_CALL PolarCoordinateSystem::createClone()
// ____ XServiceInfo ____
OUString SAL_CALL PolarCoordinateSystem::getImplementationName()
{
- return "com.sun.star.comp.chart.PolarCoordinateSystem";
+ return u"com.sun.star.comp.chart.PolarCoordinateSystem"_ustr;
}
sal_Bool SAL_CALL PolarCoordinateSystem::supportsService( const OUString& rServiceName )
@@ -96,7 +97,7 @@ PolarCoordinateSystem2d::~PolarCoordinateSystem2d()
// ____ XServiceInfo ____
OUString SAL_CALL PolarCoordinateSystem2d::getImplementationName()
{
- return "com.sun.star.comp.chart2.PolarCoordinateSystem2d" ;
+ return u"com.sun.star.comp.chart2.PolarCoordinateSystem2d"_ustr ;
}
sal_Bool SAL_CALL PolarCoordinateSystem2d::supportsService( const OUString& rServiceName )
@@ -108,7 +109,7 @@ css::uno::Sequence< OUString > SAL_CALL PolarCoordinateSystem2d::getSupportedSer
{
return {
CHART2_COOSYSTEM_POLAR_SERVICE_NAME,
- "com.sun.star.chart2.PolarCoordinateSystem2d" };
+ u"com.sun.star.chart2.PolarCoordinateSystem2d"_ustr };
}
// ==== PolarCoordinateSystem3d ====
@@ -123,7 +124,7 @@ PolarCoordinateSystem3d::~PolarCoordinateSystem3d()
// ____ XServiceInfo ____
OUString SAL_CALL PolarCoordinateSystem3d::getImplementationName()
{
- return "com.sun.star.comp.chart2.PolarCoordinateSystem3d";
+ return u"com.sun.star.comp.chart2.PolarCoordinateSystem3d"_ustr;
}
sal_Bool SAL_CALL PolarCoordinateSystem3d::supportsService( const OUString& rServiceName )
@@ -135,7 +136,7 @@ css::uno::Sequence< OUString > SAL_CALL PolarCoordinateSystem3d::getSupportedSer
{
return {
CHART2_COOSYSTEM_POLAR_SERVICE_NAME,
- "com.sun.star.chart2.PolarCoordinateSystem3d" };
+ u"com.sun.star.chart2.PolarCoordinateSystem3d"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/main/StockBar.cxx b/chart2/source/model/main/StockBar.cxx
index 22e082ad06b3..0be153bb8059 100644
--- a/chart2/source/model/main/StockBar.cxx
+++ b/chart2/source/model/main/StockBar.cxx
@@ -23,13 +23,9 @@
#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;
@@ -38,69 +34,36 @@ 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 >
+::cppu::OPropertyArrayHelper& StaticStockBarInfoHelper()
{
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-struct StaticStockBarInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticStockBarInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticStockBarInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticStockBarInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
-struct StaticStockBarDefaults_Initializer
+const ::chart::tPropertyValueMap & StaticStockBarDefaults()
{
- ::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 );
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
+ ::chart::FillProperties::AddDefaultsToMap( aTmp );
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); // white
- }
-};
-
-struct StaticStockBarDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticStockBarDefaults_Initializer >
-{
+ // override other defaults
+ ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( aTmp, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); // white
+ return aTmp;
+ }();
+ return aStaticDefaults;
};
} // anonymous namespace
@@ -109,8 +72,7 @@ namespace chart
{
StockBar::StockBar( bool bRisingCourse ) :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
if( ! bRisingCourse )
{
@@ -125,13 +87,21 @@ StockBar::StockBar( bool bRisingCourse ) :
StockBar::StockBar( const StockBar & rOther ) :
impl::StockBar_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
StockBar::~StockBar()
{}
+// ____ XTypeProvider ____
+uno::Sequence< css::uno::Type > SAL_CALL StockBar::getTypes()
+{
+ return ::comphelper::concatSequences(
+ impl::StockBar_Base::getTypes(),
+ ::property::OPropertySet::getTypes());
+}
+
// ____ XCloneable ____
uno::Reference< util::XCloneable > SAL_CALL StockBar::createClone()
{
@@ -139,51 +109,38 @@ uno::Reference< util::XCloneable > SAL_CALL StockBar::createClone()
}
// ____ OPropertySet ____
-uno::Any StockBar::GetDefaultValue( sal_Int32 nHandle ) const
+void StockBar::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticStockBarDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticStockBarDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL StockBar::getInfoHelper()
{
- return *StaticStockBarInfoHelper::get();
+ return StaticStockBarInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL StockBar::getPropertySetInfo()
{
- return *StaticStockBarInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticStockBarInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XModifyBroadcaster ____
void SAL_CALL StockBar::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL StockBar::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
diff --git a/chart2/source/model/main/Title.cxx b/chart2/source/model/main/Title.cxx
index a42374ce5f51..d882304d43d3 100644
--- a/chart2/source/model/main/Title.cxx
+++ b/chart2/source/model/main/Title.cxx
@@ -17,7 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "Title.hxx"
+#include <Title.hxx>
+#include <CharacterProperties.hxx>
#include <LinePropertiesHelper.hxx>
#include <FillProperties.hxx>
#include <CloneHelper.hxx>
@@ -30,7 +31,6 @@
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/awt/Size.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
#include <vector>
#include <algorithm>
@@ -140,86 +140,56 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEVOID );
}
-struct StaticTitleDefaults_Initializer
+const ::chart::tPropertyValueMap& StaticTitleDefaults()
{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
- ::chart::FillProperties::AddDefaultsToMap( rOutMap );
-
- // ParagraphProperties
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_PARA_ADJUST,
- css::style::ParagraphAdjust_CENTER );
- // PROP_TITLE_PARA_LAST_LINE_ADJUST
-
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_LEFT_MARGIN, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_RIGHT_MARGIN, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_TOP_MARGIN, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_TITLE_PARA_BOTTOM_MARGIN, 0 );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_PARA_IS_HYPHENATION, true );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_VISIBLE, true );
-
- // own properties
- ::chart::PropertyHelper::setPropertyValueDefault< double >( rOutMap, PROP_TITLE_TEXT_ROTATION, 0.0 );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_TITLE_TEXT_STACKED, false );
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE );
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
- }
-};
-
-struct StaticTitleDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticTitleDefaults_Initializer >
-{
-};
-
-struct StaticTitleInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static uno::Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
- ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
- ::chart::FillProperties::AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticTitleInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticTitleInfoHelper_Initializer >
-{
-};
-
-struct StaticTitleInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticTitleInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+
+ ::chart::CharacterProperties::AddDefaultsToMap( aTmp );
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
+ ::chart::FillProperties::AddDefaultsToMap( aTmp );
+
+ // ParagraphProperties
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_TITLE_PARA_ADJUST,
+ css::style::ParagraphAdjust_CENTER );
+ // PROP_TITLE_PARA_LAST_LINE_ADJUST
+
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_TITLE_PARA_LEFT_MARGIN, 0 );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_TITLE_PARA_RIGHT_MARGIN, 0 );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_TITLE_PARA_TOP_MARGIN, 0 );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_TITLE_PARA_BOTTOM_MARGIN, 0 );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_TITLE_PARA_IS_HYPHENATION, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_TITLE_VISIBLE, true );
+
+ // own properties
+ ::chart::PropertyHelper::setPropertyValueDefault< double >( aTmp, PROP_TITLE_TEXT_ROTATION, 0.0 );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_TITLE_TEXT_STACKED, false );
+
+ // override other defaults
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::FillProperties::PROP_FILL_STYLE, drawing::FillStyle_NONE );
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
+ return aTmp;
+ }();
+ return aStaticDefaults;
};
-struct StaticTitleInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticTitleInfo_Initializer >
+::cppu::OPropertyArrayHelper& StaticTitleInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ ::chart::CharacterProperties::AddPropertiesToVector( aProperties );
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -228,14 +198,13 @@ namespace chart
{
Title::Title() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
Title::Title( const Title & rOther ) :
impl::Title_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{
CloneHelper::CloneRefSequence<chart2::XFormattedString>(
rOther.m_aStrings, m_aStrings );
@@ -283,51 +252,38 @@ void SAL_CALL Title::setText( const uno::Sequence< uno::Reference< chart2::XForm
}
// ____ OPropertySet ____
-uno::Any Title::GetDefaultValue( sal_Int32 nHandle ) const
+void Title::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticTitleDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticTitleDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL Title::getInfoHelper()
{
- return *StaticTitleInfoHelper::get();
+ return StaticTitleInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL Title::getPropertySetInfo()
{
- return *StaticTitleInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticTitleInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XModifyBroadcaster ____
void SAL_CALL Title::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL Title::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
@@ -355,7 +311,7 @@ void Title::fireModifyEvent()
OUString SAL_CALL Title::getImplementationName()
{
- return "com.sun.star.comp.chart2.Title";
+ return u"com.sun.star.comp.chart2.Title"_ustr;
}
sal_Bool SAL_CALL Title::supportsService( const OUString& rServiceName )
@@ -366,10 +322,10 @@ sal_Bool SAL_CALL Title::supportsService( const OUString& 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" };
+ u"com.sun.star.chart2.Title"_ustr,
+ u"com.sun.star.style.ParagraphProperties"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr,
+ u"com.sun.star.layout.LayoutElement"_ustr };
}
// needed by MSC compiler
diff --git a/chart2/source/model/main/Title.hxx b/chart2/source/model/main/Title.hxx
deleted file mode 100644
index 9326b54b21ca..000000000000
--- a/chart2/source/model/main/Title.hxx
+++ /dev/null
@@ -1,115 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#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
index f295bc288eb2..45f2b29ffffc 100644
--- a/chart2/source/model/main/UndoManager.cxx
+++ b/chart2/source/model/main/UndoManager.cxx
@@ -18,9 +18,9 @@
*/
#include "UndoManager.hxx"
+#include <ChartModel.hxx>
#include <ChartViewHelper.hxx>
-#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/NoSupportException.hpp>
@@ -34,7 +34,6 @@ 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;
@@ -42,19 +41,17 @@ namespace chart
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 )
+ UndoManager_Impl( UndoManager& i_antiImpl, ::chart::ChartModel& i_parent, ::osl::Mutex& i_mutex )
:m_rAntiImpl( i_antiImpl )
,m_rParent( i_parent )
,m_rMutex( i_mutex )
,m_bDisposed( false )
- ,m_aUndoManager()
,m_aUndoHelper( *this )
{
m_aUndoManager.SetMaxUndoActionCount(
@@ -71,7 +68,7 @@ namespace chart
virtual Reference< XUndoManager > getThis() override;
// attribute access
- ::cppu::OWeakObject& getParent() { return m_rParent; }
+ ::chart::ChartModel& getParent() { return m_rParent; }
::framework::UndoManagerHelper& getUndoHelper() { return m_aUndoHelper; }
// public interface
@@ -84,7 +81,7 @@ namespace chart
private:
UndoManager& m_rAntiImpl;
- ::cppu::OWeakObject& m_rParent;
+ ::chart::ChartModel& m_rParent;
::osl::Mutex& m_rMutex;
bool m_bDisposed;
@@ -173,7 +170,7 @@ namespace chart
using impl::UndoManagerMethodGuard;
- UndoManager::UndoManager( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ UndoManager::UndoManager( ::chart::ChartModel& i_parent, ::osl::Mutex& i_mutex )
:m_pImpl( new impl::UndoManager_Impl( *this, i_parent, i_mutex ) )
{
}
@@ -182,12 +179,12 @@ namespace chart
{
}
- void SAL_CALL UndoManager::acquire() throw ()
+ void SAL_CALL UndoManager::acquire() noexcept
{
m_pImpl->getParent().acquire();
}
- void SAL_CALL UndoManager::release() throw ()
+ void SAL_CALL UndoManager::release() noexcept
{
m_pImpl->getParent().release();
}
@@ -226,7 +223,7 @@ namespace chart
UndoManagerMethodGuard aGuard( *m_pImpl );
m_pImpl->getUndoHelper().undo( aGuard );
- ChartViewHelper::setViewToDirtyState( Reference< XModel >( getParent(), UNO_QUERY ) );
+ ChartViewHelper::setViewToDirtyState( &m_pImpl->getParent() );
}
void SAL_CALL UndoManager::redo( )
@@ -234,7 +231,7 @@ namespace chart
UndoManagerMethodGuard aGuard( *m_pImpl );
m_pImpl->getUndoHelper().redo( aGuard );
- ChartViewHelper::setViewToDirtyState( Reference< XModel >( getParent(), UNO_QUERY ) );
+ ChartViewHelper::setViewToDirtyState( &m_pImpl->getParent() );
}
sal_Bool SAL_CALL UndoManager::isUndoPossible( )
diff --git a/chart2/source/model/main/UndoManager.hxx b/chart2/source/model/main/UndoManager.hxx
index c599113d45cb..c20dcef6643d 100644
--- a/chart2/source/model/main/UndoManager.hxx
+++ b/chart2/source/model/main/UndoManager.hxx
@@ -17,8 +17,7 @@
* 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
+#pragma once
#include <com/sun/star/document/XUndoManager.hpp>
#include <com/sun/star/util/XModifyBroadcaster.hpp>
@@ -29,6 +28,7 @@
namespace chart
{
+class ChartModel;
namespace impl
{
@@ -41,12 +41,12 @@ namespace chart
class UndoManager : public impl::UndoManager_Base
{
public:
- UndoManager( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex );
+ UndoManager( ::chart::ChartModel& i_parent, ::osl::Mutex& i_mutex );
virtual ~UndoManager();
// XInterface
- virtual void SAL_CALL acquire( ) throw () override;
- virtual void SAL_CALL release( ) throw () override;
+ virtual void SAL_CALL acquire( ) noexcept override;
+ virtual void SAL_CALL release( ) noexcept override;
// XComponent equivalents
void disposing();
@@ -89,6 +89,4 @@ namespace chart
} // 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
index 5ba8aaf18401..1bbe133de905 100644
--- a/chart2/source/model/main/Wall.cxx
+++ b/chart2/source/model/main/Wall.cxx
@@ -24,7 +24,6 @@
#include <PropertyHelper.hxx>
#include <ModifyListenerHelper.hxx>
#include <com/sun/star/drawing/LineStyle.hpp>
-#include <tools/diagnose_ex.h>
#include <vector>
#include <algorithm>
@@ -36,69 +35,21 @@ using ::com::sun::star::beans::Property;
namespace
{
-struct StaticWallDefaults_Initializer
+::cppu::OPropertyArrayHelper& StaticWallInfoHelper()
{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap );
- ::chart::FillProperties::AddDefaultsToMap( rOutMap );
-
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
- }
-};
-
-struct StaticWallDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticWallDefaults_Initializer >
-{
-};
-
-struct StaticWallInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static uno::Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
- ::chart::FillProperties::AddPropertiesToVector( aProperties );
- ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticWallInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticWallInfoHelper_Initializer >
-{
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties );
+ ::chart::FillProperties::AddPropertiesToVector( aProperties );
+ ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties );
-struct StaticWallInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticWallInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticWallInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticWallInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -107,19 +58,26 @@ namespace chart
{
Wall::Wall() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
Wall::Wall( const Wall & rOther ) :
impl::Wall_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() )
{}
Wall::~Wall()
{}
+// ____ XTypeProvider ____
+uno::Sequence< css::uno::Type > SAL_CALL Wall::getTypes()
+{
+ return ::comphelper::concatSequences(
+ impl::Wall_Base::getTypes(),
+ ::property::OPropertySet::getTypes());
+}
+
// ____ XCloneable ____
uno::Reference< util::XCloneable > SAL_CALL Wall::createClone()
{
@@ -127,51 +85,47 @@ uno::Reference< util::XCloneable > SAL_CALL Wall::createClone()
}
// ____ OPropertySet ____
-uno::Any Wall::GetDefaultValue( sal_Int32 nHandle ) const
-{
- const tPropertyValueMap& rStaticDefaults = *StaticWallDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+void Wall::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
+{
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp );
+ ::chart::FillProperties::AddDefaultsToMap( aTmp );
+
+ // override other defaults
+ ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::LinePropertiesHelper::PROP_LINE_STYLE, drawing::LineStyle_NONE );
+ return aTmp;
+ }();
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL Wall::getInfoHelper()
{
- return *StaticWallInfoHelper::get();
+ return StaticWallInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL Wall::getPropertySetInfo()
{
- return *StaticWallInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticWallInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XModifyBroadcaster ____
void SAL_CALL Wall::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
void SAL_CALL Wall::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
{
- try
- {
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
// ____ XModifyListener ____
diff --git a/chart2/source/model/main/Wall.hxx b/chart2/source/model/main/Wall.hxx
index a3112a614bda..6cae798959c1 100644
--- a/chart2/source/model/main/Wall.hxx
+++ b/chart2/source/model/main/Wall.hxx
@@ -16,17 +16,14 @@
* 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
+#pragma once
#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-#include <MutexContainer.hxx>
#include <OPropertySet.hxx>
#include <cppuhelper/implbase.hxx>
#include <comphelper/uno3.hxx>
+#include <ModifyListenerHelper.hxx>
namespace chart
{
@@ -41,7 +38,6 @@ typedef ::cppu::WeakImplHelper<
}
class Wall final :
- public MutexContainer,
public impl::Wall_Base,
public ::property::OPropertySet
{
@@ -52,11 +48,13 @@ public:
/// merge XInterface implementations
DECLARE_XINTERFACE()
-private:
explicit Wall( const Wall & rOther );
+ // ____ XTypeProvider ____
+ virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
+
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
// ____ OPropertySet ____
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -74,6 +72,7 @@ private:
virtual void SAL_CALL removeModifyListener(
const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
+private:
// ____ XModifyListener ____
virtual void SAL_CALL modified(
const css::lang::EventObject& aEvent ) override;
@@ -88,12 +87,9 @@ private:
private:
- css::uno::Reference< css::util::XModifyListener > m_xModifyEventForwarder;
+ rtl::Reference<ModifyEventForwarder> 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
index 840bdba036d7..6d1dd578b0fe 100644
--- a/chart2/source/model/template/AreaChartType.cxx
+++ b/chart2/source/model/template/AreaChartType.cxx
@@ -44,6 +44,11 @@ uno::Reference< util::XCloneable > SAL_CALL AreaChartType::createClone()
return uno::Reference< util::XCloneable >( new AreaChartType( *this ));
}
+rtl::Reference< ChartType > AreaChartType::cloneChartType() const
+{
+ return new AreaChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL AreaChartType::getChartType()
{
@@ -52,7 +57,7 @@ OUString SAL_CALL AreaChartType::getChartType()
OUString SAL_CALL AreaChartType::getImplementationName()
{
- return "com.sun.star.comp.chart.AreaChartType";
+ return u"com.sun.star.comp.chart.AreaChartType"_ustr;
}
sal_Bool SAL_CALL AreaChartType::supportsService( const OUString& rServiceName )
@@ -64,7 +69,7 @@ css::uno::Sequence< OUString > SAL_CALL AreaChartType::getSupportedServiceNames(
{
return {
CHART2_SERVICE_NAME_CHARTTYPE_AREA,
- "com.sun.star.chart2.ChartType" };
+ u"com.sun.star.chart2.ChartType"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/template/AreaChartType.hxx b/chart2/source/model/template/AreaChartType.hxx
index acb76ef106cb..8ca01e1f3afd 100644
--- a/chart2/source/model/template/AreaChartType.hxx
+++ b/chart2/source/model/template/AreaChartType.hxx
@@ -16,10 +16,9 @@
* 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
+#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -37,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit AreaChartType( const AreaChartType & rOther );
@@ -49,7 +50,4 @@ private:
} // 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
index 401dc6971dc9..c71fb5fb126f 100644
--- a/chart2/source/model/template/AreaChartTypeTemplate.cxx
+++ b/chart2/source/model/template/AreaChartTypeTemplate.cxx
@@ -18,15 +18,15 @@
*/
#include "AreaChartTypeTemplate.hxx"
-#include <servicenames_charttypes.hxx>
-#include <DiagramHelper.hxx>
+#include "AreaChartType.hxx"
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <PropertyHelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -54,58 +54,19 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEDEFAULT );
}
-struct StaticAreaChartTypeTemplateDefaults_Initializer
+::cppu::OPropertyArrayHelper& StaticAreaChartTypeTemplateInfoHelper()
{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aStaticDefaults, PROP_AREA_TEMPLATE_DIMENSION, 2 );
- return &aStaticDefaults;
- }
-};
-
-struct StaticAreaChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticAreaChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticAreaChartTypeTemplateInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static uno::Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticAreaChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticAreaChartTypeTemplateInfoHelper_Initializer >
-{
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
-struct StaticAreaChartTypeTemplateInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAreaChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticAreaChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticAreaChartTypeTemplateInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -120,7 +81,6 @@ AreaChartTypeTemplate::AreaChartTypeTemplate(
StackMode eStackMode,
sal_Int32 nDim /* = 2 */ ) :
ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex ),
m_eStackMode( eStackMode )
{
setFastPropertyValue_NoBroadcast( PROP_AREA_TEMPLATE_DIMENSION, uno::Any( nDim ));
@@ -130,24 +90,32 @@ AreaChartTypeTemplate::~AreaChartTypeTemplate()
{}
// ____ OPropertySet ____
-uno::Any AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticAreaChartTypeTemplateDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_AREA_TEMPLATE_DIMENSION, 2 );
+ return aTmp;
+ }();
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL AreaChartTypeTemplate::getInfoHelper()
{
- return *StaticAreaChartTypeTemplateInfoHelper::get();
+ return StaticAreaChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL AreaChartTypeTemplate::getPropertySetInfo()
{
- return *StaticAreaChartTypeTemplateInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticAreaChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
}
sal_Int32 AreaChartTypeTemplate::getDimension() const
@@ -172,59 +140,41 @@ StackMode AreaChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ )
return m_eStackMode;
}
-// ____ XChartTypeTemplate ____
-void SAL_CALL AreaChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+// ____ ChartTypeTemplate ____
+void AreaChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
- DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) );
}
-void SAL_CALL AreaChartTypeTemplate::resetStyles( const Reference< chart2::XDiagram >& xDiagram )
+void AreaChartTypeTemplate::resetStyles2( const rtl::Reference< ::chart::Diagram >& xDiagram )
{
- ChartTypeTemplate::resetStyles( xDiagram );
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ ChartTypeTemplate::resetStyles2( xDiagram );
+ std::vector< rtl::Reference< ::chart::DataSeries > > aSeriesVec(
+ xDiagram->getDataSeries());
uno::Any aLineStyleAny( drawing::LineStyle_NONE );
for (auto const& series : aSeriesVec)
{
- Reference< beans::XPropertyState > xState(series, uno::UNO_QUERY);
- Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY);
- if( xState.is() &&
- xProp.is() &&
- xProp->getPropertyValue( "BorderStyle") == aLineStyleAny )
+ if( series->getPropertyValue( u"BorderStyle"_ustr) == aLineStyleAny )
{
- xState->setPropertyToDefault( "BorderStyle");
+ series->setPropertyToDefault( u"BorderStyle"_ustr);
}
}
}
-Reference< chart2::XChartType > AreaChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+rtl::Reference< ChartType > AreaChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
{
- Reference< chart2::XChartType > xResult;
-
- try
- {
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_AREA ), uno::UNO_QUERY_THROW );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
- return xResult;
+ return new AreaChartType();
}
-Reference< chart2::XChartType > SAL_CALL AreaChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > AreaChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult( getChartTypeForIndex( 0 ) );
+ rtl::Reference< ChartType > xResult( getChartTypeForIndex( 0 ) );
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
return xResult;
}
diff --git a/chart2/source/model/template/AreaChartTypeTemplate.hxx b/chart2/source/model/template/AreaChartTypeTemplate.hxx
index e56be9833937..76a5bfd4c890 100644
--- a/chart2/source/model/template/AreaChartTypeTemplate.hxx
+++ b/chart2/source/model/template/AreaChartTypeTemplate.hxx
@@ -16,21 +16,18 @@
* 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
+#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <StackMode.hxx>
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
namespace chart
{
class AreaChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -49,27 +46,27 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence<
- css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ // ____ ChartTypeTemplate ____
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
- virtual void SAL_CALL resetStyles(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override;
+ virtual void resetStyles2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram ) override;
// ____ ChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual sal_Int32 getDimension() const override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
@@ -80,7 +77,4 @@ private:
} // 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
index 87675e3f140d..7bd27a943238 100644
--- a/chart2/source/model/template/BarChartType.cxx
+++ b/chart2/source/model/template/BarChartType.cxx
@@ -45,6 +45,11 @@ uno::Reference< util::XCloneable > SAL_CALL BarChartType::createClone()
return uno::Reference< util::XCloneable >( new BarChartType( *this ));
}
+rtl::Reference< ChartType > BarChartType::cloneChartType() const
+{
+ return new BarChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL BarChartType::getChartType()
{
@@ -53,16 +58,12 @@ OUString SAL_CALL BarChartType::getChartType()
uno::Sequence< OUString > BarChartType::getSupportedPropertyRoles()
{
- uno::Sequence< OUString > aPropRoles(2);
- aPropRoles[0] = "FillColor";
- aPropRoles[1] = "BorderColor";
-
- return aPropRoles;
+ return { u"FillColor"_ustr, u"BorderColor"_ustr };
}
OUString SAL_CALL BarChartType::getImplementationName()
{
- return "com.sun.star.comp.chart.BarChartType";
+ return u"com.sun.star.comp.chart.BarChartType"_ustr;
}
sal_Bool SAL_CALL BarChartType::supportsService( const OUString& rServiceName )
@@ -74,7 +75,7 @@ css::uno::Sequence< OUString > SAL_CALL BarChartType::getSupportedServiceNames()
{
return {
CHART2_SERVICE_NAME_CHARTTYPE_BAR,
- "com.sun.star.chart2.ChartType" };
+ u"com.sun.star.chart2.ChartType"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/template/BarChartType.hxx b/chart2/source/model/template/BarChartType.hxx
index 4d090c783ebb..cceaf05777f0 100644
--- a/chart2/source/model/template/BarChartType.hxx
+++ b/chart2/source/model/template/BarChartType.hxx
@@ -16,10 +16,9 @@
* 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
+#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -37,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit BarChartType( const BarChartType & rOther );
@@ -51,7 +52,4 @@ private:
} // 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
index dce1ffbb09d9..e1d380fc8f85 100644
--- a/chart2/source/model/template/BarChartTypeTemplate.cxx
+++ b/chart2/source/model/template/BarChartTypeTemplate.cxx
@@ -18,17 +18,16 @@
*/
#include "BarChartTypeTemplate.hxx"
-#include <DiagramHelper.hxx>
-#include <servicenames_charttypes.hxx>
+#include "ColumnChartType.hxx"
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <PropertyHelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/chart2/DataPointGeometry3D.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -62,64 +61,19 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEDEFAULT );
}
-struct StaticBarChartTypeTemplateDefaults_Initializer
+::cppu::OPropertyArrayHelper& StaticBarChartTypeTemplateInfoHelper()
{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_BAR_TEMPLATE_DIMENSION, 2 );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BAR_TEMPLATE_GEOMETRY3D, ::chart2::DataPointGeometry3D::CUBOID );
- }
-};
-
-struct StaticBarChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBarChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticBarChartTypeTemplateInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticBarChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBarChartTypeTemplateInfoHelper_Initializer >
-{
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
-struct StaticBarChartTypeTemplateInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBarChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticBarChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBarChartTypeTemplateInfo_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -135,7 +89,6 @@ BarChartTypeTemplate::BarChartTypeTemplate(
BarDirection eDirection,
sal_Int32 nDim /* = 2 */ ) :
ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex ),
m_eStackMode( eStackMode ),
m_eBarDirection( eDirection ),
m_nDim( nDim )
@@ -159,19 +112,19 @@ bool BarChartTypeTemplate::isSwapXAndY() const
return (m_eBarDirection == HORIZONTAL);
}
-// ____ XChartTypeTemplate ____
-sal_Bool SAL_CALL BarChartTypeTemplate::matchesTemplate(
- const Reference< chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties )
+// ____ ChartTypeTemplate ____
+bool BarChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties )
{
- bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
+ bool bResult = ChartTypeTemplate::matchesTemplate2( xDiagram, bAdaptProperties );
//check BarDirection
if( bResult )
{
bool bFound = false;
bool bAmbiguous = false;
- bool bVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous );
+ bool bVertical = xDiagram->getVertical( bFound, bAmbiguous );
if( m_eBarDirection == HORIZONTAL )
bResult = bVertical;
else if( m_eBarDirection == VERTICAL )
@@ -185,7 +138,7 @@ sal_Bool SAL_CALL BarChartTypeTemplate::matchesTemplate(
{
bool bGeomFound = false, bGeomAmbiguous = false;
- sal_Int32 aCommonGeom = DiagramHelper::getGeometry3D( xDiagram, bGeomFound, bGeomAmbiguous );
+ sal_Int32 aCommonGeom = xDiagram->getGeometry3D( bGeomFound, bGeomAmbiguous );
if( !bGeomAmbiguous )
{
@@ -196,62 +149,58 @@ sal_Bool SAL_CALL BarChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< chart2::XChartType > BarChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
-{
- Reference< chart2::XChartType > xResult;
-
- try
- {
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY_THROW );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
- return xResult;
+rtl::Reference< ChartType > BarChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+{
+ return new ColumnChartType();
}
-Reference< chart2::XChartType > SAL_CALL BarChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > BarChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult( getChartTypeForIndex( 0 ) );
+ rtl::Reference< ChartType > xResult( getChartTypeForIndex( 0 ) );
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
return xResult;
}
// ____ OPropertySet ____
-uno::Any BarChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void BarChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticBarChartTypeTemplateDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_BAR_TEMPLATE_DIMENSION, 2 );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_BAR_TEMPLATE_GEOMETRY3D, ::chart2::DataPointGeometry3D::CUBOID );
+ return aTmp;
+ }();
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL BarChartTypeTemplate::getInfoHelper()
{
- return *StaticBarChartTypeTemplateInfoHelper::get();
+ return StaticBarChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL BarChartTypeTemplate::getPropertySetInfo()
{
- return *StaticBarChartTypeTemplateInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticBarChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
}
-void SAL_CALL BarChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void BarChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
- DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) );
if( getDimension() != 3 )
return;
@@ -260,7 +209,7 @@ void SAL_CALL BarChartTypeTemplate::applyStyle(
//apply Geometry3D
uno::Any aAGeometry3D;
getFastPropertyValue( aAGeometry3D, PROP_BAR_TEMPLATE_GEOMETRY3D );
- DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "Geometry3D", aAGeometry3D );
+ xSeries->setPropertyAlsoToAllAttributedDataPoints( u"Geometry3D"_ustr, aAGeometry3D );
}
catch( const uno::Exception & )
{
@@ -268,39 +217,32 @@ void SAL_CALL BarChartTypeTemplate::applyStyle(
}
}
-void SAL_CALL BarChartTypeTemplate::resetStyles(
- const Reference< chart2::XDiagram >& xDiagram )
+void BarChartTypeTemplate::resetStyles2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram )
{
- ChartTypeTemplate::resetStyles( xDiagram );
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ ChartTypeTemplate::resetStyles2( xDiagram );
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec(
+ xDiagram->getDataSeries());
uno::Any aLineStyleAny( drawing::LineStyle_NONE );
for (auto const& series : aSeriesVec)
{
- Reference< beans::XPropertyState > xState(series, uno::UNO_QUERY);
- if( xState.is())
+ if( getDimension() == 3 )
+ series->setPropertyToDefault( u"Geometry3D"_ustr);
+ if( series->getPropertyValue( u"BorderStyle"_ustr) == aLineStyleAny )
{
- if( getDimension() == 3 )
- xState->setPropertyToDefault( "Geometry3D");
- Reference< beans::XPropertySet > xProp( xState, uno::UNO_QUERY );
- if( xProp.is() &&
- xProp->getPropertyValue( "BorderStyle") == aLineStyleAny )
- {
- xState->setPropertyToDefault( "BorderStyle");
- }
+ series->setPropertyToDefault( u"BorderStyle"_ustr);
}
}
- DiagramHelper::setVertical( xDiagram, false );
+ xDiagram->setVertical( false );
}
void BarChartTypeTemplate::createCoordinateSystems(
- const Reference< chart2::XCoordinateSystemContainer > & xCooSysCnt )
+ const rtl::Reference< ::chart::Diagram > & xDiagram )
{
- ChartTypeTemplate::createCoordinateSystems( xCooSysCnt );
+ ChartTypeTemplate::createCoordinateSystems( xDiagram );
- Reference< chart2::XDiagram > xDiagram( xCooSysCnt, uno::UNO_QUERY );
- DiagramHelper::setVertical( xDiagram, m_eBarDirection == HORIZONTAL );
+ xDiagram->setVertical( m_eBarDirection == HORIZONTAL );
}
IMPLEMENT_FORWARD_XINTERFACE2( BarChartTypeTemplate, ChartTypeTemplate, OPropertySet )
diff --git a/chart2/source/model/template/BarChartTypeTemplate.hxx b/chart2/source/model/template/BarChartTypeTemplate.hxx
index 593a1f7fecdd..ab56869e71cd 100644
--- a/chart2/source/model/template/BarChartTypeTemplate.hxx
+++ b/chart2/source/model/template/BarChartTypeTemplate.hxx
@@ -16,21 +16,18 @@
* 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
+#pragma once
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <StackMode.hxx>
namespace chart
{
class BarChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -56,37 +53,35 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence<
- css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ // ____ ChartTypeTemplate ____
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
- virtual void SAL_CALL resetStyles(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override;
-
- // ____ ChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual void resetStyles2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram ) override;
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual sal_Int32 getDimension() const override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
virtual bool isSwapXAndY() const override;
virtual void createCoordinateSystems(
- const css::uno::Reference< css::chart2::XCoordinateSystemContainer > & xCooSysCnt ) override;
+ const rtl::Reference< ::chart::Diagram > & xDiagram ) override;
private:
StackMode m_eStackMode;
@@ -96,7 +91,4 @@ private:
} // 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
index 4abdbb826467..76abecfe27ef 100644
--- a/chart2/source/model/template/BubbleChartType.cxx
+++ b/chart2/source/model/template/BubbleChartType.cxx
@@ -21,6 +21,7 @@
#include <PropertyHelper.hxx>
#include <servicenames_charttypes.hxx>
#include <CartesianCoordinateSystem.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
#include <AxisIndexDefines.hxx>
#include <com/sun/star/chart2/AxisType.hpp>
@@ -35,55 +36,16 @@ using ::com::sun::star::uno::Reference;
namespace
{
-struct StaticBubbleChartTypeDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- return &aStaticDefaults;
- }
-};
-
-struct StaticBubbleChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeDefaults_Initializer >
-{
-};
-
-struct StaticBubbleChartTypeInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-};
-
-struct StaticBubbleChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeInfoHelper_Initializer >
-{
-};
-
-struct StaticBubbleChartTypeInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticBubbleChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeInfo_Initializer >
+::cppu::OPropertyArrayHelper& StaticBubbleChartTypeInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -109,16 +71,21 @@ uno::Reference< util::XCloneable > SAL_CALL BubbleChartType::createClone()
return uno::Reference< util::XCloneable >( new BubbleChartType( *this ));
}
+rtl::Reference< ChartType > BubbleChartType::cloneChartType() const
+{
+ return new BubbleChartType( *this );
+}
+
// ____ XChartType ____
-Reference< chart2::XCoordinateSystem > SAL_CALL
- BubbleChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
+rtl::Reference< ::chart::BaseCoordinateSystem >
+ BubbleChartType::createCoordinateSystem2( sal_Int32 DimensionCount )
{
- Reference< chart2::XCoordinateSystem > xResult(
- new CartesianCoordinateSystem( DimensionCount ));
+ rtl::Reference< CartesianCoordinateSystem > xResult =
+ new CartesianCoordinateSystem( DimensionCount );
for( sal_Int32 i=0; i<DimensionCount; ++i )
{
- Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
+ rtl::Reference< Axis > xAxis = xResult->getAxisByDimension2( i, MAIN_AXIS_INDEX );
if( !xAxis.is() )
{
OSL_FAIL("a created coordinate system should have an axis for each dimension");
@@ -147,52 +114,47 @@ OUString SAL_CALL BubbleChartType::getChartType()
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;
+ return { u"label"_ustr, u"values-x"_ustr, u"values-y"_ustr, u"values-size"_ustr };
}
uno::Sequence< OUString > SAL_CALL BubbleChartType::getSupportedPropertyRoles()
{
- uno::Sequence< OUString > aPropertyRoles(2);
- aPropertyRoles[0] = "FillColor";
- aPropertyRoles[1] = "BorderColor";
- return aPropertyRoles;
+ return { u"FillColor"_ustr, u"BorderColor"_ustr };
}
OUString SAL_CALL BubbleChartType::getRoleOfSequenceForSeriesLabel()
{
- return "values-size";
+ return u"values-size"_ustr;
}
// ____ OPropertySet ____
-uno::Any BubbleChartType::GetDefaultValue( sal_Int32 nHandle ) const
-{
- const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+void BubbleChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
+{
+ static ::chart::tPropertyValueMap aStaticDefaults;
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartType::getInfoHelper()
{
- return *StaticBubbleChartTypeInfoHelper::get();
+ return StaticBubbleChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartType::getPropertySetInfo()
{
- return *StaticBubbleChartTypeInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticBubbleChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
}
OUString SAL_CALL BubbleChartType::getImplementationName()
{
- return "com.sun.star.comp.chart.BubbleChartType";
+ return u"com.sun.star.comp.chart.BubbleChartType"_ustr;
}
sal_Bool SAL_CALL BubbleChartType::supportsService( const OUString& rServiceName )
@@ -204,8 +166,8 @@ css::uno::Sequence< OUString > SAL_CALL BubbleChartType::getSupportedServiceName
{
return {
CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE,
- "com.sun.star.chart2.ChartType",
- "com.sun.star.beans.PropertySet" };
+ u"com.sun.star.chart2.ChartType"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/template/BubbleChartType.hxx b/chart2/source/model/template/BubbleChartType.hxx
index e37a01ac25e1..a2afa7e6941d 100644
--- a/chart2/source/model/template/BubbleChartType.hxx
+++ b/chart2/source/model/template/BubbleChartType.hxx
@@ -16,10 +16,9 @@
* 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
+#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -37,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit BubbleChartType( const BubbleChartType & rOther );
@@ -46,12 +47,10 @@ private:
getSupportedMandatoryRoles() override;
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedPropertyRoles() override;
- virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL
- createCoordinateSystem( ::sal_Int32 DimensionCount ) override;
virtual OUString SAL_CALL getRoleOfSequenceForSeriesLabel() override;
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
// ____ OPropertySet ____
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -62,11 +61,11 @@ private:
// ____ XCloneable ____
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+
+ virtual rtl::Reference< ::chart::BaseCoordinateSystem >
+ createCoordinateSystem2( sal_Int32 DimensionCount ) override;
};
} // namespace chart
-// 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
index 90ec1a75db21..f72515eefd87 100644
--- a/chart2/source/model/template/BubbleChartTypeTemplate.cxx
+++ b/chart2/source/model/template/BubbleChartTypeTemplate.cxx
@@ -18,14 +18,14 @@
*/
#include "BubbleChartTypeTemplate.hxx"
+#include "BubbleChartType.hxx"
#include "BubbleDataInterpreter.hxx"
-#include <servicenames_charttypes.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <PropertyHelper.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -38,56 +38,16 @@ using ::com::sun::star::beans::Property;
namespace
{
-struct StaticBubbleChartTypeTemplateDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- return &aStaticDefaults;
- }
-};
-
-struct StaticBubbleChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticBubbleChartTypeTemplateInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticBubbleChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeTemplateInfoHelper_Initializer >
-{
-};
-
-struct StaticBubbleChartTypeTemplateInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticBubbleChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeTemplateInfo_Initializer >
+::cppu::OPropertyArrayHelper & StaticBubbleChartTypeTemplateInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -99,8 +59,7 @@ BubbleChartTypeTemplate::BubbleChartTypeTemplate(
Reference<
uno::XComponentContext > const & xContext,
const OUString & rServiceName ) :
- ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex )
+ ChartTypeTemplate( xContext, rServiceName )
{
}
@@ -108,24 +67,27 @@ BubbleChartTypeTemplate::~BubbleChartTypeTemplate()
{}
// ____ OPropertySet ____
-uno::Any BubbleChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
-{
- const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeTemplateDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+void BubbleChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
+{
+ static ::chart::tPropertyValueMap aStaticDefaults;
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartTypeTemplate::getInfoHelper()
{
- return *StaticBubbleChartTypeTemplateInfoHelper::get();
+ return StaticBubbleChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartTypeTemplate::getPropertySetInfo()
{
- return *StaticBubbleChartTypeTemplateInfo::get();
+ static const uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticBubbleChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
}
sal_Int32 BubbleChartTypeTemplate::getDimension() const
@@ -138,14 +100,14 @@ StackMode BubbleChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */
return StackMode::NONE;
}
-void SAL_CALL BubbleChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void BubbleChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
- DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) );
}
// ____ XChartTypeTemplate ____
@@ -154,36 +116,19 @@ sal_Bool SAL_CALL BubbleChartTypeTemplate::supportsCategories()
return false;
}
-Reference< chart2::XChartType > BubbleChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+rtl::Reference< ChartType > BubbleChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
{
- Reference< chart2::XChartType > xResult;
-
- try
- {
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE ), uno::UNO_QUERY_THROW );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
- return xResult;
+ return new BubbleChartType();
}
-Reference< chart2::XChartType > SAL_CALL BubbleChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > BubbleChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE ), uno::UNO_QUERY_THROW );
+ xResult = new BubbleChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
}
@@ -195,7 +140,7 @@ Reference< chart2::XChartType > SAL_CALL BubbleChartTypeTemplate::getChartTypeFo
return xResult;
}
-Reference< chart2::XDataInterpreter > SAL_CALL BubbleChartTypeTemplate::getDataInterpreter()
+rtl::Reference< DataInterpreter > BubbleChartTypeTemplate::getDataInterpreter2()
{
if( ! m_xDataInterpreter.is())
m_xDataInterpreter.set( new BubbleDataInterpreter );
diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.hxx b/chart2/source/model/template/BubbleChartTypeTemplate.hxx
index b771d6f57545..8a59e5e72817 100644
--- a/chart2/source/model/template/BubbleChartTypeTemplate.hxx
+++ b/chart2/source/model/template/BubbleChartTypeTemplate.hxx
@@ -16,19 +16,16 @@
* 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
+#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
namespace chart
{
class BubbleChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -45,26 +42,27 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
+ // ____ ChartTypeTemplate ____
virtual sal_Bool SAL_CALL supportsCategories() override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual css::uno::Reference< css::chart2::XDataInterpreter > SAL_CALL getDataInterpreter() override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual rtl::Reference< ::chart::DataInterpreter > getDataInterpreter2() override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
// ____ ChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual sal_Int32 getDimension() const override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
@@ -72,7 +70,4 @@ protected:
} // 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
index 3078d3590a42..8157fdcfb0fe 100644
--- a/chart2/source/model/template/BubbleDataInterpreter.cxx
+++ b/chart2/source/model/template/BubbleDataInterpreter.cxx
@@ -17,17 +17,19 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cstddef>
+
#include "BubbleDataInterpreter.hxx"
#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <CommonConverters.hxx>
-#include <com/sun/star/chart2/data/XDataSink.hpp>
#include <com/sun/star/util/XCloneable.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
-using namespace ::std;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -35,8 +37,7 @@ using ::com::sun::star::uno::Sequence;
namespace chart
{
-BubbleDataInterpreter::BubbleDataInterpreter() :
- DataInterpreter()
+BubbleDataInterpreter::BubbleDataInterpreter()
{
}
@@ -45,25 +46,25 @@ BubbleDataInterpreter::~BubbleDataInterpreter()
}
// ____ XDataInterpreter ____
-chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
+InterpretedData BubbleDataInterpreter::interpretDataSource(
const Reference< chart2::data::XDataSource >& xSource,
const Sequence< beans::PropertyValue >& aArguments,
- const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+ const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
{
if( ! xSource.is())
return InterpretedData();
- Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aData = DataInterpreter::getDataSequences(xSource);
- Reference< data::XLabeledDataSequence > xValuesX;
- vector< Reference< data::XLabeledDataSequence > > aYValuesVector;
- vector< Reference< data::XLabeledDataSequence > > aSizeValuesVector;
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesX;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aYValuesVector;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSizeValuesVector;
- Reference< data::XLabeledDataSequence > xCategories;
+ uno::Reference< chart2::data::XLabeledDataSequence > xCategories;
bool bHasCategories = HasCategories( aArguments, aData );
bool bUseCategoriesAsX = UseCategoriesAsX( aArguments );
- sal_Int32 nDataSeqCount = aData.getLength();
+ sal_Int32 nDataSeqCount = aData.size();
bool bSetXValues = bHasCategories ? ( (nDataSeqCount-1) > 2 && (nDataSeqCount-1) % 2 != 0 )
:( nDataSeqCount > 2 && nDataSeqCount % 2 != 0 );
@@ -76,10 +77,10 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
{
if( bHasCategories && !bCategoriesUsed )
{
- xCategories.set( aData[nDataIdx] );
+ xCategories = aData[nDataIdx];
if( xCategories.is())
{
- SetRole( xCategories->getValues(), "categories");
+ SetRole( xCategories->getValues(), u"categories"_ustr);
if( bUseCategoriesAsX )
{
bSetXValues = false;
@@ -90,22 +91,22 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
}
else if( !xValuesX.is() && bSetXValues )
{
- xValuesX.set( aData[nDataIdx] );
+ xValuesX = aData[nDataIdx];
if( xValuesX.is())
- SetRole( xValuesX->getValues(), "values-x");
+ SetRole( xValuesX->getValues(), u"values-x"_ustr);
}
else if( bNextIsYValues )
{
aYValuesVector.push_back( aData[nDataIdx] );
if( aData[nDataIdx].is())
- SetRole( aData[nDataIdx]->getValues(), "values-y");
+ SetRole( aData[nDataIdx]->getValues(), u"values-y"_ustr);
bNextIsYValues = false;
}
else if( !bNextIsYValues )
{
aSizeValuesVector.push_back( aData[nDataIdx] );
if( aData[nDataIdx].is())
- SetRole( aData[nDataIdx]->getValues(), "values-size");
+ SetRole( aData[nDataIdx]->getValues(), u"values-size"_ustr);
bNextIsYValues = (nDataSeqCount-(nDataIdx+1)) >= 2;//two or more left
}
}
@@ -116,8 +117,8 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
}
// create DataSeries
- sal_Int32 nSeriesIndex = 0;
- vector< Reference< XDataSeries > > aSeriesVec;
+ std::size_t nSeriesIndex = 0;
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec;
aSeriesVec.reserve( aSizeValuesVector.size());
Reference< data::XLabeledDataSequence > xClonedXValues = xValuesX;
@@ -125,7 +126,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
for( size_t nN = 0; nN < aSizeValuesVector.size(); ++nN, ++nSeriesIndex )
{
- vector< Reference< data::XLabeledDataSequence > > aNewData;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewData;
if( xValuesX.is() )
{
if( nN > 0 && xCloneableX.is() )
@@ -136,53 +137,48 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
aNewData.push_back( aYValuesVector[nN] );
aNewData.push_back(aSizeValuesVector[nN]);
- Reference< XDataSeries > xSeries;
- if( nSeriesIndex < aSeriesToReUse.getLength())
- xSeries.set( aSeriesToReUse[nSeriesIndex] );
+ rtl::Reference< DataSeries > xSeries;
+ if( nSeriesIndex < aSeriesToReUse.size())
+ xSeries = aSeriesToReUse[nSeriesIndex];
else
- xSeries.set( new DataSeries );
- OSL_ASSERT( xSeries.is() );
- Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
- OSL_ASSERT( xSink.is() );
- xSink->setData( comphelper::containerToSequence( aNewData ) );
+ xSeries = new DataSeries;
+ assert( xSeries.is() );
+ xSeries->setData( aNewData );
aSeriesVec.push_back( xSeries );
}
- Sequence< Sequence< Reference< XDataSeries > > > aSeries(1);
- aSeries[0] = comphelper::containerToSequence( aSeriesVec );
- return InterpretedData( aSeries, xCategories );
+ return { { std::move(aSeriesVec) }, xCategories };
}
-chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
- const chart2::InterpretedData& aInterpretedData )
+InterpretedData BubbleDataInterpreter::reinterpretDataSeries(
+ const InterpretedData& aInterpretedData )
{
InterpretedData aResult( aInterpretedData );
sal_Int32 i=0;
- Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- const sal_Int32 nCount = aSeries.getLength();
+ std::vector< rtl::Reference< DataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ const sal_Int32 nCount = aSeries.size();
for( ; i<nCount; ++i )
{
try
{
- Reference< data::XDataSource > xSeriesSource( aSeries[i], uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aNewSequences;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewSequences;
- Reference< data::XLabeledDataSequence > xValuesSize(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-size" ));
- Reference< data::XLabeledDataSequence > xValuesY(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-y" ));
- Reference< data::XLabeledDataSequence > xValuesX(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-x" ));
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesSize(
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], u"values-size"_ustr ));
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesY(
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], u"values-y"_ustr ));
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesX(
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], u"values-x"_ustr ));
if( ! xValuesX.is() ||
! xValuesY.is() ||
! xValuesSize.is() )
{
- vector< Reference< data::XLabeledDataSequence > > aValueSeqVec(
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aValueSeqVec(
DataSeriesHelper::getAllDataSequencesByRole(
- xSeriesSource->getDataSequences(), "values" ));
+ aSeries[i]->getDataSequences2(), u"values"_ustr ));
if( xValuesX.is())
aValueSeqVec.erase( find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesX ));
if( xValuesY.is())
@@ -195,25 +191,25 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
if( ! xValuesSize.is() &&
aValueSeqVec.size() > nIndex )
{
- xValuesSize.set( aValueSeqVec[nIndex++] );
+ xValuesSize = aValueSeqVec[nIndex++];
if( xValuesSize.is())
- SetRole( xValuesSize->getValues(), "values-size");
+ SetRole( xValuesSize->getValues(), u"values-size"_ustr);
}
if( ! xValuesY.is() &&
aValueSeqVec.size() > nIndex )
{
- xValuesY.set( aValueSeqVec[nIndex++] );
+ xValuesY = aValueSeqVec[nIndex++];
if( xValuesY.is())
- SetRole( xValuesY->getValues(), "values-y");
+ SetRole( xValuesY->getValues(), u"values-y"_ustr);
}
if( ! xValuesX.is() &&
aValueSeqVec.size() > nIndex )
{
- xValuesX.set( aValueSeqVec[nIndex++] );
+ xValuesX = aValueSeqVec[nIndex++];
if( xValuesX.is())
- SetRole( xValuesY->getValues(), "values-x");
+ SetRole( xValuesX->getValues(), u"values-x"_ustr);
}
}
if( xValuesSize.is())
@@ -222,27 +218,21 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
{
if( xValuesX.is() )
{
- aNewSequences.realloc(3);
- aNewSequences[0] = xValuesX;
- aNewSequences[1] = xValuesY;
- aNewSequences[2] = xValuesSize;
+ aNewSequences = { xValuesX, xValuesY, xValuesSize };
}
else
{
- aNewSequences.realloc(2);
- aNewSequences[0] = xValuesY;
- aNewSequences[1] = xValuesSize;
+ aNewSequences = { xValuesY, xValuesSize };
}
}
else
{
- aNewSequences.realloc(1);
- aNewSequences[0] = xValuesSize;
+ aNewSequences = { xValuesSize };
}
}
- const Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
- if( aSeqs.getLength() != aNewSequences.getLength() )
+ const std::vector< uno::Reference< data::XLabeledDataSequence > > & aSeqs = aSeries[i]->getDataSequences2();
+ if( aSeqs.size() != aNewSequences.size() )
{
#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
for( auto const & j : aSeqs )
@@ -250,8 +240,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
assert( (j == xValuesY || j == xValuesX || j == xValuesSize) && "All sequences should be used" );
}
#endif
- Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
- xSink->setData( aNewSequences );
+ aSeries[i]->setData( aNewSequences );
}
}
catch( const uno::Exception & )
@@ -263,17 +252,15 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
return aResult;
}
-sal_Bool SAL_CALL BubbleDataInterpreter::isDataCompatible(
- const chart2::InterpretedData& aInterpretedData )
+bool BubbleDataInterpreter::isDataCompatible(
+ const InterpretedData& aInterpretedData )
{
- const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- for( Reference< XDataSeries > const & dataSeries : aSeries )
+ const std::vector< rtl::Reference< DataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ for( rtl::Reference< DataSeries > const & dataSeries : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
- if( aSeq.getLength() != 3 )
+ if( dataSeries->getDataSequences2().size() != 3 )
return false;
}
catch( const uno::Exception & )
diff --git a/chart2/source/model/template/BubbleDataInterpreter.hxx b/chart2/source/model/template/BubbleDataInterpreter.hxx
index 43921262ed2a..ff4b56de615a 100644
--- a/chart2/source/model/template/BubbleDataInterpreter.hxx
+++ b/chart2/source/model/template/BubbleDataInterpreter.hxx
@@ -16,10 +16,9 @@
* 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
+#pragma once
-#include "DataInterpreter.hxx"
+#include <DataInterpreter.hxx>
namespace chart
{
@@ -31,20 +30,17 @@ public:
virtual ~BubbleDataInterpreter() override;
protected:
- // ____ XDataInterpreter ____
- virtual css::chart2::InterpretedData SAL_CALL interpretDataSource(
+ // ____ DataInterpreter ____
+ virtual InterpretedData interpretDataSource(
const css::uno::Reference< css::chart2::data::XDataSource >& xSource,
const css::uno::Sequence< css::beans::PropertyValue >& aArguments,
- const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > >& aSeriesToReUse ) override;
- virtual css::chart2::InterpretedData SAL_CALL reinterpretDataSeries(
- const css::chart2::InterpretedData& aInterpretedData ) override;
- virtual sal_Bool SAL_CALL isDataCompatible(
- const css::chart2::InterpretedData& aInterpretedData ) override;
+ const std::vector< rtl::Reference< ::chart::DataSeries > >& aSeriesToReUse ) override;
+ virtual InterpretedData reinterpretDataSeries(
+ const InterpretedData& aInterpretedData ) override;
+ virtual bool isDataCompatible(
+ const InterpretedData& aInterpretedData ) override;
};
} // namespace chart
-// 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
index af0c1f04f52b..4e1f08f05679 100644
--- a/chart2/source/model/template/CandleStickChartType.cxx
+++ b/chart2/source/model/template/CandleStickChartType.cxx
@@ -24,7 +24,7 @@
#include <servicenames_charttypes.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
namespace com::sun::star::uno { class XComponentContext; }
@@ -79,66 +79,17 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEDEFAULT );
}
-struct StaticCandleStickChartTypeDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- // must match default in CTOR!
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_JAPANESE, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW, true );
- }
-};
-
-struct StaticCandleStickChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticCandleStickChartTypeDefaults_Initializer >
-{
-};
-
-struct StaticCandleStickChartTypeInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticCandleStickChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticCandleStickChartTypeInfoHelper_Initializer >
-{
-};
-
-struct StaticCandleStickChartTypeInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticCandleStickChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticCandleStickChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticCandleStickChartTypeInfo_Initializer >
+::cppu::OPropertyArrayHelper& StaticCandleStickChartTypeInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -206,6 +157,11 @@ uno::Reference< util::XCloneable > SAL_CALL CandleStickChartType::createClone()
return uno::Reference< util::XCloneable >( new CandleStickChartType( *this ));
}
+rtl::Reference< ChartType > CandleStickChartType::cloneChartType() const
+{
+ return new CandleStickChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL CandleStickChartType::getChartType()
{
@@ -259,29 +215,40 @@ Sequence< OUString > SAL_CALL CandleStickChartType::getSupportedOptionalRoles()
OUString SAL_CALL CandleStickChartType::getRoleOfSequenceForSeriesLabel()
{
- return "values-last";
+ return u"values-last"_ustr;
}
// ____ OPropertySet ____
-uno::Any CandleStickChartType::GetDefaultValue( sal_Int32 nHandle ) const
+void CandleStickChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticCandleStickChartTypeDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ static const ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ // must match default in CTOR!
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_CANDLESTICKCHARTTYPE_JAPANESE, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW, true );
+ return aTmp;
+ }();
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL CandleStickChartType::getInfoHelper()
{
- return *StaticCandleStickChartTypeInfoHelper::get();
+ return StaticCandleStickChartTypeInfoHelper();
}
// ____ XPropertySet ____
Reference< beans::XPropertySetInfo > SAL_CALL CandleStickChartType::getPropertySetInfo()
{
- return *StaticCandleStickChartTypeInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticCandleStickChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
}
void SAL_CALL CandleStickChartType::setFastPropertyValue_NoBroadcast(
@@ -300,7 +267,7 @@ void SAL_CALL CandleStickChartType::setFastPropertyValue_NoBroadcast(
ModifyListenerHelper::removeListener( xBroadcaster, m_xModifyEventForwarder );
}
- OSL_ASSERT( rValue.getValueType().getTypeClass() == uno::TypeClass_INTERFACE );
+ OSL_ASSERT( rValue.getValueTypeClass() == uno::TypeClass_INTERFACE );
if( rValue.hasValue() &&
(rValue >>= xBroadcaster) &&
xBroadcaster.is())
@@ -314,7 +281,7 @@ void SAL_CALL CandleStickChartType::setFastPropertyValue_NoBroadcast(
OUString SAL_CALL CandleStickChartType::getImplementationName()
{
- return "com.sun.star.comp.chart.CandleStickChartType" ;
+ return u"com.sun.star.comp.chart.CandleStickChartType"_ustr ;
}
sal_Bool SAL_CALL CandleStickChartType::supportsService( const OUString& rServiceName )
@@ -326,8 +293,8 @@ css::uno::Sequence< OUString > SAL_CALL CandleStickChartType::getSupportedServic
{
return {
CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK,
- "com.sun.star.chart2.ChartType",
- "com.sun.star.beans.PropertySet" };
+ u"com.sun.star.chart2.ChartType"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/template/CandleStickChartType.hxx b/chart2/source/model/template/CandleStickChartType.hxx
index b3f8d37ec306..822422aac85f 100644
--- a/chart2/source/model/template/CandleStickChartType.hxx
+++ b/chart2/source/model/template/CandleStickChartType.hxx
@@ -16,10 +16,9 @@
* 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
+#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -37,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit CandleStickChartType( const CandleStickChartType & rOther );
@@ -49,7 +50,7 @@ private:
virtual OUString SAL_CALL getRoleOfSequenceForSeriesLabel() override;
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
// ____ OPropertySet ____
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -69,7 +70,4 @@ private:
} // 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
index 999f7c1ede96..9e6f91f1def0 100644
--- a/chart2/source/model/template/ChartType.cxx
+++ b/chart2/source/model/template/ChartType.cxx
@@ -17,16 +17,21 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "ChartType.hxx"
+#include <ChartType.hxx>
#include <CartesianCoordinateSystem.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
#include <CloneHelper.hxx>
#include <AxisIndexDefines.hxx>
#include <ModifyListenerHelper.hxx>
-#include <vcl/svapp.hxx>
+#include <DataSeries.hxx>
+#include <servicenames_charttypes.hxx>
+#include <StackMode.hxx>
+#include <DiagramHelper.hxx>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/container/NoSuchElementException.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+#include <vcl/svapp.hxx>
using namespace ::com::sun::star;
@@ -38,20 +43,19 @@ namespace chart
{
ChartType::ChartType() :
- ::property::OPropertySet( m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_bNotifyChanges( true )
{}
ChartType::ChartType( const ChartType & rOther ) :
impl::ChartType_Base(rOther),
- ::property::OPropertySet( rOther, m_aMutex ),
- m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()),
+ ::property::OPropertySet( rOther ),
+ m_xModifyEventForwarder( new ModifyEventForwarder() ),
m_bNotifyChanges( true )
{
{
SolarMutexGuard g; // access to rOther.m_aDataSeries
- CloneHelper::CloneRefVector<css::chart2::XDataSeries>(
+ CloneHelper::CloneRefVector(
rOther.m_aDataSeries, m_aDataSeries);
}
ModifyListenerHelper::addListenerToAllElements( m_aDataSeries, m_xModifyEventForwarder );
@@ -67,12 +71,18 @@ ChartType::~ChartType()
Reference< chart2::XCoordinateSystem > SAL_CALL
ChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
{
- Reference< chart2::XCoordinateSystem > xResult(
- new CartesianCoordinateSystem( DimensionCount ));
+ return createCoordinateSystem2(DimensionCount);
+}
+
+rtl::Reference< BaseCoordinateSystem >
+ ChartType::createCoordinateSystem2( ::sal_Int32 DimensionCount )
+{
+ rtl::Reference< CartesianCoordinateSystem > xResult =
+ new CartesianCoordinateSystem( DimensionCount );
for( sal_Int32 i=0; i<DimensionCount; ++i )
{
- Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
+ rtl::Reference< Axis > xAxis = xResult->getAxisByDimension2( i, MAIN_AXIS_INDEX );
if( !xAxis.is() )
{
OSL_FAIL("a created coordinate system should have an axis for each dimension");
@@ -98,10 +108,7 @@ Reference< chart2::XCoordinateSystem > SAL_CALL
Sequence< OUString > SAL_CALL ChartType::getSupportedMandatoryRoles()
{
- Sequence< OUString > aDefaultSeq(2);
- aDefaultSeq[0] = "label";
- aDefaultSeq[1] = "values-y";
- return aDefaultSeq;
+ return { u"label"_ustr, u"values-y"_ustr };
}
Sequence< OUString > SAL_CALL ChartType::getSupportedOptionalRoles()
@@ -116,15 +123,15 @@ Sequence< OUString > SAL_CALL ChartType::getSupportedPropertyRoles()
OUString SAL_CALL ChartType::getRoleOfSequenceForSeriesLabel()
{
- return "values-y";
+ return u"values-y"_ustr;
}
void ChartType::impl_addDataSeriesWithoutNotification(
- const Reference< chart2::XDataSeries >& xDataSeries )
+ const rtl::Reference< DataSeries >& xDataSeries )
{
if( std::find( m_aDataSeries.begin(), m_aDataSeries.end(), xDataSeries )
!= m_aDataSeries.end())
- throw lang::IllegalArgumentException();
+ throw lang::IllegalArgumentException(u"dataseries not found"_ustr, static_cast<cppu::OWeakObject*>(this), 1);
m_aDataSeries.push_back( xDataSeries );
ModifyListenerHelper::addListener( xDataSeries, m_xModifyEventForwarder );
@@ -133,6 +140,13 @@ void ChartType::impl_addDataSeriesWithoutNotification(
// ____ XDataSeriesContainer ____
void SAL_CALL ChartType::addDataSeries( const Reference< chart2::XDataSeries >& xDataSeries )
{
+ rtl::Reference<DataSeries> xTmp = dynamic_cast<DataSeries*>(xDataSeries.get());
+ assert(xTmp);
+ addDataSeries(xTmp);
+}
+
+void ChartType::addDataSeries( const rtl::Reference< DataSeries >& xDataSeries )
+{
SolarMutexGuard g;
impl_addDataSeriesWithoutNotification( xDataSeries );
@@ -141,17 +155,23 @@ void SAL_CALL ChartType::addDataSeries( const Reference< chart2::XDataSeries >&
void SAL_CALL ChartType::removeDataSeries( const Reference< chart2::XDataSeries >& xDataSeries )
{
+ rtl::Reference<DataSeries> xTmp = dynamic_cast<DataSeries*>(xDataSeries.get());
+ assert(xTmp);
+ removeDataSeries(xTmp);
+}
+
+void ChartType::removeDataSeries( const rtl::Reference< DataSeries >& xDataSeries )
+{
if( !xDataSeries.is())
throw container::NoSuchElementException();
SolarMutexGuard g;
- tDataSeriesContainerType::iterator aIt(
- std::find( m_aDataSeries.begin(), m_aDataSeries.end(), xDataSeries ) );
+ auto aIt = std::find( m_aDataSeries.begin(), m_aDataSeries.end(), xDataSeries );
if( aIt == m_aDataSeries.end())
throw container::NoSuchElementException(
- "The given series is no element of this charttype",
+ u"The given series is no element of this charttype"_ustr,
static_cast< uno::XWeak * >( this ));
ModifyListenerHelper::removeListener( xDataSeries, m_xModifyEventForwarder );
@@ -163,18 +183,34 @@ Sequence< Reference< chart2::XDataSeries > > SAL_CALL ChartType::getDataSeries()
{
SolarMutexGuard g;
- return comphelper::containerToSequence( m_aDataSeries );
+ return comphelper::containerToSequence< Reference< chart2::XDataSeries > >( m_aDataSeries );
+}
+
+const std::vector<rtl::Reference<::chart::DataSeries>>& ChartType::getDataSeries2() const
+{
+ return m_aDataSeries;
}
void SAL_CALL ChartType::setDataSeries( const Sequence< Reference< chart2::XDataSeries > >& aDataSeries )
{
+ std::vector< rtl::Reference<DataSeries> > aTmp;
+ for (auto const & i : aDataSeries)
+ {
+ auto p = dynamic_cast<DataSeries*>(i.get());
+ assert(p);
+ aTmp.push_back(p);
+ }
+ setDataSeries(aTmp);
+}
+
+void ChartType::setDataSeries( const std::vector< rtl::Reference< DataSeries > >& aDataSeries )
+{
SolarMutexGuard g;
m_bNotifyChanges = false;
try
{
- const Sequence< Reference< chart2::XDataSeries > > aOldSeries( getDataSeries() );
- for( auto const & i : aOldSeries )
+ for( auto const & i : m_aDataSeries )
ModifyListenerHelper::removeListener( i, m_xModifyEventForwarder );
m_aDataSeries.clear();
@@ -188,42 +224,28 @@ void SAL_CALL ChartType::setDataSeries( const Sequence< Reference< chart2::XData
}
m_bNotifyChanges = true;
fireModifyEvent();
-}
-// ____ OPropertySet ____
-uno::Any ChartType::GetDefaultValue( sal_Int32 /* nHandle */ ) const
-{
- return uno::Any();
+ createCalculatedDataSeries();
}
-namespace
+void ChartType::createCalculatedDataSeries()
{
-struct StaticChartTypeInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( Sequence< beans::Property >{} );
- return &aPropHelper;
- }
-};
+}
-struct StaticChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticChartTypeInfoHelper_Initializer >
+// ____ OPropertySet ____
+void ChartType::GetDefaultValue( sal_Int32 /* nHandle */, uno::Any& rAny ) const
{
-};
+ rAny.clear();
+}
-struct StaticChartTypeInfo_Initializer
+namespace
{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-struct StaticChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticChartTypeInfo_Initializer >
+::cppu::OPropertyArrayHelper& StaticChartTypeInfoHelper()
{
+ static ::cppu::OPropertyArrayHelper aPropHelper( Sequence< beans::Property >{} );
+ return aPropHelper;
};
}
@@ -231,13 +253,15 @@ struct StaticChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans:
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL ChartType::getInfoHelper()
{
- return *StaticChartTypeInfoHelper::get();
+ return StaticChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL ChartType::getPropertySetInfo()
{
- return *StaticChartTypeInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo( StaticChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
}
// ____ XModifyBroadcaster ____
@@ -245,8 +269,7 @@ void SAL_CALL ChartType::addModifyListener( const uno::Reference< util::XModifyL
{
try
{
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->addModifyListener( aListener );
+ m_xModifyEventForwarder->addModifyListener( aListener );
}
catch( const uno::Exception & )
{
@@ -258,8 +281,7 @@ void SAL_CALL ChartType::removeModifyListener( const uno::Reference< util::XModi
{
try
{
- uno::Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW );
- xBroadcaster->removeModifyListener( aListener );
+ m_xModifyEventForwarder->removeModifyListener( aListener );
}
catch( const uno::Exception & )
{
@@ -298,11 +320,350 @@ void ChartType::fireModifyEvent()
m_xModifyEventForwarder->modified( lang::EventObject( static_cast< uno::XWeak* >( this )));
}
+bool ChartType::isSupportingStatisticProperties(sal_Int32 nDimensionCount)
+{
+ //3D charts, pie, net and stock do not support statistic properties
+
+ if (nDimensionCount == 3)
+ return false;
+
+ OUString aChartTypeName = getChartType();
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE))
+ return false;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET))
+ return false;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET))
+ return false;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK))
+ return false;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE)) //todo: BubbleChart support error bars and trend lines
+ return false;
+
+ return true;
+}
+
+bool ChartType::isSupportingRegressionProperties(sal_Int32 nDimensionCount)
+{
+ // note: old chart: only scatter chart
+ return isSupportingStatisticProperties(nDimensionCount);
+}
+
+bool ChartType::isSupportingGeometryProperties(sal_Int32 nDimensionCount)
+{
+ //form tab only for 3D-bar and 3D-column charts.
+ if (nDimensionCount == 3)
+ {
+ OUString aChartTypeName = getChartType();
+
+ if (aChartTypeName == CHART2_SERVICE_NAME_CHARTTYPE_BAR)
+ return true;
+
+ if (aChartTypeName == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
+ return true;
+ }
+ return false;
+}
+
+bool ChartType::isSupportingAreaProperties(sal_Int32 nDimensionCount)
+{
+ //2D line charts, net and stock do not support area properties
+ if (nDimensionCount == 2)
+ {
+ OUString aChartTypeName = getChartType();
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE))
+ return false;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER))
+ return false;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET))
+ return false;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK))
+ return false;
+ }
+ return true;
+}
+
+bool ChartType::isSupportingSymbolProperties(sal_Int32 nDimensionCount)
+{
+ //2D line charts, 2D scatter charts and 2D net charts do support symbols
+ if (nDimensionCount == 3)
+ return false;
+
+ OUString aChartTypeName = getChartType();
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE))
+ return true;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER))
+ return true;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET))
+ return true;
+
+ return false;
+}
+
+bool ChartType::isSupportingSecondaryAxis(sal_Int32 nDimensionCount)
+{
+ //3D, pie and net charts do not support a secondary axis at all
+ if (nDimensionCount == 3)
+ return false;
+
+ OUString aChartTypeName = getChartType();
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE))
+ return false;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET))
+ return false;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET))
+ return false;
+
+ return true;
+}
+
+bool ChartType::isSupportingRightAngledAxes()
+{
+ OUString aChartTypeName = getChartType();
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE))
+ return false;
+ return true;
+}
+
+bool ChartType::isSupportingOverlapAndGapWidthProperties(sal_Int32 nDimensionCount)
+{
+ //2D bar charts do support a this special properties
+ if (nDimensionCount == 3)
+ return false;
+
+ OUString aChartTypeName = getChartType();
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN))
+ return true;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR))
+ return true;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_HISTOGRAM))
+ return true;
+ return false;
+}
+
+bool ChartType::isSupportingBarConnectors(sal_Int32 nDimensionCount)
+{
+ //2D bar charts with stacked series support this
+
+ if (nDimensionCount == 3)
+ return false;
+
+ bool bFound = false;
+ bool bAmbiguous = false;
+ StackMode eStackMode = DiagramHelper::getStackModeFromChartType(this, bFound, bAmbiguous, nullptr);
+ if (eStackMode != StackMode::YStacked || bAmbiguous)
+ return false;
+
+ OUString aChartTypeName = getChartType();
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN))
+ return true;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR))
+ return true; // note: old chart was false here
+
+ return false;
+}
+
+bool ChartType::isSupportingAxisSideBySide(sal_Int32 nDimensionCount)
+{
+ bool bResult = false;
+
+ if (nDimensionCount < 3)
+ {
+ bool bFound = false;
+ bool bAmbiguous = false;
+ StackMode eStackMode = DiagramHelper::getStackModeFromChartType(this, bFound, bAmbiguous, nullptr);
+ if (eStackMode == StackMode::NONE && !bAmbiguous)
+ {
+ OUString aChartTypeName = getChartType();
+
+ bResult = aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) ||
+ aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR);
+ }
+ }
+
+ return bResult;
+}
+
+bool ChartType::isSupportingBaseValue()
+{
+ OUString aChartTypeName = getChartType();
+
+ return aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN)
+ || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR)
+ || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA);
+}
+
+bool ChartType::isSupportingAxisPositioning(sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex )
+{
+ OUString aChartTypeName = getChartType();
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET))
+ return false;
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET))
+ return false;
+
+ if (nDimensionCount == 3)
+ return nDimensionIndex < 2;
+
+ return true;
+}
+
+bool ChartType::isSupportingMainAxis(sal_Int32 nDimensionCount, sal_Int32 nDimensionIndex)
+{
+ // pie charts do not support axis at all
+ // no 3rd axis for 2D charts
+
+ OUString aChartTypeName = getChartType();
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE))
+ return false;
+
+ if (nDimensionIndex == 2)
+ return nDimensionCount == 3;
+
+ return true;
+}
+
+bool ChartType::isSupportingStartingAngle()
+{
+ OUString aChartTypeName = getChartType();
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE))
+ return true;
+ return false;
+}
+
+bool ChartType::isSupportingDateAxis(sal_Int32 nDimensionIndex)
+{
+ if (nDimensionIndex != 0)
+ return false;
+
+ sal_Int32 nType = getAxisType(nDimensionIndex);
+
+ if (nType != chart2::AxisType::CATEGORY)
+ return false;
+
+ OUString aChartTypeName = getChartType();
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE)
+ || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_NET)
+ || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET))
+ {
+ return false;
+ }
+ return true;
+}
+
+bool ChartType::isSupportingComplexCategory()
+{
+ OUString aChartTypeName = getChartType();
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_PIE))
+ return false;
+ return true;
+}
+
+bool ChartType::isSupportingCategoryPositioning(sal_Int32 nDimensionCount)
+{
+ OUString aChartTypeName = getChartType();
+
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA) ||
+ aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) ||
+ aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK))
+ {
+ return true;
+ }
+ else if (nDimensionCount == 2 &&
+ (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_COLUMN) ||
+ aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BAR) ||
+ aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_HISTOGRAM)))
+ {
+ return true;
+ }
+ return false;
+}
+
+bool ChartType::isSupportingOnlyDeepStackingFor3D()
+{
+ OUString aChartTypeName = getChartType();
+ return
+ aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_LINE) ||
+ aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) ||
+ aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_AREA);
+}
+
+bool ChartType::isSeriesInFrontOfAxisLine()
+{
+ OUString aChartTypeName = getChartType();
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET))
+ return false;
+ return true;
+}
+
+sal_Int32 ChartType::getAxisType(sal_Int32 nDimensionIndex)
+{
+ //returned is a constant from constant group css::chart2::AxisType
+
+ OUString aChartTypeName = getChartType();
+ if (nDimensionIndex == 2) //z-axis
+ return chart2::AxisType::SERIES;
+
+ if (nDimensionIndex == 1) //y-axis
+ return chart2::AxisType::REALNUMBER;
+
+ if (nDimensionIndex == 0) //x-axis
+ {
+ if (aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER)
+ || aChartTypeName.match(CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE))
+ return chart2::AxisType::REALNUMBER;
+ return chart2::AxisType::CATEGORY;
+ }
+ return chart2::AxisType::CATEGORY;
+}
+
using impl::ChartType_Base;
IMPLEMENT_FORWARD_XINTERFACE2( ChartType, ChartType_Base, ::property::OPropertySet )
IMPLEMENT_FORWARD_XTYPEPROVIDER2( ChartType, ChartType_Base, ::property::OPropertySet )
+void ChartType::deleteSeries( const rtl::Reference< ::chart::DataSeries > & xSeries )
+{
+ try
+ {
+ SolarMutexGuard g;
+
+ auto it = std::find( m_aDataSeries.begin(), m_aDataSeries.end(), xSeries );
+ if( it == m_aDataSeries.end())
+ return;
+
+ ModifyListenerHelper::removeListener( *it, m_xModifyEventForwarder );
+ m_aDataSeries.erase(it);
+ fireModifyEvent();
+
+ createCalculatedDataSeries();
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+
+
} // 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
deleted file mode 100644
index 3274d5660c9b..000000000000
--- a/chart2/source/model/template/ChartType.hxx
+++ /dev/null
@@ -1,141 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#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
index c0bcc0a03d33..8baf3682ecac 100644
--- a/chart2/source/model/template/ChartTypeManager.cxx
+++ b/chart2/source/model/template/ChartTypeManager.cxx
@@ -23,23 +23,25 @@
#include "LineChartTypeTemplate.hxx"
#include "BarChartTypeTemplate.hxx"
#include "ColumnLineChartTypeTemplate.hxx"
+#include "HistogramChartTypeTemplate.hxx"
#include "AreaChartTypeTemplate.hxx"
#include "PieChartTypeTemplate.hxx"
#include "ScatterChartTypeTemplate.hxx"
#include "StockChartTypeTemplate.hxx"
#include "NetChartTypeTemplate.hxx"
#include "BubbleChartTypeTemplate.hxx"
+#include "FunnelChartTypeTemplate.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>
+#include <utility>
using namespace ::com::sun::star;
@@ -79,6 +81,7 @@ enum TemplateId
TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT,
TEMPLATE_COLUMNWITHLINE,
TEMPLATE_STACKEDCOLUMNWITHLINE,
+ TEMPLATE_HISTOGRAM,
TEMPLATE_AREA,
TEMPLATE_STACKEDAREA,
TEMPLATE_PERCENTSTACKEDAREA,
@@ -89,6 +92,8 @@ enum TemplateId
TEMPLATE_PIEALLEXPLODED,
TEMPLATE_DONUT,
TEMPLATE_DONUTALLEXPLODED,
+ TEMPLATE_BAROFPIE,
+ TEMPLATE_PIEOFPIE,
TEMPLATE_THREEDPIE,
TEMPLATE_THREEDPIEALLEXPLODED,
TEMPLATE_THREEDDONUT,
@@ -114,6 +119,7 @@ enum TemplateId
TEMPLATE_STOCKVOLUMELOWHIGHCLOSE,
TEMPLATE_STOCKVOLUMEOPENLOWHIGHCLOSE,
TEMPLATE_BUBBLE,
+ TEMPLATE_FUNNEL,
// TEMPLATE_SURFACE,
// TEMPLATE_ADDIN,
TEMPLATE_NOT_FOUND = 0xffff
@@ -153,6 +159,7 @@ const tTemplateMapType & lcl_DefaultChartTypeMap()
{"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.Histogram", TEMPLATE_HISTOGRAM},
{"com.sun.star.chart2.template.Area", TEMPLATE_AREA},
{"com.sun.star.chart2.template.StackedArea", TEMPLATE_STACKEDAREA},
{"com.sun.star.chart2.template.PercentStackedArea", TEMPLATE_PERCENTSTACKEDAREA},
@@ -163,6 +170,9 @@ const tTemplateMapType & lcl_DefaultChartTypeMap()
{"com.sun.star.chart2.template.PieAllExploded", TEMPLATE_PIEALLEXPLODED},
{"com.sun.star.chart2.template.Donut", TEMPLATE_DONUT},
{"com.sun.star.chart2.template.DonutAllExploded", TEMPLATE_DONUTALLEXPLODED},
+ {"com.sun.star.chart2.template.BarOfPie", TEMPLATE_BAROFPIE},
+ {"com.sun.star.chart2.template.PieOfPie", TEMPLATE_PIEOFPIE},
+ {"com.sun.star.chart2.template.DonutAllExploded", TEMPLATE_DONUTALLEXPLODED},
{"com.sun.star.chart2.template.ThreeDPie", TEMPLATE_THREEDPIE},
{"com.sun.star.chart2.template.ThreeDPieAllExploded", TEMPLATE_THREEDPIEALLEXPLODED},
{"com.sun.star.chart2.template.ThreeDDonut", TEMPLATE_THREEDDONUT},
@@ -188,6 +198,7 @@ const tTemplateMapType & lcl_DefaultChartTypeMap()
{"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.Funnel", TEMPLATE_FUNNEL},
// {"com.sun.star.chart2.template.Surface", TEMPLATE_SURFACE},
// {"com.sun.star.chart2.template.Addin", TEMPLATE_ADDIN},
};
@@ -213,8 +224,8 @@ namespace chart
ChartTypeManager::ChartTypeManager(
uno::Reference<
- uno::XComponentContext > const & xContext ) :
- m_xContext( xContext )
+ uno::XComponentContext > xContext ) :
+ m_xContext(std::move( xContext ))
{}
ChartTypeManager::~ChartTypeManager()
@@ -224,312 +235,323 @@ ChartTypeManager::~ChartTypeManager()
uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance(
const OUString& aServiceSpecifier )
{
- uno::Reference< uno::XInterface > xResult;
+ return static_cast<cppu::OWeakObject*>(createTemplate(aServiceSpecifier).get());
+}
+
+rtl::Reference< ::chart::ChartTypeTemplate > ChartTypeManager::createTemplate(
+ const OUString& aServiceSpecifier )
+{
TemplateId nId = lcl_GetTemplateIdForService( aServiceSpecifier );
- if( nId == TEMPLATE_NOT_FOUND )
+ rtl::Reference< ::chart::ChartTypeTemplate > xTemplate;
+ switch( nId )
{
- try
- {
- xResult = m_xContext->getServiceManager()->createInstanceWithContext(
- aServiceSpecifier, m_xContext );
- }
-// catch( registry::InvalidValueException & ex )
- catch( const uno::Exception & )
+ // Point (category x axis)
+ case TEMPLATE_SYMBOL:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, true, false ));
+ break;
+ case TEMPLATE_STACKEDSYMBOL:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, true, false ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDSYMBOL:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, true, false ));
+ break;
+ // Line (category x axis)
+ case TEMPLATE_LINE:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, false ));
+ break;
+ case TEMPLATE_STACKEDLINE:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, false ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDLINE:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, false ));
+ break;
+ case TEMPLATE_LINESYMBOL:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, true ));
+ break;
+ case TEMPLATE_STACKEDLINESYMBOL:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, true ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDLINESYMBOL:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, true ));
+ break;
+ case TEMPLATE_THREEDLINE:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, false, true, 3 ));
+ break;
+ case TEMPLATE_STACKEDTHREEDLINE:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, false, true, 3 ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDTHREEDLINE:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, false, true, 3 ));
+ break;
+ case TEMPLATE_THREEDLINEDEEP:
+ xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::ZStacked, false, true, 3 ));
+ break;
+
+ // Bar/Column
+ case TEMPLATE_COLUMN:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, BarChartTypeTemplate::VERTICAL ));
+ break;
+ case TEMPLATE_STACKEDCOLUMN:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, BarChartTypeTemplate::VERTICAL ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDCOLUMN:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, BarChartTypeTemplate::VERTICAL ));
+ break;
+ case TEMPLATE_BAR:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, BarChartTypeTemplate::HORIZONTAL ));
+ break;
+ case TEMPLATE_STACKEDBAR:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, BarChartTypeTemplate::HORIZONTAL ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDBAR:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, BarChartTypeTemplate::HORIZONTAL ));
+ break;
+ case TEMPLATE_THREEDCOLUMNDEEP:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::ZStacked, BarChartTypeTemplate::VERTICAL, 3 ));
+ break;
+ case TEMPLATE_THREEDCOLUMNFLAT:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, BarChartTypeTemplate::VERTICAL, 3 ));
+ break;
+ case TEMPLATE_STACKEDTHREEDCOLUMNFLAT:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, BarChartTypeTemplate::VERTICAL, 3 ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, BarChartTypeTemplate::VERTICAL, 3 ));
+ break;
+ case TEMPLATE_THREEDBARDEEP:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::ZStacked, BarChartTypeTemplate::HORIZONTAL, 3 ));
+ break;
+ case TEMPLATE_THREEDBARFLAT:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::NONE, BarChartTypeTemplate::HORIZONTAL, 3 ));
+ break;
+ case TEMPLATE_STACKEDTHREEDBARFLAT:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStacked, BarChartTypeTemplate::HORIZONTAL, 3 ));
+ break;
+ case TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT:
+ xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
+ StackMode::YStackedPercent, BarChartTypeTemplate::HORIZONTAL, 3 ));
+ break;
+
+ // Combi-Chart Line/Column
+ case TEMPLATE_COLUMNWITHLINE:
+ case TEMPLATE_STACKEDCOLUMNWITHLINE:
{
- // couldn't create service via factory
+ StackMode eMode = ( nId == TEMPLATE_COLUMNWITHLINE )
+ ? StackMode::NONE
+ : StackMode::YStacked;
- // As XMultiServiceFactory does not specify, what to do in case
- // createInstance is called with an unknown service-name, this
- // function will just return an empty XInterface.
- DBG_UNHANDLED_EXCEPTION("chart2");
- SAL_WARN("chart2", "Couldn't instantiate service: "<< aServiceSpecifier );
- xResult.set( nullptr );
+ xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, aServiceSpecifier, eMode, 1 ));
}
- }
- else
- {
- uno::Reference< chart2::XChartTypeTemplate > xTemplate;
- switch( nId )
- {
- // Point (category x axis)
- case TEMPLATE_SYMBOL:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, true, false ));
- break;
- case TEMPLATE_STACKEDSYMBOL:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, true, false ));
- break;
- case TEMPLATE_PERCENTSTACKEDSYMBOL:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, true, false ));
- break;
- // Line (category x axis)
- case TEMPLATE_LINE:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, false ));
- break;
- case TEMPLATE_STACKEDLINE:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, false ));
- break;
- case TEMPLATE_PERCENTSTACKEDLINE:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, false ));
- break;
- case TEMPLATE_LINESYMBOL:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, true ));
- break;
- case TEMPLATE_STACKEDLINESYMBOL:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, true ));
- break;
- case TEMPLATE_PERCENTSTACKEDLINESYMBOL:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, true ));
- break;
- case TEMPLATE_THREEDLINE:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, false, true, 3 ));
- break;
- case TEMPLATE_STACKEDTHREEDLINE:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, false, true, 3 ));
- break;
- case TEMPLATE_PERCENTSTACKEDTHREEDLINE:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, false, true, 3 ));
- break;
- case TEMPLATE_THREEDLINEDEEP:
- xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::ZStacked, false, true, 3 ));
- break;
-
- // Bar/Column
- case TEMPLATE_COLUMN:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, BarChartTypeTemplate::VERTICAL ));
- break;
- case TEMPLATE_STACKEDCOLUMN:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, BarChartTypeTemplate::VERTICAL ));
- break;
- case TEMPLATE_PERCENTSTACKEDCOLUMN:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, BarChartTypeTemplate::VERTICAL ));
- break;
- case TEMPLATE_BAR:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, BarChartTypeTemplate::HORIZONTAL ));
- break;
- case TEMPLATE_STACKEDBAR:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, BarChartTypeTemplate::HORIZONTAL ));
- break;
- case TEMPLATE_PERCENTSTACKEDBAR:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, BarChartTypeTemplate::HORIZONTAL ));
- break;
- case TEMPLATE_THREEDCOLUMNDEEP:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::ZStacked, BarChartTypeTemplate::VERTICAL, 3 ));
- break;
- case TEMPLATE_THREEDCOLUMNFLAT:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, BarChartTypeTemplate::VERTICAL, 3 ));
- break;
- case TEMPLATE_STACKEDTHREEDCOLUMNFLAT:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, BarChartTypeTemplate::VERTICAL, 3 ));
- break;
- case TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, BarChartTypeTemplate::VERTICAL, 3 ));
- break;
- case TEMPLATE_THREEDBARDEEP:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::ZStacked, BarChartTypeTemplate::HORIZONTAL, 3 ));
- break;
- case TEMPLATE_THREEDBARFLAT:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::NONE, BarChartTypeTemplate::HORIZONTAL, 3 ));
- break;
- case TEMPLATE_STACKEDTHREEDBARFLAT:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStacked, BarChartTypeTemplate::HORIZONTAL, 3 ));
- break;
- case TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT:
- xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier,
- StackMode::YStackedPercent, BarChartTypeTemplate::HORIZONTAL, 3 ));
- break;
-
- // Combi-Chart Line/Column
- case TEMPLATE_COLUMNWITHLINE:
- case TEMPLATE_STACKEDCOLUMNWITHLINE:
- {
- StackMode eMode = ( nId == TEMPLATE_COLUMNWITHLINE )
- ? StackMode::NONE
- : StackMode::YStacked;
+ break;
- xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, aServiceSpecifier, eMode, 1 ));
- }
+ // Histogram
+ case TEMPLATE_HISTOGRAM:
+ xTemplate.set( new HistogramChartTypeTemplate( m_xContext, aServiceSpecifier, StackMode::NONE ));
+ 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,
+ chart2::PieChartSubType_NONE, 3, 2));
+ break;
+ case TEMPLATE_PIEALLEXPLODED:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_ALL_EXPLODED, false,
+ chart2::PieChartSubType_NONE, 3, 2 ));
+ break;
+ case TEMPLATE_DONUT:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_NONE, true,
+ chart2::PieChartSubType_NONE, 3, 2 ));
+ break;
+ case TEMPLATE_DONUTALLEXPLODED:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_ALL_EXPLODED, true,
+ chart2::PieChartSubType_NONE, 3, 2 ));
+ break;
+ case TEMPLATE_BAROFPIE:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_NONE, false,
+ chart2::PieChartSubType_BAR, 3, 2 ));
+ break;
+ case TEMPLATE_PIEOFPIE:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_NONE, false,
+ chart2::PieChartSubType_PIE, 3, 2 ));
+ break;
+ case TEMPLATE_THREEDPIE:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_NONE, false,
+ chart2::PieChartSubType_NONE, 3, 3 ));
+ break;
+ case TEMPLATE_THREEDPIEALLEXPLODED:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_ALL_EXPLODED, false,
+ chart2::PieChartSubType_NONE, 3, 3 ));
+ break;
+ case TEMPLATE_THREEDDONUT:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_NONE, true,
+ chart2::PieChartSubType_NONE, 3, 3 ));
+ break;
+ case TEMPLATE_THREEDDONUTALLEXPLODED:
+ xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier,
+ chart2::PieChartOffsetMode_ALL_EXPLODED, true,
+ chart2::PieChartSubType_NONE, 3, 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;
- // 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;
+ // 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;
+
+ // Funnel chart
+ case TEMPLATE_FUNNEL:
+ xTemplate.set( new FunnelChartTypeTemplate( m_xContext,
+ aServiceSpecifier));
+ break;
+ case TEMPLATE_NOT_FOUND:
+ SAL_WARN("chart2", "Couldn't instantiate service: "<< aServiceSpecifier );
+ assert(false);
+ break;
+
+ default: break;
// case TEMPLATE_SURFACE:
// case TEMPLATE_ADDIN:
// break;
-
- case TEMPLATE_NOT_FOUND:
- OSL_ASSERT( false );
- break;
- }
- xResult.set( xTemplate, uno::UNO_QUERY );
}
- return xResult;
+ return xTemplate;
}
uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstanceWithArguments(
@@ -556,7 +578,7 @@ uno::Sequence< OUString > SAL_CALL ChartTypeManager::getAvailableServiceNames()
if( xEnumAcc.is())
{
uno::Reference< container::XEnumeration > xEnum(
- xEnumAcc->createContentEnumeration( "com.sun.star.chart2.ChartTypeTemplate" ));
+ xEnumAcc->createContentEnumeration( u"com.sun.star.chart2.ChartTypeTemplate"_ustr ));
if( xEnum.is())
{
uno::Reference< uno::XInterface > xFactIntf;
@@ -579,7 +601,7 @@ uno::Sequence< OUString > SAL_CALL ChartTypeManager::getAvailableServiceNames()
// ____ XServiceInfo ____
OUString SAL_CALL ChartTypeManager::getImplementationName()
{
- return "com.sun.star.comp.chart.ChartTypeManager";
+ return u"com.sun.star.comp.chart.ChartTypeManager"_ustr;
}
sal_Bool SAL_CALL ChartTypeManager::supportsService( const OUString& rServiceName )
@@ -590,8 +612,8 @@ sal_Bool SAL_CALL ChartTypeManager::supportsService( const OUString& rServiceNam
css::uno::Sequence< OUString > SAL_CALL ChartTypeManager::getSupportedServiceNames()
{
return {
- "com.sun.star.chart2.ChartTypeManager",
- "com.sun.star.lang.MultiServiceFactory" };
+ u"com.sun.star.chart2.ChartTypeManager"_ustr,
+ u"com.sun.star.lang.MultiServiceFactory"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx
index 8aafc1fd1d8b..5685f9e06c0c 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -17,30 +17,36 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "ChartTypeTemplate.hxx"
-#include "DataInterpreter.hxx"
+#include <ChartTypeTemplate.hxx>
+#include <DataInterpreter.hxx>
#include <CommonConverters.hxx>
#include <ChartTypeHelper.hxx>
+#include <ChartType.hxx>
+#include <DataSeriesProperties.hxx>
+#include <DataSource.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
+#include <Diagram.hxx>
#include <DiagramHelper.hxx>
#include <AxisIndexDefines.hxx>
+#include <BaseCoordinateSystem.hxx>
#include <unonames.hxx>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/chart2/StackingDirection.hpp>
-#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
-#include <tools/diagnose_ex.h>
+#include <com/sun/star/chart2/XColorScheme.hpp>
+#include <comphelper/diagnose_ex.hxx>
#include <comphelper/property.hxx>
-#include <comphelper/sequence.hxx>
#include <algorithm>
+#include <cstddef>
+#include <utility>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
+using namespace ::chart::DataSeriesProperties;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Reference;
@@ -49,19 +55,18 @@ namespace
{
void lcl_applyDefaultStyle(
- const Reference< XDataSeries > & xSeries,
+ const rtl::Reference< ::chart::DataSeries > & xSeries,
sal_Int32 nIndex,
- const Reference< XDiagram > & xDiagram )
+ const rtl::Reference< ::chart::Diagram > & xDiagram )
{
// @deprecated: correct default color should be found by view without
// setting color as hard attribute
if( xSeries.is() && xDiagram.is())
{
- Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
Reference< chart2::XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme());
- if( xSeriesProp.is() && xColorScheme.is() )
- xSeriesProp->setPropertyValue(
- "Color",
+ if( xColorScheme.is() )
+ xSeries->setPropertyValue(
+ u"Color"_ustr,
uno::Any( xColorScheme->getColorByIndex( nIndex )));
}
}
@@ -69,7 +74,7 @@ void lcl_applyDefaultStyle(
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)) )
+ if( !(xProp.is() && (xProp->getPropertyValue( u"LabelPlacement"_ustr ) >>= nLabelPlacement)) )
return;
bool bValid = false;
@@ -87,7 +92,7 @@ void lcl_ensureCorrectLabelPlacement( const Reference< beans::XPropertySet >& xP
//otherwise use the first supported one
if( rAvailablePlacements.hasElements() )
aNewValue <<=rAvailablePlacements[0];
- xProp->setPropertyValue( "LabelPlacement", aNewValue );
+ xProp->setPropertyValue( u"LabelPlacement"_ustr, aNewValue );
}
}
@@ -95,25 +100,24 @@ void lcl_resetLabelPlacementIfDefault( const Reference< beans::XPropertySet >& x
{
sal_Int32 nLabelPlacement=0;
- if( xProp.is() && (xProp->getPropertyValue( "LabelPlacement" ) >>= nLabelPlacement) )
+ if( xProp.is() && (xProp->getPropertyValue( u"LabelPlacement"_ustr ) >>= nLabelPlacement) )
{
if( nDefaultPlacement == nLabelPlacement )
- xProp->setPropertyValue( "LabelPlacement", uno::Any() );
+ xProp->setPropertyValue( u"LabelPlacement"_ustr, uno::Any() );
}
}
-void lcl_ensureCorrectMissingValueTreatment( const Reference< chart2::XDiagram >& xDiagram, const Reference< XChartType >& xChartType )
+void lcl_ensureCorrectMissingValueTreatment( const rtl::Reference< ::chart::Diagram >& xDiagram, const rtl::Reference< ::chart::ChartType >& xChartType )
{
- Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY );
- if( xDiaProp.is() )
+ if( xDiagram.is() )
{
uno::Sequence < sal_Int32 > aAvailableMissingValueTreatment(
::chart::ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ) );
if( aAvailableMissingValueTreatment.hasElements() )
- xDiaProp->setPropertyValue( "MissingValueTreatment", uno::Any( aAvailableMissingValueTreatment[0] ) );
+ xDiagram->setPropertyValue( u"MissingValueTreatment"_ustr, uno::Any( aAvailableMissingValueTreatment[0] ) );
else
- xDiaProp->setPropertyValue( "MissingValueTreatment", uno::Any() );
+ xDiagram->setPropertyValue( u"MissingValueTreatment"_ustr, uno::Any() );
}
}
@@ -124,44 +128,39 @@ namespace chart
ChartTypeTemplate::ChartTypeTemplate(
Reference< uno::XComponentContext > const & xContext,
- const OUString & rServiceName ) :
+ OUString aServiceName ) :
m_xContext( xContext ),
- m_aServiceName( rServiceName )
+ m_aServiceName(std::move( aServiceName ))
{
}
ChartTypeTemplate::~ChartTypeTemplate()
{}
-// ____ XChartTypeTemplate ____
-uno::Reference< XDiagram > SAL_CALL ChartTypeTemplate::createDiagramByDataSource(
+// ____ ChartTypeTemplate ____
+rtl::Reference< Diagram > ChartTypeTemplate::createDiagramByDataSource2(
const uno::Reference< data::XDataSource >& xDataSource,
const uno::Sequence< beans::PropertyValue >& aArguments )
{
- Reference< XDiagram > xDia;
+ rtl::Reference< Diagram > xDia;
try
{
// create diagram
- xDia.set(
- GetComponentContext()->getServiceManager()->createInstanceWithContext(
- "com.sun.star.chart2.Diagram",
- GetComponentContext() ),
- uno::UNO_QUERY_THROW );
+ xDia = new Diagram(GetComponentContext());
// modify diagram
- Reference< chart2::XDataInterpreter > xInterpreter( getDataInterpreter());
- chart2::InterpretedData aData(
+ rtl::Reference< DataInterpreter > xInterpreter( getDataInterpreter2());
+ InterpretedData aData(
xInterpreter->interpretDataSource(
- xDataSource, aArguments, Sequence< Reference< XDataSeries > >() ));
+ xDataSource, aArguments, {} ));
- const Sequence< Sequence< Reference< XDataSeries > > > aSeries( aData.Series );
sal_Int32 nCount = 0;
- for( auto const & i : aSeries )
+ for( auto const & i : aData.Series )
for( auto const & j : i )
lcl_applyDefaultStyle( j, nCount++, xDia );
- Sequence< Reference< XChartType > > aOldChartTypesSeq;
+ std::vector< rtl::Reference< ChartType > > aOldChartTypesSeq;
FillDiagram( xDia, aData.Series, aData.Categories, aOldChartTypesSeq );
}
catch( const uno::Exception & )
@@ -177,23 +176,23 @@ sal_Bool SAL_CALL ChartTypeTemplate::supportsCategories()
return true;
}
-void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >& xDiagram )
+void ChartTypeTemplate::changeDiagram( const rtl::Reference< Diagram >& xDiagram )
{
if( ! xDiagram.is())
return;
try
{
- Sequence< Sequence< Reference< XDataSeries > > > aSeriesSeq(
- DiagramHelper::getDataSeriesGroups( xDiagram ));
- Sequence< Reference< XDataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq ));
- const sal_Int32 nFormerSeriesCount = aFlatSeriesSeq.getLength();
+ std::vector< std::vector< rtl::Reference< DataSeries > > > aSeriesSeq =
+ xDiagram->getDataSeriesGroups();
+ std::vector< rtl::Reference< DataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq ));
+ const sal_Int32 nFormerSeriesCount = aFlatSeriesSeq.size();
// chart-type specific interpretation of existing data series
- Reference< chart2::XDataInterpreter > xInterpreter( getDataInterpreter());
- chart2::InterpretedData aData;
+ rtl::Reference< DataInterpreter > xInterpreter( getDataInterpreter2());
+ InterpretedData aData;
aData.Series = aSeriesSeq;
- aData.Categories = DiagramHelper::getCategoriesFromDiagram( xDiagram );
+ aData.Categories = xDiagram->getCategories();
if( xInterpreter->isDataCompatible( aData ) )
{
@@ -201,7 +200,7 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >
}
else
{
- Reference< data::XDataSource > xSource( xInterpreter->mergeInterpretedData( aData ));
+ rtl::Reference< DataSource > xSource = DataInterpreter::mergeInterpretedData( aData );
// todo: get a "range-union" from the data provider by calling
// OUString aRange = getRangeRepresentationByData( xSource );
// xSource.set( getDataByRangeRepresentation( aRange, aParam ));
@@ -209,38 +208,29 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >
Sequence< beans::PropertyValue > aParam;
if( aData.Categories.is())
{
- aParam.realloc( 1 );
- aParam[0] = beans::PropertyValue( "HasCategories", -1, uno::Any( true ),
- beans::PropertyState_DIRECT_VALUE );
+ aParam = { beans::PropertyValue( u"HasCategories"_ustr, -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& i : aSeriesSeq)
for( auto const & j : i )
{
if( nIndex >= nFormerSeriesCount )
- lcl_applyDefaultStyle( j, nIndex++, xDiagram );
+ lcl_applyDefaultStyle( j, nIndex, xDiagram );
+ nIndex++;
}
// remove charttype groups from all coordinate systems
- Sequence< Reference< XChartType > > aOldChartTypesSeq(
- DiagramHelper::getChartTypesFromDiagram(xDiagram) );
+ std::vector< rtl::Reference< ChartType > > aOldChartTypesSeq =
+ xDiagram->getChartTypes();
- Reference< XCoordinateSystemContainer > xCoordSysCnt( xDiagram, uno::UNO_QUERY );
- OSL_ASSERT( xCoordSysCnt.is());
- if( xCoordSysCnt.is())
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : xDiagram->getBaseCoordinateSystems() )
{
- const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
- xCoordSysCnt->getCoordinateSystems());
- for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
- {
- Reference< XChartTypeContainer > xContainer( coords, uno::UNO_QUERY );
- if( xContainer.is() )
- xContainer->setChartTypes( Sequence< Reference< XChartType > >() );
- }
+ coords->setChartTypes( Sequence< Reference< XChartType > >() );
}
FillDiagram( xDiagram, aSeriesSeq, aData.Categories, aOldChartTypesSeq );
@@ -251,8 +241,8 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >
}
}
-void SAL_CALL ChartTypeTemplate::changeDiagramData(
- const Reference< chart2::XDiagram >& xDiagram,
+void ChartTypeTemplate::changeDiagramData(
+ const rtl::Reference< Diagram >& xDiagram,
const Reference< chart2::data::XDataSource >& xDataSource,
const Sequence< beans::PropertyValue >& aArguments )
{
@@ -263,37 +253,34 @@ void SAL_CALL ChartTypeTemplate::changeDiagramData(
try
{
// interpret new data and re-use existing series
- Sequence< Reference< XDataSeries > > aFlatSeriesSeq(
- comphelper::containerToSequence( DiagramHelper::getDataSeriesFromDiagram( xDiagram )));
- const sal_Int32 nFormerSeriesCount = aFlatSeriesSeq.getLength();
- Reference< chart2::XDataInterpreter > xInterpreter( getDataInterpreter());
- chart2::InterpretedData aData =
+ std::vector< rtl::Reference< DataSeries > > aFlatSeriesSeq =
+ xDiagram->getDataSeries();
+ const sal_Int32 nFormerSeriesCount = aFlatSeriesSeq.size();
+ rtl::Reference< DataInterpreter > xInterpreter( getDataInterpreter2());
+ InterpretedData aData =
xInterpreter->interpretDataSource( xDataSource, aArguments, aFlatSeriesSeq );
// data series
- Sequence< Sequence< Reference< XDataSeries > > > aSeriesSeq( aData.Series );
-
- sal_Int32 i, j, nIndex = 0;
- for( i=0; i<aSeriesSeq.getLength(); ++i )
- for( j=0; j<aSeriesSeq[i].getLength(); ++j, ++nIndex )
+ sal_Int32 nIndex = 0;
+ for( std::size_t i=0; i<aData.Series.size(); ++i )
+ for( std::size_t j=0; j<aData.Series[i].size(); ++j, ++nIndex )
{
if( nIndex >= nFormerSeriesCount )
{
- lcl_applyDefaultStyle( aSeriesSeq[i][j], nIndex, xDiagram );
- applyStyle( aSeriesSeq[i][j], i, j, aSeriesSeq[i].getLength() );
+ lcl_applyDefaultStyle( aData.Series[i][j], nIndex, xDiagram );
+ applyStyle2( aData.Series[i][j], i, j, aData.Series[i].size() );
}
}
// categories
- DiagramHelper::setCategoriesToDiagram( aData.Categories, xDiagram, true, supportsCategories() );
+ xDiagram->setCategories( aData.Categories, true, supportsCategories() );
- Sequence< Reference< XChartType > > aChartTypes(
- DiagramHelper::getChartTypesFromDiagram( xDiagram ));
- sal_Int32 nMax = std::min( aChartTypes.getLength(), aSeriesSeq.getLength());
- for( i=0; i<nMax; ++i )
+ std::vector< rtl::Reference< ChartType > > aChartTypes =
+ xDiagram->getChartTypes();
+ sal_Int32 nMax = std::min( aChartTypes.size(), aData.Series.size());
+ for( sal_Int32 i=0; i<nMax; ++i )
{
- Reference< XDataSeriesContainer > xDSCnt( aChartTypes[i], uno::UNO_QUERY_THROW );
- xDSCnt->setDataSeries( aSeriesSeq[i] );
+ aChartTypes[i]->setDataSeries( aData.Series[i] );
}
}
catch( const uno::Exception & )
@@ -302,9 +289,9 @@ void SAL_CALL ChartTypeTemplate::changeDiagramData(
}
}
-sal_Bool SAL_CALL ChartTypeTemplate::matchesTemplate(
- const Reference< chart2::XDiagram >& xDiagram,
- sal_Bool /* bAdaptProperties */ )
+bool ChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool /* bAdaptProperties */ )
{
bool bResult = false;
@@ -313,36 +300,30 @@ sal_Bool SAL_CALL ChartTypeTemplate::matchesTemplate(
try
{
- Reference< XCoordinateSystemContainer > xCooSysCnt(
- xDiagram, uno::UNO_QUERY_THROW );
- Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
- xCooSysCnt->getCoordinateSystems());
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > aCooSysSeq(
+ xDiagram->getBaseCoordinateSystems());
// need to have at least one coordinate system
- bResult = aCooSysSeq.hasElements();
+ bResult = !aCooSysSeq.empty();
if( bResult )
{
- Sequence< Reference< XChartType > > aFormerlyUsedChartTypes;
- Reference<XChartType> xOldCT = getChartTypeForNewSeries(aFormerlyUsedChartTypes);
+ std::vector< rtl::Reference< ChartType > > aFormerlyUsedChartTypes;
+ rtl::Reference<ChartType> xOldCT = getChartTypeForNewSeries2(aFormerlyUsedChartTypes);
if (!xOldCT.is())
return false;
const OUString aChartTypeToMatch = xOldCT->getChartType();
const sal_Int32 nDimensionToMatch = getDimension();
- for( sal_Int32 nCooSysIdx=0; bResult && (nCooSysIdx < aCooSysSeq.getLength()); ++nCooSysIdx )
+ for( std::size_t nCooSysIdx=0; bResult && (nCooSysIdx < aCooSysSeq.size()); ++nCooSysIdx )
{
// match dimension
- bResult = bResult && (aCooSysSeq[nCooSysIdx]->getDimension() == nDimensionToMatch);
+ bResult = aCooSysSeq[nCooSysIdx]->getDimension() == nDimensionToMatch;
- Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW );
- Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
- for( sal_Int32 nCTIdx=0; bResult && (nCTIdx < aChartTypeSeq.getLength()); ++nCTIdx )
+ const std::vector< rtl::Reference< ChartType > > & aChartTypeSeq( aCooSysSeq[nCooSysIdx]->getChartTypes2());
+ for( std::size_t nCTIdx=0; bResult && (nCTIdx < aChartTypeSeq.size()); ++nCTIdx )
{
- if (!aChartTypeSeq[nCTIdx].is())
- return false;
-
// match chart type
- bResult = bResult && aChartTypeSeq[nCTIdx]->getChartType() == aChartTypeToMatch;
+ bResult = aChartTypeSeq[nCTIdx]->getChartType() == aChartTypeToMatch;
bool bFound=false;
bool bAmbiguous=false;
// match stacking mode
@@ -363,7 +344,7 @@ sal_Bool SAL_CALL ChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< chart2::XDataInterpreter > SAL_CALL ChartTypeTemplate::getDataInterpreter()
+rtl::Reference< DataInterpreter > ChartTypeTemplate::getDataInterpreter2()
{
if( ! m_xDataInterpreter.is())
m_xDataInterpreter.set( new DataInterpreter );
@@ -371,15 +352,14 @@ Reference< chart2::XDataInterpreter > SAL_CALL ChartTypeTemplate::getDataInterpr
return m_xDataInterpreter;
}
-void SAL_CALL ChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void ChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 /* nSeriesIndex */,
::sal_Int32 /* nSeriesCount */ )
{
// sset stacking mode
- Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
- if( !xSeriesProp.is())
+ if( !xSeries.is())
return;
try
@@ -392,16 +372,17 @@ void SAL_CALL ChartTypeTemplate::applyStyle(
: (eStackMode == StackMode::ZStacked )
? chart2::StackingDirection_Z_STACKING
: chart2::StackingDirection_NO_STACKING );
- xSeriesProp->setPropertyValue( "StackingDirection", aPropValue );
+ xSeries->setPropertyValue( u"StackingDirection"_ustr, aPropValue );
//ensure valid label placement
{
uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements(
getChartTypeForIndex( nChartTypeIndex ), isSwapXAndY(), xSeries ) );
- lcl_ensureCorrectLabelPlacement( xSeriesProp, aAvailablePlacements );
+ lcl_ensureCorrectLabelPlacement( xSeries, aAvailablePlacements );
uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- if( xSeriesProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
+ // "AttributedDataPoints"
+ if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList )
for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
lcl_ensureCorrectLabelPlacement( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]), aAvailablePlacements );
}
@@ -412,88 +393,63 @@ void SAL_CALL ChartTypeTemplate::applyStyle(
}
}
-void ChartTypeTemplate::applyStyles( const Reference< chart2::XDiagram >& xDiagram )
+void ChartTypeTemplate::applyStyles( const rtl::Reference< ::chart::Diagram >& xDiagram )
{
// apply chart-type specific styles, like "symbols on" for example
- Sequence< Sequence< Reference< XDataSeries > > > aNewSeriesSeq(
- DiagramHelper::getDataSeriesGroups( xDiagram ));
- for( sal_Int32 i=0; i<aNewSeriesSeq.getLength(); ++i )
+ std::vector< std::vector< rtl::Reference< DataSeries > > > aNewSeriesSeq(
+ xDiagram->getDataSeriesGroups());
+ for( std::size_t i=0; i<aNewSeriesSeq.size(); ++i )
{
- const sal_Int32 nNumSeries = aNewSeriesSeq[i].getLength();
+ const sal_Int32 nNumSeries = aNewSeriesSeq[i].size();
for( sal_Int32 j=0; j<nNumSeries; ++j )
- applyStyle( aNewSeriesSeq[i][j], i, j, nNumSeries );
+ applyStyle2( aNewSeriesSeq[i][j], i, j, nNumSeries );
}
//ensure valid empty cell handling (for first chart type...)
lcl_ensureCorrectMissingValueTreatment( xDiagram, getChartTypeForIndex( 0 ) );
}
-void SAL_CALL ChartTypeTemplate::resetStyles( const Reference< chart2::XDiagram >& xDiagram )
+void ChartTypeTemplate::resetStyles2( const rtl::Reference< ::chart::Diagram >& xDiagram )
{
// reset number format if we had percent stacking on
bool bPercent = (getStackMode(0) == StackMode::YStackedPercent);
if( bPercent )
{
- const Sequence< Reference< chart2::XAxis > > aAxisSeq( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
- for( Reference< chart2::XAxis > const & axis : aAxisSeq )
+ const std::vector< rtl::Reference< Axis > > aAxisSeq( AxisHelper::getAllAxesOfDiagram( xDiagram ) );
+ for( rtl::Reference< Axis > const & axis : aAxisSeq )
{
if( AxisHelper::getDimensionIndexOfAxis( axis, xDiagram )== 1 )
{
- Reference< beans::XPropertySet > xAxisProp( axis, uno::UNO_QUERY );
- if( xAxisProp.is())
- {
- // set number format to source format
- xAxisProp->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(true));
- xAxisProp->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any());
- }
+ // set number format to source format
+ axis->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(true));
+ axis->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any());
}
}
}
//reset label placement if default
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : xDiagram->getBaseCoordinateSystems() )
{
- uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
- if( xCooSysContainer.is() )
+ //iterate through all chart types in the current coordinate system
+ for( rtl::Reference< ChartType > const & xChartType : xCooSys->getChartTypes2() )
{
- const uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
- for( uno::Reference< XCoordinateSystem > const & xCooSys : aCooSysList )
+ //iterate through all series in this chart type
+ for( rtl::Reference< DataSeries > const & xSeries : xChartType->getDataSeries2() )
{
- //iterate through all chart types in the current coordinate system
- uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
- OSL_ASSERT( xChartTypeContainer.is());
- if( !xChartTypeContainer.is() )
+ uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements(
+ xChartType, isSwapXAndY(), xSeries ) );
+ if(!aAvailablePlacements.hasElements())
continue;
- const uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
- for( uno::Reference< XChartType > const & xChartType : aChartTypeList )
- {
- //iterate through all series in this chart type
- uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
- OSL_ASSERT( xDataSeriesContainer.is());
- if( !xDataSeriesContainer.is() )
- continue;
-
- const uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() );
- for( Reference< XDataSeries > const & xSeries : aSeriesList )
- {
- Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
- if(!xSeries.is() || !xSeriesProp.is() )
- continue;
-
- uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements(
- xChartType, isSwapXAndY(), xSeries ) );
- if(!aAvailablePlacements.hasElements())
- continue;
- sal_Int32 nDefaultPlacement = aAvailablePlacements[0];
+ sal_Int32 nDefaultPlacement = aAvailablePlacements[0];
- lcl_resetLabelPlacementIfDefault( xSeriesProp, nDefaultPlacement );
+ lcl_resetLabelPlacementIfDefault( xSeries, nDefaultPlacement );
- uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- if( xSeriesProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
- for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
- lcl_resetLabelPlacementIfDefault( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]), nDefaultPlacement );
- }
- }
+ uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
+ // "AttributedDataPoints"
+ if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList )
+ for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
+ lcl_resetLabelPlacementIfDefault( xSeries->getDataPointByIndex(aAttributedDataPointIndexList[nN]), nDefaultPlacement );
}
}
}
@@ -522,48 +478,45 @@ bool ChartTypeTemplate::isSwapXAndY() const
}
void ChartTypeTemplate::createCoordinateSystems(
- const Reference< chart2::XCoordinateSystemContainer > & xOutCooSysCnt )
+ const rtl::Reference< ::chart::Diagram > & xDiagram )
{
- if( ! xOutCooSysCnt.is())
+ if( ! xDiagram.is())
return;
- Sequence< Reference< XChartType > > aFormerlyUsedChartTypes;
- Reference< XChartType > xChartType( getChartTypeForNewSeries(aFormerlyUsedChartTypes));
+ std::vector< rtl::Reference< ChartType > > aFormerlyUsedChartTypes;
+ rtl::Reference< ChartType > xChartType( getChartTypeForNewSeries2(aFormerlyUsedChartTypes));
if( ! xChartType.is())
return;
- Reference< XCoordinateSystem > xCooSys( xChartType->createCoordinateSystem( getDimension()));
+ rtl::Reference< BaseCoordinateSystem > xCooSys = xChartType->createCoordinateSystem2( getDimension());
if( ! xCooSys.is())
{
// chart type wants no coordinate systems
- xOutCooSysCnt->setCoordinateSystems( Sequence< Reference< XCoordinateSystem > >());
+ xDiagram->setCoordinateSystems( Sequence< Reference< XCoordinateSystem > >());
return;
}
// #i69680# make grid of first y-axis visible (was in the CooSys CTOR before)
if( xCooSys->getDimension() >= 2 )
{
- Reference< chart2::XAxis > xAxis( xCooSys->getAxisByDimension( 1, 0 ));
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2( 1, 0 );
if( xAxis.is())
- AxisHelper::makeGridVisible( xAxis->getGridProperties() );
+ AxisHelper::makeGridVisible( xAxis->getGridProperties2() );
}
- Sequence< Reference< XCoordinateSystem > > aCoordinateSystems(
- xOutCooSysCnt->getCoordinateSystems());
+ std::vector< rtl::Reference< BaseCoordinateSystem > > aCoordinateSystems(
+ xDiagram->getBaseCoordinateSystems());
- if( aCoordinateSystems.hasElements())
+ if( !aCoordinateSystems.empty() )
{
bool bOk = true;
- for( sal_Int32 i=0; bOk && i<aCoordinateSystems.getLength(); ++i )
- bOk = bOk && ( xCooSys->getCoordinateSystemType() == aCoordinateSystems[i]->getCoordinateSystemType() &&
+ for( std::size_t i=0; bOk && i<aCoordinateSystems.size(); ++i )
+ 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] );
+ //copy as much info from former coordinate system as possible:
+ const rtl::Reference< BaseCoordinateSystem >& xOldCooSys( aCoordinateSystems[0] );
sal_Int32 nMaxDimensionCount = std::min( xCooSys->getDimension(), xOldCooSys->getDimension() );
for(sal_Int32 nDimensionIndex=0; nDimensionIndex<nMaxDimensionCount; nDimensionIndex++)
@@ -571,7 +524,7 @@ void ChartTypeTemplate::createCoordinateSystems(
const sal_Int32 nMaximumAxisIndex = xOldCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
for(sal_Int32 nAxisIndex=0; nAxisIndex<=nMaximumAxisIndex; ++nAxisIndex)
{
- uno::Reference< XAxis > xAxis( xOldCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) );
+ rtl::Reference< Axis > xAxis = xOldCooSys->getAxisByDimension2( nDimensionIndex, nAxisIndex );
if( xAxis.is())
{
xCooSys->setAxisByDimension( nDimensionIndex, xAxis, nAxisIndex );
@@ -581,25 +534,21 @@ void ChartTypeTemplate::createCoordinateSystems(
}
// set new coordinate systems
- aCoordinateSystems.realloc( 1 );
- aCoordinateSystems[0] = xCooSys;
+ aCoordinateSystems = { xCooSys };
- xOutCooSysCnt->setCoordinateSystems( aCoordinateSystems );
+ xDiagram->setCoordinateSystems( aCoordinateSystems );
}
void ChartTypeTemplate::adaptScales(
- const Sequence< Reference< chart2::XCoordinateSystem > > & aCooSysSeq,
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & aCooSysSeq,
const Reference< data::XLabeledDataSequence > & xCategories //@todo: in future there may be more than one sequence of categories (e.g. charttype with categories at x and y axis )
)
{
bool bSupportsCategories( supportsCategories() );
- for( Reference< XCoordinateSystem > const & xCooSys : aCooSysSeq )
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : aCooSysSeq )
{
try
{
- if( !xCooSys.is() )
- continue;
-
// attach categories to first axis
sal_Int32 nDim( xCooSys->getDimension());
if( nDim > 0 )
@@ -608,19 +557,26 @@ void ChartTypeTemplate::adaptScales(
const sal_Int32 nMaxIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionX);
for(sal_Int32 nI=0; nI<=nMaxIndex; ++nI)
{
- Reference< XAxis > xAxis( xCooSys->getAxisByDimension(nDimensionX,nI) );
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2(nDimensionX,nI);
if( xAxis.is())
{
ScaleData aData( xAxis->getScaleData() );
aData.Categories = xCategories;
if(bSupportsCategories)
{
- Reference< XChartType > xChartType(getChartTypeForNewSeries(Sequence< Reference< XChartType > >()));
+ rtl::Reference< ChartType > xChartType = getChartTypeForNewSeries2({});
if( aData.AxisType == AxisType::CATEGORY )
{
- aData.ShiftedCategoryPosition = m_aServiceName.indexOf("Column") != -1 || m_aServiceName.indexOf("Bar") != -1 || m_aServiceName.endsWith("Close");
+ // Shift for Column, Hi-Lo-Close, and regular
+ // Bar types, but not BarOfPie
+ aData.ShiftedCategoryPosition =
+ m_aServiceName.indexOf("Column") != -1 ||
+ m_aServiceName.indexOf("Histogram") != -1 ||
+ (m_aServiceName.indexOf("Bar") != -1 &&
+ !m_aServiceName.indexOf("BarOfPie")) ||
+ m_aServiceName.endsWith("Close");
}
- bool bSupportsDates = ::chart::ChartTypeHelper::isSupportingDateAxis( xChartType, nDimensionX );
+ bool bSupportsDates = xChartType.is() ? xChartType->isSupportingDateAxis(nDimensionX) : true;
if( aData.AxisType != AxisType::CATEGORY && ( aData.AxisType != AxisType::DATE || !bSupportsDates) )
{
aData.AxisType = AxisType::CATEGORY;
@@ -641,7 +597,7 @@ void ChartTypeTemplate::adaptScales(
const sal_Int32 nMaxIndex = xCooSys->getMaximumAxisIndexByDimension(1);
for(sal_Int32 nI=0; nI<=nMaxIndex; ++nI)
{
- Reference< chart2::XAxis > xAxis( xCooSys->getAxisByDimension( 1,nI ));
+ rtl::Reference< Axis > xAxis = xCooSys->getAxisByDimension2( 1,nI );
if( xAxis.is())
{
bool bPercent = (getStackMode(0) == StackMode::YStackedPercent);
@@ -666,18 +622,18 @@ void ChartTypeTemplate::adaptScales(
}
}
-void ChartTypeTemplate::adaptDiagram( const Reference< XDiagram > & /* xDiagram */ )
+void ChartTypeTemplate::adaptDiagram( const rtl::Reference< ::chart::Diagram > & /* xDiagram */ )
{
- }
+}
void ChartTypeTemplate::createAxes(
- const Sequence< Reference< XCoordinateSystem > > & rCoordSys )
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys )
{
//create missing axes
- if( !rCoordSys.hasElements() )
+ if( rCoordSys.empty() )
return;
- Reference< XCoordinateSystem > xCooSys( rCoordSys[0] );
+ const rtl::Reference< BaseCoordinateSystem >& xCooSys( rCoordSys[0] );
if(!xCooSys.is())
return;
@@ -692,26 +648,26 @@ void ChartTypeTemplate::createAxes(
nAxisCount = 2;
for( sal_Int32 nAxisIndex = 0; nAxisIndex < nAxisCount; ++nAxisIndex )
{
- Reference< XAxis > xAxis = AxisHelper::getAxis( nDim, nAxisIndex, xCooSys );
+ rtl::Reference< Axis > xAxis = AxisHelper::getAxis( nDim, nAxisIndex, xCooSys );
if( !xAxis.is())
{
// create and add axis
- xAxis.set( AxisHelper::createAxis(
- nDim, nAxisIndex, xCooSys, GetComponentContext() ));
+ xAxis = AxisHelper::createAxis(
+ nDim, nAxisIndex, xCooSys, GetComponentContext() );
}
}
}
}
void ChartTypeTemplate::adaptAxes(
- const Sequence< Reference< XCoordinateSystem > > & rCoordSys )
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys )
{
//adapt properties of existing axes and remove superfluous axes
- if( !rCoordSys.hasElements() )
+ if( rCoordSys.empty() )
return;
- for( Reference< XCoordinateSystem > const & xCooSys : rCoordSys )
+ for( rtl::Reference< BaseCoordinateSystem > const & xCooSys : rCoordSys )
{
if( !xCooSys.is() )
continue;
@@ -721,7 +677,7 @@ void ChartTypeTemplate::adaptAxes(
sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension( nDim );
for( sal_Int32 nAxisIndex=0; nAxisIndex<=nMaxAxisIndex; nAxisIndex++ )
{
- Reference< XAxis > xAxis( AxisHelper::getAxis( nDim, nAxisIndex, xCooSys ) );
+ rtl::Reference< Axis > xAxis = AxisHelper::getAxis( nDim, nAxisIndex, xCooSys );
if( !xAxis.is() )
continue;
@@ -731,13 +687,9 @@ void ChartTypeTemplate::adaptAxes(
bool bPercent = (getStackMode(0) == StackMode::YStackedPercent);
if( bPercent && nDim == 1 )
{
- Reference< beans::XPropertySet > xAxisProp( xAxis, uno::UNO_QUERY );
- if( xAxisProp.is())
- {
- // set number format to source format
- xAxisProp->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(true));
- xAxisProp->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any());
- }
+ // set number format to source format
+ xAxis->setPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT, uno::Any(true));
+ xAxis->setPropertyValue(CHART_UNONAME_NUMFMT, uno::Any());
}
}
}
@@ -751,19 +703,18 @@ sal_Int32 ChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension )
}
void ChartTypeTemplate::FillDiagram(
- const Reference< XDiagram >& xDiagram,
- const Sequence< Sequence< Reference< XDataSeries > > >& aSeriesSeq,
- const Reference< data::XLabeledDataSequence >& xCategories,
- const Sequence< Reference< XChartType > >& aOldChartTypesSeq )
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ const std::vector< std::vector< rtl::Reference< DataSeries > > >& aSeriesSeq,
+ const uno::Reference< chart2::data::XLabeledDataSequence >& xCategories,
+ const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq )
{
adaptDiagram( xDiagram );
try
{
// create coordinate systems and scales
- Reference< XCoordinateSystemContainer > xCoordSysCnt( xDiagram, uno::UNO_QUERY_THROW );
- createCoordinateSystems( xCoordSysCnt );
- Sequence< Reference< XCoordinateSystem > > aCoordinateSystems( xCoordSysCnt->getCoordinateSystems());
+ createCoordinateSystems( xDiagram );
+ std::vector< rtl::Reference< BaseCoordinateSystem > > aCoordinateSystems( xDiagram->getBaseCoordinateSystems());
createAxes( aCoordinateSystems );
adaptAxes( aCoordinateSystems );
adaptScales( aCoordinateSystems, xCategories );
@@ -779,65 +730,57 @@ void ChartTypeTemplate::FillDiagram(
}
void ChartTypeTemplate::createChartTypes(
- const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq,
- const Sequence< Reference< XCoordinateSystem > > & rCoordSys,
- const Sequence< Reference< XChartType > >& aOldChartTypesSeq )
+ const std::vector< std::vector< rtl::Reference< DataSeries > > > & aSeriesSeq,
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq )
{
- if( ! rCoordSys.hasElements() ||
- ! rCoordSys[0].is() )
+ if( rCoordSys.empty() )
return;
try
{
- sal_Int32 nCooSysIdx=0;
- Reference< XChartType > xCT;
- if( !aSeriesSeq.hasElements() )
+ std::size_t nCooSysIdx=0;
+ rtl::Reference< ChartType > xCT;
+ if( aSeriesSeq.empty() )
{
// we need a new chart type
- xCT.set( getChartTypeForNewSeries( aOldChartTypesSeq ));
- Reference< XChartTypeContainer > xCTCnt( rCoordSys[nCooSysIdx], uno::UNO_QUERY_THROW );
- Sequence< Reference< XChartType > > aCTSeq( xCTCnt->getChartTypes());
- aCTSeq.realloc( 1 );
- aCTSeq[0] = xCT;
- xCTCnt->setChartTypes( aCTSeq );
+ xCT = getChartTypeForNewSeries2( aOldChartTypesSeq );
+ rCoordSys[nCooSysIdx]->setChartTypes(std::vector{ xCT });
}
else
{
- for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx )
+ for( std::size_t nSeriesIdx=0; nSeriesIdx<aSeriesSeq.size(); ++nSeriesIdx )
{
if( nSeriesIdx == nCooSysIdx )
{
// we need a new chart type
- xCT.set( getChartTypeForNewSeries( aOldChartTypesSeq ));
- Reference< XChartTypeContainer > xCTCnt( rCoordSys[nCooSysIdx], uno::UNO_QUERY_THROW );
- Sequence< Reference< XChartType > > aCTSeq( xCTCnt->getChartTypes());
- if( aCTSeq.hasElements())
+ xCT = getChartTypeForNewSeries2( aOldChartTypesSeq );
+ std::vector< rtl::Reference< ChartType > > aCTSeq( rCoordSys[nCooSysIdx]->getChartTypes2());
+ if( !aCTSeq.empty())
{
aCTSeq[0] = xCT;
- xCTCnt->setChartTypes( aCTSeq );
+ rCoordSys[nCooSysIdx]->setChartTypes( aCTSeq );
}
else
- xCTCnt->addChartType( xCT );
+ rCoordSys[nCooSysIdx]->addChartType( xCT );
- Reference< chart2::XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- xDSCnt->setDataSeries( aSeriesSeq[nSeriesIdx] );
+ xCT->setDataSeries( aSeriesSeq[nSeriesIdx] );
}
else
{
// reuse existing chart type
OSL_ASSERT( xCT.is());
- Reference< chart2::XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- Sequence< Reference< XDataSeries > > aNewSeriesSeq( xDSCnt->getDataSeries());
- sal_Int32 nNewStartIndex = aNewSeriesSeq.getLength();
- aNewSeriesSeq.realloc( nNewStartIndex + aSeriesSeq[nSeriesIdx].getLength() );
+ std::vector< rtl::Reference< DataSeries > > aNewSeriesSeq = xCT->getDataSeries2();
+ sal_Int32 nNewStartIndex = aNewSeriesSeq.size();
+ aNewSeriesSeq.resize( nNewStartIndex + aSeriesSeq[nSeriesIdx].size() );
std::copy( aSeriesSeq[nSeriesIdx].begin(),
aSeriesSeq[nSeriesIdx].end(),
- aNewSeriesSeq.getArray() + nNewStartIndex );
- xDSCnt->setDataSeries( aNewSeriesSeq );
+ aNewSeriesSeq.begin() + nNewStartIndex );
+ xCT->setDataSeries( aNewSeriesSeq );
}
// spread the series over the available coordinate systems
- if( rCoordSys.getLength() > (nCooSysIdx + 1) )
+ if( rCoordSys.size() > (nCooSysIdx + 1) )
++nCooSysIdx;
}
}
@@ -849,27 +792,77 @@ void ChartTypeTemplate::createChartTypes(
}
void ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(
- const Sequence< Reference< XChartType > > & rOldChartTypesSeq,
- const Reference< XChartType > & xNewChartType )
+ const std::vector< rtl::Reference< ChartType > > & rOldChartTypesSeq,
+ const rtl::Reference< ChartType > & xNewChartType )
{
- Reference< beans::XPropertySet > xDestination( xNewChartType, uno::UNO_QUERY );
- if( !xDestination.is() )
+ if( !xNewChartType.is() )
return;
OUString aNewChartType( xNewChartType->getChartType() );
- Reference< beans::XPropertySet > xSource;
- for( Reference< XChartType > const & xOldType : rOldChartTypesSeq )
+ rtl::Reference< ChartType > xSource;
+ for( rtl::Reference< ChartType > const & xOldType : rOldChartTypesSeq )
{
if( xOldType.is() && xOldType->getChartType() == aNewChartType )
{
- xSource.set( Reference< beans::XPropertySet >(xOldType, uno::UNO_QUERY ) );
+ xSource = xOldType;
if( xSource.is() )
break;
}
}
if( xSource.is() )
- comphelper::copyProperties( xSource, xDestination );
+ comphelper::copyProperties( xSource, xNewChartType );
+}
+
+css::uno::Reference< css::uno::XInterface > ChartTypeTemplate::getDataInterpreter()
+{
+ return static_cast<cppu::OWeakObject*>(getDataInterpreter2().get());
+}
+css::uno::Reference< css::chart2::XDiagram > ChartTypeTemplate::createDiagramByDataSource(
+ const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource,
+ const css::uno::Sequence< css::beans::PropertyValue >& aArguments )
+{
+ return createDiagramByDataSource2(xDataSource, aArguments);
+}
+void ChartTypeTemplate::changeDiagram(
+ const css::uno::Reference< css::chart2::XDiagram >& xDiagram )
+{
+ changeDiagram(rtl::Reference<Diagram>(dynamic_cast<Diagram*>(xDiagram.get())));
+}
+void ChartTypeTemplate::changeDiagramData(
+ const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
+ const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource,
+ const css::uno::Sequence< css::beans::PropertyValue >& aArguments )
+{
+ changeDiagramData(rtl::Reference<Diagram>(dynamic_cast<Diagram*>(xDiagram.get())), xDataSource, aArguments);
+}
+sal_Bool ChartTypeTemplate::matchesTemplate(
+ const css::uno::Reference<css::chart2::XDiagram >& xDiagram,
+ sal_Bool bAdaptProperties )
+{
+ return matchesTemplate2(dynamic_cast<Diagram*>(xDiagram.get()), static_cast<bool>(bAdaptProperties));
+}
+css::uno::Reference< ::css::chart2::XChartType > ChartTypeTemplate::getChartTypeForNewSeries(
+ const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes )
+{
+ std::vector< rtl::Reference< ::chart::ChartType > > aTmp;
+ aTmp.reserve(aFormerlyUsedChartTypes.getLength());
+ for (auto const & rxChartType : aFormerlyUsedChartTypes)
+ aTmp.push_back(dynamic_cast<ChartType*>(rxChartType.get()));
+ return getChartTypeForNewSeries2(aTmp);
+}
+void ChartTypeTemplate::applyStyle(
+ const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ ::sal_Int32 nChartTypeIndex,
+ ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount )
+{
+ applyStyle2(dynamic_cast<DataSeries*>(xSeries.get()), nChartTypeIndex, nSeriesIndex, nSeriesCount);
+}
+void ChartTypeTemplate::resetStyles(
+ const css::uno::Reference< css::chart2::XDiagram >& xDiagram )
+{
+ resetStyles2(dynamic_cast<Diagram*>(xDiagram.get()));
}
} // namespace chart
diff --git a/chart2/source/model/template/ChartTypeTemplate.hxx b/chart2/source/model/template/ChartTypeTemplate.hxx
deleted file mode 100644
index 0fe236ce1eb8..000000000000
--- a/chart2/source/model/template/ChartTypeTemplate.hxx
+++ /dev/null
@@ -1,256 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#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
index 4c95b1c1b0b8..378ed35e59d7 100644
--- a/chart2/source/model/template/ColumnChartType.cxx
+++ b/chart2/source/model/template/ColumnChartType.cxx
@@ -54,69 +54,19 @@ void lcl_AddPropertiesToVector(
| beans::PropertyAttribute::MAYBEDEFAULT );
}
-struct StaticColumnChartTypeDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- Sequence< sal_Int32 > aSeq(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 & StaticColumnChartTypeInfoHelper()
{
- ::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 );
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
+ {
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-};
-
-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 >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
} // anonymous namespace
@@ -141,6 +91,11 @@ uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone()
return uno::Reference< util::XCloneable >( new ColumnChartType( *this ));
}
+rtl::Reference< ChartType > ColumnChartType::cloneChartType() const
+{
+ return new ColumnChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL ColumnChartType::getChartType()
{
@@ -149,37 +104,44 @@ OUString SAL_CALL ColumnChartType::getChartType()
uno::Sequence< OUString > ColumnChartType::getSupportedPropertyRoles()
{
- uno::Sequence< OUString > aPropRoles(2);
- aPropRoles[0] = "FillColor";
- aPropRoles[1] = "BorderColor";
-
- return aPropRoles;
+ return { u"FillColor"_ustr, u"BorderColor"_ustr };
}
// ____ OPropertySet ____
-uno::Any ColumnChartType::GetDefaultValue( sal_Int32 nHandle ) const
-{
- const tPropertyValueMap& rStaticDefaults = *StaticColumnChartTypeDefaults::get();
- tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
- if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+void ColumnChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
+{
+ static const ::chart::tPropertyValueMap aStaticDefaults = []()
+ {
+ ::chart::tPropertyValueMap aTmp;
+ Sequence< sal_Int32 > aSeq{ 0, 0 };
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq );
+ aSeq = { 100, 100 };
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq );
+ return aTmp;
+ }();
+ tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) );
+ if( aFound == aStaticDefaults.end() )
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL ColumnChartType::getInfoHelper()
{
- return *StaticColumnChartTypeInfoHelper::get();
+ return StaticColumnChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnChartType::getPropertySetInfo()
{
- return *StaticColumnChartTypeInfo::get();
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticColumnChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
}
OUString SAL_CALL ColumnChartType::getImplementationName()
{
- return "com.sun.star.comp.chart.ColumnChartType";
+ return u"com.sun.star.comp.chart.ColumnChartType"_ustr;
}
sal_Bool SAL_CALL ColumnChartType::supportsService( const OUString& rServiceName )
@@ -191,7 +153,7 @@ css::uno::Sequence< OUString > SAL_CALL ColumnChartType::getSupportedServiceName
{
return {
CHART2_SERVICE_NAME_CHARTTYPE_COLUMN,
- "com.sun.star.chart2.ChartType" };
+ u"com.sun.star.chart2.ChartType"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/template/ColumnChartType.hxx b/chart2/source/model/template/ColumnChartType.hxx
index d7b879479bf6..2c6b3d762321 100644
--- a/chart2/source/model/template/ColumnChartType.hxx
+++ b/chart2/source/model/template/ColumnChartType.hxx
@@ -16,10 +16,9 @@
* 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
+#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -37,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit ColumnChartType( const ColumnChartType & rOther );
@@ -46,7 +47,7 @@ private:
getSupportedPropertyRoles() override;
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
@@ -59,7 +60,4 @@ private:
} // 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
index 560332b81e98..d45ca516af2c 100644
--- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx
@@ -18,24 +18,24 @@
*/
#include "ColumnLineChartTypeTemplate.hxx"
+#include "ColumnChartType.hxx"
+#include "LineChartType.hxx"
#include <CommonConverters.hxx>
+#include <BaseCoordinateSystem.hxx>
+#include <Diagram.hxx>
#include <DiagramHelper.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <servicenames_charttypes.hxx>
#include "ColumnLineDataInterpreter.hxx"
#include <PropertyHelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
-using namespace ::com::sun::star::chart2;
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
@@ -50,69 +50,44 @@ enum
PROP_COL_LINE_NUMBER_OF_LINES
};
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+::chart::tPropertyValueMap& StaticColumnLineChartTypeTemplateDefaults()
{
- rOutProperties.emplace_back( "NumberOfLines",
- PROP_COL_LINE_NUMBER_OF_LINES,
- cppu::UnoType<sal_Int32>::get(),
- beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ []()
+ {
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_COL_LINE_NUMBER_OF_LINES, 1 );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
}
-struct StaticColumnLineChartTypeTemplateDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aStaticDefaults, PROP_COL_LINE_NUMBER_OF_LINES, 1 );
- return &aStaticDefaults;
- }
-};
-
-struct StaticColumnLineChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticColumnLineChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticColumnLineChartTypeTemplateInfoHelper_Initializer
+::cppu::OPropertyArrayHelper& StaticColumnLineChartTypeTemplateInfoHelper()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static uno::Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { u"NumberOfLines"_ustr,
+ PROP_COL_LINE_NUMBER_OF_LINES,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT } };
-struct StaticColumnLineChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticColumnLineChartTypeTemplateInfoHelper_Initializer >
-{
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticColumnLineChartTypeTemplateInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnLineChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ return comphelper::containerToSequence( aProperties );
+ }());
+ return aPropHelper;
+}
-struct StaticColumnLineChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnLineChartTypeTemplateInfo_Initializer >
+uno::Reference< beans::XPropertySetInfo >& StaticColumnLineChartTypeTemplateInfo()
{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticColumnLineChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -126,7 +101,6 @@ ColumnLineChartTypeTemplate::ColumnLineChartTypeTemplate(
StackMode eStackMode,
sal_Int32 nNumberOfLines ) :
ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex ),
m_eStackMode( eStackMode )
{
setFastPropertyValue_NoBroadcast( PROP_COL_LINE_NUMBER_OF_LINES, uno::Any( nNumberOfLines ));
@@ -136,41 +110,39 @@ ColumnLineChartTypeTemplate::~ColumnLineChartTypeTemplate()
{}
// ____ OPropertySet ____
-uno::Any ColumnLineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void ColumnLineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticColumnLineChartTypeTemplateDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticColumnLineChartTypeTemplateDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL ColumnLineChartTypeTemplate::getInfoHelper()
{
- return *StaticColumnLineChartTypeTemplateInfoHelper::get();
+ return StaticColumnLineChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnLineChartTypeTemplate::getPropertySetInfo()
{
- return *StaticColumnLineChartTypeTemplateInfo::get();
+ return StaticColumnLineChartTypeTemplateInfo();
}
void ColumnLineChartTypeTemplate::createChartTypes(
- const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq,
- const Sequence< Reference< XCoordinateSystem > > & rCoordSys,
- const Sequence< Reference< XChartType > >& aOldChartTypesSeq )
+ const std::vector< std::vector< rtl::Reference< DataSeries > > > & aSeriesSeq,
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > >& aOldChartTypesSeq )
{
- if( ! rCoordSys.hasElements() ||
- ! rCoordSys[0].is() )
+ if( rCoordSys.empty() )
return;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- Sequence< Reference< XDataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq ));
- sal_Int32 nNumberOfSeries = aFlatSeriesSeq.getLength();
+ const std::vector< rtl::Reference< DataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq ));
+ sal_Int32 nNumberOfSeries = aFlatSeriesSeq.size();
sal_Int32 nNumberOfLines = 0;
sal_Int32 nNumberOfColumns = 0;
@@ -194,38 +166,33 @@ void ColumnLineChartTypeTemplate::createChartTypes(
// Columns
- Reference< XChartType > xCT(
- xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY_THROW );
+ rtl::Reference< ChartType > xCT = new ColumnChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aOldChartTypesSeq, xCT );
- Reference< XChartTypeContainer > xCTCnt( rCoordSys[ 0 ], uno::UNO_QUERY_THROW );
- xCTCnt->setChartTypes( Sequence< Reference< chart2::XChartType > >( &xCT, 1 ));
+ rCoordSys[ 0 ]->setChartTypes( std::vector{xCT} );
if( nNumberOfColumns > 0 )
{
- Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- Sequence< Reference< XDataSeries > > aColumnSeq( nNumberOfColumns );
+ std::vector< rtl::Reference< DataSeries > > aColumnSeq( nNumberOfColumns );
std::copy( aFlatSeriesSeq.begin(),
aFlatSeriesSeq.begin() + nNumberOfColumns,
- aColumnSeq.getArray());
- xDSCnt->setDataSeries( aColumnSeq );
+ aColumnSeq.begin());
+ xCT->setDataSeries( aColumnSeq );
}
// Lines
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
- xCTCnt.set( rCoordSys[ 0 ], uno::UNO_QUERY_THROW );
- xCTCnt->addChartType( xCT );
+ xCT = new LineChartType();
+ rCoordSys[ 0 ]->addChartType( xCT );
if( nNumberOfLines > 0 )
{
- Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- Sequence< Reference< XDataSeries > > aLineSeq( nNumberOfLines );
+ std::vector< rtl::Reference< DataSeries > > aLineSeq( nNumberOfLines );
std::copy( aFlatSeriesSeq.begin() + nNumberOfColumns,
aFlatSeriesSeq.end(),
- aLineSeq.getArray());
- xDSCnt->setDataSeries( aLineSeq );
+ aLineSeq.begin());
+ xCT->setDataSeries( aLineSeq );
}
}
catch( const uno::Exception & )
@@ -234,27 +201,23 @@ void ColumnLineChartTypeTemplate::createChartTypes(
}
}
-void SAL_CALL ColumnLineChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void ColumnLineChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
if( nChartTypeIndex==0 ) // columns
{
- DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+ xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, 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 );
- }
+ xSeries->switchLinesOnOrOff( true );
+ xSeries->switchSymbolsOnOrOff( false, nSeriesIndex );
+ xSeries->makeLinesThickOrThin( true );
}
}
@@ -266,9 +229,9 @@ StackMode ColumnLineChartTypeTemplate::getStackMode( sal_Int32 nChartTypeIndex )
}
// ____ XChartTypeTemplate ____
-sal_Bool SAL_CALL ColumnLineChartTypeTemplate::matchesTemplate(
- const uno::Reference< XDiagram >& xDiagram,
- sal_Bool bAdaptProperties )
+bool ColumnLineChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties )
{
bool bResult = false;
@@ -277,35 +240,27 @@ sal_Bool SAL_CALL ColumnLineChartTypeTemplate::matchesTemplate(
try
{
- Reference< chart2::XChartType > xColumnChartType;
- Reference< XCoordinateSystem > xColumnChartCooSys;
- Reference< chart2::XChartType > xLineChartType;
+ rtl::Reference< ChartType > xColumnChartType;
+ rtl::Reference< BaseCoordinateSystem > xColumnChartCooSys;
+ rtl::Reference< ChartType > xLineChartType;
sal_Int32 nNumberOfChartTypes = 0;
- Reference< XCoordinateSystemContainer > xCooSysCnt(
- xDiagram, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
- xCooSysCnt->getCoordinateSystems());
- for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : xDiagram->getBaseCoordinateSystems() )
{
- Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
- for( Reference< XChartType > const & chartType : aChartTypeSeq )
+ const std::vector< rtl::Reference< ChartType > > aChartTypeSeq( coords->getChartTypes2());
+ for( rtl::Reference< ChartType > const & chartType : aChartTypeSeq )
{
- if( chartType.is())
+ ++nNumberOfChartTypes;
+ if( nNumberOfChartTypes > 2 )
+ break;
+ OUString aCTService = chartType->getChartType();
+ if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
{
- ++nNumberOfChartTypes;
- if( nNumberOfChartTypes > 2 )
- break;
- OUString aCTService = chartType->getChartType();
- if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
- {
- xColumnChartType.set( chartType );
- xColumnChartCooSys.set( coords );
- }
- else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
- xLineChartType.set( chartType );
+ xColumnChartType = chartType;
+ xColumnChartCooSys = coords;
}
+ else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
+ xLineChartType = chartType;
}
if( nNumberOfChartTypes > 2 )
break;
@@ -330,10 +285,9 @@ sal_Bool SAL_CALL ColumnLineChartTypeTemplate::matchesTemplate(
if( bResult && bAdaptProperties )
{
- Reference< XDataSeriesContainer > xSeriesContainer( xLineChartType, uno::UNO_QUERY );
- if( xSeriesContainer.is() )
+ if( xLineChartType.is() )
{
- sal_Int32 nNumberOfLines = xSeriesContainer->getDataSeries().getLength();
+ sal_Int32 nNumberOfLines = xLineChartType->getDataSeries().getLength();
setFastPropertyValue_NoBroadcast( PROP_COL_LINE_NUMBER_OF_LINES, uno::Any( nNumberOfLines ));
}
}
@@ -348,32 +302,22 @@ sal_Bool SAL_CALL ColumnLineChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< chart2::XChartType > ColumnLineChartTypeTemplate::getChartTypeForIndex( sal_Int32 nChartTypeIndex )
+rtl::Reference< ChartType > ColumnLineChartTypeTemplate::getChartTypeForIndex( sal_Int32 nChartTypeIndex )
{
- Reference< chart2::XChartType > xCT;
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY );
- if(xFact.is())
- {
- if( nChartTypeIndex == 0 )
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY );
- else
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY );
- }
- return xCT;
+ if( nChartTypeIndex == 0 )
+ return new ColumnChartType();
+ else
+ return new LineChartType();
}
-Reference< XChartType > SAL_CALL ColumnLineChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > ColumnLineChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
+ xResult = new LineChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
}
catch( const uno::Exception & )
@@ -384,13 +328,13 @@ Reference< XChartType > SAL_CALL ColumnLineChartTypeTemplate::getChartTypeForNew
return xResult;
}
-Reference< XDataInterpreter > SAL_CALL ColumnLineChartTypeTemplate::getDataInterpreter()
+rtl::Reference< DataInterpreter > ColumnLineChartTypeTemplate::getDataInterpreter2()
{
if( ! m_xDataInterpreter.is())
{
sal_Int32 nNumberOfLines = 1;
getFastPropertyValue( PROP_COL_LINE_NUMBER_OF_LINES ) >>= nNumberOfLines;
- m_xDataInterpreter.set( new ColumnLineDataInterpreter( nNumberOfLines ) );
+ m_xDataInterpreter = new ColumnLineDataInterpreter( nNumberOfLines );
}
else
{
diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx
index 9f04b633d2b3..68f144d6fedb 100644
--- a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx
+++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx
@@ -16,21 +16,18 @@
* 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
+#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <StackMode.hxx>
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
namespace chart
{
class ColumnLineChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -49,42 +46,40 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence<
- css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ // ____ ChartTypeTemplate ____
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
- virtual css::uno::Reference< css::chart2::XDataInterpreter > SAL_CALL getDataInterpreter() override;
+ virtual rtl::Reference< ::chart::DataInterpreter > getDataInterpreter2() override;
// ____ ChartTypeTemplate ____
virtual void createChartTypes(
- const css::uno::Sequence<
- css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XDataSeries > > > & aSeriesSeq,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XCoordinateSystem > > & rCoordSys,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XChartType > > & aOldChartTypesSeq
+ const std::vector<
+ std::vector<
+ rtl::Reference<
+ ::chart::DataSeries > > > & aSeriesSeq,
+ const std::vector<
+ rtl::Reference<
+ ::chart::BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq
) override;
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
@@ -95,7 +90,4 @@ private:
} // 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
index b99324d27c00..5cce30cd97a0 100644
--- a/chart2/source/model/template/ColumnLineDataInterpreter.cxx
+++ b/chart2/source/model/template/ColumnLineDataInterpreter.cxx
@@ -18,13 +18,13 @@
*/
#include "ColumnLineDataInterpreter.hxx"
+#include <DataSeries.hxx>
#include <osl/diagnose.h>
#include <algorithm>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
-using namespace ::std;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -35,40 +35,39 @@ namespace chart
// explicit
ColumnLineDataInterpreter::ColumnLineDataInterpreter(
sal_Int32 nNumberOfLines ) :
- DataInterpreter(),
m_nNumberOfLines( nNumberOfLines )
{}
ColumnLineDataInterpreter::~ColumnLineDataInterpreter()
{}
-// ____ XDataInterpreter ____
-InterpretedData SAL_CALL ColumnLineDataInterpreter::interpretDataSource(
+// ____ DataInterpreter ____
+InterpretedData ColumnLineDataInterpreter::interpretDataSource(
const Reference< data::XDataSource >& xSource,
const Sequence< beans::PropertyValue >& aArguments,
- const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+ const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
{
InterpretedData aResult( DataInterpreter::interpretDataSource( xSource, aArguments, aSeriesToReUse ));
// the base class should return one group
- OSL_ASSERT( aResult.Series.getLength() == 1 );
- if( aResult.Series.getLength() == 1 )
+ OSL_ASSERT( aResult.Series.size() == 1 );
+ if( aResult.Series.size() == 1 )
{
- sal_Int32 nNumberOfSeries = aResult.Series[0].getLength();
+ sal_Int32 nNumberOfSeries = aResult.Series[0].size();
// if we have more than one series put the last nNumOfLines ones into a new group
if( nNumberOfSeries > 1 && m_nNumberOfLines > 0 )
{
sal_Int32 nNumOfLines = std::min( m_nNumberOfLines, nNumberOfSeries - 1 );
- aResult.Series.realloc(2);
+ aResult.Series.resize(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 );
+ std::vector< rtl::Reference< DataSeries > > & rColumnDataSeries = aResult.Series[0];
+ std::vector< rtl::Reference< DataSeries > > & rLineDataSeries = aResult.Series[1];
+ rLineDataSeries.resize( nNumOfLines );
+ std::copy( std::cbegin(rColumnDataSeries) + nNumberOfSeries - nNumOfLines,
+ std::cbegin(rColumnDataSeries) + nNumberOfSeries,
+ rLineDataSeries.begin() );
+ rColumnDataSeries.resize( nNumberOfSeries - nNumOfLines );
}
}
diff --git a/chart2/source/model/template/ColumnLineDataInterpreter.hxx b/chart2/source/model/template/ColumnLineDataInterpreter.hxx
index e6956db4cd30..c2ec75826007 100644
--- a/chart2/source/model/template/ColumnLineDataInterpreter.hxx
+++ b/chart2/source/model/template/ColumnLineDataInterpreter.hxx
@@ -16,27 +16,24 @@
* 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
+#pragma once
-#include "DataInterpreter.hxx"
+#include <DataInterpreter.hxx>
namespace chart
{
-
class ColumnLineDataInterpreter : public DataInterpreter
{
public:
- explicit ColumnLineDataInterpreter(
- sal_Int32 nNumberOfLines );
+ 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;
+ // ____ DataInterpreter ____
+ virtual InterpretedData interpretDataSource(
+ const css::uno::Reference<css::chart2::data::XDataSource>& xSource,
+ const css::uno::Sequence<css::beans::PropertyValue>& aArguments,
+ const std::vector<rtl::Reference<::chart::DataSeries>>& aSeriesToReUse) override;
private:
sal_Int32 m_nNumberOfLines;
@@ -44,7 +41,4 @@ private:
} // 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
index 7e85e0b36199..0b60c03c2a1f 100644
--- a/chart2/source/model/template/DataInterpreter.cxx
+++ b/chart2/source/model/template/DataInterpreter.cxx
@@ -17,22 +17,20 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "DataInterpreter.hxx"
+#include <DataInterpreter.hxx>
#include <DataSeries.hxx>
-#include <DataSourceHelper.hxx>
+#include <DataSource.hxx>
#include <DataSeriesHelper.hxx>
#include <CommonConverters.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/chart2/data/XDataSink.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
-#include <vector>
#include <algorithm>
+#include <cstddef>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
-using namespace ::std;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -54,10 +52,10 @@ DataInterpreter::~DataInterpreter()
{}
// ____ XDataInterpreter ____
-InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
+InterpretedData DataInterpreter::interpretDataSource(
const Reference< data::XDataSource >& xSource,
const Sequence< beans::PropertyValue >& aArguments,
- const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+ const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
{
if( ! xSource.is())
return InterpretedData();
@@ -66,10 +64,10 @@ InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
lcl_ShowDataSource( xSource );
#endif
- const Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aData = getDataSequences(xSource);
- Reference< data::XLabeledDataSequence > xCategories;
- vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
+ uno::Reference< chart2::data::XLabeledDataSequence > xCategories;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSequencesVec;
// check if we should use categories
@@ -77,22 +75,22 @@ InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
// parse data
bool bCategoriesUsed = false;
- for( Reference< data::XLabeledDataSequence > const & labeledData : aData )
+ for( uno::Reference< chart2::data::XLabeledDataSequence > const & labeledData : aData )
{
try
{
if( bHasCategories && ! bCategoriesUsed )
{
- xCategories.set( labeledData );
+ xCategories = labeledData;
if( xCategories.is())
- SetRole( xCategories->getValues(), "categories");
+ SetRole( xCategories->getValues(), u"categories"_ustr);
bCategoriesUsed = true;
}
else
{
aSequencesVec.push_back( labeledData );
if( labeledData.is())
- SetRole( labeledData->getValues(), "values-y");
+ SetRole( labeledData->getValues(), u"values-y"_ustr);
}
}
catch( const uno::Exception & )
@@ -102,66 +100,60 @@ InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
}
// create DataSeries
- sal_Int32 nSeriesIndex = 0;
- vector< Reference< XDataSeries > > aSeriesVec;
+ std::size_t nSeriesIndex = 0;
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec;
aSeriesVec.reserve( aSequencesVec.size());
for (auto const& elem : aSequencesVec)
{
- Sequence< Reference< data::XLabeledDataSequence > > aNewData( &elem, 1 );
- Reference< XDataSeries > xSeries;
- if( nSeriesIndex < aSeriesToReUse.getLength())
- xSeries.set( aSeriesToReUse[nSeriesIndex] );
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewData { elem };
+ rtl::Reference< DataSeries > xSeries;
+ if( nSeriesIndex < aSeriesToReUse.size())
+ xSeries = aSeriesToReUse[nSeriesIndex];
else
- xSeries.set( new DataSeries );
- OSL_ASSERT( xSeries.is() );
- Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
- OSL_ASSERT( xSink.is() );
- xSink->setData( aNewData );
+ xSeries = new DataSeries;
+ assert( xSeries.is() );
+ xSeries->setData( aNewData );
aSeriesVec.push_back( xSeries );
++nSeriesIndex;
}
- Sequence< Sequence< Reference< XDataSeries > > > aSeries(1);
- aSeries[0] = comphelper::containerToSequence( aSeriesVec );
- return InterpretedData( aSeries, xCategories );
+ return { { std::move(aSeriesVec) }, xCategories };
}
-InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
+InterpretedData DataInterpreter::reinterpretDataSeries(
const InterpretedData& aInterpretedData )
{
InterpretedData aResult( aInterpretedData );
sal_Int32 i=0;
- Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- const sal_Int32 nCount = aSeries.getLength();
+ std::vector< rtl::Reference< DataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ const sal_Int32 nCount = aSeries.size();
for( ; i<nCount; ++i )
{
try
{
- Reference< data::XDataSource > xSeriesSource( aSeries[i], uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aNewSequences;
+ std::vector< uno::Reference< data::XLabeledDataSequence > > aNewSequences;
// values-y
- Reference< data::XLabeledDataSequence > xValuesY(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-y" ));
+ uno::Reference< data::XLabeledDataSequence > xValuesY =
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], u"values-y"_ustr );
// re-use values-... as values-y
if( ! xValuesY.is())
{
- xValuesY.set(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values", true ));
+ xValuesY =
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], u"values"_ustr, true );
if( xValuesY.is())
- SetRole( xValuesY->getValues(), "values-y");
+ SetRole( xValuesY->getValues(), u"values-y"_ustr);
}
if( xValuesY.is())
{
- aNewSequences.realloc(1);
- aNewSequences[0] = xValuesY;
+ aNewSequences = { xValuesY };
}
- Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
- if( aSeqs.getLength() != aNewSequences.getLength() )
+ const std::vector< uno::Reference< data::XLabeledDataSequence > > & aSeqs = aSeries[i]->getDataSequences2();
+ if( aSeqs.size() != aNewSequences.size() )
{
#ifdef DEBUG_CHART2_TEMPLATE
sal_Int32 j=0;
@@ -170,8 +162,7 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
assert( aSeqs[j] == xValuesY && "All sequences should be used" );
}
#endif
- Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
- xSink->setData( aNewSequences );
+ aSeries[i]->setData( aNewSequences );
}
}
catch( const uno::Exception & )
@@ -184,17 +175,15 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
}
// criterion: all series must have exactly one data::XLabeledDataSequence
-sal_Bool SAL_CALL DataInterpreter::isDataCompatible(
- const chart2::InterpretedData& aInterpretedData )
+bool DataInterpreter::isDataCompatible(
+ const InterpretedData& aInterpretedData )
{
- const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- for( Reference< XDataSeries > const & i : aSeries )
+ const std::vector< rtl::Reference< DataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
+ for( rtl::Reference< DataSeries > const & i : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( i, uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
- if( aSeq.getLength() != 1 )
+ if( i->getDataSequences2().size() != 1 )
return false;
}
catch( const uno::Exception & )
@@ -259,27 +248,24 @@ private:
} // anonymous namespace
-Reference< data::XDataSource > SAL_CALL DataInterpreter::mergeInterpretedData(
+rtl::Reference< DataSource > DataInterpreter::mergeInterpretedData(
const InterpretedData& aInterpretedData )
{
- vector< Reference< data::XLabeledDataSequence > > aResultVec;
- aResultVec.reserve( aInterpretedData.Series.getLength() +
+ std::vector< Reference< data::XLabeledDataSequence > > aResultVec;
+ aResultVec.reserve( aInterpretedData.Series.size() +
1 // categories
);
if( aInterpretedData.Categories.is())
aResultVec.push_back( aInterpretedData.Categories );
- const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- for( Reference< XDataSeries > const & dataSeries : aSeries )
+ const std::vector< rtl::Reference< DataSeries > > aSeries = FlattenSequence( aInterpretedData.Series );
+ for( rtl::Reference< DataSeries > const & dataSeries : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
- const Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
-
// add all sequences of data series
- for( Reference< data::XLabeledDataSequence > const & xAdd : aSeq )
+ for( uno::Reference< data::XLabeledDataSequence > const & xAdd : dataSeries->getDataSequences2() )
{
// only add if sequence is not yet in the result
if( none_of( aResultVec.begin(), aResultVec.end(),
@@ -295,7 +281,13 @@ Reference< data::XDataSource > SAL_CALL DataInterpreter::mergeInterpretedData(
}
}
- return DataSourceHelper::createDataSource( comphelper::containerToSequence( aResultVec ) );
+ return new DataSource(aResultVec);
+}
+
+uno::Any DataInterpreter::getChartTypeSpecificData(
+ const OUString & )
+{
+ return uno::Any();
}
// convenience methods
@@ -309,7 +301,7 @@ OUString DataInterpreter::GetRole( const Reference< data::XDataSequence > & xSeq
try
{
Reference< beans::XPropertySet > xProp( xSeq, uno::UNO_QUERY_THROW );
- xProp->getPropertyValue( "Role") >>= aResult;
+ xProp->getPropertyValue( u"Role"_ustr) >>= aResult;
}
catch( const uno::Exception & )
{
@@ -325,7 +317,7 @@ void DataInterpreter::SetRole( const Reference< data::XDataSequence > & xSeq, co
try
{
Reference< beans::XPropertySet > xProp( xSeq, uno::UNO_QUERY_THROW );
- xProp->setPropertyValue( "Role", uno::Any( rRole ));
+ xProp->setPropertyValue( u"Role"_ustr, uno::Any( rRole ));
}
catch( const uno::Exception & )
{
@@ -335,7 +327,7 @@ void DataInterpreter::SetRole( const Reference< data::XDataSequence > & xSeq, co
uno::Any DataInterpreter::GetProperty(
const Sequence< beans::PropertyValue > & aArguments,
- const OUString & rName )
+ std::u16string_view rName )
{
for( sal_Int32 i=aArguments.getLength(); i--; )
{
@@ -347,14 +339,14 @@ uno::Any DataInterpreter::GetProperty(
bool DataInterpreter::HasCategories(
const Sequence< beans::PropertyValue > & rArguments,
- const Sequence< Reference< data::XLabeledDataSequence > > & rData )
+ const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & rData )
{
bool bHasCategories = false;
if( rArguments.hasElements() )
- GetProperty( rArguments, "HasCategories" ) >>= bHasCategories;
+ GetProperty( rArguments, u"HasCategories" ) >>= bHasCategories;
- for( sal_Int32 nLSeqIdx=0; ! bHasCategories && nLSeqIdx<rData.getLength(); ++nLSeqIdx )
+ for( std::size_t nLSeqIdx=0; ! bHasCategories && nLSeqIdx<rData.size(); ++nLSeqIdx )
bHasCategories = ( rData[nLSeqIdx].is() && GetRole( rData[nLSeqIdx]->getValues() ) == "categories");
return bHasCategories;
@@ -364,13 +356,13 @@ bool DataInterpreter::UseCategoriesAsX( const Sequence< beans::PropertyValue > &
{
bool bUseCategoriesAsX = true;
if( rArguments.hasElements() )
- GetProperty( rArguments, "UseCategoriesAsX" ) >>= bUseCategoriesAsX;
+ GetProperty( rArguments, u"UseCategoriesAsX" ) >>= bUseCategoriesAsX;
return bUseCategoriesAsX;
}
OUString SAL_CALL DataInterpreter::getImplementationName()
{
- return "com.sun.star.comp.chart2.DataInterpreter";
+ return u"com.sun.star.comp.chart2.DataInterpreter"_ustr;
}
sal_Bool SAL_CALL DataInterpreter::supportsService( const OUString& rServiceName )
@@ -380,7 +372,18 @@ sal_Bool SAL_CALL DataInterpreter::supportsService( const OUString& rServiceName
css::uno::Sequence< OUString > SAL_CALL DataInterpreter::getSupportedServiceNames()
{
- return { "com.sun.star.chart2.DataInterpreter" };
+ return { u"com.sun.star.chart2.DataInterpreter"_ustr };
+}
+
+std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > DataInterpreter::getDataSequences(
+ const css::uno::Reference< css::chart2::data::XDataSource >& xSource)
+{
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aData;
+ for (const Reference< data::XLabeledDataSequence > & rLDS : xSource->getDataSequences() )
+ {
+ aData.push_back(rLDS);
+ }
+ return aData;
}
} // namespace chart
@@ -403,7 +406,7 @@ void lcl_ShowDataSource( const Reference< data::XDataSource > & xSource )
{
if( aSequences[k].is())
{
- OUString aSourceRepr("<none>");
+ OUString aSourceRepr(u"<none>"_ustr);
if( aSequences[k]->getValues().is())
aSourceRepr = aSequences[k]->getValues()->getSourceRangeRepresentation();
xProp.set( aSequences[k]->getValues(), uno::UNO_QUERY );
@@ -417,7 +420,7 @@ void lcl_ShowDataSource( const Reference< data::XDataSource > & xSource )
SAL_INFO("chart2", " <data sequence " << k << "> unknown Role, Source: " << aSourceRepr );
}
- aSourceRepr = "<none>";
+ aSourceRepr = u"<none>"_ustr;
if( aSequences[k]->getLabel().is())
aSourceRepr = aSequences[k]->getLabel()->getSourceRangeRepresentation();
xProp.set( aSequences[k]->getLabel(), uno::UNO_QUERY );
diff --git a/chart2/source/model/template/DataInterpreter.hxx b/chart2/source/model/template/DataInterpreter.hxx
deleted file mode 100644
index 72d3d61e4aab..000000000000
--- a/chart2/source/model/template/DataInterpreter.hxx
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#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
index 3179317daee5..5d44dc95d46a 100644
--- a/chart2/source/model/template/FilledNetChartType.cxx
+++ b/chart2/source/model/template/FilledNetChartType.cxx
@@ -24,7 +24,6 @@
namespace com::sun::star::uno { class XComponentContext; }
using namespace ::com::sun::star;
-using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Sequence;
@@ -48,6 +47,11 @@ uno::Reference< util::XCloneable > SAL_CALL FilledNetChartType::createClone()
return uno::Reference< util::XCloneable >( new FilledNetChartType( *this ));
}
+rtl::Reference< ChartType > FilledNetChartType::cloneChartType() const
+{
+ return new FilledNetChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL FilledNetChartType::getChartType()
{
@@ -56,7 +60,7 @@ OUString SAL_CALL FilledNetChartType::getChartType()
OUString SAL_CALL FilledNetChartType::getImplementationName()
{
- return "com.sun.star.comp.chart.FilledNetChartType";
+ return u"com.sun.star.comp.chart.FilledNetChartType"_ustr;
}
sal_Bool SAL_CALL FilledNetChartType::supportsService( const OUString& rServiceName )
@@ -68,8 +72,8 @@ css::uno::Sequence< OUString > SAL_CALL FilledNetChartType::getSupportedServiceN
{
return {
CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET,
- "com.sun.star.chart2.ChartType",
- "com.sun.star.beans.PropertySet" };
+ u"com.sun.star.chart2.ChartType"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/template/FilledNetChartType.hxx b/chart2/source/model/template/FilledNetChartType.hxx
index baa2b9efb91b..b2d239aeca36 100644
--- a/chart2/source/model/template/FilledNetChartType.hxx
+++ b/chart2/source/model/template/FilledNetChartType.hxx
@@ -16,40 +16,34 @@
* 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
+#pragma once
#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;
+ 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;
+
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
private:
- explicit FilledNetChartType( const FilledNetChartType & rOther );
+ explicit FilledNetChartType(const FilledNetChartType& rOther);
// ____ XChartType ____
virtual OUString SAL_CALL getChartType() override;
// ____ XCloneable ____
- virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+ 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/FunnelChartType.cxx b/chart2/source/model/template/FunnelChartType.cxx
new file mode 100644
index 000000000000..d9ffe231063f
--- /dev/null
+++ b/chart2/source/model/template/FunnelChartType.cxx
@@ -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/.
+ */
+
+#include "FunnelChartType.hxx"
+#include <servicenames_charttypes.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+namespace com::sun::star::uno
+{
+class XComponentContext;
+}
+
+using namespace ::com::sun::star;
+
+namespace chart
+{
+FunnelChartType::FunnelChartType() {}
+
+FunnelChartType::FunnelChartType(const FunnelChartType& rOther)
+ : ChartType(rOther)
+{
+}
+
+FunnelChartType::~FunnelChartType() {}
+
+// ____ XCloneable ____
+uno::Reference<util::XCloneable> SAL_CALL FunnelChartType::createClone()
+{
+ return uno::Reference<util::XCloneable>(new FunnelChartType(*this));
+}
+
+rtl::Reference<ChartType> FunnelChartType::cloneChartType() const
+{
+ return new FunnelChartType(*this);
+}
+
+// ____ XChartType ____
+OUString SAL_CALL FunnelChartType::getChartType() { return CHART2_SERVICE_NAME_CHARTTYPE_FUNNEL; }
+
+uno::Sequence<OUString> FunnelChartType::getSupportedPropertyRoles()
+{
+ return { "FillColor", "BorderColor" };
+}
+
+OUString SAL_CALL FunnelChartType::getImplementationName()
+{
+ return "com.sun.star.comp.chart.FunnelChartType";
+}
+
+sal_Bool SAL_CALL FunnelChartType::supportsService(const OUString& rServiceName)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence<OUString> SAL_CALL FunnelChartType::getSupportedServiceNames()
+{
+ return { CHART2_SERVICE_NAME_CHARTTYPE_FUNNEL, "com.sun.star.chart2.ChartType" };
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+com_sun_star_comp_chart_FunnelChartType_get_implementation(css::uno::XComponentContext* /*context*/,
+ css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire(new ::chart::FunnelChartType);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/FunnelChartType.hxx b/chart2/source/model/template/FunnelChartType.hxx
new file mode 100644
index 000000000000..fbaa3f46354d
--- /dev/null
+++ b/chart2/source/model/template/FunnelChartType.hxx
@@ -0,0 +1,40 @@
+/* -*- 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/.
+ */
+#pragma once
+
+#include <ChartType.hxx>
+
+namespace chart
+{
+class FunnelChartType final : public ChartType
+{
+public:
+ explicit FunnelChartType();
+ virtual ~FunnelChartType() 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;
+
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
+private:
+ explicit FunnelChartType(const FunnelChartType& 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
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/FunnelChartTypeTemplate.cxx b/chart2/source/model/template/FunnelChartTypeTemplate.cxx
new file mode 100644
index 000000000000..40b3897f8ad1
--- /dev/null
+++ b/chart2/source/model/template/FunnelChartTypeTemplate.cxx
@@ -0,0 +1,192 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "FunnelChartTypeTemplate.hxx"
+#include "ColumnChartType.hxx"
+#include <Diagram.hxx>
+#include <DiagramHelper.hxx>
+#include <DataSeries.hxx>
+#include <DataSeriesHelper.hxx>
+#include <PropertyHelper.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/chart2/DataPointGeometry3D.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <comphelper/diagnose_ex.hxx>
+
+#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_FUNNEL_TEMPLATE_DIMENSION,
+ PROP_FUNNEL_TEMPLATE_GEOMETRY3D
+};
+
+void lcl_AddPropertiesToVector(std::vector<Property>& rOutProperties)
+{
+ rOutProperties.emplace_back(
+ "Dimension", PROP_FUNNEL_TEMPLATE_DIMENSION, cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT);
+ rOutProperties.emplace_back(
+ "Geometry3D", PROP_FUNNEL_TEMPLATE_GEOMETRY3D, cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT);
+}
+
+::cppu::OPropertyArrayHelper& StaticFunnelChartTypeTemplateInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []() {
+ std::vector<css::beans::Property> aProperties;
+ lcl_AddPropertiesToVector(aProperties);
+
+ std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess());
+
+ return comphelper::containerToSequence(aProperties);
+ }();
+ return aPropHelper;
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+FunnelChartTypeTemplate::FunnelChartTypeTemplate(Reference<uno::XComponentContext> const& xContext,
+ const OUString& rServiceName,
+ sal_Int32 nDim /* = 2 */)
+ : ChartTypeTemplate(xContext, rServiceName)
+ , m_nDim(nDim)
+{
+}
+
+FunnelChartTypeTemplate::~FunnelChartTypeTemplate() {}
+
+sal_Int32 FunnelChartTypeTemplate::getDimension() const { return m_nDim; }
+
+// ____ ChartTypeTemplate ____
+bool FunnelChartTypeTemplate::matchesTemplate2(const rtl::Reference<::chart::Diagram>& xDiagram,
+ bool bAdaptProperties)
+{
+ bool bResult = ChartTypeTemplate::matchesTemplate2(xDiagram, bAdaptProperties);
+
+ // adapt solid-type of template according to values in series
+ if (bAdaptProperties && bResult && getDimension() == 3)
+ {
+ bool bGeomFound = false, bGeomAmbiguous = false;
+ sal_Int32 aCommonGeom = xDiagram->getGeometry3D(bGeomFound, bGeomAmbiguous);
+
+ if (!bGeomAmbiguous)
+ {
+ setFastPropertyValue_NoBroadcast(PROP_FUNNEL_TEMPLATE_GEOMETRY3D,
+ uno::Any(aCommonGeom));
+ }
+ }
+
+ return bResult;
+}
+
+rtl::Reference<ChartType>
+ FunnelChartTypeTemplate::getChartTypeForIndex(sal_Int32 /*nChartTypeIndex*/)
+{
+ return new ColumnChartType();
+}
+
+rtl::Reference<ChartType> FunnelChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector<rtl::Reference<ChartType>>& aFormerlyUsedChartTypes)
+{
+ rtl::Reference<ChartType> xResult(getChartTypeForIndex(0));
+ ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(aFormerlyUsedChartTypes, xResult);
+ return xResult;
+}
+
+// ____ OPropertySet ____
+void FunnelChartTypeTemplate::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const
+{
+ static ::chart::tPropertyValueMap aStaticDefaults = []() {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::PropertyHelper::setPropertyValueDefault<sal_Int32>(
+ aTmp, PROP_FUNNEL_TEMPLATE_DIMENSION, 2);
+ ::chart::PropertyHelper::setPropertyValueDefault(aTmp, PROP_FUNNEL_TEMPLATE_GEOMETRY3D,
+ ::chart2::DataPointGeometry3D::CUBOID);
+ return aTmp;
+ }();
+ tPropertyValueMap::const_iterator aFound(aStaticDefaults.find(nHandle));
+ if (aFound == aStaticDefaults.end())
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper& SAL_CALL FunnelChartTypeTemplate::getInfoHelper()
+{
+ return StaticFunnelChartTypeTemplateInfoHelper();
+}
+
+// ____ XPropertySet ____
+Reference<beans::XPropertySetInfo> SAL_CALL FunnelChartTypeTemplate::getPropertySetInfo()
+{
+ static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(
+ StaticFunnelChartTypeTemplateInfoHelper()));
+ return xPropertySetInfo;
+}
+
+void FunnelChartTypeTemplate::applyStyle2(const rtl::Reference<DataSeries>& xSeries,
+ ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount)
+{
+ ChartTypeTemplate::applyStyle2(xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount);
+ xSeries->setPropertyAlsoToAllAttributedDataPoints("BorderStyle",
+ uno::Any(drawing::LineStyle_NONE));
+ if (getDimension() != 3)
+ return;
+
+ try
+ {
+ //apply Geometry3D
+ uno::Any aAGeometry3D;
+ getFastPropertyValue(aAGeometry3D, PROP_FUNNEL_TEMPLATE_GEOMETRY3D);
+ xSeries->setPropertyAlsoToAllAttributedDataPoints("Geometry3D", aAGeometry3D);
+ }
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+}
+
+void FunnelChartTypeTemplate::resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram)
+{
+ ChartTypeTemplate::resetStyles2(xDiagram);
+ std::vector<rtl::Reference<DataSeries>> aSeriesVec(xDiagram->getDataSeries());
+ uno::Any aLineStyleAny(drawing::LineStyle_NONE);
+ for (auto const& series : aSeriesVec)
+ {
+ if (getDimension() == 3)
+ series->setPropertyToDefault("Geometry3D");
+ if (series->getPropertyValue("BorderStyle") == aLineStyleAny)
+ {
+ series->setPropertyToDefault("BorderStyle");
+ }
+ }
+
+ xDiagram->setVertical(false);
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2(FunnelChartTypeTemplate, ChartTypeTemplate, OPropertySet)
+IMPLEMENT_FORWARD_XTYPEPROVIDER2(FunnelChartTypeTemplate, ChartTypeTemplate, OPropertySet)
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/FunnelChartTypeTemplate.hxx b/chart2/source/model/template/FunnelChartTypeTemplate.hxx
new file mode 100644
index 000000000000..ffaefeace151
--- /dev/null
+++ b/chart2/source/model/template/FunnelChartTypeTemplate.hxx
@@ -0,0 +1,61 @@
+/* -*- 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/.
+ */
+#pragma once
+
+#include <OPropertySet.hxx>
+#include <comphelper/uno3.hxx>
+
+#include <ChartTypeTemplate.hxx>
+
+namespace chart
+{
+class FunnelChartTypeTemplate : public ChartTypeTemplate, public ::property::OPropertySet
+{
+public:
+ FunnelChartTypeTemplate(css::uno::Reference<css::uno::XComponentContext> const& xContext,
+ const OUString& rServiceName, sal_Int32 nDim = 2);
+ virtual ~FunnelChartTypeTemplate() override;
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ OPropertySet ____
+ virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any& rAny) const override;
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
+
+ // ____ XPropertySet ____
+ virtual css::uno::Reference<css::beans::XPropertySetInfo>
+ SAL_CALL getPropertySetInfo() override;
+
+ // ____ ChartTypeTemplate ____
+ virtual bool matchesTemplate2(const rtl::Reference<::chart::Diagram>& xDiagram,
+ bool bAdaptProperties) override;
+ virtual rtl::Reference<::chart::ChartType> getChartTypeForNewSeries2(
+ const std::vector<rtl::Reference<::chart::ChartType>>& aFormerlyUsedChartTypes) override;
+ virtual void applyStyle2(const rtl::Reference<::chart::DataSeries>& xSeries,
+ ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount) override;
+ virtual void resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram) override;
+
+ // ____ ChartTypeTemplate ____
+ virtual sal_Int32 getDimension() const override;
+
+ virtual rtl::Reference<::chart::ChartType>
+ getChartTypeForIndex(sal_Int32 nChartTypeIndex) override;
+
+private:
+ sal_Int32 m_nDim;
+};
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/HistogramCalculator.cxx b/chart2/source/model/template/HistogramCalculator.cxx
new file mode 100644
index 000000000000..ac0455196a53
--- /dev/null
+++ b/chart2/source/model/template/HistogramCalculator.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "HistogramCalculator.hxx"
+
+#include <algorithm>
+#include <cmath>
+
+namespace chart
+{
+HistogramCalculator::HistogramCalculator() = default;
+
+void HistogramCalculator::computeBinFrequencyHistogram(const std::vector<double>& rDataPoints)
+{
+ if (rDataPoints.empty())
+ return;
+
+ mnBins = 1;
+ mfBinWidth = 1.0;
+ maBinRanges.clear();
+ maBinFrequencies.clear();
+
+ // Calculate statistics
+ double fSum = 0.0;
+ double fSquareSum = 0.0;
+ double fMinValue = rDataPoints[0];
+ double fMaxValue = rDataPoints[0];
+ sal_Int32 nValidCount = 0;
+
+ // Compute min and max values, ignoring non-finite values
+ for (const auto& rValue : rDataPoints)
+ {
+ if (std::isfinite(rValue))
+ {
+ fSum += rValue;
+ fSquareSum += rValue * rValue;
+ fMinValue = std::min(fMinValue, rValue);
+ fMaxValue = std::max(fMaxValue, rValue);
+ ++nValidCount;
+ }
+ }
+
+ if (nValidCount < 2 || fMinValue == fMaxValue) // Need at least two points for variance
+ {
+ mnBins = 1;
+ mfBinWidth = 1.0;
+ maBinRanges = { { std::floor(fMinValue), std::ceil(fMinValue + 1.0) } };
+ maBinFrequencies = { nValidCount };
+ return;
+ }
+
+ double fMean = fSum / nValidCount;
+ double fVariance = (fSquareSum - fSum * fMean) / (nValidCount - 1);
+ double fStdDev = std::sqrt(fVariance);
+
+ // Apply Scott's rule for bin width
+ mfBinWidth = (3.5 * fStdDev) / std::cbrt(nValidCount);
+
+ // Calculate number of bins
+ mnBins = static_cast<sal_Int32>(std::ceil((fMaxValue - fMinValue) / mfBinWidth));
+ mnBins = std::max<sal_Int32>(mnBins, 1); // Ensure at least one bin
+
+ // Set up bin ranges
+ maBinRanges.reserve(mnBins);
+ double fBinStart = fMinValue;
+
+ for (sal_Int32 i = 0; i < mnBins; ++i)
+ {
+ double fBinEnd = fBinStart + mfBinWidth;
+
+ // Correct rounding to avoid discrepancies
+ fBinStart = std::round(fBinStart * 100.0) / 100.0;
+ fBinEnd = std::round(fBinEnd * 100.0) / 100.0;
+
+ if (i == 0)
+ {
+ // First bin includes the minimum value, so use closed interval [fMinValue, fBinEnd]
+ maBinRanges.emplace_back(fMinValue, fBinEnd);
+ }
+ else
+ {
+ // Subsequent bins use half-open interval (fBinStart, fBinEnd]
+ maBinRanges.emplace_back(fBinStart, fBinEnd);
+ }
+ fBinStart = fBinEnd;
+ }
+
+ // Adjust the last bin end to be inclusive
+ maBinRanges.back().second = std::max(maBinRanges.back().second, fMaxValue);
+
+ // Calculate frequencies
+ maBinFrequencies.assign(mnBins, 0);
+ for (double fValue : rDataPoints)
+ {
+ if (std::isfinite(fValue))
+ {
+ for (size_t i = 0; i < maBinRanges.size(); ++i)
+ {
+ if (i == 0 && fValue >= maBinRanges[i].first && fValue <= maBinRanges[i].second)
+ {
+ maBinFrequencies[i]++;
+ break;
+ }
+ else if (i > 0 && fValue > maBinRanges[i].first && fValue <= maBinRanges[i].second)
+ {
+ maBinFrequencies[i]++;
+ break;
+ }
+ }
+ }
+ }
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/chart2/source/model/template/HistogramCalculator.hxx b/chart2/source/model/template/HistogramCalculator.hxx
new file mode 100644
index 000000000000..d2c43453af1b
--- /dev/null
+++ b/chart2/source/model/template/HistogramCalculator.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#pragma once
+
+#include <sal/types.h>
+#include <vector>
+
+namespace chart
+{
+class HistogramCalculator
+{
+ sal_Int32 mnBins = 1;
+ double mfBinWidth = 1.0;
+
+ std::vector<std::pair<double, double>> maBinRanges;
+ std::vector<sal_Int32> maBinFrequencies;
+
+public:
+ HistogramCalculator();
+
+ void computeBinFrequencyHistogram(const std::vector<double>& dataPoints);
+
+ const std::vector<std::pair<double, double>>& getBinRanges() const { return maBinRanges; }
+ const std::vector<sal_Int32>& getBinFrequencies() const { return maBinFrequencies; }
+};
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/chart2/source/model/template/HistogramChartType.cxx b/chart2/source/model/template/HistogramChartType.cxx
new file mode 100644
index 000000000000..2f202de39945
--- /dev/null
+++ b/chart2/source/model/template/HistogramChartType.cxx
@@ -0,0 +1,295 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "HistogramChartType.hxx"
+#include <servicenames_charttypes.hxx>
+#include <CartesianCoordinateSystem.hxx>
+#include <PropertyHelper.hxx>
+#include <Axis.hxx>
+#include <AxisHelper.hxx>
+#include <AxisIndexDefines.hxx>
+#include <DataSeries.hxx>
+#include <LabeledDataSequence.hxx>
+#include <HistogramDataSequence.hxx>
+#include "HistogramCalculator.hxx"
+#include <com/sun/star/chart2/AxisType.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <algorithm>
+#include <cmath>
+#include <iostream>
+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_HISTOGRAMCHARTTYPE_BINWIDTH,
+ PROP_HISTOGRAMCHARTTYPE_BINRANGE,
+ PROP_HISTOGRAMCHARTTYPE_FREQUENCYTYPE,
+ PROP_HISTOGRAMCHARTTYPE_OVERLAP_SEQUENCE,
+ PROP_HISTOGRAMCHARTTYPE_GAPWIDTH_SEQUENCE
+};
+
+void lcl_AddPropertiesToVector(std::vector<Property>& rOutProperties)
+{
+ rOutProperties.emplace_back(
+ "BinWidth", PROP_HISTOGRAMCHARTTYPE_BINWIDTH, cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT);
+
+ rOutProperties.emplace_back(
+ "BinRange", PROP_HISTOGRAMCHARTTYPE_BINRANGE, cppu::UnoType<double>::get(),
+ beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT);
+
+ rOutProperties.emplace_back(
+ "FrequencyType", PROP_HISTOGRAMCHARTTYPE_FREQUENCYTYPE, cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT);
+
+ rOutProperties.emplace_back("OverlapSequence", PROP_HISTOGRAMCHARTTYPE_OVERLAP_SEQUENCE,
+ cppu::UnoType<Sequence<sal_Int32>>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT);
+
+ rOutProperties.emplace_back("GapwidthSequence", PROP_HISTOGRAMCHARTTYPE_GAPWIDTH_SEQUENCE,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT);
+}
+
+::cppu::OPropertyArrayHelper& StaticHistogramChartTypeInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []() {
+ std::vector<css::beans::Property> aProperties;
+ lcl_AddPropertiesToVector(aProperties);
+
+ std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess());
+
+ return comphelper::containerToSequence(aProperties);
+ }();
+ return aPropHelper;
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+HistogramChartType::HistogramChartType() {}
+
+HistogramChartType::HistogramChartType(const HistogramChartType& rOther)
+ : ChartType(rOther)
+{
+}
+
+HistogramChartType::~HistogramChartType() {}
+
+// ____ XCloneable ____
+uno::Reference<util::XCloneable> SAL_CALL HistogramChartType::createClone()
+{
+ return uno::Reference<util::XCloneable>(new HistogramChartType(*this));
+}
+
+rtl::Reference<ChartType> HistogramChartType::cloneChartType() const
+{
+ return new HistogramChartType(*this);
+}
+
+// ____ XChartType ____
+rtl::Reference<::chart::BaseCoordinateSystem>
+HistogramChartType::createCoordinateSystem2(sal_Int32 DimensionCount)
+{
+ rtl::Reference<CartesianCoordinateSystem> xResult
+ = new CartesianCoordinateSystem(DimensionCount);
+
+ for (sal_Int32 i = 0; i < DimensionCount; i++)
+ {
+ rtl::Reference<Axis> xAxis = xResult->getAxisByDimension2(i, MAIN_AXIS_INDEX);
+ if (xAxis.is())
+ {
+ chart2::ScaleData aScaleData = xAxis->getScaleData();
+ aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
+ aScaleData.Scaling = AxisHelper::createLinearScaling();
+
+ if (i == 0) //X-axis
+ {
+ aScaleData.AxisType = chart2::AxisType::REALNUMBER;
+ aScaleData.AutoDateAxis = false;
+ }
+ else if (i == 1) //Y-axis
+ {
+ aScaleData.AxisType = chart2::AxisType::REALNUMBER;
+ }
+
+ xAxis->setScaleData(aScaleData);
+ }
+ }
+
+ return xResult;
+}
+
+OUString SAL_CALL HistogramChartType::getChartType()
+{
+ return CHART2_SERVICE_NAME_CHARTTYPE_HISTOGRAM;
+}
+
+uno::Sequence<OUString> HistogramChartType::getSupportedPropertyRoles()
+{
+ return { u"FillColor"_ustr, u"BorderColor"_ustr };
+}
+
+::cppu::IPropertyArrayHelper& SAL_CALL HistogramChartType::getInfoHelper()
+{
+ return StaticHistogramChartTypeInfoHelper();
+}
+
+// ____ OPropertySet ____
+void HistogramChartType::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const
+{
+ static const ::chart::tPropertyValueMap aStaticDefaults = []() {
+ ::chart::tPropertyValueMap aTmp;
+ Sequence<sal_Int32> aSeq{ 0 }; // No gap for histogram
+ ::chart::PropertyHelper::setPropertyValueDefault(
+ aTmp, PROP_HISTOGRAMCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq);
+ ::chart::PropertyHelper::setPropertyValueDefault(
+ aTmp, PROP_HISTOGRAMCHARTTYPE_OVERLAP_SEQUENCE, aSeq);
+ ::chart::PropertyHelper::setPropertyValueDefault(aTmp, PROP_HISTOGRAMCHARTTYPE_BINWIDTH,
+ 2.0);
+ ::chart::PropertyHelper::setPropertyValueDefault(aTmp, PROP_HISTOGRAMCHARTTYPE_BINRANGE,
+ 1.0);
+ ::chart::PropertyHelper::setPropertyValueDefault(
+ aTmp, PROP_HISTOGRAMCHARTTYPE_FREQUENCYTYPE, sal_Int32(0));
+ return aTmp;
+ }();
+
+ tPropertyValueMap::const_iterator aFound(aStaticDefaults.find(nHandle));
+ if (aFound == aStaticDefaults.end())
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
+}
+// ____ XPropertySet ____
+uno::Reference<beans::XPropertySetInfo> SAL_CALL HistogramChartType::getPropertySetInfo()
+{
+ static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticHistogramChartTypeInfoHelper()));
+ return xPropertySetInfo;
+}
+
+OUString SAL_CALL HistogramChartType::getImplementationName()
+{
+ return "com.sun.star.comp.chart.HistogramChartType";
+}
+
+sal_Bool SAL_CALL HistogramChartType::supportsService(const OUString& rServiceName)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+css::uno::Sequence<OUString> SAL_CALL HistogramChartType::getSupportedServiceNames()
+{
+ return { CHART2_SERVICE_NAME_CHARTTYPE_HISTOGRAM, "com.sun.star.chart2.ChartType" };
+}
+
+namespace
+{
+void setRoleToTheSequence(uno::Reference<chart2::data::XDataSequence> const& xSequence,
+ OUString const& rRole)
+{
+ if (!xSequence.is())
+ return;
+ try
+ {
+ uno::Reference<beans::XPropertySet> xProperty(xSequence, uno::UNO_QUERY_THROW);
+ xProperty->setPropertyValue(u"Role"_ustr, uno::Any(rRole));
+ }
+ catch (const uno::Exception&)
+ {
+ }
+}
+}
+
+void HistogramChartType::createCalculatedDataSeries()
+{
+ if (m_aDataSeries.empty())
+ return;
+
+ std::vector<uno::Reference<chart2::data::XLabeledDataSequence>> const& aDataSequences
+ = m_aDataSeries[0]->getDataSequences2();
+
+ if (aDataSequences.empty() || !aDataSequences[0].is())
+ return;
+
+ // Extract raw data from the spreadsheet
+ std::vector<double> rawData;
+ uno::Reference<chart2::data::XDataSequence> xValues = aDataSequences[0]->getValues();
+
+ uno::Sequence<uno::Any> aRawAnyValues = xValues->getData();
+ for (const auto& aAny : aRawAnyValues)
+ {
+ double fValue = 0.0;
+ if (aAny >>= fValue) // Extract double from Any
+ {
+ rawData.push_back(fValue);
+ }
+ }
+
+ // Perform histogram calculations
+ HistogramCalculator aHistogramCalculator;
+ aHistogramCalculator.computeBinFrequencyHistogram(rawData);
+
+ // Get bin ranges and frequencies
+ const auto& binRanges = aHistogramCalculator.getBinRanges();
+ const auto& binFrequencies = aHistogramCalculator.getBinFrequencies();
+
+ // Create labels and values for HistogramDataSequence
+ std::vector<OUString> aLabels;
+ std::vector<double> aValues;
+ for (size_t i = 0; i < binRanges.size(); ++i)
+ {
+ OUString aLabel;
+ if (i == 0)
+ {
+ aLabel = u"["_ustr + OUString::number(binRanges[i].first) + u"-"_ustr
+ + OUString::number(binRanges[i].second) + u"]"_ustr;
+ }
+ else
+ {
+ aLabel = u"("_ustr + OUString::number(binRanges[i].first) + u"-"_ustr
+ + OUString::number(binRanges[i].second) + u"]"_ustr;
+ }
+ aLabels.push_back(aLabel);
+ aValues.push_back(static_cast<double>(binFrequencies[i]));
+ }
+
+ rtl::Reference<HistogramDataSequence> aValuesDataSequence = new HistogramDataSequence();
+ aValuesDataSequence->setValues(comphelper::containerToSequence(aValues));
+ aValuesDataSequence->setLabels(comphelper::containerToSequence(aLabels));
+
+ setRoleToTheSequence(aValuesDataSequence, u"values-y"_ustr);
+
+ m_aDataSeries[0]->addDataSequence(new LabeledDataSequence(aValuesDataSequence));
+}
+
+} // namespace chart
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+com_sun_star_comp_chart_HistogramChartType_get_implementation(
+ css::uno::XComponentContext* /*context*/, css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire(new ::chart::HistogramChartType());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/chart2/source/model/template/HistogramChartType.hxx b/chart2/source/model/template/HistogramChartType.hxx
new file mode 100644
index 000000000000..621c153a2d61
--- /dev/null
+++ b/chart2/source/model/template/HistogramChartType.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#pragma once
+
+#include <ChartType.hxx>
+
+namespace chart
+{
+class HistogramChartType : public ChartType
+{
+public:
+ explicit HistogramChartType();
+ virtual ~HistogramChartType() 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;
+
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
+ void createCalculatedDataSeries() override;
+
+protected:
+ explicit HistogramChartType(const HistogramChartType& rOther);
+
+ // ____ XChartType ____
+ rtl::Reference<::chart::BaseCoordinateSystem>
+ createCoordinateSystem2(sal_Int32 DimensionCount) override;
+ OUString SAL_CALL getChartType() override;
+ css::uno::Sequence<OUString> SAL_CALL getSupportedPropertyRoles() override;
+
+ // ____ OPropertySet ____
+ void GetDefaultValue(sal_Int32 nHandle, css::uno::Any& rAny) const override;
+ ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
+
+ // ____ XPropertySet ____
+ css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
+
+ // ____ XCloneable ____
+ css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override;
+};
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/chart2/source/model/template/HistogramChartTypeTemplate.cxx b/chart2/source/model/template/HistogramChartTypeTemplate.cxx
new file mode 100644
index 000000000000..b30d1205c429
--- /dev/null
+++ b/chart2/source/model/template/HistogramChartTypeTemplate.cxx
@@ -0,0 +1,160 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "HistogramChartTypeTemplate.hxx"
+#include "HistogramChartType.hxx"
+#include "HistogramDataInterpreter.hxx"
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
+#include <DataSeriesHelper.hxx>
+#include <PropertyHelper.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/chart2/DataPointGeometry3D.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <comphelper/diagnose_ex.hxx>
+
+#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_HISTOGRAM_TEMPLATE_DIMENSION,
+};
+
+void lcl_AddPropertiesToVector(std::vector<Property>& rOutProperties)
+{
+ rOutProperties.emplace_back(
+ "Dimension", PROP_HISTOGRAM_TEMPLATE_DIMENSION, cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT);
+}
+
+::cppu::OPropertyArrayHelper& StaticHistogramChartTypeTemplateInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aPropHelper = []() {
+ std::vector<css::beans::Property> aProperties;
+ lcl_AddPropertiesToVector(aProperties);
+
+ std::sort(aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess());
+
+ return comphelper::containerToSequence(aProperties);
+ }();
+ return aPropHelper;
+};
+
+} // anonymous namespace
+
+namespace chart
+{
+HistogramChartTypeTemplate::HistogramChartTypeTemplate(
+ Reference<uno::XComponentContext> const& xContext, const OUString& rServiceName,
+ StackMode eStackMode)
+ : ChartTypeTemplate(xContext, rServiceName)
+ , m_eStackMode(eStackMode)
+ , m_nDim(2)
+{
+}
+
+sal_Int32 HistogramChartTypeTemplate::getDimension() const { return m_nDim; }
+
+StackMode HistogramChartTypeTemplate::getStackMode(sal_Int32 /* nChartTypeIndex */) const
+{
+ return m_eStackMode;
+}
+
+rtl::Reference<ChartType>
+ HistogramChartTypeTemplate::getChartTypeForIndex(sal_Int32 /*nChartTypeIndex*/)
+{
+ return new HistogramChartType();
+}
+
+rtl::Reference<ChartType> HistogramChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector<rtl::Reference<ChartType>>& aFormerlyUsedChartTypes)
+{
+ rtl::Reference<ChartType> xResult(getChartTypeForIndex(0));
+ ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem(aFormerlyUsedChartTypes, xResult);
+ return xResult;
+}
+
+// ____ OPropertySet ____
+void HistogramChartTypeTemplate::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const
+{
+ static ::chart::tPropertyValueMap aStaticDefaults = []() {
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::PropertyHelper::setPropertyValueDefault<sal_Int32>(
+ aTmp, PROP_HISTOGRAM_TEMPLATE_DIMENSION, 2);
+ return aTmp;
+ }();
+ tPropertyValueMap::const_iterator aFound(aStaticDefaults.find(nHandle));
+ if (aFound == aStaticDefaults.end())
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
+}
+
+::cppu::IPropertyArrayHelper& SAL_CALL HistogramChartTypeTemplate::getInfoHelper()
+{
+ return StaticHistogramChartTypeTemplateInfoHelper();
+}
+
+// ____ XPropertySet ____
+Reference<beans::XPropertySetInfo> SAL_CALL HistogramChartTypeTemplate::getPropertySetInfo()
+{
+ static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(
+ StaticHistogramChartTypeTemplateInfoHelper()));
+ return xPropertySetInfo;
+}
+
+void HistogramChartTypeTemplate::applyStyle2(const rtl::Reference<DataSeries>& xSeries,
+ ::sal_Int32 nChartTypeIndex, ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount)
+{
+ ChartTypeTemplate::applyStyle2(xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount);
+ xSeries->setPropertyAlsoToAllAttributedDataPoints("BorderStyle",
+ uno::Any(drawing::LineStyle_NONE));
+}
+
+void HistogramChartTypeTemplate::resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram)
+{
+ ChartTypeTemplate::resetStyles2(xDiagram);
+ std::vector<rtl::Reference<DataSeries>> aSeriesVec(xDiagram->getDataSeries());
+ uno::Any aLineStyleAny(drawing::LineStyle_NONE);
+ for (auto const& series : aSeriesVec)
+ {
+ if (series->getPropertyValue("BorderStyle") == aLineStyleAny)
+ {
+ series->setPropertyToDefault("BorderStyle");
+ }
+ }
+
+ xDiagram->setVertical(false);
+}
+
+rtl::Reference<DataInterpreter> HistogramChartTypeTemplate::getDataInterpreter2()
+{
+ if (!m_xDataInterpreter.is())
+ m_xDataInterpreter.set(new HistogramDataInterpreter);
+
+ return m_xDataInterpreter;
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2(HistogramChartTypeTemplate, ChartTypeTemplate, OPropertySet)
+IMPLEMENT_FORWARD_XTYPEPROVIDER2(HistogramChartTypeTemplate, ChartTypeTemplate, OPropertySet)
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/chart2/source/model/template/HistogramChartTypeTemplate.hxx b/chart2/source/model/template/HistogramChartTypeTemplate.hxx
new file mode 100644
index 000000000000..519292f6107f
--- /dev/null
+++ b/chart2/source/model/template/HistogramChartTypeTemplate.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+#pragma once
+
+#include <OPropertySet.hxx>
+#include <comphelper/uno3.hxx>
+
+#include <ChartTypeTemplate.hxx>
+#include <StackMode.hxx>
+
+namespace chart
+{
+class HistogramChartTypeTemplate : public ChartTypeTemplate, public ::property::OPropertySet
+{
+public:
+ explicit HistogramChartTypeTemplate(
+ css::uno::Reference<css::uno::XComponentContext> const& xContext,
+ const OUString& rServiceName, StackMode eStackMode);
+
+ /// merge XInterface implementations
+ DECLARE_XINTERFACE()
+ /// merge XTypeProvider implementations
+ DECLARE_XTYPEPROVIDER()
+
+protected:
+ // ____ OPropertySet ____
+ virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any& rAny) const override;
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
+
+ // ____ XPropertySet ____
+ virtual css::uno::Reference<css::beans::XPropertySetInfo>
+ SAL_CALL getPropertySetInfo() override;
+
+ // ____ ChartTypeTemplate ____
+ virtual rtl::Reference<::chart::ChartType> getChartTypeForNewSeries2(
+ const std::vector<rtl::Reference<::chart::ChartType>>& aFormerlyUsedChartTypes) override;
+
+ virtual sal_Bool SAL_CALL supportsCategories() override { return true; }
+
+ virtual void applyStyle2(const rtl::Reference<::chart::DataSeries>& xSeries,
+ ::sal_Int32 nChartTypeGroupIndex, ::sal_Int32 nSeriesIndex,
+ ::sal_Int32 nSeriesCount) override;
+
+ virtual void resetStyles2(const rtl::Reference<::chart::Diagram>& xDiagram) override;
+
+ virtual rtl::Reference<::chart::ChartType>
+ getChartTypeForIndex(sal_Int32 nChartTypeIndex) override;
+
+ virtual sal_Int32 getDimension() const override;
+ virtual StackMode getStackMode(sal_Int32 nChartTypeIndex) const override;
+
+ rtl::Reference<chart::DataInterpreter> getDataInterpreter2() override;
+
+private:
+ StackMode m_eStackMode;
+ sal_Int32 m_nDim;
+};
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/chart2/source/model/template/HistogramDataInterpreter.cxx b/chart2/source/model/template/HistogramDataInterpreter.cxx
new file mode 100644
index 000000000000..c78f3b298b33
--- /dev/null
+++ b/chart2/source/model/template/HistogramDataInterpreter.cxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/config.h>
+
+#include "HistogramDataInterpreter.hxx"
+#include <HistogramDataSequence.hxx>
+#include "HistogramCalculator.hxx"
+#include <LabeledDataSequence.hxx>
+
+#include <DataSeries.hxx>
+#include <DataSeriesHelper.hxx>
+#include <CommonConverters.hxx>
+#include <com/sun/star/util/XCloneable.hpp>
+#include <comphelper/diagnose_ex.hxx>
+#include <sal/log.hxx>
+
+using namespace css;
+
+namespace chart
+{
+InterpretedData HistogramDataInterpreter::interpretDataSource(
+ const uno::Reference<chart2::data::XDataSource>& xSource,
+ const uno::Sequence<beans::PropertyValue>& aArguments,
+ const std::vector<rtl::Reference<DataSeries>>& aSeriesToReUse)
+{
+ if (!xSource.is())
+ return InterpretedData();
+
+ InterpretedData aInterpretedData(
+ DataInterpreter::interpretDataSource(xSource, aArguments, aSeriesToReUse));
+
+ std::vector<uno::Reference<chart2::data::XLabeledDataSequence>> aData
+ = DataInterpreter::getDataSequences(xSource);
+
+ if (aData.empty() || !aData[0].is())
+ return InterpretedData();
+
+ SetRole(aData[0]->getValues(), u"values-y-original"_ustr);
+
+ return aInterpretedData;
+}
+
+InterpretedData
+HistogramDataInterpreter::reinterpretDataSeries(const InterpretedData& rInterpretedData)
+{
+ return rInterpretedData;
+}
+
+bool HistogramDataInterpreter::isDataCompatible(const InterpretedData& /*aInterpretedData*/)
+{
+ return false;
+}
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/chart2/source/model/template/HistogramDataInterpreter.hxx b/chart2/source/model/template/HistogramDataInterpreter.hxx
new file mode 100644
index 000000000000..9d90e0f2512a
--- /dev/null
+++ b/chart2/source/model/template/HistogramDataInterpreter.hxx
@@ -0,0 +1,35 @@
+/* -*- 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/.
+ */
+
+#pragma once
+
+#include <DataInterpreter.hxx>
+
+namespace chart
+{
+class HistogramDataInterpreter : public DataInterpreter
+{
+public:
+ explicit HistogramDataInterpreter() = default;
+
+protected:
+ // ____ DataInterpreter ____
+ virtual InterpretedData interpretDataSource(
+ const css::uno::Reference<css::chart2::data::XDataSource>& xSource,
+ const css::uno::Sequence<css::beans::PropertyValue>& aArguments,
+ const std::vector<rtl::Reference<::chart::DataSeries>>& aSeriesToReUse) override;
+
+ virtual InterpretedData reinterpretDataSeries(const InterpretedData& aInterpretedData) override;
+
+ virtual bool isDataCompatible(const InterpretedData& aInterpretedData) override;
+};
+
+} // namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/model/template/LineChartType.cxx b/chart2/source/model/template/LineChartType.cxx
index 64b2fe9c146f..4d75a029b944 100644
--- a/chart2/source/model/template/LineChartType.cxx
+++ b/chart2/source/model/template/LineChartType.cxx
@@ -43,90 +43,59 @@ enum
PROP_LINECHARTTYPE_SPLINE_ORDER
};
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+::chart::tPropertyValueMap& StaticLineChartTypeDefaults()
+{
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ []()
+ {
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_LINECHARTTYPE_CURVE_STYLE, ::chart2::CurveStyle_LINES );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_CURVE_RESOLUTION, 20 );
+
+ // todo: check whether order 3 means polygons of order 3 or 2. (see
+ // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_SPLINE_ORDER, 3 );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
+}
+
+::cppu::OPropertyArrayHelper& StaticLineChartTypeInfoHelper()
{
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_STYLE,
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { CHART_UNONAME_CURVE_STYLE,
PROP_LINECHARTTYPE_CURVE_STYLE,
cppu::UnoType<chart2::CurveStyle>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
-
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_RESOLUTION,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_CURVE_RESOLUTION,
PROP_LINECHARTTYPE_CURVE_RESOLUTION,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_SPLINE_ORDER,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_SPLINE_ORDER,
PROP_LINECHARTTYPE_SPLINE_ORDER,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
-}
-
-struct StaticLineChartTypeDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINECHARTTYPE_CURVE_STYLE, ::chart2::CurveStyle_LINES );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_CURVE_RESOLUTION, 20 );
-
- // todo: check whether order 3 means polygons of order 3 or 2. (see
- // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_SPLINE_ORDER, 3 );
- }
-};
-
-struct StaticLineChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLineChartTypeDefaults_Initializer >
-{
-};
-
-struct StaticLineChartTypeInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
+ | beans::PropertyAttribute::MAYBEDEFAULT } };
- return comphelper::containerToSequence( aProperties );
- }
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-};
-
-struct StaticLineChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLineChartTypeInfoHelper_Initializer >
-{
-};
-
-struct StaticLineChartTypeInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLineChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ return comphelper::containerToSequence( aProperties );
+ }());
+ return aPropHelper;
+}
-struct StaticLineChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLineChartTypeInfo_Initializer >
+uno::Reference< beans::XPropertySetInfo >& StaticLineChartTypeInfo()
{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticLineChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -151,6 +120,11 @@ uno::Reference< util::XCloneable > SAL_CALL LineChartType::createClone()
return uno::Reference< util::XCloneable >( new LineChartType( *this ));
}
+rtl::Reference< ChartType > LineChartType::cloneChartType() const
+{
+ return new LineChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL LineChartType::getChartType()
{
@@ -158,29 +132,30 @@ OUString SAL_CALL LineChartType::getChartType()
}
// ____ OPropertySet ____
-uno::Any LineChartType::GetDefaultValue( sal_Int32 nHandle ) const
+void LineChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticLineChartTypeDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticLineChartTypeDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL LineChartType::getInfoHelper()
{
- return *StaticLineChartTypeInfoHelper::get();
+ return StaticLineChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL LineChartType::getPropertySetInfo()
{
- return *StaticLineChartTypeInfo::get();
+ return StaticLineChartTypeInfo();
}
OUString SAL_CALL LineChartType::getImplementationName()
{
- return "com.sun.star.comp.chart.LineChartType";
+ return u"com.sun.star.comp.chart.LineChartType"_ustr;
}
sal_Bool SAL_CALL LineChartType::supportsService( const OUString& rServiceName )
@@ -192,8 +167,8 @@ css::uno::Sequence< OUString > SAL_CALL LineChartType::getSupportedServiceNames(
{
return {
CHART2_SERVICE_NAME_CHARTTYPE_LINE,
- "com.sun.star.chart2.ChartType",
- "com.sun.star.beans.PropertySet" };
+ u"com.sun.star.chart2.ChartType"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/template/LineChartType.hxx b/chart2/source/model/template/LineChartType.hxx
index 27ebc7ffb2bf..4c44cca9c349 100644
--- a/chart2/source/model/template/LineChartType.hxx
+++ b/chart2/source/model/template/LineChartType.hxx
@@ -16,10 +16,9 @@
* 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
+#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -37,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit LineChartType( const LineChartType & rOther );
@@ -44,7 +45,7 @@ private:
virtual OUString SAL_CALL getChartType() override;
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
@@ -57,7 +58,4 @@ private:
} // 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
index 7989a743529a..816ae23c4dc7 100644
--- a/chart2/source/model/template/LineChartTypeTemplate.cxx
+++ b/chart2/source/model/template/LineChartTypeTemplate.cxx
@@ -18,10 +18,12 @@
*/
#include "LineChartTypeTemplate.hxx"
-#include <DiagramHelper.hxx>
-#include <servicenames_charttypes.hxx>
+#include "LineChartType.hxx"
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <PropertyHelper.hxx>
+#include <ChartType.hxx>
#include <unonames.hxx>
#include <com/sun/star/chart2/CurveStyle.hpp>
@@ -30,8 +32,7 @@
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -52,89 +53,58 @@ enum
};
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+::chart::tPropertyValueMap& StaticLineChartTypeTemplateDefaults()
{
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_STYLE,
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ []()
+ {
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 );
+
+ // todo: check whether order 3 means polygons of order 3 or 2. (see
+ // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
+}
+
+::cppu::OPropertyArrayHelper& StaticLineChartTypeTemplateInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { CHART_UNONAME_CURVE_STYLE,
PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE,
cppu::UnoType<chart2::CurveStyle>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_RESOLUTION,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_CURVE_RESOLUTION,
PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_SPLINE_ORDER,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_SPLINE_ORDER,
PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
-}
-
-struct StaticLineChartTypeTemplateDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 );
-
- // todo: check whether order 3 means polygons of order 3 or 2. (see
- // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 );
- }
-};
-
-struct StaticLineChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLineChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticLineChartTypeTemplateInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
+ | beans::PropertyAttribute::MAYBEDEFAULT } };
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticLineChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLineChartTypeTemplateInfoHelper_Initializer >
-{
-};
-
-struct StaticLineChartTypeTemplateInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLineChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ return comphelper::containerToSequence( aProperties );
+ }());
+ return aPropHelper;
+}
-struct StaticLineChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLineChartTypeTemplateInfo_Initializer >
+uno::Reference< beans::XPropertySetInfo >& StaticLineChartTypeTemplateInfo()
{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticLineChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -150,7 +120,6 @@ LineChartTypeTemplate::LineChartTypeTemplate(
bool bHasLines /* = true */,
sal_Int32 nDim /* = 2 */ ) :
ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex ),
m_eStackMode( eStackMode ),
m_bHasSymbols( bSymbols ),
m_bHasLines( bHasLines ),
@@ -162,25 +131,27 @@ LineChartTypeTemplate::LineChartTypeTemplate(
LineChartTypeTemplate::~LineChartTypeTemplate()
{}
+
// ____ OPropertySet ____
-uno::Any LineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void LineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticLineChartTypeTemplateDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticLineChartTypeTemplateDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL LineChartTypeTemplate::getInfoHelper()
{
- return *StaticLineChartTypeTemplateInfoHelper::get();
+ return StaticLineChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL LineChartTypeTemplate::getPropertySetInfo()
{
- return *StaticLineChartTypeTemplateInfo::get();
+ return StaticLineChartTypeTemplateInfo();
}
sal_Int32 LineChartTypeTemplate::getDimension() const
@@ -193,12 +164,12 @@ StackMode LineChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ )
return m_eStackMode;
}
-// ____ XChartTypeTemplate ____
-sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
- const uno::Reference< chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties )
+// ____ ChartTypeTemplate ____
+bool LineChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties )
{
- bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
+ bool bResult = ChartTypeTemplate::matchesTemplate2( xDiagram, bAdaptProperties );
// check symbol-style and line-style
// for a template with symbols (or with lines) it is ok, if there is at least one series
@@ -208,8 +179,8 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
bool bSymbolFound = false;
bool bLineFound = false;
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ xDiagram->getDataSeries();
for (auto const& series : aSeriesVec)
{
@@ -217,9 +188,8 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
{
chart2::Symbol aSymbProp;
drawing::LineStyle eLineStyle;
- Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY_THROW);
- bool bCurrentHasSymbol = (xProp->getPropertyValue( "Symbol") >>= aSymbProp) &&
+ bool bCurrentHasSymbol = (series->getPropertyValue( u"Symbol"_ustr) >>= aSymbProp) &&
(aSymbProp.Style != chart2::SymbolStyle_NONE);
if( bCurrentHasSymbol )
@@ -231,7 +201,7 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
break;
}
- bool bCurrentHasLine = (xProp->getPropertyValue( "LineStyle") >>= eLineStyle) &&
+ bool bCurrentHasLine = (series->getPropertyValue( u"LineStyle"_ustr) >>= eLineStyle) &&
( eLineStyle != drawing::LineStyle_NONE );
if( bCurrentHasLine )
@@ -265,12 +235,10 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
{
try
{
- uno::Reference< beans::XPropertySet > xChartTypeProp(
- DiagramHelper::getChartTypeByIndex( xDiagram, 0 ),
- uno::UNO_QUERY_THROW );
- setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_STYLE) );
- setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) );
- setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartTypeProp->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) );
+ rtl::Reference< ChartType > xChartType = xDiagram->getChartTypeByIndex( 0 );
+ setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE, xChartType->getPropertyValue(CHART_UNONAME_CURVE_STYLE) );
+ setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartType->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) );
+ setFastPropertyValue_NoBroadcast( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartType->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) );
}
catch( const uno::Exception & )
{
@@ -281,27 +249,20 @@ sal_Bool SAL_CALL LineChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< chart2::XChartType > LineChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+rtl::Reference< ChartType > LineChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
-
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ));
- }
+ xResult = new LineChartType();
+
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ));
}
catch( const uno::Exception & )
{
@@ -311,30 +272,23 @@ Reference< chart2::XChartType > LineChartTypeTemplate::getChartTypeForIndex( sal
return xResult;
}
-Reference< chart2::XChartType > SAL_CALL LineChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > LineChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
+ xResult = new LineChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ));
- }
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_STYLE ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_LINECHARTTYPE_TEMPLATE_SPLINE_ORDER ));
}
catch( const uno::Exception & )
{
@@ -344,21 +298,19 @@ Reference< chart2::XChartType > SAL_CALL LineChartTypeTemplate::getChartTypeForN
return xResult;
}
-void SAL_CALL LineChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void LineChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
try
{
- Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
-
- DataSeriesHelper::switchSymbolsOnOrOff( xProp, m_bHasSymbols, nSeriesIndex );
- DataSeriesHelper::switchLinesOnOrOff( xProp, m_bHasLines );
- DataSeriesHelper::makeLinesThickOrThin( xProp, m_nDim==2 );
+ xSeries->switchSymbolsOnOrOff( m_bHasSymbols, nSeriesIndex );
+ xSeries->switchLinesOnOrOff( m_bHasLines );
+ xSeries->makeLinesThickOrThin( m_nDim==2 );
}
catch( const uno::Exception & )
{
diff --git a/chart2/source/model/template/LineChartTypeTemplate.hxx b/chart2/source/model/template/LineChartTypeTemplate.hxx
index 2663fb11325d..a634fb390aae 100644
--- a/chart2/source/model/template/LineChartTypeTemplate.hxx
+++ b/chart2/source/model/template/LineChartTypeTemplate.hxx
@@ -16,12 +16,10 @@
* 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
+#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <StackMode.hxx>
#include <comphelper/uno3.hxx>
@@ -29,7 +27,6 @@ namespace chart
{
class LineChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -50,27 +47,26 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ // ____ ChartTypeTemplate ____
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
-
- // ____ ChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual sal_Int32 getDimension() const override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
@@ -84,7 +80,4 @@ private:
} // 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
index 95de304b6ae1..b1bed1b605ca 100644
--- a/chart2/source/model/template/NetChartType.cxx
+++ b/chart2/source/model/template/NetChartType.cxx
@@ -22,6 +22,7 @@
#include <servicenames_charttypes.hxx>
#include <AxisIndexDefines.hxx>
#include <AxisHelper.hxx>
+#include <Axis.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/chart2/AxisType.hpp>
@@ -47,18 +48,18 @@ NetChartType_Base::NetChartType_Base( const NetChartType_Base & rOther ) :
NetChartType_Base::~NetChartType_Base()
{}
-Reference< XCoordinateSystem > SAL_CALL
- NetChartType_Base::createCoordinateSystem( ::sal_Int32 DimensionCount )
+rtl::Reference< ::chart::BaseCoordinateSystem >
+ NetChartType_Base::createCoordinateSystem2( sal_Int32 DimensionCount )
{
if( DimensionCount != 2 )
throw lang::IllegalArgumentException(
- "NetChart must be two-dimensional",
+ u"NetChart must be two-dimensional"_ustr,
static_cast< ::cppu::OWeakObject* >( this ), 0 );
- Reference< XCoordinateSystem > xResult(
- new PolarCoordinateSystem( DimensionCount ));
+ rtl::Reference< PolarCoordinateSystem > xResult =
+ new PolarCoordinateSystem( DimensionCount );
- Reference< XAxis > xAxis( xResult->getAxisByDimension( 0, MAIN_AXIS_INDEX ) );
+ rtl::Reference< Axis > xAxis = xResult->getAxisByDimension2( 0, MAIN_AXIS_INDEX );
if( xAxis.is() )
{
ScaleData aScaleData = xAxis->getScaleData();
@@ -68,7 +69,7 @@ Reference< XCoordinateSystem > SAL_CALL
xAxis->setScaleData( aScaleData );
}
- xAxis = xResult->getAxisByDimension( 1, MAIN_AXIS_INDEX );
+ xAxis = xResult->getAxisByDimension2( 1, MAIN_AXIS_INDEX );
if( xAxis.is() )
{
ScaleData aScaleData = xAxis->getScaleData();
@@ -81,53 +82,39 @@ Reference< XCoordinateSystem > SAL_CALL
}
// ____ OPropertySet ____
-uno::Any NetChartType_Base::GetDefaultValue( sal_Int32 /*nHandle*/ ) const
+void NetChartType_Base::GetDefaultValue( sal_Int32 /*nHandle*/, uno::Any& rAny ) const
{
- return uno::Any();
+ rAny.clear();
}
namespace
{
-struct StaticNetChartTypeInfoHelper_Initializer
+::cppu::OPropertyArrayHelper& StaticNetChartTypeInfoHelper()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper(Sequence< beans::Property >{});
- return &aPropHelper;
- }
-};
-
-struct StaticNetChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticNetChartTypeInfoHelper_Initializer >
-{
-};
-
-struct StaticNetChartTypeInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticNetChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper(Sequence< beans::Property >{});
+ return aPropHelper;
+}
-struct StaticNetChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticNetChartTypeInfo_Initializer >
+uno::Reference< beans::XPropertySetInfo >& StaticNetChartTypeInfo()
{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticNetChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
+}
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL NetChartType_Base::getInfoHelper()
{
- return *StaticNetChartTypeInfoHelper::get();
+ return StaticNetChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL NetChartType_Base::getPropertySetInfo()
{
- return *StaticNetChartTypeInfo::get();
+ return StaticNetChartTypeInfo();
}
NetChartType::NetChartType()
@@ -147,6 +134,11 @@ uno::Reference< util::XCloneable > SAL_CALL NetChartType::createClone()
return uno::Reference< util::XCloneable >( new NetChartType( *this ));
}
+rtl::Reference< ChartType > NetChartType::cloneChartType() const
+{
+ return new NetChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL NetChartType::getChartType()
{
@@ -155,7 +147,7 @@ OUString SAL_CALL NetChartType::getChartType()
OUString SAL_CALL NetChartType::getImplementationName()
{
- return "com.sun.star.comp.chart.NetChartType";
+ return u"com.sun.star.comp.chart.NetChartType"_ustr;
}
sal_Bool SAL_CALL NetChartType::supportsService( const OUString& rServiceName )
@@ -167,8 +159,8 @@ css::uno::Sequence< OUString > SAL_CALL NetChartType::getSupportedServiceNames()
{
return {
CHART2_SERVICE_NAME_CHARTTYPE_NET,
- "com.sun.star.chart2.ChartType",
- "com.sun.star.beans.PropertySet" };
+ u"com.sun.star.chart2.ChartType"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/template/NetChartType.hxx b/chart2/source/model/template/NetChartType.hxx
index 3d3efed8cfe5..ae414a27c4e1 100644
--- a/chart2/source/model/template/NetChartType.hxx
+++ b/chart2/source/model/template/NetChartType.hxx
@@ -16,10 +16,9 @@
* 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
+#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -33,18 +32,17 @@ public:
protected:
explicit NetChartType_Base( const NetChartType_Base & rOther );
- // ____ XChartType ____
- virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL
- createCoordinateSystem( ::sal_Int32 DimensionCount ) override;
-
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
+
+ virtual rtl::Reference< ::chart::BaseCoordinateSystem >
+ createCoordinateSystem2( sal_Int32 DimensionCount ) override;
};
class NetChartType final : public NetChartType_Base
@@ -60,6 +58,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit NetChartType( const NetChartType & rOther );
@@ -72,7 +72,4 @@ private:
} // 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
index fed499cb3970..07537c66b1df 100644
--- a/chart2/source/model/template/NetChartTypeTemplate.cxx
+++ b/chart2/source/model/template/NetChartTypeTemplate.cxx
@@ -18,20 +18,21 @@
*/
#include "NetChartTypeTemplate.hxx"
-#include <DiagramHelper.hxx>
-#include <servicenames_charttypes.hxx>
+#include "FilledNetChartType.hxx"
+#include "NetChartType.hxx"
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <ChartType.hxx>
#include <com/sun/star/chart2/SymbolStyle.hpp>
#include <com/sun/star/chart2/Symbol.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
namespace chart
{
@@ -58,21 +59,19 @@ StackMode NetChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ )
return m_eStackMode;
}
-void SAL_CALL NetChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void NetChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
try
{
- Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
-
- DataSeriesHelper::switchSymbolsOnOrOff( xProp, m_bHasSymbols, nSeriesIndex );
- DataSeriesHelper::switchLinesOnOrOff( xProp, m_bHasLines );
- DataSeriesHelper::makeLinesThickOrThin( xProp, true );
+ xSeries->switchSymbolsOnOrOff( m_bHasSymbols, nSeriesIndex );
+ xSeries->switchLinesOnOrOff( m_bHasLines );
+ xSeries->makeLinesThickOrThin( true );
}
catch( const uno::Exception & )
{
@@ -80,15 +79,12 @@ void SAL_CALL NetChartTypeTemplate::applyStyle(
}
}
-// ____ XChartTypeTemplate ____
-sal_Bool SAL_CALL NetChartTypeTemplate::matchesTemplate(
- const Reference< chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties )
+// ____ ChartTypeTemplate ____
+bool NetChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties )
{
- bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
-
- uno::Reference< beans::XPropertySet > xChartTypeProp(
- DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), uno::UNO_QUERY_THROW );
+ bool bResult = ChartTypeTemplate::matchesTemplate2( xDiagram, bAdaptProperties );
if( bResult )
{
@@ -102,8 +98,8 @@ sal_Bool SAL_CALL NetChartTypeTemplate::matchesTemplate(
bool bSymbolFound = false;
bool bLineFound = false;
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ xDiagram->getDataSeries();
for (auto const& series : aSeriesVec)
{
@@ -111,9 +107,8 @@ sal_Bool SAL_CALL NetChartTypeTemplate::matchesTemplate(
{
chart2::Symbol aSymbProp;
drawing::LineStyle eLineStyle;
- Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY_THROW);
- bool bCurrentHasSymbol = (xProp->getPropertyValue( "Symbol") >>= aSymbProp) &&
+ bool bCurrentHasSymbol = (series->getPropertyValue( u"Symbol"_ustr) >>= aSymbProp) &&
(aSymbProp.Style != chart2::SymbolStyle_NONE);
if( bCurrentHasSymbol )
@@ -125,7 +120,7 @@ sal_Bool SAL_CALL NetChartTypeTemplate::matchesTemplate(
break;
}
- bool bCurrentHasLine = (xProp->getPropertyValue( "LineStyle") >>= eLineStyle) &&
+ bool bCurrentHasLine = (series->getPropertyValue( u"LineStyle"_ustr) >>= eLineStyle) &&
( eLineStyle != drawing::LineStyle_NONE );
if( bCurrentHasLine )
@@ -157,34 +152,18 @@ sal_Bool SAL_CALL NetChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< chart2::XChartType > NetChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+rtl::Reference< ChartType > NetChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
{
- Reference< chart2::XChartType > xResult;
-
- try
- {
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
-
- if( m_bHasFilledArea )
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET ), uno::UNO_QUERY_THROW );
- else
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_NET ), uno::UNO_QUERY_THROW );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION("chart2");
- }
-
- return xResult;
+ if( m_bHasFilledArea )
+ return new FilledNetChartType();
+ else
+ return new NetChartType();
}
-Reference< chart2::XChartType > SAL_CALL NetChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > NetChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult( getChartTypeForIndex( 0 ) );
+ rtl::Reference< ChartType > xResult( getChartTypeForIndex( 0 ) );
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
return xResult;
}
diff --git a/chart2/source/model/template/NetChartTypeTemplate.hxx b/chart2/source/model/template/NetChartTypeTemplate.hxx
index 369989e6f988..b1f5ac9dbd83 100644
--- a/chart2/source/model/template/NetChartTypeTemplate.hxx
+++ b/chart2/source/model/template/NetChartTypeTemplate.hxx
@@ -16,10 +16,9 @@
* 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
+#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <StackMode.hxx>
namespace chart
@@ -39,20 +38,21 @@ public:
virtual ~NetChartTypeTemplate() override;
protected:
- // ____ XChartTypeTemplate ____
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ // ____ ChartTypeTemplate ____
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
// ____ ChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
@@ -65,7 +65,4 @@ private:
} // 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
index c18c8d11d376..36f9a59d0862 100644
--- a/chart2/source/model/template/PieChartType.cxx
+++ b/chart2/source/model/template/PieChartType.cxx
@@ -20,12 +20,14 @@
#include "PieChartType.hxx"
#include <PropertyHelper.hxx>
#include <PolarCoordinateSystem.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
#include <servicenames_charttypes.hxx>
#include <AxisIndexDefines.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/chart2/AxisType.hpp>
+#include <com/sun/star/chart2/PieChartSubType.hpp>
using namespace ::com::sun::star;
@@ -36,85 +38,59 @@ using ::com::sun::star::uno::Reference;
namespace
{
-enum
+::chart::tPropertyValueMap& StaticPieChartTypeDefaults()
{
- PROP_PIECHARTTYPE_USE_RINGS,
- PROP_PIECHARTTYPE_3DRELATIVEHEIGHT
-};
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ []()
+ {
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, ::chart::PROP_PIECHARTTYPE_USE_RINGS, false );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, ::chart::PROP_PIECHARTTYPE_3DRELATIVEHEIGHT, 100 );
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, ::chart::PROP_PIECHARTTYPE_SUBTYPE, chart2::PieChartSubType_NONE );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, ::chart::PROP_PIECHARTTYPE_SPLIT_POS, 2 );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
+}
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+::cppu::OPropertyArrayHelper& StaticPieChartTypeInfoHelper()
{
- rOutProperties.emplace_back( "UseRings",
- PROP_PIECHARTTYPE_USE_RINGS,
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { u"UseRings"_ustr,
+ ::chart::PROP_PIECHARTTYPE_USE_RINGS,
cppu::UnoType<bool>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( "3DRelativeHeight",
- PROP_PIECHARTTYPE_3DRELATIVEHEIGHT,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { u"3DRelativeHeight"_ustr,
+ ::chart::PROP_PIECHARTTYPE_3DRELATIVEHEIGHT,
cppu::UnoType<sal_Int32>::get(),
- beans::PropertyAttribute::MAYBEVOID );
+ beans::PropertyAttribute::MAYBEVOID },
+ { u"SubPieType"_ustr,
+ ::chart::PROP_PIECHARTTYPE_SUBTYPE,
+ cppu::UnoType<chart2::PieChartSubType>::get(),
+ beans::PropertyAttribute::MAYBEDEFAULT },
+ { u"SplitPos"_ustr,
+ ::chart::PROP_PIECHARTTYPE_SPLIT_POS,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::MAYBEVOID }
+ };
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+
+ return comphelper::containerToSequence( aProperties );
+ }());
+ return aPropHelper;
}
-struct StaticPieChartTypeDefaults_Initializer
+uno::Reference< beans::XPropertySetInfo >& StaticPieChartTypeInfo()
{
- ::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 >
-{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo( StaticPieChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -139,21 +115,26 @@ uno::Reference< util::XCloneable > SAL_CALL PieChartType::createClone()
return uno::Reference< util::XCloneable >( new PieChartType( *this ));
}
+rtl::Reference< ChartType > PieChartType::cloneChartType() const
+{
+ return new PieChartType( *this );
+}
+
// ____ XChartType ____
OUString SAL_CALL PieChartType::getChartType()
{
return CHART2_SERVICE_NAME_CHARTTYPE_PIE;
}
-Reference< chart2::XCoordinateSystem > SAL_CALL
- PieChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
+rtl::Reference< ::chart::BaseCoordinateSystem >
+ PieChartType::createCoordinateSystem2( sal_Int32 DimensionCount )
{
- Reference< chart2::XCoordinateSystem > xResult(
- new PolarCoordinateSystem( DimensionCount ));
+ rtl::Reference< PolarCoordinateSystem > xResult =
+ new PolarCoordinateSystem( DimensionCount );
for( sal_Int32 i=0; i<DimensionCount; ++i )
{
- Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
+ rtl::Reference< Axis > xAxis = xResult->getAxisByDimension2( i, MAIN_AXIS_INDEX );
if( !xAxis.is() )
{
OSL_FAIL("a created coordinate system should have an axis for each dimension");
@@ -182,38 +163,35 @@ Reference< chart2::XCoordinateSystem > SAL_CALL
uno::Sequence< OUString > PieChartType::getSupportedPropertyRoles()
{
- uno::Sequence< OUString > aPropRoles(2);
- aPropRoles[0] = "FillColor";
- aPropRoles[1] = "BorderColor";
-
- return aPropRoles;
+ return { u"FillColor"_ustr, u"BorderColor"_ustr };
}
// ____ OPropertySet ____
-uno::Any PieChartType::GetDefaultValue( sal_Int32 nHandle ) const
+void PieChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticPieChartTypeDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticPieChartTypeDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL PieChartType::getInfoHelper()
{
- return *StaticPieChartTypeInfoHelper::get();
+ return StaticPieChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL PieChartType::getPropertySetInfo()
{
- return *StaticPieChartTypeInfo::get();
+ return StaticPieChartTypeInfo();
}
OUString SAL_CALL PieChartType::getImplementationName()
{
- return "com.sun.star.comp.chart.PieChartType";
+ return u"com.sun.star.comp.chart.PieChartType"_ustr;
}
sal_Bool SAL_CALL PieChartType::supportsService( const OUString& rServiceName )
@@ -225,8 +203,8 @@ css::uno::Sequence< OUString > SAL_CALL PieChartType::getSupportedServiceNames()
{
return {
CHART2_SERVICE_NAME_CHARTTYPE_PIE,
- "com.sun.star.chart2.ChartType",
- "com.sun.star.beans.PropertySet" };
+ u"com.sun.star.chart2.ChartType"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/template/PieChartType.hxx b/chart2/source/model/template/PieChartType.hxx
index 897ec96950f1..083bd78facd3 100644
--- a/chart2/source/model/template/PieChartType.hxx
+++ b/chart2/source/model/template/PieChartType.hxx
@@ -16,10 +16,10 @@
* 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
+#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
+#include <com/sun/star/chart2/PieChartSubType.hpp>
namespace chart
{
@@ -37,18 +37,18 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit PieChartType( const PieChartType & rOther );
// ____ XChartType ____
virtual OUString SAL_CALL getChartType() override;
- virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL
- createCoordinateSystem( ::sal_Int32 DimensionCount ) override;
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedPropertyRoles() override;
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
// ____ OPropertySet ____
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -59,11 +59,11 @@ private:
// ____ XCloneable ____
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+
+ virtual rtl::Reference< ::chart::BaseCoordinateSystem >
+ createCoordinateSystem2( sal_Int32 DimensionCount ) override;
};
} // namespace chart
-// 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
index 964b5d96d5c2..25d6d9c6ffe6 100644
--- a/chart2/source/model/template/PieChartTypeTemplate.cxx
+++ b/chart2/source/model/template/PieChartTypeTemplate.cxx
@@ -18,27 +18,29 @@
*/
#include "PieChartTypeTemplate.hxx"
+#include "PieChartType.hxx"
+#include <BaseCoordinateSystem.hxx>
#include <CommonConverters.hxx>
-#include <DiagramHelper.hxx>
-#include <servicenames_charttypes.hxx>
+#include <ChartType.hxx>
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
+#include <DataSeriesProperties.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
-#include <ThreeDHelper.hxx>
#include <PropertyHelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <officecfg/Office/Compatibility.hxx>
+#include <comphelper/diagnose_ex.hxx>
#include <rtl/math.hxx>
#include <algorithm>
using namespace ::com::sun::star;
+using namespace ::chart::DataSeriesProperties;
using ::com::sun::star::beans::Property;
using ::com::sun::star::uno::Sequence;
@@ -52,95 +54,80 @@ enum
PROP_PIE_TEMPLATE_DEFAULT_OFFSET,
PROP_PIE_TEMPLATE_OFFSET_MODE,
PROP_PIE_TEMPLATE_DIMENSION,
- PROP_PIE_TEMPLATE_USE_RINGS
+ PROP_PIE_TEMPLATE_USE_RINGS,
+ PROP_PIE_TEMPLATE_SUB_PIE_TYPE,
+ PROP_PIE_TEMPLATE_SPLIT_POS
};
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+::chart::tPropertyValueMap& StaticPieChartTypeTemplateDefaults()
{
- rOutProperties.emplace_back( "OffsetMode",
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ []{
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_PIE_TEMPLATE_OFFSET_MODE, chart2::PieChartOffsetMode_NONE );
+ ::chart::PropertyHelper::setPropertyValueDefault< double >( aOutMap, PROP_PIE_TEMPLATE_DEFAULT_OFFSET, 0.5 );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_PIE_TEMPLATE_DIMENSION, 2 );
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_PIE_TEMPLATE_USE_RINGS, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_PIE_TEMPLATE_SUB_PIE_TYPE, chart2::PieChartSubType_NONE );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >(
+ aOutMap, PROP_PIE_TEMPLATE_SPLIT_POS, 2 );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
+}
+
+::cppu::OPropertyArrayHelper& StaticPieChartTypeTemplateInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { u"OffsetMode"_ustr,
PROP_PIE_TEMPLATE_OFFSET_MODE,
cppu::UnoType<chart2::PieChartOffsetMode>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( "DefaultOffset",
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { u"DefaultOffset"_ustr,
PROP_PIE_TEMPLATE_DEFAULT_OFFSET,
cppu::UnoType<double>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( "Dimension",
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { u"Dimension"_ustr,
PROP_PIE_TEMPLATE_DIMENSION,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( "UseRings",
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { u"UseRings"_ustr,
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 );
- }
-
-};
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { u"SubPieType"_ustr,
+ PROP_PIE_TEMPLATE_SUB_PIE_TYPE,
+ cppu::UnoType<chart2::PieChartSubType>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { u"SplitPos"_ustr,
+ PROP_PIE_TEMPLATE_SPLIT_POS,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT }
+ };
-struct StaticPieChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticPieChartTypeTemplateInfoHelper_Initializer >
-{
-};
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
-struct StaticPieChartTypeTemplateInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPieChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ return comphelper::containerToSequence( aProperties );
+ }() );
+ return aPropHelper;
+}
-struct StaticPieChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPieChartTypeTemplateInfo_Initializer >
+uno::Reference< beans::XPropertySetInfo >& StaticPieChartTypeTemplateInfo()
{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticPieChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -152,38 +139,42 @@ PieChartTypeTemplate::PieChartTypeTemplate(
uno::XComponentContext > const & xContext,
const OUString & rServiceName,
chart2::PieChartOffsetMode eMode,
- bool bRings /* = false */,
+ bool bRings,
+ chart2::PieChartSubType eSubType,
+ sal_Int32 nCompositeSize,
sal_Int32 nDim /* = 2 */ ) :
- ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex )
+ ChartTypeTemplate( xContext, rServiceName )
{
setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_OFFSET_MODE, uno::Any( eMode ));
setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_DIMENSION, uno::Any( nDim ));
setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_USE_RINGS, uno::Any( bRings ));
+ setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_SUB_PIE_TYPE, uno::Any( eSubType ));
+ setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_SPLIT_POS, uno::Any( nCompositeSize ));
}
PieChartTypeTemplate::~PieChartTypeTemplate()
{}
// ____ OPropertySet ____
-uno::Any PieChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void PieChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticPieChartTypeTemplateDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticPieChartTypeTemplateDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL PieChartTypeTemplate::getInfoHelper()
{
- return *StaticPieChartTypeTemplateInfoHelper::get();
+ return StaticPieChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL PieChartTypeTemplate::getPropertySetInfo()
{
- return *StaticPieChartTypeTemplateInfo::get();
+ return StaticPieChartTypeTemplateInfo();
}
// ____ ChartTypeTemplate ____
@@ -210,14 +201,14 @@ sal_Int32 PieChartTypeTemplate::getAxisCountByDimension( sal_Int32 /*nDimension*
}
void PieChartTypeTemplate::adaptAxes(
- const uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > & /*rCoordSys*/ )
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & /*rCoordSys*/ )
{
// hide existing axes
//hhhh todo
}
void PieChartTypeTemplate::adaptScales(
- const Sequence< Reference< chart2::XCoordinateSystem > > & aCooSysSeq,
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & aCooSysSeq,
const Reference< chart2::data::XLabeledDataSequence > & xCategories //@todo: in future there may be more than one sequence of categories (e.g. charttype with categories at x and y axis )
)
{
@@ -226,17 +217,25 @@ void PieChartTypeTemplate::adaptScales(
//remove explicit scalings from radius axis
//and ensure correct orientation of scales for donuts
- for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq )
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : aCooSysSeq )
{
try
{
- Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 1 /*nDimensionIndex*/,0 /*nAxisIndex*/
- , coords ) );
+ rtl::Reference< Axis > xAxis = AxisHelper::getAxis( 1 /*nDimensionIndex*/,0 /*nAxisIndex*/
+ , coords );
if( xAxis.is() )
{
chart2::ScaleData aScaleData( xAxis->getScaleData() );
AxisHelper::removeExplicitScaling( aScaleData );
- aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
+ // tdf#108059 Create new pie/donut charts with clockwise orientation
+ if (!officecfg::Office::Compatibility::View::ClockwisePieChartDirection::get())
+ {
+ aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
+ }
+ else
+ {
+ aScaleData.Orientation = chart2::AxisOrientation_REVERSE;
+ }
xAxis->setScaleData( aScaleData );
}
@@ -245,7 +244,12 @@ void PieChartTypeTemplate::adaptScales(
if( xAxis.is() )
{
chart2::ScaleData aScaleData( xAxis->getScaleData() );
- aScaleData.Orientation = chart2::AxisOrientation_REVERSE;
+
+ //tdf#123218 Don't reverse the orientation in OOXML-heavy environments
+ if( officecfg::Office::Compatibility::View::ReverseXAxisOrientationDoughnutChart::get() )
+ aScaleData.Orientation = chart2::AxisOrientation_REVERSE;
+ else
+ aScaleData.Orientation = chart2::AxisOrientation_MATHEMATICAL;
xAxis->setScaleData( aScaleData );
}
}
@@ -257,35 +261,29 @@ void PieChartTypeTemplate::adaptScales(
}
void PieChartTypeTemplate::createChartTypes(
- const Sequence< Sequence< Reference< chart2::XDataSeries > > > & aSeriesSeq,
- const Sequence< Reference< chart2::XCoordinateSystem > > & rCoordSys,
- const Sequence< Reference< chart2::XChartType > >& /* aOldChartTypesSeq */ )
+ const std::vector< std::vector< rtl::Reference< DataSeries > > > & aSeriesSeq,
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > >& /* aOldChartTypesSeq */ )
{
- if( ! rCoordSys.hasElements() ||
- ! rCoordSys[0].is() )
+ if( rCoordSys.empty() )
return;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
-
- Reference< chart2::XChartType > xCT(
- xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_PIE ), uno::UNO_QUERY_THROW );
- Reference< beans::XPropertySet > xCTProp( xCT, uno::UNO_QUERY );
- if( xCTProp.is())
+ rtl::Reference< ChartType > xCT = new PieChartType();
+ xCT->setFastPropertyValue(
+ PROP_PIECHARTTYPE_USE_RINGS, getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS )); // "UseRings"
+ xCT->setFastPropertyValue(
+ PROP_PIECHARTTYPE_SUBTYPE, getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE )); // "SubType"
+ xCT->setFastPropertyValue(
+ PROP_PIECHARTTYPE_SPLIT_POS, getFastPropertyValue(
+ PROP_PIE_TEMPLATE_SPLIT_POS )); // "CompositeSize"
+ rCoordSys[0]->setChartTypes( std::vector{xCT} );
+
+ if( !aSeriesSeq.empty() )
{
- xCTProp->setPropertyValue(
- "UseRings", getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ));
- }
- Reference< chart2::XChartTypeContainer > xCTCnt( rCoordSys[0], uno::UNO_QUERY_THROW );
- xCTCnt->setChartTypes( Sequence< Reference< chart2::XChartType > >( &xCT, 1 ));
-
- if( aSeriesSeq.hasElements() )
- {
- Reference< chart2::XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- Sequence< Reference< chart2::XDataSeries > > aFlatSeriesSeq( FlattenSequence( aSeriesSeq ));
- xDSCnt->setDataSeries( aFlatSeriesSeq );
+ std::vector< rtl::Reference< DataSeries > > aFlatSeriesSeq = FlattenSequence( aSeriesSeq );
+ xCT->setDataSeries( aFlatSeriesSeq );
DataSeriesHelper::setStackModeAtSeries(
aFlatSeriesSeq, rCoordSys[0], getStackMode( 0 ));
@@ -298,16 +296,18 @@ void PieChartTypeTemplate::createChartTypes(
}
// ____ XChartTypeTemplate ____
-sal_Bool SAL_CALL PieChartTypeTemplate::matchesTemplate(
- const uno::Reference< chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties )
+bool PieChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties )
{
- bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
+ bool bResult = ChartTypeTemplate::matchesTemplate2( xDiagram, bAdaptProperties );
bool bTemplateUsesRings = false;
getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ) >>= bTemplateUsesRings;
chart2::PieChartOffsetMode ePieOffsetMode;
getFastPropertyValue( PROP_PIE_TEMPLATE_OFFSET_MODE ) >>= ePieOffsetMode;
+ chart2::PieChartSubType eTemplateSubType;
+ getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE ) >>= eTemplateSubType;
//check offset-mode
if( bResult )
@@ -316,21 +316,25 @@ sal_Bool SAL_CALL PieChartTypeTemplate::matchesTemplate(
{
double fOffset=0.0;
bool bAllOffsetsEqual = true;
+ sal_Int32 nOuterSeriesIndex = 0;
+
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ xDiagram->getDataSeries();
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ //tdf#108067 The outer series is the last series in OOXML-heavy environments
+ if( !officecfg::Office::Compatibility::View::ReverseXAxisOrientationDoughnutChart::get() )
+ nOuterSeriesIndex = aSeriesVec.size() - 1;
//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;
+ const rtl::Reference< DataSeries >& xSeries( aSeriesVec[nOuterSeriesIndex] );
+ xSeries->getPropertyValue( u"Offset"_ustr) >>= fOffset;
- //get AttributedDataPoints
+ // "AttributedDataPoints"
uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- if( xProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList )
+ if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList )
{
for(sal_Int32 nN=aAttributedDataPointIndexList.getLength();nN--;)
{
@@ -338,7 +342,7 @@ sal_Bool SAL_CALL PieChartTypeTemplate::matchesTemplate(
if(xPointProp.is())
{
double fPointOffset=0.0;
- if( xProp->getPropertyValue( "Offset") >>= fPointOffset )
+ if( xSeries->getPropertyValue( u"Offset"_ustr) >>= fPointOffset )
{
if( ! ::rtl::math::approxEqual( fPointOffset, fOffset ) )
{
@@ -371,35 +375,37 @@ sal_Bool SAL_CALL PieChartTypeTemplate::matchesTemplate(
//check UseRings
if( bResult )
{
- uno::Reference< beans::XPropertySet > xCTProp(
- DiagramHelper::getChartTypeByIndex( xDiagram, 0 ), uno::UNO_QUERY_THROW );
+ rtl::Reference< ChartType > xCTProp = xDiagram->getChartTypeByIndex( 0 );
bool bUseRings = false;
- if( xCTProp->getPropertyValue( "UseRings") >>= bUseRings )
+ if( xCTProp->getFastPropertyValue( PROP_PIECHARTTYPE_USE_RINGS ) >>= bUseRings ) // "UseRings"
{
bResult = ( bTemplateUsesRings == bUseRings );
}
}
+ if( bResult )
+ {
+ rtl::Reference< ChartType > xCTProp = xDiagram->getChartTypeByIndex( 0 );
+ chart2::PieChartSubType eSubType = chart2::PieChartSubType_NONE;
+ if( xCTProp->getFastPropertyValue( PROP_PIECHARTTYPE_SUBTYPE ) >>= eSubType )
+ {
+ bResult = ( eTemplateSubType == eSubType );
+ }
+ }
return bResult;
}
-Reference< chart2::XChartType > PieChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+rtl::Reference< ChartType > PieChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_PIE ), uno::UNO_QUERY_THROW );
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- "UseRings", getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ));
- }
-
+ xResult = new PieChartType();
+ xResult->setFastPropertyValue(
+ PROP_PIECHARTTYPE_USE_RINGS, getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS )); // "UseRings"
+ xResult->setFastPropertyValue(
+ PROP_PIECHARTTYPE_SUBTYPE, getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE ));
}
catch( const uno::Exception & )
{
@@ -409,25 +415,19 @@ Reference< chart2::XChartType > PieChartTypeTemplate::getChartTypeForIndex( sal_
return xResult;
}
-Reference< chart2::XChartType > SAL_CALL PieChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > PieChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_PIE ), uno::UNO_QUERY_THROW );
+ xResult = new PieChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- "UseRings", getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ));
- }
-
+ xResult->setFastPropertyValue(
+ PROP_PIECHARTTYPE_USE_RINGS, getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS )); // "UseRings"
+ xResult->setFastPropertyValue(
+ PROP_PIECHARTTYPE_SUBTYPE, getFastPropertyValue( PROP_PIE_TEMPLATE_SUB_PIE_TYPE ));
}
catch( const uno::Exception & )
{
@@ -437,23 +437,27 @@ Reference< chart2::XChartType > SAL_CALL PieChartTypeTemplate::getChartTypeForNe
return xResult;
}
-void SAL_CALL PieChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void PieChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
try
{
- uno::Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
-
bool bTemplateUsesRings = false;
+ sal_Int32 nOuterSeriesIndex = 0;
getFastPropertyValue( PROP_PIE_TEMPLATE_USE_RINGS ) >>= bTemplateUsesRings;
- if( nSeriesIndex == 0 ) //@todo in future this will depend on Orientation of the radius axis scale
+
+ //tdf#108067 The outer series is the last series in OOXML-heavy environments
+ if( !officecfg::Office::Compatibility::View::ReverseXAxisOrientationDoughnutChart::get() )
+ nOuterSeriesIndex = nSeriesCount - 1;
+
+ if( nSeriesIndex == nOuterSeriesIndex ) //@todo in future this will depend on Orientation of the radius axis scale
{
- const OUString aOffsetPropName( "Offset" );
+ static constexpr OUString aOffsetPropName( u"Offset"_ustr );
// get offset mode
chart2::PieChartOffsetMode ePieOffsetMode;
getFastPropertyValue( PROP_PIE_TEMPLATE_OFFSET_MODE ) >>= ePieOffsetMode;
@@ -464,7 +468,8 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
double fOffsetToSet = fDefaultOffset;
uno::Sequence< sal_Int32 > aAttributedDataPointIndexList;
- xProp->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList;
+ // "AttributedDataPoints"
+ xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList;
// determine whether to set the new offset
bool bSetOffset = ( ePieOffsetMode == chart2::PieChartOffsetMode_ALL_EXPLODED );
@@ -474,12 +479,12 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
// set offset to 0 if the offset was exactly "all exploded"
// before (individual offsets are kept)
double fOffset = 0.0;
- if( (xProp->getPropertyValue( aOffsetPropName ) >>= fOffset) &&
+ if( (xSeries->getPropertyValue( aOffsetPropName ) >>= fOffset) &&
::rtl::math::approxEqual( fOffset, fDefaultOffset ))
{
fOffsetToSet = 0.0;
bSetOffset = true;
- for( auto const & pointIndex : std::as_const(aAttributedDataPointIndexList) )
+ for (auto const& pointIndex : aAttributedDataPointIndexList)
{
uno::Reference< beans::XPropertySet > xPointProp(
xSeries->getDataPointByIndex( pointIndex ));
@@ -501,10 +506,10 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
if( bSetOffset )
{
// set the offset to the series and to the attributed data points
- xProp->setPropertyValue( aOffsetPropName, uno::Any( fOffsetToSet ));
+ xSeries->setPropertyValue( aOffsetPropName, uno::Any( fOffsetToSet ));
// remove hard attributes from data points
- for( auto const & pointIndex : std::as_const(aAttributedDataPointIndexList) )
+ for (auto const& pointIndex : aAttributedDataPointIndexList)
{
uno::Reference< beans::XPropertyState > xPointState(
xSeries->getDataPointByIndex( pointIndex ), uno::UNO_QUERY );
@@ -515,10 +520,10 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
}
// line style
- DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+ xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) );
// vary colors by point
- xProp->setPropertyValue( "VaryColorsByPoint", uno::Any( true ));
+ xSeries->setFastPropertyValue( PROP_DATASERIES_VARY_COLORS_BY_POINT, uno::Any( true )); // "VaryColorsByPoint"
}
catch( const uno::Exception & )
{
@@ -526,22 +531,21 @@ void SAL_CALL PieChartTypeTemplate::applyStyle(
}
}
-void SAL_CALL PieChartTypeTemplate::resetStyles( const Reference< chart2::XDiagram >& xDiagram )
+void PieChartTypeTemplate::resetStyles2( const rtl::Reference< ::chart::Diagram >& xDiagram )
{
// reset axes and grids
- Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY );
- if( xCooSysCnt.is())
+ if( xDiagram.is())
{
- const Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > aCooSysSeq( xDiagram->getBaseCoordinateSystems());
ChartTypeTemplate::createAxes( aCooSysSeq );
//reset scale orientation
- for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq )
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : aCooSysSeq )
{
try
{
- Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 0 /*nDimensionIndex*/,0 /*nAxisIndex*/
- , coords ) );
+ rtl::Reference< Axis > xAxis = AxisHelper::getAxis( 0 /*nDimensionIndex*/,0 /*nAxisIndex*/
+ , coords );
if( xAxis.is() )
{
chart2::ScaleData aScaleData( xAxis->getScaleData() );
@@ -564,40 +568,34 @@ void SAL_CALL PieChartTypeTemplate::resetStyles( const Reference< chart2::XDiagr
}
}
- ChartTypeTemplate::resetStyles( xDiagram );
+ ChartTypeTemplate::resetStyles2( xDiagram );
// vary colors by point,
// line style
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ xDiagram->getDataSeries();
uno::Any aLineStyleAny( drawing::LineStyle_NONE );
for (auto const& series : aSeriesVec)
{
- Reference< beans::XPropertyState > xState(series, uno::UNO_QUERY);
- if( xState.is())
+ series->setPropertyToDefault( u"VaryColorsByPoint"_ustr);
+ if( series->getPropertyValue( u"BorderStyle"_ustr) == aLineStyleAny )
{
- xState->setPropertyToDefault( "VaryColorsByPoint");
- Reference< beans::XPropertySet > xProp( xState, uno::UNO_QUERY );
- if( xProp.is() &&
- xProp->getPropertyValue( "BorderStyle") == aLineStyleAny )
- {
- xState->setPropertyToDefault( "BorderStyle");
- }
+ series->setPropertyToDefault( u"BorderStyle"_ustr);
}
}
//reset scene properties
- ThreeDHelper::setDefaultRotation( uno::Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY ), false );
+ xDiagram->setDefaultRotation( false );
}
// ____ XChartTypeTemplate ____
-void PieChartTypeTemplate::adaptDiagram( const uno::Reference< chart2::XDiagram >& xDiagram )
+void PieChartTypeTemplate::adaptDiagram( const rtl::Reference< ::chart::Diagram >& xDiagram )
{
if( !xDiagram.is() )
return;
//different default for scene geometry:
- ThreeDHelper::setDefaultRotation( uno::Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY ), true );
+ xDiagram->setDefaultRotation( true );
}
IMPLEMENT_FORWARD_XINTERFACE2( PieChartTypeTemplate, ChartTypeTemplate, OPropertySet )
diff --git a/chart2/source/model/template/PieChartTypeTemplate.hxx b/chart2/source/model/template/PieChartTypeTemplate.hxx
index f11099fdd9f5..d95b8c49d900 100644
--- a/chart2/source/model/template/PieChartTypeTemplate.hxx
+++ b/chart2/source/model/template/PieChartTypeTemplate.hxx
@@ -16,21 +16,19 @@
* 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
+#pragma once
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <com/sun/star/chart2/PieChartOffsetMode.hpp>
+#include <com/sun/star/chart2/PieChartSubType.hpp>
namespace chart
{
class PieChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -40,7 +38,9 @@ public:
const OUString & rServiceName,
css::chart2::PieChartOffsetMode eMode,
bool bRings,
- sal_Int32 nDim = 2 );
+ css::chart2::PieChartSubType eSubType,
+ sal_Int32 nCompositeSize,
+ sal_Int32 nDim );
virtual ~PieChartTypeTemplate() override;
/// merge XInterface implementations
@@ -50,63 +50,58 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence<
- css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ // ____ ChartTypeTemplate ____
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
- virtual void SAL_CALL resetStyles(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override;
+ virtual void resetStyles2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram ) override;
// ____ ChartTypeTemplate ____
virtual sal_Int32 getDimension() const override;
virtual void adaptDiagram(
- const css::uno::Reference< css::chart2::XDiagram > & xDiagram ) override;
+ const rtl::Reference< ::chart::Diagram > & xDiagram ) override;
virtual sal_Int32 getAxisCountByDimension( sal_Int32 nDimension ) override;
virtual void adaptAxes(
- const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & rCoordSys ) override;
+ const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > & rCoordSys ) override;
virtual void adaptScales(
- const css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > & aCooSysSeq,
+ const std::vector< rtl::Reference< ::chart::BaseCoordinateSystem > > & aCooSysSeq,
const css::uno::Reference< css::chart2::data::XLabeledDataSequence > & xCategories ) override;
virtual void createChartTypes(
- const css::uno::Sequence<
- css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XDataSeries > > >& aSeriesSeq,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XCoordinateSystem > > & rCoordSys,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XChartType > > & aOldChartTypesSeq
+ const std::vector<
+ std::vector<
+ rtl::Reference<
+ ::chart::DataSeries > > >& aSeriesSeq,
+ const std::vector<
+ rtl::Reference<
+ ::chart::BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq
) override;
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
};
} // 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
index 10798f9bd455..47698f448f24 100644
--- a/chart2/source/model/template/ScatterChartType.cxx
+++ b/chart2/source/model/template/ScatterChartType.cxx
@@ -21,6 +21,7 @@
#include <PropertyHelper.hxx>
#include <servicenames_charttypes.hxx>
#include <CartesianCoordinateSystem.hxx>
+#include <Axis.hxx>
#include <AxisHelper.hxx>
#include <AxisIndexDefines.hxx>
#include <unonames.hxx>
@@ -46,90 +47,57 @@ enum
PROP_SCATTERCHARTTYPE_SPLINE_ORDER
};
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+::chart::tPropertyValueMap& StaticScatterChartTypeDefaults()
{
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_STYLE,
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ []()
+ {
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_SCATTERCHARTTYPE_CURVE_STYLE, chart2::CurveStyle_LINES );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION, 20 );
+
+ // todo: check whether order 3 means polygons of order 3 or 2. (see
+ // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_SCATTERCHARTTYPE_SPLINE_ORDER, 3 );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
+}
+
+::cppu::OPropertyArrayHelper& StaticScatterChartTypeInfoHelper()
+{
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { CHART_UNONAME_CURVE_STYLE,
PROP_SCATTERCHARTTYPE_CURVE_STYLE,
cppu::UnoType<chart2::CurveStyle>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
-
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_RESOLUTION,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_CURVE_RESOLUTION,
PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_SPLINE_ORDER,
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_SPLINE_ORDER,
PROP_SCATTERCHARTTYPE_SPLINE_ORDER,
cppu::UnoType<sal_Int32>::get(),
beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
+ | beans::PropertyAttribute::MAYBEDEFAULT } };
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+ return comphelper::containerToSequence( aProperties );
+ }() );
+ return aPropHelper;
}
-struct StaticScatterChartTypeDefaults_Initializer
+const uno::Reference< beans::XPropertySetInfo >& StaticScatterChartTypeInfo()
{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCATTERCHARTTYPE_CURVE_STYLE, chart2::CurveStyle_LINES );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_CURVE_RESOLUTION, 20 );
-
- // todo: check whether order 3 means polygons of order 3 or 2. (see
- // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_SPLINE_ORDER, 3 );
- }
-};
-
-struct StaticScatterChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticScatterChartTypeDefaults_Initializer >
-{
-};
-
-struct StaticScatterChartTypeInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticScatterChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticScatterChartTypeInfoHelper_Initializer >
-{
-};
-
-struct StaticScatterChartTypeInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticScatterChartTypeInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
-
-struct StaticScatterChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticScatterChartTypeInfo_Initializer >
-{
-};
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticScatterChartTypeInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -154,16 +122,21 @@ uno::Reference< util::XCloneable > SAL_CALL ScatterChartType::createClone()
return uno::Reference< util::XCloneable >( new ScatterChartType( *this ));
}
+rtl::Reference< ChartType > ScatterChartType::cloneChartType() const
+{
+ return new ScatterChartType( *this );
+}
+
// ____ XChartType ____
-Reference< chart2::XCoordinateSystem > SAL_CALL
- ScatterChartType::createCoordinateSystem( ::sal_Int32 DimensionCount )
+rtl::Reference< ::chart::BaseCoordinateSystem >
+ ScatterChartType::createCoordinateSystem2( sal_Int32 DimensionCount )
{
- Reference< chart2::XCoordinateSystem > xResult(
- new CartesianCoordinateSystem( DimensionCount ));
+ rtl::Reference< CartesianCoordinateSystem > xResult =
+ new CartesianCoordinateSystem( DimensionCount );
for( sal_Int32 i=0; i<DimensionCount; ++i )
{
- Reference< chart2::XAxis > xAxis( xResult->getAxisByDimension( i, MAIN_AXIS_INDEX ) );
+ rtl::Reference< Axis > xAxis = xResult->getAxisByDimension2( i, MAIN_AXIS_INDEX );
if( !xAxis.is() )
{
OSL_FAIL("a created coordinate system should have an axis for each dimension");
@@ -192,38 +165,35 @@ OUString SAL_CALL ScatterChartType::getChartType()
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;
+ return { u"label"_ustr, u"values-x"_ustr, u"values-y"_ustr };
}
// ____ OPropertySet ____
-uno::Any ScatterChartType::GetDefaultValue( sal_Int32 nHandle ) const
+void ScatterChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticScatterChartTypeDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticScatterChartTypeDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL ScatterChartType::getInfoHelper()
{
- return *StaticScatterChartTypeInfoHelper::get();
+ return StaticScatterChartTypeInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL ScatterChartType::getPropertySetInfo()
{
- return *StaticScatterChartTypeInfo::get();
+ return StaticScatterChartTypeInfo();
}
OUString SAL_CALL ScatterChartType::getImplementationName()
{
- return "com.sun.star.comp.chart.ScatterChartType";
+ return u"com.sun.star.comp.chart.ScatterChartType"_ustr;
}
sal_Bool SAL_CALL ScatterChartType::supportsService( const OUString& rServiceName )
@@ -235,8 +205,8 @@ css::uno::Sequence< OUString > SAL_CALL ScatterChartType::getSupportedServiceNam
{
return {
CHART2_SERVICE_NAME_CHARTTYPE_SCATTER,
- "com.sun.star.chart2.ChartType",
- "com.sun.star.beans.PropertySet" };
+ u"com.sun.star.chart2.ChartType"_ustr,
+ u"com.sun.star.beans.PropertySet"_ustr };
}
} // namespace chart
diff --git a/chart2/source/model/template/ScatterChartType.hxx b/chart2/source/model/template/ScatterChartType.hxx
index e7f1e24de3cf..f490c108ca56 100644
--- a/chart2/source/model/template/ScatterChartType.hxx
+++ b/chart2/source/model/template/ScatterChartType.hxx
@@ -16,10 +16,9 @@
* 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
+#pragma once
-#include "ChartType.hxx"
+#include <ChartType.hxx>
namespace chart
{
@@ -37,6 +36,8 @@ public:
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() override;
+ virtual rtl::Reference<ChartType> cloneChartType() const override;
+
private:
explicit ScatterChartType( const ScatterChartType & rOther );
@@ -44,11 +45,9 @@ private:
virtual OUString SAL_CALL getChartType() override;
virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedMandatoryRoles() override;
- virtual css::uno::Reference< css::chart2::XCoordinateSystem > SAL_CALL
- createCoordinateSystem( ::sal_Int32 DimensionCount ) override;
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
// ____ OPropertySet ____
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
@@ -59,11 +58,11 @@ private:
// ____ XCloneable ____
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override;
+
+ virtual rtl::Reference< ::chart::BaseCoordinateSystem >
+ createCoordinateSystem2( sal_Int32 DimensionCount ) override;
};
} // namespace chart
-// 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
index e0dc1cd1183a..5ba115af253c 100644
--- a/chart2/source/model/template/ScatterChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ScatterChartTypeTemplate.cxx
@@ -18,9 +18,11 @@
*/
#include "ScatterChartTypeTemplate.hxx"
+#include "ScatterChartType.hxx"
#include "XYDataInterpreter.hxx"
-#include <DiagramHelper.hxx>
-#include <servicenames_charttypes.hxx>
+#include <ChartType.hxx>
+#include <Diagram.hxx>
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <PropertyHelper.hxx>
#include <unonames.hxx>
@@ -31,8 +33,7 @@
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <algorithm>
@@ -53,89 +54,58 @@ enum
};
-void lcl_AddPropertiesToVector(
- std::vector< Property > & rOutProperties )
+const ::chart::tPropertyValueMap& StaticScatterChartTypeTemplateDefaults()
{
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_STYLE,
- PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE,
- cppu::UnoType<chart2::CurveStyle>::get(),
- beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_CURVE_RESOLUTION,
- PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION,
- cppu::UnoType<sal_Int32>::get(),
- beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
- rOutProperties.emplace_back( CHART_UNONAME_SPLINE_ORDER,
- PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER,
- cppu::UnoType<sal_Int32>::get(),
- beans::PropertyAttribute::BOUND
- | beans::PropertyAttribute::MAYBEDEFAULT );
+ static const ::chart::tPropertyValueMap aStaticDefaults =
+ []()
+ {
+ ::chart::tPropertyValueMap aOutMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 );
+
+ // todo: check whether order 3 means polygons of order 3 or 2. (see
+ // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 );
+ return aOutMap;
+ }();
+ return aStaticDefaults;
}
-struct StaticScatterChartTypeTemplateDefaults_Initializer
-{
- ::chart::tPropertyValueMap* operator()()
- {
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE, chart2::CurveStyle_LINES );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION, 20 );
-
- // todo: check whether order 3 means polygons of order 3 or 2. (see
- // http://www.people.nnov.ru/fractal/Splines/Basis.htm )
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER, 3 );
- }
-};
-
-struct StaticScatterChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticScatterChartTypeTemplateDefaults_Initializer >
-{
-};
-
-struct StaticScatterChartTypeTemplateInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
-
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-
-};
-
-struct StaticScatterChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticScatterChartTypeTemplateInfoHelper_Initializer >
-{
-};
-struct StaticScatterChartTypeTemplateInfo_Initializer
+::cppu::OPropertyArrayHelper& StaticScatterChartTypeTemplateInfoHelper()
{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticScatterChartTypeTemplateInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
-};
+ static ::cppu::OPropertyArrayHelper aPropHelper(
+ []()
+ {
+ std::vector< css::beans::Property > aProperties {
+ { CHART_UNONAME_CURVE_STYLE,
+ PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE,
+ cppu::UnoType<chart2::CurveStyle>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_CURVE_RESOLUTION,
+ PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT },
+ { CHART_UNONAME_SPLINE_ORDER,
+ PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER,
+ cppu::UnoType<sal_Int32>::get(),
+ beans::PropertyAttribute::BOUND
+ | beans::PropertyAttribute::MAYBEDEFAULT } };
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
+ return comphelper::containerToSequence( aProperties );
+ }() );
+ return aPropHelper;
+}
-struct StaticScatterChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticScatterChartTypeTemplateInfo_Initializer >
+const uno::Reference< beans::XPropertySetInfo >& StaticScatterChartTypeTemplateInfo()
{
-};
+ static const uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticScatterChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
+}
} // anonymous namespace
@@ -150,7 +120,6 @@ ScatterChartTypeTemplate::ScatterChartTypeTemplate(
bool bHasLines /* = true */,
sal_Int32 nDim /* = 2 */ ) :
ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex ),
m_bHasSymbols( bSymbols ),
m_bHasLines( bHasLines ),
m_nDim( nDim )
@@ -163,24 +132,25 @@ ScatterChartTypeTemplate::~ScatterChartTypeTemplate()
{}
// ____ OPropertySet ____
-uno::Any ScatterChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void ScatterChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticScatterChartTypeTemplateDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticScatterChartTypeTemplateDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL ScatterChartTypeTemplate::getInfoHelper()
{
- return *StaticScatterChartTypeTemplateInfoHelper::get();
+ return StaticScatterChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL ScatterChartTypeTemplate::getPropertySetInfo()
{
- return *StaticScatterChartTypeTemplateInfo::get();
+ return StaticScatterChartTypeTemplateInfo();
}
sal_Int32 ScatterChartTypeTemplate::getDimension() const
@@ -195,23 +165,21 @@ StackMode ScatterChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex *
return StackMode::NONE;
}
-void SAL_CALL ScatterChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void ScatterChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
try
{
- Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY_THROW );
-
- DataSeriesHelper::switchSymbolsOnOrOff( xProp, m_bHasSymbols, nSeriesIndex );
- DataSeriesHelper::switchLinesOnOrOff( xProp, m_bHasLines );
- DataSeriesHelper::makeLinesThickOrThin( xProp, m_nDim==2 );
+ xSeries->switchSymbolsOnOrOff( m_bHasSymbols, nSeriesIndex );
+ xSeries->switchLinesOnOrOff( m_bHasLines );
+ xSeries->makeLinesThickOrThin( m_nDim==2 );
if( m_nDim==3 )
- DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+ xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) );
}
catch( const uno::Exception & )
{
@@ -225,11 +193,11 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::supportsCategories()
return false;
}
-sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
- const Reference< chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties )
+bool ScatterChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties )
{
- bool bResult = ChartTypeTemplate::matchesTemplate( xDiagram, bAdaptProperties );
+ bool bResult = ChartTypeTemplate::matchesTemplate2( xDiagram, bAdaptProperties );
// check symbol-style and line-style
// for a template with symbols (or with lines) it is ok, if there is at least one series
@@ -239,8 +207,8 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
bool bSymbolFound = false;
bool bLineFound = false;
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ xDiagram->getDataSeries();
for (auto const& series : aSeriesVec)
{
@@ -248,9 +216,8 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
{
chart2::Symbol aSymbProp;
drawing::LineStyle eLineStyle;
- Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY_THROW);
- bool bCurrentHasSymbol = (xProp->getPropertyValue( "Symbol") >>= aSymbProp) &&
+ bool bCurrentHasSymbol = (series->getPropertyValue( u"Symbol"_ustr) >>= aSymbProp) &&
(aSymbProp.Style != chart2::SymbolStyle_NONE);
if( bCurrentHasSymbol )
@@ -262,7 +229,7 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
break;
}
- bool bCurrentHasLine = (xProp->getPropertyValue( "LineStyle") >>= eLineStyle) &&
+ bool bCurrentHasLine = (series->getPropertyValue( u"LineStyle"_ustr) >>= eLineStyle) &&
( eLineStyle != drawing::LineStyle_NONE );
if( bCurrentHasLine )
@@ -296,9 +263,8 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
{
try
{
- uno::Reference< beans::XPropertySet > xChartTypeProp(
- DiagramHelper::getChartTypeByIndex( xDiagram, 0 ),
- uno::UNO_QUERY_THROW );
+ rtl::Reference< ChartType > xChartTypeProp =
+ xDiagram->getChartTypeByIndex(0);
setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_STYLE) );
setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION, xChartTypeProp->getPropertyValue(CHART_UNONAME_CURVE_RESOLUTION) );
setFastPropertyValue_NoBroadcast( PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER, xChartTypeProp->getPropertyValue(CHART_UNONAME_SPLINE_ORDER) );
@@ -312,27 +278,20 @@ sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< chart2::XChartType > ScatterChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
+rtl::Reference< ChartType > ScatterChartTypeTemplate::getChartTypeForIndex( sal_Int32 /*nChartTypeIndex*/ )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_SCATTER ), uno::UNO_QUERY_THROW );
-
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER ));
- }
+ xResult = new ScatterChartType();
+
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER ));
}
catch( const uno::Exception & )
{
@@ -342,30 +301,23 @@ Reference< chart2::XChartType > ScatterChartTypeTemplate::getChartTypeForIndex(
return xResult;
}
-Reference< chart2::XChartType > SAL_CALL ScatterChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > ScatterChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_SCATTER ), uno::UNO_QUERY_THROW );
+ xResult = new ScatterChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
- Reference< beans::XPropertySet > xCTProp( xResult, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
- xCTProp->setPropertyValue(
- CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER ));
- }
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_STYLE, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_STYLE ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_CURVE_RESOLUTION, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_CURVE_RESOLUTION ));
+ xResult->setPropertyValue(
+ CHART_UNONAME_SPLINE_ORDER, getFastPropertyValue( PROP_SCATTERCHARTTYPE_TEMPLATE_SPLINE_ORDER ));
}
catch( const uno::Exception & )
{
@@ -375,7 +327,7 @@ Reference< chart2::XChartType > SAL_CALL ScatterChartTypeTemplate::getChartTypeF
return xResult;
}
-Reference< chart2::XDataInterpreter > SAL_CALL ScatterChartTypeTemplate::getDataInterpreter()
+rtl::Reference< DataInterpreter > ScatterChartTypeTemplate::getDataInterpreter2()
{
if( ! m_xDataInterpreter.is())
m_xDataInterpreter.set( new XYDataInterpreter );
diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.hxx b/chart2/source/model/template/ScatterChartTypeTemplate.hxx
index ee32e200f551..0d7aec7ad188 100644
--- a/chart2/source/model/template/ScatterChartTypeTemplate.hxx
+++ b/chart2/source/model/template/ScatterChartTypeTemplate.hxx
@@ -16,19 +16,16 @@
* 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
+#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
namespace chart
{
class ScatterChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -48,30 +45,30 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo() override;
- // ____ XChartTypeTemplate ____
+ // ____ ChartTypeTemplate ____
virtual sal_Bool SAL_CALL supportsCategories() override;
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence<
- css::uno::Reference< css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual css::uno::Reference< css::chart2::XDataInterpreter > SAL_CALL getDataInterpreter() override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual rtl::Reference< ::chart::DataInterpreter > getDataInterpreter2() override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeGroupIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
// ____ ChartTypeTemplate ____
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
virtual sal_Int32 getDimension() const override;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const override;
@@ -84,7 +81,4 @@ private:
} // 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
index 7eb0e1ca51da..b9f141831d08 100644
--- a/chart2/source/model/template/StockChartTypeTemplate.cxx
+++ b/chart2/source/model/template/StockChartTypeTemplate.cxx
@@ -18,25 +18,25 @@
*/
#include "StockChartTypeTemplate.hxx"
+#include "ColumnChartType.hxx"
+#include "CandleStickChartType.hxx"
+#include "LineChartType.hxx"
+#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include "StockDataInterpreter.hxx"
-#include <DiagramHelper.hxx>
+#include <Diagram.hxx>
+#include <BaseCoordinateSystem.hxx>
#include <servicenames_charttypes.hxx>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <PropertyHelper.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
-#include <vector>
#include <algorithm>
+#include <cstddef>
using namespace ::com::sun::star;
-using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -78,65 +78,41 @@ void lcl_AddPropertiesToVector(
| 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 >
+::chart::tPropertyValueMap& GetStaticStockChartTypeTemplateDefaults()
{
+ static ::chart::tPropertyValueMap aStaticDefaults =
+ [](){
+ ::chart::tPropertyValueMap aTmp;
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_STOCKCHARTTYPE_TEMPLATE_OPEN, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE, false );
+ return aTmp;
+ }();
+ return aStaticDefaults;
};
-struct StaticStockChartTypeTemplateInfoHelper_Initializer
+::cppu::OPropertyArrayHelper& GetStaticStockChartTypeTemplateInfoHelper()
{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
+ static ::cppu::OPropertyArrayHelper aPropHelper =
+ [](){
+ std::vector< css::beans::Property > aProperties;
+ lcl_AddPropertiesToVector( aProperties );
-private:
- static Sequence< Property > lcl_GetPropertySequence()
- {
- std::vector< css::beans::Property > aProperties;
- lcl_AddPropertiesToVector( aProperties );
+ std::sort( aProperties.begin(), aProperties.end(),
+ ::chart::PropertyNameLess() );
- std::sort( aProperties.begin(), aProperties.end(),
- ::chart::PropertyNameLess() );
-
- return comphelper::containerToSequence( aProperties );
- }
-};
-
-struct StaticStockChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticStockChartTypeTemplateInfoHelper_Initializer >
-{
+ return comphelper::containerToSequence( aProperties );
+ }();
+ return aPropHelper;
};
-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 >
+uno::Reference< beans::XPropertySetInfo >& GetStaticStockChartTypeTemplateInfo()
{
+ static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(GetStaticStockChartTypeTemplateInfoHelper() ) );
+ return xPropertySetInfo;
};
} // anonymous namespace
@@ -151,7 +127,6 @@ StockChartTypeTemplate::StockChartTypeTemplate(
StockVariant eVariant,
bool bJapaneseStyle ) :
ChartTypeTemplate( xContext, rServiceName ),
- ::property::OPropertySet( m_aMutex ),
m_eStockVariant( eVariant )
{
setFastPropertyValue_NoBroadcast(
@@ -169,25 +144,27 @@ StockChartTypeTemplate::StockChartTypeTemplate(
StockChartTypeTemplate::~StockChartTypeTemplate()
{}
+
// ____ OPropertySet ____
-uno::Any StockChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const
+void StockChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticStockChartTypeTemplateDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = GetStaticStockChartTypeTemplateDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
- return uno::Any();
- return (*aFound).second;
+ rAny.clear();
+ else
+ rAny = (*aFound).second;
}
::cppu::IPropertyArrayHelper & SAL_CALL StockChartTypeTemplate::getInfoHelper()
{
- return *StaticStockChartTypeTemplateInfoHelper::get();
+ return GetStaticStockChartTypeTemplateInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL StockChartTypeTemplate::getPropertySetInfo()
{
- return *StaticStockChartTypeTemplateInfo::get();
+ return GetStaticStockChartTypeTemplateInfo();
}
sal_Int32 StockChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension )
@@ -206,13 +183,13 @@ sal_Int32 StockChartTypeTemplate::getAxisCountByDimension( sal_Int32 nDimension
return bHasVolume ? 2 : 1;
}
-void SAL_CALL StockChartTypeTemplate::applyStyle(
- const Reference< chart2::XDataSeries >& xSeries,
+void StockChartTypeTemplate::applyStyle2(
+ const rtl::Reference< DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount )
{
- ChartTypeTemplate::applyStyle( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
+ ChartTypeTemplate::applyStyle2( xSeries, nChartTypeIndex, nSeriesIndex, nSeriesCount );
try
{
sal_Int32 nNewAxisIndex = 0;
@@ -222,25 +199,20 @@ void SAL_CALL StockChartTypeTemplate::applyStyle(
if( bHasVolume && nChartTypeIndex != 0 )
nNewAxisIndex = 1;
- Reference< beans::XPropertySet > xProp( xSeries, uno::UNO_QUERY );
- if( xProp.is() )
- xProp->setPropertyValue( "AttachedAxisIndex", uno::Any( nNewAxisIndex ) );
+ xSeries->setPropertyValue( u"AttachedAxisIndex"_ustr, uno::Any( nNewAxisIndex ) );
if( bHasVolume && nChartTypeIndex==0 )
{
//switch lines off for volume bars
- DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", uno::Any( drawing::LineStyle_NONE ) );
+ xSeries->setPropertyAlsoToAllAttributedDataPoints( u"BorderStyle"_ustr, 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 ));
- }
+ drawing::LineStyle eStyle = drawing::LineStyle_NONE;
+ xSeries->getPropertyValue( u"LineStyle"_ustr ) >>= eStyle;
+ if( eStyle == drawing::LineStyle_NONE )
+ xSeries->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_SOLID ));
}
}
@@ -250,66 +222,57 @@ void SAL_CALL StockChartTypeTemplate::applyStyle(
}
}
-void SAL_CALL StockChartTypeTemplate::resetStyles(
- const Reference< chart2::XDiagram >& xDiagram )
+void StockChartTypeTemplate::resetStyles2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram )
{
- ChartTypeTemplate::resetStyles( xDiagram );
+ ChartTypeTemplate::resetStyles2( xDiagram );
if( getDimension() == 3 )
{
- std::vector< Reference< chart2::XDataSeries > > aSeriesVec(
- DiagramHelper::getDataSeriesFromDiagram( xDiagram ));
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec =
+ xDiagram->getDataSeries();
for (auto const& series : aSeriesVec)
{
- Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY);
- if( xProp.is() )
- xProp->setPropertyValue( "AttachedAxisIndex", uno::Any( sal_Int32(0) ) );
+ series->setPropertyValue( u"AttachedAxisIndex"_ustr, uno::Any( sal_Int32(0) ) );
}
}
- DiagramHelper::setVertical( xDiagram, false );
+ xDiagram->setVertical( false );
}
-Reference< XChartType > StockChartTypeTemplate::getChartTypeForIndex( sal_Int32 nChartTypeIndex )
+rtl::Reference< ChartType > StockChartTypeTemplate::getChartTypeForIndex( sal_Int32 nChartTypeIndex )
{
- Reference< XChartType > xCT;
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY );
- if(xFact.is())
+ rtl::Reference< ChartType > xCT;
+ bool bHasVolume = false;
+ getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME ) >>= bHasVolume;
+ if( bHasVolume )
{
- bool bHasVolume = false;
- getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_VOLUME ) >>= bHasVolume;
- if( bHasVolume )
- {
- if( nChartTypeIndex == 0 )
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY );
- else if( nChartTypeIndex == 1 )
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ), uno::UNO_QUERY );
- else
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY );
- }
+ if( nChartTypeIndex == 0 )
+ xCT = new ColumnChartType();
+ else if( nChartTypeIndex == 1 )
+ xCT = new CandleStickChartType();
else
- {
- if( nChartTypeIndex == 0 )
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ), uno::UNO_QUERY );
- else
- xCT.set( xFact->createInstance( CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY );
- }
+ xCT = new LineChartType();
+ }
+ else
+ {
+ if( nChartTypeIndex == 0 )
+ xCT = new CandleStickChartType();
+ else
+ xCT = new LineChartType();
}
return xCT;
}
void StockChartTypeTemplate::createChartTypes(
- const Sequence< Sequence< Reference< XDataSeries > > > & aSeriesSeq,
- const Sequence< Reference< XCoordinateSystem > > & rCoordSys,
- const Sequence< Reference< XChartType > >& /* aOldChartTypesSeq */ )
+ const std::vector< std::vector< rtl::Reference< DataSeries > > > & aSeriesSeq,
+ const std::vector< rtl::Reference< BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > >& /* aOldChartTypesSeq */ )
{
- if( !rCoordSys.hasElements() )
+ if( rCoordSys.empty() )
return;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
bool bHasVolume = false;
bool bShowFirst = false;
bool bJapaneseStyle = false;
@@ -320,63 +283,49 @@ void StockChartTypeTemplate::createChartTypes(
getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE ) >>= bJapaneseStyle;
getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_LOW_HIGH ) >>= bShowHighLow;
- sal_Int32 nSeriesIndex = 0;
+ std::size_t nSeriesIndex = 0;
- std::vector< Reference< chart2::XChartType > > aChartTypeVec;
+ std::vector< rtl::Reference< ChartType > > aChartTypeVec;
// Bars (Volume)
if( bHasVolume )
{
// chart type
- Reference< XChartType > xCT(
- xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_COLUMN ), uno::UNO_QUERY_THROW );
+ rtl::Reference< ChartType > xCT = new ColumnChartType();
aChartTypeVec.push_back( xCT );
- if( aSeriesSeq.getLength() > nSeriesIndex &&
- aSeriesSeq[nSeriesIndex].hasElements() )
+ if( aSeriesSeq.size() > nSeriesIndex &&
+ !aSeriesSeq[nSeriesIndex].empty() )
{
- Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- xDSCnt->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
+ xCT->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
}
++nSeriesIndex;
}
- Reference< XChartType > xCT(
- xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ), uno::UNO_QUERY_THROW );
+ rtl::Reference< ChartType > xCT = new CandleStickChartType();
aChartTypeVec.push_back( xCT );
- Reference< beans::XPropertySet > xCTProp( xCT, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- xCTProp->setPropertyValue( "Japanese", uno::Any( bJapaneseStyle ));
- xCTProp->setPropertyValue( "ShowFirst", uno::Any( bShowFirst ));
- xCTProp->setPropertyValue( "ShowHighLow", uno::Any( bShowHighLow ));
- }
+ xCT->setPropertyValue( u"Japanese"_ustr, uno::Any( bJapaneseStyle ));
+ xCT->setPropertyValue( u"ShowFirst"_ustr, uno::Any( bShowFirst ));
+ xCT->setPropertyValue( u"ShowHighLow"_ustr, uno::Any( bShowHighLow ));
- if( aSeriesSeq.getLength() > nSeriesIndex &&
- aSeriesSeq[ nSeriesIndex ].hasElements() )
+ if( aSeriesSeq.size() > nSeriesIndex &&
+ !aSeriesSeq[ nSeriesIndex ].empty() )
{
- Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- xDSCnt->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
+ xCT->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
}
++nSeriesIndex;
// Lines (remaining series)
- if( aSeriesSeq.getLength() > nSeriesIndex &&
- aSeriesSeq[ nSeriesIndex ].hasElements() )
+ if( aSeriesSeq.size() > nSeriesIndex &&
+ !aSeriesSeq[ nSeriesIndex ].empty() )
{
- xCT.set(
- xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
+ xCT = new LineChartType();
aChartTypeVec.push_back( xCT );
- Reference< XDataSeriesContainer > xDSCnt( xCT, uno::UNO_QUERY_THROW );
- xDSCnt->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
+ xCT->setDataSeries( aSeriesSeq[ nSeriesIndex ] );
}
- Reference< XChartTypeContainer > xCTCnt( rCoordSys[ 0 ], uno::UNO_QUERY_THROW );
- xCTCnt->setChartTypes( comphelper::containerToSequence(aChartTypeVec) );
+ rCoordSys[ 0 ]->setChartTypes( aChartTypeVec );
}
catch( const uno::Exception & )
{
@@ -384,10 +333,10 @@ void StockChartTypeTemplate::createChartTypes(
}
}
-// ____ XChartTypeTemplate ____
-sal_Bool SAL_CALL StockChartTypeTemplate::matchesTemplate(
- const uno::Reference< XDiagram >& xDiagram,
- sal_Bool /* bAdaptProperties */ )
+// ____ ChartTypeTemplate ____
+bool StockChartTypeTemplate::matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool /* bAdaptProperties */ )
{
bool bResult = false;
@@ -402,34 +351,25 @@ sal_Bool SAL_CALL StockChartTypeTemplate::matchesTemplate(
getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_OPEN ) >>= bHasOpenValue;
getFastPropertyValue( PROP_STOCKCHARTTYPE_TEMPLATE_JAPANESE ) >>= bHasJapaneseStyle;
- Reference< chart2::XChartType > xVolumeChartType;
- Reference< chart2::XChartType > xCandleStickChartType;
- Reference< chart2::XChartType > xLineChartType;
+ rtl::Reference< ChartType > xVolumeChartType;
+ rtl::Reference< ChartType > xCandleStickChartType;
+ rtl::Reference< ChartType > xLineChartType;
sal_Int32 nNumberOfChartTypes = 0;
- Reference< XCoordinateSystemContainer > xCooSysCnt(
- xDiagram, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XCoordinateSystem > > aCooSysSeq(
- xCooSysCnt->getCoordinateSystems());
- for( Reference< XCoordinateSystem > const & coords : aCooSysSeq )
+ for( rtl::Reference< BaseCoordinateSystem > const & coords : xDiagram->getBaseCoordinateSystems() )
{
- Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW );
- const Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes());
- for( Reference< XChartType > const & chartType : aChartTypeSeq )
+ for( rtl::Reference< ChartType > const & chartType : coords->getChartTypes2() )
{
- if( chartType.is())
- {
- ++nNumberOfChartTypes;
- if( nNumberOfChartTypes > 3 )
- break;
- OUString aCTService = chartType->getChartType();
- if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
- xVolumeChartType.set( chartType );
- else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
- xCandleStickChartType.set( chartType );
- else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
- xLineChartType.set( chartType );
- }
+ ++nNumberOfChartTypes;
+ if( nNumberOfChartTypes > 3 )
+ break;
+ OUString aCTService = chartType->getChartType();
+ if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )
+ xVolumeChartType = chartType;
+ else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )
+ xCandleStickChartType = chartType;
+ else if( aCTService == CHART2_SERVICE_NAME_CHARTTYPE_LINE )
+ xLineChartType = chartType;
}
if( nNumberOfChartTypes > 3 )
break;
@@ -440,18 +380,14 @@ sal_Bool SAL_CALL StockChartTypeTemplate::matchesTemplate(
bResult = true;
// check for japanese style
- Reference< beans::XPropertySet > xCTProp( xCandleStickChartType, uno::UNO_QUERY );
- if( xCTProp.is())
- {
- bool bJapaneseProp = false;
- xCTProp->getPropertyValue( "Japanese") >>= bJapaneseProp;
- bResult = bResult && ( bHasJapaneseStyle == bJapaneseProp );
-
- // in old chart japanese == showFirst
- bool bShowFirstProp = false;
- xCTProp->getPropertyValue( "ShowFirst") >>= bShowFirstProp;
- bResult = bResult && ( bHasOpenValue == bShowFirstProp );
- }
+ bool bJapaneseProp = false;
+ xCandleStickChartType->getPropertyValue( u"Japanese"_ustr) >>= bJapaneseProp;
+ bResult = bResult && ( bHasJapaneseStyle == bJapaneseProp );
+
+ // in old chart japanese == showFirst
+ bool bShowFirstProp = false;
+ xCandleStickChartType->getPropertyValue( u"ShowFirst"_ustr) >>= bShowFirstProp;
+ bResult = bResult && ( bHasOpenValue == bShowFirstProp );
}
}
catch( const uno::Exception & )
@@ -462,17 +398,14 @@ sal_Bool SAL_CALL StockChartTypeTemplate::matchesTemplate(
return bResult;
}
-Reference< XChartType > SAL_CALL StockChartTypeTemplate::getChartTypeForNewSeries(
- const uno::Sequence< Reference< chart2::XChartType > >& aFormerlyUsedChartTypes )
+rtl::Reference< ChartType > StockChartTypeTemplate::getChartTypeForNewSeries2(
+ const std::vector< rtl::Reference< ChartType > >& aFormerlyUsedChartTypes )
{
- Reference< chart2::XChartType > xResult;
+ rtl::Reference< ChartType > xResult;
try
{
- Reference< lang::XMultiServiceFactory > xFact(
- GetComponentContext()->getServiceManager(), uno::UNO_QUERY_THROW );
- xResult.set( xFact->createInstance(
- CHART2_SERVICE_NAME_CHARTTYPE_LINE ), uno::UNO_QUERY_THROW );
+ xResult = new LineChartType();
ChartTypeTemplate::copyPropertiesFromOldToNewCoordinateSystem( aFormerlyUsedChartTypes, xResult );
}
catch( const uno::Exception & )
@@ -483,7 +416,7 @@ Reference< XChartType > SAL_CALL StockChartTypeTemplate::getChartTypeForNewSerie
return xResult;
}
-Reference< XDataInterpreter > SAL_CALL StockChartTypeTemplate::getDataInterpreter()
+rtl::Reference< DataInterpreter > StockChartTypeTemplate::getDataInterpreter2()
{
if( ! m_xDataInterpreter.is())
m_xDataInterpreter.set( new StockDataInterpreter( m_eStockVariant ) );
diff --git a/chart2/source/model/template/StockChartTypeTemplate.hxx b/chart2/source/model/template/StockChartTypeTemplate.hxx
index 6a05450f8194..aed35a000919 100644
--- a/chart2/source/model/template/StockChartTypeTemplate.hxx
+++ b/chart2/source/model/template/StockChartTypeTemplate.hxx
@@ -16,19 +16,16 @@
* 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
+#pragma once
-#include "ChartTypeTemplate.hxx"
+#include <ChartTypeTemplate.hxx>
#include <OPropertySet.hxx>
-#include <MutexContainer.hxx>
#include <comphelper/uno3.hxx>
namespace chart
{
class StockChartTypeTemplate :
- public MutexContainer,
public ChartTypeTemplate,
public ::property::OPropertySet
{
@@ -63,7 +60,7 @@ public:
protected:
// ____ OPropertySet ____
- virtual css::uno::Any GetDefaultValue( sal_Int32 nHandle ) const override;
+ virtual void GetDefaultValue( sal_Int32 nHandle, css::uno::Any& rAny ) const override;
virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
// ____ XPropertySet ____
@@ -71,40 +68,37 @@ protected:
getPropertySetInfo() override;
// ____ XChartTypeTemplate ____
- virtual sal_Bool SAL_CALL matchesTemplate(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram,
- sal_Bool bAdaptProperties ) override;
- virtual css::uno::Reference< css::chart2::XChartType > SAL_CALL
- getChartTypeForNewSeries( const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XChartType > >& aFormerlyUsedChartTypes ) override;
- virtual css::uno::Reference< css::chart2::XDataInterpreter > SAL_CALL getDataInterpreter() override;
- virtual void SAL_CALL applyStyle(
- const css::uno::Reference< css::chart2::XDataSeries >& xSeries,
+ virtual bool matchesTemplate2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram,
+ bool bAdaptProperties ) override;
+ virtual rtl::Reference< ::chart::ChartType >
+ getChartTypeForNewSeries2( const std::vector<
+ rtl::Reference< ::chart::ChartType > >& aFormerlyUsedChartTypes ) override;
+ virtual rtl::Reference< ::chart::DataInterpreter > getDataInterpreter2() override;
+ virtual void applyStyle2(
+ const rtl::Reference< ::chart::DataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
::sal_Int32 nSeriesIndex,
::sal_Int32 nSeriesCount ) override;
- virtual void SAL_CALL resetStyles(
- const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override;
+ virtual void resetStyles2(
+ const rtl::Reference< ::chart::Diagram >& xDiagram ) override;
// ChartTypeTemplate
virtual sal_Int32 getAxisCountByDimension( sal_Int32 nDimension ) override;
// ____ ChartTypeTemplate ____
virtual void createChartTypes(
- const css::uno::Sequence<
- css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XDataSeries > > >& aSeriesSeq,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XCoordinateSystem > > & rCoordSys,
- const css::uno::Sequence<
- css::uno::Reference<
- css::chart2::XChartType > > & aOldChartTypesSeq
+ const std::vector<
+ std::vector<
+ rtl::Reference<
+ ::chart::DataSeries > > >& aSeriesSeq,
+ const std::vector<
+ rtl::Reference<
+ ::chart::BaseCoordinateSystem > > & rCoordSys,
+ const std::vector< rtl::Reference< ChartType > > & aOldChartTypesSeq
) override;
- virtual css::uno::Reference< css::chart2::XChartType >
+ virtual rtl::Reference< ::chart::ChartType >
getChartTypeForIndex( sal_Int32 nChartTypeIndex ) override;
private:
@@ -114,7 +108,4 @@ private:
} // 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
index 15c2891975ad..75e0bb439c72 100644
--- a/chart2/source/model/template/StockDataInterpreter.cxx
+++ b/chart2/source/model/template/StockDataInterpreter.cxx
@@ -17,14 +17,17 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cstddef>
+
#include "StockDataInterpreter.hxx"
+#include "StockChartTypeTemplate.hxx"
#include <DataSeries.hxx>
-#include <com/sun/star/chart2/data/XDataSink.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
-using namespace ::std;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -35,7 +38,6 @@ namespace chart
// explicit
StockDataInterpreter::StockDataInterpreter(
StockChartTypeTemplate::StockVariant eVariant ) :
- DataInterpreter(),
m_eStockVariant( eVariant )
{}
@@ -43,17 +45,17 @@ StockDataInterpreter::~StockDataInterpreter()
{}
// ____ XDataInterpreter ____
-InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
+InterpretedData StockDataInterpreter::interpretDataSource(
const Reference< data::XDataSource >& xSource,
const Sequence< beans::PropertyValue >& rArguments,
- const Sequence< Reference< XDataSeries > >& rSeriesToReUse )
+ const std::vector< rtl::Reference< ::chart::DataSeries > >& rSeriesToReUse )
{
if( ! xSource.is())
return InterpretedData();
- Reference< data::XLabeledDataSequence > xCategories;
- Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
- const sal_Int32 nDataCount( aData.getLength());
+ uno::Reference< chart2::data::XLabeledDataSequence > xCategories;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aData = DataInterpreter::getDataSequences(xSource);
+ const sal_Int32 nDataCount( aData.size());
// sub-type properties
const StockChartTypeTemplate::StockVariant eVar( GetStockVariant());
@@ -87,14 +89,15 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
sal_Int32 nNumberOfGroups( bHasVolume ? 2 : 1 );
// sequences of data::XLabeledDataSequence per series per group
- Sequence< Sequence< Sequence< Reference< data::XLabeledDataSequence > > > > aSequences( nNumberOfGroups );
- sal_Int32 nBarGroupIndex( 0 );
- sal_Int32 nCandleStickGroupIndex( nNumberOfGroups - 1 );
+ std::vector< std::vector< std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > > > aSequences( nNumberOfGroups );
+ const sal_Int32 nBarGroupIndex( 0 );
+ const sal_Int32 nCandleStickGroupIndex( nNumberOfGroups - 1 );
// allocate space for labeled sequences
if( nRemaining > 0 )
++nCandleStickSeries;
- aSequences[nCandleStickGroupIndex].realloc( nCandleStickSeries );
+ aSequences[nCandleStickGroupIndex].resize( nCandleStickSeries );
+ auto & pCandleStickGroup = aSequences[nCandleStickGroupIndex];
if( bHasVolume )
{
// if there are remaining sequences, the first one is taken for
@@ -102,8 +105,9 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
// is used
if( nRemaining > 1 )
++nVolumeSeries;
- aSequences[nBarGroupIndex].realloc( nVolumeSeries );
+ aSequences[nBarGroupIndex].resize( nVolumeSeries );
}
+ auto & pBarGroup = aSequences[nBarGroupIndex];
// create data
sal_Int32 nSourceIndex = 0; // index into aData sequence
@@ -111,7 +115,7 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
// 1. categories
if( bHasCategories )
{
- xCategories.set( aData[nSourceIndex] );
+ xCategories = aData[nSourceIndex];
++nSourceIndex;
}
@@ -121,41 +125,42 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
// bar
if( bHasVolume )
{
- aSequences[nBarGroupIndex][nLabeledSeqIdx].realloc( 1 );
- aSequences[nBarGroupIndex][nLabeledSeqIdx][0].set( aData[nSourceIndex] );
+ pBarGroup[nLabeledSeqIdx].resize( 1 );
+ pBarGroup[nLabeledSeqIdx][0] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
- SetRole( aData[nSourceIndex]->getValues(), "values-y");
+ SetRole( aData[nSourceIndex]->getValues(), u"values-y"_ustr);
++nSourceIndex;
}
sal_Int32 nSeqIdx = 0;
if( bHasOpenValues )
{
- aSequences[nCandleStickGroupIndex][nLabeledSeqIdx].realloc( 4 );
- aSequences[nCandleStickGroupIndex][nLabeledSeqIdx][nSeqIdx].set( aData[nSourceIndex] );
+ pCandleStickGroup[nLabeledSeqIdx].resize( 4 );
+ pCandleStickGroup[nLabeledSeqIdx][nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
- SetRole( aData[nSourceIndex]->getValues(), "values-first");
+ SetRole( aData[nSourceIndex]->getValues(), u"values-first"_ustr);
++nSourceIndex;
++nSeqIdx;
}
else
- aSequences[nCandleStickGroupIndex][nLabeledSeqIdx].realloc( 3 );
+ pCandleStickGroup[nLabeledSeqIdx].resize( 3 );
+ auto & pLabeledSeq = pCandleStickGroup[nLabeledSeqIdx];
- aSequences[nCandleStickGroupIndex][nLabeledSeqIdx][nSeqIdx].set( aData[nSourceIndex] );
+ pLabeledSeq[nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
- SetRole( aData[nSourceIndex]->getValues(), "values-min");
+ SetRole( aData[nSourceIndex]->getValues(), u"values-min"_ustr);
++nSourceIndex;
++nSeqIdx;
- aSequences[nCandleStickGroupIndex][nLabeledSeqIdx][nSeqIdx].set( aData[nSourceIndex] );
+ pLabeledSeq[nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
- SetRole( aData[nSourceIndex]->getValues(), "values-max");
+ SetRole( aData[nSourceIndex]->getValues(), u"values-max"_ustr);
++nSourceIndex;
++nSeqIdx;
- aSequences[nCandleStickGroupIndex][nLabeledSeqIdx][nSeqIdx].set( aData[nSourceIndex] );
+ pLabeledSeq[nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
- SetRole( aData[nSourceIndex]->getValues(), "values-last");
+ SetRole( aData[nSourceIndex]->getValues(), u"values-last"_ustr);
++nSourceIndex;
++nSeqIdx;
}
@@ -164,11 +169,11 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
if( bHasVolume && nRemaining > 1 )
{
OSL_ASSERT( nVolumeSeries > nNumOfFullSeries );
- aSequences[nBarGroupIndex][nVolumeSeries - 1].realloc( 1 );
+ pBarGroup[nVolumeSeries - 1].resize( 1 );
OSL_ASSERT( nDataCount > nSourceIndex );
if( aData[nSourceIndex].is())
- SetRole( aData[nSourceIndex]->getValues(), "values-y");
- aSequences[nBarGroupIndex][nVolumeSeries - 1][0].set( aData[nSourceIndex] );
+ SetRole( aData[nSourceIndex]->getValues(), u"values-y"_ustr);
+ pBarGroup[nVolumeSeries - 1][0] = aData[nSourceIndex];
++nSourceIndex;
--nRemaining;
OSL_ENSURE( nRemaining, "additional bar should only be used if there is at least one more sequence for a candle stick" );
@@ -179,23 +184,24 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
{
OSL_ASSERT( nCandleStickSeries > nNumOfFullSeries );
const sal_Int32 nSeriesIndex = nCandleStickSeries - 1;
- aSequences[nCandleStickGroupIndex][nSeriesIndex].realloc( nRemaining );
+ pCandleStickGroup[nSeriesIndex].resize( nRemaining );
+ auto & pLabeledSeq = pCandleStickGroup[nSeriesIndex];
OSL_ASSERT( nDataCount > nSourceIndex );
// 1. low
sal_Int32 nSeqIdx( 0 );
- aSequences[nCandleStickGroupIndex][nSeriesIndex][nSeqIdx].set( aData[nSourceIndex] );
+ pLabeledSeq[nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
- SetRole( aData[nSourceIndex]->getValues(), "values-min");
+ SetRole( aData[nSourceIndex]->getValues(), u"values-min"_ustr);
++nSourceIndex;
++nSeqIdx;
// 2. high
if( nSeqIdx < nRemaining )
{
- aSequences[nCandleStickGroupIndex][nSeriesIndex][nSeqIdx].set( aData[nSourceIndex] );
+ pLabeledSeq[nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
- SetRole( aData[nSourceIndex]->getValues(), "values-max");
+ SetRole( aData[nSourceIndex]->getValues(), u"values-max"_ustr);
++nSourceIndex;
++nSeqIdx;
}
@@ -204,9 +210,9 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
OSL_ENSURE( bHasOpenValues || nSeqIdx >= nRemaining, "could have created full series" );
if( nSeqIdx < nRemaining )
{
- aSequences[nCandleStickGroupIndex][nSeriesIndex][nSeqIdx].set( aData[nSourceIndex] );
+ pLabeledSeq[nSeqIdx] = aData[nSourceIndex];
if( aData[nSourceIndex].is())
- SetRole( aData[nSourceIndex]->getValues(), "values-last");
+ SetRole( aData[nSourceIndex]->getValues(), u"values-last"_ustr);
++nSourceIndex;
++nSeqIdx;
}
@@ -216,25 +222,26 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
}
// create DataSeries
- Sequence< Sequence< Reference< XDataSeries > > > aResultSeries( nNumberOfGroups );
- sal_Int32 nGroupIndex, nReUsedSeriesIdx = 0;
+ std::vector< std::vector< rtl::Reference< DataSeries > > > aResultSeries( nNumberOfGroups );
+ sal_Int32 nGroupIndex;
+ std::size_t nReUsedSeriesIdx = 0;
for( nGroupIndex=0; nGroupIndex<nNumberOfGroups; ++nGroupIndex )
{
- const sal_Int32 nNumSeriesData = aSequences[nGroupIndex].getLength();
- aResultSeries[nGroupIndex].realloc( nNumSeriesData );
+ const sal_Int32 nNumSeriesData = aSequences[nGroupIndex].size();
+ aResultSeries[nGroupIndex].resize( nNumSeriesData );
+ auto & pResultSerie = aResultSeries[nGroupIndex];
for( sal_Int32 nSeriesIdx = 0; nSeriesIdx < nNumSeriesData; ++nSeriesIdx, ++nReUsedSeriesIdx )
{
try
{
- Reference< XDataSeries > xSeries;
- if( nReUsedSeriesIdx < rSeriesToReUse.getLength())
- xSeries.set( rSeriesToReUse[nReUsedSeriesIdx] );
+ rtl::Reference< DataSeries > xSeries;
+ if( nReUsedSeriesIdx < rSeriesToReUse.size())
+ xSeries = rSeriesToReUse[nReUsedSeriesIdx];
else
- xSeries.set( new DataSeries );
- OSL_ASSERT( xSeries.is() );
- Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY_THROW );
- xSink->setData( aSequences[nGroupIndex][nSeriesIdx] );
- aResultSeries[nGroupIndex][nSeriesIdx].set( xSeries );
+ xSeries = new DataSeries;
+ assert( xSeries.is() );
+ xSeries->setData( aSequences[nGroupIndex][nSeriesIdx] );
+ pResultSerie[nSeriesIdx] = std::move(xSeries);
}
catch( const uno::Exception & )
{
@@ -243,7 +250,7 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
}
}
- return InterpretedData( aResultSeries, xCategories );
+ return { std::move(aResultSeries), xCategories };
}
// criterion: there must be two groups for stock-charts with volume and all
@@ -251,11 +258,11 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
// todo: skip first criterion? (to allow easy switch from stock-chart without
// volume to one with volume)
-sal_Bool SAL_CALL StockDataInterpreter::isDataCompatible(
+bool StockDataInterpreter::isDataCompatible(
const InterpretedData& aInterpretedData )
{
// high/low/close
- sal_Int32 nNumberOfNecessarySequences = 3;
+ std::size_t nNumberOfNecessarySequences = 3;
// open
StockChartTypeTemplate::StockVariant eVar( GetStockVariant());
if( ( eVar == StockChartTypeTemplate::StockVariant::Open ) ||
@@ -266,32 +273,30 @@ sal_Bool SAL_CALL StockDataInterpreter::isDataCompatible(
( eVar == StockChartTypeTemplate::StockVariant::VolumeOpen ));
// 1. correct number of sub-types
- if( aInterpretedData.Series.getLength() < (bHasVolume ? 2 : 1 ))
+ if( aInterpretedData.Series.size() < (bHasVolume ? 2U : 1U ))
return false;
// 2. a. volume -- use default check
if( bHasVolume )
{
if( ! DataInterpreter::isDataCompatible(
- InterpretedData( Sequence< Sequence< Reference< XDataSeries > > >(
- aInterpretedData.Series.getConstArray(), 1 ),
- aInterpretedData.Categories )))
+ { std::vector< std::vector< rtl::Reference< DataSeries > > >{
+ aInterpretedData.Series[0] },
+ aInterpretedData.Categories }))
return false;
}
// 2. b. candlestick
{
- OSL_ASSERT( aInterpretedData.Series.getLength() > (bHasVolume ? 1 : 0));
- const Sequence< Reference< XDataSeries > > aSeries( aInterpretedData.Series[(bHasVolume ? 1 : 0)] );
- if(!aSeries.hasElements())
+ OSL_ASSERT( aInterpretedData.Series.size() > (bHasVolume ? 1U : 0U));
+ const std::vector< rtl::Reference< DataSeries > > & aSeries = aInterpretedData.Series[(bHasVolume ? 1 : 0)];
+ if(aSeries.empty())
return false;
- for( Reference< XDataSeries > const & dataSeries : aSeries )
+ for( rtl::Reference< DataSeries > const & dataSeries : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
- if( aSeq.getLength() != nNumberOfNecessarySequences )
+ if( dataSeries->getDataSequences2().size() != nNumberOfNecessarySequences )
return false;
}
catch( const uno::Exception & )
@@ -307,13 +312,30 @@ sal_Bool SAL_CALL StockDataInterpreter::isDataCompatible(
return true;
}
-InterpretedData SAL_CALL StockDataInterpreter::reinterpretDataSeries(
+InterpretedData StockDataInterpreter::reinterpretDataSeries(
const InterpretedData& aInterpretedData )
{
// prerequisite: StockDataInterpreter::isDataCompatible() returned true
return aInterpretedData;
}
+uno::Any StockDataInterpreter::getChartTypeSpecificData(
+ const OUString& sKey )
+{
+ if( sKey == "stock variant" )
+ {
+ StockChartTypeTemplate::StockVariant eStockVariant( GetStockVariant());
+ std::map< StockChartTypeTemplate::StockVariant, sal_Int32 > aTranslation {
+ { StockChartTypeTemplate::StockVariant::NONE, 0 },
+ { StockChartTypeTemplate::StockVariant::Open, 1 },
+ { StockChartTypeTemplate::StockVariant::Volume, 2 },
+ { StockChartTypeTemplate::StockVariant::VolumeOpen, 3 }
+ };
+ return uno::Any( aTranslation[eStockVariant] );
+ }
+ return uno::Any();
+}
+
} // 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
index 2bd5b2b61976..4617da5974a9 100644
--- a/chart2/source/model/template/StockDataInterpreter.hxx
+++ b/chart2/source/model/template/StockDataInterpreter.hxx
@@ -16,10 +16,9 @@
* 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
+#pragma once
-#include "DataInterpreter.hxx"
+#include <DataInterpreter.hxx>
#include "StockChartTypeTemplate.hxx"
@@ -35,14 +34,16 @@ public:
protected:
// ____ XDataInterpreter ____
- virtual css::chart2::InterpretedData SAL_CALL interpretDataSource(
+ virtual InterpretedData interpretDataSource(
const css::uno::Reference< css::chart2::data::XDataSource >& xSource,
const css::uno::Sequence< css::beans::PropertyValue >& aArguments,
- const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > >& aSeriesToReUse ) override;
- virtual sal_Bool SAL_CALL isDataCompatible(
- const css::chart2::InterpretedData& aInterpretedData ) override;
- virtual css::chart2::InterpretedData SAL_CALL reinterpretDataSeries(
- const css::chart2::InterpretedData& aInterpretedData ) override;
+ const std::vector< rtl::Reference< ::chart::DataSeries > >& aSeriesToReUse ) override;
+ virtual bool isDataCompatible(
+ const InterpretedData& aInterpretedData ) override;
+ virtual InterpretedData reinterpretDataSeries(
+ const InterpretedData& aInterpretedData ) override;
+ virtual css::uno::Any getChartTypeSpecificData(
+ const OUString& sKey ) override;
private:
StockChartTypeTemplate::StockVariant m_eStockVariant;
@@ -52,7 +53,4 @@ private:
} // 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
index a3fb67fa9202..d6daa2a5b1d9 100644
--- a/chart2/source/model/template/XYDataInterpreter.cxx
+++ b/chart2/source/model/template/XYDataInterpreter.cxx
@@ -17,18 +17,20 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cstddef>
+
#include "XYDataInterpreter.hxx"
#include <DataSeries.hxx>
#include <DataSeriesHelper.hxx>
#include <CommonConverters.hxx>
-#include <com/sun/star/chart2/data/XDataSink.hpp>
#include <com/sun/star/util/XCloneable.hpp>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <sal/log.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
-using namespace ::std;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -36,8 +38,7 @@ using ::com::sun::star::uno::Sequence;
namespace chart
{
-XYDataInterpreter::XYDataInterpreter() :
- DataInterpreter()
+XYDataInterpreter::XYDataInterpreter()
{
}
@@ -46,36 +47,36 @@ XYDataInterpreter::~XYDataInterpreter()
}
// ____ XDataInterpreter ____
-chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
+InterpretedData XYDataInterpreter::interpretDataSource(
const Reference< chart2::data::XDataSource >& xSource,
const Sequence< beans::PropertyValue >& aArguments,
- const Sequence< Reference< XDataSeries > >& aSeriesToReUse )
+ const std::vector< rtl::Reference< DataSeries > >& aSeriesToReUse )
{
if( ! xSource.is())
return InterpretedData();
- const Sequence< Reference< data::XLabeledDataSequence > > aData( xSource->getDataSequences() );
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aData = DataInterpreter::getDataSequences(xSource);
- Reference< data::XLabeledDataSequence > xValuesX;
- vector< Reference< data::XLabeledDataSequence > > aSequencesVec;
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesX;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSequencesVec;
- Reference< data::XLabeledDataSequence > xCategories;
+ uno::Reference< chart2::data::XLabeledDataSequence > xCategories;
bool bHasCategories = HasCategories( aArguments, aData );
bool bUseCategoriesAsX = UseCategoriesAsX( aArguments );
// parse data
bool bCategoriesUsed = false;
- bool bSetXValues = aData.getLength()>1;
- for( Reference< data::XLabeledDataSequence > const & labelData : aData )
+ bool bSetXValues = aData.size()>1;
+ for( uno::Reference< chart2::data::XLabeledDataSequence > const & labelData : aData )
{
try
{
if( bHasCategories && ! bCategoriesUsed )
{
- xCategories.set( labelData );
+ xCategories = labelData;
if( xCategories.is())
{
- SetRole( xCategories->getValues(), "categories");
+ SetRole( xCategories->getValues(), u"categories"_ustr);
if( bUseCategoriesAsX )
bSetXValues = false;
}
@@ -83,15 +84,15 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
}
else if( !xValuesX.is() && bSetXValues )
{
- xValuesX.set( labelData );
+ xValuesX = labelData;
if( xValuesX.is())
- SetRole( xValuesX->getValues(), "values-x");
+ SetRole( xValuesX->getValues(), u"values-x"_ustr);
}
else
{
aSequencesVec.push_back( labelData );
if( labelData.is())
- SetRole( labelData->getValues(), "values-y");
+ SetRole( labelData->getValues(), u"values-y"_ustr);
}
}
catch( const uno::Exception & )
@@ -101,16 +102,16 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
}
// create DataSeries
- vector< Reference< XDataSeries > > aSeriesVec;
+ std::vector< rtl::Reference< DataSeries > > aSeriesVec;
aSeriesVec.reserve( aSequencesVec.size());
Reference< data::XLabeledDataSequence > xClonedXValues = xValuesX;
Reference< util::XCloneable > xCloneable( xValuesX, uno::UNO_QUERY );
- sal_Int32 nSeriesIndex = 0;
+ std::size_t nSeriesIndex = 0;
for (auto const& elem : aSequencesVec)
{
- vector< Reference< data::XLabeledDataSequence > > aNewData;
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewData;
if( nSeriesIndex && xCloneable.is() )
xClonedXValues.set( xCloneable->createClone(), uno::UNO_QUERY );
@@ -119,52 +120,47 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
aNewData.push_back(elem);
- Reference< XDataSeries > xSeries;
- if( nSeriesIndex < aSeriesToReUse.getLength())
- xSeries.set( aSeriesToReUse[nSeriesIndex] );
+ rtl::Reference< DataSeries > xSeries;
+ if( nSeriesIndex < aSeriesToReUse.size())
+ xSeries = aSeriesToReUse[nSeriesIndex];
else
- xSeries.set( new DataSeries );
- OSL_ASSERT( xSeries.is() );
- Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
- OSL_ASSERT( xSink.is() );
- xSink->setData( comphelper::containerToSequence( aNewData ) );
+ xSeries = new DataSeries;
+ assert( xSeries.is() );
+ xSeries->setData( aNewData );
aSeriesVec.push_back( xSeries );
++nSeriesIndex;
}
- Sequence< Sequence< Reference< XDataSeries > > > aSeries(1);
- aSeries[0] = comphelper::containerToSequence( aSeriesVec );
- return InterpretedData( aSeries, xCategories );
+ return { { std::move(aSeriesVec) }, xCategories };
}
-chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
- const chart2::InterpretedData& aInterpretedData )
+InterpretedData XYDataInterpreter::reinterpretDataSeries(
+ const InterpretedData& aInterpretedData )
{
InterpretedData aResult( aInterpretedData );
sal_Int32 i=0;
- Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- const sal_Int32 nCount = aSeries.getLength();
+ std::vector< rtl::Reference< DataSeries > > aSeries = FlattenSequence( aInterpretedData.Series );
+ const sal_Int32 nCount = aSeries.size();
for( ; i<nCount; ++i )
{
try
{
- Reference< data::XDataSource > xSeriesSource( aSeries[i], uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aNewSequences;
+ std::vector< uno::Reference< data::XLabeledDataSequence > > aNewSequences;
// values-y
- Reference< data::XLabeledDataSequence > xValuesY(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-y" ));
- Reference< data::XLabeledDataSequence > xValuesX(
- DataSeriesHelper::getDataSequenceByRole( xSeriesSource, "values-x" ));
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesY(
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], u"values-y"_ustr ));
+ uno::Reference< chart2::data::XLabeledDataSequence > xValuesX(
+ DataSeriesHelper::getDataSequenceByRole( aSeries[i], u"values-x"_ustr ));
// re-use values-... as values-x/values-y
if( ! xValuesX.is() ||
! xValuesY.is())
{
- vector< Reference< data::XLabeledDataSequence > > aValueSeqVec(
+ std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aValueSeqVec(
DataSeriesHelper::getAllDataSequencesByRole(
- xSeriesSource->getDataSequences(), "values" ));
+ aSeries[i]->getDataSequences2(), u"values"_ustr ));
if( xValuesX.is())
aValueSeqVec.erase( find( aValueSeqVec.begin(), aValueSeqVec.end(), xValuesX ));
if( xValuesY.is())
@@ -174,36 +170,33 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
if( ! xValuesY.is() &&
aValueSeqVec.size() > nIndex )
{
- xValuesY.set( aValueSeqVec[nIndex++] );
+ xValuesY = aValueSeqVec[nIndex++];
if( xValuesY.is())
- SetRole( xValuesY->getValues(), "values-y");
+ SetRole( xValuesY->getValues(), u"values-y"_ustr);
}
if( ! xValuesX.is() &&
aValueSeqVec.size() > nIndex )
{
- xValuesX.set( aValueSeqVec[nIndex++] );
+ xValuesX = aValueSeqVec[nIndex++];
if( xValuesX.is())
- SetRole( xValuesY->getValues(), "values-x");
+ SetRole( xValuesX->getValues(), u"values-x"_ustr);
}
}
if( xValuesY.is())
{
if( xValuesX.is())
{
- aNewSequences.realloc(2);
- aNewSequences[0] = xValuesX;
- aNewSequences[1] = xValuesY;
+ aNewSequences = { xValuesX, xValuesY };
}
else
{
- aNewSequences.realloc(1);
- aNewSequences[0] = xValuesY;
+ aNewSequences = { xValuesY };
}
}
- const Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
- if( aSeqs.getLength() != aNewSequences.getLength() )
+ const std::vector< uno::Reference< data::XLabeledDataSequence > > & aSeqs = aSeries[i]->getDataSequences2();
+ if( aSeqs.size() != aNewSequences.size() )
{
#ifdef DBG_UTIL
for( auto const & j : aSeqs )
@@ -211,8 +204,7 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
SAL_WARN_IF((j == xValuesY || j == xValuesX), "chart2.template", "All sequences should be used" );
}
#endif
- Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
- xSink->setData( aNewSequences );
+ aSeries[i]->setData( aNewSequences );
}
}
catch( const uno::Exception & )
@@ -225,17 +217,15 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
}
// criterion: all series must have exactly two data::XLabeledDataSequences
-sal_Bool SAL_CALL XYDataInterpreter::isDataCompatible(
- const chart2::InterpretedData& aInterpretedData )
+bool XYDataInterpreter::isDataCompatible(
+ const InterpretedData& aInterpretedData )
{
- const Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
- for( Reference< XDataSeries > const & dataSeries : aSeries )
+ const std::vector< rtl::Reference< DataSeries > > aSeries = FlattenSequence( aInterpretedData.Series );
+ for( rtl::Reference< DataSeries > const & dataSeries : aSeries )
{
try
{
- Reference< data::XDataSource > xSrc( dataSeries, uno::UNO_QUERY_THROW );
- Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSrc->getDataSequences());
- if( aSeq.getLength() != 2 )
+ if( dataSeries->getDataSequences2().size() != 2 )
return false;
}
catch( const uno::Exception & )
diff --git a/chart2/source/model/template/XYDataInterpreter.hxx b/chart2/source/model/template/XYDataInterpreter.hxx
index c57889ce880d..56343013da08 100644
--- a/chart2/source/model/template/XYDataInterpreter.hxx
+++ b/chart2/source/model/template/XYDataInterpreter.hxx
@@ -16,10 +16,9 @@
* 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
+#pragma once
-#include "DataInterpreter.hxx"
+#include <DataInterpreter.hxx>
namespace chart
{
@@ -31,20 +30,17 @@ public:
virtual ~XYDataInterpreter() override;
protected:
- // ____ XDataInterpreter ____
- virtual css::chart2::InterpretedData SAL_CALL interpretDataSource(
+ // ____ DataInterpreter ____
+ virtual InterpretedData interpretDataSource(
const css::uno::Reference< css::chart2::data::XDataSource >& xSource,
const css::uno::Sequence< css::beans::PropertyValue >& aArguments,
- const css::uno::Sequence< css::uno::Reference< css::chart2::XDataSeries > >& aSeriesToReUse ) override;
- virtual css::chart2::InterpretedData SAL_CALL reinterpretDataSeries(
- const css::chart2::InterpretedData& aInterpretedData ) override;
- virtual sal_Bool SAL_CALL isDataCompatible(
- const css::chart2::InterpretedData& aInterpretedData ) override;
+ const std::vector< rtl::Reference< ::chart::DataSeries > >& aSeriesToReUse ) override;
+ virtual InterpretedData reinterpretDataSeries(
+ const InterpretedData& aInterpretedData ) override;
+ virtual bool isDataCompatible(
+ const InterpretedData& aInterpretedData ) override;
};
} // namespace chart
-// INCLUDED_CHART2_SOURCE_MODEL_TEMPLATE_XYDATAINTERPRETER_HXX
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */