diff options
author | Armin Le Grand <alg@apache.org> | 2013-07-01 10:43:33 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-07-01 14:46:11 +0100 |
commit | 4dda042c354b4cfaf190bca35092bbd5f6dc2a1f (patch) | |
tree | 25aa4b1326c3f5c0b4cbdad1c919922c223102f6 /chart2 | |
parent | 1ef63d0842dab4154c5ca2fc42e416950bd7459a (diff) |
Resolves: #i120559# Corrected load for charts without RangeString...
but with local row-oriented data
(cherry picked from commit 855d5e3bc075e516edf1dc7e844924bbf9ab590c)
Conflicts:
chart2/source/tools/ChartModelHelper.cxx
Change-Id: I4979b639f5652a1c27b640b6b469f66c65a888aa
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/inc/InternalDataProvider.hxx | 9 | ||||
-rw-r--r-- | chart2/source/tools/ChartModelHelper.cxx | 32 | ||||
-rw-r--r-- | chart2/source/tools/InternalDataProvider.cxx | 17 |
3 files changed, 52 insertions, 6 deletions
diff --git a/chart2/source/inc/InternalDataProvider.hxx b/chart2/source/inc/InternalDataProvider.hxx index 3b6cd9a46da0..71a61a590362 100644 --- a/chart2/source/inc/InternalDataProvider.hxx +++ b/chart2/source/inc/InternalDataProvider.hxx @@ -71,8 +71,13 @@ class InternalDataProvider : { public: explicit InternalDataProvider(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & _xContext); - explicit InternalDataProvider( const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XChartDocument > & xChartDoc, bool bConnectToModel ); + + // #i120559# allow handing over a default for data orientation + // (DataInColumns) that will be used when no data is available + explicit InternalDataProvider( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc, + bool bConnectToModel, + bool bDefaultDataInColumns ); explicit InternalDataProvider( const InternalDataProvider & rOther ); virtual ~InternalDataProvider(); diff --git a/chart2/source/tools/ChartModelHelper.cxx b/chart2/source/tools/ChartModelHelper.cxx index 7002a471f2d0..5c1e78d8e800 100644 --- a/chart2/source/tools/ChartModelHelper.cxx +++ b/chart2/source/tools/ChartModelHelper.cxx @@ -25,6 +25,8 @@ #include "RangeHighlighter.hxx" #include "InternalDataProvider.hxx" +#include <com/sun/star/chart/ChartDataRowSource.hpp> +#include <com/sun/star/chart/XChartDocument.hpp> #include <com/sun/star/chart2/data/XDataReceiver.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XChartTypeContainer.hpp> @@ -50,7 +52,35 @@ uno::Reference< chart2::data::XRangeHighlighter > ChartModelHelper::createRangeH uno::Reference< chart2::data::XDataProvider > ChartModelHelper::createInternalDataProvider( const uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc, bool bConnectToModel ) { - return new InternalDataProvider( xChartDoc, bConnectToModel ); + bool bDefaultDataInColumns(true); + + // #i120559# Try to access the current state of "DataRowSource" for the + // chart data and use it as default for creating a new InternalDataProvider + if(xChartDoc.is()) + { + ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDocument > xDoc(xChartDoc, uno::UNO_QUERY); + + if(xDoc.is()) + { + ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram > aDiagram = xDoc->getDiagram(); + + if(aDiagram.is()) + { + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xProp(aDiagram, uno::UNO_QUERY); + + if(xProp.is()) + { + ::com::sun::star::chart::ChartDataRowSource aDataRowSource(::com::sun::star::chart::ChartDataRowSource_COLUMNS); + + xProp->getPropertyValue( ::rtl::OUString::createFromAscii("DataRowSource")) >>= aDataRowSource; + + bDefaultDataInColumns = (::com::sun::star::chart::ChartDataRowSource_COLUMNS == aDataRowSource); + } + } + } + } + + return new InternalDataProvider( xChartDoc, bConnectToModel, bDefaultDataInColumns ); } uno::Reference< XDiagram > ChartModelHelper::findDiagram( const uno::Reference< frame::XModel >& xModel ) diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index 147afc8a2935..2def119a8956 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -315,8 +315,11 @@ InternalDataProvider::InternalDataProvider( const Reference< uno::XComponentCont : m_bDataInColumns( true ) {} -InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocument > & xChartDoc, bool bConnectToModel ) - : m_bDataInColumns( true ) +InternalDataProvider::InternalDataProvider( + const Reference< chart2::XChartDocument > & xChartDoc, + bool bConnectToModel, + bool bDefaultDataInColumns) +: m_bDataInColumns( bDefaultDataInColumns ) { try { @@ -331,7 +334,15 @@ InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocum bool bFirstCellAsLabel = true; bool bHasCategories = true; uno::Sequence< sal_Int32 > aSequenceMapping; - DataSourceHelper::detectRangeSegmentation( xChartModel, aRangeString, aSequenceMapping, m_bDataInColumns, bFirstCellAsLabel, bHasCategories ); + const bool bSomethingDetected( + DataSourceHelper::detectRangeSegmentation( + xChartModel, aRangeString, aSequenceMapping, m_bDataInColumns, bFirstCellAsLabel, bHasCategories )); + + // #i120559# if no data was available, restore default + if(!bSomethingDetected && m_bDataInColumns != bDefaultDataInColumns) + { + m_bDataInColumns = bDefaultDataInColumns; + } } // categories |