[Libreoffice-commits] core.git: Branch 'aoo/trunk' - chart2/source
Armin Le Grand
alg at apache.org
Mon Jul 1 05:08:30 PDT 2013
chart2/source/inc/InternalDataProvider.hxx | 9 +++++--
chart2/source/tools/ChartModelHelper.cxx | 33 ++++++++++++++++++++++++++-
chart2/source/tools/InternalDataProvider.cxx | 17 +++++++++++--
3 files changed, 53 insertions(+), 6 deletions(-)
New commits:
commit 855d5e3bc075e516edf1dc7e844924bbf9ab590c
Author: Armin Le Grand <alg at apache.org>
Date: Mon Jul 1 10:43:33 2013 +0000
i120559 Corrected load for charts without RangeString bu twith local row-oriented data
diff --git a/chart2/source/inc/InternalDataProvider.hxx b/chart2/source/inc/InternalDataProvider.hxx
index 4272c58..2596467 100644
--- a/chart2/source/inc/InternalDataProvider.hxx
+++ b/chart2/source/inc/InternalDataProvider.hxx
@@ -75,8 +75,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 );
+
+ // #120559# 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 a743c9f..563c15a 100755
--- a/chart2/source/tools/ChartModelHelper.cxx
+++ b/chart2/source/tools/ChartModelHelper.cxx
@@ -43,6 +43,9 @@
// header for define DBG_ASSERT
#include <tools/debug.hxx>
+#include <com/sun/star/chart/XChartDocument.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+
//.............................................................................
namespace chart
{
@@ -59,7 +62,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);
+
+ // #120559# Try to access the current state of "DataRowSource" fo rthe 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 d904adf..7c1fc27 100755
--- a/chart2/source/tools/InternalDataProvider.cxx
+++ b/chart2/source/tools/InternalDataProvider.cxx
@@ -337,8 +337,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
{
@@ -353,7 +356,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 ));
+
+ // #120559# if no data was available, restore default
+ if(!bSomethingDetected && m_bDataInColumns != bDefaultDataInColumns)
+ {
+ m_bDataInColumns = bDefaultDataInColumns;
+ }
}
// categories
More information about the Libreoffice-commits
mailing list