summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx595
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx44
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx126
-rw-r--r--chart2/source/controller/dialogs/DataBrowser.cxx71
-rw-r--r--chart2/source/controller/dialogs/DataBrowser.hxx4
-rw-r--r--chart2/source/controller/dialogs/DataBrowserModel.cxx109
-rw-r--r--chart2/source/controller/dialogs/DataBrowserModel.hxx11
-rw-r--r--chart2/source/controller/dialogs/DialogModel.cxx2
-rw-r--r--chart2/source/controller/dialogs/ObjectNameProvider.cxx4
-rw-r--r--chart2/source/controller/dialogs/dlg_DataEditor.cxx52
-rw-r--r--chart2/source/controller/dialogs/dlg_DataEditor.hrc9
-rw-r--r--chart2/source/controller/dialogs/dlg_DataEditor.src8
-rw-r--r--chart2/source/controller/dialogs/dlg_ObjectProperties.cxx2
-rw-r--r--chart2/source/controller/inc/HelpIds.hrc11
-rw-r--r--chart2/source/controller/main/ImplUndoManager.cxx12
-rw-r--r--chart2/source/inc/ChartModelHelper.hxx12
-rw-r--r--chart2/source/inc/CloneHelper.hxx1
-rw-r--r--chart2/source/inc/DataSourceHelper.hxx13
-rw-r--r--chart2/source/inc/DiagramHelper.hxx8
-rw-r--r--chart2/source/inc/ExplicitCategoriesProvider.hxx63
-rwxr-xr-xchart2/source/inc/InternalData.hxx109
-rw-r--r--chart2/source/inc/InternalDataProvider.hxx69
-rw-r--r--chart2/source/model/inc/Diagram.hxx10
-rw-r--r--chart2/source/model/main/ChartData.cxx104
-rw-r--r--chart2/source/model/main/ChartData.hxx102
-rwxr-xr-x[-rw-r--r--]chart2/source/model/main/ChartModel.cxx409
-rw-r--r--chart2/source/model/main/ChartModel.hxx50
-rw-r--r--chart2/source/model/main/ChartModel_Persistence.cxx93
-rw-r--r--chart2/source/model/main/Diagram.cxx12
-rwxr-xr-xchart2/source/model/main/ImplChartModel.cxx537
-rw-r--r--chart2/source/model/main/ImplChartModel.hxx228
-rw-r--r--chart2/source/model/main/InternalData.cxx257
-rw-r--r--chart2/source/model/main/InternalData.hxx118
-rw-r--r--chart2/source/model/main/makefile.mk2
-rw-r--r--chart2/source/model/template/BubbleChartTypeTemplate.cxx10
-rw-r--r--chart2/source/model/template/BubbleChartTypeTemplate.hxx4
-rw-r--r--chart2/source/model/template/BubbleDataInterpreter.cxx14
-rw-r--r--chart2/source/model/template/ChartTypeTemplate.cxx39
-rw-r--r--chart2/source/model/template/ChartTypeTemplate.hxx6
-rw-r--r--chart2/source/model/template/DataInterpreter.cxx36
-rw-r--r--chart2/source/model/template/ScatterChartTypeTemplate.cxx10
-rw-r--r--chart2/source/model/template/ScatterChartTypeTemplate.hxx4
-rw-r--r--chart2/source/model/template/StockDataInterpreter.cxx5
-rw-r--r--chart2/source/model/template/XYDataInterpreter.cxx13
-rw-r--r--chart2/source/tools/ChartModelHelper.cxx31
-rw-r--r--chart2/source/tools/DataSourceHelper.cxx38
-rw-r--r--chart2/source/tools/DiagramHelper.cxx66
-rw-r--r--chart2/source/tools/ExplicitCategoriesProvider.cxx367
-rwxr-xr-xchart2/source/tools/InternalData.cxx530
-rw-r--r--chart2/source/tools/InternalDataProvider.cxx1430
-rw-r--r--chart2/source/tools/makefile.mk1
-rw-r--r--chart2/source/view/axes/TickmarkHelper.cxx109
-rw-r--r--chart2/source/view/axes/TickmarkHelper.hxx39
-rw-r--r--chart2/source/view/axes/VAxisBase.cxx51
-rw-r--r--chart2/source/view/axes/VAxisBase.hxx3
-rw-r--r--chart2/source/view/axes/VAxisProperties.cxx24
-rw-r--r--chart2/source/view/axes/VAxisProperties.hxx14
-rw-r--r--chart2/source/view/axes/VCartesianAxis.cxx619
-rw-r--r--chart2/source/view/axes/VCartesianAxis.hxx19
-rw-r--r--chart2/source/view/axes/VCartesianCoordinateSystem.cxx10
-rw-r--r--chart2/source/view/axes/VCoordinateSystem.cxx10
-rw-r--r--chart2/source/view/axes/VPolarAngleAxis.cxx9
-rw-r--r--chart2/source/view/axes/VPolarAngleAxis.hxx2
-rw-r--r--chart2/source/view/axes/VPolarGrid.cxx2
-rw-r--r--chart2/source/view/axes/VPolarRadiusAxis.cxx3
-rw-r--r--chart2/source/view/charttypes/AreaChart.cxx17
-rw-r--r--chart2/source/view/charttypes/AreaChart.hxx3
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx31
-rw-r--r--chart2/source/view/inc/PropertyMapper.hxx5
-rw-r--r--chart2/source/view/inc/VCoordinateSystem.hxx11
-rw-r--r--chart2/source/view/inc/VSeriesPlotter.hxx8
-rw-r--r--chart2/source/view/main/ChartView.cxx15
-rw-r--r--chart2/source/view/main/PropertyMapper.cxx8
73 files changed, 3324 insertions, 3549 deletions
diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
index 375119ce521f..253699f4595c 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
@@ -61,59 +61,18 @@
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::rtl::OUString;
using ::osl::MutexGuard;
+using ::com::sun::star::chart::XComplexDescriptionAccess;
+using ::com::sun::star::chart::XChartData;
+using ::com::sun::star::chart::XChartDataArray;
namespace
{
static const ::rtl::OUString lcl_aServiceName(
RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.ChartData" ));
-struct lcl_DataSequenceToDoubleSeq : public ::std::unary_function<
- uno::Reference< chart2::data::XDataSequence >,
- uno::Sequence< double > >
-{
- uno::Sequence< double > operator() ( const uno::Reference< chart2::data::XDataSequence > & xSeq )
- {
- uno::Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY );
- if( xNumSeq.is())
- {
- return xNumSeq->getNumericalData();
- }
- else if( xSeq.is())
- {
- uno::Sequence< uno::Any > aValues = xSeq->getData();
- uno::Sequence< double > aResult( aValues.getLength());
- const sal_Int32 nLength = aValues.getLength();
- for( sal_Int32 i = 0; i < nLength; ++i )
- {
- if( ! ( aValues[ i ] >>= aResult[ i ]) )
- {
- aResult[ i ] = DBL_MIN;
- }
- double& rValue = aResult[ i ];
- if( ::rtl::math::isNan( rValue ) )
- rValue = DBL_MIN;
- }
- return aResult;
- }
- return uno::Sequence< double >();
- }
-};
-
-void lcl_AddSequences( uno::Reference< chart2::data::XLabeledDataSequence > xLSeq,
- ::std::vector< uno::Reference< chart2::data::XDataSequence > > & rOutSeqVector,
- ::std::vector< ::rtl::OUString > & rOutLabelVector )
-{
- if( xLSeq.is() )
- {
- uno::Reference< chart2::data::XDataSequence > xSeq( xLSeq->getValues() );
- rOutSeqVector.push_back( xSeq );
-
- ::rtl::OUString aLabel( ::chart::DataSeriesHelper::getLabelForLabeledDataSequence( xLSeq ) );
- rOutLabelVector.push_back( aLabel );
- }
-}
-
uno::Sequence< uno::Sequence< double > > lcl_getNANInsteadDBL_MIN( const uno::Sequence< uno::Sequence< double > >& rData )
{
uno::Sequence< uno::Sequence< double > > aRet;
@@ -163,11 +122,197 @@ namespace chart
namespace wrapper
{
+//--------------------------------------------------------------------------------------
+
+struct lcl_Operator
+{
+ lcl_Operator()
+ {
+ }
+ virtual ~lcl_Operator()
+ {
+ }
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) = 0;
+
+ virtual bool setsCategories( bool /*bDataInColumns*/ )
+ {
+ return false;
+ }
+};
+
+//--------------------------------------------------------------------------
+
+struct lcl_AllOperator : public lcl_Operator
+{
+ lcl_AllOperator( const Reference< XChartData >& xDataToApply )
+ : lcl_Operator()
+ , m_xDataToApply( xDataToApply )
+ {
+ }
+
+ virtual bool setsCategories( bool /*bDataInColumns*/ )
+ {
+ return true;
+ }
+
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess )
+ {
+ if( !xDataAccess.is() )
+ return;
+
+ Reference< XComplexDescriptionAccess > xNewComplex( m_xDataToApply, uno::UNO_QUERY );
+ if( xNewComplex.is() )
+ {
+ xDataAccess->setData( xNewComplex->getData() );
+ xDataAccess->setComplexRowDescriptions( xNewComplex->getComplexRowDescriptions() );
+ xDataAccess->setComplexColumnDescriptions( xNewComplex->getComplexColumnDescriptions() );
+ }
+ else
+ {
+ Reference< XChartDataArray > xNew( m_xDataToApply, uno::UNO_QUERY );
+ if( xNew.is() )
+ {
+ xDataAccess->setData( xNew->getData() );
+ xDataAccess->setRowDescriptions( xNew->getRowDescriptions() );
+ xDataAccess->setColumnDescriptions( xNew->getColumnDescriptions() );
+ }
+ }
+ }
+
+ Reference< XChartData > m_xDataToApply;
+};
+
+//--------------------------------------------------------------------------
+
+struct lcl_DataOperator : public lcl_Operator
+{
+ lcl_DataOperator( const Sequence< Sequence< double > >& rData )
+ : lcl_Operator()
+ , m_rData( rData )
+ {
+ }
+
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess )
+ {
+ if( xDataAccess.is() )
+ xDataAccess->setData( lcl_getNANInsteadDBL_MIN( m_rData ) );
+ }
+
+ const Sequence< Sequence< double > >& m_rData;
+};
+
+//--------------------------------------------------------------------------
+
+struct lcl_RowDescriptionsOperator : public lcl_Operator
+{
+ lcl_RowDescriptionsOperator( const Sequence< OUString >& rRowDescriptions )
+ : lcl_Operator()
+ , m_rRowDescriptions( rRowDescriptions )
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns )
+ {
+ return bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess )
+ {
+ if( xDataAccess.is() )
+ xDataAccess->setRowDescriptions( m_rRowDescriptions );
+ }
+
+ const Sequence< OUString >& m_rRowDescriptions;
+};
+
+//--------------------------------------------------------------------------
+
+struct lcl_ComplexRowDescriptionsOperator : public lcl_Operator
+{
+ lcl_ComplexRowDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexRowDescriptions )
+ : lcl_Operator()
+ , m_rComplexRowDescriptions( rComplexRowDescriptions )
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns )
+ {
+ return !bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess )
+ {
+ if( xDataAccess.is() )
+ xDataAccess->setComplexRowDescriptions( m_rComplexRowDescriptions );
+ }
+
+ const Sequence< Sequence< OUString > >& m_rComplexRowDescriptions;
+};
+
+//--------------------------------------------------------------------------
+
+struct lcl_ColumnDescriptionsOperator : public lcl_Operator
+{
+ lcl_ColumnDescriptionsOperator( const Sequence< OUString >& rColumnDescriptions )
+ : lcl_Operator()
+ , m_rColumnDescriptions( rColumnDescriptions )
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns )
+ {
+ return !bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess )
+ {
+ if( xDataAccess.is() )
+ xDataAccess->setColumnDescriptions( m_rColumnDescriptions );
+ }
+
+ const Sequence< OUString >& m_rColumnDescriptions;
+};
+
+//--------------------------------------------------------------------------
+
+struct lcl_ComplexColumnDescriptionsOperator : public lcl_Operator
+{
+ lcl_ComplexColumnDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexColumnDescriptions )
+ : lcl_Operator()
+ , m_rComplexColumnDescriptions( rComplexColumnDescriptions )
+ {
+ }
+
+ virtual bool setsCategories( bool bDataInColumns )
+ {
+ return !bDataInColumns;
+ }
+
+ virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess )
+ {
+ if( xDataAccess.is() )
+ xDataAccess->setComplexColumnDescriptions( m_rComplexColumnDescriptions );
+ }
+
+ const Sequence< Sequence< OUString > >& m_rComplexColumnDescriptions;
+};
+
+//--------------------------------------------------------------------------
+
ChartDataWrapper::ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) :
m_spChart2ModelContact( spChart2ModelContact ),
m_aEventListenerContainer( m_aMutex )
{
- refreshData();
+ initDataAccess();
+}
+
+ChartDataWrapper::ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
+ const Reference< XChartData >& xNewData ) :
+ m_spChart2ModelContact( spChart2ModelContact ),
+ m_aEventListenerContainer( m_aMutex )
+{
+ lcl_AllOperator aOperator( xNewData );
+ applyData( aOperator );
}
ChartDataWrapper::~ChartDataWrapper()
@@ -179,87 +324,80 @@ ChartDataWrapper::~ChartDataWrapper()
// m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) );
}
-// ____ XChartDataArray ____
-uno::Sequence< uno::Sequence< double > > SAL_CALL ChartDataWrapper::getData()
+// ____ XChartDataArray (read)____
+Sequence< Sequence< double > > SAL_CALL ChartDataWrapper::getData()
throw (uno::RuntimeException)
{
- // until we have a data change notification mechanism we always have to
- // update the data here
- refreshData();
- // /--
- MutexGuard aGuard( GetMutex());
- return m_aData;
- // \--
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return lcl_getDBL_MINInsteadNAN( m_xDataAccess->getData() );
+ return Sequence< Sequence< double > >();
}
-
-void SAL_CALL ChartDataWrapper::setData(
- const uno::Sequence< uno::Sequence< double > >& aData )
+Sequence< OUString > SAL_CALL ChartDataWrapper::getRowDescriptions()
throw (uno::RuntimeException)
{
- refreshData();
- {
- // /--
- MutexGuard aGuard( GetMutex());
- m_aData = aData;
- // \--
- }
- applyData( true, false, false );
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getRowDescriptions();
+ return Sequence< OUString >();
}
-
-uno::Sequence< ::rtl::OUString > SAL_CALL ChartDataWrapper::getRowDescriptions()
+Sequence< OUString > SAL_CALL ChartDataWrapper::getColumnDescriptions()
throw (uno::RuntimeException)
{
- // until we have a data change notification mechanism we always have to
- // update the data here
- refreshData();
-
- // /--
- MutexGuard aGuard( GetMutex());
- return m_aRowDescriptions;
- // \--
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getColumnDescriptions();
+ return Sequence< OUString > ();
+}
+// ____ XComplexDescriptionAccess (read) ____
+Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexRowDescriptions() throw (uno::RuntimeException)
+{
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getComplexRowDescriptions();
+ return Sequence< Sequence< OUString > >();
+}
+Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexColumnDescriptions() throw (uno::RuntimeException)
+{
+ initDataAccess();
+ if( m_xDataAccess.is() )
+ return m_xDataAccess->getComplexColumnDescriptions();
+ return Sequence< Sequence< OUString > >();
}
-void SAL_CALL ChartDataWrapper::setRowDescriptions(
- const uno::Sequence< ::rtl::OUString >& aRowDescriptions )
+// ____ XChartDataArray (write)____
+void SAL_CALL ChartDataWrapper::setData( const Sequence< Sequence< double > >& rData )
throw (uno::RuntimeException)
{
- refreshData();
- {
- // /--
- MutexGuard aGuard( GetMutex());
- m_aRowDescriptions = aRowDescriptions;
- // \--
- }
- applyData( false, true, false );
+ lcl_DataOperator aOperator( rData );
+ applyData( aOperator );
}
-
-uno::Sequence<
- ::rtl::OUString > SAL_CALL ChartDataWrapper::getColumnDescriptions()
+void SAL_CALL ChartDataWrapper::setRowDescriptions( const Sequence< OUString >& rRowDescriptions )
throw (uno::RuntimeException)
{
- // until we have a data change notification mechanism we always have to
- // update the data here
- refreshData();
- // /--
- MutexGuard aGuard( GetMutex());
- return m_aColumnDescriptions;
- // \--
+ lcl_RowDescriptionsOperator aOperator( rRowDescriptions );
+ applyData( aOperator );
}
-
-void SAL_CALL ChartDataWrapper::setColumnDescriptions(
- const uno::Sequence< ::rtl::OUString >& aColumnDescriptions )
+void SAL_CALL ChartDataWrapper::setColumnDescriptions( const Sequence< OUString >& rColumnDescriptions )
throw (uno::RuntimeException)
{
- refreshData();
- {
- // /--
- MutexGuard aGuard( GetMutex());
- m_aColumnDescriptions = aColumnDescriptions;
- // \--
- }
- applyData( false, false, true );
+ lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions );
+ applyData( aOperator );
+}
+
+// ____ XComplexDescriptionAccess (write) ____
+void SAL_CALL ChartDataWrapper::setComplexRowDescriptions( const Sequence< Sequence< ::rtl::OUString > >& rRowDescriptions ) throw (uno::RuntimeException)
+{
+ lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions );
+ applyData( aOperator );
+}
+void SAL_CALL ChartDataWrapper::setComplexColumnDescriptions( const Sequence< Sequence< ::rtl::OUString > >& rColumnDescriptions ) throw (uno::RuntimeException)
+{
+ lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions );
+ applyData( aOperator );
}
+//--------------------------------------------------------------------------------------
// ____ XChartData (base of XChartDataArray) ____
void SAL_CALL ChartDataWrapper::addChartDataChangeEventListener(
@@ -297,13 +435,7 @@ void SAL_CALL ChartDataWrapper::dispose()
throw (uno::RuntimeException)
{
m_aEventListenerContainer.disposeAndClear( lang::EventObject( static_cast< ::cppu::OWeakObject* >( this )));
-
- // /--
- MutexGuard aGuard( GetMutex());
- m_aData.realloc( 0 );
- m_aColumnDescriptions.realloc( 0 );
- m_aRowDescriptions.realloc( 0 );
- // \--
+ m_xDataAccess=0;
}
void SAL_CALL ChartDataWrapper::addEventListener(
@@ -354,160 +486,39 @@ void ChartDataWrapper::fireChartDataChangeEvent(
}
}
-void ChartDataWrapper::refreshData()
+// --------------------------------------------------------------------------------
+
+void ChartDataWrapper::switchToInternalDataProvider()
+{
+ //create an internal data provider that is connected to the model
+ Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
+ if( xChartDoc.is() )
+ xChartDoc->createInternalDataProvider( true /*bCloneExistingData*/ );
+ initDataAccess();
+}
+
+void ChartDataWrapper::initDataAccess()
{
- //todo mutex...
Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
if( !xChartDoc.is() )
return;
- if( xChartDoc->hasInternalDataProvider())
- {
- try {
- uno::Reference< ::com::sun::star::chart::XChartDataArray > xInternalData( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
- m_aColumnDescriptions = xInternalData->getColumnDescriptions();
- m_aRowDescriptions = xInternalData->getRowDescriptions();
- m_aData = lcl_getDBL_MINInsteadNAN( xInternalData->getData() );
- }
- catch( const uno::Exception & ex ) {
- ASSERT_EXCEPTION( ex );
- }
- }
+ if( xChartDoc->hasInternalDataProvider() )
+ m_xDataAccess = Reference< XComplexDescriptionAccess >( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
else
{
- uno::Reference< chart2::XDiagram > xDia(
- xChartDoc->getFirstDiagram() );
- if( ! xDia.is())
- return;
-
- // get information about the segmentation of the assumed "rectangular" data
- // range
- ::rtl::OUString aRangeString;
- bool bUseColumns = true;
- bool bFirstCellAsLabel = true;
- bool bHasCategories = true;
- uno::Sequence< sal_Int32 > aSequenceMapping;
-
- DataSourceHelper::detectRangeSegmentation(
- uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ),
- aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories );
-
-
- // get data values from data series
- // --------------------------------
- uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledSequences;
- uno::Reference< chart2::data::XDataSource > xRectangularDataSource(
- DataSourceHelper::pressUsedDataIntoRectangularFormat( xChartDoc, false /*bWithCategories*/ ) );
- if( xRectangularDataSource.is() )
- {
- aLabeledSequences = xRectangularDataSource->getDataSequences();
- }
-
- ::std::vector< uno::Reference< chart2::data::XDataSequence > > aSequenceVector;
- ::std::vector< ::rtl::OUString > aLabelVector;
- for( sal_Int32 nN=0; nN<aLabeledSequences.getLength(); nN++ )
- lcl_AddSequences( aLabeledSequences[nN], aSequenceVector, aLabelVector );
-
- if( aSequenceMapping.getLength() )
- {
- //aSequenceVector and aLabelVector contain changed positions; resort them to the original position
- ::std::vector< uno::Reference< chart2::data::XDataSequence > > aBackSortedSequences;
- ::std::vector< ::rtl::OUString > aBackSortedLabels;
-
- std::map< sal_Int32, sal_Int32 > aReverseMap;
- {
- sal_Int32 nNewIndex, nOldIndex;
- for( sal_Int32 nS=0; nS <aSequenceMapping.getLength(); nS++ )
- {
- nOldIndex = aSequenceMapping[nS];
- nNewIndex = nS;
- if( bHasCategories )
- nNewIndex--;
- if( nOldIndex >= 0 && nNewIndex >= 0 )
- aReverseMap[nOldIndex] = nNewIndex;
- }
- }
-
- std::map< sal_Int32, sal_Int32 >::iterator aMapIt = aReverseMap.begin();
- std::map< sal_Int32, sal_Int32 >::const_iterator aMapEnd = aReverseMap.end();
-
- for( ; aMapIt != aMapEnd; ++aMapIt )
- {
- size_t nNewIndex = static_cast< size_t >( aMapIt->second );
- if( nNewIndex < aSequenceVector.size() )
- aBackSortedSequences.push_back( aSequenceVector[nNewIndex] );
- if( nNewIndex < aLabelVector.size() )
- aBackSortedLabels.push_back( aLabelVector[nNewIndex] );
- }
-
- // note: assign( beg, end ) doesn't work on solaris
- aSequenceVector.clear();
- aSequenceVector.insert(
- aSequenceVector.begin(), aBackSortedSequences.begin(), aBackSortedSequences.end() );
- aLabelVector.clear();
- aLabelVector.insert(
- aLabelVector.begin(), aBackSortedLabels.begin(), aBackSortedLabels.end() );
- }
-
- if( bUseColumns )
- {
- const sal_Int32 nInnerSize = aSequenceVector.size();
- if( nInnerSize > 0 && aSequenceVector[0].is() )
- {
- // take the length of the first data series also as length for all
- // other series
- const sal_Int32 nOuterSize = aSequenceVector[0]->getData().getLength();
-
- m_aData.realloc( nOuterSize );
- for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter )
- m_aData[nOuter].realloc( nInnerSize );
-
- for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner )
- {
- uno::Sequence< double > aValues = uno::Sequence< double > (
- lcl_DataSequenceToDoubleSeq() (aSequenceVector[nInner] ));
- sal_Int32 nMax = ::std::min( nOuterSize, aValues.getLength());
- for( sal_Int32 nOuter=0; nOuter<nMax; ++nOuter )
- m_aData[nOuter][nInner] = aValues[nOuter];
- }
- }
- }
- else
- {
- m_aData.realloc( static_cast< sal_Int32 >( aSequenceVector.size()));
- ::std::transform( aSequenceVector.begin(), aSequenceVector.end(),
- m_aData.getArray(),
- lcl_DataSequenceToDoubleSeq() );
- }
-
- // labels (values already filled during parsing of data values)
- if( bUseColumns )
- m_aColumnDescriptions = ::chart::ContainerHelper::ContainerToSequence( aLabelVector );
- else
- m_aRowDescriptions = ::chart::ContainerHelper::ContainerToSequence( aLabelVector );
-
- // get row-/column descriptions
- // ----------------------------
- // categories
- uno::Sequence< ::rtl::OUString > & rSequence =
- bUseColumns ? m_aRowDescriptions : m_aColumnDescriptions;
- rSequence = DiagramHelper::generateAutomaticCategories( xChartDoc );
+ //create a separate "internal data provider" that is not connected to the model
+ m_xDataAccess = Reference< XComplexDescriptionAccess >( ChartModelHelper::createInternalDataProvider(
+ xChartDoc, false /*bConnectToModel*/ ), uno::UNO_QUERY_THROW );
}
}
-void ChartDataWrapper::applyData( bool bSetValues, bool bSetRowDescriptions, bool bSetColumnDescriptions )
+void ChartDataWrapper::applyData( lcl_Operator& rDataOperator )
{
+ //bool bSetValues, bool bSetRowDescriptions, bool bSetColumnDescriptions
Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
if( !xChartDoc.is() )
return;
- // /-- locked controllers
- ControllerLockGuard aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ));
- // should do nothing if we already have an internal data provider
- xChartDoc->createInternalDataProvider( sal_True /* bCloneExistingData */ );
-
- uno::Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider());
- uno::Reference< XChartDataArray > xDocDataArray( xDataProvider, uno::UNO_QUERY );
-
// remember some diagram properties to reset later
sal_Bool bStacked = sal_False;
sal_Bool bPercent = sal_False;
@@ -533,71 +544,24 @@ void ChartDataWrapper::applyData( bool bSetValues, bool bSetRowDescriptions, boo
uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ),
aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories );
- if( !bFirstCellAsLabel )
- {
- if( bSetRowDescriptions && !bUseColumns )
- bFirstCellAsLabel = true;
- else if( bSetColumnDescriptions && bUseColumns )
- bFirstCellAsLabel = true;
- }
- if( !bHasCategories )
- {
- if( bSetColumnDescriptions && bUseColumns )
- bHasCategories = true;
- else if( bSetRowDescriptions && !bUseColumns )
- bHasCategories = true;
- }
+ if( !bHasCategories && rDataOperator.setsCategories( bUseColumns ) )
+ bHasCategories = true;
- aRangeString = C2U("all");
uno::Sequence< beans::PropertyValue > aArguments( DataSourceHelper::createArguments(
aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories ) );
- // create and attach new data source
- uno::Reference< chart2::data::XDataSource > xSource;
- if( xDocDataArray.is() )
- {
- // we have an internal data provider that supports the XChartDataArray
- // interface
- if( bSetValues )
- xDocDataArray->setData( lcl_getNANInsteadDBL_MIN( m_aData ) );
- if( bSetRowDescriptions )
- xDocDataArray->setRowDescriptions( m_aRowDescriptions );
- if( bSetColumnDescriptions )
- xDocDataArray->setColumnDescriptions( m_aColumnDescriptions );
-
- xSource.set( xDataProvider->createDataSource( aArguments ));
- }
- else
- {
- uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
- OSL_ASSERT( xChartDoc.is());
- OSL_ASSERT( xReceiver.is());
- if( ! (xChartDoc.is() && xReceiver.is()))
- return;
- // create a data provider containing the new data
- uno::Reference< chart2::data::XDataProvider > xTempDataProvider(
- ChartModelHelper::createInternalDataProvider() );
- if( ! xTempDataProvider.is())
- throw uno::RuntimeException( C2U("Couldn't create temporary data provider"),
- static_cast< ::cppu::OWeakObject * >( this ));
+ // /-- locked controllers
+ ControllerLockGuard aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ));
- uno::Reference< ::com::sun::star::chart::XChartDataArray > xDataArray( xTempDataProvider, uno::UNO_QUERY );
- OSL_ASSERT( xDataArray.is());
- if( xDataArray.is())
- {
- if( bSetValues )
- xDataArray->setData( lcl_getNANInsteadDBL_MIN( m_aData ) );
- if( bSetRowDescriptions )
- xDataArray->setRowDescriptions( m_aRowDescriptions );
- if( bSetColumnDescriptions )
- xDataArray->setColumnDescriptions( m_aColumnDescriptions );
-
- // removes existing data provider and attaches the new one
- xReceiver->attachDataProvider( xTempDataProvider );
- xSource.set( xTempDataProvider->createDataSource( aArguments));
- }
- }
+ // create and attach new data source
+ switchToInternalDataProvider();
+ rDataOperator.apply(m_xDataAccess);
+ uno::Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
+ OSL_ASSERT( xDataProvider.is() );
+ if( !xDataProvider.is() )
+ return;
+ uno::Reference< chart2::data::XDataSource > xSource( xDataProvider->createDataSource( aArguments ) );
// determine a template
uno::Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
@@ -621,8 +585,7 @@ void ChartDataWrapper::applyData( bool bSetValues, bool bSetRowDescriptions, boo
// argument detection works with internal knowledge of the
// ArrayDataProvider
OSL_ASSERT( xDia.is());
- xTemplate->changeDiagramData(
- xDia, xSource, aArguments );
+ xTemplate->changeDiagramData( xDia, xSource, aArguments );
}
//correct stacking mode
diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx
index 6bdae0350184..d56397953d79 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx
@@ -31,7 +31,7 @@
#include "MutexContainer.hxx"
#include <cppuhelper/implbase4.hxx>
#include <cppuhelper/interfacecontainer.hxx>
-#include <com/sun/star/chart/XChartDataArray.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
@@ -45,23 +45,40 @@ namespace wrapper
{
class Chart2ModelContact;
+struct lcl_Operator;
class ChartDataWrapper : public MutexContainer, public
::cppu::WeakImplHelper4<
- com::sun::star::chart::XChartDataArray,
+ com::sun::star::chart::XComplexDescriptionAccess,
com::sun::star::lang::XServiceInfo,
com::sun::star::lang::XEventListener,
com::sun::star::lang::XComponent >
{
public:
ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact );
+ ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact
+ , const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartData >& xNewData );
virtual ~ChartDataWrapper();
/// XServiceInfo declarations
APPHELPER_XSERVICEINFO_DECL()
protected:
- // ____ XChartDataArray ____
+ // ____ XComplexDescriptionAccess ____
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL
+ getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setComplexRowDescriptions(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aRowDescriptions )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL
+ getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setComplexColumnDescriptions(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aColumnDescriptions )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
virtual ::com::sun::star::uno::Sequence<
::com::sun::star::uno::Sequence<
double > > SAL_CALL getData()
@@ -112,20 +129,17 @@ protected:
void fireChartDataChangeEvent( ::com::sun::star::chart::ChartDataChangeEvent& aEvent );
-private:
- ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
- ::cppu::OInterfaceContainerHelper m_aEventListenerContainer;
-
- ::com::sun::star::uno::Sequence<
- ::com::sun::star::uno::Sequence< double > > m_aData;
- ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aColumnDescriptions;
- ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aRowDescriptions;
+private: //methods
+ void switchToInternalDataProvider();
+ void initDataAccess();
+ void applyData( lcl_Operator& rDataOperator );
- /// re-reads the data from the model
- void refreshData();
+private: //member
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart::XComplexDescriptionAccess > m_xDataAccess;
- /// applies changed data to model
- void applyData( bool bSetValues, bool bSetRowDescriptions, bool bSetColumnDescriptions );
+ ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact;
+ ::cppu::OInterfaceContainerHelper m_aEventListenerContainer;
};
} // namespace wrapper
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index da0c9b4e8167..67f537c49b98 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -58,7 +58,7 @@
#include <com/sun/star/chart2/XTitled.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
-#include <com/sun/star/chart/XChartDataArray.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
#include <comphelper/InlineContainer.hxx>
// header for function SvxShapeCollection_NewInstance
#include <svx/unoshcol.hxx>
@@ -77,6 +77,7 @@
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart;
+using ::com::sun::star::chart::XComplexDescriptionAccess;
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
@@ -830,7 +831,7 @@ void SAL_CALL ChartDocumentWrapper::setDiagram( const Reference< XDiagram >& xDi
Reference< XChartData > SAL_CALL ChartDocumentWrapper::getData()
throw (uno::RuntimeException)
{
- if( ! m_xChartData.is())
+ if( !m_xChartData.is() )
{
m_xChartData.set( new ChartDataWrapper( m_spChart2ModelContact ) );
}
@@ -839,128 +840,15 @@ Reference< XChartData > SAL_CALL ChartDocumentWrapper::getData()
return m_xChartData;
}
-void SAL_CALL ChartDocumentWrapper::attachData( const Reference< XChartData >& xData )
+void SAL_CALL ChartDocumentWrapper::attachData( const Reference< XChartData >& xNewData )
throw (uno::RuntimeException)
{
- if( !xData.is())
+ if( !xNewData.is() )
return;
- Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() );
- if( !xChartDoc.is() )
- return;
-
- uno::Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider());
- uno::Reference< XChartDataArray > xDocDataArray( xDataProvider, uno::UNO_QUERY );
- uno::Reference< XChartDataArray > xDataArray( xData, uno::UNO_QUERY );
- OSL_ASSERT( xDataArray.is());
- if( ! xDataArray.is() ||
- xDocDataArray == xDataArray )
- return;
-
- // remember some diagram properties to reset later
- ChartDataRowSource eSeriesSource = ChartDataRowSource_ROWS;
- sal_Bool bStacked = sal_False;
- sal_Bool bPercent = sal_False;
- sal_Bool bDeep = sal_False;
- Reference< beans::XPropertySet > xDiaProp( getDiagram(), uno::UNO_QUERY );
- if( xDiaProp.is())
- {
- xDiaProp->getPropertyValue( C2U("DataRowSource")) >>= eSeriesSource;
- xDiaProp->getPropertyValue( C2U("Stacked")) >>= bStacked;
- xDiaProp->getPropertyValue( C2U("Percent")) >>= bPercent;
- xDiaProp->getPropertyValue( C2U("Deep")) >>= bDeep;
- }
-
- // create and attach new data source
- uno::Reference< chart2::data::XDataSource > xSource;
- Sequence< beans::PropertyValue > aArguments( 4 );
- aArguments[0] = beans::PropertyValue(
- C2U("CellRangeRepresentation"), -1, uno::makeAny( C2U("all") ),
- beans::PropertyState_DIRECT_VALUE );
- aArguments[1] = beans::PropertyValue(
- C2U("DataRowSource"), -1, uno::makeAny( eSeriesSource ),
- beans::PropertyState_DIRECT_VALUE );
- aArguments[2] = beans::PropertyValue(
- C2U("FirstCellAsLabel"), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
- aArguments[3] = beans::PropertyValue(
- C2U("HasCategories"), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
-
// /-- locked controllers
- ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ));
- if( xDocDataArray.is())
- {
- // we have an internal data provider that supports the XChartDataArray
- // interface
- xDocDataArray->setData( xDataArray->getData());
- xDocDataArray->setRowDescriptions( xDataArray->getRowDescriptions());
- xDocDataArray->setColumnDescriptions( xDataArray->getColumnDescriptions());
-
- xSource.set( xDataProvider->createDataSource( aArguments ));
- }
- else
- {
- uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
- OSL_ASSERT( xChartDoc.is());
- OSL_ASSERT( xReceiver.is());
- OSL_ASSERT( xDataArray.is());
- if( ! (xChartDoc.is() &&
- xReceiver.is()))
- return;
-
- // create a data provider containing the new data
- Reference< chart2::data::XDataProvider > xTempDataProvider(
- ChartModelHelper::createInternalDataProvider( xDataArray ));
-
- if( ! xTempDataProvider.is())
- throw uno::RuntimeException( C2U("Couldn't create temporary data provider"),
- static_cast< ::cppu::OWeakObject * >( this ));
-
- // removes existing data provider and attaches the new one
- xReceiver->attachDataProvider( xTempDataProvider );
- xSource.set( xTempDataProvider->createDataSource( aArguments));
- }
-
- // determine a template
- Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
- Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram());
- DiagramHelper::tTemplateWithServiceName aTemplateAndService =
- DiagramHelper::getTemplateForDiagram( xDia, xFact );
- OUString aServiceName( aTemplateAndService.second );
- Reference< chart2::XChartTypeTemplate > xTemplate = aTemplateAndService.first;
-
- // (fall-back)
- if( ! xTemplate.is())
- {
- if( aServiceName.getLength() == 0 )
- aServiceName = C2U("com.sun.star.chart2.template.Column");
- xTemplate.set( xFact->createInstance( aServiceName ), uno::UNO_QUERY );
- }
- OSL_ASSERT( xTemplate.is());
-
- if( xTemplate.is() && xSource.is())
- {
- // argument detection works with internal knowledge of the
- // ArrayDataProvider
- OSL_ASSERT( xDia.is());
- xTemplate->changeDiagramData(
- xDia, xSource, aArguments );
- }
-
- // should do nothing if we already have an internal data provider
- xChartDoc->createInternalDataProvider( sal_True /* bCloneExistingData */ );
-
- //correct stacking mode
- if( bStacked || bPercent || bDeep )
- {
- StackMode eStackMode = StackMode_Y_STACKED;
- if( bDeep )
- eStackMode = StackMode_Z_STACKED;
- else if( bPercent )
- eStackMode = StackMode_Y_STACKED_PERCENT;
- DiagramHelper::setStackMode( xDia, eStackMode );
- }
-
- m_xChartData = xData;
+ ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( m_spChart2ModelContact->getChart2Document(), uno::UNO_QUERY ));
+ m_xChartData.set( new ChartDataWrapper( m_spChart2ModelContact, xNewData ) );
// \-- locked controllers
}
diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx
index 1265f4412f2a..67930fc6f7a7 100644
--- a/chart2/source/controller/dialogs/DataBrowser.cxx
+++ b/chart2/source/controller/dialogs/DataBrowser.cxx
@@ -45,6 +45,8 @@
#include "DataSeriesHelper.hxx"
#include "DiagramHelper.hxx"
#include "ChartModelHelper.hxx"
+#include "CommonConverters.hxx"
+#include "macros.hxx"
#include "chartview/NumberFormatterWrapper.hxx"
#include "servicenames_charttypes.hxx"
#include "ResId.hxx"
@@ -187,6 +189,8 @@ public:
sal_Int32 GetStartColumn() const;
sal_Int32 GetEndColumn() const;
+ static sal_Int32 GetRelativeAppFontXPosForNameField();
+
void Show();
/** call this before destroying the class. This notifies the listeners to
@@ -262,23 +266,30 @@ void SeriesHeader::SetColor( const Color & rCol )
m_spColorBar->SetControlBackground( rCol );
}
+const sal_Int32 nSymbolHeight = 10;
+const sal_Int32 nSymbolDistance = 2;
+
+sal_Int32 SeriesHeader::GetRelativeAppFontXPosForNameField()
+{
+ return nSymbolHeight + nSymbolDistance;
+}
+
void SeriesHeader::SetPos( const Point & rPos )
{
m_aPos = rPos;
// chart type symbol
- sal_Int32 nHeight = 10;
Point aPos( rPos );
- aPos.setY( aPos.getY() + 2 );
- Size aSize( nHeight, nHeight );
+ aPos.setY( aPos.getY() + nSymbolDistance );
+ Size aSize( nSymbolHeight, nSymbolHeight );
m_spSymbol->SetPosPixel( m_pDevice->LogicToPixel( aPos, MAP_APPFONT ));
m_spSymbol->SetSizePixel( m_pDevice->LogicToPixel( aSize, MAP_APPFONT ));
- aPos.setY( aPos.getY() - 2 );
+ aPos.setY( aPos.getY() - nSymbolDistance );
// series name edit field
- aPos.setX( aPos.getX() + nHeight + 2 );
- aSize.setWidth( m_nWidth - nHeight - 2 );
- nHeight = 12;
+ aPos.setX( aPos.getX() + nSymbolHeight + nSymbolDistance );
+ aSize.setWidth( m_nWidth - nSymbolHeight - nSymbolDistance );
+ sal_Int32 nHeight = 12;
aSize.setHeight( nHeight );
m_spSeriesName->SetPosPixel( m_pDevice->LogicToPixel( aPos, MAP_APPFONT ));
m_spSeriesName->SetSizePixel( m_pDevice->LogicToPixel( aSize, MAP_APPFONT ));
@@ -553,25 +564,14 @@ bool DataBrowser::MaySwapColumns() const
return (static_cast< sal_uInt32 >( nColIndex ) < (m_aSeriesHeaders.size() - 1));
}
+ sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders );
return ! IsReadOnly()
- && ( GetCurColumnId() > 1 )
- && ( GetCurColumnId() < ColCount() - 1 );
+ && ( nColIdx > 0 )
+ && ( nColIdx < ColCount()-2 )
+ && m_apDataBrowserModel.get()
+ && !m_apDataBrowserModel->isCategoriesColumn( nColIdx );
}
-// bool DataBrowser::MaySortRow() const
-// {
-// // not implemented
-// return false;
-// // return ! IsReadOnly() && ( GetCurRow() >= 0 );
-// }
-
-// bool DataBrowser::MaySortColumn() const
-// {
-// // not implemented
-// return false;
-// // return ! IsReadOnly() && ( GetCurColumnId() > 1 );
-// }
-
void DataBrowser::clearHeaders()
{
::std::for_each( m_aSeriesHeaders.begin(), m_aSeriesHeaders.end(), impl::applyChangesFunctor());
@@ -601,9 +601,10 @@ void DataBrowser::RenewTable()
InsertHandleColumn( static_cast< sal_uInt16 >(
GetDataWindow().LogicToPixel( Size( 42, 0 )).getWidth() ));
- const sal_Int32 nDefaultColumnWidth = 94;
-
- sal_Int32 nColumnWidth( GetDataWindow().LogicToPixel( Size( nDefaultColumnWidth, 0 )).getWidth());
+ OUString aDefaultSeriesName( ::chart::SchResId::getResString( STR_COLUMN_LABEL ));
+ replaceParamterInString( aDefaultSeriesName, C2U("%COLUMNNUMBER"), OUString::valueOf( sal_Int32(24) ) );
+ sal_Int32 nColumnWidth = GetDataWindow().GetTextWidth( aDefaultSeriesName )
+ + GetDataWindow().LogicToPixel( Point( 4 + impl::SeriesHeader::GetRelativeAppFontXPosForNameField(), 0 ), MAP_APPFONT ).X();
sal_Int32 nColumnCount = m_apDataBrowserModel->getColumnCount();
// nRowCount is a member of a base class
sal_Int32 nRowCountLocal = m_apDataBrowserModel->getMaxRowCount();
@@ -882,6 +883,22 @@ void DataBrowser::InsertColumn()
}
}
+void DataBrowser::InsertTextColumn()
+{
+ sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders );
+
+ if( nColIdx >= 0 &&
+ m_apDataBrowserModel.get())
+ {
+ // save changes made to edit-field
+ if( IsModified() )
+ SaveModified();
+
+ m_apDataBrowserModel->insertComplexCategoryLevel( nColIdx );
+ RenewTable();
+ }
+}
+
void DataBrowser::RemoveColumn()
{
sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders );
@@ -894,7 +911,7 @@ void DataBrowser::RemoveColumn()
SaveModified();
m_bDataValid = true;
- m_apDataBrowserModel->removeDataSeries( nColIdx );
+ m_apDataBrowserModel->removeDataSeriesOrComplexCategoryLevel( nColIdx );
RenewTable();
}
}
diff --git a/chart2/source/controller/dialogs/DataBrowser.hxx b/chart2/source/controller/dialogs/DataBrowser.hxx
index 97c952c2cee9..3583db2770c0 100644
--- a/chart2/source/controller/dialogs/DataBrowser.hxx
+++ b/chart2/source/controller/dialogs/DataBrowser.hxx
@@ -121,12 +121,10 @@ public:
bool MaySwapRows() const;
bool MaySwapColumns() const;
-// bool MaySortRow() const;
-// bool MaySortColumn() const;
-
// mutators mutating data
void InsertRow();
void InsertColumn();
+ void InsertTextColumn();
void RemoveRow();
void RemoveColumn();
diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx
index decdda0f8793..c0b865536686 100644
--- a/chart2/source/controller/dialogs/DataBrowserModel.cxx
+++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx
@@ -40,6 +40,7 @@
#include "ContainerHelper.hxx"
#include "ChartTypeHelper.hxx"
#include "chartview/ExplicitValueProvider.hxx"
+#include "ExplicitCategoriesProvider.hxx"
#include <com/sun/star/container/XIndexReplace.hpp>
#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
@@ -51,6 +52,7 @@
#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
#include <rtl/math.hxx>
@@ -322,6 +324,9 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex )
m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
if( xDataProvider.is())
{
+ if( isCategoriesColumn(nAfterColumnIndex) )
+ nAfterColumnIndex = getCategoryColumnCount()-1;
+
sal_Int32 nStartCol = 0;
Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartDocument ));
Reference< chart2::XChartType > xChartType;
@@ -353,7 +358,7 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex )
{
sal_Int32 nOffset = 0;
if( xDiagram.is() && lcl_ShowCategories( xDiagram ))
- ++nOffset;
+ nOffset=getCategoryColumnCount();
// get shared sequences of current series
Reference< chart2::XDataSeriesContainer > xSeriesCnt( xChartType, uno::UNO_QUERY );
lcl_tSharedSeqVec aSharedSequences;
@@ -423,7 +428,31 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex )
}
}
-void DataBrowserModel::removeDataSeries( sal_Int32 nAtColumnIndex )
+void DataBrowserModel::insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex )
+{
+ //create a new text column for complex categories
+
+ OSL_ASSERT( m_apDialogModel.get());
+ Reference< chart2::XInternalDataProvider > xDataProvider( m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
+ if( xDataProvider.is() )
+ {
+ if( !isCategoriesColumn(nAfterColumnIndex) )
+ nAfterColumnIndex = getCategoryColumnCount()-1;
+
+ if(nAfterColumnIndex<0)
+ {
+ OSL_ENSURE( false, "wrong index for category level insertion" );
+ return;
+ }
+
+ m_apDialogModel->startControllerLockTimer();
+ ControllerLockGuard aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) );
+ xDataProvider->insertComplexCategoryLevel( nAfterColumnIndex+1 );
+ updateFromModel();
+ }
+}
+
+void DataBrowserModel::removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex )
{
OSL_ASSERT( m_apDialogModel.get());
if( static_cast< tDataColumnVector::size_type >( nAtColumnIndex ) < m_aColumns.size())
@@ -474,6 +503,20 @@ void DataBrowserModel::removeDataSeries( sal_Int32 nAtColumnIndex )
}
updateFromModel();
}
+ else
+ {
+ //delete a category column if there is more than one level (in case of a single column we do not get here)
+ OSL_ENSURE(nAtColumnIndex>0, "wrong index for categories deletion" );
+
+ Reference< chart2::XInternalDataProvider > xDataProvider( m_apDialogModel->getDataProvider(), uno::UNO_QUERY );
+ if( xDataProvider.is() )
+ {
+ m_apDialogModel->startControllerLockTimer();
+ ControllerLockGuard aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) );
+ xDataProvider->deleteComplexCategoryLevel( nAtColumnIndex );
+ updateFromModel();
+ }
+ }
}
}
@@ -614,6 +657,8 @@ bool DataBrowserModel::setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const
bResult = true;
try
{
+ ControllerLockGuard aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) );
+
// label
if( nAtRow == -1 )
{
@@ -627,6 +672,12 @@ bool DataBrowserModel::setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const
m_aColumns[ nIndex ].m_xLabeledDataSequence->getValues(), uno::UNO_QUERY_THROW );
xIndexReplace->replaceByIndex( nAtRow, rValue );
}
+
+ m_apDialogModel->startControllerLockTimer();
+ //notify change directly to the model (this is necessary here as sequences for complex categories not known directly to the chart model so they do not notify their changes) (for complex categories see issue #i82971#)
+ Reference< util::XModifiable > xModifiable( m_xChartDocument, uno::UNO_QUERY );
+ if( xModifiable.is() )
+ xModifiable->setModified(true);
}
catch( const uno::Exception & ex )
{
@@ -683,11 +734,26 @@ OUString DataBrowserModel::getRoleOfColumn( sal_Int32 nColumnIndex ) const
return OUString();
}
-Reference< chart2::data::XLabeledDataSequence >
- DataBrowserModel::getCategories() const throw()
+bool DataBrowserModel::isCategoriesColumn( sal_Int32 nColumnIndex ) const
{
- OSL_ASSERT( m_apDialogModel.get());
- return m_apDialogModel->getCategories();
+ bool bIsCategories = false;
+ if( nColumnIndex>=0 && nColumnIndex<static_cast< sal_Int32 >(m_aColumns.size()) )
+ bIsCategories = !m_aColumns[ nColumnIndex ].m_xDataSeries.is();
+ return bIsCategories;
+}
+
+sal_Int32 DataBrowserModel::getCategoryColumnCount()
+{
+ sal_Int32 nLastTextColumnIndex = -1;
+ tDataColumnVector::const_iterator aIt = m_aColumns.begin();
+ for( ; aIt != m_aColumns.end(); ++aIt )
+ {
+ if( !aIt->m_xDataSeries.is() )
+ nLastTextColumnIndex++;
+ else
+ break;
+ }
+ return nLastTextColumnIndex+1;
}
const DataBrowserModel::tDataHeaderVector& DataBrowserModel::getDataHeaders() const
@@ -717,16 +783,27 @@ void DataBrowserModel::updateFromModel()
sal_Int32 nHeaderEnd = 0;
if( lcl_ShowCategories( xDiagram ))
{
- Reference< chart2::data::XLabeledDataSequence > xCategories( this->getCategories());
- tDataColumn aCategories;
- aCategories.m_xLabeledDataSequence.set( xCategories );
- if( lcl_ShowCategoriesAsDataLabel( xDiagram ))
- aCategories.m_aUIRoleName = DialogModel::GetRoleDataLabel();
- else
- aCategories.m_aUIRoleName = lcl_getUIRoleName( xCategories );
- aCategories.m_eCellType = TEXT;
- m_aColumns.push_back( aCategories );
- ++nHeaderStart;
+ Reference< frame::XModel > xChartModel( m_xChartDocument, uno::UNO_QUERY );
+ ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel );
+
+ const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() );
+ sal_Int32 nLevelCount = rSplitCategoriesList.getLength();
+ for( sal_Int32 nL = 0; nL<nLevelCount; nL++ )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xCategories( rSplitCategoriesList[nL] );
+ if( !xCategories.is() )
+ continue;
+
+ tDataColumn aCategories;
+ aCategories.m_xLabeledDataSequence.set( xCategories );
+ if( lcl_ShowCategoriesAsDataLabel( xDiagram ))
+ aCategories.m_aUIRoleName = DialogModel::GetRoleDataLabel();
+ else
+ aCategories.m_aUIRoleName = lcl_getUIRoleName( xCategories );
+ aCategories.m_eCellType = TEXT;
+ m_aColumns.push_back( aCategories );
+ ++nHeaderStart;
+ }
}
Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY );
diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx
index 5b6a6e41c01b..a4378972f70f 100644
--- a/chart2/source/controller/dialogs/DataBrowserModel.hxx
+++ b/chart2/source/controller/dialogs/DataBrowserModel.hxx
@@ -60,10 +60,14 @@ public:
*/
void insertDataSeries( sal_Int32 nAfterColumnIndex );
+ /** Inserts a new text column for complex categories.
+ */
+ void insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex );
+
/** Removes a data series to which the data column with index nAtColumnIndex
belongs.
*/
- void removeDataSeries( sal_Int32 nAtColumnIndex );
+ void removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex );
/** Swaps the series to which the data column with index nFirstIndex belongs
with the next series (which starts at an index >= nFirstIndex + 1)
@@ -97,6 +101,7 @@ public:
// returns the UI string of the corresponding role
::rtl::OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const;
+ bool isCategoriesColumn( sal_Int32 nColumnIndex ) const;
struct tDataHeader
{
@@ -153,9 +158,7 @@ private:
sal_Int32 & rInOutSequenceIndex,
sal_Int32 & rInOutHeaderEnd );
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XLabeledDataSequence >
- getCategories() const throw();
+ sal_Int32 getCategoryColumnCount();
::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartDocument > m_xChartDocument;
diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx
index a8d9288e381f..f104045727bb 100644
--- a/chart2/source/controller/dialogs/DialogModel.cxx
+++ b/chart2/source/controller/dialogs/DialogModel.cxx
@@ -827,8 +827,6 @@ void DialogModel::applyInterpretedData(
DialogModel::setCategories(rNewData.Categories);
}
-
- OSL_ASSERT( ! rNewData.UnusedData.hasElements());
}
sal_Int32 DialogModel::countSeries() const
diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx
index a29e91457c93..0836ab9ca93a 100644
--- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx
+++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx
@@ -46,8 +46,6 @@
#include <tools/debug.hxx>
#include <tools/string.hxx>
-// #include <unotools/syslocale.hxx>
-
#include <com/sun/star/chart2/XTitle.hpp>
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
@@ -197,7 +195,7 @@ OUString lcl_getDataPointValueText( const Reference< XDataSeries >& xSeries, sal
replaceParamterInString( aCategory
, C2U("%CATEGORYVALUE")
- , ExplicitCategoriesProvider::getCategoryByIndex( xCooSys, nPointIndex )
+ , ExplicitCategoriesProvider::getCategoryByIndex( xCooSys, xChartModel, nPointIndex )
);
aRet = aCategory;
diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.cxx b/chart2/source/controller/dialogs/dlg_DataEditor.cxx
index 41539df061b9..f1d441921a6a 100644
--- a/chart2/source/controller/dialogs/dlg_DataEditor.cxx
+++ b/chart2/source/controller/dialogs/dlg_DataEditor.cxx
@@ -144,34 +144,22 @@ IMPL_LINK( DataEditor, ToolboxHdl, void *, EMPTYARG )
break;
case TBI_DATA_INSERT_COL:
m_apBrwData->InsertColumn();
-// ImplAdjustHeaderControls( true /* bRefreshFromModel */ );
+ break;
+ case TBI_DATA_INSERT_TEXT_COL:
+ m_apBrwData->InsertTextColumn();
break;
case TBI_DATA_DELETE_ROW:
m_apBrwData->RemoveRow();
break;
case TBI_DATA_DELETE_COL:
m_apBrwData->RemoveColumn();
-// ImplAdjustHeaderControls( true /* bRefreshFromModel */ );
break;
case TBI_DATA_SWAP_COL :
m_apBrwData->SwapColumn ();
-// ImplAdjustHeaderControls( true /* bRefreshFromModel */ );
break;
case TBI_DATA_SWAP_ROW :
m_apBrwData->SwapRow ();
break;
-// case TBI_DATA_SORT_COL :
-// m_apBrwData->QuickSortCol();
-// break;
-// case TBI_DATA_SORT_ROW :
-// m_apBrwData->QuickSortRow();
-// break;
-// case TBI_DATA_SORT_TABLE_COL :
-// m_apBrwData->QuickSortTableCols ();
-// break;
-// case TBI_DATA_SORT_TABLE_ROW :
-// m_apBrwData->QuickSortTableRows ();
-// break;
}
return 0;
@@ -183,27 +171,16 @@ IMPL_LINK( DataEditor, BrowserCursorMovedHdl, void *, EMPTYARG )
if( m_bReadOnly )
return 0;
- if( m_apBrwData->IsEnableItem() )
- {
- m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, m_apBrwData->MayInsertRow() );
- m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, m_apBrwData->MayInsertColumn() );
- m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, m_apBrwData->MayDeleteRow() );
- m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, m_apBrwData->MayDeleteColumn() );
+ bool bIsDataValid = m_apBrwData->IsEnableItem();
- m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, m_apBrwData->MaySwapColumns() );
- m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, m_apBrwData->MaySwapRows() );
- }
- else
- {
- m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, FALSE );
- m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, FALSE );
- m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, FALSE );
- m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, FALSE );
- }
-// m_aTbxData.EnableItem( TBI_DATA_SORT_COL, m_apBrwData->MaySortColumn() );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_ROW, m_apBrwData->MaySortRow() );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_COL, m_apBrwData->MaySortColumn() );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_ROW, m_apBrwData->MaySortRow() );
+ m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, bIsDataValid && m_apBrwData->MayInsertRow() );
+ m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() );
+ m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, bIsDataValid && m_apBrwData->MayInsertColumn() );
+ m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, m_apBrwData->MayDeleteRow() );
+ m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, m_apBrwData->MayDeleteColumn() );
+
+ m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, bIsDataValid && m_apBrwData->MaySwapColumns() );
+ m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, bIsDataValid && m_apBrwData->MaySwapRows() );
return 0;
}
@@ -216,14 +193,11 @@ void DataEditor::SetReadOnly( bool bReadOnly )
{
m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, FALSE );
m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, FALSE );
+ m_aTbxData.EnableItem( TBI_DATA_INSERT_TEXT_COL, FALSE );
m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, FALSE );
m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, FALSE );
m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, FALSE );
m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, FALSE );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_COL, FALSE );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_ROW, FALSE );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_ROW, FALSE );
-// m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_COL, FALSE );
}
m_apBrwData->SetReadOnly( m_bReadOnly );
diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.hrc b/chart2/source/controller/dialogs/dlg_DataEditor.hrc
index 8673f5e8cf80..d2675c5bb29e 100644
--- a/chart2/source/controller/dialogs/dlg_DataEditor.hrc
+++ b/chart2/source/controller/dialogs/dlg_DataEditor.hrc
@@ -33,19 +33,14 @@
#define CTL_DATA 1
// images for toolbox image list
+//the numbers correspond to the icon names: default_images\chart2\res\dataeditor_icon_xy
#define TBI_DATA_INSERT_ROW 1
#define TBI_DATA_INSERT_COL 2
#define TBI_DATA_DELETE_ROW 3
#define TBI_DATA_DELETE_COL 4
#define TBI_DATA_SWAP_COL 5
#define TBI_DATA_SWAP_ROW 6
-#define TBI_DATA_TRANSFER 7
-
-// #define TBI_DATA_SORT_ROW 7
-// #define TBI_DATA_SORT_COL 8
-// #define TBI_DATA_SORT_TABLE_ROW 9
-// #define TBI_DATA_SORT_TABLE_COL 10
-// #define TBI_DATA_TRANSFER 11
+#define TBI_DATA_INSERT_TEXT_COL 7
// image lists (normal and high-contrast) for toolbox
#define IL_DIAGRAM_DATA 1
diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.src b/chart2/source/controller/dialogs/dlg_DataEditor.src
index ce774e8f5bd2..dadd1ac3098d 100644
--- a/chart2/source/controller/dialogs/dlg_DataEditor.src
+++ b/chart2/source/controller/dialogs/dlg_DataEditor.src
@@ -80,6 +80,12 @@ ModalDialog DLG_DIAGRAM_DATA
};
ToolBoxItem
{
+ HelpID = HID_SCH_TBI_DATA_INSERT_TEXT_COL ;
+ Identifier = TBI_DATA_INSERT_TEXT_COL ;
+ Text [ en-US ] = "Insert Text Column" ;
+ };
+ ToolBoxItem
+ {
HelpID = HID_SCH_TBI_DATA_DELETE_ROW ;
Identifier = TBI_DATA_DELETE_ROW ;
Text [ en-US ] = "Delete Row" ;
@@ -118,11 +124,11 @@ ModalDialog DLG_DIAGRAM_DATA
{ \
TBI_DATA_INSERT_ROW; \
TBI_DATA_INSERT_COL; \
+ TBI_DATA_INSERT_TEXT_COL; \
TBI_DATA_DELETE_ROW; \
TBI_DATA_DELETE_COL; \
TBI_DATA_SWAP_COL; \
TBI_DATA_SWAP_ROW; \
- TBI_DATA_TRANSFER; \
}; \
IdCount = { 7; }
diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
index 285464dc90ff..2a41d35313e8 100644
--- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
+++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
@@ -204,7 +204,7 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel
ScaleData aScale( xCrossingMainAxis->getScaleData() );
m_bIsCrossingAxisIsCategoryAxis = ( chart2::AxisType::CATEGORY == aScale.AxisType );
if( m_bIsCrossingAxisIsCategoryAxis )
- m_aCategories = DiagramHelper::generateAutomaticCategories( Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY) );
+ m_aCategories = DiagramHelper::getExplicitSimpleCategories( Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY) );
}
}
}
diff --git a/chart2/source/controller/inc/HelpIds.hrc b/chart2/source/controller/inc/HelpIds.hrc
index 88cd1619bab8..1052b7ea962f 100644
--- a/chart2/source/controller/inc/HelpIds.hrc
+++ b/chart2/source/controller/inc/HelpIds.hrc
@@ -29,6 +29,7 @@
#include <svl/solar.hrc>
//next is 120
+//free: 20, 21, 22, 30, 31, 32, 33
//see old chart: schhids.h
@@ -61,21 +62,13 @@
//#define HID_SCH_CT_INDICATE2 (HID_SCH_START + 18)
//#define HID_SCH_CT_REGRESS2 (HID_SCH_START + 19)
-//#define HID_SCH_TBI_EDIT_CANCEL (HID_SCH_START + 20)
-//#define HID_SCH_TBI_EDIT_ACCEPT (HID_SCH_START + 21)
-#define HID_SCH_TBI_DATA_TRANSFER (HID_SCH_START + 22)
#define HID_SCH_TBI_DATA_INSERT_ROW (HID_SCH_START + 23)
#define HID_SCH_TBI_DATA_INSERT_COL (HID_SCH_START + 24)
#define HID_SCH_TBI_DATA_DELETE_ROW (HID_SCH_START + 25)
#define HID_SCH_TBI_DATA_DELETE_COL (HID_SCH_START + 26)
#define HID_SCH_TBI_DATA_SWAP_COL (HID_SCH_START + 27)
#define HID_SCH_TBI_DATA_SWAP_ROW (HID_SCH_START + 28)
-//#define HID_SCH_TBI_DATA_SORT_ROW (HID_SCH_START + 29)
-//#define HID_SCH_TBI_DATA_SORT_COL (HID_SCH_START + 30)
-//#define HID_SCH_TBI_DATA_SORT_TABLE_ROW (HID_SCH_START + 31)
-//#define HID_SCH_TBI_DATA_SORT_TABLE_COL (HID_SCH_START + 32)
-
-// #define HID_SCH_TBX_EDIT (HID_SCH_START + 33)
+#define HID_SCH_TBI_DATA_INSERT_TEXT_COL (HID_SCH_START + 29)
#define HID_SCH_TBX_DATA (HID_SCH_START + 34)
#define HID_SCH_ALIGNMENT_CTR_DIAL (HID_SCH_START + 35)
diff --git a/chart2/source/controller/main/ImplUndoManager.cxx b/chart2/source/controller/main/ImplUndoManager.cxx
index 5af76f2bd781..57e8e7315334 100644
--- a/chart2/source/controller/main/ImplUndoManager.cxx
+++ b/chart2/source/controller/main/ImplUndoManager.cxx
@@ -36,7 +36,7 @@
#include "DataSourceHelper.hxx"
#include "ChartModelHelper.hxx"
-#include <com/sun/star/chart/XChartDataArray.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/XInternalDataProvider.hpp>
#include <com/sun/star/chart2/XTitled.hpp>
@@ -52,7 +52,7 @@ using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
using ::rtl::OUString;
-using ::com::sun::star::chart::XChartDataArray;
+using ::com::sun::star::chart::XComplexDescriptionAccess;
namespace chart
{
@@ -69,13 +69,13 @@ void ImplApplyDataToModel(
// copy data from stored internal data provider
if( xDoc.is() && xDoc->hasInternalDataProvider())
{
- Reference< XChartDataArray > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY );
- Reference< XChartDataArray > xSavedData( xData, uno::UNO_QUERY );
+ Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY );
+ Reference< XComplexDescriptionAccess > xSavedData( xData, uno::UNO_QUERY );
if( xCurrentData.is() && xSavedData.is())
{
xCurrentData->setData( xSavedData->getData());
- xCurrentData->setRowDescriptions( xSavedData->getRowDescriptions());
- xCurrentData->setColumnDescriptions( xSavedData->getColumnDescriptions());
+ xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions());
+ xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions());
}
}
}
diff --git a/chart2/source/inc/ChartModelHelper.hxx b/chart2/source/inc/ChartModelHelper.hxx
index bdeab6736044..7cd205b83fb5 100644
--- a/chart2/source/inc/ChartModelHelper.hxx
+++ b/chart2/source/inc/ChartModelHelper.hxx
@@ -34,7 +34,6 @@
#include <com/sun/star/chart2/XUndoManager.hpp>
#include <com/sun/star/chart2/data/XDataProvider.hpp>
#include <com/sun/star/chart2/data/XRangeHighlighter.hpp>
-#include <com/sun/star/chart/XChartDataArray.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/awt/Size.hpp>
@@ -58,13 +57,8 @@ public:
static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XRangeHighlighter > createRangeHighlighter(
const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionSupplier >& xSelectionSupplier );
- static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > createInternalDataProvider();
-
- static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > createInternalDataProvider(
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataArray >& xDataToCopy );
-
static ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > createInternalDataProvider(
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc );
+ const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc, bool bConnectToModel );
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDiagram >
@@ -74,6 +68,10 @@ public:
::com::sun::star::chart2::XDiagram >
findDiagram( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc );
+ static ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XCoordinateSystem >
+ getFirstCoordinateSystem( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel );
+
SAL_DLLPRIVATE static ::std::vector< ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XDataSeries > > getDataSeries(
const ::com::sun::star::uno::Reference<
diff --git a/chart2/source/inc/CloneHelper.hxx b/chart2/source/inc/CloneHelper.hxx
index c78abe32da59..6747bd614d84 100644
--- a/chart2/source/inc/CloneHelper.hxx
+++ b/chart2/source/inc/CloneHelper.hxx
@@ -29,6 +29,7 @@
#include <com/sun/star/util/XCloneable.hpp>
+#include <map>
#include <functional>
#include <algorithm>
diff --git a/chart2/source/inc/DataSourceHelper.hxx b/chart2/source/inc/DataSourceHelper.hxx
index efb69df7f2b5..06888fe858d6 100644
--- a/chart2/source/inc/DataSourceHelper.hxx
+++ b/chart2/source/inc/DataSourceHelper.hxx
@@ -111,14 +111,12 @@ public:
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSource > getUsedData(
const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel >& xChartModel,
- bool bIncludeUnusedData = false );
+ ::com::sun::star::frame::XModel >& xChartModel );
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSource > getUsedData(
const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartDocument >& xChartDoc,
- bool bIncludeUnusedData = false );
+ ::com::sun::star::chart2::XChartDocument >& xChartDoc );
static bool detectRangeSegmentation(
const ::com::sun::star::uno::Reference<
@@ -127,8 +125,7 @@ public:
, ::com::sun::star::uno::Sequence< sal_Int32 >& rSequenceMapping
, bool& rOutUseColumns
, bool& rOutFirstCellAsLabel
- , bool& rOutHasCategories
- , bool bIncludeUnusedData = false );
+ , bool& rOutHasCategories );
static void setRangeSegmentation(
const ::com::sun::star::uno::Reference<
@@ -152,6 +149,10 @@ public:
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XLabeledDataSequence > & xLSeq );
+ SAL_DLLPRIVATE static ::rtl::OUString getRangeFromValues(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XLabeledDataSequence > & xLSeq );
+
SAL_DLLPRIVATE static ::com::sun::star::uno::Sequence< ::rtl::OUString > getRangesFromDataSource(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSource > & xSource );
diff --git a/chart2/source/inc/DiagramHelper.hxx b/chart2/source/inc/DiagramHelper.hxx
index fe412366606b..c685b99b974f 100644
--- a/chart2/source/inc/DiagramHelper.hxx
+++ b/chart2/source/inc/DiagramHelper.hxx
@@ -223,19 +223,15 @@ public:
::com::sun::star::chart2::XDiagram > & xDiagram );
static ::com::sun::star::uno::Sequence< rtl::OUString >
- generateAutomaticCategories(
+ getExplicitSimpleCategories(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartDocument > & xChartDoc );
SAL_DLLPRIVATE static ::com::sun::star::uno::Sequence< rtl::OUString >
- generateAutomaticCategories(
+ generateAutomaticCategoriesFromCooSys(
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XCoordinateSystem > & xCooSys );
- SAL_DLLPRIVATE static void generateAutomaticCategoriesFromChartType(
- ::com::sun::star::uno::Sequence< rtl::OUString >& rRet,
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType >& xChartType );
-
static ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartType >
getChartTypeByIndex( const ::com::sun::star::uno::Reference<
diff --git a/chart2/source/inc/ExplicitCategoriesProvider.hxx b/chart2/source/inc/ExplicitCategoriesProvider.hxx
index 8195ae0d92f2..18d54eb6e2ad 100644
--- a/chart2/source/inc/ExplicitCategoriesProvider.hxx
+++ b/chart2/source/inc/ExplicitCategoriesProvider.hxx
@@ -35,36 +35,71 @@
#include <com/sun/star/frame/XModel.hpp>
#include "charttoolsdllapi.hxx"
+#include <vector>
+
namespace chart
{
-class OOO_DLLPUBLIC_CHARTTOOLS ExplicitCategoriesProvider :
- public ::cppu::WeakImplHelper1<
- ::com::sun::star::chart2::data::XTextualDataSequence
- >
+struct OOO_DLLPUBLIC_CHARTTOOLS ComplexCategory
+{
+ rtl::OUString Text;
+ sal_Int32 Count;
+
+ ComplexCategory( const rtl::OUString& rText, sal_Int32 nCount ) : Text( rText ), Count (nCount)
+ {}
+};
+
+class OOO_DLLPUBLIC_CHARTTOOLS SplitCategoriesProvider
+{
+public:
+ virtual ~SplitCategoriesProvider();
+
+ virtual sal_Int32 getLevelCount() const = 0;
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const = 0;
+};
+
+class OOO_DLLPUBLIC_CHARTTOOLS ExplicitCategoriesProvider
{
public:
ExplicitCategoriesProvider( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel );
- SAL_DLLPRIVATE virtual ~ExplicitCategoriesProvider();
+ ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel
+ , const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel >& xChartModel
+ );
+ virtual ~ExplicitCategoriesProvider();
+
+ void init();
- //XTextualDataSequence
- SAL_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getTextualData()
- throw (::com::sun::star::uno::RuntimeException);
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > getSimpleCategories();
+ ::std::vector< ComplexCategory > getCategoriesByLevel( sal_Int32 nLevel );
static ::rtl::OUString getCategoryByIndex(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel,
- sal_Int32 nIndex );
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XCoordinateSystem >& xCooSysModel
+ , const ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel >& xChartModel
+ , sal_Int32 nIndex );
+
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getExplicitSimpleCategories(
+ const SplitCategoriesProvider& rSplitCategoriesProvider );
+
+ bool hasComplexCategories() const;
+ sal_Int32 getCategoryLevelCount() const;
+
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XLabeledDataSequence> >& getSplitCategoriesList();
private: //member
- ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aExplicitCategories;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aExplicitCategories;
+ ::std::vector< ::std::vector< ComplexCategory > > m_aComplexCats;
bool volatile m_bDirty;
::com::sun::star::uno::WeakReference<
::com::sun::star::chart2::XCoordinateSystem > m_xCooSysModel;
::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XLabeledDataSequence> m_xCategories;
+ ::com::sun::star::chart2::data::XLabeledDataSequence> m_xOriginalCategories;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XLabeledDataSequence> > m_aSplitCategoriesList;
};
} // namespace chart
diff --git a/chart2/source/inc/InternalData.hxx b/chart2/source/inc/InternalData.hxx
new file mode 100755
index 000000000000..6b6590cffdac
--- /dev/null
+++ b/chart2/source/inc/InternalData.hxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CHART2_INTERNALDATA_HXX
+#define CHART2_INTERNALDATA_HXX
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <vector>
+#include <valarray>
+
+namespace chart
+{
+
+class InternalData
+{
+public:
+ InternalData();
+
+ void createDefaultData();
+
+ void setData( const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< double > > & rDataInRows );
+ ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< double > > getData() const;
+
+ ::com::sun::star::uno::Sequence< double > getColumnValues( sal_Int32 nColumnIndex ) const;
+ ::com::sun::star::uno::Sequence< double > getRowValues( sal_Int32 nRowIndex ) const;
+
+ void setColumnValues( sal_Int32 nColumnIndex, const ::std::vector< double > & rNewData );
+ void setRowValues( sal_Int32 nRowIndex, const ::std::vector< double > & rNewData );
+
+ void setComplexColumnLabel( sal_Int32 nColumnIndex, const ::std::vector< ::rtl::OUString >& rComplexLabel );
+ void setComplexRowLabel( sal_Int32 nRowIndex, const ::std::vector< ::rtl::OUString >& rComplexLabel );
+
+ ::std::vector< ::rtl::OUString > getComplexColumnLabel( sal_Int32 nColumnIndex ) const;
+ ::std::vector< ::rtl::OUString > getComplexRowLabel( sal_Int32 nRowIndex ) const;
+
+ void swapRowWithNext( sal_Int32 nRowIndex );
+ void swapColumnWithNext( sal_Int32 nColumnIndex );
+
+ void insertColumn( sal_Int32 nAfterIndex );
+ void insertRow( sal_Int32 nAfterIndex );
+ void deleteColumn( sal_Int32 nAtIndex );
+ void deleteRow( sal_Int32 nAtIndex );
+
+ /// @return the index of the newly appended column
+ sal_Int32 appendColumn();
+ /// @return the index of the newly appended row
+ sal_Int32 appendRow();
+
+ sal_Int32 getRowCount() const;
+ sal_Int32 getColumnCount() const;
+
+ typedef ::std::valarray< double > tDataType;
+ typedef ::std::vector< ::std::vector< ::rtl::OUString > > tVecVecString; //inner index is hierarchical level
+
+ void setComplexRowLabels( const tVecVecString& rNewRowLabels );
+ tVecVecString getComplexRowLabels() const;
+ void setComplexColumnLabels( const tVecVecString& rNewColumnLabels );
+ tVecVecString getComplexColumnLabels() const;
+
+#if OSL_DEBUG_LEVEL > 2
+ void traceData() const;
+#endif
+
+private: //methods
+ /** resizes the data if at least one of the given dimensions is larger than
+ before. The data is never becoming smaller only larger.
+
+ @return </TRUE>, if the data was enlarged
+ */
+ bool enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount );
+
+private:
+ sal_Int32 m_nColumnCount;
+ sal_Int32 m_nRowCount;
+
+ tDataType m_aData;
+ tVecVecString m_aRowLabels;//outer index is row index, inner index is category level
+ tVecVecString m_aColumnLabels;//outer index is column index
+};
+
+#endif
+
+} // namespace chart
diff --git a/chart2/source/inc/InternalDataProvider.hxx b/chart2/source/inc/InternalDataProvider.hxx
index 9100b32d5859..f5e12f87f505 100644
--- a/chart2/source/inc/InternalDataProvider.hxx
+++ b/chart2/source/inc/InternalDataProvider.hxx
@@ -27,8 +27,10 @@
#ifndef CHART2_INTERNALDATAPROVIDER_HXX
#define CHART2_INTERNALDATAPROVIDER_HXX
+#include "InternalData.hxx"
+
#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/chart/XChartDataArray.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
#include <com/sun/star/chart2/data/XDataProvider.hpp>
#include <com/sun/star/chart2/XInternalDataProvider.hpp>
#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
@@ -49,12 +51,11 @@ namespace chart
namespace impl
{
-class InternalData;
typedef ::cppu::WeakImplHelper6<
::com::sun::star::chart2::XInternalDataProvider,
::com::sun::star::chart2::data::XRangeXMLConversion,
- ::com::sun::star::chart::XChartDataArray,
+ ::com::sun::star::chart::XComplexDescriptionAccess,
::com::sun::star::util::XCloneable,
::com::sun::star::lang::XInitialization,
::com::sun::star::lang::XServiceInfo >
@@ -75,16 +76,9 @@ class InternalDataProvider :
public impl::InternalDataProvider_Base
{
public:
- explicit InternalDataProvider();
explicit InternalDataProvider(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & _xContext);
- /// sets the internal data to the given data
- explicit InternalDataProvider(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart::XChartDataArray > & xDataToCopy );
- /// copies the data from the given data provider for all given used ranges
explicit InternalDataProvider( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartDocument > & xChartDoc );
- // copy-CTOR
+ ::com::sun::star::chart2::XChartDocument > & xChartDoc, bool bConnectToModel );
explicit InternalDataProvider( const InternalDataProvider & rOther );
virtual ~InternalDataProvider();
@@ -110,6 +104,10 @@ public:
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL appendSequence()
throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL insertComplexCategoryLevel( ::sal_Int32 nLevel )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteComplexCategoryLevel( ::sal_Int32 nLevel )
+ throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL insertDataPointForAllSequences( ::sal_Int32 nAfterIndex )
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL deleteDataPointForAllSequences( ::sal_Int32 nAtIndex )
@@ -151,7 +149,21 @@ public:
throw (::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::uno::RuntimeException);
- // ____ XChartDataArray ____
+ // ____ XComplexDescriptionAccess ____
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL
+ getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setComplexRowDescriptions(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aRowDescriptions )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL
+ getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setComplexColumnDescriptions(
+ const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aColumnDescriptions )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL getData()
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setData(
@@ -189,29 +201,27 @@ public:
throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception);
private:
- impl::InternalData & getInternalData();
- const impl::InternalData & getInternalData() const;
-
- void addDataSequenceToMap(
+ void lcl_addDataSequenceToMap(
const ::rtl::OUString & rRangeRepresentation,
const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSequence > & xSequence );
+
::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSequence >
- createDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation,
+ lcl_createDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation,
const ::rtl::OUString & rRole );
::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XDataSequence >
- createDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation );
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataSequence >
- createErrorBarDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation );
- void deleteMapReferences( const ::rtl::OUString & rRangeRepresentation );
- void adaptMapReferences(
+ lcl_createDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation );
+
+ void lcl_deleteMapReferences( const ::rtl::OUString & rRangeRepresentation );
+
+ void lcl_adaptMapReferences(
const ::rtl::OUString & rOldRangeRepresentation,
const ::rtl::OUString & rNewRangeRepresentation );
- void increaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
- void decreaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
+
+ void lcl_increaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
+ void lcl_decreaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
typedef ::std::multimap< ::rtl::OUString,
::com::sun::star::uno::WeakReference< ::com::sun::star::chart2::data::XDataSequence > >
@@ -225,14 +235,9 @@ private:
referred to by some component (weak reference is valid), the range will
be adapted.
*/
- mutable tSequenceMap m_aSequenceMap;
- mutable ::std::auto_ptr< impl::InternalData > m_apData;
+ tSequenceMap m_aSequenceMap;
+ InternalData m_aInternalData;
bool m_bDataInColumns;
-
-// typedef ::std::map< ::rtl::OUString,
-// ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > >
-// tHardRefSequenceMap;
-// tHardRefSequenceMap m_aErrorBarSequences;
};
} // namespace chart
diff --git a/chart2/source/model/inc/Diagram.hxx b/chart2/source/model/inc/Diagram.hxx
index bf888775f337..fc672e29b24c 100644
--- a/chart2/source/model/inc/Diagram.hxx
+++ b/chart2/source/model/inc/Diagram.hxx
@@ -136,11 +136,6 @@ protected:
virtual void SAL_CALL setDefaultColorScheme(
const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XColorScheme >& xColorScheme )
throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setUnusedData(
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > >& aUnusedData )
- throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > > SAL_CALL getUnusedData()
- throw (::com::sun::star::uno::RuntimeException);
// ____ XCoordinateSystemContainer ____
@@ -237,11 +232,6 @@ private:
::com::sun::star::chart2::XColorScheme >
m_xColorScheme;
- ::com::sun::star::uno::Sequence<
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XLabeledDataSequence > >
- m_aUnusedData;
-
::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > m_xModifyEventForwarder;
};
diff --git a/chart2/source/model/main/ChartData.cxx b/chart2/source/model/main/ChartData.cxx
deleted file mode 100644
index 866d4c67e885..000000000000
--- a/chart2/source/model/main/ChartData.cxx
+++ /dev/null
@@ -1,104 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_chart2.hxx"
-
-#include "ChartData.hxx"
-#include "ChartModelHelper.hxx"
-
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/beans/NamedValue.hpp>
-
-using namespace ::com::sun::star;
-
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-using ::rtl::OUString;
-
-namespace chart
-{
-
-ChartData::ChartData( const Reference< uno::XComponentContext > & xContext ) :
- m_xContext( xContext ),
- m_xDataProvider( 0 ),
- m_xInternalDataProvider( 0 )
-{}
-
-ChartData::~ChartData()
-{}
-
-void ChartData::setDataProvider(
- const Reference< chart2::data::XDataProvider > & xDataProvider ) throw()
-{
- m_xDataProvider.set( xDataProvider );
- m_xInternalDataProvider.clear();
-}
-
-Reference< chart2::data::XDataProvider > ChartData::getDataProvider() const throw()
-{
- return m_xDataProvider;
-}
-
-bool ChartData::createInternalData(
- bool bCloneOldData, const Reference< chart2::XChartDocument > & xChartDoc ) throw()
-{
- if( hasInternalData() )
- return false;
-
- if( bCloneOldData )
- m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( xChartDoc );
- else
- m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider();
-
- m_xDataProvider.set( m_xInternalDataProvider );
- return true;
-}
-
-bool ChartData::hasInternalData() const
-{
- return (m_xDataProvider.is() && m_xInternalDataProvider.is());
-}
-
-bool ChartData::createDefaultData() throw()
-{
- if( hasInternalData() )
- {
- uno::Reference< lang::XInitialization > xIni(m_xInternalDataProvider,uno::UNO_QUERY);
- if ( xIni.is() )
- {
- uno::Sequence< uno::Any > aArgs(1);
- beans::NamedValue aParam(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),uno::makeAny(sal_True));
- aArgs[0] <<= aParam;
- xIni->initialize(aArgs);
- return true;
- }
- }
- return false;
-}
-
-} // namespace chart
diff --git a/chart2/source/model/main/ChartData.hxx b/chart2/source/model/main/ChartData.hxx
deleted file mode 100644
index c2a528bc89d7..000000000000
--- a/chart2/source/model/main/ChartData.hxx
+++ /dev/null
@@ -1,102 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-#ifndef CHART2_CHARTDATA_HXX
-#define CHART2_CHARTDATA_HXX
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
-#include <com/sun/star/chart2/XChartDocument.hpp>
-
-#include <memory>
-
-namespace com { namespace sun { namespace star {
- namespace uno {
- class XComponentContext;
- }
- namespace embed {
- class XStorage;
- class XEmbeddedObject;
- class XEmbeddedClient;
- }
- namespace chart2 {
- namespace data {
- class XDataProvider;
- }
- }
- namespace util {
- class XCloseBroadcaster;
- }
-}}}
-
-namespace chart
-{
-
-class ChartData
-{
-public:
- explicit ChartData(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XComponentContext > & xContext );
- ~ChartData();
-
- void setDataProvider(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataProvider > & xDataProvider ) throw();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >
- getDataProvider() const throw();
-
- /** @return </TRUE>, if a new internal data provider has been created
- */
- bool createInternalData(
- bool bCloneOldData,
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc ) throw();
-
- bool hasInternalData() const;
-
- /** only works if currently an internal data provider is set
- */
- bool createDefaultData() throw();
-
-private:
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
- m_xContext;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >
- m_xDataProvider;
-
- /** is only valid if m_xDataProvider is set. If m_xDataProvider is set to an
- external data provider this reference must be set to 0
- */
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider >
- m_xInternalDataProvider;
-};
-
-} // namespace chart
-
-// CHART2_CHARTDATA_HXX
-#endif
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index 4eedac67f713..77533ec1306b 100644..100755
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -28,19 +28,22 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_chart2.hxx"
#include "ChartModel.hxx"
-#include "ImplChartModel.hxx"
#include "servicenames.hxx"
#include "MediaDescriptorHelper.hxx"
#include "macros.hxx"
-#include "InternalData.hxx"
#include "servicenames.hxx"
-#include "DataSourceHelper.hxx"
#include "NoWarningThisInCTOR.hxx"
+#include "DataSourceHelper.hxx"
#include "ChartModelHelper.hxx"
+#include "DiagramHelper.hxx"
#include "DisposeHelper.hxx"
#include "ControllerLockGuard.hxx"
#include "ObjectIdentifier.hxx"
-#include "ChartModelHelper.hxx"
+#include "PageBackground.hxx"
+#include "CloneHelper.hxx"
+#include "NameContainer.hxx"
+
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
#include <comphelper/InlineContainer.hxx>
#include <comphelper/processfactory.hxx>
@@ -57,13 +60,16 @@
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/embed/EmbedMapUnits.hpp>
#include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/drawing/Hatch.hpp>
+#include <com/sun/star/drawing/LineDash.hpp>
#include <com/sun/star/drawing/XShapes.hpp>
-#include <map>
-#include <algorithm>
+// header for class SvNumberFormatter
+#include <svl/zforlist.hxx>
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Reference;
@@ -73,6 +79,7 @@ using ::osl::MutexGuard;
using namespace ::com::sun::star;
using namespace ::apphelper;
+using namespace ::chart::CloneHelper;
namespace
{
@@ -101,14 +108,22 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
, m_xContext( xContext )
// default visual area is 8 x 7 cm
, m_aVisualAreaSize( 8000, 7000 )
+ , m_xDataProvider( 0 )
+ , m_xInternalDataProvider( 0 )
+ , m_xPageBackground( new PageBackground( m_xContext ) )
+ , m_xXMLNamespaceMap( createNameContainer( ::getCppuType( (const OUString*) 0 ),
+ C2U( "com.sun.star.xml.NamespaceMap" ), C2U( "com.sun.star.comp.chart.XMLNameSpaceMap" ) ), uno::UNO_QUERY)
{
OSL_TRACE( "ChartModel: CTOR called" );
+ osl_incrementInterlockedCount(&m_refCount);
- // attention: passing this as reference to ImplChartModel
- m_pImplChartModel.reset( new impl::ImplChartModel( xContext, this ));
-
+ ModifyListenerHelper::addListener( m_xPageBackground, this );
+ m_xChartTypeManager.set( xContext->getServiceManager()->createInstanceWithContext(
+ C2U( "com.sun.star.chart2.ChartTypeManager" ), m_xContext ), uno::UNO_QUERY );
m_xUndoManager = Reference< chart2::XUndoManager >(
this->createInstance( CHART_UNDOMANAGER_SERVICE_NAME ), uno::UNO_QUERY );
+
+ osl_decrementInterlockedCount(&m_refCount);
}
ChartModel::ChartModel( const ChartModel & rOther )
@@ -129,15 +144,23 @@ ChartModel::ChartModel( const ChartModel & rOther )
, m_xStorage( 0 ) //rOther.m_xStorage )
, m_aVisualAreaSize( rOther.m_aVisualAreaSize )
, m_aGraphicObjectVector( rOther.m_aGraphicObjectVector )
+ , m_xDataProvider( rOther.m_xDataProvider )
+ , m_xInternalDataProvider( rOther.m_xInternalDataProvider )
, m_xUndoManager( rOther.m_xUndoManager )
{
OSL_TRACE( "ChartModel: Copy-CTOR called" );
+ osl_incrementInterlockedCount(&m_refCount);
- // attention: passing this as reference to ImplChartModel
- if( rOther.m_pImplChartModel.get())
- m_pImplChartModel.reset( new impl::ImplChartModel( * rOther.m_pImplChartModel.get(), this ));
- else
- m_pImplChartModel.reset( new impl::ImplChartModel( m_xContext, this ));
+ m_xChartTypeManager.set( CreateRefClone< Reference< chart2::XChartTypeManager > >()( rOther.m_xChartTypeManager ));
+ m_xTitle.set( CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle ));
+ ModifyListenerHelper::addListener( m_xTitle, this );
+ m_xPageBackground.set( CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xPageBackground ));
+ ModifyListenerHelper::addListener( m_xPageBackground, this );
+
+ m_xXMLNamespaceMap.set( CreateRefClone< Reference< container::XNameAccess > >()( rOther.m_xXMLNamespaceMap ));
+
+ CloneRefVector< Reference< chart2::XDiagram > >( rOther.m_aDiagrams, m_aDiagrams );
+ osl_decrementInterlockedCount(&m_refCount);
}
ChartModel::~ChartModel()
@@ -152,8 +175,7 @@ ChartModel::~ChartModel()
// private methods
//-----------------------------------------------------------------
- ::rtl::OUString ChartModel
-::impl_g_getLocation()
+::rtl::OUString ChartModel::impl_g_getLocation()
{
LifeTimeGuard aGuard(m_aLifeTimeManager);
@@ -163,8 +185,7 @@ ChartModel::~ChartModel()
return m_aResource;
}
- sal_Bool ChartModel
-::impl_isControllerConnected( const uno::Reference< frame::XController >& xController )
+sal_Bool ChartModel::impl_isControllerConnected( const uno::Reference< frame::XController >& xController )
{
try
{
@@ -181,8 +202,7 @@ ChartModel::~ChartModel()
return sal_False;
}
- uno::Reference< frame::XController > ChartModel
-::impl_getCurrentController() throw(uno::RuntimeException)
+uno::Reference< frame::XController > ChartModel::impl_getCurrentController() throw(uno::RuntimeException)
{
//@todo? hold only weak references to controllers
@@ -201,8 +221,7 @@ ChartModel::~ChartModel()
return uno::Reference< frame::XController > ();
}
- void SAL_CALL ChartModel
-::impl_notifyCloseListeners()
+void SAL_CALL ChartModel::impl_notifyCloseListeners()
throw( uno::RuntimeException)
{
::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer
@@ -259,8 +278,7 @@ void ChartModel::impl_adjustAdditionalShapesPositionAndSize( const awt::Size& aV
APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
- uno::Sequence< rtl::OUString > ChartModel
-::getSupportedServiceNames_Static()
+uno::Sequence< rtl::OUString > ChartModel::getSupportedServiceNames_Static()
{
uno::Sequence< rtl::OUString > aSNS( 3 );
aSNS[0] = CHART_MODEL_SERVICE_NAME;
@@ -274,8 +292,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
// frame::XModel (required interface)
//-----------------------------------------------------------------
- sal_Bool SAL_CALL ChartModel
-::attachResource( const ::rtl::OUString& rURL
+sal_Bool SAL_CALL ChartModel::attachResource( const ::rtl::OUString& rURL
, const uno::Sequence< beans::PropertyValue >& rMediaDescriptor )
throw(uno::RuntimeException)
{
@@ -301,14 +318,12 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
return sal_True;
}
- ::rtl::OUString SAL_CALL ChartModel
-::getURL() throw(uno::RuntimeException)
+::rtl::OUString SAL_CALL ChartModel::getURL() throw(uno::RuntimeException)
{
return impl_g_getLocation();
}
- uno::Sequence< beans::PropertyValue > SAL_CALL ChartModel
-::getArgs() throw(uno::RuntimeException)
+uno::Sequence< beans::PropertyValue > SAL_CALL ChartModel::getArgs() throw(uno::RuntimeException)
{
/*
The method getArgs() returns a sequence of property values
@@ -324,8 +339,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
return m_aMediaDescriptor;
}
- void SAL_CALL ChartModel
-::connectController( const uno::Reference< frame::XController >& xController )
+void SAL_CALL ChartModel::connectController( const uno::Reference< frame::XController >& xController )
throw(uno::RuntimeException)
{
//@todo? this method is declared as oneway -> ...?
@@ -339,8 +353,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
m_aControllers.addInterface(xController);
}
- void SAL_CALL ChartModel
-::disconnectController( const uno::Reference< frame::XController >& xController )
+void SAL_CALL ChartModel::disconnectController( const uno::Reference< frame::XController >& xController )
throw(uno::RuntimeException)
{
//@todo? this method is declared as oneway -> ...?
@@ -359,8 +372,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
}
- void SAL_CALL ChartModel
-::lockControllers() throw(uno::RuntimeException)
+void SAL_CALL ChartModel::lockControllers() throw(uno::RuntimeException)
{
/*
suspends some notifications to the controllers which are used for display updates.
@@ -378,8 +390,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
++m_nControllerLockCount;
}
- void SAL_CALL ChartModel
-::unlockControllers() throw(uno::RuntimeException)
+void SAL_CALL ChartModel::unlockControllers() throw(uno::RuntimeException)
{
/*
resumes the notifications which were suspended by lockControllers() .
@@ -407,8 +418,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
}
}
- sal_Bool SAL_CALL ChartModel
-::hasControllersLocked() throw(uno::RuntimeException)
+sal_Bool SAL_CALL ChartModel::hasControllersLocked() throw(uno::RuntimeException)
{
LifeTimeGuard aGuard(m_aLifeTimeManager);
if(!aGuard.startApiCall())
@@ -416,8 +426,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
return ( m_nControllerLockCount != 0 ) ;
}
- uno::Reference< frame::XController > SAL_CALL ChartModel
-::getCurrentController() throw(uno::RuntimeException)
+uno::Reference< frame::XController > SAL_CALL ChartModel::getCurrentController() throw(uno::RuntimeException)
{
LifeTimeGuard aGuard(m_aLifeTimeManager);
if(!aGuard.startApiCall())
@@ -428,8 +437,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
return impl_getCurrentController();
}
- void SAL_CALL ChartModel
-::setCurrentController( const uno::Reference< frame::XController >& xController )
+void SAL_CALL ChartModel::setCurrentController( const uno::Reference< frame::XController >& xController )
throw(container::NoSuchElementException, uno::RuntimeException)
{
LifeTimeGuard aGuard(m_aLifeTimeManager);
@@ -449,8 +457,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
}
- uno::Reference< uno::XInterface > SAL_CALL ChartModel
-::getCurrentSelection() throw(uno::RuntimeException)
+uno::Reference< uno::XInterface > SAL_CALL ChartModel::getCurrentSelection() throw(uno::RuntimeException)
{
LifeTimeGuard aGuard(m_aLifeTimeManager);
if(!aGuard.startApiCall())
@@ -483,8 +490,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
//-----------------------------------------------------------------
// lang::XComponent (base of XModel)
//-----------------------------------------------------------------
- void SAL_CALL ChartModel
-::dispose() throw(uno::RuntimeException)
+void SAL_CALL ChartModel::dispose() throw(uno::RuntimeException)
{
//This object should release all resources and references in the
//easiest possible manner
@@ -497,8 +503,17 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
//--release all resources and references
//// @todo
- if( m_pImplChartModel.get())
- m_pImplChartModel->dispose();
+
+ m_xDataProvider.clear();
+ m_xInternalDataProvider.clear();
+ m_xNumberFormatsSupplier.clear();
+ DisposeHelper::DisposeAndClear( m_xOwnNumberFormatsSupplier );
+ DisposeHelper::DisposeAndClear( m_xChartTypeManager );
+ DisposeHelper::DisposeAllElements( m_aDiagrams );
+ m_aDiagrams.clear();
+ DisposeHelper::DisposeAndClear( m_xTitle );
+ DisposeHelper::DisposeAndClear( m_xPageBackground );
+ DisposeHelper::DisposeAndClear( m_xXMLNamespaceMap );
// not owner of storage
// if( m_xStorage.is())
@@ -524,8 +539,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
OSL_TRACE( "ChartModel: dispose() called" );
}
- void SAL_CALL ChartModel
-::addEventListener( const uno::Reference< lang::XEventListener > & xListener )
+void SAL_CALL ChartModel::addEventListener( const uno::Reference< lang::XEventListener > & xListener )
throw(uno::RuntimeException)
{
if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
@@ -534,8 +548,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
m_aLifeTimeManager.m_aListenerContainer.addInterface( ::getCppuType((const uno::Reference< lang::XEventListener >*)0), xListener );
}
- void SAL_CALL ChartModel
-::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
+void SAL_CALL ChartModel::removeEventListener( const uno::Reference< lang::XEventListener > & xListener )
throw(uno::RuntimeException)
{
if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
@@ -548,15 +561,13 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
//-----------------------------------------------------------------
// util::XCloseBroadcaster (base of XCloseable)
//-----------------------------------------------------------------
- void SAL_CALL ChartModel
-::addCloseListener( const uno::Reference< util::XCloseListener > & xListener )
+void SAL_CALL ChartModel::addCloseListener( const uno::Reference< util::XCloseListener > & xListener )
throw(uno::RuntimeException)
{
m_aLifeTimeManager.g_addCloseListener( xListener );
}
- void SAL_CALL ChartModel
-::removeCloseListener( const uno::Reference< util::XCloseListener > & xListener )
+void SAL_CALL ChartModel::removeCloseListener( const uno::Reference< util::XCloseListener > & xListener )
throw(uno::RuntimeException)
{
if( m_aLifeTimeManager.impl_isDisposedOrClosed() )
@@ -569,8 +580,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
//-----------------------------------------------------------------
// util::XCloseable
//-----------------------------------------------------------------
- void SAL_CALL ChartModel
-::close( sal_Bool bDeliverOwnership )
+void SAL_CALL ChartModel::close( sal_Bool bDeliverOwnership )
throw( util::CloseVetoException,
uno::RuntimeException )
{
@@ -627,8 +637,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME)
//-----------------------------------------------------------------
// lang::XTypeProvider
//-----------------------------------------------------------------
- uno::Sequence< uno::Type > SAL_CALL ChartModel
-::getTypes()
+uno::Sequence< uno::Type > SAL_CALL ChartModel::getTypes()
throw (uno::RuntimeException)
{
uno::Reference< lang::XTypeProvider > xAggTypeProvider;
@@ -669,82 +678,121 @@ uno::Reference< document::XDocumentProperties > SAL_CALL
// chart2::XChartDocument
//-----------------------------------------------------------------
- uno::Reference< chart2::XDiagram > SAL_CALL ChartModel
-::getFirstDiagram()
+uno::Reference< chart2::XDiagram > SAL_CALL ChartModel::getFirstDiagram()
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
// /--
MutexGuard aGuard( m_aModelMutex );
- try
- {
- return m_pImplChartModel->GetDiagram( 0 );
- }
- catch( container::NoSuchElementException )
- {
- }
-
+ if( m_aDiagrams.size() )
+ return m_aDiagrams[ 0 ];
return uno::Reference< chart2::XDiagram >();
// \--
}
- void SAL_CALL ChartModel
-::setFirstDiagram( const uno::Reference< chart2::XDiagram >& xDiagram )
+void ChartModel::impl_removeAllDiagrams()
+{
+ ModifyListenerHelper::removeListenerFromAllElements( m_aDiagrams, this );
+ m_aDiagrams.clear();
+}
+
+void ChartModel::impl_appendDiagram( const Reference< chart2::XDiagram > & xDiagram )
+{
+ Reference< util::XModifyBroadcaster > xBroadcaster( xDiagram, uno::UNO_QUERY );
+ ModifyListenerHelper::addListener( xDiagram, this );
+ m_aDiagrams.push_back( xDiagram );
+}
+
+
+void SAL_CALL ChartModel::setFirstDiagram( const uno::Reference< chart2::XDiagram >& xDiagram )
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
{
// /--
MutexGuard aGuard( m_aModelMutex );
- m_pImplChartModel->RemoveAllDiagrams();
- m_pImplChartModel->AppendDiagram( xDiagram );
+ impl_removeAllDiagrams();
+ impl_appendDiagram( xDiagram );
// \--
}
setModified( sal_True );
}
- void SAL_CALL ChartModel
-::createInternalDataProvider( sal_Bool bCloneExistingData )
- throw (util::CloseVetoException,
- uno::RuntimeException)
+Reference< chart2::data::XDataSource > ChartModel::impl_createDefaultData()
+{
+ Reference< chart2::data::XDataSource > xDataSource;
+ if( hasInternalDataProvider() )
+ {
+ uno::Reference< lang::XInitialization > xIni(m_xInternalDataProvider,uno::UNO_QUERY);
+ if( xIni.is() )
+ {
+ //init internal dataprovider
+ {
+ uno::Sequence< uno::Any > aArgs(1);
+ beans::NamedValue aParam(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),uno::makeAny(sal_True));
+ aArgs[0] <<= aParam;
+ xIni->initialize(aArgs);
+ }
+ //create data
+ uno::Sequence< beans::PropertyValue > aArgs( 4 );
+ aArgs[0] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
+ uno::makeAny( C2U("all") ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[1] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("HasCategories"), -1,
+ uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[2] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
+ uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[3] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("DataRowSource"), -1,
+ uno::makeAny( ::com::sun::star::chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE );
+ xDataSource = m_xInternalDataProvider->createDataSource( aArgs );
+ }
+ }
+ return xDataSource;
+}
+
+void SAL_CALL ChartModel::createInternalDataProvider( sal_Bool bCloneExistingData )
+ throw (util::CloseVetoException, uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
// don't lock the mutex, because this call calls out to code that tries to
// lock the solar mutex. On the other hand, a paint locks the solar mutex
// and calls to the model lock the model's mutex => deadlock
// @todo: lock a separate mutex in the InternalData class
- m_pImplChartModel->CreateInternalDataProvider( bCloneExistingData, this );
+ if( !hasInternalDataProvider() )
+ {
+ if( bCloneExistingData )
+ m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( this, true );
+ else
+ m_xInternalDataProvider = ChartModelHelper::createInternalDataProvider( Reference<XChartDocument>(), true );
+ m_xDataProvider.set( m_xInternalDataProvider );
+ }
setModified( sal_True );
}
sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
throw (uno::RuntimeException)
{
- return m_pImplChartModel->HasInternalDataProvider();
+ return m_xDataProvider.is() && m_xInternalDataProvider.is();
}
- uno::Reference< chart2::data::XDataProvider > SAL_CALL ChartModel
-::getDataProvider()
+uno::Reference< chart2::data::XDataProvider > SAL_CALL ChartModel::getDataProvider()
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
// /--
MutexGuard aGuard( m_aModelMutex );
- return m_pImplChartModel->GetDataProvider();
+ return m_xDataProvider;
// \--
}
// ____ XDataReceiver ____
- void SAL_CALL ChartModel
-::attachDataProvider( const uno::Reference< chart2::data::XDataProvider >& xProvider )
+void SAL_CALL ChartModel::attachDataProvider( const uno::Reference< chart2::data::XDataProvider >& xDataProvider )
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
{
// /--
MutexGuard aGuard( m_aModelMutex );
- uno::Reference< beans::XPropertySet > xProp( xProvider, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xProp( xDataProvider, uno::UNO_QUERY );
if( xProp.is() )
{
try
@@ -757,41 +805,95 @@ sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
}
}
- m_pImplChartModel->SetDataProvider( xProvider );
+ m_xDataProvider.set( xDataProvider );
+ m_xInternalDataProvider.clear();
+
+ //the numberformatter is kept independent of the data provider!
// \--
}
setModified( sal_True );
}
- void SAL_CALL ChartModel
-::attachNumberFormatsSupplier( const uno::Reference< util::XNumberFormatsSupplier >& xSupplier )
+void SAL_CALL ChartModel::attachNumberFormatsSupplier( const uno::Reference< util::XNumberFormatsSupplier >& xNewSupplier )
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
{
// /--
MutexGuard aGuard( m_aModelMutex );
- m_pImplChartModel->SetNumberFormatsSupplier( xSupplier );
+ if( xNewSupplier==m_xNumberFormatsSupplier )
+ return;
+ if( xNewSupplier==m_xOwnNumberFormatsSupplier )
+ return;
+ if( m_xOwnNumberFormatsSupplier.is() && xNewSupplier.is() )
+ {
+ //@todo
+ //merge missing numberformats from own to new formatter
+ }
+ else if( !xNewSupplier.is() )
+ {
+ if( m_xNumberFormatsSupplier.is() )
+ {
+ //@todo
+ //merge missing numberformats from old numberformatter to own numberformatter
+ //create own numberformatter if necessary
+ }
+ }
+
+ m_xNumberFormatsSupplier.set( xNewSupplier );
+ m_xOwnNumberFormatsSupplier.clear();
// \--
}
setModified( sal_True );
}
- void SAL_CALL ChartModel
-::setArguments( const Sequence< beans::PropertyValue >& aArguments )
+void SAL_CALL ChartModel::setArguments( const Sequence< beans::PropertyValue >& aArguments )
throw (lang::IllegalArgumentException,
uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
{
// /--
MutexGuard aGuard( m_aModelMutex );
+ if( !m_xDataProvider.is() )
+ return;
lockControllers();
+
try
{
- m_pImplChartModel->SetArguments( aArguments, true /* bSetData */ );
+ Reference< chart2::data::XDataSource > xDataSource( m_xDataProvider->createDataSource( aArguments ) );
+ if( xDataSource.is() )
+ {
+ // set new data
+ Reference< chart2::XChartTypeTemplate > xTemplate;
+ Reference< chart2::XDiagram > xDia( getFirstDiagram() );
+ if( xDia.is())
+ {
+ // apply new data
+ DiagramHelper::tTemplateWithServiceName aTemplateAndService =
+ DiagramHelper::getTemplateForDiagram(
+ xDia, Reference< lang::XMultiServiceFactory >( m_xChartTypeManager, uno::UNO_QUERY ));
+ xTemplate.set( aTemplateAndService.first );
+ }
+
+ if( !xTemplate.is())
+ xTemplate.set( impl_createDefaultChartTypeTemplate() );
+
+ if( xTemplate.is())
+ {
+ if( xDia.is())
+ xTemplate->changeDiagramData( xDia, xDataSource, aArguments );
+ else
+ {
+ impl_removeAllDiagrams();
+ impl_appendDiagram( xTemplate->createDiagramByDataSource( xDataSource, aArguments ));
+ }
+ }
+ }
+ }
+ catch( lang::IllegalArgumentException & )
+ {
+ throw;
}
- catch( const uno::Exception & ex )
+ catch( uno::Exception & ex )
{
ASSERT_EXCEPTION( ex );
}
@@ -801,22 +903,19 @@ sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
setModified( sal_True );
}
- Sequence< OUString > SAL_CALL ChartModel
-::getUsedRangeRepresentations()
+Sequence< OUString > SAL_CALL ChartModel::getUsedRangeRepresentations()
throw (uno::RuntimeException)
{
return DataSourceHelper::getUsedDataRanges( Reference< frame::XModel >(this));
}
- Reference< chart2::data::XDataSource > SAL_CALL ChartModel
-::getUsedData()
+Reference< chart2::data::XDataSource > SAL_CALL ChartModel::getUsedData()
throw (uno::RuntimeException)
{
return DataSourceHelper::getUsedData( Reference< chart2::XChartDocument >(this));
}
- Reference< chart2::data::XRangeHighlighter > SAL_CALL ChartModel
-::getRangeHighlighter()
+Reference< chart2::data::XRangeHighlighter > SAL_CALL ChartModel::getRangeHighlighter()
throw (uno::RuntimeException)
{
if( ! m_xRangeHighlighter.is())
@@ -828,40 +927,42 @@ sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
return m_xRangeHighlighter;
}
+Reference< chart2::XChartTypeTemplate > ChartModel::impl_createDefaultChartTypeTemplate()
+{
+ Reference< chart2::XChartTypeTemplate > xTemplate;
+ Reference< lang::XMultiServiceFactory > xFact( m_xChartTypeManager, uno::UNO_QUERY );
+ if( xFact.is() )
+ xTemplate.set( xFact->createInstance( C2U( "com.sun.star.chart2.template.Column" ) ), uno::UNO_QUERY );
+ return xTemplate;
+}
- void SAL_CALL ChartModel
-::setChartTypeManager( const uno::Reference< chart2::XChartTypeManager >& xNewManager )
+void SAL_CALL ChartModel::setChartTypeManager( const uno::Reference< chart2::XChartTypeManager >& xNewManager )
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
{
// /--
MutexGuard aGuard( m_aModelMutex );
- m_pImplChartModel->SetChartTypeManager( xNewManager );
+ m_xChartTypeManager = xNewManager;
// \--
}
setModified( sal_True );
}
- uno::Reference< chart2::XChartTypeManager > SAL_CALL ChartModel
-::getChartTypeManager()
+uno::Reference< chart2::XChartTypeManager > SAL_CALL ChartModel::getChartTypeManager()
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
// /--
MutexGuard aGuard( m_aModelMutex );
- return m_pImplChartModel->GetChartTypeManager();
+ return m_xChartTypeManager;
// \--
}
- uno::Reference< beans::XPropertySet > SAL_CALL ChartModel
-::getPageBackground()
+uno::Reference< beans::XPropertySet > SAL_CALL ChartModel::getPageBackground()
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
// /--
MutexGuard aGuard( m_aModelMutex );
- return m_pImplChartModel->GetPageBackground();
+ return m_xPageBackground;
// \--
}
@@ -869,23 +970,22 @@ sal_Bool SAL_CALL ChartModel::hasInternalDataProvider()
uno::Reference< chart2::XTitle > SAL_CALL ChartModel::getTitleObject()
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
// /--
MutexGuard aGuard( m_aModelMutex );
- return m_pImplChartModel->GetTitle();
+ return m_xTitle;
// \--
}
-void SAL_CALL ChartModel::setTitleObject(
- const uno::Reference<
- chart2::XTitle >& Title )
+void SAL_CALL ChartModel::setTitleObject( const uno::Reference< chart2::XTitle >& xTitle )
throw (uno::RuntimeException)
{
- OSL_ASSERT( m_pImplChartModel.get() != 0 );
{
// /--
MutexGuard aGuard( m_aModelMutex );
- m_pImplChartModel->SetTitle( Title );
+ if( m_xTitle.is() )
+ ModifyListenerHelper::removeListener( m_xTitle, this );
+ m_xTitle = xTitle;
+ ModifyListenerHelper::addListener( m_xTitle, this );
// \--
}
setModified( sal_True );
@@ -1123,9 +1223,6 @@ tServiceNameMap & lcl_getStaticServiceNameMap()
Reference< uno::XInterface > SAL_CALL ChartModel::createInstance( const OUString& rServiceSpecifier )
throw( uno::Exception, uno::RuntimeException )
{
- if( ! m_pImplChartModel.get() )
- return 0;
-
uno::Reference< uno::XInterface > xResult;
tServiceNameMap & rMap = lcl_getStaticServiceNameMap();
@@ -1150,9 +1247,7 @@ Reference< uno::XInterface > SAL_CALL ChartModel::createInstance( const OUString
}
break;
case SERVICE_NAMESPACE_MAP:
- // not yet supported, @todo
-// return 0;
- return m_pImplChartModel->GetXMLNameSpaceMap();
+ return Reference< uno::XInterface >( m_xXMLNamespaceMap );
}
}
else
@@ -1198,6 +1293,21 @@ Sequence< OUString > SAL_CALL ChartModel::getAvailableServiceNames()
return aResult;
}
+Reference< util::XNumberFormatsSupplier > ChartModel::impl_getNumberFormatsSupplier()
+{
+ if( !m_xNumberFormatsSupplier.is() )
+ {
+ if( !m_xOwnNumberFormatsSupplier.is() )
+ {
+ Reference< lang::XMultiServiceFactory > xFactory( m_xContext->getServiceManager(), uno::UNO_QUERY );
+ m_xOwnNumberFormatsSupplier = new SvNumberFormatsSupplierObj( new SvNumberFormatter( xFactory, LANGUAGE_SYSTEM ) );
+ //pOwnNumberFormatter->ChangeStandardPrec( 15 ); todo?
+ }
+ m_xNumberFormatsSupplier = m_xOwnNumberFormatsSupplier;
+ }
+ return m_xNumberFormatsSupplier;
+}
+
// ____ XUnoTunnel ___
::sal_Int64 SAL_CALL ChartModel::getSomething( const Sequence< ::sal_Int8 >& aIdentifier )
throw( uno::RuntimeException)
@@ -1205,14 +1315,9 @@ Sequence< OUString > SAL_CALL ChartModel::getAvailableServiceNames()
if( aIdentifier.getLength() == 16 && 0 == rtl_compareMemory( SvNumberFormatsSupplierObj::getUnoTunnelId().getConstArray(),
aIdentifier.getConstArray(), 16 ) )
{
- OSL_ENSURE( m_pImplChartModel.get(), "need a model implementation to provide a numberformatter" );
- if( m_pImplChartModel.get() )
- {
- Reference< lang::XUnoTunnel > xTunnel( m_pImplChartModel->GetNumberFormatsSupplier(), uno::UNO_QUERY );
- if( xTunnel.is() )
- return xTunnel->getSomething( aIdentifier );
- }
- return 0;
+ Reference< lang::XUnoTunnel > xTunnel( impl_getNumberFormatsSupplier(), uno::UNO_QUERY );
+ if( xTunnel.is() )
+ return xTunnel->getSomething( aIdentifier );
}
return 0;
}
@@ -1221,26 +1326,18 @@ Sequence< OUString > SAL_CALL ChartModel::getAvailableServiceNames()
uno::Reference< beans::XPropertySet > SAL_CALL ChartModel::getNumberFormatSettings()
throw (uno::RuntimeException)
{
- OSL_ENSURE( m_pImplChartModel.get(), "need a model implementation to provide a numberformatter" );
- if( m_pImplChartModel.get() )
- {
- Reference< util::XNumberFormatsSupplier > xSupplier( m_pImplChartModel->GetNumberFormatsSupplier() );
- if( xSupplier.is() )
- return xSupplier->getNumberFormatSettings();
- }
+ Reference< util::XNumberFormatsSupplier > xSupplier( impl_getNumberFormatsSupplier() );
+ if( xSupplier.is() )
+ return xSupplier->getNumberFormatSettings();
return uno::Reference< beans::XPropertySet >();
}
uno::Reference< util::XNumberFormats > SAL_CALL ChartModel::getNumberFormats()
throw (uno::RuntimeException)
{
- OSL_ENSURE( m_pImplChartModel.get(), "need a model implementation to provide a numberformatter" );
- if( m_pImplChartModel.get() )
- {
- Reference< util::XNumberFormatsSupplier > xSupplier( m_pImplChartModel->GetNumberFormatsSupplier() );
- if( xSupplier.is() )
- return xSupplier->getNumberFormats();
- }
+ Reference< util::XNumberFormatsSupplier > xSupplier( impl_getNumberFormatsSupplier() );
+ if( xSupplier.is() )
+ return xSupplier->getNumberFormats();
return uno::Reference< util::XNumberFormats >();
}
diff --git a/chart2/source/model/main/ChartModel.hxx b/chart2/source/model/main/ChartModel.hxx
index ab30e40f85fc..860f71f909ea 100644
--- a/chart2/source/model/main/ChartModel.hxx
+++ b/chart2/source/model/main/ChartModel.hxx
@@ -47,6 +47,8 @@
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/chart2/XUndoSupplier.hpp>
#include <com/sun/star/chart2/data/XDataSource.hpp>
+#include <com/sun/star/chart2/XChartTypeTemplate.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
// public API
#include <com/sun/star/chart2/data/XDataProvider.hpp>
@@ -81,7 +83,6 @@ namespace chart
namespace impl
{
- class ImplChartModel;
// Note: needed for queryInterface (if it calls the base-class implementation)
typedef ::comphelper::WeakImplHelper20<
@@ -136,8 +137,6 @@ private:
// ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aPrinterOptions;
- ::std::auto_ptr< impl::ImplChartModel > m_pImplChartModel;
-
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > m_xOldModelAgg;
@@ -147,7 +146,40 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xParent;
::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XRangeHighlighter > m_xRangeHighlighter;
::std::vector< GraphicObject > m_aGraphicObjectVector;
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > m_xUndoManager;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > m_xDataProvider;
+ /** is only valid if m_xDataProvider is set. If m_xDataProvider is set to an
+ external data provider this reference must be set to 0
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > m_xInternalDataProvider;
+
+ ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >
+ m_xOwnNumberFormatsSupplier;
+ ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >
+ m_xNumberFormatsSupplier;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeManager >
+ m_xChartTypeManager;
+
+ // Diagram Access
+ typedef ::std::vector< ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDiagram > >
+ tDiagramContainer;
+
+ tDiagramContainer m_aDiagrams;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle >
+ m_xTitle;
+
+ bool m_bIsDisposed;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xPageBackground;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager >
+ m_xUndoManager;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xXMLNamespaceMap;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > m_xModifyListener;
private:
//private methods
@@ -193,9 +225,19 @@ private:
impl_createFilter( const ::com::sun::star::uno::Sequence<
::com::sun::star::beans::PropertyValue > & rMediaDescriptor );
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeTemplate > impl_createDefaultChartTypeTemplate();
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > impl_createDefaultData();
+
void impl_adjustAdditionalShapesPositionAndSize(
const ::com::sun::star::awt::Size& aVisualAreaSize );
+ void impl_removeAllDiagrams();
+ void impl_appendDiagram( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::XDiagram > & xDiagram );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >
+ impl_getNumberFormatsSupplier();
+
public:
//no default constructor
ChartModel(::com::sun::star::uno::Reference<
diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx
index 82f1cdc2054a..b7b8f380ceea 100644
--- a/chart2/source/model/main/ChartModel_Persistence.cxx
+++ b/chart2/source/model/main/ChartModel_Persistence.cxx
@@ -29,28 +29,36 @@
#include "precompiled_chart2.hxx"
#include "ChartModel.hxx"
-#include "ImplChartModel.hxx"
#include "MediaDescriptorHelper.hxx"
#include "ChartDebugTrace.hxx"
#include "macros.hxx"
#include "ChartViewHelper.hxx"
#include "ChartModelHelper.hxx"
+#include "AxisHelper.hxx"
+#include "ThreeDHelper.hxx"
+
+#include <com/sun/star/chart2/LegendPosition.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/document/XExporter.hpp>
#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/drawing/ProjectionMode.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/io/XSeekable.hpp>
+
#include <ucbhelper/content.hxx>
#ifndef _UNOTOOLS_UCBSTREAMHELPER_HXX
#include <unotools/ucbstreamhelper.hxx>
#endif
#include <vcl/cvtgrf.hxx>
#include <comphelper/storagehelper.hxx>
+#include <vcl/svapp.hxx>
#include <algorithm>
#include <functional>
@@ -404,7 +412,88 @@ void SAL_CALL ChartModel::initNew()
createInternalDataProvider( sal_False );
try
{
- m_pImplChartModel->CreateDefaultChart();
+ // create default chart
+ impl_removeAllDiagrams();
+
+ Reference< chart2::XChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() );
+ if( xTemplate.is())
+ {
+ try
+ {
+ Reference< chart2::data::XDataSource > xDataSource( impl_createDefaultData() );
+ Sequence< beans::PropertyValue > aParam;
+
+ bool bSupportsCategories = xTemplate->supportsCategories();
+ if( bSupportsCategories )
+ {
+ aParam.realloc( 1 );
+ aParam[0] = beans::PropertyValue( C2U("HasCategories"), -1, uno::makeAny( true ),
+ beans::PropertyState_DIRECT_VALUE );
+ }
+
+ Reference< chart2::XDiagram > xDiagram( xTemplate->createDiagramByDataSource( xDataSource, aParam ) );
+
+ impl_appendDiagram( xDiagram );
+
+ bool bIsRTL = Application::GetSettings().GetLayoutRTL();
+ //reverse x axis for rtl charts
+ if( bIsRTL )
+ AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
+
+ // create and attach legend
+ Reference< chart2::XLegend > xLegend(
+ m_xContext->getServiceManager()->createInstanceWithContext(
+ C2U( "com.sun.star.chart2.Legend" ), m_xContext ), uno::UNO_QUERY_THROW );
+ Reference< beans::XPropertySet > xLegendProperties( xLegend, uno::UNO_QUERY );
+ if( xLegendProperties.is() )
+ {
+ xLegendProperties->setPropertyValue( C2U( "FillStyle" ), uno::makeAny( drawing::FillStyle_NONE ));
+ xLegendProperties->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_NONE ));
+ xLegendProperties->setPropertyValue( C2U( "LineColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) )); // gray30
+ xLegendProperties->setPropertyValue( C2U( "FillColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
+
+ if( bIsRTL )
+ xLegendProperties->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( 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( C2U("RightAngledAxes"), uno::makeAny( sal_True ));
+ xDiagramProperties->setPropertyValue( C2U("D3DScenePerspective"), uno::makeAny( drawing::ProjectionMode_PARALLEL ));
+ ThreeDHelper::setScheme( xDiagram, ThreeDLookScheme_Simple );
+ }
+
+ //set some new 'defaults' for wall and floor
+ if( xDiagram.is() )
+ {
+ Reference< beans::XPropertySet > xWall( xDiagram->getWall() );
+ if( xWall.is() )
+ {
+ xWall->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_SOLID ) );
+ xWall->setPropertyValue( C2U( "FillStyle" ), uno::makeAny( drawing::FillStyle_NONE ) );
+ xWall->setPropertyValue( C2U( "LineColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
+ xWall->setPropertyValue( C2U( "FillColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
+ }
+ Reference< beans::XPropertySet > xFloor( xDiagram->getFloor() );
+ if( xFloor.is() )
+ {
+ xFloor->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
+ xFloor->setPropertyValue( C2U( "FillStyle" ), uno::makeAny( drawing::FillStyle_SOLID ) );
+ xFloor->setPropertyValue( C2U( "LineColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
+ xFloor->setPropertyValue( C2U( "FillColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xcccccc ) ) ); // gray20
+ }
+
+ }
+ }
+ catch( uno::Exception & ex )
+ {
+ ASSERT_EXCEPTION( ex );
+ }
+ }
ChartModelHelper::setIncludeHiddenCells( false, this );
}
catch( uno::Exception & ex )
diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx
index d5436ddc02eb..f74764c398ef 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -369,18 +369,6 @@ void SAL_CALL Diagram::setDefaultColorScheme( const Reference< chart2::XColorSch
fireModifyEvent();
}
-void SAL_CALL Diagram::setUnusedData( const Sequence< Reference< chart2::data::XLabeledDataSequence > >& aUnusedData )
- throw (uno::RuntimeException)
-{
- m_aUnusedData = aUnusedData;
-}
-
-Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL Diagram::getUnusedData()
- throw (uno::RuntimeException)
-{
- return m_aUnusedData;
-}
-
// ____ XTitled ____
uno::Reference< chart2::XTitle > SAL_CALL Diagram::getTitleObject()
throw (uno::RuntimeException)
diff --git a/chart2/source/model/main/ImplChartModel.cxx b/chart2/source/model/main/ImplChartModel.cxx
deleted file mode 100755
index 77b78f16c861..000000000000
--- a/chart2/source/model/main/ImplChartModel.cxx
+++ /dev/null
@@ -1,537 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_chart2.hxx"
-#include "ImplChartModel.hxx"
-#include "DataSeries.hxx"
-#include "macros.hxx"
-#include "PageBackground.hxx"
-#include "DiagramHelper.hxx"
-#include "NameContainer.hxx"
-#include "CloneHelper.hxx"
-#include "ModifyListenerHelper.hxx"
-#include "DataSourceHelper.hxx"
-#include "DisposeHelper.hxx"
-#include "ChartModelHelper.hxx"
-#include "ThreeDHelper.hxx"
-#include "AxisHelper.hxx"
-
-// header for class SvNumberFormatter
-#include <svl/zforlist.hxx>
-// header for class SvNumberFormatsSupplierObj
-#include <svl/numuno.hxx>
-#include <vcl/svapp.hxx>
-#include <cppuhelper/component_context.hxx>
-
-#include <com/sun/star/chart2/LegendPosition.hpp>
-#include <com/sun/star/chart2/XDataSeries.hpp>
-#include <com/sun/star/chart/ChartDataRowSource.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/embed/XStorage.hpp>
-#include <com/sun/star/embed/ElementModes.hpp>
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/drawing/FillStyle.hpp>
-#include <com/sun/star/drawing/Hatch.hpp>
-#include <com/sun/star/drawing/LineDash.hpp>
-#include <com/sun/star/drawing/LineStyle.hpp>
-#include <com/sun/star/awt/Gradient.hpp>
-#include <com/sun/star/drawing/ProjectionMode.hpp>
-
-#include <vector>
-#include <algorithm>
-#include <functional>
-
-using namespace ::com::sun::star;
-using namespace ::chart::CloneHelper;
-
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-
-using ::rtl::OUString;
-
-namespace
-{
-
-struct lcl_removeListener : public ::std::unary_function< Reference< chart2::XDiagram >, void >
-{
- explicit lcl_removeListener( const Reference< util::XModifyListener > & xListener ) :
- m_xListener( xListener )
- {}
-
- void operator() ( const Reference< chart2::XDiagram > & xDia )
- {
- Reference< util::XModifyBroadcaster > xBroadcaster( xDia, uno::UNO_QUERY );
- if( xBroadcaster.is() && m_xListener.is())
- xBroadcaster->removeModifyListener( m_xListener );
- }
-private:
- Reference< util::XModifyListener > m_xListener;
-};
-
-} // anonymous namespace
-
-namespace chart
-{
-namespace impl
-{
-
-ImplChartModel::ImplChartModel(
- Reference< uno::XComponentContext > const & xContext,
- const Reference< util::XModifyListener > & xListener ) :
- m_xContext( xContext ),
- m_spChartData( new ChartData( m_xContext )),
- m_bIsDisposed( false ),
- m_xPageBackground( new PageBackground( m_xContext )),
- m_xXMLNamespaceMap( createNameContainer( ::getCppuType( (const OUString*) 0 ),
- C2U( "com.sun.star.xml.NamespaceMap" ), C2U( "com.sun.star.comp.chart.XMLNameSpaceMap" ) ), uno::UNO_QUERY),
- m_xModifyListener( xListener )
-{
- ModifyListenerHelper::addListener( m_xPageBackground, m_xModifyListener );
- m_xChartTypeManager.set(
- xContext->getServiceManager()->createInstanceWithContext(
- C2U( "com.sun.star.chart2.ChartTypeManager" ),
- xContext ), uno::UNO_QUERY );
-
- GetStyleFamilies();
- CreateDefaultChartTypeTemplate();
-}
-
-ImplChartModel::ImplChartModel( const ImplChartModel & rOther, const Reference< util::XModifyListener > & xListener ) :
- m_xContext( rOther.m_xContext ),
- m_spChartData( rOther.m_spChartData ),
- m_bIsDisposed( rOther.m_bIsDisposed ),
- m_xModifyListener( xListener )
-{
- m_xFamilies.set( CreateRefClone< Reference< container::XNameAccess > >()( rOther.m_xFamilies ));
- m_xChartTypeManager.set( CreateRefClone< Reference< chart2::XChartTypeManager > >()( rOther.m_xChartTypeManager ));
- m_xChartTypeTemplate.set( CreateRefClone< Reference< chart2::XChartTypeTemplate > >()( rOther.m_xChartTypeTemplate ));
- m_xTitle.set( CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle ));
- ModifyListenerHelper::addListener( m_xTitle, m_xModifyListener );
- m_xPageBackground.set( CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xPageBackground ));
- ModifyListenerHelper::addListener( m_xPageBackground, m_xModifyListener );
-
- m_xXMLNamespaceMap.set( CreateRefClone< Reference< container::XNameAccess > >()( rOther.m_xXMLNamespaceMap ));
-
- CloneRefVector< Reference< chart2::XDiagram > >( rOther.m_aDiagrams, m_aDiagrams );
-}
-
-ImplChartModel::~ImplChartModel()
-{}
-
-Reference< container::XNameAccess > ImplChartModel::GetStyleFamilies()
-{
- return m_xFamilies;
-}
-
-// Diagram Access
-
-void ImplChartModel::RemoveAllDiagrams()
-{
- ModifyListenerHelper::removeListenerFromAllElements( m_aDiagrams, m_xModifyListener );
- m_aDiagrams.clear();
-}
-
-void ImplChartModel::AppendDiagram( const Reference< chart2::XDiagram > & xDiagram )
-{
- Reference< util::XModifyBroadcaster > xBroadcaster( xDiagram, uno::UNO_QUERY );
- ModifyListenerHelper::addListener( xDiagram, m_xModifyListener );
- m_aDiagrams.push_back( xDiagram );
-}
-
-Reference< chart2::XDiagram > ImplChartModel::GetDiagram( size_t nIndex ) const
- throw( container::NoSuchElementException )
-{
- if( nIndex >= m_aDiagrams.size() )
- throw container::NoSuchElementException();
-
- return m_aDiagrams[ nIndex ];
-}
-
-void ImplChartModel::SetDataProvider(
- const Reference< chart2::data::XDataProvider > & xProvider )
-{
- OSL_ASSERT( m_spChartData.get() );
-
- m_spChartData->setDataProvider( xProvider );
-
- //the numberformatter is kept independent of the data provider!
-
- // release other ressources
-
- // @todo: maybe we need to save some properties of the old diagrams. When
- // the data provider changes from an outside Calc to an internal Calc,
- // e.g. when copying a chart into the clipboard as "standalone" format
-// if( bDeleteDiagrams && ! m_aDiagrams.empty())
-// m_aDiagrams.clear();
-}
-
-Reference< chart2::data::XDataProvider > ImplChartModel::GetDataProvider() const
-{
- OSL_ASSERT( m_spChartData.get() );
-
- return m_spChartData->getDataProvider();
-}
-
-void ImplChartModel::CreateInternalDataProvider(
- bool bCloneExistingData,
- const Reference< chart2::XChartDocument > & xChartDoc )
-{
- m_spChartData->createInternalData( bCloneExistingData, xChartDoc );
-}
-
-bool ImplChartModel::HasInternalDataProvider() const
-{
- OSL_ASSERT( m_spChartData.get() );
-
- return m_spChartData->hasInternalData();
-}
-
-Reference< chart2::data::XDataSource > SAL_CALL ImplChartModel::SetArguments(
- const Sequence< beans::PropertyValue > & aArguments,
- bool bSetData )
- throw (lang::IllegalArgumentException)
-{
- Reference< chart2::data::XDataSource > xResult;
- try
- {
- OSL_ASSERT( m_spChartData.get() );
-
- Reference< chart2::data::XDataProvider > xDataProvider(
- m_spChartData->getDataProvider());
- if( xDataProvider.is() )
- {
- xResult.set( xDataProvider->createDataSource( aArguments ));
-
- if( bSetData && xResult.is())
- SetNewData( xResult, aArguments );
- }
- }
- catch( lang::IllegalArgumentException & )
- {
- throw;
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
-
- return xResult;
-}
-
-Reference< chart2::data::XDataSource > SAL_CALL ImplChartModel::SetRangeRepresentation(
- const OUString & rRangeRepresentation, bool bSetData )
- throw (::com::sun::star::lang::IllegalArgumentException)
-{
- uno::Sequence< beans::PropertyValue > aArgs( 4 );
- aArgs[0] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
- uno::makeAny( rRangeRepresentation ), beans::PropertyState_DIRECT_VALUE );
- aArgs[1] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("HasCategories"), -1,
- uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
- aArgs[2] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
- uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
- aArgs[3] = beans::PropertyValue(
- ::rtl::OUString::createFromAscii("DataRowSource"), -1,
- uno::makeAny( ::com::sun::star::chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE );
- return SetArguments( aArgs, bSetData );
- /*
- uno::Sequence< beans::PropertyValue > aArgs();
-
- Reference< chart2::data::XDataProvider > xDataProvider( this->GetDataProvider() );
- if( xDataProvider.is() )
- aArgs = xDataProvider->detectArguments( DataSourceHelper::getUsedData( xChartModel ) ),
-
- ::rtl::OUString aRangeString;
- uno::Sequence< sal_Int32 > aSequenceMapping;
- bool bUseColumns = true;
- bool bFirstCellAsLabel = true;
- bool bHasCategories = true;
-
- DataSourceHelper::detectRangeSegmentation(
- uno::Reference< frame::XModel >( m_xChartDoc, uno::UNO_QUERY ),
- aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories );
-
- aArgs = createArguments( rRangeRepresentation, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories ) );
-
- return SetArguments( aArgs, bSetData );
- */
-}
-
-void ImplChartModel::SetChartTypeManager(
- const Reference< chart2::XChartTypeManager > & xManager )
-{
- m_xChartTypeManager = xManager;
-}
-
-Reference< chart2::XChartTypeManager > ImplChartModel::GetChartTypeManager()
-{
- return m_xChartTypeManager;
-}
-
-Reference< chart2::XChartTypeTemplate > ImplChartModel::GetChartTypeTemplate()
-{
- return m_xChartTypeTemplate;
-}
-
-void ImplChartModel::CreateDefaultChart()
-{
- CreateDefaultChartTypeTemplate();
-
- // clean up
- RemoveAllDiagrams();
-
- Reference< chart2::XChartTypeTemplate > xTemplate( GetChartTypeTemplate());
- if( xTemplate.is())
- {
- try
- {
- Reference< chart2::data::XDataSource > xDataSource( CreateDefaultData());
- Sequence< beans::PropertyValue > aParam;
-
- Sequence< OUString > aParamNames( xTemplate->getAvailableCreationParameterNames());
- const OUString * pBeg = aParamNames.getConstArray();
- const OUString * pEnd = pBeg + aParamNames.getLength();
- const OUString * pFound( ::std::find( pBeg, pEnd, C2U("HasCategories")));
- if( pFound != pEnd )
- {
- aParam.realloc( 1 );
- aParam[0] = beans::PropertyValue( C2U("HasCategories"), -1, uno::makeAny( true ),
- beans::PropertyState_DIRECT_VALUE );
- }
-
- Reference< chart2::XDiagram > xDiagram( xTemplate->createDiagramByDataSource( xDataSource, aParam ) );
-
- AppendDiagram( xDiagram );
-
- bool bIsRTL = Application::GetSettings().GetLayoutRTL();
- //reverse x axis for rtl charts
- if( bIsRTL )
- AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) );
-
- // create and attach legend
- Reference< chart2::XLegend > xLegend(
- m_xContext->getServiceManager()->createInstanceWithContext(
- C2U( "com.sun.star.chart2.Legend" ), m_xContext ), uno::UNO_QUERY_THROW );
- Reference< beans::XPropertySet > xLegendProperties( xLegend, uno::UNO_QUERY );
- if( xLegendProperties.is() )
- {
- xLegendProperties->setPropertyValue( C2U( "FillStyle" ), uno::makeAny( drawing::FillStyle_NONE ));
- xLegendProperties->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_NONE ));
- xLegendProperties->setPropertyValue( C2U( "LineColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) )); // gray30
- xLegendProperties->setPropertyValue( C2U( "FillColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
-
- if( bIsRTL )
- xLegendProperties->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( 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( C2U("RightAngledAxes"), uno::makeAny( sal_True ));
- xDiagramProperties->setPropertyValue( C2U("D3DScenePerspective"), uno::makeAny( drawing::ProjectionMode_PARALLEL ));
- ThreeDHelper::setScheme( xDiagram, ThreeDLookScheme_Simple );
- }
-
- //set some new 'defaults' for wall and floor
- if( xDiagram.is() )
- {
- Reference< beans::XPropertySet > xWall( xDiagram->getWall() );
- if( xWall.is() )
- {
- xWall->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_SOLID ) );
- xWall->setPropertyValue( C2U( "FillStyle" ), uno::makeAny( drawing::FillStyle_NONE ) );
- xWall->setPropertyValue( C2U( "LineColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
- xWall->setPropertyValue( C2U( "FillColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xe6e6e6 ) ) ); // gray10
- }
- Reference< beans::XPropertySet > xFloor( xDiagram->getFloor() );
- if( xFloor.is() )
- {
- xFloor->setPropertyValue( C2U( "LineStyle" ), uno::makeAny( drawing::LineStyle_NONE ) );
- xFloor->setPropertyValue( C2U( "FillStyle" ), uno::makeAny( drawing::FillStyle_SOLID ) );
- xFloor->setPropertyValue( C2U( "LineColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xb3b3b3 ) ) ); // gray30
- xFloor->setPropertyValue( C2U( "FillColor" ), uno::makeAny( static_cast< sal_Int32 >( 0xcccccc ) ) ); // gray20
- }
-
- }
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
- }
-}
-
-Reference< chart2::XTitle > ImplChartModel::GetTitle()
-{
- return m_xTitle;
-}
-
-void ImplChartModel::SetTitle( const Reference< chart2::XTitle >& rTitle )
-{
- if( m_xTitle.is())
- ModifyListenerHelper::removeListener( m_xTitle, m_xModifyListener );
- m_xTitle = rTitle;
- ModifyListenerHelper::addListener( m_xTitle, m_xModifyListener );
-}
-
-void ImplChartModel::dispose()
-{
- // exception is thrown by ChartModel
- if( m_bIsDisposed )
- return;
-
- m_spChartData.reset();
- m_xNumberFormatsSupplier.clear();
-
- DisposeHelper::DisposeAndClear( m_xFamilies );
- DisposeHelper::DisposeAndClear( m_xOwnNumberFormatsSupplier );
- DisposeHelper::DisposeAndClear( m_xChartTypeManager );
- DisposeHelper::DisposeAndClear( m_xChartTypeTemplate );
- DisposeHelper::DisposeAllElements( m_aDiagrams );
- m_aDiagrams.clear();
- DisposeHelper::DisposeAndClear( m_xTitle );
- DisposeHelper::DisposeAndClear( m_xPageBackground );
- DisposeHelper::DisposeAndClear( m_xXMLNamespaceMap );
-
- // note: m_xModifyListener is the ChartModel, so don't call dispose()
- m_xModifyListener.clear();
-
- m_bIsDisposed = true;
-}
-
-Reference< beans::XPropertySet > ImplChartModel::GetPageBackground()
-{
- return m_xPageBackground;
-}
-
-void ImplChartModel::SetNewData( const Reference< chart2::data::XDataSource > & xDataSource,
- const Sequence< beans::PropertyValue > & rArgs )
-{
- Reference< chart2::XDiagram > xDia;
- if( m_aDiagrams.size() > 0 )
- xDia.set( GetDiagram(0));
- Reference< chart2::XChartTypeTemplate > xTemplate;
-
- if( xDia.is())
- {
- // apply new data
- DiagramHelper::tTemplateWithServiceName aTemplateAndService =
- DiagramHelper::getTemplateForDiagram(
- xDia, Reference< lang::XMultiServiceFactory >( m_xChartTypeManager, uno::UNO_QUERY ));
- xTemplate.set( aTemplateAndService.first );
- }
-
- if( !xTemplate.is())
- xTemplate.set( GetChartTypeTemplate());
-
- if( xTemplate.is())
- {
- if( xDia.is())
- xTemplate->changeDiagramData( xDia, xDataSource, rArgs );
- else
- {
- RemoveAllDiagrams();
- AppendDiagram( xTemplate->createDiagramByDataSource( xDataSource, rArgs ));
- }
- }
-}
-
-Reference< chart2::data::XDataSource > ImplChartModel::CreateDefaultData()
-{
- Reference< chart2::data::XDataSource > xResult;
- if( m_spChartData->createDefaultData())
- xResult.set( SetRangeRepresentation( C2U("all"), false /* bSetData */ ));
- return xResult;
-}
-
-void ImplChartModel::CreateDefaultChartTypeTemplate()
-{
- // set default chart type
- Reference< lang::XMultiServiceFactory > xFact( m_xChartTypeManager, uno::UNO_QUERY );
- if( xFact.is() )
- {
- m_xChartTypeTemplate.set(
- xFact->createInstance( C2U( "com.sun.star.chart2.template.Column" ) ), uno::UNO_QUERY );
- }
-}
-
-Reference< uno::XInterface > ImplChartModel::GetXMLNameSpaceMap() const
-{
- return Reference< uno::XInterface >( m_xXMLNamespaceMap );
-}
-
-void ImplChartModel::SetNumberFormatsSupplier(
- const Reference< util::XNumberFormatsSupplier > & xNew )
-{
- if( xNew==m_xNumberFormatsSupplier )
- return;
- if( xNew==m_xOwnNumberFormatsSupplier )
- return;
- if( m_xOwnNumberFormatsSupplier.is() && xNew.is() )
- {
- //@todo
- //merge missing numberformats from own to new formatter
- }
- else if( !xNew.is() )
- {
- if( m_xNumberFormatsSupplier.is() )
- {
- //@todo
- //merge missing numberformats from old numberformatter to own numberformatter
- //create own numberformatter if necessary
- }
- }
-
- m_xNumberFormatsSupplier.set( xNew );
- m_xOwnNumberFormatsSupplier.clear();
-}
-
-Reference< util::XNumberFormatsSupplier > ImplChartModel::GetNumberFormatsSupplier()
-{
- if( !m_xNumberFormatsSupplier.is() )
- {
- if( !m_xOwnNumberFormatsSupplier.is() )
- {
- Reference< lang::XMultiServiceFactory > xFactory( m_xContext->getServiceManager(), uno::UNO_QUERY );
- m_xOwnNumberFormatsSupplier = new SvNumberFormatsSupplierObj( new SvNumberFormatter( xFactory, LANGUAGE_SYSTEM ) );
- //pOwnNumberFormatter->ChangeStandardPrec( 15 ); todo?
- }
- m_xNumberFormatsSupplier = m_xOwnNumberFormatsSupplier;
- }
- return m_xNumberFormatsSupplier;
-}
-
-} // namespace impl
-} // namespace chart
diff --git a/chart2/source/model/main/ImplChartModel.hxx b/chart2/source/model/main/ImplChartModel.hxx
deleted file mode 100644
index 1e0a0bf2c35a..000000000000
--- a/chart2/source/model/main/ImplChartModel.hxx
+++ /dev/null
@@ -1,228 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-#ifndef CHART_IMPLCHARTMODEL_HXX
-#define CHART_IMPLCHARTMODEL_HXX
-
-#include <com/sun/star/chart2/data/XDataSource.hpp>
-#include <com/sun/star/chart2/XDataSeries.hpp>
-#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
-#include <com/sun/star/chart2/XDiagram.hpp>
-#include <com/sun/star/chart2/data/XDataProvider.hpp>
-#include <com/sun/star/chart2/XChartTypeManager.hpp>
-#include <com/sun/star/chart2/XChartTypeTemplate.hpp>
-#include <com/sun/star/chart2/XTitle.hpp>
-#include <com/sun/star/chart2/XChartDocument.hpp>
-#include <com/sun/star/chart2/XUndoManager.hpp>
-
-#include <com/sun/star/container/XNameContainer.hpp>
-#include <com/sun/star/container/NoSuchElementException.hpp>
-#include <com/sun/star/io/IOException.hpp>
-#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
-
-#include <cppuhelper/weakref.hxx>
-
-#include "ChartData.hxx"
-
-#include <vector>
-#include <memory>
-#include <boost/shared_ptr.hpp>
-
-namespace com { namespace sun { namespace star {
- namespace container {
- class XNameAccess;
- }
- namespace uno {
- class XComponentContext;
- }
- namespace embed {
- class XStorage;
- }
- namespace document {
- class XFilter;
- }
- namespace util {
- class XModifyListener;
- }
-}}}
-
-class SvNumberFormatter;
-
-namespace chart
-{
-namespace impl
-{
-
-class ImplChartModel
-{
- typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > tDataSourceType;
-
-public:
- ImplChartModel( ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XComponentContext > const & xContext,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::util::XModifyListener > & xListener );
- explicit ImplChartModel( const ImplChartModel & rOther,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::util::XModifyListener > & xListener );
- ~ImplChartModel();
-
-// ::com::sun::star::uno::Sequence<
-// ::com::sun::star::uno::Reference<
-// ::com::sun::star::chart2::XDataSeries > >
-// GetDataSeries() const;
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::container::XNameAccess >
- GetStyleFamilies();
-
- // Diagram Access
- void RemoveAllDiagrams();
- /** @return true, if the chart was found and removed, false otherwise.
- */
- void AppendDiagram( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XDiagram > & xDiagram );
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XDiagram >
- GetDiagram( size_t nIndex ) const
- throw( ::com::sun::star::container::NoSuchElementException );
-
- void SetDataProvider( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataProvider > & xProvider );
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataProvider > GetDataProvider() const;
-
- void CreateInternalDataProvider(
- bool bCloneExistingData,
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc );
-
- bool HasInternalDataProvider() const;
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataSource > SAL_CALL SetArguments(
- const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & rArgs,
- bool bSetData )
- throw (::com::sun::star::lang::IllegalArgumentException);
-
- void SetChartTypeManager(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartTypeManager > & xManager );
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartTypeManager >
- GetChartTypeManager();
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XChartTypeTemplate >
- GetChartTypeTemplate();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle >
- GetTitle();
-
- void SetTitle( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XTitle >& rTitle );
-
- /** Is called by the ChartModel's XComponent::dispose() to notify the
- impl-class to release resources
- */
- void dispose();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
- GetPageBackground();
-
- void CreateDefaultChart();
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XInterface > GetXMLNameSpaceMap() const;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >
- GetNumberFormatsSupplier();
-
- void SetNumberFormatsSupplier(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier );
-
-private:
- void CreateDefaultChartTypeTemplate();
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataSource > CreateDefaultData();
- void SetNewData( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataSource > & xDataSource,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & rArgs );
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataSource > SAL_CALL SetRangeRepresentation(
- const ::rtl::OUString & rRangeRepresentation, bool bSetData )
- throw (::com::sun::star::lang::IllegalArgumentException);
-
-// void CreateDefaultLayout();
-
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xFamilies;
-
- ::boost::shared_ptr< ChartData > m_spChartData;
-
- // Data Access (deprecated, temporary solution)
-// ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > m_xChartData;
-// ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > m_xDataProvider;
-
-// ::std::vector< ::com::sun::star::uno::Reference<
-// ::com::sun::star::chart2::XDataSeries > > m_aInterpretedData;
-
- ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >
- m_xOwnNumberFormatsSupplier;
- ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >
- m_xNumberFormatsSupplier;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeManager >
- m_xChartTypeManager;
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeTemplate >
- m_xChartTypeTemplate;
-
- // Diagram Access
- typedef ::std::vector< ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XDiagram > >
- tDiagramContainer;
-
- tDiagramContainer m_aDiagrams;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle >
- m_xTitle;
-
- bool m_bIsDisposed;
- ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
- m_xPageBackground;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xXMLNamespaceMap;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > m_xModifyListener;
-};
-
-} // namespace impl
-} // namespace chart
-
-// CHART_IMPLCHARTMODEL_HXX
-#endif
diff --git a/chart2/source/model/main/InternalData.cxx b/chart2/source/model/main/InternalData.cxx
deleted file mode 100644
index 860715825af4..000000000000
--- a/chart2/source/model/main/InternalData.cxx
+++ /dev/null
@@ -1,257 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_chart2.hxx"
-
-#include "InternalData.hxx"
-#include "macros.hxx"
-#include <com/sun/star/embed/XEmbedPersist.hpp>
-#include <com/sun/star/embed/XEmbedObjectCreator.hpp>
-#include <com/sun/star/chart2/data/XDataProvider.hpp>
-#include <com/sun/star/util/XCloseable.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <sot/clsids.hxx>
-
-using namespace ::com::sun::star;
-
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-using ::rtl::OUString;
-
-namespace
-{
-/** convert a class-id macro into a byte-sequence
- call e.g. lcl_GetSequenceClassID( SO3_SC_CLASSID_60 )
- */
-Sequence< sal_Int8 > lcl_GetSequenceClassID( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
- sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11,
- sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15 )
-{
- Sequence< sal_Int8 > aResult( 16 );
- aResult[0] = static_cast<sal_Int8>(n1 >> 24);
- aResult[1] = static_cast<sal_Int8>(( n1 << 8 ) >> 24);
- aResult[2] = static_cast<sal_Int8>(( n1 << 16 ) >> 24);
- aResult[3] = static_cast<sal_Int8>(( n1 << 24 ) >> 24);
- aResult[4] = n2 >> 8;
- aResult[5] = ( n2 << 8 ) >> 8;
- aResult[6] = n3 >> 8;
- aResult[7] = ( n3 << 8 ) >> 8;
- aResult[8] = b8;
- aResult[9] = b9;
- aResult[10] = b10;
- aResult[11] = b11;
- aResult[12] = b12;
- aResult[13] = b13;
- aResult[14] = b14;
- aResult[15] = b15;
-
- return aResult;
-}
-
-Reference< embed::XStorage > lcl_CreateTempStorage(
- const Reference< lang::XMultiServiceFactory > & rFactory )
-{
- Reference< embed::XStorage > xResult;
-
- try
- {
- Reference< lang::XSingleServiceFactory > xStorageFact(
- rFactory->createInstance( C2U( "com.sun.star.embed.StorageFactory" )),
- uno::UNO_QUERY_THROW );
- xResult.set( xStorageFact->createInstance(), uno::UNO_QUERY_THROW );
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
-
- return xResult;
-}
-
-} // anonymous namespace
-
-
-
-namespace chart
-{
-
-//explicit
-InternalData::InternalData(
- const Reference< uno::XComponentContext > & xContext,
- const Reference< embed::XStorage > & xParentStorage ) :
- m_aDataStorageName( RTL_CONSTASCII_USTRINGPARAM("ChartData")),
- m_xContext( xContext ),
- m_xParentStorage( xParentStorage )
-{}
-
-InternalData::~InternalData()
-{
-}
-
-void SAL_CALL InternalData::saveObject()
- throw (embed::ObjectSaveVetoException,
- uno::Exception,
- uno::RuntimeException)
-{
- if( m_xInternalData.is())
- {
- try
- {
- Reference< embed::XEmbedPersist > xPersist( m_xInternalData, uno::UNO_QUERY_THROW );
- xPersist->storeOwn();
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
- }
-}
-
-void SAL_CALL InternalData::visibilityChanged( sal_Bool bVisible )
- throw (embed::WrongStateException,
- uno::RuntimeException)
-{
- // ignore (this is for swapping OLE objects?)
-}
-
-Reference< util::XCloseable > SAL_CALL InternalData::getComponent()
- throw (uno::RuntimeException)
-{
- return Reference< util::XCloseable >( m_xInternalData, uno::UNO_QUERY );
-}
-
-// ____ XCloseListener ____
-void SAL_CALL InternalData::queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership )
- throw (util::CloseVetoException,
- uno::RuntimeException)
-{
- // empty
-}
-
-void SAL_CALL InternalData::notifyClosing( const lang::EventObject& Source )
- throw (uno::RuntimeException)
-{
- try
- {
- Reference< util::XCloseable > xCloseable( m_xInternalData, uno::UNO_QUERY );
- if( xCloseable.is())
- xCloseable->close( /* DeliverOwnership */ sal_False );
-
- Reference< lang::XComponent > xComp( m_xInternalData, uno::UNO_QUERY );
- if( xComp.is())
- xComp->dispose();
- m_xInternalData = 0;
- }
- catch( const util::CloseVetoException & )
- {
- throw;
- }
- catch( const uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
-}
-
- // ____ XEventListener ____
-void SAL_CALL InternalData::disposing(
- const lang::EventObject& Source )
- throw (uno::RuntimeException)
-{
- // empty
-}
-
-Reference< chart2::data::XDataProvider > InternalData::createEmbeddedObject() throw()
-{
- OSL_ASSERT( m_xContext.is());
- Reference< chart2::data::XDataProvider > xResult;
-
- try
- {
- if( ! m_xInternalData.is() && m_xContext.is())
- {
- Reference< lang::XMultiServiceFactory > xFactory(
- m_xContext->getServiceManager(), uno::UNO_QUERY_THROW );
- Reference< embed::XEmbedObjectCreator > xCreator(
- xFactory->createInstance(
- C2U( "com.sun.star.embed.EmbeddedObjectCreator")), uno::UNO_QUERY_THROW );
-
- Reference< embed::XStorage > xStorage( m_xParentStorage );
- if( !xStorage.is())
- {
- // as we don't store the spreadsheet as substorage in the final
- // document, it is ok, or maybe even better to create a
- // temporary storage
-// OSL_ENSURE( false, "Using temporary storage for chart data!" );
- xStorage.set( lcl_CreateTempStorage( xFactory ));
- }
-
- m_xInternalData.set(
- xCreator->createInstanceInitNew(
- lcl_GetSequenceClassID( SO3_SC_CLASSID_60 ),
- C2U( "ChartDataEditor" ),
- xStorage,
- m_aDataStorageName,
- Sequence< beans::PropertyValue >() ), uno::UNO_QUERY_THROW );
-
- m_xInternalData->setClientSite( this );
-
- xFactory.set( m_xInternalData->getComponent(), uno::UNO_QUERY_THROW );
- xResult.set(
- xFactory->createInstance( C2U( "com.sun.star.chart2.data.DataProvider" )), uno::UNO_QUERY_THROW );
- }
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
-
- return xResult;
-}
-
-void InternalData::removeEmbeddedObject() throw()
-{
- if( m_xParentStorage.is())
- {
- try
- {
- m_xParentStorage->removeElement( m_aDataStorageName );
- }
- catch( uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
- }
-}
-
-Reference< embed::XEmbeddedObject > InternalData::getEmbeddedObject() const throw()
-{
- return m_xInternalData;
-}
-
-} // namespace chart
diff --git a/chart2/source/model/main/InternalData.hxx b/chart2/source/model/main/InternalData.hxx
deleted file mode 100644
index 15b3e9d0e8f0..000000000000
--- a/chart2/source/model/main/InternalData.hxx
+++ /dev/null
@@ -1,118 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-#ifndef CHART2_INTERNALDATA_HXX
-#define CHART2_INTERNALDATA_HXX
-
-#include <com/sun/star/embed/XEmbeddedClient.hpp>
-#include <com/sun/star/embed/XEmbeddedObject.hpp>
-#include <com/sun/star/util/XCloseListener.hpp>
-#include <cppuhelper/implbase2.hxx>
-
-namespace com { namespace sun { namespace star {
- namespace uno {
- class XComponentContext;
- }
- namespace embed {
- class XStorage;
- class XEmbeddedObject;
- }
- namespace chart2 {
- namespace data {
- class XDataProvider;
- }
- }
-}}}
-
-namespace chart
-{
-
-class InternalData :
- public ::cppu::WeakImplHelper2<
- ::com::sun::star::embed::XEmbeddedClient,
- ::com::sun::star::util::XCloseListener >
-{
-public:
- explicit InternalData(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XComponentContext > & xContext,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::embed::XStorage > & xParentStorage );
- virtual ~InternalData();
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XDataProvider > createEmbeddedObject() throw();
-
- void removeEmbeddedObject() throw();
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::embed::XEmbeddedObject > getEmbeddedObject() const throw();
-
- // ____ XEmbeddedClient ____
- virtual void SAL_CALL saveObject()
- throw (::com::sun::star::embed::ObjectSaveVetoException,
- ::com::sun::star::uno::Exception,
- ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL visibilityChanged( sal_Bool bVisible )
- throw (::com::sun::star::embed::WrongStateException,
- ::com::sun::star::uno::RuntimeException);
-
- // ____ XComponentSupplier ____
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > SAL_CALL getComponent()
- throw (::com::sun::star::uno::RuntimeException);
-
- // ____ XCloseListener ____
- virtual void SAL_CALL queryClosing(
- const ::com::sun::star::lang::EventObject& Source,
- ::sal_Bool GetsOwnership )
- throw (::com::sun::star::util::CloseVetoException,
- ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL notifyClosing(
- const ::com::sun::star::lang::EventObject& Source )
- throw (::com::sun::star::uno::RuntimeException);
-
- // ____ XEventListener ____
- virtual void SAL_CALL disposing(
- const ::com::sun::star::lang::EventObject& Source )
- throw (::com::sun::star::uno::RuntimeException);
-
-private:
- const ::rtl::OUString m_aDataStorageName;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
- m_xContext;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject >
- m_xInternalData;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
- m_xParentStorage;
-};
-
-} // namespace chart
-
-// CHART2_INTERNALDATA_HXX
-#endif
diff --git a/chart2/source/model/main/makefile.mk b/chart2/source/model/main/makefile.mk
index b4d74a878584..8e963dfa0f5c 100644
--- a/chart2/source/model/main/makefile.mk
+++ b/chart2/source/model/main/makefile.mk
@@ -46,7 +46,6 @@ SLOFILES= \
$(SLO)$/GridProperties.obj \
$(SLO)$/BaseCoordinateSystem.obj \
$(SLO)$/CartesianCoordinateSystem.obj \
- $(SLO)$/ChartData.obj \
$(SLO)$/ChartModel.obj \
$(SLO)$/ChartModel_Persistence.obj \
$(SLO)$/DataPoint.obj \
@@ -55,7 +54,6 @@ SLOFILES= \
$(SLO)$/Diagram.obj \
$(SLO)$/DataSeriesProperties.obj \
$(SLO)$/FormattedString.obj \
- $(SLO)$/ImplChartModel.obj \
$(SLO)$/Legend.obj \
$(SLO)$/PageBackground.obj \
$(SLO)$/PolarCoordinateSystem.obj \
diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.cxx b/chart2/source/model/template/BubbleChartTypeTemplate.cxx
index 706db07f8288..3f297d1e2e27 100644
--- a/chart2/source/model/template/BubbleChartTypeTemplate.cxx
+++ b/chart2/source/model/template/BubbleChartTypeTemplate.cxx
@@ -178,12 +178,6 @@ StackMode BubbleChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */
return StackMode_NONE;
}
-bool BubbleChartTypeTemplate::supportsCategories() const
-{
- return false;
-}
-
-
void SAL_CALL BubbleChartTypeTemplate::applyStyle(
const Reference< chart2::XDataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
@@ -203,10 +197,10 @@ void SAL_CALL BubbleChartTypeTemplate::applyStyle(
}
// ____ XChartTypeTemplate ____
-Sequence< OUString > SAL_CALL BubbleChartTypeTemplate::getAvailableCreationParameterNames()
+sal_Bool SAL_CALL BubbleChartTypeTemplate::supportsCategories()
throw (uno::RuntimeException)
{
- return Sequence< OUString >();
+ return false;
}
sal_Bool SAL_CALL BubbleChartTypeTemplate::matchesTemplate(
diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.hxx b/chart2/source/model/template/BubbleChartTypeTemplate.hxx
index 27259f877805..24d35c6acbb7 100644
--- a/chart2/source/model/template/BubbleChartTypeTemplate.hxx
+++ b/chart2/source/model/template/BubbleChartTypeTemplate.hxx
@@ -67,7 +67,7 @@ protected:
throw (::com::sun::star::uno::RuntimeException);
// ____ XChartTypeTemplate ____
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableCreationParameterNames()
+ virtual sal_Bool SAL_CALL supportsCategories()
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL matchesTemplate(
const ::com::sun::star::uno::Reference<
@@ -93,8 +93,6 @@ protected:
getChartTypeForIndex( sal_Int32 nChartTypeIndex );
virtual sal_Int32 getDimension() const;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const;
-
- virtual bool supportsCategories() const;
};
} // namespace chart
diff --git a/chart2/source/model/template/BubbleDataInterpreter.cxx b/chart2/source/model/template/BubbleDataInterpreter.cxx
index b69055a9e632..1f26fff907e4 100644
--- a/chart2/source/model/template/BubbleDataInterpreter.cxx
+++ b/chart2/source/model/template/BubbleDataInterpreter.cxx
@@ -78,8 +78,6 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
Reference< data::XLabeledDataSequence > xCategories;
bool bHasCategories = HasCategories( aArguments, aData );
- Sequence< Reference< data::XLabeledDataSequence > > aUnusedData;
-
bool bHasXValues = false;
sal_Int32 nDataSeqCount = aData.getLength();
@@ -170,7 +168,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource(
Sequence< Sequence< Reference< XDataSeries > > > aSeries(1);
aSeries[0] = ContainerHelper::ContainerToSequence( aSeriesVec );
- return InterpretedData( aSeries, xCategories, aUnusedData );
+ return InterpretedData( aSeries, xCategories );
}
chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
@@ -178,8 +176,6 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
throw (uno::RuntimeException)
{
InterpretedData aResult( aInterpretedData );
- vector< Reference< data::XLabeledDataSequence > > aUnused(
- ContainerHelper::SequenceToVector( aInterpretedData.UnusedData ));
sal_Int32 i=0;
Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
@@ -266,17 +262,15 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries(
Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
if( aSeqs.getLength() != aNewSequences.getLength() )
{
+#if OSL_DEBUG_LEVEL > 1
sal_Int32 j=0;
for( ; j<aSeqs.getLength(); ++j )
{
- if( aSeqs[j] != xValuesY &&
- aSeqs[j] != xValuesX &&
- aSeqs[j] != xValuesSize )
- aUnused.push_back( aSeqs[j] );
+ OSL_ENSURE( aSeqs[j] == xValuesY || aSeqs[j] == xValuesX || aSeqs[j] == xValuesSize, "All sequences should be used" );
}
+#endif
Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
xSink->setData( aNewSequences );
- aResult.UnusedData = ContainerHelper::ContainerToSequence( aUnused );
}
}
catch( uno::Exception & ex )
diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx
index 2fd0ca2a1d89..393321a19d55 100644
--- a/chart2/source/model/template/ChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ChartTypeTemplate.cxx
@@ -192,11 +192,10 @@ uno::Reference< XDiagram > SAL_CALL ChartTypeTemplate::createDiagramByDataSource
return xDia;
}
-Sequence< OUString > SAL_CALL ChartTypeTemplate::getAvailableCreationParameterNames()
+sal_Bool SAL_CALL ChartTypeTemplate::supportsCategories()
throw (uno::RuntimeException)
{
- OUString aHasCat( C2U("HasCategories"));
- return Sequence< OUString >( & aHasCat, 1 );
+ return sal_True;
}
void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >& xDiagram )
@@ -217,10 +216,8 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >
chart2::InterpretedData aData;
aData.Series = aSeriesSeq;
aData.Categories = DiagramHelper::getCategoriesFromDiagram( xDiagram );
- aData.UnusedData = xDiagram->getUnusedData();
- if( (aData.UnusedData.getLength() == 0) &&
- xInterpreter->isDataCompatible( aData ))
+ if( xInterpreter->isDataCompatible( aData ) )
{
aData = xInterpreter->reinterpretDataSeries( aData );
}
@@ -238,32 +235,9 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >
aParam[0] = beans::PropertyValue( C2U("HasCategories"), -1, uno::makeAny( true ),
beans::PropertyState_DIRECT_VALUE );
}
- else if( aData.UnusedData.getLength())
- {
- for( sal_Int32 i=0; i<aData.UnusedData.getLength(); ++i )
- try
- {
- Reference< beans::XPropertySet > xProp( aData.UnusedData[i]->getValues(), uno::UNO_QUERY_THROW );
- OUString aRole;
- if( (xProp->getPropertyValue(C2U("Role")) >>= aRole) &
- aRole.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("categories")) )
- {
- aData.Categories = aData.UnusedData[i];
- for( ++i; i<aData.UnusedData.getLength(); ++i )
- aData.UnusedData[i-1] = aData.UnusedData[i];
- aData.UnusedData.realloc( aData.UnusedData.getLength() - 1 );
- break;
- }
- }
- catch( const uno::Exception & ex )
- {
- ASSERT_EXCEPTION( ex );
- }
- }
aData = xInterpreter->interpretDataSource( xSource, aParam, aFlatSeriesSeq );
}
aSeriesSeq = aData.Series;
- xDiagram->setUnusedData( aData.UnusedData );
sal_Int32 i, j, nIndex = 0;
for( i=0; i<aSeriesSeq.getLength(); ++i )
@@ -583,11 +557,6 @@ bool ChartTypeTemplate::isSwapXAndY() const
return false;
}
-bool ChartTypeTemplate::supportsCategories() const
-{
- return true;
-}
-
// ________________________________________
void ChartTypeTemplate::createCoordinateSystems(
@@ -661,7 +630,7 @@ void ChartTypeTemplate::adaptScales(
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());
+ bool bSupportsCategories( supportsCategories() );
for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
{
try
diff --git a/chart2/source/model/template/ChartTypeTemplate.hxx b/chart2/source/model/template/ChartTypeTemplate.hxx
index 2247c13ec940..3f43e0ca6038 100644
--- a/chart2/source/model/template/ChartTypeTemplate.hxx
+++ b/chart2/source/model/template/ChartTypeTemplate.hxx
@@ -100,7 +100,8 @@ protected:
const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource >& xDataSource,
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableCreationParameterNames()
+ /// denotes if the chart needs categories at the first scale
+ virtual sal_Bool SAL_CALL supportsCategories()
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL changeDiagram(
const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram )
@@ -158,9 +159,6 @@ protected:
virtual bool isSwapXAndY() const;
- /// denotes if the chart needs categories at the first scale
- virtual bool supportsCategories() const;
-
// Methods for creating the diagram piecewise
// ------------------------------------------
diff --git a/chart2/source/model/template/DataInterpreter.cxx b/chart2/source/model/template/DataInterpreter.cxx
index 6d5b85fd3e4b..b619553ee959 100644
--- a/chart2/source/model/template/DataInterpreter.cxx
+++ b/chart2/source/model/template/DataInterpreter.cxx
@@ -149,7 +149,7 @@ InterpretedData SAL_CALL DataInterpreter::interpretDataSource(
Sequence< Sequence< Reference< XDataSeries > > > aSeries(1);
aSeries[0] = ContainerToSequence( aSeriesVec );
- return InterpretedData( aSeries, xCategories, Sequence< Reference< data::XLabeledDataSequence > >() );
+ return InterpretedData( aSeries, xCategories );
}
InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
@@ -157,8 +157,6 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
throw (uno::RuntimeException)
{
InterpretedData aResult( aInterpretedData );
- vector< Reference< data::XLabeledDataSequence > > aUnused(
- SequenceToVector( aInterpretedData.UnusedData ));
sal_Int32 i=0;
Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
@@ -190,14 +188,14 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
if( aSeqs.getLength() != aNewSequences.getLength() )
{
+#if OSL_DEBUG_LEVEL > 1
sal_Int32 j=0;
for( ; j<aSeqs.getLength(); ++j )
{
- if( aSeqs[j] != xValuesY )
- aUnused.push_back( aSeqs[j] );
+ OSL_ENSURE( aSeqs[j] == xValuesY, "All sequences should be used" );
}
+#endif
Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
-
xSink->setData( aNewSequences );
}
}
@@ -207,8 +205,6 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries(
}
}
- aResult.UnusedData = ContainerToSequence( aUnused );
-
return aResult;
}
@@ -294,34 +290,13 @@ Reference< data::XDataSource > SAL_CALL DataInterpreter::mergeInterpretedData(
throw (uno::RuntimeException)
{
vector< Reference< data::XLabeledDataSequence > > aResultVec;
- vector< Reference< data::XLabeledDataSequence > > aUnusedDataVec;
aResultVec.reserve( aInterpretedData.Series.getLength() +
- aInterpretedData.UnusedData.getLength() +
1 // categories
);
if( aInterpretedData.Categories.is())
aResultVec.push_back( aInterpretedData.Categories );
- // add unused data that has the Role categories at front
- if( aInterpretedData.UnusedData.getLength())
- {
- sal_Int32 nSize = aInterpretedData.UnusedData.getLength();
- for( sal_Int32 i=0; i<nSize; ++i )
- {
- Reference< data::XLabeledDataSequence > xPotentialCategories( aInterpretedData.UnusedData[i] );
- if( xPotentialCategories.is() )
- {
- if( GetRole( xPotentialCategories->getValues()).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("categories")))
- aResultVec.push_back( xPotentialCategories );
- else
- aUnusedDataVec.push_back( xPotentialCategories );
- }
- }
- }
- else
- aUnusedDataVec = SequenceToVector( aInterpretedData.UnusedData );
-
Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeries.getLength(); ++nSeriesIdx )
{
@@ -349,9 +324,6 @@ Reference< data::XDataSource > SAL_CALL DataInterpreter::mergeInterpretedData(
}
}
- // add unused data at end
- copy( aUnusedDataVec.begin(), aUnusedDataVec.end(), back_inserter( aResultVec ));
-
return Reference< data::XDataSource >( DataSourceHelper::createDataSource( ContainerToSequence( aResultVec ) ) );
}
diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.cxx b/chart2/source/model/template/ScatterChartTypeTemplate.cxx
index 7c83e80d7234..f952abaa3611 100644
--- a/chart2/source/model/template/ScatterChartTypeTemplate.cxx
+++ b/chart2/source/model/template/ScatterChartTypeTemplate.cxx
@@ -219,12 +219,6 @@ StackMode ScatterChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex *
return StackMode_NONE;
}
-bool ScatterChartTypeTemplate::supportsCategories() const
-{
- return false;
-}
-
-
void SAL_CALL ScatterChartTypeTemplate::applyStyle(
const Reference< chart2::XDataSeries >& xSeries,
::sal_Int32 nChartTypeIndex,
@@ -249,10 +243,10 @@ void SAL_CALL ScatterChartTypeTemplate::applyStyle(
}
// ____ XChartTypeTemplate ____
-Sequence< OUString > SAL_CALL ScatterChartTypeTemplate::getAvailableCreationParameterNames()
+sal_Bool SAL_CALL ScatterChartTypeTemplate::supportsCategories()
throw (uno::RuntimeException)
{
- return Sequence< OUString >();
+ return sal_False;
}
sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate(
diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.hxx b/chart2/source/model/template/ScatterChartTypeTemplate.hxx
index 6cb15247a0d9..048cca73a92c 100644
--- a/chart2/source/model/template/ScatterChartTypeTemplate.hxx
+++ b/chart2/source/model/template/ScatterChartTypeTemplate.hxx
@@ -71,7 +71,7 @@ protected:
throw (::com::sun::star::uno::RuntimeException);
// ____ XChartTypeTemplate ____
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableCreationParameterNames()
+ virtual sal_Bool SAL_CALL supportsCategories()
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL matchesTemplate(
const ::com::sun::star::uno::Reference<
@@ -98,8 +98,6 @@ protected:
virtual sal_Int32 getDimension() const;
virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const;
- virtual bool supportsCategories() const;
-
private:
bool m_bHasSymbols;
bool m_bHasLines;
diff --git a/chart2/source/model/template/StockDataInterpreter.cxx b/chart2/source/model/template/StockDataInterpreter.cxx
index d7da1e7ea04c..0d134516a1bb 100644
--- a/chart2/source/model/template/StockDataInterpreter.cxx
+++ b/chart2/source/model/template/StockDataInterpreter.cxx
@@ -268,8 +268,7 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource(
}
}
- const Sequence< Reference< data::XLabeledDataSequence > > aUnusedData;//@todo remove the unused data concept completely
- return InterpretedData( aResultSeries, xCategories, aUnusedData );
+ return InterpretedData( aResultSeries, xCategories );
}
// criterion: there must be two groups for stock-charts with volume and all
@@ -302,7 +301,7 @@ sal_Bool SAL_CALL StockDataInterpreter::isDataCompatible(
if( ! DataInterpreter::isDataCompatible(
InterpretedData( Sequence< Sequence< Reference< XDataSeries > > >(
aInterpretedData.Series.getConstArray(), 1 ),
- aInterpretedData.Categories, aInterpretedData.UnusedData )))
+ aInterpretedData.Categories )))
return sal_False;
}
diff --git a/chart2/source/model/template/XYDataInterpreter.cxx b/chart2/source/model/template/XYDataInterpreter.cxx
index 0bf1e73562e4..839c0cbac510 100644
--- a/chart2/source/model/template/XYDataInterpreter.cxx
+++ b/chart2/source/model/template/XYDataInterpreter.cxx
@@ -79,8 +79,6 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
bool bHasCategories = HasCategories( aArguments, aData );
// parse data
- Sequence< Reference< data::XLabeledDataSequence > > aUnusedData;
-
bool bCategoriesUsed = false;
for( sal_Int32 nDataIdx= 0; nDataIdx < aData.getLength(); ++nDataIdx )
{
@@ -157,7 +155,7 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource(
Sequence< Sequence< Reference< XDataSeries > > > aSeries(1);
aSeries[0] = ContainerHelper::ContainerToSequence( aSeriesVec );
- return InterpretedData( aSeries, xCategories, aUnusedData );
+ return InterpretedData( aSeries, xCategories );
}
chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
@@ -165,8 +163,6 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
throw (uno::RuntimeException)
{
InterpretedData aResult( aInterpretedData );
- vector< Reference< data::XLabeledDataSequence > > aUnused(
- ContainerHelper::SequenceToVector( aInterpretedData.UnusedData ));
sal_Int32 i=0;
Sequence< Reference< XDataSeries > > aSeries( FlattenSequence( aInterpretedData.Series ));
@@ -230,16 +226,15 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries(
Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences());
if( aSeqs.getLength() != aNewSequences.getLength() )
{
+#if OSL_DEBUG_LEVEL > 1
sal_Int32 j=0;
for( ; j<aSeqs.getLength(); ++j )
{
- if( aSeqs[j] != xValuesY &&
- aSeqs[j] != xValuesX )
- aUnused.push_back( aSeqs[j] );
+ OSL_ENSURE( aSeqs[j] == xValuesY || aSeqs[j] == xValuesX, "All sequences should be used" );
}
+#endif
Reference< data::XDataSink > xSink( xSeriesSource, uno::UNO_QUERY_THROW );
xSink->setData( aNewSequences );
- aResult.UnusedData = ContainerHelper::ContainerToSequence( aUnused );
}
}
catch( uno::Exception & ex )
diff --git a/chart2/source/tools/ChartModelHelper.cxx b/chart2/source/tools/ChartModelHelper.cxx
index 8ce45e85038d..ed8c36e08c8d 100644
--- a/chart2/source/tools/ChartModelHelper.cxx
+++ b/chart2/source/tools/ChartModelHelper.cxx
@@ -62,23 +62,10 @@ uno::Reference< chart2::data::XRangeHighlighter > ChartModelHelper::createRangeH
}
//static
-uno::Reference< chart2::data::XDataProvider > ChartModelHelper::createInternalDataProvider()
-{
- return new InternalDataProvider();
-}
-
-//static
uno::Reference< chart2::data::XDataProvider > ChartModelHelper::createInternalDataProvider(
- const uno::Reference< ::com::sun::star::chart::XChartDataArray >& xDataToCopy )
+ const uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc, bool bConnectToModel )
{
- return new InternalDataProvider( xDataToCopy );
-}
-
-//static
-uno::Reference< chart2::data::XDataProvider > ChartModelHelper::createInternalDataProvider(
- const uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc )
-{
- return new InternalDataProvider( xChartDoc );
+ return new InternalDataProvider( xChartDoc, bConnectToModel );
}
//static
@@ -105,6 +92,20 @@ uno::Reference< XDiagram > ChartModelHelper::findDiagram( const uno::Reference<
return NULL;
}
+//static
+uno::Reference< XCoordinateSystem > ChartModelHelper::getFirstCoordinateSystem( const uno::Reference< frame::XModel >& xModel )
+{
+ uno::Reference< XCoordinateSystem > XCooSys;
+ uno::Reference< XCoordinateSystemContainer > xCooSysCnt( ChartModelHelper::findDiagram( xModel ), uno::UNO_QUERY );
+ if( xCooSysCnt.is() )
+ {
+ uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() );
+ if( aCooSysSeq.getLength() )
+ XCooSys = aCooSysSeq[0];
+ }
+ return XCooSys;
+}
+
// static
::std::vector< uno::Reference< XDataSeries > > ChartModelHelper::getDataSeries(
const uno::Reference< XChartDocument > & xChartDoc )
diff --git a/chart2/source/tools/DataSourceHelper.cxx b/chart2/source/tools/DataSourceHelper.cxx
index 837f07432e32..0cc6ef4a4315 100644
--- a/chart2/source/tools/DataSourceHelper.cxx
+++ b/chart2/source/tools/DataSourceHelper.cxx
@@ -298,18 +298,13 @@ uno::Sequence< ::rtl::OUString > DataSourceHelper::getUsedDataRanges( const uno:
}
uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData(
- const uno::Reference< chart2::XChartDocument >& xChartDoc,
- bool bIncludeUnusedData /* = false */ )
+ const uno::Reference< chart2::XChartDocument >& xChartDoc )
{
- if( bIncludeUnusedData )
- return getUsedData( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ), bIncludeUnusedData );
- else
- return pressUsedDataIntoRectangularFormat( xChartDoc );
+ return pressUsedDataIntoRectangularFormat( xChartDoc );
}
uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData(
- const uno::Reference< frame::XModel >& xChartModel,
- bool bIncludeUnusedData /* = false */ )
+ const uno::Reference< frame::XModel >& xChartModel )
{
::std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aResult;
@@ -330,14 +325,6 @@ uno::Reference< chart2::data::XDataSource > DataSourceHelper::getUsedData(
::std::back_inserter( aResult ));
}
- if( bIncludeUnusedData && xDiagram.is())
- {
- uno::Sequence< uno::Reference< data::XLabeledDataSequence > > aUnusedData( xDiagram->getUnusedData());
- ::std::copy( aUnusedData.getConstArray(),
- aUnusedData.getConstArray() + aUnusedData.getLength(),
- ::std::back_inserter( aResult ));
- }
-
return uno::Reference< chart2::data::XDataSource >(
new DataSource( ContainerHelper::ContainerToSequence( aResult )));
}
@@ -349,8 +336,7 @@ bool DataSourceHelper::detectRangeSegmentation(
, ::com::sun::star::uno::Sequence< sal_Int32 >& rSequenceMapping
, bool& rOutUseColumns
, bool& rOutFirstCellAsLabel
- , bool& rOutHasCategories
- , bool bIncludeUnusedData /* = false */)
+ , bool& rOutHasCategories )
{
bool bSomethingDetected = false;
@@ -361,9 +347,6 @@ bool DataSourceHelper::detectRangeSegmentation(
if( !xDataProvider.is() )
return bSomethingDetected;
- OSL_ASSERT( !bIncludeUnusedData ); //bIncludeUnusedData is not supported currently
- (void)(bIncludeUnusedData); // avoid warning in non-debug build
-
try
{
DataSourceHelper::readArguments(
@@ -531,6 +514,19 @@ Sequence< OUString > DataSourceHelper::getRangesFromLabeledDataSequence(
return aResult;
}
+OUString DataSourceHelper::getRangeFromValues(
+ const Reference< data::XLabeledDataSequence > & xLSeq )
+{
+ OUString aResult;
+ if( xLSeq.is() )
+ {
+ Reference< data::XDataSequence > xValues( xLSeq->getValues() );
+ if( xValues.is() )
+ aResult = xValues->getSourceRangeRepresentation();
+ }
+ return aResult;
+}
+
Sequence< OUString > DataSourceHelper::getRangesFromDataSource( const Reference< data::XDataSource > & xSource )
{
::std::vector< OUString > aResult;
diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx
index 31ac5f1ae4ec..a8da65e5133d 100644
--- a/chart2/source/tools/DiagramHelper.cxx
+++ b/chart2/source/tools/DiagramHelper.cxx
@@ -35,7 +35,9 @@
#include "AxisHelper.hxx"
#include "ContainerHelper.hxx"
#include "ChartTypeHelper.hxx"
+#include "ChartModelHelper.hxx"
#include "CommonConverters.hxx"
+#include "ExplicitCategoriesProvider.hxx"
#include "servicenames_charttypes.hxx"
#include <com/sun/star/chart/MissingValueTreatment.hpp>
@@ -955,8 +957,7 @@ Reference< data::XLabeledDataSequence >
return xResult;
}
-//static
-void DiagramHelper::generateAutomaticCategoriesFromChartType(
+void lcl_generateAutomaticCategoriesFromChartType(
Sequence< rtl::OUString >& rRet,
const Reference< XChartType >& xChartType )
{
@@ -986,64 +987,35 @@ void DiagramHelper::generateAutomaticCategoriesFromChartType(
}
}
-//static
-Sequence< rtl::OUString > DiagramHelper::generateAutomaticCategories(
- const Reference< XChartDocument >& xChartDoc )
+Sequence< rtl::OUString > DiagramHelper::generateAutomaticCategoriesFromCooSys( const Reference< XCoordinateSystem > & xCooSys )
{
Sequence< rtl::OUString > aRet;
- if(xChartDoc.is())
+
+ Reference< XChartTypeContainer > xTypeCntr( xCooSys, uno::UNO_QUERY );
+ if( xTypeCntr.is() )
{
- uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram() );
- if(xDia.is())
+ Sequence< Reference< XChartType > > aChartTypes( xTypeCntr->getChartTypes() );
+ for( sal_Int32 nN=0; nN<aChartTypes.getLength(); nN++ )
{
- Reference< data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDia ) );
- if( xCategories.is() )
- aRet = DataSequenceToStringSequence(xCategories->getValues());
- if( !aRet.getLength() )
- {
- /*
- //unused ranges are very problematic as they bear the risk to damage the rectangular structure completly
- if( bUseUnusedDataAlso )
- {
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aUnusedSequences( xDia->getUnusedData() );
- ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aUnusedCategoryVector(
- DataSeriesHelper::getAllDataSequencesByRole( aUnusedSequences, C2U("categories") ) );
- if( aUnusedCategoryVector.size() && aUnusedCategoryVector[0].is() )
- aRet = DataSequenceToStringSequence(aUnusedCategoryVector[0]->getValues());
- }
- */
- if( !aRet.getLength() )
- {
- Reference< XCoordinateSystemContainer > xCooSysCnt( xDia, uno::UNO_QUERY );
- if( xCooSysCnt.is() )
- {
- Sequence< Reference< XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems() );
- if( aCooSysSeq.getLength() )
- aRet = DiagramHelper::generateAutomaticCategories( aCooSysSeq[0] );
- }
- }
- }
+ lcl_generateAutomaticCategoriesFromChartType( aRet, aChartTypes[nN] );
+ if( aRet.getLength() )
+ return aRet;
}
}
return aRet;
}
//static
-Sequence< rtl::OUString > DiagramHelper::generateAutomaticCategories(
- const Reference< XCoordinateSystem > & xCooSys )
+Sequence< rtl::OUString > DiagramHelper::getExplicitSimpleCategories(
+ const Reference< XChartDocument >& xChartDoc )
{
Sequence< rtl::OUString > aRet;
-
- Reference< XChartTypeContainer > xTypeCntr( xCooSys, uno::UNO_QUERY );
- if( xTypeCntr.is() )
+ uno::Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY );
+ if(xChartModel.is())
{
- Sequence< Reference< XChartType > > aChartTypes( xTypeCntr->getChartTypes() );
- for( sal_Int32 nN=0; nN<aChartTypes.getLength(); nN++ )
- {
- DiagramHelper::generateAutomaticCategoriesFromChartType( aRet, aChartTypes[nN] );
- if( aRet.getLength() )
- return aRet;
- }
+ uno::Reference< chart2::XCoordinateSystem > xCooSys( ChartModelHelper::getFirstCoordinateSystem( xChartModel ) );
+ ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, xChartModel );
+ aRet = aExplicitCategoriesProvider.getSimpleCategories();
}
return aRet;
}
diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx
index cd4b0334f117..bd1c1bb79813 100644
--- a/chart2/source/tools/ExplicitCategoriesProvider.cxx
+++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx
@@ -31,6 +31,10 @@
#include "ExplicitCategoriesProvider.hxx"
#include "DiagramHelper.hxx"
#include "CommonConverters.hxx"
+#include "DataSourceHelper.hxx"
+#include "ChartModelHelper.hxx"
+#include "ContainerHelper.hxx"
+#include "macros.hxx"
//.............................................................................
namespace chart
@@ -41,18 +45,88 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
-using rtl::OUString;
+using ::rtl::OUString;
+using ::std::vector;
-ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2::XCoordinateSystem >& xCooSysModel )
+
+ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2::XCoordinateSystem >& xCooSysModel
+ , const uno::Reference< frame::XModel >& xChartModel )
: m_bDirty(true)
, m_xCooSysModel( xCooSysModel )
- , m_xCategories()
+ , m_xOriginalCategories()
{
- if( xCooSysModel.is() )
+ try
+ {
+ if( xCooSysModel.is() )
+ {
+ uno::Reference< XAxis > xAxis( xCooSysModel->getAxisByDimension(0,0) );
+ if( xAxis.is() )
+ m_xOriginalCategories = xAxis->getScaleData().Categories;
+ }
+
+ if( m_xOriginalCategories.is() )
+ {
+ Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY );
+ if( xChartDoc.is() )
+ {
+ uno::Reference< data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
+
+ if( xDataProvider.is() )
+ {
+ OUString aCatgoriesRange( DataSourceHelper::getRangeFromValues( m_xOriginalCategories ) );
+ const bool bFirstCellAsLabel = false;
+ const bool bHasCategories = false;
+ const uno::Sequence< sal_Int32 > aSequenceMapping;
+
+ uno::Reference< data::XDataSource > xColumnCategoriesSource( xDataProvider->createDataSource(
+ DataSourceHelper::createArguments( aCatgoriesRange, aSequenceMapping, true /*bUseColumns*/
+ , bFirstCellAsLabel, bHasCategories ) ) );
+
+ uno::Reference< data::XDataSource > xRowCategoriesSource( xDataProvider->createDataSource(
+ DataSourceHelper::createArguments( aCatgoriesRange, aSequenceMapping, false /*bUseColumns*/
+ , bFirstCellAsLabel, bHasCategories ) ) );
+
+ if( xColumnCategoriesSource.is() && xRowCategoriesSource.is() )
+ {
+ Sequence< Reference< data::XLabeledDataSequence> > aColumns = xColumnCategoriesSource->getDataSequences();
+ Sequence< Reference< data::XLabeledDataSequence> > aRows = xRowCategoriesSource->getDataSequences();
+
+ sal_Int32 nColumnCount = aColumns.getLength();
+ sal_Int32 nRowCount = aRows.getLength();
+ if( nColumnCount>1 && nRowCount>1 )
+ {
+ //we have complex categories
+ //->split them in the direction of the first series
+ //detect whether the first series is a row or a column
+ bool bSeriesUsesColumns = true;
+ ::std::vector< Reference< XDataSeries > > aSeries( ChartModelHelper::getDataSeries( xChartModel ) );
+ if( !aSeries.empty() )
+ {
+ uno::Reference< data::XDataSource > xSeriesSource( aSeries.front(), uno::UNO_QUERY );
+ ::rtl::OUString aStringDummy;
+ bool bDummy;
+ uno::Sequence< sal_Int32 > aSeqDummy;
+ DataSourceHelper::readArguments( xDataProvider->detectArguments( xSeriesSource),
+ aStringDummy, aSeqDummy, bSeriesUsesColumns, bDummy, bDummy );
+ }
+ if( bSeriesUsesColumns )
+ m_aSplitCategoriesList=aColumns;
+ else
+ m_aSplitCategoriesList=aRows;
+ }
+ }
+ }
+ }
+ if( !m_aSplitCategoriesList.getLength() )
+ {
+ m_aSplitCategoriesList.realloc(1);
+ m_aSplitCategoriesList[0]=m_xOriginalCategories;
+ }
+ }
+ }
+ catch( const uno::Exception & ex )
{
- uno::Reference< XAxis > xAxis( xCooSysModel->getAxisByDimension(0,0) );
- if( xAxis.is() )
- m_xCategories = xAxis->getScaleData().Categories;
+ ASSERT_EXCEPTION( ex );
}
}
@@ -60,34 +134,285 @@ ExplicitCategoriesProvider::~ExplicitCategoriesProvider()
{
}
-//XTextualDataSequence
-Sequence< ::rtl::OUString > SAL_CALL ExplicitCategoriesProvider::getTextualData() throw( uno::RuntimeException)
+const Sequence< Reference< data::XLabeledDataSequence> >& ExplicitCategoriesProvider::getSplitCategoriesList()
+{
+ return m_aSplitCategoriesList;
+}
+
+bool ExplicitCategoriesProvider::hasComplexCategories() const
+{
+ return m_aSplitCategoriesList.getLength() > 1;
+}
+
+sal_Int32 ExplicitCategoriesProvider::getCategoryLevelCount() const
+{
+ sal_Int32 nCount = m_aSplitCategoriesList.getLength();
+ if(!nCount)
+ nCount = 1;
+ return nCount;
+}
+
+std::vector<sal_Int32> lcl_getLimitingBorders( const std::vector< ComplexCategory >& rComplexCategories )
+{
+ std::vector<sal_Int32> aLimitingBorders;
+ std::vector< ComplexCategory >::const_iterator aIt( rComplexCategories.begin() );
+ std::vector< ComplexCategory >::const_iterator aEnd( rComplexCategories.end() );
+ sal_Int32 nBorderIndex = 0; /*border below the index*/
+ for( ; aIt != aEnd; ++aIt )
+ {
+ ComplexCategory aComplexCategory(*aIt);
+ nBorderIndex += aComplexCategory.Count;
+ aLimitingBorders.push_back(nBorderIndex);
+ }
+ return aLimitingBorders;
+}
+
+uno::Sequence< rtl::OUString > lcl_DataToStringSequence( const uno::Reference< data::XDataSequence >& xDataSequence )
+{
+ uno::Sequence< rtl::OUString > aStrings;
+
+ OSL_ASSERT( xDataSequence.is());
+ if( !xDataSequence.is() )
+ return aStrings;
+
+
+ uno::Reference< data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY );
+ if( xTextualDataSequence.is() )
+ {
+ aStrings = xTextualDataSequence->getTextualData();
+ }
+ else
+ {
+ uno::Sequence< uno::Any > aValues = xDataSequence->getData();
+ aStrings.realloc(aValues.getLength());
+
+ for(sal_Int32 nN=aValues.getLength();nN--;)
+ aValues[nN] >>= aStrings[nN];
+ }
+
+ return aStrings;
+}
+
+SplitCategoriesProvider::~SplitCategoriesProvider()
+{
+}
+
+class SplitCategoriesProvider_ForLabeledDataSequences : public SplitCategoriesProvider
+{
+public:
+
+ explicit SplitCategoriesProvider_ForLabeledDataSequences( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XLabeledDataSequence> >& rSplitCategoriesList )
+ : m_rSplitCategoriesList( rSplitCategoriesList )
+ {}
+ virtual ~SplitCategoriesProvider_ForLabeledDataSequences()
+ {}
+
+ virtual sal_Int32 getLevelCount() const;
+ virtual uno::Sequence< rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const;
+
+private:
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
+ ::com::sun::star::chart2::data::XLabeledDataSequence> >& m_rSplitCategoriesList;
+};
+
+sal_Int32 SplitCategoriesProvider_ForLabeledDataSequences::getLevelCount() const
+{
+ return m_rSplitCategoriesList.getLength();
+}
+uno::Sequence< rtl::OUString > SplitCategoriesProvider_ForLabeledDataSequences::getStringsForLevel( sal_Int32 nLevel ) const
+{
+ uno::Sequence< rtl::OUString > aRet;
+ Reference< data::XLabeledDataSequence > xLabeledDataSequence( m_rSplitCategoriesList[nLevel] );
+ if( xLabeledDataSequence.is() )
+ aRet = lcl_DataToStringSequence( xLabeledDataSequence->getValues() );
+ return aRet;
+}
+
+std::vector< ComplexCategory > lcl_DataSequenceToComplexCategoryVector(
+ const uno::Sequence< rtl::OUString >& rStrings
+ , const std::vector<sal_Int32>& rLimitingBorders, bool bCreateSingleCategories )
+{
+ std::vector< ComplexCategory > aResult;
+
+ sal_Int32 nMaxCount = rStrings.getLength();
+ OUString aPrevious;
+ sal_Int32 nCurrentCount=0;
+ for( sal_Int32 nN=0; nN<nMaxCount; nN++ )
+ {
+ OUString aCurrent = rStrings[nN];
+ if( bCreateSingleCategories || ::std::find( rLimitingBorders.begin(), rLimitingBorders.end(), nN ) != rLimitingBorders.end() )
+ {
+ aResult.push_back( ComplexCategory(aPrevious,nCurrentCount) );
+ nCurrentCount=1;
+ aPrevious = aCurrent;
+ }
+ else
+ {
+ if( aCurrent.getLength() && aPrevious != aCurrent )
+ {
+ aResult.push_back( ComplexCategory(aPrevious,nCurrentCount) );
+ nCurrentCount=1;
+ aPrevious = aCurrent;
+ }
+ else
+ nCurrentCount++;
+ }
+ }
+ if( nCurrentCount )
+ aResult.push_back( ComplexCategory(aPrevious,nCurrentCount) );
+
+ return aResult;
+}
+
+sal_Int32 lcl_getCategoryCount( std::vector< ComplexCategory >& rComplexCategories )
+{
+ sal_Int32 nCount = 0;
+ std::vector< ComplexCategory >::iterator aIt( rComplexCategories.begin() );
+ std::vector< ComplexCategory >::const_iterator aEnd( rComplexCategories.end() );
+ for( ; aIt != aEnd; ++aIt )
+ nCount+=aIt->Count;
+ return nCount;
+}
+
+Sequence< OUString > lcl_getExplicitSimpleCategories(
+ const SplitCategoriesProvider& rSplitCategoriesProvider,
+ ::std::vector< ::std::vector< ComplexCategory > >& rComplexCats )
+{
+ Sequence< OUString > aRet;
+
+ rComplexCats.clear();
+ sal_Int32 nLCount = rSplitCategoriesProvider.getLevelCount();
+ for( sal_Int32 nL = 0; nL < nLCount; nL++ )
+ {
+ std::vector<sal_Int32> aLimitingBorders;
+ if(nL>0)
+ aLimitingBorders = lcl_getLimitingBorders( rComplexCats.back() );
+ rComplexCats.push_back( lcl_DataSequenceToComplexCategoryVector(
+ rSplitCategoriesProvider.getStringsForLevel(nL), aLimitingBorders, nL==(nLCount-1) ) );
+ }
+
+ std::vector< std::vector< ComplexCategory > >::iterator aOuterIt( rComplexCats.begin() );
+ std::vector< std::vector< ComplexCategory > >::const_iterator aOuterEnd( rComplexCats.end() );
+
+ //ensure that the category count is the same on each level
+ sal_Int32 nMaxCategoryCount = 0;
+ {
+ for( aOuterIt=rComplexCats.begin(); aOuterIt != aOuterEnd; ++aOuterIt )
+ {
+ sal_Int32 nCurrentCount = lcl_getCategoryCount( *aOuterIt );
+ nMaxCategoryCount = std::max( nCurrentCount, nMaxCategoryCount );
+ }
+ for( aOuterIt=rComplexCats.begin(); aOuterIt != aOuterEnd; ++aOuterIt )
+ {
+ sal_Int32 nCurrentCount = lcl_getCategoryCount( *aOuterIt );
+ if( nCurrentCount< nMaxCategoryCount )
+ {
+ ComplexCategory& rComplexCategory = aOuterIt->back();
+ rComplexCategory.Count += (nMaxCategoryCount-nCurrentCount);
+ }
+ }
+ }
+
+ //create a list with an element for every index
+ std::vector< std::vector< ComplexCategory > > aComplexCatsPerIndex;
+ for( aOuterIt=rComplexCats.begin() ; aOuterIt != aOuterEnd; ++aOuterIt )
+ {
+ std::vector< ComplexCategory > aSingleLevel;
+ std::vector< ComplexCategory >::iterator aIt( aOuterIt->begin() );
+ std::vector< ComplexCategory >::const_iterator aEnd( aOuterIt->end() );
+ for( ; aIt != aEnd; ++aIt )
+ {
+ ComplexCategory aComplexCategory( *aIt );
+ sal_Int32 nCount = aComplexCategory.Count;
+ while( nCount-- )
+ aSingleLevel.push_back(aComplexCategory);
+ }
+ aComplexCatsPerIndex.push_back( aSingleLevel );
+ }
+
+ if(nMaxCategoryCount)
+ {
+ aRet.realloc(nMaxCategoryCount);
+ aOuterEnd = aComplexCatsPerIndex.end();
+ OUString aSpace(C2U(" "));
+ for(sal_Int32 nN=0; nN<nMaxCategoryCount; nN++)
+ {
+ OUString aText;
+ for( aOuterIt=aComplexCatsPerIndex.begin() ; aOuterIt != aOuterEnd; ++aOuterIt )
+ {
+ OUString aAddText = (*aOuterIt)[nN].Text;
+ if( aAddText.getLength() )
+ {
+ if(aText.getLength())
+ aText += aSpace;
+ aText += aAddText;
+ }
+ }
+ aRet[nN]=aText;
+ }
+ }
+ return aRet;
+}
+
+//static
+Sequence< OUString > ExplicitCategoriesProvider::getExplicitSimpleCategories(
+ const SplitCategoriesProvider& rSplitCategoriesProvider )
+{
+ vector< vector< ComplexCategory > > aComplexCats;
+ return lcl_getExplicitSimpleCategories( rSplitCategoriesProvider, aComplexCats );
+}
+
+void ExplicitCategoriesProvider::init()
{
if( m_bDirty )
{
- if( m_xCategories.is() )
- m_aExplicitCategories = DataSequenceToStringSequence(m_xCategories->getValues());
+ m_aExplicitCategories.realloc(0);
+ m_aComplexCats.clear();//not one per index
+
+ if( m_xOriginalCategories.is() )
+ {
+ if( !hasComplexCategories() )
+ m_aExplicitCategories = DataSequenceToStringSequence(m_xOriginalCategories->getValues());
+ else
+ m_aExplicitCategories = lcl_getExplicitSimpleCategories(
+ SplitCategoriesProvider_ForLabeledDataSequences( m_aSplitCategoriesList ), m_aComplexCats );
+ }
if(!m_aExplicitCategories.getLength())
- m_aExplicitCategories = DiagramHelper::generateAutomaticCategories( uno::Reference< chart2::XCoordinateSystem >( m_xCooSysModel.get(), uno::UNO_QUERY ) );
+ m_aExplicitCategories = DiagramHelper::generateAutomaticCategoriesFromCooSys( m_xCooSysModel );
m_bDirty = false;
}
+}
+
+
+Sequence< ::rtl::OUString > ExplicitCategoriesProvider::getSimpleCategories()
+{
+ init();
return m_aExplicitCategories;
}
+std::vector< ComplexCategory > ExplicitCategoriesProvider::getCategoriesByLevel( sal_Int32 nLevel )
+{
+ std::vector< ComplexCategory > aRet;
+ init();
+ sal_Int32 nMaxIndex = m_aComplexCats.size()-1;
+ if( nLevel >= 0 && nLevel <= nMaxIndex )
+ aRet = m_aComplexCats[nMaxIndex-nLevel];
+ return aRet;
+}
+
// static
OUString ExplicitCategoriesProvider::getCategoryByIndex(
- const Reference< XCoordinateSystem >& xCooSysModel,
- sal_Int32 nIndex )
+ const Reference< XCoordinateSystem >& xCooSysModel
+ , const uno::Reference< frame::XModel >& xChartModel
+ , sal_Int32 nIndex )
{
if( xCooSysModel.is())
{
- Reference< XTextualDataSequence > xTemp( new ExplicitCategoriesProvider( xCooSysModel ));
- if( xTemp.is())
- {
- Sequence< OUString > aCategories( xTemp->getTextualData());
- if( nIndex < aCategories.getLength())
- return aCategories[ nIndex ];
- }
+ ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSysModel, xChartModel );
+ Sequence< OUString > aCategories( aExplicitCategoriesProvider.getSimpleCategories());
+ if( nIndex < aCategories.getLength())
+ return aCategories[ nIndex ];
}
return OUString();
}
diff --git a/chart2/source/tools/InternalData.cxx b/chart2/source/tools/InternalData.cxx
new file mode 100755
index 000000000000..65fc97a04b38
--- /dev/null
+++ b/chart2/source/tools/InternalData.cxx
@@ -0,0 +1,530 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_chart2.hxx"
+
+#include "InternalData.hxx"
+#include "ResId.hxx"
+#include "Strings.hrc"
+#include "macros.hxx"
+
+#include <rtl/math.hxx>
+
+using ::com::sun::star::uno::Sequence;
+using ::rtl::OUString;
+
+using namespace ::std;
+
+namespace chart
+{
+
+// ----------------------------------------
+namespace
+{
+struct lcl_NumberedStringGenerator
+{
+ lcl_NumberedStringGenerator( const OUString & rStub, const OUString & rWildcard ) :
+ m_aStub( rStub ),
+ m_nCounter( 0 ),
+ m_nStubStartIndex( rStub.indexOf( rWildcard )),
+ m_nWildcardLength( rWildcard.getLength())
+ {
+ }
+ vector< OUString > operator()()
+ {
+ vector< OUString > aRet(1);
+ aRet[0] = m_aStub.replaceAt( m_nStubStartIndex, m_nWildcardLength, OUString::valueOf( ++m_nCounter ));
+ return aRet;
+ }
+private:
+ OUString m_aStub;
+ sal_Int32 m_nCounter;
+ const sal_Int32 m_nStubStartIndex;
+ const sal_Int32 m_nWildcardLength;
+};
+
+template< typename T >
+ Sequence< T > lcl_ValarrayToSequence( const ::std::valarray< T > & rValarray )
+{
+ // is there a more elegant way of conversion?
+ Sequence< T > aResult( rValarray.size());
+ for( size_t i = 0; i < rValarray.size(); ++i )
+ aResult[i] = rValarray[i];
+ return aResult;
+}
+
+} // anonymous namespace
+// ----------------------------------------
+
+InternalData::InternalData()
+ : m_nColumnCount( 0 )
+ , m_nRowCount( 0 )
+ , m_aRowLabels( 0 )
+ , m_aColumnLabels( 0 )
+{}
+
+void InternalData::createDefaultData()
+{
+ const sal_Int32 nRowCount = 4;
+ const sal_Int32 nColumnCount = 3;
+
+ m_nRowCount = nRowCount;
+ m_nColumnCount = nColumnCount;
+ const sal_Int32 nSize = nColumnCount * nRowCount;
+ // @todo: localize this!
+ const OUString aRowName( ::chart::SchResId::getResString( STR_ROW_LABEL ));
+ const OUString aColName( ::chart::SchResId::getResString( STR_COLUMN_LABEL ));
+
+ const double fDefaultData[ nSize ] =
+ { 9.10, 3.20, 4.54,
+ 2.40, 8.80, 9.65,
+ 3.10, 1.50, 3.70,
+ 4.30, 9.02, 6.20 };
+
+ m_aData.resize( nSize );
+ for( sal_Int32 i=0; i<nSize; ++i )
+ m_aData[i] = fDefaultData[i];
+
+ m_aRowLabels.clear();
+ m_aRowLabels.reserve( m_nRowCount );
+ generate_n( back_inserter( m_aRowLabels ), m_nRowCount,
+ lcl_NumberedStringGenerator( aRowName, C2U("%ROWNUMBER") ));
+
+ m_aColumnLabels.clear();
+ m_aColumnLabels.reserve( m_nColumnCount );
+ generate_n( back_inserter( m_aColumnLabels ), m_nColumnCount,
+ lcl_NumberedStringGenerator( aColName, C2U("%COLUMNNUMBER") ));
+}
+
+void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows )
+{
+ m_nRowCount = rDataInRows.getLength();
+ m_nColumnCount = (m_nRowCount ? rDataInRows[0].getLength() : 0);
+
+ if( m_aRowLabels.size() != static_cast< sal_uInt32 >( m_nRowCount ))
+ m_aRowLabels.resize( m_nRowCount );
+ if( m_aColumnLabels.size() != static_cast< sal_uInt32 >( m_nColumnCount ))
+ m_aColumnLabels.resize( m_nColumnCount );
+
+ m_aData.resize( m_nRowCount * m_nColumnCount );
+ double fNan;
+ ::rtl::math::setNan( & fNan );
+ // set all values to Nan
+ m_aData = fNan;
+
+ for( sal_Int32 nRow=0; nRow<m_nRowCount; ++nRow )
+ {
+ int nDataIdx = nRow*m_nColumnCount;
+ const sal_Int32 nMax = ::std::min( rDataInRows[nRow].getLength(), m_nColumnCount );
+ for( sal_Int32 nCol=0; nCol < nMax; ++nCol )
+ {
+ m_aData[nDataIdx] = rDataInRows[nRow][nCol];
+ nDataIdx += 1;
+ }
+ }
+}
+
+Sequence< Sequence< double > > InternalData::getData() const
+{
+ Sequence< Sequence< double > > aResult( m_nRowCount );
+
+ for( sal_Int32 i=0; i<m_nRowCount; ++i )
+ aResult[i] = lcl_ValarrayToSequence< tDataType::value_type >(
+ m_aData[ ::std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
+
+ return aResult;
+}
+
+Sequence< double > InternalData::getColumnValues( sal_Int32 nColumnIndex ) const
+{
+ if( nColumnIndex >= 0 && nColumnIndex < m_nColumnCount )
+ return lcl_ValarrayToSequence< tDataType::value_type >(
+ m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ] );
+ return Sequence< double >();
+}
+Sequence< double > InternalData::getRowValues( sal_Int32 nRowIndex ) const
+{
+ if( nRowIndex >= 0 && nRowIndex < m_nRowCount )
+ return lcl_ValarrayToSequence< tDataType::value_type >(
+ m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ] );
+ return Sequence< double >();
+}
+
+void InternalData::setColumnValues( sal_Int32 nColumnIndex, const vector< double > & rNewData )
+{
+ if( nColumnIndex < 0 )
+ return;
+ enlargeData( nColumnIndex + 1, rNewData.size() );
+
+ tDataType aSlice = m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ];
+ for( vector< double >::size_type i = 0; i < rNewData.size(); ++i )
+ aSlice[i] = rNewData[i];
+ m_aData[ ::std::slice( nColumnIndex, m_nRowCount, m_nColumnCount ) ] = aSlice;
+}
+
+void InternalData::setRowValues( sal_Int32 nRowIndex, const vector< double > & rNewData )
+{
+ if( nRowIndex < 0 )
+ return;
+ enlargeData( rNewData.size(), nRowIndex+1 );
+
+ tDataType aSlice = m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ];
+ for( vector< double >::size_type i = 0; i < rNewData.size(); ++i )
+ aSlice[i] = rNewData[i];
+ m_aData[ ::std::slice( nRowIndex*m_nColumnCount, m_nColumnCount, 1 ) ]= aSlice;
+}
+
+void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, const vector< OUString >& rComplexLabel )
+{
+ if( nColumnIndex < 0 )
+ return;
+ if( nColumnIndex >= static_cast< sal_Int32 >( m_aColumnLabels.size() ) )
+ {
+ m_aColumnLabels.resize(nColumnIndex+1);
+ enlargeData( nColumnIndex+1, 0 );
+ }
+
+ m_aColumnLabels[nColumnIndex]=rComplexLabel;
+}
+void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< OUString >& rComplexLabel )
+{
+ if( nRowIndex < 0 )
+ return;
+ if( nRowIndex >= static_cast< sal_Int32 >( m_aRowLabels.size() ) )
+ {
+ m_aRowLabels.resize(nRowIndex+1);
+ enlargeData( 0, nRowIndex+1 );
+ }
+
+ m_aRowLabels[nRowIndex] = rComplexLabel;
+}
+
+vector< OUString > InternalData::getComplexColumnLabel( sal_Int32 nColumnIndex ) const
+{
+ if( nColumnIndex < static_cast< sal_Int32 >( m_aColumnLabels.size() ) )
+ return m_aColumnLabels[nColumnIndex];
+ else
+ return vector< OUString >();
+}
+vector< OUString > InternalData::getComplexRowLabel( sal_Int32 nRowIndex ) const
+{
+ if( nRowIndex < static_cast< sal_Int32 >( m_aRowLabels.size() ) )
+ return m_aRowLabels[nRowIndex];
+ else
+ return vector< OUString >();
+}
+
+void InternalData::swapRowWithNext( sal_Int32 nRowIndex )
+{
+ if( nRowIndex < m_nRowCount - 1 )
+ {
+ const sal_Int32 nMax = m_nColumnCount;
+ for( sal_Int32 nColIdx=0; nColIdx<nMax; ++nColIdx )
+ {
+ size_t nIndex1 = nColIdx + nRowIndex*m_nColumnCount;
+ size_t nIndex2 = nIndex1 + m_nColumnCount;
+ double fTemp = m_aData[nIndex1];
+ m_aData[nIndex1] = m_aData[nIndex2];
+ m_aData[nIndex2] = fTemp;
+ }
+
+ vector< OUString > aTemp( m_aRowLabels[nRowIndex] );
+ m_aRowLabels[nRowIndex] = m_aRowLabels[nRowIndex + 1];
+ m_aRowLabels[nRowIndex + 1] = aTemp;
+ }
+}
+
+void InternalData::swapColumnWithNext( sal_Int32 nColumnIndex )
+{
+ if( nColumnIndex < m_nColumnCount - 1 )
+ {
+ const sal_Int32 nMax = m_nRowCount;
+ for( sal_Int32 nRowIdx=0; nRowIdx<nMax; ++nRowIdx )
+ {
+ size_t nIndex1 = nColumnIndex + nRowIdx*m_nColumnCount;
+ size_t nIndex2 = nIndex1 + 1;
+ double fTemp = m_aData[nIndex1];
+ m_aData[nIndex1] = m_aData[nIndex2];
+ m_aData[nIndex2] = fTemp;
+ }
+
+ vector< OUString > aTemp( m_aColumnLabels[nColumnIndex] );
+ m_aColumnLabels[nColumnIndex] = m_aColumnLabels[nColumnIndex + 1];
+ m_aColumnLabels[nColumnIndex + 1] = aTemp;
+ }
+}
+
+bool InternalData::enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount )
+{
+ sal_Int32 nNewColumnCount( ::std::max<sal_Int32>( m_nColumnCount, nColumnCount ) );
+ sal_Int32 nNewRowCount( ::std::max<sal_Int32>( m_nRowCount, nRowCount ) );
+ sal_Int32 nNewSize( nNewColumnCount*nNewRowCount );
+
+ bool bGrow = (nNewSize > m_nColumnCount*m_nRowCount);
+
+ if( bGrow )
+ {
+ double fNan;
+ ::rtl::math::setNan( &fNan );
+ tDataType aNewData( fNan, nNewSize );
+ // copy old data
+ for( int nCol=0; nCol<m_nColumnCount; ++nCol )
+ static_cast< tDataType >(
+ aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] ) =
+ m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ];
+
+ m_aData.resize( nNewSize );
+ m_aData = aNewData;
+ }
+ m_nColumnCount = nNewColumnCount;
+ m_nRowCount = nNewRowCount;
+ return bGrow;
+}
+
+void InternalData::insertColumn( sal_Int32 nAfterIndex )
+{
+ // note: -1 is allowed, as we insert after the given index
+ OSL_ASSERT( nAfterIndex < m_nColumnCount && nAfterIndex >= -1 );
+ if( nAfterIndex >= m_nColumnCount || nAfterIndex < -1 )
+ return;
+ sal_Int32 nNewColumnCount = m_nColumnCount + 1;
+ sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
+
+ double fNan;
+ ::rtl::math::setNan( &fNan );
+ tDataType aNewData( fNan, nNewSize );
+
+ // copy old data
+ int nCol=0;
+ for( ; nCol<=nAfterIndex; ++nCol )
+ aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ] );
+ for( ++nCol; nCol<nNewColumnCount; ++nCol )
+ aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( nCol - 1, m_nRowCount, m_nColumnCount ) ] );
+
+ m_nColumnCount = nNewColumnCount;
+ m_aData.resize( nNewSize );
+ m_aData = aNewData;
+
+ // labels
+ if( nAfterIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
+ m_aColumnLabels.insert( m_aColumnLabels.begin() + (nAfterIndex + 1), vector< OUString >(1) );
+
+#if OSL_DEBUG_LEVEL > 2
+ traceData();
+#endif
+}
+
+sal_Int32 InternalData::appendColumn()
+{
+ insertColumn( getColumnCount() - 1 );
+ return getColumnCount() - 1;
+}
+
+sal_Int32 InternalData::appendRow()
+{
+ insertRow( getRowCount() - 1 );
+ return getRowCount() - 1;
+}
+
+void InternalData::insertRow( sal_Int32 nAfterIndex )
+{
+ // note: -1 is allowed, as we insert after the given index
+ OSL_ASSERT( nAfterIndex < m_nRowCount && nAfterIndex >= -1 );
+ if( nAfterIndex >= m_nRowCount || nAfterIndex < -1 )
+ return;
+ sal_Int32 nNewRowCount = m_nRowCount + 1;
+ sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
+
+ double fNan;
+ ::rtl::math::setNan( &fNan );
+ tDataType aNewData( fNan, nNewSize );
+
+ // copy old data
+ sal_Int32 nIndex = nAfterIndex + 1;
+ aNewData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] );
+
+ if( nIndex < m_nRowCount )
+ {
+ sal_Int32 nRemainingCount = m_nColumnCount * (m_nRowCount - nIndex);
+ aNewData[ ::std::slice( (nIndex + 1) * m_nColumnCount, nRemainingCount, 1 ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( nIndex * m_nColumnCount, nRemainingCount, 1 ) ] );
+ }
+
+ m_nRowCount = nNewRowCount;
+ m_aData.resize( nNewSize );
+ m_aData = aNewData;
+
+ // labels
+ if( nAfterIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
+ m_aRowLabels.insert( m_aRowLabels.begin() + nIndex, vector< OUString> (1));
+
+#if OSL_DEBUG_LEVEL > 2
+ traceData();
+#endif
+}
+
+void InternalData::deleteColumn( sal_Int32 nAtIndex )
+{
+ OSL_ASSERT( nAtIndex < m_nColumnCount && nAtIndex >= 0 );
+ if( nAtIndex >= m_nColumnCount || m_nColumnCount < 1 || nAtIndex < 0 )
+ return;
+ sal_Int32 nNewColumnCount = m_nColumnCount - 1;
+ sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
+
+ double fNan;
+ ::rtl::math::setNan( &fNan );
+ tDataType aNewData( fNan, nNewSize );
+
+ // copy old data
+ int nCol=0;
+ for( ; nCol<nAtIndex; ++nCol )
+ aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ] );
+ for( ; nCol<nNewColumnCount; ++nCol )
+ aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( nCol + 1, m_nRowCount, m_nColumnCount ) ] );
+
+ m_nColumnCount = nNewColumnCount;
+ m_aData.resize( nNewSize );
+ m_aData = aNewData;
+
+ // labels
+ if( nAtIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
+ m_aColumnLabels.erase( m_aColumnLabels.begin() + nAtIndex );
+
+#if OSL_DEBUG_LEVEL > 2
+ traceData();
+#endif
+}
+
+void InternalData::deleteRow( sal_Int32 nAtIndex )
+{
+ OSL_ASSERT( nAtIndex < m_nRowCount && nAtIndex >= 0 );
+ if( nAtIndex >= m_nRowCount || m_nRowCount < 1 || nAtIndex < 0 )
+ return;
+ sal_Int32 nNewRowCount = m_nRowCount - 1;
+ sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
+
+ double fNan;
+ ::rtl::math::setNan( &fNan );
+ tDataType aNewData( fNan, nNewSize );
+
+ // copy old data
+ sal_Int32 nIndex = nAtIndex;
+ if( nIndex )
+ aNewData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] );
+
+ if( nIndex < nNewRowCount )
+ {
+ sal_Int32 nRemainingCount = m_nColumnCount * (nNewRowCount - nIndex);
+ aNewData[ ::std::slice( nIndex * m_nColumnCount, nRemainingCount, 1 ) ] =
+ static_cast< tDataType >(
+ m_aData[ ::std::slice( (nIndex + 1) * m_nColumnCount, nRemainingCount, 1 ) ] );
+ }
+
+ m_nRowCount = nNewRowCount;
+ m_aData.resize( nNewSize );
+ m_aData = aNewData;
+
+ // labels
+ if( nAtIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
+ m_aRowLabels.erase( m_aRowLabels.begin() + nAtIndex );
+
+#if OSL_DEBUG_LEVEL > 2
+ traceData();
+#endif
+}
+
+sal_Int32 InternalData::getRowCount() const
+{
+ return m_nRowCount;
+}
+
+sal_Int32 InternalData::getColumnCount() const
+{
+ return m_nColumnCount;
+}
+
+void InternalData::setComplexRowLabels( const vector< vector< OUString > >& rNewRowLabels )
+{
+ m_aRowLabels = rNewRowLabels;
+ sal_Int32 nNewRowCount = static_cast< sal_Int32 >( m_aRowLabels.size() );
+ if( nNewRowCount < m_nRowCount )
+ m_aRowLabels.resize( m_nRowCount );
+ else
+ enlargeData( 0, nNewRowCount );
+}
+
+vector< vector< OUString > > InternalData::getComplexRowLabels() const
+{
+ return m_aRowLabels;
+}
+
+void InternalData::setComplexColumnLabels( const vector< vector< OUString > >& rNewColumnLabels )
+{
+ m_aColumnLabels = rNewColumnLabels;
+ sal_Int32 nNewColumnCount = static_cast< sal_Int32 >( m_aColumnLabels.size() );
+ if( nNewColumnCount < m_nColumnCount )
+ m_aColumnLabels.resize( m_nColumnCount );
+ else
+ enlargeData( nNewColumnCount, 0 );
+}
+
+vector< vector< OUString > > InternalData::getComplexColumnLabels() const
+{
+ return m_aColumnLabels;
+}
+
+#if OSL_DEBUG_LEVEL > 2
+void InternalData::traceData() const
+{
+ OSL_TRACE( "InternalData: Data in rows\n" );
+
+ for( sal_Int32 i=0; i<m_nRowCount; ++i )
+ {
+ tDataType aSlice( m_aData[ ::std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
+ for( sal_Int32 j=0; j<m_nColumnCount; ++j )
+ OSL_TRACE( "%lf ", aSlice[j] );
+ OSL_TRACE( "\n" );
+ }
+ OSL_TRACE( "\n" );
+}
+#endif
+
+} // namespace chart
diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx
index 70215623840d..4abc51be31af 100644
--- a/chart2/source/tools/InternalDataProvider.cxx
+++ b/chart2/source/tools/InternalDataProvider.cxx
@@ -45,8 +45,8 @@
#include "DataSourceHelper.hxx"
#include "ChartModelHelper.hxx"
#include "DiagramHelper.hxx"
-#include "ResId.hxx"
-#include "Strings.hrc"
+#include "ExplicitCategoriesProvider.hxx"
+
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/data/XDataSequence.hpp>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
@@ -67,774 +67,327 @@ using ::rtl::OUStringBuffer;
namespace chart
{
-namespace impl
-{
-
-
-struct OUStringBufferAppend : public unary_function< OUString, void >
-{
- OUStringBufferAppend( OUStringBuffer & rBuffer, const OUString & rSeparator ) :
- m_rBuffer( rBuffer ),
- m_aSep( rSeparator )
- {}
- void operator() ( const OUString & rStr )
- {
- m_rBuffer.append( m_aSep );
- m_rBuffer.append( rStr );
- }
-private:
- OUStringBuffer m_rBuffer;
- OUString m_aSep;
-};
-
-OUString FlattenStringSequence( const Sequence< OUString > & aSeq )
-{
- if( aSeq.getLength() == 0 )
- return OUString();
- OUStringBuffer aBuf( aSeq[0] );
- for_each( aSeq.getConstArray() + 1, aSeq.getConstArray() + aSeq.getLength(),
- OUStringBufferAppend( aBuf, OUString(RTL_CONSTASCII_USTRINGPARAM(" "))));
- return aBuf.makeStringAndClear();
-}
-
-class InternalData
-{
-public:
- InternalData();
-
- void createDefaultData();
-
- void setData( const Sequence< Sequence< double > > & rNewData, bool bDataInColumns );
- Sequence< Sequence< double > > getData( bool bDataInColumns ) const;
- Sequence< double > getDataAt( sal_Int32 nIndex, bool bDataInColumns ) const;
- void setDataAt( sal_Int32 nIndex, bool bDataInColumns, const ::std::vector< double > & rNewData );
- void swapAllDataAtIndexWithNext( sal_Int32 nAtIndex, bool bDataInColumns );
-
- /** resizes the data if at least one of the given dimensions is larger than
- before. The data is never becoming smaller only larger.
-
- @return </TRUE>, if the data was enlarged
- */
- bool enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount );
-
- void insertColumn( sal_Int32 nAfterIndex );
- void insertRow( sal_Int32 nAfterIndex );
- void deleteColumn( sal_Int32 nAtIndex );
- void deleteRow( sal_Int32 nAtIndex );
-
- /// @return the index of the newly appended column
- sal_Int32 appendColumn();
- /// @return the index of the newly appended row
- sal_Int32 appendRow();
-
- sal_Int32 getRowCount() const;
- sal_Int32 getColumnCount() const;
-
- void setRowLabels( const ::std::vector< OUString > & rNewRowLabels );
- ::std::vector< OUString > getRowLabels() const;
- void setColumnLabels( const ::std::vector< OUString > & rNewColumnLabels );
- ::std::vector< OUString > getColumnLabels() const;
-
-#if OSL_DEBUG_LEVEL > 2
- void traceData() const;
-#endif
-private:
- sal_Int32 m_nColumnCount;
- sal_Int32 m_nRowCount;
-
- typedef ::std::valarray< double > tDataType;
- typedef ::std::vector< OUString > tLabelType;
-
- tDataType m_aData;
- tLabelType m_aRowLabels;
- tLabelType m_aColumnLabels;
-};
+// ================================================================================
-// ----------------------------------------
namespace
{
-struct lcl_NumberedStringGenerator
-{
- lcl_NumberedStringGenerator( const OUString & rStub, const OUString & rWildcard ) :
- m_aStub( rStub ),
- m_nCounter( 0 ),
- m_nStubStartIndex( rStub.indexOf( rWildcard )),
- m_nWildcardLength( rWildcard.getLength())
- {
- }
- OUString operator()() {
- return m_aStub.replaceAt( m_nStubStartIndex, m_nWildcardLength, OUString::valueOf( ++m_nCounter ));
- }
-private:
- OUString m_aStub;
- sal_Int32 m_nCounter;
- const sal_Int32 m_nStubStartIndex;
- const sal_Int32 m_nWildcardLength;
-};
-
-template< typename T >
- Sequence< T > lcl_ValarrayToSequence( const ::std::valarray< T > & rValarray )
-{
- // is there a more elegant way of conversion?
- Sequence< T > aResult( rValarray.size());
- for( size_t i = 0; i < rValarray.size(); ++i )
- aResult[i] = rValarray[i];
- return aResult;
-}
-
-struct lcl_ValuesOfLabeledSequence :
- public unary_function< Reference< chart2::data::XLabeledDataSequence >, Sequence< double > >
-{
- Sequence< double > operator() ( const Reference< chart2::data::XLabeledDataSequence > & xLSeq )
- {
- if( ! xLSeq.is())
- return Sequence< double >();
- return DataSequenceToDoubleSequence( xLSeq->getValues());
- }
-};
-
-struct lcl_LabelsOfLabeledSequence :
- public unary_function< Reference< chart2::data::XLabeledDataSequence >, Sequence< OUString > >
-{
- Sequence< OUString > operator() ( const Reference< chart2::data::XLabeledDataSequence > & xLSeq )
- {
- if( ! xLSeq.is())
- return Sequence< OUString >();
- return DataSequenceToStringSequence( xLSeq->getLabel());
- }
-};
-
-struct lcl_LabelOfLabeledSequence :
- public unary_function< Reference< chart2::data::XLabeledDataSequence >, OUString >
-{
- OUString operator() ( const Reference< chart2::data::XLabeledDataSequence > & xLSeq )
- {
- if( ! xLSeq.is())
- return OUString();
- return FlattenStringSequence( DataSequenceToStringSequence( xLSeq->getLabel()));
- }
-};
-} // anonymous namespace
-// ----------------------------------------
+// note: in xmloff this name is used to indicate usage of own data
+static const ::rtl::OUString lcl_aServiceName(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.InternalDataProvider" ));
-InternalData::InternalData() :
- m_nColumnCount( 0 ),
- m_nRowCount( 0 )
-{}
+static const ::rtl::OUString lcl_aCategoriesRangeName(
+ RTL_CONSTASCII_USTRINGPARAM( "categories" ));
+static const ::rtl::OUString lcl_aCategoriesLevelRangeNamePrefix(
+ RTL_CONSTASCII_USTRINGPARAM( "categoriesL " )); //L <-> level
+static const ::rtl::OUString lcl_aCategoriesPointRangeNamePrefix(
+ RTL_CONSTASCII_USTRINGPARAM( "categoriesP " )); //P <-> point
+static const ::rtl::OUString lcl_aCategoriesRoleName(
+ RTL_CONSTASCII_USTRINGPARAM( "categories" ));
+static const ::rtl::OUString lcl_aLabelRangePrefix(
+ RTL_CONSTASCII_USTRINGPARAM( "label " ));
+static const ::rtl::OUString lcl_aCompleteRange(
+ RTL_CONSTASCII_USTRINGPARAM( "all" ));
-void InternalData::createDefaultData()
-{
- const sal_Int32 nNumRows = 4;
- const sal_Int32 nNumColumns = 3;
- const sal_Int32 nSize = nNumColumns * nNumRows;
- // @todo: localize this!
- const OUString aRowName( ::chart::SchResId::getResString( STR_ROW_LABEL ));
- const OUString aColName( ::chart::SchResId::getResString( STR_COLUMN_LABEL ));
-
- const double fDefaultData[ nSize ] =
- { 9.10, 3.20, 4.54,
- 2.40, 8.80, 9.65,
- 3.10, 1.50, 3.70,
- 4.30, 9.02, 6.20 };
-
- m_aData.resize( nSize );
- for( sal_Int32 i=0; i<nSize; ++i )
- m_aData[i] = fDefaultData[i];
- m_nRowCount = nNumRows;
- m_nColumnCount = nNumColumns;
-
- vector< OUString > aRowLabels;
- aRowLabels.reserve( nNumRows );
- generate_n( back_inserter( aRowLabels ), nNumRows,
- lcl_NumberedStringGenerator( aRowName, C2U("%ROWNUMBER") ));
- setRowLabels( aRowLabels );
-
- vector< OUString > aColumnLabels;
- aColumnLabels.reserve( nNumColumns );
- generate_n( back_inserter( aColumnLabels ), nNumColumns,
- lcl_NumberedStringGenerator( aColName, C2U("%COLUMNNUMBER") ));
- setColumnLabels( aColumnLabels );
-}
+typedef ::std::multimap< OUString, uno::WeakReference< chart2::data::XDataSequence > >
+ lcl_tSequenceMap;
-void InternalData::setData( const Sequence< Sequence< double > > & rNewData, bool bDataInColumns )
+struct lcl_setModified : public ::std::unary_function< lcl_tSequenceMap, void >
{
- sal_Int32 nOuterSize = rNewData.getLength();
- sal_Int32 nInnerSize = (nOuterSize ? rNewData[0].getLength() : 0);
-
- m_nRowCount = (bDataInColumns ? nInnerSize : nOuterSize);
- m_nColumnCount = (bDataInColumns ? nOuterSize : nInnerSize);
-
- if( m_aRowLabels.size() != static_cast< sal_uInt32 >( m_nRowCount ))
- m_aRowLabels.resize( m_nRowCount );
- if( m_aColumnLabels.size() != static_cast< sal_uInt32 >( m_nColumnCount ))
- m_aColumnLabels.resize( m_nColumnCount );
-
- m_aData.resize( m_nRowCount * m_nColumnCount );
- double fNan;
- ::rtl::math::setNan( & fNan );
- // set all values to Nan
- m_aData = fNan;
-
- for( sal_Int32 nOuterIdx=0; nOuterIdx<nOuterSize; ++nOuterIdx )
+ void operator() ( const lcl_tSequenceMap::value_type & rMapEntry )
{
- int nDataIdx = (bDataInColumns ? nOuterIdx : nOuterIdx*nInnerSize);
- const sal_Int32 nMax = ::std::min( rNewData[nOuterIdx].getLength(), nInnerSize );
- sal_Int32 nInnerIdx=0;
- for( ; nInnerIdx < nMax; ++nInnerIdx )
+ // convert weak reference to reference
+ Reference< chart2::data::XDataSequence > xSeq( rMapEntry.second );
+ if( xSeq.is())
{
- m_aData[nDataIdx] = rNewData[nOuterIdx][nInnerIdx];
- nDataIdx += (bDataInColumns ? m_nColumnCount : 1);
+ Reference< util::XModifiable > xMod( xSeq, uno::UNO_QUERY );
+ if( xMod.is())
+ xMod->setModified( sal_True );
}
}
-}
-
-Sequence< Sequence< double > > InternalData::getData( bool bDataInColumns ) const
-{
- Sequence< Sequence< double > > aResult( bDataInColumns ? m_nColumnCount : m_nRowCount );
-
- if( bDataInColumns )
- {
- for( sal_Int32 i=0; i<m_nColumnCount; ++i )
- aResult[i] = lcl_ValarrayToSequence< tDataType::value_type >(
- m_aData[ ::std::slice( i, m_nRowCount, m_nColumnCount ) ] );
- }
- else
- {
- for( sal_Int32 i=0; i<m_nRowCount; ++i )
- aResult[i] = lcl_ValarrayToSequence< tDataType::value_type >(
- m_aData[ ::std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
- }
-
- return aResult;
-}
-
-Sequence< double > InternalData::getDataAt( sal_Int32 nIndex, bool bDataInColumns ) const
-{
- Sequence< double > aResult( bDataInColumns ? m_nRowCount : m_nColumnCount );
-
- if( bDataInColumns )
- {
- if( nIndex < m_nColumnCount )
- return lcl_ValarrayToSequence< tDataType::value_type >(
- m_aData[ ::std::slice( nIndex, m_nRowCount, m_nColumnCount ) ] );
- }
- else
- {
- if( nIndex < m_nRowCount )
- return lcl_ValarrayToSequence< tDataType::value_type >(
- m_aData[ ::std::slice( nIndex*m_nColumnCount, m_nColumnCount, 1 ) ] );
- }
-
- return Sequence< double >();
-}
+};
-void InternalData::setDataAt( sal_Int32 nIndex, bool bDataInColumns, const ::std::vector< double > & rNewData )
+struct lcl_internalizeSeries : public ::std::unary_function< Reference< chart2::XDataSeries >, void >
{
- if( bDataInColumns )
- {
- if( nIndex < m_nColumnCount )
- {
- tDataType aSlice = m_aData[ ::std::slice( nIndex, m_nRowCount, m_nColumnCount ) ];
- for( ::std::vector< double >::size_type i = 0; i < rNewData.size(); ++i )
- aSlice[i] = rNewData[i];
- m_aData[ ::std::slice( nIndex, m_nRowCount, m_nColumnCount ) ] = aSlice;
- }
- }
- else
+ lcl_internalizeSeries( InternalData & rInternalData,
+ InternalDataProvider & rProvider,
+ bool bConnectToModel, bool bDataInColumns ) :
+ m_rInternalData( rInternalData ),
+ m_rProvider( rProvider ),
+ m_bConnectToModel( bConnectToModel ),
+ m_bDataInColumns( bDataInColumns )
+ {}
+ void operator() ( const Reference< chart2::XDataSeries > & xSeries )
{
- if( nIndex < m_nRowCount )
+ Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
+ Reference< chart2::data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
+ if( xSource.is() && xSink.is() )
{
- tDataType aSlice = m_aData[ ::std::slice( nIndex*m_nColumnCount, m_nColumnCount, 1 ) ];
- for( ::std::vector< double >::size_type i = 0; i < rNewData.size(); ++i )
- aSlice[i] = rNewData[i];
- m_aData[ ::std::slice( nIndex*m_nColumnCount, m_nColumnCount, 1 ) ]= aSlice;
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeriesData = xSource->getDataSequences();
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeriesData( aOldSeriesData.getLength() );
+ for( sal_Int32 i=0; i<aOldSeriesData.getLength(); ++i )
+ {
+ sal_Int32 nNewIndex( m_bDataInColumns ? m_rInternalData.appendColumn() : m_rInternalData.appendRow() );
+ OUString aIdentifier( OUString::valueOf( nNewIndex ));
+ //@todo: deal also with genericXDataSequence
+ Reference< chart2::data::XNumericalDataSequence > xValues( aOldSeriesData[i]->getValues(), uno::UNO_QUERY );
+ Reference< chart2::data::XTextualDataSequence > xLabel( aOldSeriesData[i]->getLabel(), uno::UNO_QUERY );
+ Reference< chart2::data::XDataSequence > xNewValues;
+
+ if( xValues.is() )
+ {
+ ::std::vector< double > aValues( ContainerHelper::SequenceToVector( xValues->getNumericalData()));
+ if( m_bDataInColumns )
+ m_rInternalData.setColumnValues( nNewIndex, aValues );
+ else
+ m_rInternalData.setRowValues( nNewIndex, aValues );
+ if( m_bConnectToModel )
+ {
+ xNewValues.set( m_rProvider.createDataSequenceByRangeRepresentation( aIdentifier ));
+ comphelper::copyProperties(
+ Reference< beans::XPropertySet >( xValues, uno::UNO_QUERY ),
+ Reference< beans::XPropertySet >( xNewValues, uno::UNO_QUERY ));
+ }
+ }
+
+ if( xLabel.is() )
+ {
+ if( m_bDataInColumns )
+ m_rInternalData.setComplexColumnLabel( nNewIndex, ContainerHelper::SequenceToVector( xLabel->getTextualData() ) );
+ else
+ m_rInternalData.setComplexRowLabel( nNewIndex, ContainerHelper::SequenceToVector( xLabel->getTextualData() ) );
+ if( m_bConnectToModel )
+ {
+ Reference< chart2::data::XDataSequence > xNewLabel(
+ m_rProvider.createDataSequenceByRangeRepresentation( lcl_aLabelRangePrefix + aIdentifier ));
+ comphelper::copyProperties(
+ Reference< beans::XPropertySet >( xLabel, uno::UNO_QUERY ),
+ Reference< beans::XPropertySet >( xNewLabel, uno::UNO_QUERY ));
+ aNewSeriesData[i] = Reference< chart2::data::XLabeledDataSequence >(
+ new LabeledDataSequence( xNewValues, xNewLabel ));
+ }
+ }
+ else
+ {
+ if( m_bConnectToModel )
+ aNewSeriesData[i] = Reference< chart2::data::XLabeledDataSequence >(
+ new LabeledDataSequence( xNewValues ));
+ }
+ }
+ if( m_bConnectToModel )
+ xSink->setData( aNewSeriesData );
}
- }
-}
+ }
-void InternalData::swapAllDataAtIndexWithNext( sal_Int32 nAtIndex, bool bDataInColumns )
-{
- if( bDataInColumns && nAtIndex < m_nRowCount - 1 )
- {
- const sal_Int32 nMax = m_nColumnCount;
- for( sal_Int32 nColIdx=0; nColIdx<nMax; ++nColIdx )
- {
- size_t nIndex1 = nColIdx + nAtIndex*m_nColumnCount;
- size_t nIndex2 = nIndex1 + m_nColumnCount;
- double fTemp = m_aData[nIndex1];
- m_aData[nIndex1] = m_aData[nIndex2];
- m_aData[nIndex2] = fTemp;
- }
- OUString sTemp( m_aRowLabels[nAtIndex] );
- m_aRowLabels[nAtIndex] = m_aRowLabels[nAtIndex + 1];
- m_aRowLabels[nAtIndex + 1] = sTemp;
- }
- else if( nAtIndex < m_nColumnCount - 1 )
- {
- const sal_Int32 nMax = m_nRowCount;
- for( sal_Int32 nRowIdx=0; nRowIdx<nMax; ++nRowIdx )
- {
- size_t nIndex1 = nAtIndex + nRowIdx*m_nColumnCount;
- size_t nIndex2 = nIndex1 + 1;
- double fTemp = m_aData[nIndex1];
- m_aData[nIndex1] = m_aData[nIndex2];
- m_aData[nIndex2] = fTemp;
- }
- OUString sTemp( m_aColumnLabels[nAtIndex] );
- m_aColumnLabels[nAtIndex] = m_aColumnLabels[nAtIndex + 1];
- m_aColumnLabels[nAtIndex + 1] = sTemp;
- }
-}
+private:
+ InternalData & m_rInternalData;
+ InternalDataProvider & m_rProvider;
+ bool m_bConnectToModel;
+ bool m_bDataInColumns;
+};
-bool InternalData::enlargeData( sal_Int32 nColumnCount, sal_Int32 nRowCount )
+struct lcl_makeAnyFromLevelVector : public ::std::unary_function< vector< OUString >, uno::Any >
{
- sal_Int32 nNewColumnCount( ::std::max<sal_Int32>( m_nColumnCount, nColumnCount ) );
- sal_Int32 nNewRowCount( ::std::max<sal_Int32>( m_nRowCount, nRowCount ) );
- sal_Int32 nNewSize( nNewColumnCount*nNewRowCount );
+public:
- bool bGrow = (nNewSize > m_nColumnCount*m_nRowCount);
+ explicit lcl_makeAnyFromLevelVector( sal_Int32 nLevel ) : m_nLevel( nLevel )
+ {}
- if( bGrow )
+ uno::Any operator() ( const vector< OUString >& rVector )
{
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
- // copy old data
- for( int nCol=0; nCol<m_nColumnCount; ++nCol )
- static_cast< tDataType >(
- aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] ) =
- m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ];
-
- m_aData.resize( nNewSize );
- m_aData = aNewData;
+ OUString aString;
+ if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) )
+ aString = rVector[m_nLevel];
+ return uno::makeAny( aString );
}
- m_nColumnCount = nNewColumnCount;
- m_nRowCount = nNewRowCount;
- return bGrow;
-}
-
-void InternalData::insertColumn( sal_Int32 nAfterIndex )
-{
- // note: -1 is allowed, as we insert after the given index
- OSL_ASSERT( nAfterIndex < m_nColumnCount && nAfterIndex >= -1 );
- if( nAfterIndex >= m_nColumnCount || nAfterIndex < -1 )
- return;
- sal_Int32 nNewColumnCount = m_nColumnCount + 1;
- sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
-
- // copy old data
- int nCol=0;
- for( ; nCol<=nAfterIndex; ++nCol )
- aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ] );
- for( ++nCol; nCol<nNewColumnCount; ++nCol )
- aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( nCol - 1, m_nRowCount, m_nColumnCount ) ] );
-
- m_nColumnCount = nNewColumnCount;
- m_aData.resize( nNewSize );
- m_aData = aNewData;
-
- // labels
- if( nAfterIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
- m_aColumnLabels.insert( m_aColumnLabels.begin() + (nAfterIndex + 1), OUString());
-
-#if OSL_DEBUG_LEVEL > 2
- traceData();
-#endif
-}
-
-sal_Int32 InternalData::appendColumn()
-{
- insertColumn( getColumnCount() - 1 );
- return getColumnCount() - 1;
-}
-
-sal_Int32 InternalData::appendRow()
-{
- insertRow( getRowCount() - 1 );
- return getRowCount() - 1;
-}
+private:
+ sal_Int32 m_nLevel;
+};
-void InternalData::insertRow( sal_Int32 nAfterIndex )
+struct lcl_getStringFromLevelVector : public ::std::unary_function< vector< OUString >, OUString >
{
- // note: -1 is allowed, as we insert after the given index
- OSL_ASSERT( nAfterIndex < m_nRowCount && nAfterIndex >= -1 );
- if( nAfterIndex >= m_nRowCount || nAfterIndex < -1 )
- return;
- sal_Int32 nNewRowCount = m_nRowCount + 1;
- sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
-
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
+public:
- // copy old data
- sal_Int32 nIndex = nAfterIndex + 1;
- aNewData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] );
+ explicit lcl_getStringFromLevelVector( sal_Int32 nLevel ) : m_nLevel( nLevel )
+ {}
- if( nIndex < m_nRowCount )
+ OUString operator() ( const vector< OUString >& rVector )
{
- sal_Int32 nRemainingCount = m_nColumnCount * (m_nRowCount - nIndex);
- aNewData[ ::std::slice( (nIndex + 1) * m_nColumnCount, nRemainingCount, 1 ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( nIndex * m_nColumnCount, nRemainingCount, 1 ) ] );
+ OUString aString;
+ if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) )
+ aString = rVector[m_nLevel];
+ return aString;
}
- m_nRowCount = nNewRowCount;
- m_aData.resize( nNewSize );
- m_aData = aNewData;
-
- // labels
- if( nAfterIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
- m_aRowLabels.insert( m_aRowLabels.begin() + nIndex, OUString());
-
-#if OSL_DEBUG_LEVEL > 2
- traceData();
-#endif
-}
-
-void InternalData::deleteColumn( sal_Int32 nAtIndex )
-{
- OSL_ASSERT( nAtIndex < m_nColumnCount && nAtIndex >= 0 );
- if( nAtIndex >= m_nColumnCount || m_nColumnCount < 1 || nAtIndex < 0 )
- return;
- sal_Int32 nNewColumnCount = m_nColumnCount - 1;
- sal_Int32 nNewSize( nNewColumnCount * m_nRowCount );
+private:
+ sal_Int32 m_nLevel;
+};
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
-
- // copy old data
- int nCol=0;
- for( ; nCol<nAtIndex; ++nCol )
- aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( nCol, m_nRowCount, m_nColumnCount ) ] );
- for( ; nCol<nNewColumnCount; ++nCol )
- aNewData[ ::std::slice( nCol, m_nRowCount, nNewColumnCount ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( nCol + 1, m_nRowCount, m_nColumnCount ) ] );
-
- m_nColumnCount = nNewColumnCount;
- m_aData.resize( nNewSize );
- m_aData = aNewData;
-
- // labels
- if( nAtIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
- m_aColumnLabels.erase( m_aColumnLabels.begin() + nAtIndex );
-
-#if OSL_DEBUG_LEVEL > 2
- traceData();
-#endif
-}
-void InternalData::deleteRow( sal_Int32 nAtIndex )
+struct lcl_setStringAtLevel : public ::std::binary_function< vector< OUString >, OUString, vector< OUString > >
{
- OSL_ASSERT( nAtIndex < m_nRowCount && nAtIndex >= 0 );
- if( nAtIndex >= m_nRowCount || m_nRowCount < 1 || nAtIndex < 0 )
- return;
- sal_Int32 nNewRowCount = m_nRowCount - 1;
- sal_Int32 nNewSize( m_nColumnCount * nNewRowCount );
-
- double fNan;
- ::rtl::math::setNan( &fNan );
- tDataType aNewData( fNan, nNewSize );
+public:
- // copy old data
- sal_Int32 nIndex = nAtIndex;
- if( nIndex )
- aNewData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( 0, nIndex * m_nColumnCount, 1 ) ] );
+ explicit lcl_setStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
+ {}
- if( nIndex < nNewRowCount )
+ vector< OUString > operator() ( const vector< OUString >& rVector, const OUString& rNewText )
{
- sal_Int32 nRemainingCount = m_nColumnCount * (nNewRowCount - nIndex);
- aNewData[ ::std::slice( nIndex * m_nColumnCount, nRemainingCount, 1 ) ] =
- static_cast< tDataType >(
- m_aData[ ::std::slice( (nIndex + 1) * m_nColumnCount, nRemainingCount, 1 ) ] );
+ vector< OUString > aRet( rVector );
+ if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) )
+ aRet.resize( m_nLevel+1 );
+ aRet[ m_nLevel ]=rNewText;
+ return aRet;
}
- m_nRowCount = nNewRowCount;
- m_aData.resize( nNewSize );
- m_aData = aNewData;
-
- // labels
- if( nAtIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
- m_aRowLabels.erase( m_aRowLabels.begin() + nAtIndex );
-
-#if OSL_DEBUG_LEVEL > 2
- traceData();
-#endif
-}
-
-sal_Int32 InternalData::getRowCount() const
-{
- return m_nRowCount;
-}
-
-sal_Int32 InternalData::getColumnCount() const
-{
- return m_nColumnCount;
-}
-
-void InternalData::setRowLabels( const ::std::vector< OUString > & rNewRowLabels )
-{
- m_aRowLabels = rNewRowLabels;
- if( m_aRowLabels.size() < static_cast< ::std::vector< OUString >::size_type >( m_nRowCount ))
- m_aRowLabels.resize( m_nRowCount );
- else
- enlargeData( 0, static_cast< sal_Int32 >( m_aRowLabels.size() ));
-}
-
-::std::vector< OUString > InternalData::getRowLabels() const
-{
- return m_aRowLabels;
-}
-
-void InternalData::setColumnLabels( const ::std::vector< OUString > & rNewColumnLabels )
-{
- m_aColumnLabels = rNewColumnLabels;
- if( m_aColumnLabels.size() < static_cast< ::std::vector< OUString >::size_type >( m_nColumnCount ))
- m_aColumnLabels.resize( m_nColumnCount );
- else
- enlargeData( static_cast< sal_Int32 >( m_aColumnLabels.size()), 0 );
-}
+private:
+ sal_Int32 m_nLevel;
+};
-::std::vector< OUString > InternalData::getColumnLabels() const
+struct lcl_insertStringAtLevel : public ::std::unary_function< vector< OUString >, void >
{
- return m_aColumnLabels;
-}
+public:
-#if OSL_DEBUG_LEVEL > 2
-void InternalData::traceData() const
-{
- OSL_TRACE( "InternalData: Data in rows\n" );
+ explicit lcl_insertStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
+ {}
- for( sal_Int32 i=0; i<m_nRowCount; ++i )
+ void operator() ( vector< OUString >& rVector )
{
- tDataType aSlice( m_aData[ ::std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
- for( sal_Int32 j=0; j<m_nColumnCount; ++j )
- OSL_TRACE( "%lf ", aSlice[j] );
- OSL_TRACE( "\n" );
- }
- OSL_TRACE( "\n" );
-}
-#endif
+ if( m_nLevel > static_cast< sal_Int32 >(rVector.size()) )
+ rVector.resize( m_nLevel );
-} // namespace impl
+ vector< OUString >::iterator aIt( rVector.begin() );
+ for( sal_Int32 nN=0; aIt<rVector.end(); aIt++, nN++)
+ {
+ if( nN==m_nLevel )
+ break;
+ }
+ rVector.insert( aIt, OUString() );
+ }
-// ================================================================================
+private:
+ sal_Int32 m_nLevel;
+};
-namespace
+struct lcl_removeStringAtLevel : public ::std::unary_function< vector< OUString >, void >
{
+public:
-// note: in xmloff this name is used to indicate usage of own data
-static const ::rtl::OUString lcl_aServiceName(
- RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.InternalDataProvider" ));
-
-static const ::rtl::OUString lcl_aCategoriesRangeName(
- RTL_CONSTASCII_USTRINGPARAM( "categories" ));
-static const ::rtl::OUString lcl_aCategoriesRoleName(
- RTL_CONSTASCII_USTRINGPARAM( "categories" ));
-static const ::rtl::OUString lcl_aLabelRangePrefix(
- RTL_CONSTASCII_USTRINGPARAM( "label " ));
-static const ::rtl::OUString lcl_aCompleteRange(
- RTL_CONSTASCII_USTRINGPARAM( "all" ));
-
-
-struct lcl_DataProviderRangeCreator : public unary_function< OUString, Reference< chart2::data::XLabeledDataSequence > >
-{
- lcl_DataProviderRangeCreator( const Reference< chart2::data::XDataProvider > & xDataProvider ) :
- m_xDataProvider( xDataProvider )
+ explicit lcl_removeStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
{}
- Reference< chart2::data::XLabeledDataSequence > operator() ( const OUString & rRange )
+ void operator() ( vector< OUString >& rVector )
{
- Reference< chart2::data::XLabeledDataSequence > xResult;
- if( m_xDataProvider.is())
- try
- {
- xResult.set( new ::chart::LabeledDataSequence(
- m_xDataProvider->createDataSequenceByRangeRepresentation( rRange )));
- }
- catch( const lang::IllegalArgumentException & ex )
- {
- // data provider cannot create single data sequences, but then
- // detectArguments should work also with an empty data source
- (void)(ex);
- }
- catch( const uno::Exception & ex )
+ vector< OUString >::iterator aIt( rVector.begin() );
+ for( sal_Int32 nN=0; aIt<rVector.end(); aIt++, nN++)
+ {
+ if( nN==m_nLevel )
{
- ASSERT_EXCEPTION( ex );
+ rVector.erase( aIt );
+ break;
}
- return xResult;
+ }
}
private:
- Reference< chart2::data::XDataProvider > m_xDataProvider;
+ sal_Int32 m_nLevel;
};
-typedef ::std::multimap< OUString, uno::WeakReference< chart2::data::XDataSequence > >
- lcl_tSequenceMap;
-
-struct lcl_modifySeqMapValue : public ::std::unary_function< lcl_tSequenceMap, void >
+vector< OUString > lcl_AnyToStringVector( const Sequence< uno::Any >& aAnySeq )
{
- void operator() ( const lcl_tSequenceMap::value_type & rMapEntry )
- {
- // convert weak reference to reference
- Reference< chart2::data::XDataSequence > xSeq( rMapEntry.second );
- if( xSeq.is())
- {
- Reference< util::XModifiable > xMod( xSeq, uno::UNO_QUERY );
- if( xMod.is())
- xMod->setModified( sal_True );
- }
- }
-};
+ vector< OUString > aStringVec;
+ transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(),
+ back_inserter( aStringVec ), CommonFunctors::AnyToString() );
+ return aStringVec;
+}
-Sequence< Reference< chart2::data::XLabeledDataSequence > >
- lcl_internalizeData(
- const Sequence< Reference< chart2::data::XLabeledDataSequence > > & rDataSeq,
- impl::InternalData & rInternalData,
- InternalDataProvider & rProvider )
+Sequence< OUString > lcl_AnyToStringSequence( const Sequence< uno::Any >& aAnySeq )
{
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aResult( rDataSeq.getLength());
- for( sal_Int32 i=0; i<rDataSeq.getLength(); ++i )
- {
- sal_Int32 nNewIndex( rInternalData.appendColumn());
- OUString aIdentifier( OUString::valueOf( nNewIndex ));
- //@todo: deal also with genericXDataSequence
- Reference< chart2::data::XNumericalDataSequence > xValues( rDataSeq[i]->getValues(), uno::UNO_QUERY );
- Reference< chart2::data::XTextualDataSequence > xLabel( rDataSeq[i]->getLabel(), uno::UNO_QUERY );
- Reference< chart2::data::XDataSequence > xNewValues;
-
- if( xValues.is())
- {
- ::std::vector< double > aValues( ContainerHelper::SequenceToVector( xValues->getNumericalData()));
- rInternalData.enlargeData( nNewIndex + 1, aValues.size());
- rInternalData.setDataAt( nNewIndex, true, aValues );
- xNewValues.set( rProvider.createDataSequenceByRangeRepresentation( aIdentifier ));
- comphelper::copyProperties(
- Reference< beans::XPropertySet >( xValues, uno::UNO_QUERY ),
- Reference< beans::XPropertySet >( xNewValues, uno::UNO_QUERY ));
- }
-
- if( xLabel.is())
- {
- ::std::vector< OUString > aLabels( rInternalData.getColumnLabels());
- OSL_ASSERT( static_cast< size_t >( nNewIndex ) < aLabels.size());
- if( aLabels.size() <= static_cast< size_t >( nNewIndex ) )
- aLabels.resize( nNewIndex+1 );
- aLabels[nNewIndex] = impl::FlattenStringSequence( xLabel->getTextualData());
- rInternalData.setColumnLabels( aLabels );
- Reference< chart2::data::XDataSequence > xNewLabel(
- rProvider.createDataSequenceByRangeRepresentation( lcl_aLabelRangePrefix + aIdentifier ));
- comphelper::copyProperties(
- Reference< beans::XPropertySet >( xLabel, uno::UNO_QUERY ),
- Reference< beans::XPropertySet >( xNewLabel, uno::UNO_QUERY ));
- aResult[i] =
- Reference< chart2::data::XLabeledDataSequence >(
- new LabeledDataSequence( xNewValues, xNewLabel ));
- }
- else
- {
- aResult[i] =
- Reference< chart2::data::XLabeledDataSequence >(
- new LabeledDataSequence( xNewValues ));
- }
- }
+ Sequence< OUString > aResult;
+ aResult.realloc( aAnySeq.getLength() );
+ transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(),
+ aResult.getArray(), CommonFunctors::AnyToString() );
return aResult;
}
-struct lcl_internalizeSeries : public ::std::unary_function< Reference< chart2::XDataSeries >, void >
-{
- lcl_internalizeSeries( impl::InternalData & rInternalData,
- InternalDataProvider & rProvider ) :
- m_rInternalData( rInternalData ),
- m_rProvider( rProvider )
- {}
- void operator() ( const Reference< chart2::XDataSeries > & xSeries )
- {
- Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
- Reference< chart2::data::XDataSink > xSink( xSeries, uno::UNO_QUERY );
- if( xSource.is() && xSink.is())
- xSink->setData( lcl_internalizeData( xSource->getDataSequences(), m_rInternalData, m_rProvider ));
- }
-
-private:
- impl::InternalData & m_rInternalData;
- InternalDataProvider & m_rProvider;
-};
-
} // anonymous namespace
-InternalDataProvider::InternalDataProvider(const Reference< uno::XComponentContext > & /*_xContext*/) :
- m_bDataInColumns( true )
-{}
// ================================================================================
-InternalDataProvider::InternalDataProvider() :
- m_bDataInColumns( true )
+InternalDataProvider::InternalDataProvider( const Reference< uno::XComponentContext > & /*_xContext*/)
+ : m_bDataInColumns( true )
{}
-InternalDataProvider::InternalDataProvider(
- const Reference< ::com::sun::star::chart::XChartDataArray > & xDataToCopy ) :
- m_bDataInColumns( true )
-{
- if( xDataToCopy.is())
- {
- setData( xDataToCopy->getData() );
- setColumnDescriptions( xDataToCopy->getColumnDescriptions() );
- setRowDescriptions( xDataToCopy->getRowDescriptions() );
- }
-}
-
-InternalDataProvider::InternalDataProvider(
- const Reference< chart2::XChartDocument > & xChartDoc ) :
- m_bDataInColumns( true )
+InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocument > & xChartDoc, bool bConnectToModel )
+ : m_bDataInColumns( true )
{
try
{
Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartDoc ) );
if( xDiagram.is())
{
- impl::InternalData & rData( getInternalData());
+ Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY );
+
+ //data in columns?
+ {
+ ::rtl::OUString aRangeString;
+ bool bFirstCellAsLabel = true;
+ bool bHasCategories = true;
+ uno::Sequence< sal_Int32 > aSequenceMapping;
+ DataSourceHelper::detectRangeSegmentation( xChartModel, aRangeString, aSequenceMapping, m_bDataInColumns, bFirstCellAsLabel, bHasCategories );
+ }
+
// categories
- Reference< chart2::data::XLabeledDataSequence > xCategories( DiagramHelper::getCategoriesFromDiagram( xDiagram ));
- if( xCategories.is())
{
- // @todo: be able to deal with XDataSequence, too
- Reference< chart2::data::XTextualDataSequence > xSeq( xCategories->getValues(), uno::UNO_QUERY );
- if( xSeq.is())
- rData.setRowLabels( ContainerHelper::SequenceToVector( xSeq->getTextualData()));
- DiagramHelper::setCategoriesToDiagram(
- new LabeledDataSequence(
- createDataSequenceByRangeRepresentation( lcl_aCategoriesRangeName )),
- xDiagram );
+ vector< vector< OUString > > aNewCategories;//inner count is level
+ {
+ ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel );
+ const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() );
+ sal_Int32 nLevelCount = rSplitCategoriesList.getLength();
+ for( sal_Int32 nL = 0; nL<nLevelCount; nL++ )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xLDS( rSplitCategoriesList[nL] );
+ if( !xLDS.is() )
+ continue;
+ Reference< chart2::data::XTextualDataSequence > xSeq( xLDS->getValues(), uno::UNO_QUERY );
+ Sequence< OUString > aStringSeq;
+ if( xSeq.is() )
+ aStringSeq = xSeq->getTextualData(); // @todo: be able to deal with XDataSequence, too
+ sal_Int32 nLength = aStringSeq.getLength();
+ if( static_cast< sal_Int32 >(aNewCategories.size()) < nLength )
+ aNewCategories.resize( nLength );
+
+ transform( aNewCategories.begin(), aNewCategories.end(), aStringSeq.getConstArray(),
+ aNewCategories.begin(), lcl_setStringAtLevel(nL) );
+ }
+ if( !nLevelCount )
+ {
+ Sequence< OUString > aSimplecategories = aExplicitCategoriesProvider.getSimpleCategories();
+ sal_Int32 nLength = aSimplecategories.getLength();
+ aNewCategories.reserve( nLength );
+ for( sal_Int32 nN=0; nN<nLength; nN++)
+ {
+ vector< OUString > aStringVector(1);
+ aStringVector[0] = aSimplecategories[nN];
+ aNewCategories.push_back( aStringVector );
+ }
+ }
+ }
+
+ if( m_bDataInColumns )
+ m_aInternalData.setComplexRowLabels( aNewCategories );
+ else
+ m_aInternalData.setComplexColumnLabels( aNewCategories );
+ if( bConnectToModel )
+ DiagramHelper::setCategoriesToDiagram( new LabeledDataSequence(
+ createDataSequenceByRangeRepresentation( lcl_aCategoriesRangeName )), xDiagram );
}
// data series
::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( ChartModelHelper::getDataSeries( xChartDoc ));
- ::std::for_each( aSeriesVector.begin(), aSeriesVector.end(),
- lcl_internalizeSeries( rData, *this ));
-
- // unused data
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aUnusedData( xDiagram->getUnusedData());
- aUnusedData = lcl_internalizeData( aUnusedData, rData, *this );
- xDiagram->setUnusedData( aUnusedData );
+ ::std::for_each( aSeriesVector.begin(), aSeriesVector.end(), lcl_internalizeSeries( m_aInternalData, *this, bConnectToModel, m_bDataInColumns ) );
}
}
catch( const uno::Exception & ex )
@@ -847,14 +400,14 @@ InternalDataProvider::InternalDataProvider(
InternalDataProvider::InternalDataProvider( const InternalDataProvider & rOther ) :
impl::InternalDataProvider_Base(),
m_aSequenceMap( rOther.m_aSequenceMap ),
- m_apData( new impl::InternalData( rOther.getInternalData())),
+ m_aInternalData( rOther.m_aInternalData ),
m_bDataInColumns( rOther.m_bDataInColumns )
{}
InternalDataProvider::~InternalDataProvider()
{}
-void InternalDataProvider::addDataSequenceToMap(
+void InternalDataProvider::lcl_addDataSequenceToMap(
const OUString & rRangeRepresentation,
const Reference< chart2::data::XDataSequence > & xSequence )
{
@@ -864,7 +417,7 @@ void InternalDataProvider::addDataSequenceToMap(
uno::WeakReference< chart2::data::XDataSequence >( xSequence )));
}
-void InternalDataProvider::deleteMapReferences( const OUString & rRangeRepresentation )
+void InternalDataProvider::lcl_deleteMapReferences( const OUString & rRangeRepresentation )
{
// set sequence to deleted by setting its range to an empty string
tSequenceMapRange aRange( m_aSequenceMap.equal_range( rRangeRepresentation ));
@@ -882,7 +435,7 @@ void InternalDataProvider::deleteMapReferences( const OUString & rRangeRepresent
m_aSequenceMap.erase( aRange.first, aRange.second );
}
-void InternalDataProvider::adaptMapReferences(
+void InternalDataProvider::lcl_adaptMapReferences(
const OUString & rOldRangeRepresentation,
const OUString & rNewRangeRepresentation )
{
@@ -907,70 +460,52 @@ void InternalDataProvider::adaptMapReferences(
m_aSequenceMap.upper_bound( rNewRangeRepresentation )));
}
-void InternalDataProvider::increaseMapReferences(
+void InternalDataProvider::lcl_increaseMapReferences(
sal_Int32 nBegin, sal_Int32 nEnd )
{
for( sal_Int32 nIndex = nEnd - 1; nIndex >= nBegin; --nIndex )
{
- adaptMapReferences( OUString::valueOf( nIndex ),
+ lcl_adaptMapReferences( OUString::valueOf( nIndex ),
OUString::valueOf( nIndex + 1 ));
- adaptMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ),
+ lcl_adaptMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ),
lcl_aLabelRangePrefix + OUString::valueOf( nIndex + 1 ));
}
}
-void InternalDataProvider::decreaseMapReferences(
+void InternalDataProvider::lcl_decreaseMapReferences(
sal_Int32 nBegin, sal_Int32 nEnd )
{
for( sal_Int32 nIndex = nBegin; nIndex < nEnd; ++nIndex )
{
- adaptMapReferences( OUString::valueOf( nIndex ),
+ lcl_adaptMapReferences( OUString::valueOf( nIndex ),
OUString::valueOf( nIndex - 1 ));
- adaptMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ),
+ lcl_adaptMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ),
lcl_aLabelRangePrefix + OUString::valueOf( nIndex - 1 ));
}
}
-Reference< chart2::data::XDataSequence > InternalDataProvider::createDataSequenceAndAddToMap(
+Reference< chart2::data::XDataSequence > InternalDataProvider::lcl_createDataSequenceAndAddToMap(
const OUString & rRangeRepresentation )
{
Reference< chart2::data::XDataSequence > xSeq(
new UncachedDataSequence( this, rRangeRepresentation ));
- addDataSequenceToMap( rRangeRepresentation, xSeq );
+ lcl_addDataSequenceToMap( rRangeRepresentation, xSeq );
return xSeq;
}
-Reference< chart2::data::XDataSequence > InternalDataProvider::createDataSequenceAndAddToMap(
+Reference< chart2::data::XDataSequence > InternalDataProvider::lcl_createDataSequenceAndAddToMap(
const OUString & rRangeRepresentation,
const OUString & rRole )
{
Reference< chart2::data::XDataSequence > xSeq(
new UncachedDataSequence( this, rRangeRepresentation, rRole ));
- addDataSequenceToMap( rRangeRepresentation, xSeq );
+ lcl_addDataSequenceToMap( rRangeRepresentation, xSeq );
return xSeq;
}
-const impl::InternalData & InternalDataProvider::getInternalData() const
-{
- if( m_apData.get())
- return *(m_apData.get());
-
- m_apData.reset( new impl::InternalData());
- return *(m_apData.get());
-}
-
-impl::InternalData & InternalDataProvider::getInternalData()
-{
- if( m_apData.get())
- return *(m_apData.get());
-
- m_apData.reset( new impl::InternalData());
- return *(m_apData.get());
-}
-
void InternalDataProvider::createDefaultData()
{
- getInternalData().createDefaultData();
+ m_aInternalData.createDefaultData();
}
// ____ XDataProvider ____
@@ -980,6 +515,24 @@ void InternalDataProvider::createDefaultData()
return true;
}
+namespace
+{
+
+sal_Int32 lcl_getInnerLevelCount( const vector< vector< OUString > >& rLabels )
+{
+ sal_Int32 nCount = 1;//minimum is 1!
+ vector< vector< OUString > >::const_iterator aLevelIt( rLabels.begin() );
+ vector< vector< OUString > >::const_iterator aLevelEnd( rLabels.end() );
+ for( ;aLevelIt!=aLevelEnd; ++aLevelIt )
+ {
+ const vector< ::rtl::OUString >& rCurrentLevelLabels = *aLevelIt;
+ nCount = std::max<sal_Int32>( rCurrentLevelLabels.size(), nCount );
+ }
+ return nCount;
+}
+
+}//end anonymous namespace
+
Reference< chart2::data::XDataSource > SAL_CALL InternalDataProvider::createDataSource(
const Sequence< beans::PropertyValue >& aArguments )
throw (lang::IllegalArgumentException,
@@ -992,25 +545,51 @@ Reference< chart2::data::XDataSource > SAL_CALL InternalDataProvider::createData
uno::Sequence< sal_Int32 > aSequenceMapping;
DataSourceHelper::readArguments( aArguments, aRangeRepresentation, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories );
+ if( aRangeRepresentation.equals( lcl_aCategoriesRangeName ) )
+ {
+ //return split complex categories if we have any:
+ ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aComplexCategories;
+ vector< vector< OUString > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
+ if( bUseColumns==m_bDataInColumns )
+ {
+ sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories );
+ for( sal_Int32 nL=0; nL<nLevelCount; nL++ )
+ aComplexCategories.push_back( new LabeledDataSequence(
+ new UncachedDataSequence( this
+ , lcl_aCategoriesLevelRangeNamePrefix + OUString::valueOf( nL )
+ , lcl_aCategoriesRoleName ) ) );
+ }
+ else
+ {
+ sal_Int32 nPointCount = m_bDataInColumns ? m_aInternalData.getRowCount() : m_aInternalData.getColumnCount();
+ for( sal_Int32 nP=0; nP<nPointCount; nP++ )
+ aComplexCategories.push_back( new LabeledDataSequence(
+ new UncachedDataSequence( this
+ , lcl_aCategoriesPointRangeNamePrefix + OUString::valueOf( nP )
+ , lcl_aCategoriesRoleName ) ) );
+ }
+ //don't add the created sequences to the map as they are used temporarily only ...
+ return new DataSource( ContainerHelper::ContainerToSequence(aComplexCategories) );
+ }
+
OSL_ASSERT( aRangeRepresentation.equals( lcl_aCompleteRange ));
::std::vector< Reference< chart2::data::XLabeledDataSequence > > aResultLSeqVec;
- impl::InternalData & rData( getInternalData());
// categories
- if ( bHasCategories )
+ if( bHasCategories )
aResultLSeqVec.push_back(
- new LabeledDataSequence( createDataSequenceAndAddToMap( lcl_aCategoriesRangeName, lcl_aCategoriesRoleName )));
+ new LabeledDataSequence( lcl_createDataSequenceAndAddToMap( lcl_aCategoriesRangeName, lcl_aCategoriesRoleName ) ) );
// data with labels
::std::vector< Reference< chart2::data::XLabeledDataSequence > > aDataVec;
- const sal_Int32 nCount = (bUseColumns ? rData.getColumnCount() : rData.getRowCount());
- for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
+ const sal_Int32 nCount = (bUseColumns ? m_aInternalData.getColumnCount() : m_aInternalData.getRowCount());
+ for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
{
aDataVec.push_back(
new LabeledDataSequence(
- createDataSequenceAndAddToMap( OUString::valueOf( nIdx )),
- createDataSequenceAndAddToMap( lcl_aLabelRangePrefix + OUString::valueOf( nIdx ))));
+ lcl_createDataSequenceAndAddToMap( OUString::valueOf( nIdx )),
+ lcl_createDataSequenceAndAddToMap( lcl_aLabelRangePrefix + OUString::valueOf( nIdx ))));
}
// attention: this data provider has the limitation that it stores
@@ -1082,29 +661,31 @@ Reference< chart2::data::XDataSequence > SAL_CALL InternalDataProvider::createDa
throw (lang::IllegalArgumentException,
uno::RuntimeException)
{
- if( aRangeRepresentation.equals( lcl_aCategoriesRangeName ))
+ if( aRangeRepresentation.match( lcl_aCategoriesRangeName ))
{
+ OSL_ASSERT( aRangeRepresentation.equals( lcl_aCategoriesRangeName ) );//it is not expected nor implmented that only parts of the categories are really requested
+
// categories
- return createDataSequenceAndAddToMap( lcl_aCategoriesRangeName, lcl_aCategoriesRoleName );
+ return lcl_createDataSequenceAndAddToMap( lcl_aCategoriesRangeName, lcl_aCategoriesRoleName );
}
else if( aRangeRepresentation.match( lcl_aLabelRangePrefix ))
{
// label
sal_Int32 nIndex = aRangeRepresentation.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
- return createDataSequenceAndAddToMap( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ));
+ return lcl_createDataSequenceAndAddToMap( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ));
}
else if( aRangeRepresentation.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "last" )))
{
sal_Int32 nIndex = (m_bDataInColumns
- ? getInternalData().getColumnCount()
- : getInternalData().getRowCount()) - 1;
- return createDataSequenceAndAddToMap( OUString::valueOf( nIndex ));
+ ? m_aInternalData.getColumnCount()
+ : m_aInternalData.getRowCount()) - 1;
+ return lcl_createDataSequenceAndAddToMap( OUString::valueOf( nIndex ));
}
else if( aRangeRepresentation.getLength())
{
// data
sal_Int32 nIndex = aRangeRepresentation.toInt32();
- return createDataSequenceAndAddToMap( OUString::valueOf( nIndex ));
+ return lcl_createDataSequenceAndAddToMap( OUString::valueOf( nIndex ));
}
return Reference< chart2::data::XDataSequence >();
@@ -1122,21 +703,21 @@ Reference< sheet::XRangeSelection > SAL_CALL InternalDataProvider::getRangeSelec
throw (uno::RuntimeException)
{
sal_Bool bResult = false;
- const impl::InternalData & rData( getInternalData());
- if( aRange.equals( lcl_aCategoriesRangeName ))
+ if( aRange.match( lcl_aCategoriesRangeName ))
{
+ OSL_ASSERT( aRange.equals( lcl_aCategoriesRangeName ) );//it is not expected nor implmented that only parts of the categories are really requested
bResult = true;
}
else if( aRange.match( lcl_aLabelRangePrefix ))
{
sal_Int32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
- bResult = (nIndex < (m_bDataInColumns ? rData.getColumnCount(): rData.getRowCount()));
+ bResult = (nIndex < (m_bDataInColumns ? m_aInternalData.getColumnCount(): m_aInternalData.getRowCount()));
}
else
{
sal_Int32 nIndex = aRange.toInt32();
- bResult = (nIndex < (m_bDataInColumns ? rData.getColumnCount(): rData.getRowCount()));
+ bResult = (nIndex < (m_bDataInColumns ? m_aInternalData.getColumnCount(): m_aInternalData.getRowCount()));
}
return bResult;
@@ -1146,34 +727,67 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation
throw (uno::RuntimeException)
{
Sequence< uno::Any > aResult;
- const impl::InternalData & rData( getInternalData());
- if( aRange.equals( lcl_aCategoriesRangeName ))
+ if( aRange.match( lcl_aLabelRangePrefix ) )
{
- vector< OUString > aCategories( m_bDataInColumns ? rData.getRowLabels() : rData.getColumnLabels());
- aResult.realloc( aCategories.size());
- transform( aCategories.begin(), aCategories.end(),
- aResult.getArray(), CommonFunctors::makeAny< OUString >());
+ sal_Int32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
+ vector< OUString > aComplexLabel = m_bDataInColumns
+ ? m_aInternalData.getComplexColumnLabel( nIndex )
+ : m_aInternalData.getComplexRowLabel( nIndex );
+ if( !aComplexLabel.empty() )
+ {
+ aResult.realloc( aComplexLabel.size() );
+ transform( aComplexLabel.begin(), aComplexLabel.end(),
+ aResult.getArray(), CommonFunctors::makeAny< OUString >());
+ }
}
- else if( aRange.match( lcl_aLabelRangePrefix ))
+ else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) )
{
- sal_Int32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
- vector< OUString > aLabels( m_bDataInColumns ? rData.getColumnLabels() : rData.getRowLabels());
- if( nIndex < static_cast< sal_Int32 >( aLabels.size()))
+ sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesPointRangeNamePrefix.getLength() ).toInt32();
+ vector< OUString > aComplexCategory = m_bDataInColumns
+ ? m_aInternalData.getComplexRowLabel( nPointIndex )
+ : m_aInternalData.getComplexColumnLabel( nPointIndex );
+ if( !aComplexCategory.empty() )
{
- aResult.realloc( 1 );
- aResult[0] = uno::makeAny( aLabels[ nIndex ] );
+ aResult.realloc( aComplexCategory.size() );
+ transform( aComplexCategory.begin(), aComplexCategory.end(),
+ aResult.getArray(), CommonFunctors::makeAny< OUString >());
}
}
+ else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) )
+ {
+ sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength() ).toInt32();
+ vector< vector< OUString > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
+ if( nLevel < lcl_getInnerLevelCount( aCategories ) )
+ {
+ aResult.realloc( aCategories.size() );
+ transform( aCategories.begin(), aCategories.end(),
+ aResult.getArray(), lcl_makeAnyFromLevelVector(nLevel) );
+ }
+ }
+ else if( aRange.equals( lcl_aCategoriesRangeName ) )
+ {
+ Sequence< OUString > aLabels = m_bDataInColumns ? this->getRowDescriptions() : this->getColumnDescriptions();
+ aResult.realloc( aLabels.getLength() );
+ transform( aLabels.getConstArray(), aLabels.getConstArray() + aLabels.getLength(),
+ aResult.getArray(), CommonFunctors::makeAny< OUString >() );
+ }
else
{
sal_Int32 nIndex = aRange.toInt32();
- if( nIndex < (m_bDataInColumns ? rData.getColumnCount() : rData.getRowCount()))
+ if( nIndex >= 0 )
{
- Sequence< double > aData( rData.getDataAt( nIndex, m_bDataInColumns ));
- aResult.realloc( aData.getLength());
- transform( aData.getConstArray(), aData.getConstArray() + aData.getLength(),
- aResult.getArray(), CommonFunctors::makeAny< double >());
+ Sequence< double > aData;
+ if( m_bDataInColumns )
+ aData = m_aInternalData.getColumnValues(nIndex);
+ else
+ aData = m_aInternalData.getRowValues(nIndex);
+ if( aData.getLength() )
+ {
+ aResult.realloc( aData.getLength());
+ transform( aData.getConstArray(), aData.getConstArray() + aData.getLength(),
+ aResult.getArray(), CommonFunctors::makeAny< double >());
+ }
}
}
@@ -1184,61 +798,63 @@ void SAL_CALL InternalDataProvider::setDataByRangeRepresentation(
const OUString& aRange, const Sequence< uno::Any >& aNewData )
throw (uno::RuntimeException)
{
- impl::InternalData & rData( getInternalData());
-
- if( aRange.equals( lcl_aCategoriesRangeName ))
+ if( aRange.match( lcl_aLabelRangePrefix ) )
+ {
+ vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) );
+ sal_uInt32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
+ if( m_bDataInColumns )
+ m_aInternalData.setComplexColumnLabel( nIndex, aNewStrings );
+ else
+ m_aInternalData.setComplexRowLabel( nIndex, aNewStrings );
+ }
+ else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) )
{
- vector< OUString > aCategories;
- transform( aNewData.getConstArray(), aNewData.getConstArray() + aNewData.getLength(),
- back_inserter( aCategories ), CommonFunctors::AnyToString());
+ vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) );
+ sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32();
+ if( m_bDataInColumns )
+ m_aInternalData.setComplexRowLabel( nPointIndex, aNewStrings );
+ else
+ m_aInternalData.setComplexColumnLabel( nPointIndex, aNewStrings );
+ }
+ else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) )
+ {
+ vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) );
+ sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32();
+ vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
+
+ //ensure equal length
+ if( aNewStrings.size() > aComplexCategories.size() )
+ aComplexCategories.resize( aNewStrings.size() );
+ else if( aNewStrings.size() < aComplexCategories.size() )
+ aNewStrings.resize( aComplexCategories.size() );
+
+ transform( aComplexCategories.begin(), aComplexCategories.end(), aNewStrings.begin(),
+ aComplexCategories.begin(), lcl_setStringAtLevel(nLevel) );
if( m_bDataInColumns )
- rData.setRowLabels( aCategories );
+ m_aInternalData.setComplexRowLabels( aComplexCategories );
else
- rData.setColumnLabels( aCategories );
+ m_aInternalData.setComplexColumnLabels( aComplexCategories );
}
- else if( aRange.match( lcl_aLabelRangePrefix ))
+ else if( aRange.equals( lcl_aCategoriesRangeName ) )
{
- sal_uInt32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
- OUString aNewLabel;
- if( aNewData.getLength() &&
- (aNewData[0] >>= aNewLabel))
- {
- if( m_bDataInColumns )
- {
- vector< OUString > aLabels( rData.getColumnLabels());
- if ( aLabels.size() <= nIndex )
- aLabels.push_back(aNewLabel);
- else
- aLabels[ nIndex ] = aNewLabel;
- rData.setColumnLabels( aLabels );
- }
- else
- {
- vector< OUString > aLabels( rData.getRowLabels());
- if ( aLabels.size() <= nIndex )
- aLabels.push_back(aNewLabel);
- else
- aLabels[ nIndex ] = aNewLabel;
- rData.setRowLabels( aLabels );
- }
- }
+ if( m_bDataInColumns )
+ this->setRowDescriptions( lcl_AnyToStringSequence(aNewData) );
+ else
+ this->setColumnDescriptions( lcl_AnyToStringSequence(aNewData) );
}
else
{
sal_Int32 nIndex = aRange.toInt32();
- // ensure that the data is large enough
- if( m_bDataInColumns )
- rData.enlargeData( nIndex, 0 );
- else
- rData.enlargeData( 0, nIndex );
-
- if( nIndex < (m_bDataInColumns ? rData.getColumnCount() : rData.getRowCount()))
+ if( nIndex>=0 )
{
vector< double > aNewDataVec;
transform( aNewData.getConstArray(), aNewData.getConstArray() + aNewData.getLength(),
back_inserter( aNewDataVec ), CommonFunctors::AnyToDouble());
- rData.setDataAt( nIndex, m_bDataInColumns, aNewDataVec );
+ if( m_bDataInColumns )
+ m_aInternalData.setColumnValues( nIndex, aNewDataVec );
+ else
+ m_aInternalData.setRowValues( nIndex, aNewDataVec );
}
}
}
@@ -1248,30 +864,30 @@ void SAL_CALL InternalDataProvider::insertSequence( ::sal_Int32 nAfterIndex )
{
if( m_bDataInColumns )
{
- increaseMapReferences( nAfterIndex + 1, getInternalData().getColumnCount());
- getInternalData().insertColumn( nAfterIndex );
+ lcl_increaseMapReferences( nAfterIndex + 1, m_aInternalData.getColumnCount());
+ m_aInternalData.insertColumn( nAfterIndex );
}
else
{
- increaseMapReferences( nAfterIndex + 1, getInternalData().getRowCount());
- getInternalData().insertRow( nAfterIndex );
+ lcl_increaseMapReferences( nAfterIndex + 1, m_aInternalData.getRowCount());
+ m_aInternalData.insertRow( nAfterIndex );
}
}
void SAL_CALL InternalDataProvider::deleteSequence( ::sal_Int32 nAtIndex )
throw (uno::RuntimeException)
{
- deleteMapReferences( OUString::valueOf( nAtIndex ));
- deleteMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nAtIndex ));
+ lcl_deleteMapReferences( OUString::valueOf( nAtIndex ));
+ lcl_deleteMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nAtIndex ));
if( m_bDataInColumns )
{
- decreaseMapReferences( nAtIndex + 1, getInternalData().getColumnCount());
- getInternalData().deleteColumn( nAtIndex );
+ lcl_decreaseMapReferences( nAtIndex + 1, m_aInternalData.getColumnCount());
+ m_aInternalData.deleteColumn( nAtIndex );
}
else
{
- decreaseMapReferences( nAtIndex + 1, getInternalData().getRowCount());
- getInternalData().deleteRow( nAtIndex );
+ lcl_decreaseMapReferences( nAtIndex + 1, m_aInternalData.getRowCount());
+ m_aInternalData.deleteRow( nAtIndex );
}
}
@@ -1279,9 +895,44 @@ void SAL_CALL InternalDataProvider::appendSequence()
throw (uno::RuntimeException)
{
if( m_bDataInColumns )
- getInternalData().appendColumn();
+ m_aInternalData.appendColumn();
else
- getInternalData().appendRow();
+ m_aInternalData.appendRow();
+}
+
+void SAL_CALL InternalDataProvider::insertComplexCategoryLevel( sal_Int32 nLevel )
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( nLevel> 0, "you can only insert category levels > 0" );//the first categories level cannot be deleted, check the calling code for error
+ if( nLevel>0 )
+ {
+ vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
+ ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_insertStringAtLevel(nLevel) );
+ if( m_bDataInColumns )
+ m_aInternalData.setComplexRowLabels( aComplexCategories );
+ else
+ m_aInternalData.setComplexColumnLabels( aComplexCategories );
+
+ tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
+ ::std::for_each( aRange.first, aRange.second, lcl_setModified());
+ }
+}
+void SAL_CALL InternalDataProvider::deleteComplexCategoryLevel( sal_Int32 nLevel )
+ throw (uno::RuntimeException)
+{
+ OSL_ENSURE( nLevel>0, "you can only delete category levels > 0" );//the first categories level cannot be deleted, check the calling code for error
+ if( nLevel>0 )
+ {
+ vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
+ ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_removeStringAtLevel(nLevel) );
+ if( m_bDataInColumns )
+ m_aInternalData.setComplexRowLabels( aComplexCategories );
+ else
+ m_aInternalData.setComplexColumnLabels( aComplexCategories );
+
+ tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
+ ::std::for_each( aRange.first, aRange.second, lcl_setModified());
+ }
}
void SAL_CALL InternalDataProvider::insertDataPointForAllSequences( ::sal_Int32 nAfterIndex )
@@ -1290,22 +941,22 @@ void SAL_CALL InternalDataProvider::insertDataPointForAllSequences( ::sal_Int32
sal_Int32 nMaxRep = 0;
if( m_bDataInColumns )
{
- getInternalData().insertRow( nAfterIndex );
- nMaxRep = getInternalData().getColumnCount();
+ m_aInternalData.insertRow( nAfterIndex );
+ nMaxRep = m_aInternalData.getColumnCount();
}
else
{
- getInternalData().insertColumn( nAfterIndex );
- nMaxRep = getInternalData().getRowCount();
+ m_aInternalData.insertColumn( nAfterIndex );
+ nMaxRep = m_aInternalData.getRowCount();
}
// notify change to all affected ranges
tSequenceMap::const_iterator aBegin( m_aSequenceMap.lower_bound( C2U("0")));
tSequenceMap::const_iterator aEnd( m_aSequenceMap.upper_bound( OUString::valueOf( nMaxRep )));
- ::std::for_each( aBegin, aEnd, lcl_modifySeqMapValue());
+ ::std::for_each( aBegin, aEnd, lcl_setModified());
tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
- ::std::for_each( aRange.first, aRange.second, lcl_modifySeqMapValue());
+ ::std::for_each( aRange.first, aRange.second, lcl_setModified());
}
void SAL_CALL InternalDataProvider::deleteDataPointForAllSequences( ::sal_Int32 nAtIndex )
@@ -1314,46 +965,49 @@ void SAL_CALL InternalDataProvider::deleteDataPointForAllSequences( ::sal_Int32
sal_Int32 nMaxRep = 0;
if( m_bDataInColumns )
{
- getInternalData().deleteRow( nAtIndex );
- nMaxRep = getInternalData().getColumnCount();
+ m_aInternalData.deleteRow( nAtIndex );
+ nMaxRep = m_aInternalData.getColumnCount();
}
else
{
- getInternalData().deleteColumn( nAtIndex );
- nMaxRep = getInternalData().getRowCount();
+ m_aInternalData.deleteColumn( nAtIndex );
+ nMaxRep = m_aInternalData.getRowCount();
}
// notify change to all affected ranges
tSequenceMap::const_iterator aBegin( m_aSequenceMap.lower_bound( C2U("0")));
tSequenceMap::const_iterator aEnd( m_aSequenceMap.upper_bound( OUString::valueOf( nMaxRep )));
- ::std::for_each( aBegin, aEnd, lcl_modifySeqMapValue());
+ ::std::for_each( aBegin, aEnd, lcl_setModified());
tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
- ::std::for_each( aRange.first, aRange.second, lcl_modifySeqMapValue());
+ ::std::for_each( aRange.first, aRange.second, lcl_setModified());
}
void SAL_CALL InternalDataProvider::swapDataPointWithNextOneForAllSequences( ::sal_Int32 nAtIndex )
throw (uno::RuntimeException)
{
- getInternalData().swapAllDataAtIndexWithNext( nAtIndex, m_bDataInColumns );
+ if( m_bDataInColumns )
+ m_aInternalData.swapRowWithNext( nAtIndex );
+ else
+ m_aInternalData.swapColumnWithNext( nAtIndex );
sal_Int32 nMaxRep = (m_bDataInColumns
- ? getInternalData().getColumnCount()
- : getInternalData().getRowCount());
+ ? m_aInternalData.getColumnCount()
+ : m_aInternalData.getRowCount());
// notify change to all affected ranges
tSequenceMap::const_iterator aBegin( m_aSequenceMap.lower_bound( C2U("0")));
tSequenceMap::const_iterator aEnd( m_aSequenceMap.upper_bound( OUString::valueOf( nMaxRep )));
- ::std::for_each( aBegin, aEnd, lcl_modifySeqMapValue());
+ ::std::for_each( aBegin, aEnd, lcl_setModified());
tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
- ::std::for_each( aRange.first, aRange.second, lcl_modifySeqMapValue());
+ ::std::for_each( aRange.first, aRange.second, lcl_setModified());
}
void SAL_CALL InternalDataProvider::registerDataSequenceForChanges( const Reference< chart2::data::XDataSequence >& xSeq )
throw (uno::RuntimeException)
{
if( xSeq.is())
- addDataSequenceToMap( xSeq->getSourceRangeRepresentation(), xSeq );
+ lcl_addDataSequenceToMap( xSeq->getSourceRangeRepresentation(), xSeq );
}
@@ -1364,28 +1018,28 @@ OUString SAL_CALL InternalDataProvider::convertRangeToXML( const OUString& aRang
{
XMLRangeHelper::CellRange aRange;
aRange.aTableName = OUString(RTL_CONSTASCII_USTRINGPARAM("local-table"));
- impl::InternalData & rData( getInternalData());
// attention: this data provider has the limitation that it stores
// internally if data comes from columns or rows. It is intended for
// creating only one used data source.
// @todo: add this information in the range representation strings
- if( aRangeRepresentation.equals( lcl_aCategoriesRangeName ))
+ if( aRangeRepresentation.match( lcl_aCategoriesRangeName ))
{
+ OSL_ASSERT( aRangeRepresentation.equals( lcl_aCategoriesRangeName ) );//it is not expected nor implmented that only parts of the categories are really requested
aRange.aUpperLeft.bIsEmpty = false;
if( m_bDataInColumns )
{
aRange.aUpperLeft.nColumn = 0;
aRange.aUpperLeft.nRow = 1;
aRange.aLowerRight = aRange.aUpperLeft;
- aRange.aLowerRight.nRow = rData.getRowCount();
+ aRange.aLowerRight.nRow = m_aInternalData.getRowCount();
}
else
{
aRange.aUpperLeft.nColumn = 1;
aRange.aUpperLeft.nRow = 0;
aRange.aLowerRight = aRange.aUpperLeft;
- aRange.aLowerRight.nColumn = rData.getColumnCount();
+ aRange.aLowerRight.nColumn = m_aInternalData.getColumnCount();
}
}
else if( aRangeRepresentation.match( lcl_aLabelRangePrefix ))
@@ -1410,8 +1064,8 @@ OUString SAL_CALL InternalDataProvider::convertRangeToXML( const OUString& aRang
aRange.aLowerRight.bIsEmpty = false;
aRange.aUpperLeft.nColumn = 0;
aRange.aUpperLeft.nRow = 0;
- aRange.aLowerRight.nColumn = rData.getColumnCount();
- aRange.aLowerRight.nRow = rData.getRowCount();
+ aRange.aLowerRight.nColumn = m_aInternalData.getColumnCount();
+ aRange.aLowerRight.nRow = m_aInternalData.getRowCount();
}
else
{
@@ -1422,14 +1076,14 @@ OUString SAL_CALL InternalDataProvider::convertRangeToXML( const OUString& aRang
aRange.aUpperLeft.nColumn = nIndex + 1;
aRange.aUpperLeft.nRow = 1;
aRange.aLowerRight = aRange.aUpperLeft;
- aRange.aLowerRight.nRow = rData.getRowCount();
+ aRange.aLowerRight.nRow = m_aInternalData.getRowCount();
}
else
{
aRange.aUpperLeft.nColumn = 1;
aRange.aUpperLeft.nRow = nIndex + 1;
aRange.aLowerRight = aRange.aUpperLeft;
- aRange.aLowerRight.nColumn = rData.getColumnCount();
+ aRange.aLowerRight.nColumn = m_aInternalData.getColumnCount();
}
}
@@ -1478,46 +1132,130 @@ OUString SAL_CALL InternalDataProvider::convertRangeFromXML( const OUString& aXM
return OUString::valueOf( aRange.aUpperLeft.nRow - 1 );
}
+namespace
+{
+Sequence< Sequence< OUString > > lcl_convertComplexVectorToSequence( const vector< vector< OUString > >& rIn )
+{
+ Sequence< Sequence< OUString > > aRet;
+ sal_Int32 nOuterCount = rIn.size();
+ if( nOuterCount )
+ {
+ aRet.realloc(nOuterCount);
+ for( sal_Int32 nN=0; nN<nOuterCount; nN++)
+ aRet[nN]=ContainerHelper::ContainerToSequence( rIn[nN] );
+ }
+ return aRet;
+}
+
+vector< vector< OUString > > lcl_convertComplexSequenceToVector( const Sequence< Sequence< OUString > >& rIn )
+{
+ vector< vector< OUString > > aRet;
+ sal_Int32 nOuterCount = rIn.getLength();
+ for( sal_Int32 nN=0; nN<nOuterCount; nN++)
+ aRet.push_back( ContainerHelper::SequenceToVector( rIn[nN] ) );
+ return aRet;
+}
+
+class SplitCategoriesProvider_ForComplexDescriptions : public SplitCategoriesProvider
+{
+public:
+
+ explicit SplitCategoriesProvider_ForComplexDescriptions( const ::std::vector< ::std::vector< ::rtl::OUString > >& rComplexDescriptions )
+ : m_rComplexDescriptions( rComplexDescriptions )
+ {}
+ virtual ~SplitCategoriesProvider_ForComplexDescriptions()
+ {}
+
+ virtual sal_Int32 getLevelCount() const;
+ virtual uno::Sequence< rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const;
+
+private:
+ const ::std::vector< ::std::vector< ::rtl::OUString > >& m_rComplexDescriptions;
+};
+
+sal_Int32 SplitCategoriesProvider_ForComplexDescriptions::getLevelCount() const
+{
+ return lcl_getInnerLevelCount( m_rComplexDescriptions );
+}
+uno::Sequence< rtl::OUString > SplitCategoriesProvider_ForComplexDescriptions::getStringsForLevel( sal_Int32 nLevel ) const
+{
+ uno::Sequence< rtl::OUString > aResult;
+ if( nLevel < lcl_getInnerLevelCount( m_rComplexDescriptions ) )
+ {
+ aResult.realloc( m_rComplexDescriptions.size() );
+ transform( m_rComplexDescriptions.begin(), m_rComplexDescriptions.end(),
+ aResult.getArray(), lcl_getStringFromLevelVector(nLevel) );
+ }
+ return aResult;
+}
+
+}//anonymous namespace
+
+// ____ XComplexDescriptionAccess ____
+Sequence< Sequence< OUString > > SAL_CALL InternalDataProvider::getComplexRowDescriptions() throw (uno::RuntimeException)
+{
+ return lcl_convertComplexVectorToSequence( m_aInternalData.getComplexRowLabels() );
+}
+void SAL_CALL InternalDataProvider::setComplexRowDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aRowDescriptions ) throw (uno::RuntimeException)
+{
+ m_aInternalData.setComplexRowLabels( lcl_convertComplexSequenceToVector(aRowDescriptions) );
+}
+Sequence< Sequence< ::rtl::OUString > > SAL_CALL InternalDataProvider::getComplexColumnDescriptions() throw (uno::RuntimeException)
+{
+ return lcl_convertComplexVectorToSequence( m_aInternalData.getComplexColumnLabels() );
+}
+void SAL_CALL InternalDataProvider::setComplexColumnDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aColumnDescriptions ) throw (uno::RuntimeException)
+{
+ m_aInternalData.setComplexColumnLabels( lcl_convertComplexSequenceToVector(aColumnDescriptions) );
+}
+
// ____ XChartDataArray ____
-// note: do not use m_bDataInColumns for all XChartDataArray-specific code
-// the chart-API assumes data is always in rows
Sequence< Sequence< double > > SAL_CALL InternalDataProvider::getData()
throw (uno::RuntimeException)
{
- return getInternalData().getData( false );
+ return m_aInternalData.getData();
}
-void SAL_CALL InternalDataProvider::setData( const Sequence< Sequence< double > >& aData )
+void SAL_CALL InternalDataProvider::setData( const Sequence< Sequence< double > >& rDataInRows )
throw (uno::RuntimeException)
{
- return getInternalData().setData( aData, false );
+ return m_aInternalData.setData( rDataInRows );
}
-Sequence< OUString > SAL_CALL InternalDataProvider::getRowDescriptions()
+void SAL_CALL InternalDataProvider::setRowDescriptions( const Sequence< OUString >& aRowDescriptions )
throw (uno::RuntimeException)
{
- return ContainerHelper::ContainerToSequence( getInternalData().getRowLabels());
+ vector< vector< OUString > > aComplexDescriptions( aRowDescriptions.getLength() );
+ transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aRowDescriptions.getConstArray(),
+ aComplexDescriptions.begin(), lcl_setStringAtLevel(0) );
+ m_aInternalData.setComplexRowLabels( aComplexDescriptions );
}
-void SAL_CALL InternalDataProvider::setRowDescriptions( const Sequence< OUString >& aRowDescriptions )
+void SAL_CALL InternalDataProvider::setColumnDescriptions( const Sequence< OUString >& aColumnDescriptions )
throw (uno::RuntimeException)
{
- getInternalData().setRowLabels( ContainerHelper::SequenceToVector( aRowDescriptions ));
+ vector< vector< OUString > > aComplexDescriptions( aColumnDescriptions.getLength() );
+ transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aColumnDescriptions.getConstArray(),
+ aComplexDescriptions.begin(), lcl_setStringAtLevel(0) );
+ m_aInternalData.setComplexColumnLabels( aComplexDescriptions );
}
-Sequence< OUString > SAL_CALL InternalDataProvider::getColumnDescriptions()
+Sequence< OUString > SAL_CALL InternalDataProvider::getRowDescriptions()
throw (uno::RuntimeException)
{
- return ContainerHelper::ContainerToSequence( getInternalData().getColumnLabels());
+ vector< vector< OUString > > aComplexLabels( m_aInternalData.getComplexRowLabels() );
+ SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels );
+ return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider );
}
-void SAL_CALL InternalDataProvider::setColumnDescriptions( const Sequence< OUString >& aColumnDescriptions )
+Sequence< OUString > SAL_CALL InternalDataProvider::getColumnDescriptions()
throw (uno::RuntimeException)
{
- getInternalData().setColumnLabels( ContainerHelper::SequenceToVector( aColumnDescriptions ));
+ vector< vector< OUString > > aComplexLabels( m_aInternalData.getComplexColumnLabels() );
+ SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels );
+ return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider );
}
-
// ____ XChartData (base of XChartDataArray) ____
void SAL_CALL InternalDataProvider::addChartDataChangeEventListener(
const Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& )
diff --git a/chart2/source/tools/makefile.mk b/chart2/source/tools/makefile.mk
index 2b6e0cf518c1..2f990af7adb0 100644
--- a/chart2/source/tools/makefile.mk
+++ b/chart2/source/tools/makefile.mk
@@ -64,6 +64,7 @@ SLOFILES= \
$(SLO)$/DiagramHelper.obj \
$(SLO)$/ExponentialRegressionCurveCalculator.obj \
$(SLO)$/ImplOPropertySet.obj \
+ $(SLO)$/InternalData.obj \
$(SLO)$/InternalDataProvider.obj \
$(SLO)$/LabeledDataSequence.obj \
$(SLO)$/LinearRegressionCurveCalculator.obj \
diff --git a/chart2/source/view/axes/TickmarkHelper.cxx b/chart2/source/view/axes/TickmarkHelper.cxx
index 20f452431492..4d1f48795fa7 100644
--- a/chart2/source/view/axes/TickmarkHelper.cxx
+++ b/chart2/source/view/axes/TickmarkHelper.cxx
@@ -48,6 +48,7 @@ TickInfo::TickInfo()
, aTickScreenPosition(0.0,0.0)
, bPaintIt( true )
, xTextShape( NULL )
+, nFactorForLimitedTextWidth(1)
{
}
@@ -59,10 +60,45 @@ void TickInfo::updateUnscaledValue( const uno::Reference< XScaling >& xInverseSc
this->fUnscaledTickValue = this->fScaledTickValue;
}
-TickIter::TickIter( const uno::Sequence< uno::Sequence< double > >& rTicks
+sal_Int32 TickInfo::getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const
+{
+ //return the positive distance between the two first tickmarks in screen values
+
+ B2DVector aDistance = rOherTickInfo.aTickScreenPosition - aTickScreenPosition;
+ sal_Int32 nRet = static_cast<sal_Int32>(aDistance.getLength());
+ if(nRet<0)
+ nRet *= -1;
+ return nRet;
+}
+
+PureTickIter::PureTickIter( ::std::vector< TickInfo >& rTickInfoVector )
+ : m_rTickVector(rTickInfoVector)
+ , m_aTickIter(m_rTickVector.begin())
+{
+}
+PureTickIter::~PureTickIter()
+{
+}
+TickInfo* PureTickIter::firstInfo()
+{
+ m_aTickIter = m_rTickVector.begin();
+ if(m_aTickIter!=m_rTickVector.end())
+ return &*m_aTickIter;
+ return 0;
+}
+TickInfo* PureTickIter::nextInfo()
+{
+ m_aTickIter++;
+ if(m_aTickIter!=m_rTickVector.end())
+ return &*m_aTickIter;
+ return 0;
+}
+
+EquidistantTickIter::EquidistantTickIter( const uno::Sequence< uno::Sequence< double > >& rTicks
, const ExplicitIncrementData& rIncrement
, sal_Int32 nMinDepth, sal_Int32 nMaxDepth )
- : m_pSimpleTicks(&rTicks), m_pInfoTicks(NULL)
+ : m_pSimpleTicks(&rTicks)
+ , m_pInfoTicks(0)
, m_rIncrement(rIncrement)
, m_nMinDepth(0), m_nMaxDepth(0)
, m_nTickCount(0), m_pnPositions(NULL)
@@ -72,10 +108,11 @@ TickIter::TickIter( const uno::Sequence< uno::Sequence< double > >& rTicks
initIter( nMinDepth, nMaxDepth );
}
-TickIter::TickIter( ::std::vector< ::std::vector< TickInfo > >& rTicks
+EquidistantTickIter::EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTicks
, const ExplicitIncrementData& rIncrement
, sal_Int32 nMinDepth, sal_Int32 nMaxDepth )
- : m_pSimpleTicks(NULL), m_pInfoTicks(&rTicks)
+ : m_pSimpleTicks(NULL)
+ , m_pInfoTicks(&rTicks)
, m_rIncrement(rIncrement)
, m_nMinDepth(0), m_nMaxDepth(0)
, m_nTickCount(0), m_pnPositions(NULL)
@@ -85,7 +122,7 @@ TickIter::TickIter( ::std::vector< ::std::vector< TickInfo > >& rTicks
initIter( nMinDepth, nMaxDepth );
}
-void TickIter::initIter( sal_Int32 /*nMinDepth*/, sal_Int32 nMaxDepth )
+void EquidistantTickIter::initIter( sal_Int32 /*nMinDepth*/, sal_Int32 nMaxDepth )
{
m_nMaxDepth = nMaxDepth;
if(nMaxDepth<0 || m_nMaxDepth>getMaxDepth())
@@ -128,14 +165,14 @@ void TickIter::initIter( sal_Int32 /*nMinDepth*/, sal_Int32 nMaxDepth )
}
}
-TickIter::~TickIter()
+EquidistantTickIter::~EquidistantTickIter()
{
delete[] m_pnPositions;
delete[] m_pnPreParentCount;
delete[] m_pbIntervalFinished;
}
-sal_Int32 TickIter::getStartDepth() const
+sal_Int32 EquidistantTickIter::getStartDepth() const
{
//find the depth of the first visible tickmark:
//it is the depth of the smallest value
@@ -156,7 +193,7 @@ sal_Int32 TickIter::getStartDepth() const
return nReturnDepth;
}
-double* TickIter::firstValue()
+double* EquidistantTickIter::firstValue()
{
if( gotoFirst() )
{
@@ -166,14 +203,14 @@ double* TickIter::firstValue()
return NULL;
}
-TickInfo* TickIter::firstInfo()
+TickInfo* EquidistantTickIter::firstInfo()
{
if( m_pInfoTicks && gotoFirst() )
return &(*m_pInfoTicks)[m_nCurrentDepth][m_pnPositions[m_nCurrentDepth]];
return NULL;
}
-sal_Int32 TickIter::getIntervalCount( sal_Int32 nDepth )
+sal_Int32 EquidistantTickIter::getIntervalCount( sal_Int32 nDepth )
{
if(nDepth>m_rIncrement.SubIncrements.getLength() || nDepth<0)
return 0;
@@ -184,7 +221,7 @@ sal_Int32 TickIter::getIntervalCount( sal_Int32 nDepth )
return m_rIncrement.SubIncrements[nDepth-1].IntervalCount;
}
-bool TickIter::isAtLastPartTick()
+bool EquidistantTickIter::isAtLastPartTick()
{
if(!m_nCurrentDepth)
return false;
@@ -203,7 +240,7 @@ bool TickIter::isAtLastPartTick()
return bRet;
}
-bool TickIter::gotoFirst()
+bool EquidistantTickIter::gotoFirst()
{
if( m_nMaxDepth<0 )
return false;
@@ -219,7 +256,7 @@ bool TickIter::gotoFirst()
return true;
}
-bool TickIter::gotoNext()
+bool EquidistantTickIter::gotoNext()
{
if( m_nCurrentPos < 0 )
return false;
@@ -250,7 +287,7 @@ bool TickIter::gotoNext()
return true;
}
-bool TickIter::gotoIndex( sal_Int32 nTickIndex )
+bool EquidistantTickIter::gotoIndex( sal_Int32 nTickIndex )
{
if( nTickIndex < 0 )
return false;
@@ -268,16 +305,16 @@ bool TickIter::gotoIndex( sal_Int32 nTickIndex )
return true;
}
-sal_Int32 TickIter::getCurrentIndex() const
+sal_Int32 EquidistantTickIter::getCurrentIndex() const
{
return m_nCurrentPos;
}
-sal_Int32 TickIter::getMaxIndex() const
+sal_Int32 EquidistantTickIter::getMaxIndex() const
{
return m_nTickCount-1;
}
-double* TickIter::nextValue()
+double* EquidistantTickIter::nextValue()
{
if( gotoNext() )
{
@@ -287,7 +324,7 @@ double* TickIter::nextValue()
return NULL;
}
-TickInfo* TickIter::nextInfo()
+TickInfo* EquidistantTickIter::nextInfo()
{
if( m_pInfoTicks && gotoNext() &&
static_cast< sal_Int32 >(
@@ -646,7 +683,7 @@ void TickmarkHelper::getAllTicksShifted( ::std::vector< ::std::vector< TickInfo
void TickmarkHelper::addSubTicks( sal_Int32 nDepth, uno::Sequence< uno::Sequence< double > >& rParentTicks ) const
{
- TickIter aIter( rParentTicks, m_rIncrement, 0, nDepth-1 );
+ EquidistantTickIter aIter( rParentTicks, m_rIncrement, 0, nDepth-1 );
double* pfNextParentTick = aIter.firstValue();
if(!pfNextParentTick)
return;
@@ -753,11 +790,7 @@ sal_Int32 TickmarkHelper_2D::getTickScreenDistance( TickIter& rIter )
if(!pSecondTickInfo || !pFirstTickInfo)
return -1;
- B2DVector aDistance = pSecondTickInfo->aTickScreenPosition-pFirstTickInfo->aTickScreenPosition;
- sal_Int32 nRet = static_cast<sal_Int32>(aDistance.getLength());
- if(nRet<0)
- nRet *= -1;
- return nRet;
+ return pFirstTickInfo->getScreenDistanceBetweenTicks( *pSecondTickInfo );
}
B2DVector TickmarkHelper_2D::getTickScreenPosition2D( double fScaledLogicTickValue ) const
@@ -797,7 +830,7 @@ void TickmarkHelper_2D::addPointSequenceForTickLine( drawing::PointSequenceSeque
rPoints[nSequenceIndex][1].Y = static_cast<sal_Int32>(aEnd.getY());
}
-B2DVector TickmarkHelper_2D::getDistanceAxisTickToText( const AxisProperties& rAxisProperties ) const
+B2DVector TickmarkHelper_2D::getDistanceAxisTickToText( const AxisProperties& rAxisProperties, bool bIncludeFarAwayDistanceIfSo, bool bIncludeSpaceBetweenTickAndText ) const
{
bool bFarAwayLabels = false;
if( ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START == rAxisProperties.m_eLabelPos
@@ -843,8 +876,9 @@ B2DVector TickmarkHelper_2D::getDistanceAxisTickToText( const AxisProperties& rA
if( rAxisProperties.m_fInnerDirectionSign != rAxisProperties.m_fLabelDirectionSign )
aOrthoLabelDirection*=-1.0;
aOrthoLabelDirection.normalize();
- aLabelDirection += aOrthoLabelDirection*AXIS2D_TICKLABELSPACING;
- if( bFarAwayLabels )
+ if( bIncludeSpaceBetweenTickAndText )
+ aLabelDirection += aOrthoLabelDirection*AXIS2D_TICKLABELSPACING;
+ if( bFarAwayLabels && bIncludeFarAwayDistanceIfSo )
aLabelDirection += m_aAxisLineToLabelLineShift;
return aLabelDirection;
}
@@ -876,27 +910,6 @@ void TickmarkHelper_2D::updateScreenValues( ::std::vector< ::std::vector< TickIn
}
}
-//'hide' tickmarks with identical screen values in aAllTickInfos
-void TickmarkHelper_2D::hideIdenticalScreenValues(
- ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const
-{
- TickIter aIter( rAllTickInfos, m_rIncrement );
-
- TickInfo* pPreviousTickInfo = aIter.firstInfo();
- if(!pPreviousTickInfo)
- return;
- pPreviousTickInfo->bPaintIt = true;
- for( TickInfo* pTickInfo = aIter.nextInfo(); pTickInfo; pTickInfo = aIter.nextInfo())
- {
- pTickInfo->bPaintIt =
- ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getX())
- != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getX()) )
- ||
- ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getY())
- != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getY()) );
- pPreviousTickInfo = pTickInfo;
- }
-}
//-----------------------------------------------------------------------------
// ___TickmarkHelper_3D___
//-----------------------------------------------------------------------------
diff --git a/chart2/source/view/axes/TickmarkHelper.hxx b/chart2/source/view/axes/TickmarkHelper.hxx
index 01ca56982b3e..78fc2fe1c502 100644
--- a/chart2/source/view/axes/TickmarkHelper.hxx
+++ b/chart2/source/view/axes/TickmarkHelper.hxx
@@ -59,23 +59,48 @@ struct TickInfo
::com::sun::star::uno::Reference<
::com::sun::star::drawing::XShape > xTextShape;
+ rtl::OUString aText;//used only for complex categories so far
+ sal_Int32 nFactorForLimitedTextWidth;//categories in higher levels of complex categories can have more place than a single simple category
+
//methods:
TickInfo();
void updateUnscaledValue( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XScaling >& xInverseScaling );
-};
+ sal_Int32 getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const;
+};
class TickIter
{
public:
- TickIter( const ::com::sun::star::uno::Sequence<
+ virtual ~TickIter(){};
+ virtual TickInfo* firstInfo()=0;
+ virtual TickInfo* nextInfo()=0;
+};
+
+class PureTickIter : public TickIter
+{
+public:
+ PureTickIter( ::std::vector< TickInfo >& rTickInfoVector );
+ virtual ~PureTickIter();
+ virtual TickInfo* firstInfo();
+ virtual TickInfo* nextInfo();
+
+private:
+ ::std::vector< TickInfo >& m_rTickVector;
+ ::std::vector< TickInfo >::iterator m_aTickIter;
+};
+
+class EquidistantTickIter : public TickIter
+{
+public:
+ EquidistantTickIter( const ::com::sun::star::uno::Sequence<
::com::sun::star::uno::Sequence< double > >& rTicks
, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement
, sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 );
- TickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
+ EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement
, sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 );
- virtual ~TickIter();
+ virtual ~EquidistantTickIter();
virtual double* firstValue();
virtual double* nextValue();
@@ -171,7 +196,6 @@ protected: //methods
bool isWithinOuterBorder( double fScaledValue ) const; //all within the outer major tick marks
virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& /*rAllTickInfos*/ ) const {}
- virtual void hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& /*rAllTickInfos*/ ) const {}
protected: //member
::com::sun::star::chart2::ExplicitScaleData m_rScale;
@@ -211,10 +235,11 @@ public:
, sal_Int32 nSequenceIndex
, double fScaledLogicTickValue, double fInnerDirectionSign
, const TickmarkProperties& rTickmarkProperties, bool bPlaceAtLabels ) const;
- ::basegfx::B2DVector getDistanceAxisTickToText( const AxisProperties& rAxisProperties ) const;
+ ::basegfx::B2DVector getDistanceAxisTickToText( const AxisProperties& rAxisProperties
+ , bool bIncludeFarAwayDistanceIfSo = false
+ , bool bIncludeSpaceBetweenTickAndText = true ) const;
virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
- virtual void hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
bool isHorizontalAxis() const;
bool isVerticalAxis() const;
diff --git a/chart2/source/view/axes/VAxisBase.cxx b/chart2/source/view/axes/VAxisBase.cxx
index 79c2529873aa..0159fb20cad6 100644
--- a/chart2/source/view/axes/VAxisBase.cxx
+++ b/chart2/source/view/axes/VAxisBase.cxx
@@ -79,23 +79,31 @@ void SAL_CALL VAxisBase::initAxisLabelProperties( const ::com::sun::star::awt::S
if( !m_aAxisProperties.m_bDisplayLabels )
return;
- if( AxisType::CATEGORY==m_aAxisProperties.m_nAxisType
- || AxisType::SERIES==m_aAxisProperties.m_nAxisType )
+ if( AxisType::SERIES==m_aAxisProperties.m_nAxisType )
{
if( m_aAxisProperties.m_xAxisTextProvider.is() )
m_aTextLabels = m_aAxisProperties.m_xAxisTextProvider->getTextualData();
m_bUseTextLabels = true;
- if( m_aTextLabels.getLength() == 1 && AxisType::SERIES==m_aAxisProperties.m_nAxisType )
+ if( m_aTextLabels.getLength() == 1 )
{
//don't show a single series name
m_aAxisProperties.m_bDisplayLabels = false;
return;
}
}
+ else if( AxisType::CATEGORY==m_aAxisProperties.m_nAxisType )
+ {
+ if( m_aAxisProperties.m_pExplicitCategoriesProvider )
+ m_aTextLabels = m_aAxisProperties.m_pExplicitCategoriesProvider->getSimpleCategories();
+
+ m_bUseTextLabels = true;
+ }
m_aAxisLabelProperties.nNumberFormatKey = m_aAxisProperties.m_nNumberFormatKey;
m_aAxisLabelProperties.init(m_aAxisProperties.m_xAxisModel);
+ if( m_aAxisProperties.m_bComplexCategories && AxisType::CATEGORY == m_aAxisProperties.m_nAxisType )
+ m_aAxisLabelProperties.eStaggering = SIDE_BY_SIDE;
}
void VAxisBase::recordMaximumTextSize( const Reference< drawing::XShape >& xShape, double fRotationAngleDegree )
@@ -152,6 +160,12 @@ void SAL_CALL VAxisBase::setExplicitScaleAndIncrement(
m_aIncrement = rIncrement;
}
+void VAxisBase::createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos )
+{
+ std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() );
+ apTickmarkHelper->getAllTicks( rAllTickInfos );
+}
+
bool VAxisBase::prepareShapeCreation()
{
//returns true if all is ready for further shape creation and any shapes need to be created
@@ -162,14 +176,9 @@ bool VAxisBase::prepareShapeCreation()
{
//-----------------------------------------
//create all scaled tickmark values
- if( m_xTextTarget.is() )
- {
- TickIter aRemoveIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
- removeTextShapesFromTicks( aRemoveIter, m_xTextTarget );
- }
+ removeTextShapesFromTicks();
- std::auto_ptr< TickmarkHelper > apTickmarkHelper( this->createTickmarkHelper() );
- apTickmarkHelper->getAllTicks( m_aAllTickInfos );
+ createAllTickInfos(m_aAllTickInfos);
m_bReCreateAllTickInfos = false;
}
@@ -203,15 +212,25 @@ sal_Int32 VAxisBase::getIndexOfLongestLabel( const uno::Sequence< rtl::OUString
return nRet;
}
-void VAxisBase::removeTextShapesFromTicks( TickIter& rIter, const Reference< drawing::XShapes >& xTarget )
+void VAxisBase::removeTextShapesFromTicks()
{
- for( TickInfo* pTickInfo = rIter.firstInfo()
- ; pTickInfo; pTickInfo = rIter.nextInfo() )
+ if( m_xTextTarget.is() )
{
- if(pTickInfo->xTextShape.is())
+ ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = m_aAllTickInfos.begin();
+ const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = m_aAllTickInfos.end();
+ for( ; aDepthIter != aDepthEnd; aDepthIter++ )
{
- xTarget->remove(pTickInfo->xTextShape);
- pTickInfo->xTextShape = NULL;
+ ::std::vector< TickInfo >::iterator aTickIter = (*aDepthIter).begin();
+ const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end();
+ for( ; aTickIter != aTickEnd; aTickIter++ )
+ {
+ TickInfo& rTickInfo = (*aTickIter);
+ if(rTickInfo.xTextShape.is())
+ {
+ m_xTextTarget->remove(rTickInfo.xTextShape);
+ rTickInfo.xTextShape = NULL;
+ }
+ }
}
}
}
diff --git a/chart2/source/view/axes/VAxisBase.hxx b/chart2/source/view/axes/VAxisBase.hxx
index fba6d867c808..ba7e94b2070c 100644
--- a/chart2/source/view/axes/VAxisBase.hxx
+++ b/chart2/source/view/axes/VAxisBase.hxx
@@ -67,6 +67,7 @@ public:
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Int32 estimateMaximumAutoMainIncrementCount();
+ virtual void createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos );
void setExrtaLinePositionAtOtherAxis( const double& fCrossingAt );
@@ -74,7 +75,7 @@ public:
//-------------------------------------------------------------------------
protected: //methods
sal_Int32 getIndexOfLongestLabel( const ::com::sun::star::uno::Sequence< rtl::OUString >& rLabels );
- void removeTextShapesFromTicks( TickIter& rIter, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget );
+ void removeTextShapesFromTicks();
void updateUnscaledValuesAtTicks( TickIter& rIter );
virtual bool prepareShapeCreation();
diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx
index e5c90f0eda4d..436541ef27ee 100644
--- a/chart2/source/view/axes/VAxisProperties.cxx
+++ b/chart2/source/view/axes/VAxisProperties.cxx
@@ -144,6 +144,18 @@ TickmarkProperties AxisProperties::makeTickmarkProperties(
return aTickmarkProperties;
}
+TickmarkProperties AxisProperties::makeTickmarkPropertiesForComplexCategories(
+ sal_Int32 nTickLength, sal_Int32 nTickStartDistanceToAxis, sal_Int32 /*nTextLevel*/ ) const
+{
+ sal_Int32 nTickmarkStyle = (m_fLabelDirectionSign==m_fInnerDirectionSign) ? 2/*outside*/ : 1/*inside*/;
+
+ TickmarkProperties aTickmarkProperties;
+ aTickmarkProperties.Length = nTickLength;// + nTextLevel*( lcl_calcTickLengthForDepth(0,nTickmarkStyle) );
+ aTickmarkProperties.RelativePos = static_cast<sal_Int32>(lcl_getTickOffset(aTickmarkProperties.Length+nTickStartDistanceToAxis,nTickmarkStyle));
+ aTickmarkProperties.aLineProperties = this->makeLinePropertiesForDepth( 0 );
+ return aTickmarkProperties;
+}
+
//static
TickmarkProperties AxisProperties::getBiggestTickmarkProperties()
{
@@ -158,7 +170,7 @@ TickmarkProperties AxisProperties::getBiggestTickmarkProperties()
//--------------------------------------------------------------------------
AxisProperties::AxisProperties( const uno::Reference< XAxis >& xAxisModel
- , const uno::Reference< data::XTextualDataSequence >& xAxisTextProvider )
+ , ExplicitCategoriesProvider* pExplicitCategoriesProvider )
: m_xAxisModel(xAxisModel)
, m_nDimensionIndex(0)
, m_bIsMainAxis(true)
@@ -173,7 +185,6 @@ AxisProperties::AxisProperties( const uno::Reference< XAxis >& xAxisModel
, m_bAxisBetweenCategories(false)
, m_fLabelDirectionSign(1.0)
, m_fInnerDirectionSign(1.0)
- , m_bLabelsOutside(true)
, m_aLabelAlignment(LABEL_ALIGN_RIGHT_TOP)
, m_bDisplayLabels( true )
, m_nNumberFormatKey(0)
@@ -183,8 +194,9 @@ AxisProperties::AxisProperties( const uno::Reference< XAxis >& xAxisModel
, m_aLineProperties()
//for category axes
, m_nAxisType(AxisType::REALNUMBER)
- , m_xAxisTextProvider(xAxisTextProvider)
- , m_bTickmarksAtIndicatedValue(false)
+ , m_bComplexCategories(false)
+ , m_pExplicitCategoriesProvider(pExplicitCategoriesProvider)
+ , m_xAxisTextProvider(0)
{
}
@@ -203,7 +215,6 @@ AxisProperties::AxisProperties( const AxisProperties& rAxisProperties )
, m_bAxisBetweenCategories( rAxisProperties.m_bAxisBetweenCategories )
, m_fLabelDirectionSign( rAxisProperties.m_fLabelDirectionSign )
, m_fInnerDirectionSign( rAxisProperties.m_fInnerDirectionSign )
- , m_bLabelsOutside( rAxisProperties.m_bLabelsOutside )
, m_aLabelAlignment( rAxisProperties.m_aLabelAlignment )
, m_bDisplayLabels( rAxisProperties.m_bDisplayLabels )
, m_nNumberFormatKey( rAxisProperties.m_nNumberFormatKey )
@@ -213,8 +224,9 @@ AxisProperties::AxisProperties( const AxisProperties& rAxisProperties )
, m_aLineProperties( rAxisProperties.m_aLineProperties )
//for category axes
, m_nAxisType( rAxisProperties.m_nAxisType )
+ , m_bComplexCategories( rAxisProperties.m_bComplexCategories )
+ , m_pExplicitCategoriesProvider( rAxisProperties.m_pExplicitCategoriesProvider )
, m_xAxisTextProvider( rAxisProperties.m_xAxisTextProvider )
- , m_bTickmarksAtIndicatedValue( rAxisProperties.m_bTickmarksAtIndicatedValue )
{
if( rAxisProperties.m_pfMainLinePositionAtOtherAxis )
m_pfMainLinePositionAtOtherAxis = new double(*rAxisProperties.m_pfMainLinePositionAtOtherAxis);
diff --git a/chart2/source/view/axes/VAxisProperties.hxx b/chart2/source/view/axes/VAxisProperties.hxx
index 8a83fb6bcf7c..5b6bfe98f777 100644
--- a/chart2/source/view/axes/VAxisProperties.hxx
+++ b/chart2/source/view/axes/VAxisProperties.hxx
@@ -30,6 +30,7 @@
#include "TickmarkProperties.hxx"
#include "PlottingPositionHelper.hxx"
#include "LabelAlignment.hxx"
+#include "ExplicitCategoriesProvider.hxx"
#include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
#include <com/sun/star/chart/ChartAxisMarkPosition.hpp>
@@ -84,7 +85,7 @@ struct AxisLabelProperties
double fRotationAngleDegree;
sal_Int32 nRhythm; //show only each nth label with n==nRhythm
- bool bRhythmIsFix; //states wether the given rythm is fix or may be changed
+ bool bRhythmIsFix; //states wether the given rhythm is fix or may be changed
//methods:
void init( const ::com::sun::star::uno::Reference<
@@ -116,7 +117,6 @@ struct AxisProperties
double m_fLabelDirectionSign;
//this direction is used to indicate in which direction inner tickmarks are to be drawn
double m_fInnerDirectionSign;
- bool m_bLabelsOutside;
LabelAlignment m_aLabelAlignment;
sal_Bool m_bDisplayLabels;
@@ -133,19 +133,18 @@ struct AxisProperties
VLineProperties m_aLineProperties;
//for category axes ->
- sal_Int32 m_nAxisType;//REALNUMBER, CATEGORY etc. type ::com::sun::star::chart2::AxisType
+ sal_Int32 m_nAxisType;//REALNUMBER, CATEGORY etc. type ::com::sun::star::chart2::AxisType
+ bool m_bComplexCategories;
+ ExplicitCategoriesProvider* m_pExplicitCategoriesProvider;/*no ownership here*/
::com::sun::star::uno::Reference<
::com::sun::star::chart2::data::XTextualDataSequence >
m_xAxisTextProvider; //for categries or series names
- //position of main tickmarks in respect to the indicated value: at value or between neighboured indicated values
- bool m_bTickmarksAtIndicatedValue;
//<- category axes
//methods:
AxisProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxisModel
- , const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XTextualDataSequence >& xAxisTextProvider );
+ , ExplicitCategoriesProvider* pExplicitCategoriesProvider );
AxisProperties( const AxisProperties& rAxisProperties );
virtual ~AxisProperties();
virtual void init(bool bCartesian=false);//init from model data (m_xAxisModel)
@@ -153,6 +152,7 @@ struct AxisProperties
void initAxisPositioning( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xAxisProp );
static TickmarkProperties getBiggestTickmarkProperties();
+ TickmarkProperties makeTickmarkPropertiesForComplexCategories( sal_Int32 nTickLength, sal_Int32 nTickStartDistanceToAxis, sal_Int32 nTextLevel ) const;
private:
AxisProperties();
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index e06360b2b1b7..caadaa554091 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -118,19 +118,19 @@ Reference< drawing::XShape > createSingleLabel(
bool lcl_doesShapeOverlapWithTickmark( const Reference< drawing::XShape >& xShape
, double fRotationAngleDegree
, const basegfx::B2DVector& rTickScreenPosition
- , TickmarkHelper_2D* pTickmarkHelper )
+ , bool bIsHorizontalAxis, bool bIsVerticalAxis )
{
if(!xShape.is())
return false;
::basegfx::B2IRectangle aShapeRect = BaseGFXHelper::makeRectangle(xShape->getPosition(),ShapeFactory::getSizeAfterRotation( xShape, fRotationAngleDegree ));
- if( pTickmarkHelper->isVerticalAxis() )
+ if( bIsVerticalAxis )
{
return ( (rTickScreenPosition.getY() >= aShapeRect.getMinY())
&& (rTickScreenPosition.getY() <= aShapeRect.getMaxY()) );
}
- if( pTickmarkHelper->isHorizontalAxis() )
+ if( bIsHorizontalAxis )
{
return ( (rTickScreenPosition.getX() >= aShapeRect.getMinX())
&& (rTickScreenPosition.getX() <= aShapeRect.getMaxX()) );
@@ -154,7 +154,7 @@ bool doesOverlap( const Reference< drawing::XShape >& xShape1
return aRect1.overlaps(aRect2);
}
-void removeShapesAtWrongRythm( TickIter& rIter
+void removeShapesAtWrongRhythm( TickIter& rIter
, sal_Int32 nCorrectRhythm
, sal_Int32 nMaxTickToCheck
, const Reference< drawing::XShapes >& xTarget )
@@ -164,7 +164,7 @@ void removeShapesAtWrongRythm( TickIter& rIter
; pTickInfo && nTick <= nMaxTickToCheck
; pTickInfo = rIter.nextInfo(), nTick++ )
{
- //remove labels which does not fit into the rythm
+ //remove labels which does not fit into the rhythm
if( nTick%nCorrectRhythm != 0)
{
if(pTickInfo->xTextShape.is())
@@ -176,7 +176,7 @@ void removeShapesAtWrongRythm( TickIter& rIter
}
}
-class LabelIterator : private TickIter
+class EquidistantLabelIterator : public EquidistantTickIter
{
//this Iterator iterates over existing text labels
@@ -190,7 +190,7 @@ class LabelIterator : private TickIter
//we iterate through all labels
public:
- LabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
+ EquidistantLabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement
, const AxisLabelStaggering eAxisLabelStaggering
, bool bInnerLine
@@ -200,29 +200,29 @@ public:
virtual TickInfo* nextInfo();
private: //methods
- LabelIterator();
+ EquidistantLabelIterator();
private: //member
const AxisLabelStaggering m_eAxisLabelStaggering;
bool m_bInnerLine;
};
-LabelIterator::LabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
+EquidistantLabelIterator::EquidistantLabelIterator( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement
, const AxisLabelStaggering eAxisLabelStaggering
, bool bInnerLine
, sal_Int32 nMinDepth, sal_Int32 nMaxDepth )
- : TickIter( rTickInfos, rIncrement, nMinDepth, nMaxDepth )
+ : EquidistantTickIter( rTickInfos, rIncrement, nMinDepth, nMaxDepth )
, m_eAxisLabelStaggering(eAxisLabelStaggering)
, m_bInnerLine(bInnerLine)
{
}
-TickInfo* LabelIterator::firstInfo()
+TickInfo* EquidistantLabelIterator::firstInfo()
{
- TickInfo* pTickInfo = TickIter::firstInfo();
+ TickInfo* pTickInfo = EquidistantTickIter::firstInfo();
while( pTickInfo && !pTickInfo->xTextShape.is() )
- pTickInfo = TickIter::nextInfo();
+ pTickInfo = EquidistantTickIter::nextInfo();
if(!pTickInfo)
return NULL;
if( (STAGGER_EVEN==m_eAxisLabelStaggering && m_bInnerLine)
@@ -232,7 +232,7 @@ TickInfo* LabelIterator::firstInfo()
{
//skip first label
do
- pTickInfo = TickIter::nextInfo();
+ pTickInfo = EquidistantTickIter::nextInfo();
while( pTickInfo && !pTickInfo->xTextShape.is() );
}
if(!pTickInfo)
@@ -240,12 +240,12 @@ TickInfo* LabelIterator::firstInfo()
return pTickInfo;
}
-TickInfo* LabelIterator::nextInfo()
+TickInfo* EquidistantLabelIterator::nextInfo()
{
TickInfo* pTickInfo = NULL;
//get next label
do
- pTickInfo = TickIter::nextInfo();
+ pTickInfo = EquidistantTickIter::nextInfo();
while( pTickInfo && !pTickInfo->xTextShape.is() );
if( STAGGER_EVEN==m_eAxisLabelStaggering
@@ -253,16 +253,16 @@ TickInfo* LabelIterator::nextInfo()
{
//skip one label
do
- pTickInfo = TickIter::nextInfo();
+ pTickInfo = EquidistantTickIter::nextInfo();
while( pTickInfo && !pTickInfo->xTextShape.is() );
}
return pTickInfo;
}
-B2DVector lcl_getStaggerDistance( LabelIterator& rIter, const B2DVector& rDistanceTickToText )
+B2DVector lcl_getLabelsDistance( TickIter& rIter, const B2DVector& rDistanceTickToText )
{
- //calculates the height or width of the first line of labels
- //thus the second line of labels needs to be shifted for that distance
+ //calculates the height or width of a line of labels
+ //thus a following line of labels can be shifted for that distance
B2DVector aRet(0,0);
@@ -280,13 +280,14 @@ B2DVector lcl_getStaggerDistance( LabelIterator& rIter, const B2DVector& rDistan
; pTickInfo = rIter.nextInfo() )
{
xShape2DText = pTickInfo->xTextShape;
- DBG_ASSERT(xShape2DText.is(),"LabelIterator does not work correctly");
-
- awt::Size aSize = xShape2DText->getSize();
- if(fabs(aStaggerDirection.getX())>fabs(aStaggerDirection.getY()))
- nDistance = ::std::max(nDistance,aSize.Width);
- else
- nDistance = ::std::max(nDistance,aSize.Height);
+ if( xShape2DText.is() )
+ {
+ awt::Size aSize = xShape2DText->getSize();
+ if(fabs(aStaggerDirection.getX())>fabs(aStaggerDirection.getY()))
+ nDistance = ::std::max(nDistance,aSize.Width);
+ else
+ nDistance = ::std::max(nDistance,aSize.Height);
+ }
}
aRet = aStaggerDirection*nDistance;
@@ -298,7 +299,7 @@ B2DVector lcl_getStaggerDistance( LabelIterator& rIter, const B2DVector& rDistan
return aRet;
}
-void lcl_correctPositionForStaggering( LabelIterator& rIter, const B2DVector& rStaggerDistance )
+void lcl_shiftLables( TickIter& rIter, const B2DVector& rStaggerDistance )
{
if(rStaggerDistance.getLength()==0.0)
return;
@@ -308,23 +309,24 @@ void lcl_correctPositionForStaggering( LabelIterator& rIter, const B2DVector& rS
; pTickInfo = rIter.nextInfo() )
{
xShape2DText = pTickInfo->xTextShape;
- DBG_ASSERT(xShape2DText.is(),"LabelIterator does not work correctly");
-
- awt::Point aPos = xShape2DText->getPosition();
- aPos.X += static_cast<sal_Int32>(rStaggerDistance.getX());
- aPos.Y += static_cast<sal_Int32>(rStaggerDistance.getY());
- xShape2DText->setPosition( aPos );
+ if( xShape2DText.is() )
+ {
+ awt::Point aPos = xShape2DText->getPosition();
+ aPos.X += static_cast<sal_Int32>(rStaggerDistance.getX());
+ aPos.Y += static_cast<sal_Int32>(rStaggerDistance.getY());
+ xShape2DText->setPosition( aPos );
+ }
}
}
-class MaxLabelTickIter : public TickIter
+class MaxLabelEquidistantTickIter : public EquidistantTickIter
{
//iterate over first two and last two labels and the longest label
public:
- MaxLabelTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
+ MaxLabelEquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement
, sal_Int32 nLongestLabelIndex );
- virtual ~MaxLabelTickIter();
+ virtual ~MaxLabelEquidistantTickIter();
virtual TickInfo* nextInfo();
@@ -332,10 +334,10 @@ private:
sal_Int32 m_nLongestLabelIndex;
};
-MaxLabelTickIter::MaxLabelTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
+MaxLabelEquidistantTickIter::MaxLabelEquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
, const ::com::sun::star::chart2::ExplicitIncrementData& rIncrement
, sal_Int32 nLongestLabelIndex )
- : TickIter( rTickInfos, rIncrement, 0//nMinDepth
+ : EquidistantTickIter( rTickInfos, rIncrement, 0//nMinDepth
, 0//nMaxDepth
)
, m_nLongestLabelIndex( nLongestLabelIndex )
@@ -353,11 +355,11 @@ MaxLabelTickIter::MaxLabelTickIter( ::std::vector< ::std::vector< TickInfo > >&
if( m_nLongestLabelIndex+1==nMaxIndex )
m_nLongestLabelIndex = 0;
}
-MaxLabelTickIter::~MaxLabelTickIter()
+MaxLabelEquidistantTickIter::~MaxLabelEquidistantTickIter()
{
}
-TickInfo* MaxLabelTickIter::nextInfo()
+TickInfo* MaxLabelEquidistantTickIter::nextInfo()
{
sal_Int32 nCurrentPos = getCurrentIndex();
sal_Int32 nMaxIndex = getMaxIndex();
@@ -374,11 +376,11 @@ TickInfo* MaxLabelTickIter::nextInfo()
}
}
- return TickIter::nextInfo();
+ return EquidistantTickIter::nextInfo();
}
bool VCartesianAxis::isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
- , TickmarkHelper_2D* pTickmarkHelper )
+ , bool bIsHorizontalAxis )
{
if( m_aTextLabels.getLength() > 100 )
return false;
@@ -392,13 +394,11 @@ bool VCartesianAxis::isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLab
if( !::rtl::math::approxEqual( rAxisLabelProperties.fRotationAngleDegree, 0.0 ) )
return false;
//break only for horizontal axis
- if( pTickmarkHelper )
- return pTickmarkHelper->isHorizontalAxis();
- return false;
+ return bIsHorizontalAxis;
}
bool VCartesianAxis::isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
- , TickmarkHelper_2D* pTickmarkHelper )
+ , bool bIsHorizontalAxis, bool bIsVerticalAxis )
{
if( rAxisLabelProperties.eStaggering != STAGGER_AUTO )
return false;
@@ -410,28 +410,163 @@ bool VCartesianAxis::isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties&
return false;
//automatic staggering only for horizontal axis with horizontal text
//or vertical axis with vertical text
- if( pTickmarkHelper )
+ if( bIsHorizontalAxis )
+ return !rAxisLabelProperties.bStackCharacters;
+ if( bIsVerticalAxis )
+ return rAxisLabelProperties.bStackCharacters;
+ return false;
+}
+
+struct ComplexCategoryPlacement
+{
+ rtl::OUString Text;
+ sal_Int32 Count;
+ double TickValue;
+
+ ComplexCategoryPlacement( const rtl::OUString& rText, sal_Int32 nCount, double fTickValue )
+ : Text(rText), Count(nCount), TickValue(fTickValue)
+ {}
+};
+
+void VCartesianAxis::createAllTickInfosFromComplexCategories( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShiftedPosition )
+{
+ //no minor tickmarks will be generated!
+ //order is: inner labels first , outer labels last (that is different to all other TickIter cases)
+ if(!bShiftedPosition)
{
- if( pTickmarkHelper->isHorizontalAxis() )
- return !rAxisLabelProperties.bStackCharacters;
- if( pTickmarkHelper->isVerticalAxis() )
- return rAxisLabelProperties.bStackCharacters;
+ rAllTickInfos.clear();
+ sal_Int32 nLevel=0;
+ sal_Int32 nLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount();
+ for( ; nLevel<nLevelCount; nLevel++ )
+ {
+ ::std::vector< TickInfo > aTickInfoVector;
+ std::vector< ComplexCategory > aComplexCategories( m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoriesByLevel( nLevel ) );
+ sal_Int32 nCatIndex = 0;
+ std::vector< ComplexCategory >::const_iterator aIt(aComplexCategories.begin());
+ std::vector< ComplexCategory >::const_iterator aEnd(aComplexCategories.end());
+ for(;aIt!=aEnd;++aIt)
+ {
+ TickInfo aTickInfo;
+ ComplexCategory aCat(*aIt);
+ sal_Int32 nCount = aCat.Count;
+ if( nCatIndex + 0.5 + nCount >= m_aScale.Maximum )
+ {
+ nCount = m_aScale.Maximum - 0.5 - nCatIndex;
+ if( nCount <= 0 )
+ nCount = 1;
+ }
+ aTickInfo.fScaledTickValue = nCatIndex + 0.5 + nCount/2.0;
+ aTickInfo.nFactorForLimitedTextWidth = nCount;
+ aTickInfo.aText = aCat.Text;
+ aTickInfoVector.push_back(aTickInfo);
+ nCatIndex += nCount;
+ if( nCatIndex + 0.5 >= m_aScale.Maximum )
+ break;
+ }
+ rAllTickInfos.push_back(aTickInfoVector);
+ }
}
- return false;
+ else //bShiftedPosition==true
+ {
+ rAllTickInfos.clear();
+ sal_Int32 nLevel=0;
+ sal_Int32 nLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount();
+ for( ; nLevel<nLevelCount; nLevel++ )
+ {
+ ::std::vector< TickInfo > aTickInfoVector;
+ std::vector< ComplexCategory > aComplexCategories( m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoriesByLevel( nLevel ) );
+ sal_Int32 nCatIndex = 0;
+ std::vector< ComplexCategory >::const_iterator aIt(aComplexCategories.begin());
+ std::vector< ComplexCategory >::const_iterator aEnd(aComplexCategories.end());
+ for(;aIt!=aEnd;++aIt)
+ {
+ TickInfo aTickInfo;
+ ComplexCategory aCat(*aIt);
+ aTickInfo.fScaledTickValue = nCatIndex + 0.5;
+ aTickInfoVector.push_back(aTickInfo);
+ nCatIndex += aCat.Count;
+ if( nCatIndex + 0.5 > m_aScale.Maximum )
+ break;
+ }
+ //fill up with single ticks until maximum scale
+ while( nCatIndex + 0.5 < m_aScale.Maximum )
+ {
+ TickInfo aTickInfo;
+ aTickInfo.fScaledTickValue = nCatIndex + 0.5;
+ aTickInfoVector.push_back(aTickInfo);
+ nCatIndex ++;
+ if( nLevel>0 )
+ break;
+ }
+ //add an additional tick at the end
+ {
+ TickInfo aTickInfo;
+ aTickInfo.fScaledTickValue = m_aScale.Maximum;
+ aTickInfoVector.push_back(aTickInfo);
+ }
+ rAllTickInfos.push_back(aTickInfoVector);
+ }
+ }
+}
+
+void VCartesianAxis::createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos )
+{
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
+ createAllTickInfosFromComplexCategories( rAllTickInfos, false );
+ else
+ VAxisBase::createAllTickInfos(rAllTickInfos);
+}
+
+::std::auto_ptr< TickIter > VCartesianAxis::createLabelTickIterator( sal_Int32 nTextLevel )
+{
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
+ {
+ if( nTextLevel>=0 && nTextLevel < static_cast< sal_Int32 >(m_aAllTickInfos.size()) )
+ return ::std::auto_ptr< TickIter >( new PureTickIter( m_aAllTickInfos[nTextLevel] ) );
+ }
+ else
+ {
+ if(nTextLevel==0)
+ return ::std::auto_ptr< TickIter >( new EquidistantTickIter( m_aAllTickInfos, m_aIncrement, 0, 0 ) );
+ }
+ return ::std::auto_ptr< TickIter >();
+}
+::std::auto_ptr< TickIter > VCartesianAxis::createMaximumLabelTickIterator( sal_Int32 nTextLevel )
+{
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
+ {
+ return createLabelTickIterator( nTextLevel ); //mmmm maybe todo: create less than all texts here
+ }
+ else
+ {
+ if(nTextLevel==0)
+ {
+ sal_Int32 nLongestLabelIndex = m_bUseTextLabels ? this->getIndexOfLongestLabel( m_aTextLabels ) : 0;
+ return ::std::auto_ptr< TickIter >( new MaxLabelEquidistantTickIter( m_aAllTickInfos, m_aIncrement, nLongestLabelIndex ) );
+ }
+ }
+ return ::std::auto_ptr< TickIter >();
+}
+
+sal_Int32 VCartesianAxis::getTextLevelCount() const
+{
+ sal_Int32 nTextLevelCount = 1;
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
+ nTextLevelCount = m_aAxisProperties.m_pExplicitCategoriesProvider->getCategoryLevelCount();
+ return nTextLevelCount;
}
bool VCartesianAxis::createTextShapes(
const Reference< drawing::XShapes >& xTarget
, TickIter& rTickIter
, AxisLabelProperties& rAxisLabelProperties
- , TickmarkHelper_2D* pTickmarkHelper )
+ , TickmarkHelper_2D* pTickmarkHelper
+ , sal_Int32 nScreenDistanceBetweenTicks )
{
//returns true if the text shapes have been created succesfully
//otherwise false - in this case the AxisLabelProperties have changed
//and contain new instructions for the next try for text shape creation
- uno::Sequence< rtl::OUString >* pCategories = m_bUseTextLabels? &m_aTextLabels : 0;
-
Reference< XScaling > xInverseScaling( NULL );
if( m_aScale.Scaling.is() )
xInverseScaling = m_aScale.Scaling->getInverseScaling();
@@ -439,40 +574,44 @@ bool VCartesianAxis::createTextShapes(
FixedNumberFormatter aFixedNumberFormatter(
m_xNumberFormatsSupplier, rAxisLabelProperties.nNumberFormatKey );
- B2DVector aTextToTickDistance( pTickmarkHelper->getDistanceAxisTickToText( m_aAxisProperties ) );
-
- TickInfo* pPreviousVisibleTickInfo = NULL;
- TickInfo* pPREPreviousVisibleTickInfo = NULL;
- TickInfo* pLastVisibleNeighbourTickInfo = NULL;
+ const bool bIsHorizontalAxis = pTickmarkHelper->isHorizontalAxis();
+ const bool bIsVerticalAxis = pTickmarkHelper->isVerticalAxis();
bool bIsStaggered = rAxisLabelProperties.getIsStaggered();
- sal_Int32 nLimitedSpace = -1;
- if( isBreakOfLabelsAllowed( rAxisLabelProperties, pTickmarkHelper ) )
+ B2DVector aTextToTickDistance( pTickmarkHelper->getDistanceAxisTickToText( m_aAxisProperties, true ) );
+ sal_Int32 nLimitedSpaceForText = -1;
+ if( isBreakOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis ) )
{
- nLimitedSpace = TickmarkHelper_2D::getTickScreenDistance( rTickIter );
+ nLimitedSpaceForText = nScreenDistanceBetweenTicks;
if( bIsStaggered )
- nLimitedSpace *= 2;
+ nLimitedSpaceForText *= 2;
- if( nLimitedSpace > 0 )
+ if( nLimitedSpaceForText > 0 )
{ //reduce space for a small amount to have a visible distance between the labels:
- sal_Int32 nReduce = (nLimitedSpace*5)/100;
+ sal_Int32 nReduce = (nLimitedSpaceForText*5)/100;
if(!nReduce)
nReduce = 1;
- nLimitedSpace -= nReduce;
+ nLimitedSpaceForText -= nReduce;
}
- //maybe @todo in future:
- //if the labeled tickmarks are not equidistant [this is not considered to be a relevant case so far]
- //the limited space maybe needs to be calculated for each tickmark seperatly
- //or the staggering could be ignored in that case
}
+ std::vector< ComplexCategoryPlacement > aComplexCategoryPlacements;
+ uno::Sequence< rtl::OUString >* pCategories = 0;
+ if( m_bUseTextLabels && !m_aAxisProperties.m_bComplexCategories )
+ pCategories = &m_aTextLabels;
+
+ TickInfo* pPreviousVisibleTickInfo = NULL;
+ TickInfo* pPREPreviousVisibleTickInfo = NULL;
+ TickInfo* pLastVisibleNeighbourTickInfo = NULL;
+
//------------------------------------------------
//prepare properties for multipropertyset-interface of shape
tNameSequence aPropNames;
tAnySequence aPropValues;
+ bool bLimitedHeight = fabs(aTextToTickDistance.getX()) > fabs(aTextToTickDistance.getY());
Reference< beans::XPropertySet > xProps( m_aAxisProperties.m_xAxisModel, uno::UNO_QUERY );
PropertyMapper::getTextLabelMultiPropertyLists( xProps, aPropNames, aPropValues, false
- , nLimitedSpace, fabs(aTextToTickDistance.getX()) > fabs(aTextToTickDistance.getY()) );
+ , nLimitedSpaceForText, bLimitedHeight );
LabelPositionHelper::doDynamicFontResize( aPropValues, aPropNames, xProps
, m_aAxisLabelProperties.m_aFontReferenceSize );
LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, m_aAxisProperties.m_aLabelAlignment );
@@ -481,6 +620,8 @@ bool VCartesianAxis::createTextShapes(
sal_Int32 nColor = Color( COL_AUTO ).GetColor();
if(pColorAny)
*pColorAny >>= nColor;
+
+ uno::Any* pLimitedSpaceAny = PropertyMapper::getValuePointerForLimitedSpace(aPropValues,aPropNames,bLimitedHeight);
//------------------------------------------------
sal_Int32 nTick = 0;
@@ -491,7 +632,7 @@ bool VCartesianAxis::createTextShapes(
pLastVisibleNeighbourTickInfo = bIsStaggered ?
pPREPreviousVisibleTickInfo : pPreviousVisibleTickInfo;
- //don't create labels which does not fit into the rythm
+ //don't create labels which does not fit into the rhythm
if( nTick%rAxisLabelProperties.nRhythm != 0)
continue;
@@ -505,10 +646,11 @@ bool VCartesianAxis::createTextShapes(
{
if( lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
- , pTickInfo->aTickScreenPosition, pTickmarkHelper ) )
+ , pTickInfo->aTickScreenPosition
+ , bIsHorizontalAxis, bIsVerticalAxis ) )
{
bool bOverlapAlsoAfterSwitchingOnAutoStaggering = true;
- if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, pTickmarkHelper ) )
+ if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis ) )
{
bIsStaggered = true;
rAxisLabelProperties.eStaggering = STAGGER_EVEN;
@@ -516,7 +658,8 @@ bool VCartesianAxis::createTextShapes(
if( !pLastVisibleNeighbourTickInfo ||
!lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
- , pTickInfo->aTickScreenPosition, pTickmarkHelper ) )
+ , pTickInfo->aTickScreenPosition
+ , bIsHorizontalAxis, bIsVerticalAxis ) )
bOverlapAlsoAfterSwitchingOnAutoStaggering = false;
}
if( bOverlapAlsoAfterSwitchingOnAutoStaggering )
@@ -524,8 +667,7 @@ bool VCartesianAxis::createTextShapes(
if( rAxisLabelProperties.bRhythmIsFix )
continue;
rAxisLabelProperties.nRhythm++;
- TickIter aRemoveIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
- removeShapesAtWrongRythm( aRemoveIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
+ removeShapesAtWrongRhythm( rTickIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
return false;
}
}
@@ -543,11 +685,17 @@ bool VCartesianAxis::createTextShapes(
if( nIndex>=0 && nIndex<pCategories->getLength() )
aLabel = (*pCategories)[nIndex];
}
+ else if( m_aAxisProperties.m_bComplexCategories )
+ {
+ aLabel = pTickInfo->aText;
+ }
else
aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->fUnscaledTickValue, nExtraColor, bHasExtraColor );
if(pColorAny)
*pColorAny = uno::makeAny(bHasExtraColor?nExtraColor:nColor);
+ if(pLimitedSpaceAny)
+ *pLimitedSpaceAny = uno::makeAny(sal_Int32(nLimitedSpaceForText*pTickInfo->nFactorForLimitedTextWidth));
B2DVector aTickScreenPos2D( pTickInfo->aTickScreenPosition );
aTickScreenPos2D += aTextToTickDistance;
@@ -572,7 +720,7 @@ bool VCartesianAxis::createTextShapes(
if( doesOverlap( pLastVisibleNeighbourTickInfo->xTextShape, pTickInfo->xTextShape, m_aAxisLabelProperties.fRotationAngleDegree ) )
{
bool bOverlapAlsoAfterSwitchingOnAutoStaggering = true;
- if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, pTickmarkHelper ) )
+ if( !bIsStaggered && isAutoStaggeringOfLabelsAllowed( rAxisLabelProperties, bIsHorizontalAxis, bIsVerticalAxis ) )
{
bIsStaggered = true;
rAxisLabelProperties.eStaggering = STAGGER_EVEN;
@@ -580,7 +728,8 @@ bool VCartesianAxis::createTextShapes(
if( !pLastVisibleNeighbourTickInfo ||
!lcl_doesShapeOverlapWithTickmark( pLastVisibleNeighbourTickInfo->xTextShape
, rAxisLabelProperties.fRotationAngleDegree
- , pTickInfo->aTickScreenPosition, pTickmarkHelper ) )
+ , pTickInfo->aTickScreenPosition
+ , bIsHorizontalAxis, bIsVerticalAxis ) )
bOverlapAlsoAfterSwitchingOnAutoStaggering = false;
}
if( bOverlapAlsoAfterSwitchingOnAutoStaggering )
@@ -592,8 +741,7 @@ bool VCartesianAxis::createTextShapes(
continue;
}
rAxisLabelProperties.nRhythm++;
- TickIter aRemoveIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
- removeShapesAtWrongRythm( aRemoveIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
+ removeShapesAtWrongRhythm( rTickIter, rAxisLabelProperties.nRhythm, nTick, xTarget );
return false;
}
}
@@ -1057,6 +1205,43 @@ TickmarkHelper_2D* VCartesianAxis::createTickmarkHelper2D()
return new TickmarkHelper_2D( m_aScale, m_aIncrement, aStart, aEnd, aLabelLineStart-aStart );
}
+void lcl_hideIdenticalScreenValues( TickIter& rTickIter )
+{
+ TickInfo* pPreviousTickInfo = rTickIter.firstInfo();
+ if(!pPreviousTickInfo)
+ return;
+ pPreviousTickInfo->bPaintIt = true;
+ for( TickInfo* pTickInfo = rTickIter.nextInfo(); pTickInfo; pTickInfo = rTickIter.nextInfo())
+ {
+ pTickInfo->bPaintIt =
+ ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getX())
+ != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getX()) )
+ ||
+ ( static_cast<sal_Int32>(pTickInfo->aTickScreenPosition.getY())
+ != static_cast<sal_Int32>(pPreviousTickInfo->aTickScreenPosition.getY()) );
+ pPreviousTickInfo = pTickInfo;
+ }
+}
+
+//'hide' tickmarks with identical screen values in aAllTickInfos
+void VCartesianAxis::hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rTickInfos ) const
+{
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
+ {
+ sal_Int32 nCount = rTickInfos.size();
+ for( sal_Int32 nN=0; nN<nCount; nN++ )
+ {
+ PureTickIter aTickIter( rTickInfos[nN] );
+ lcl_hideIdenticalScreenValues( aTickIter );
+ }
+ }
+ else
+ {
+ EquidistantTickIter aTickIter( rTickInfos, m_aIncrement, 0, -1 );
+ lcl_hideIdenticalScreenValues( aTickIter );
+ }
+}
+
sal_Int32 VCartesianAxis::estimateMaximumAutoMainIncrementCount()
{
sal_Int32 nRet = 10;
@@ -1092,15 +1277,31 @@ void VCartesianAxis::doStaggeringOfLabels( const AxisLabelProperties& rAxisLabel
if( !pTickmarkHelper2D )
return;
- if( rAxisLabelProperties.getIsStaggered() )
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
{
- LabelIterator aInnerIter( m_aAllTickInfos, m_aIncrement
+ sal_Int32 nTextLevelCount = getTextLevelCount();
+ B2DVector aCummulatedLabelsDistance(0,0);
+ for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
+ {
+ ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel );
+ if(apTickIter.get())
+ {
+ if( nTextLevel>0 )
+ lcl_shiftLables( *apTickIter.get(), aCummulatedLabelsDistance );
+ aCummulatedLabelsDistance += lcl_getLabelsDistance( *apTickIter.get()
+ , pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ) );
+ }
+ }
+ }
+ else if( rAxisLabelProperties.getIsStaggered() )
+ {
+ EquidistantLabelIterator aInnerIter( m_aAllTickInfos, m_aIncrement
, rAxisLabelProperties.eStaggering, true, 0, 0 );
- LabelIterator aOuterIter( m_aAllTickInfos, m_aIncrement
+ EquidistantLabelIterator aOuterIter( m_aAllTickInfos, m_aIncrement
, rAxisLabelProperties.eStaggering, false, 0, 0 );
- lcl_correctPositionForStaggering( aOuterIter
- , lcl_getStaggerDistance( aInnerIter
+ lcl_shiftLables( aOuterIter
+ , lcl_getLabelsDistance( aInnerIter
, pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ) ) );
}
}
@@ -1124,18 +1325,34 @@ void SAL_CALL VCartesianAxis::createLabels()
pTickmarkHelper2D->updateScreenValues( m_aAllTickInfos );
//-----------------------------------------
//'hide' tickmarks with identical screen values in aAllTickInfos
- pTickmarkHelper2D->hideIdenticalScreenValues( m_aAllTickInfos );
+ hideIdenticalScreenValues( m_aAllTickInfos );
- TickIter aRemoveIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
- removeTextShapesFromTicks( aRemoveIter, m_xTextTarget );
+ removeTextShapesFromTicks();
//create tick mark text shapes
- TickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
- while( !createTextShapes( m_xTextTarget, aTickIter
- , m_aAxisLabelProperties, pTickmarkHelper2D ) )
+ sal_Int32 nTextLevelCount = getTextLevelCount();
+ sal_Int32 nScreenDistanceBetweenTicks = -1;
+ for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
{
- };
+ ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel );
+ if(apTickIter.get())
+ {
+ if(nTextLevel==0)
+ {
+ nScreenDistanceBetweenTicks = TickmarkHelper_2D::getTickScreenDistance( *apTickIter.get() );
+ if( nTextLevelCount>1 )
+ nScreenDistanceBetweenTicks*=2; //the above used tick iter does contain also the sub ticks -> thus the given distance is only the half
+ }
+ AxisLabelProperties aCopy(m_aAxisLabelProperties);
+ aCopy.bRhythmIsFix = true;
+ aCopy.nRhythm = 1;
+ AxisLabelProperties& rAxisLabelProperties = nTextLevel==0 ? m_aAxisLabelProperties : aCopy;
+ while( !createTextShapes( m_xTextTarget, *apTickIter.get(), rAxisLabelProperties, pTickmarkHelper2D, nScreenDistanceBetweenTicks ) )
+ {
+ };
+ }
+ }
doStaggeringOfLabels( m_aAxisLabelProperties, pTickmarkHelper2D );
}
}
@@ -1163,19 +1380,22 @@ void SAL_CALL VCartesianAxis::createMaximumLabels()
//create tick mark text shapes
//@todo: iterate through all tick depth wich should be labeled
- sal_Int32 nLongestLabelIndex = m_bUseTextLabels
- ? this->getIndexOfLongestLabel( m_aTextLabels ) : 0;
- MaxLabelTickIter aTickIter( m_aAllTickInfos, m_aIncrement, nLongestLabelIndex );
AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties );
- if( isAutoStaggeringOfLabelsAllowed( aAxisLabelProperties, pTickmarkHelper2D ) )
+ if( isAutoStaggeringOfLabelsAllowed( aAxisLabelProperties, pTickmarkHelper2D->isHorizontalAxis(), pTickmarkHelper2D->isVerticalAxis() ) )
aAxisLabelProperties.eStaggering = STAGGER_EVEN;
aAxisLabelProperties.bOverlapAllowed = true;
aAxisLabelProperties.bLineBreakAllowed = false;
- while( !createTextShapes( m_xTextTarget, aTickIter
- , aAxisLabelProperties, pTickmarkHelper2D ) )
+ sal_Int32 nTextLevelCount = getTextLevelCount();
+ for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
{
- };
-
+ ::std::auto_ptr< TickIter > apTickIter = createMaximumLabelTickIterator( nTextLevel );
+ if(apTickIter.get())
+ {
+ while( !createTextShapes( m_xTextTarget, *apTickIter.get(), aAxisLabelProperties, pTickmarkHelper2D, -1 ) )
+ {
+ };
+ }
+ }
doStaggeringOfLabels( aAxisLabelProperties, pTickmarkHelper2D );
}
}
@@ -1195,46 +1415,47 @@ void SAL_CALL VCartesianAxis::updatePositions()
//update positions of all existing text shapes
pTickmarkHelper2D->updateScreenValues( m_aAllTickInfos );
- TickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
-
- Reference< drawing::XShape > xShape2DText;
- for( TickInfo* pTickInfo = aTickIter.firstInfo()
- ; pTickInfo; pTickInfo = aTickIter.nextInfo() )
+ ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = m_aAllTickInfos.begin();
+ const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = m_aAllTickInfos.end();
+ for( ; aDepthIter != aDepthEnd; aDepthIter++ )
{
- if( !pTickInfo )
- continue;
-
- xShape2DText = pTickInfo->xTextShape;
- if( xShape2DText.is() )
+ ::std::vector< TickInfo >::iterator aTickIter = aDepthIter->begin();
+ const ::std::vector< TickInfo >::const_iterator aTickEnd = aDepthIter->end();
+ for( ; aTickIter != aTickEnd; aTickIter++ )
{
- B2DVector aTextToTickDistance( pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties ) );
- B2DVector aTickScreenPos2D( pTickInfo->aTickScreenPosition );
- aTickScreenPos2D += aTextToTickDistance;
- awt::Point aAnchorScreenPosition2D(
- static_cast<sal_Int32>(aTickScreenPos2D.getX())
- ,static_cast<sal_Int32>(aTickScreenPos2D.getY()));
-
- // #i78696# use mathematically correct rotation now
- const double fRotationAnglePi(m_aAxisLabelProperties.fRotationAngleDegree * (F_PI / -180.0));
- uno::Any aATransformation = ShapeFactory::makeTransformation(aAnchorScreenPosition2D, fRotationAnglePi);
-
- //set new position
- uno::Reference< beans::XPropertySet > xProp( xShape2DText, uno::UNO_QUERY );
- if( xProp.is() )
+ TickInfo& rTickInfo = (*aTickIter);
+ Reference< drawing::XShape > xShape2DText( rTickInfo.xTextShape );
+ if( xShape2DText.is() )
{
- try
+ B2DVector aTextToTickDistance( pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, true ) );
+ B2DVector aTickScreenPos2D( rTickInfo.aTickScreenPosition );
+ aTickScreenPos2D += aTextToTickDistance;
+ awt::Point aAnchorScreenPosition2D(
+ static_cast<sal_Int32>(aTickScreenPos2D.getX())
+ ,static_cast<sal_Int32>(aTickScreenPos2D.getY()));
+
+ // #i78696# use mathematically correct rotation now
+ const double fRotationAnglePi(m_aAxisLabelProperties.fRotationAngleDegree * (F_PI / -180.0));
+ uno::Any aATransformation = ShapeFactory::makeTransformation(aAnchorScreenPosition2D, fRotationAnglePi);
+
+ //set new position
+ uno::Reference< beans::XPropertySet > xProp( xShape2DText, uno::UNO_QUERY );
+ if( xProp.is() )
{
- xProp->setPropertyValue( C2U( "Transformation" ), aATransformation );
+ try
+ {
+ xProp->setPropertyValue( C2U( "Transformation" ), aATransformation );
+ }
+ catch( uno::Exception& e )
+ {
+ ASSERT_EXCEPTION( e );
+ }
}
- catch( uno::Exception& e )
- {
- ASSERT_EXCEPTION( e );
- }
- }
- //correctPositionForRotation
- LabelPositionHelper::correctPositionForRotation( xShape2DText
- , m_aAxisProperties.m_aLabelAlignment, m_aAxisLabelProperties.fRotationAngleDegree, false );
+ //correctPositionForRotation
+ LabelPositionHelper::correctPositionForRotation( xShape2DText
+ , m_aAxisProperties.m_aLabelAlignment, m_aAxisLabelProperties.fRotationAngleDegree, false );
+ }
}
}
@@ -1242,6 +1463,37 @@ void SAL_CALL VCartesianAxis::updatePositions()
}
}
+void VCartesianAxis::createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickmarkHelper_2D& rTickmarkHelper2D, bool bOnlyAtLabels )
+{
+ sal_Int32 nPointCount = rTickInfos.size();
+ drawing::PointSequenceSequence aPoints(2*nPointCount);
+
+ ::std::vector< TickInfo >::const_iterator aTickIter = rTickInfos.begin();
+ const ::std::vector< TickInfo >::const_iterator aTickEnd = rTickInfos.end();
+ sal_Int32 nN = 0;
+ for( ; aTickIter != aTickEnd; aTickIter++ )
+ {
+ if( !(*aTickIter).bPaintIt )
+ continue;
+
+ bool bTicksAtLabels = ( m_aAxisProperties.m_eTickmarkPos != ::com::sun::star::chart::ChartAxisMarkPosition_AT_AXIS );
+ double fInnerDirectionSign = m_aAxisProperties.m_fInnerDirectionSign;
+ if( bTicksAtLabels && m_aAxisProperties.m_eLabelPos == ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END )
+ fInnerDirectionSign *= -1.0;
+ bTicksAtLabels = bTicksAtLabels || bOnlyAtLabels;
+ //add ticks at labels:
+ rTickmarkHelper2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue
+ , fInnerDirectionSign , rTickmarkProperties, bTicksAtLabels );
+ //add ticks at axis (without lables):
+ if( !bOnlyAtLabels && m_aAxisProperties.m_eTickmarkPos == ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS )
+ rTickmarkHelper2D.addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue
+ , m_aAxisProperties.m_fInnerDirectionSign, rTickmarkProperties, !bTicksAtLabels );
+ }
+ aPoints.realloc(nN);
+ m_pShapeFactory->createLine2D( m_xGroupShape_Shapes, aPoints
+ , &rTickmarkProperties.aLineProperties );
+}
+
void SAL_CALL VCartesianAxis::createShapes()
{
if( !prepareShapeCreation() )
@@ -1253,55 +1505,64 @@ void SAL_CALL VCartesianAxis::createShapes()
return;
//-----------------------------------------
- //create tick mark line shapes
+ //create line shapes
if(2==m_nDimension)
{
- ::std::vector< ::std::vector< TickInfo > > aAllShiftedTickInfos;
- if( m_aIncrement.ShiftedPosition )
- {
- pTickmarkHelper2D->getAllTicksShifted( aAllShiftedTickInfos );
- pTickmarkHelper2D->updateScreenValues( aAllShiftedTickInfos );
- pTickmarkHelper2D->hideIdenticalScreenValues( aAllShiftedTickInfos );
- }
- ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos = m_aIncrement.ShiftedPosition ? aAllShiftedTickInfos : m_aAllTickInfos;
-
- ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAllTickInfos.begin();
- const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rAllTickInfos.end();
-
- if(aDepthIter == aDepthEnd)//no tickmarks at all
- return;
-
- sal_Int32 nTickmarkPropertiesCount = m_aAxisProperties.m_aTickmarkPropertiesList.size();
- for( sal_Int32 nDepth=0
- ; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount
- ; aDepthIter++, nDepth++ )
+ //-----------------------------------------
+ //create extra long ticks to separate complex categories (create them only there where the labels are)
+ if( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels )
{
- const TickmarkProperties& rTickmarkProperties = m_aAxisProperties.m_aTickmarkPropertiesList[nDepth];
-
- sal_Int32 nPointCount = (*aDepthIter).size();
- drawing::PointSequenceSequence aPoints(2*nPointCount);
+ ::std::vector< ::std::vector< TickInfo > > aComplexTickInfos;
+ createAllTickInfosFromComplexCategories( aComplexTickInfos, true );
+ pTickmarkHelper2D->updateScreenValues( aComplexTickInfos );
+ hideIdenticalScreenValues( aComplexTickInfos );
+
+ ::std::vector<TickmarkProperties> aTickmarkPropertiesList;
+ static bool bIncludeSpaceBetweenTickAndText = false;
+ sal_Int32 nOffset = pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, false, bIncludeSpaceBetweenTickAndText ).getLength();
+ sal_Int32 nTextLevelCount = getTextLevelCount();
+ for( sal_Int32 nTextLevel=0; nTextLevel<nTextLevelCount; nTextLevel++ )
+ {
+ ::std::auto_ptr< TickIter > apTickIter = createLabelTickIterator( nTextLevel );
+ if( apTickIter.get() )
+ {
+ B2DVector aLabelsDistance( lcl_getLabelsDistance( *apTickIter.get(), pTickmarkHelper2D->getDistanceAxisTickToText( m_aAxisProperties, false ) ) );
+ sal_Int32 nCurrentLength = aLabelsDistance.getLength();
+ aTickmarkPropertiesList.push_back( m_aAxisProperties.makeTickmarkPropertiesForComplexCategories( nOffset + nCurrentLength, 0, nTextLevel ) );
+ nOffset += nCurrentLength;
+ }
+ }
- ::std::vector< TickInfo >::const_iterator aTickIter = (*aDepthIter).begin();
- const ::std::vector< TickInfo >::const_iterator aTickEnd = (*aDepthIter).end();
- sal_Int32 nN = 0;
- for( ; aTickIter != aTickEnd; aTickIter++ )
+ sal_Int32 nTickmarkPropertiesCount = aTickmarkPropertiesList.size();
+ ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = aComplexTickInfos.begin();
+ const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = aComplexTickInfos.end();
+ for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount; aDepthIter++, nDepth++ )
{
- if( !(*aTickIter).bPaintIt )
+ if(nDepth==0 && !m_aAxisProperties.m_nMajorTickmarks)
continue;
-
- bool bTicksAtLabels = ( m_aAxisProperties.m_eTickmarkPos != ::com::sun::star::chart::ChartAxisMarkPosition_AT_AXIS );
- double fInnerDirectionSign = m_aAxisProperties.m_fInnerDirectionSign;
- if( bTicksAtLabels && m_aAxisProperties.m_eLabelPos == ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END )
- fInnerDirectionSign *= -1.0;
- apTickmarkHelper2D->addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue
- , fInnerDirectionSign , rTickmarkProperties, bTicksAtLabels );
- if( m_aAxisProperties.m_eTickmarkPos == ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS )
- apTickmarkHelper2D->addPointSequenceForTickLine( aPoints, nN++, (*aTickIter).fScaledTickValue
- , m_aAxisProperties.m_fInnerDirectionSign, rTickmarkProperties, !bTicksAtLabels );
+ createTickMarkLineShapes( *aDepthIter, aTickmarkPropertiesList[nDepth], *pTickmarkHelper2D, true /*bOnlyAtLabels*/ );
+ }
+ }
+ //-----------------------------------------
+ //create normal ticks for major and minor intervals
+ {
+ ::std::vector< ::std::vector< TickInfo > > aAllShiftedTickInfos;
+ if( m_aIncrement.ShiftedPosition || ( m_aAxisProperties.m_bComplexCategories && m_bUseTextLabels ) )
+ {
+ pTickmarkHelper2D->getAllTicksShifted( aAllShiftedTickInfos );
+ pTickmarkHelper2D->updateScreenValues( aAllShiftedTickInfos );
+ hideIdenticalScreenValues( aAllShiftedTickInfos );
}
- aPoints.realloc(nN);
- m_pShapeFactory->createLine2D( m_xGroupShape_Shapes, aPoints
- , &rTickmarkProperties.aLineProperties );
+ ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos = m_aIncrement.ShiftedPosition ? aAllShiftedTickInfos : m_aAllTickInfos;
+
+ ::std::vector< ::std::vector< TickInfo > >::iterator aDepthIter = rAllTickInfos.begin();
+ const ::std::vector< ::std::vector< TickInfo > >::const_iterator aDepthEnd = rAllTickInfos.end();
+ if(aDepthIter == aDepthEnd)//no tickmarks at all
+ return;
+
+ sal_Int32 nTickmarkPropertiesCount = m_aAxisProperties.m_aTickmarkPropertiesList.size();
+ for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount; aDepthIter++, nDepth++ )
+ createTickMarkLineShapes( *aDepthIter, m_aAxisProperties.m_aTickmarkPropertiesList[nDepth], *pTickmarkHelper2D, false /*bOnlyAtLabels*/ );
}
//-----------------------------------------
//create axis main lines
diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx
index f23560eaad9c..4fbcd2409196 100644
--- a/chart2/source/view/axes/VCartesianAxis.hxx
+++ b/chart2/source/view/axes/VCartesianAxis.hxx
@@ -30,6 +30,8 @@
#include "VAxisBase.hxx"
#include <basegfx/vector/b2dvector.hxx>
+#include <memory>
+
//.............................................................................
namespace chart
{
@@ -69,6 +71,12 @@ public:
virtual void SAL_CALL createShapes();
virtual sal_Int32 estimateMaximumAutoMainIncrementCount();
+ virtual void createAllTickInfos( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos );
+ void createAllTickInfosFromComplexCategories( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos, bool bShiftedPosition );
+
+ ::std::auto_ptr< TickIter > createLabelTickIterator( sal_Int32 nTextLevel );
+ ::std::auto_ptr< TickIter > createMaximumLabelTickIterator( sal_Int32 nTextLevel );
+ sal_Int32 getTextLevelCount() const;
//-------------------------------------------------------------------------
virtual TickmarkHelper* createTickmarkHelper();
@@ -114,16 +122,19 @@ protected: //methods
::com::sun::star::drawing::XShapes >& xTarget
, TickIter& rTickIter
, AxisLabelProperties& rAxisLabelProperties
- , TickmarkHelper_2D* pTickmarkHelper );
+ , TickmarkHelper_2D* pTickmarkHelper
+ , sal_Int32 nScreenDistanceBetweenTicks );
+
+ void createTickMarkLineShapes( ::std::vector< TickInfo >& rTickInfos, const TickmarkProperties& rTickmarkProperties, TickmarkHelper_2D& rTickmarkHelper2D, bool bOnlyAtLabels );
TickmarkHelper_2D* createTickmarkHelper2D();
+ void hideIdenticalScreenValues( ::std::vector< ::std::vector< TickInfo > >& rTickInfos ) const;
void doStaggeringOfLabels( const AxisLabelProperties& rAxisLabelProperties
, TickmarkHelper_2D* pTickmarkHelper2D );
bool isAutoStaggeringOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
- , TickmarkHelper_2D* pTickmarkHelper);
- bool isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties
- , TickmarkHelper_2D* pTickmarkHelper );
+ , bool bIsHorizontalAxis, bool bIsVerticalAxis );
+ bool isBreakOfLabelsAllowed( const AxisLabelProperties& rAxisLabelProperties, bool bIsHorizontalAxis );
::basegfx::B2DVector getScreenPosition( double fLogicX, double fLogicY, double fLogicZ ) const;
ScreenPosAndLogicPos getScreenPosAndLogicPos( double fLogicX, double fLogicY, double fLogicZ ) const;
diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
index 01358b3a932f..a196397e0e9f 100644
--- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
@@ -153,7 +153,8 @@ void VCartesianCoordinateSystem::createVAxisList(
if( aCrossingScale.AxisType == AxisType::CATEGORY )
{
aAxisProperties.m_bCrossingAxisIsCategoryAxes = true;
- aAxisProperties.m_bAxisBetweenCategories = ChartTypeHelper::shiftTicksAtXAxisPerDefault( AxisHelper::getChartTypeByIndex( m_xCooSysModel, 0 ) );
+ aAxisProperties.m_bAxisBetweenCategories = ChartTypeHelper::shiftTicksAtXAxisPerDefault( AxisHelper::getChartTypeByIndex( m_xCooSysModel, 0 ) )
+ || ( aAxisProperties.m_pExplicitCategoriesProvider && aAxisProperties.m_pExplicitCategoriesProvider->hasComplexCategories() );
}
}
@@ -168,6 +169,13 @@ void VCartesianCoordinateSystem::createVAxisList(
aAxisProperties.init(true);
if(aAxisProperties.m_bDisplayLabels)
aAxisProperties.m_nNumberFormatKey = this->getNumberFormatKeyForAxis( xAxis, xNumberFormatsSupplier );
+
+ if( nDimensionIndex == 0 && aAxisProperties.m_nAxisType == AxisType::CATEGORY
+ && aAxisProperties.m_pExplicitCategoriesProvider )
+ {
+ if( aAxisProperties.m_pExplicitCategoriesProvider->hasComplexCategories() )
+ aAxisProperties.m_bComplexCategories = true;
+ }
//-------------------
::boost::shared_ptr< VAxisBase > apVAxis( new VCartesianAxis(aAxisProperties,xNumberFormatsSupplier,nDimensionIndex,nDimensionCount) );
tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx
index 22ec914fa938..bc908acdf85a 100644
--- a/chart2/source/view/axes/VCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCoordinateSystem.cxx
@@ -94,7 +94,7 @@ VCoordinateSystem::VCoordinateSystem( const Reference< XCoordinateSystem >& xCoo
, m_aMergedMinimumAndMaximumSupplier()
, m_aExplicitScales(3)
, m_aExplicitIncrements(3)
- , m_aExplicitCategoriesProvider( new ExplicitCategoriesProvider( m_xCooSysModel ) )
+ , m_apExplicitCategoriesProvider(NULL)
{
if( !m_xCooSysModel.is() || m_xCooSysModel->getDimension()<3 )
{
@@ -261,10 +261,14 @@ void VCoordinateSystem::impl_adjustDimensionAndIndex( sal_Int32& rDimensionIndex
rAxisIndex = 0;
}
+void VCoordinateSystem::setExplicitCategoriesProvider( ExplicitCategoriesProvider* pExplicitCategoriesProvider /*takes ownership*/ )
+{
+ m_apExplicitCategoriesProvider = ::std::auto_ptr< ExplicitCategoriesProvider >(pExplicitCategoriesProvider);
+}
-Reference< data::XTextualDataSequence > VCoordinateSystem::getExplicitCategoriesProvider()
+ExplicitCategoriesProvider* VCoordinateSystem::getExplicitCategoriesProvider()
{
- return m_aExplicitCategoriesProvider.getRef();
+ return m_apExplicitCategoriesProvider.get();
}
Sequence< ExplicitScaleData > VCoordinateSystem::getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const
diff --git a/chart2/source/view/axes/VPolarAngleAxis.cxx b/chart2/source/view/axes/VPolarAngleAxis.cxx
index 7a273e22f128..865a7848aa9a 100644
--- a/chart2/source/view/axes/VPolarAngleAxis.cxx
+++ b/chart2/source/view/axes/VPolarAngleAxis.cxx
@@ -62,7 +62,7 @@ VPolarAngleAxis::~VPolarAngleAxis()
bool VPolarAngleAxis::createTextShapes_ForAngleAxis(
const uno::Reference< drawing::XShapes >& xTarget
- , TickIter& rTickIter
+ , EquidistantTickIter& rTickIter
, AxisLabelProperties& rAxisLabelProperties
, double fLogicRadius
, double fLogicZ )
@@ -99,7 +99,7 @@ bool VPolarAngleAxis::createTextShapes_ForAngleAxis(
; pTickInfo
; pTickInfo = rTickIter.nextInfo(), nTick++ )
{
- //don't create labels which does not fit into the rythm
+ //don't create labels which does not fit into the rhythm
if( nTick%rAxisLabelProperties.nRhythm != 0)
continue;
@@ -189,11 +189,10 @@ void SAL_CALL VPolarAngleAxis::createLabels()
//create tick mark text shapes
//@todo: iterate through all tick depth wich should be labeled
- TickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
+ EquidistantTickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
this->updateUnscaledValuesAtTicks( aTickIter );
- TickIter aRemoveIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
- removeTextShapesFromTicks( aRemoveIter, m_xTextTarget );
+ removeTextShapesFromTicks();
AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties );
aAxisLabelProperties.bOverlapAllowed = true;
diff --git a/chart2/source/view/axes/VPolarAngleAxis.hxx b/chart2/source/view/axes/VPolarAngleAxis.hxx
index 9a27c94e3095..c03cf533e22c 100644
--- a/chart2/source/view/axes/VPolarAngleAxis.hxx
+++ b/chart2/source/view/axes/VPolarAngleAxis.hxx
@@ -55,7 +55,7 @@ public:
private: //methods
bool createTextShapes_ForAngleAxis(
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xTarget
- , TickIter& rTickIter
+ , EquidistantTickIter& rTickIter
, AxisLabelProperties& rAxisLabelProperties
, double fLogicRadius, double fLogicZ );
};
diff --git a/chart2/source/view/axes/VPolarGrid.cxx b/chart2/source/view/axes/VPolarGrid.cxx
index b9099906deb0..0bd98b642acb 100644
--- a/chart2/source/view/axes/VPolarGrid.cxx
+++ b/chart2/source/view/axes/VPolarGrid.cxx
@@ -90,7 +90,7 @@ void VPolarGrid::createLinePointSequence_ForAngleAxis(
xInverseScaling = rScale.Scaling->getInverseScaling();
sal_Int32 nTick = 0;
- TickIter aIter( rAllTickInfos, rIncrement, 0, 0 );
+ EquidistantTickIter aIter( rAllTickInfos, rIncrement, 0, 0 );
for( TickInfo* pTickInfo = aIter.firstInfo()
; pTickInfo
; pTickInfo = aIter.nextInfo(), nTick++ )
diff --git a/chart2/source/view/axes/VPolarRadiusAxis.cxx b/chart2/source/view/axes/VPolarRadiusAxis.cxx
index 7970d051e7b1..2206d4d8f559 100644
--- a/chart2/source/view/axes/VPolarRadiusAxis.cxx
+++ b/chart2/source/view/axes/VPolarRadiusAxis.cxx
@@ -49,7 +49,6 @@ VPolarRadiusAxis::VPolarRadiusAxis( const AxisProperties& rAxisProperties
{
m_aAxisProperties.m_fLabelDirectionSign=0.0;
m_aAxisProperties.m_fInnerDirectionSign=0.0;
- m_aAxisProperties.m_bLabelsOutside=true;
m_aAxisProperties.m_bIsMainAxis=false;
m_aAxisProperties.m_aLabelAlignment=LABEL_ALIGN_RIGHT;
m_aAxisProperties.init();
@@ -156,7 +155,7 @@ void SAL_CALL VPolarRadiusAxis::createShapes()
AxisProperties aAxisProperties(m_aAxisProperties);
sal_Int32 nTick = 0;
- TickIter aIter( aAngleTickInfos, rAngleIncrement, 0, 0 );
+ EquidistantTickIter aIter( aAngleTickInfos, rAngleIncrement, 0, 0 );
for( TickInfo* pTickInfo = aIter.firstInfo()
; pTickInfo; pTickInfo = aIter.nextInfo(), nTick++ )
{
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx
index 1774d9828e91..67914f47bac0 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -72,7 +72,6 @@ AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel
, bool bNoArea
, PlottingPositionHelper* pPlottingPositionHelper
, bool bConnectLastToFirstPoint
- , bool bAddOneToXMax
, bool bExpandIfValuesCloseToBorder
, sal_Int32 nKeepAspectRatio
, const drawing::Direction3D& rAspectRatio
@@ -84,7 +83,6 @@ AreaChart::AreaChart( const uno::Reference<XChartType>& xChartTypeModel
, m_bSymbol( ChartTypeHelper::isSupportingSymbolProperties(xChartTypeModel,nDimensionCount) )
, m_bIsPolarCooSys( bConnectLastToFirstPoint )
, m_bConnectLastToFirstPoint( bConnectLastToFirstPoint )
- , m_bAddOneToXMax(bAddOneToXMax)
, m_bExpandIfValuesCloseToBorder( bExpandIfValuesCloseToBorder )
, m_nKeepAspectRatio(nKeepAspectRatio)
, m_aGivenAspectRatio(rAspectRatio)
@@ -123,14 +121,17 @@ AreaChart::~AreaChart()
delete m_pMainPosHelper;
}
+double AreaChart::getMinimumX()
+{
+ if( m_bCategoryXAxis && m_bIsPolarCooSys )//the angle axis in net charts needs a different autoscaling
+ return 1.0;//first category (index 0) matches with real number 1.0
+ return VSeriesPlotter::getMinimumX();
+}
+
double AreaChart::getMaximumX()
{
- if( m_bAddOneToXMax )
- {
- //return category count
- sal_Int32 nPointCount = getPointCount();
- return nPointCount+1;
- }
+ if( m_bCategoryXAxis && m_bIsPolarCooSys )//the angle axis in net charts needs a different autoscaling
+ return getPointCount()+1;
return VSeriesPlotter::getMaximumX();
}
diff --git a/chart2/source/view/charttypes/AreaChart.hxx b/chart2/source/view/charttypes/AreaChart.hxx
index afe9908b3bfe..6924509a62a1 100644
--- a/chart2/source/view/charttypes/AreaChart.hxx
+++ b/chart2/source/view/charttypes/AreaChart.hxx
@@ -49,7 +49,6 @@ public:
, bool bCategoryXAxis, bool bNoArea=false
, PlottingPositionHelper* pPlottingPositionHelper=NULL //takes owner ship
, bool bConnectLastToFirstPoint=false
- , bool bAddOneToXMax=false
, bool bExpandIfValuesCloseToBorder=true
, sal_Int32 nKeepAspectRatio=-1 //0->no 1->yes other value->automatic
, const ::com::sun::star::drawing::Direction3D& rAspectRatio=::com::sun::star::drawing::Direction3D(1,1,1)//only taken into account if nKeepAspectRatio==1
@@ -76,6 +75,7 @@ public:
//-------------------------------------------------------------------------
// MinimumAndMaximumSupplier
//-------------------------------------------------------------------------
+ virtual double getMinimumX();
virtual double getMaximumX();
virtual bool isExpandIfValuesCloseToBorder( sal_Int32 nDimensionIndex );
virtual bool isSeperateStackingForDifferentSigns( sal_Int32 nDimensionIndex );
@@ -109,7 +109,6 @@ private: //member
bool m_bSymbol;
bool m_bIsPolarCooSys;//used e.g. for net chart (the data labels need to be placed different)
bool m_bConnectLastToFirstPoint;//used e.g. for net chart
- bool m_bAddOneToXMax;//used e.g. for net chart (the angle axis needs a different autoscaling)
bool m_bExpandIfValuesCloseToBorder; // e.g. false for net charts
sal_Int32 m_nKeepAspectRatio; //0->no 1->yes other value->automatic
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index a6ab71df15f5..ccba1fdc4106 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -156,7 +156,7 @@ VSeriesPlotter::VSeriesPlotter( const uno::Reference<XChartType>& xChartTypeMode
, m_aZSlots()
, m_bCategoryXAxis(bCategoryXAxis)
, m_xColorScheme()
- , m_xExplicitCategoriesProvider()
+ , m_pExplicitCategoriesProvider(0)
, m_bPointsWereSkipped(false)
{
DBG_ASSERT(m_xChartTypeModel.is(),"no XChartType available in view, fallback to default values may be wrong");
@@ -477,9 +477,9 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
{
if(pLabel->ShowCategoryName)
{
- if( m_xExplicitCategoriesProvider.is() )
+ if( m_pExplicitCategoriesProvider )
{
- Sequence< OUString > aCategories( m_xExplicitCategoriesProvider->getTextualData() );
+ Sequence< OUString > aCategories( m_pExplicitCategoriesProvider->getSimpleCategories() );
if( nPointIndex >= 0 && nPointIndex < aCategories.getLength() )
{
aText.append( aCategories[nPointIndex] );
@@ -1127,7 +1127,12 @@ void VSeriesPlotter::setMappedProperties(
double VSeriesPlotter::getMinimumX()
{
if( m_bCategoryXAxis )
- return 1.0;//first category (index 0) matches with real number 1.0
+ {
+ double fRet = 1.0;//first category (index 0) matches with real number 1.0
+ if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() )
+ fRet -= 0.5;
+ return fRet;
+ }
double fMinimum, fMaximum;
this->getMinimumAndMaximiumX( fMinimum, fMaximum );
@@ -1138,8 +1143,10 @@ double VSeriesPlotter::getMaximumX()
if( m_bCategoryXAxis )
{
//return category count
- sal_Int32 nPointCount = getPointCount();
- return nPointCount;//first category (index 0) matches with real number 1.0
+ double fRet = getPointCount();//first category (index 0) matches with real number 1.0
+ if( m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() )
+ fRet += 0.5;
+ return fRet;
}
double fMinimum, fMaximum;
@@ -1356,9 +1363,9 @@ void VSeriesPlotter::setColorScheme( const uno::Reference< XColorScheme >& xColo
m_xColorScheme = xColorScheme;
}
-void VSeriesPlotter::setExplicitCategoriesProvider( const uno::Reference< data::XTextualDataSequence >& xExplicitCategoriesProvider )
+void VSeriesPlotter::setExplicitCategoriesProvider( ExplicitCategoriesProvider* pExplicitCategoriesProvider )
{
- m_xExplicitCategoriesProvider = xExplicitCategoriesProvider;
+ m_pExplicitCategoriesProvider = pExplicitCategoriesProvider;
}
sal_Int32 VDataSeriesGroup::getPointCount() const
@@ -1929,8 +1936,8 @@ std::vector< ViewLegendEntry > SAL_CALL VSeriesPlotter::createLegendEntriesForSe
if( bVaryColorsByPoint )
{
Sequence< OUString > aCategoryNames;
- if( m_xExplicitCategoriesProvider.is() )
- aCategoryNames = m_xExplicitCategoriesProvider->getTextualData();
+ if( m_pExplicitCategoriesProvider )
+ aCategoryNames = m_pExplicitCategoriesProvider->getSimpleCategories();
for( sal_Int32 nIdx=0; nIdx<aCategoryNames.getLength(); ++nIdx )
{
@@ -2074,9 +2081,9 @@ VSeriesPlotter* VSeriesPlotter::createSeriesPlotter(
else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_PIE) )
pRet = new PieChart(xChartTypeModel,nDimensionCount);
else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_NET) )
- pRet = new AreaChart(xChartTypeModel,nDimensionCount,true,true,new PolarPlottingPositionHelper(),true,true,false,1,drawing::Direction3D(1,1,1) );
+ pRet = new AreaChart(xChartTypeModel,nDimensionCount,true,true,new PolarPlottingPositionHelper(),true,false,1,drawing::Direction3D(1,1,1) );
else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET) )
- pRet = new AreaChart(xChartTypeModel,nDimensionCount,true,false,new PolarPlottingPositionHelper(),true,true,false,1,drawing::Direction3D(1,1,1) );
+ pRet = new AreaChart(xChartTypeModel,nDimensionCount,true,false,new PolarPlottingPositionHelper(),true,false,1,drawing::Direction3D(1,1,1) );
else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) )
pRet = new CandleStickChart(xChartTypeModel,nDimensionCount);
else
diff --git a/chart2/source/view/inc/PropertyMapper.hxx b/chart2/source/view/inc/PropertyMapper.hxx
index fbdebb4fa1a2..c0871b94f835 100644
--- a/chart2/source/view/inc/PropertyMapper.hxx
+++ b/chart2/source/view/inc/PropertyMapper.hxx
@@ -88,6 +88,11 @@ public:
, const tNameSequence& rPropNames
, const rtl::OUString& rPropName );
+ static ::com::sun::star::uno::Any*
+ getValuePointerForLimitedSpace( tAnySequence& rPropValues
+ , const tNameSequence& rPropNames
+ , bool bLimitedHeight );
+
static void setMultiProperties(
const tNameSequence& rNames
, const tAnySequence& rValues
diff --git a/chart2/source/view/inc/VCoordinateSystem.hxx b/chart2/source/view/inc/VCoordinateSystem.hxx
index 4a3d52203545..e884af865d6e 100644
--- a/chart2/source/view/inc/VCoordinateSystem.hxx
+++ b/chart2/source/view/inc/VCoordinateSystem.hxx
@@ -30,11 +30,11 @@
#include "MinimumAndMaximumSupplier.hxx"
#include "ScaleAutomatism.hxx"
#include "ThreeDHelper.hxx"
+#include "ExplicitCategoriesProvider.hxx"
#include <com/sun/star/chart2/ExplicitIncrementData.hpp>
#include <com/sun/star/chart2/ExplicitScaleData.hpp>
#include <com/sun/star/chart2/XCoordinateSystem.hpp>
-#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
#include "comphelper/implementationreference.hxx"
#include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/drawing/HomogenMatrix.hpp>
@@ -51,8 +51,6 @@ namespace chart
{
//.............................................................................
-class ExplicitCategoriesProvider;
-
//-----------------------------------------------------------------------------
/**
*/
@@ -87,7 +85,9 @@ public:
::com::sun::star::chart2::ExplicitScaleData getExplicitScale( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
::com::sun::star::chart2::ExplicitIncrementData getExplicitIncrement( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XTextualDataSequence > getExplicitCategoriesProvider();
+
+ void setExplicitCategoriesProvider( ExplicitCategoriesProvider* /*takes ownership*/ );
+ ExplicitCategoriesProvider* getExplicitCategoriesProvider();
// returns a coplete scale set for a given dimension and index; for example if nDimensionIndex==1 and nAxisIndex==2 you get returned the secondary x axis, main y axis and main z axis
::com::sun::star::uno::Sequence< ::com::sun::star::chart2::ExplicitScaleData > getExplicitScales( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) const;
@@ -203,8 +203,7 @@ private:
tFullExplicitScaleMap m_aSecondaryExplicitScales;
tFullExplicitIncrementMap m_aSecondaryExplicitIncrements;
- comphelper::ImplementationReference< ExplicitCategoriesProvider, ::com::sun::star::chart2::data::XTextualDataSequence >
- m_aExplicitCategoriesProvider;
+ ::std::auto_ptr< ExplicitCategoriesProvider > m_apExplicitCategoriesProvider;
};
//.............................................................................
diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx
index 95093db1bfaf..02c1f3b044e9 100644
--- a/chart2/source/view/inc/VSeriesPlotter.hxx
+++ b/chart2/source/view/inc/VSeriesPlotter.hxx
@@ -32,9 +32,9 @@
#include "LabelAlignment.hxx"
#include "MinimumAndMaximumSupplier.hxx"
#include "LegendEntryProvider.hxx"
+#include "ExplicitCategoriesProvider.hxx"
#include <com/sun/star/chart2/LegendSymbolStyle.hpp>
#include <com/sun/star/chart2/XChartType.hpp>
-#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
#include <com/sun/star/drawing/Direction3D.hpp>
@@ -275,8 +275,7 @@ public:
void setColorScheme( const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XColorScheme >& xColorScheme );
- void setExplicitCategoriesProvider( const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XTextualDataSequence >& xExplicitCategoriesProvider );
+ void setExplicitCategoriesProvider( ExplicitCategoriesProvider* pExplicitCategoriesProvider );
//get series names for the z axis labels
::com::sun::star::uno::Sequence< rtl::OUString > getSeriesNames() const;
@@ -431,8 +430,7 @@ protected: //member
::com::sun::star::uno::Reference<
::com::sun::star::chart2::XColorScheme > m_xColorScheme;
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::data::XTextualDataSequence > m_xExplicitCategoriesProvider;
+ ExplicitCategoriesProvider* m_pExplicitCategoriesProvider;
//better performance for big data
::com::sun::star::uno::Sequence< sal_Int32 > m_aCoordinateSystemResolution;
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 0e954b7c7a85..da8798fe31b6 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -424,6 +424,8 @@ VCoordinateSystem* addCooSysToList( std::vector< VCoordinateSystem* >& rVCooSysL
rtl::OUString aCooSysParticle( ObjectIdentifier::createParticleForCoordinateSystem( xCooSys, xChartModel ) );
pVCooSys->setParticle(aCooSysParticle);
+ pVCooSys->setExplicitCategoriesProvider( new ExplicitCategoriesProvider(xCooSys,xChartModel) );
+
rVCooSysList.push_back( pVCooSys );
}
}
@@ -574,13 +576,13 @@ private:
std::vector< VCoordinateSystem* >& m_rVCooSysList;
::std::map< uno::Reference< XAxis >, AxisUsage > m_aAxisUsageList;
sal_Int32 m_nMaxAxisIndex;
- bool m_bShiftXAxisTicks;
+ bool m_bChartTypeUsesShiftedXAxisTicksPerDefault;
};
SeriesPlotterContainer::SeriesPlotterContainer( std::vector< VCoordinateSystem* >& rVCooSysList )
: m_rVCooSysList( rVCooSysList )
, m_nMaxAxisIndex(0)
- , m_bShiftXAxisTicks(false)
+ , m_bChartTypeUsesShiftedXAxisTicksPerDefault(false)
{
}
@@ -675,7 +677,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
uno::Reference< XChartType > xChartType( aChartTypeList[nT] );
if(nT==0)
- m_bShiftXAxisTicks = ChartTypeHelper::shiftTicksAtXAxisPerDefault( xChartType );
+ m_bChartTypeUsesShiftedXAxisTicksPerDefault = ChartTypeHelper::shiftTicksAtXAxisPerDefault( xChartType );
VSeriesPlotter* pPlotter = VSeriesPlotter::createSeriesPlotter( xChartType, nDimensionCount );
if( !pPlotter )
@@ -929,7 +931,9 @@ void SeriesPlotterContainer::doAutoScaling( const uno::Reference< frame::XModel
for( nC=0; nC < aVCooSysList_X.size(); nC++)
{
- if( m_bShiftXAxisTicks )
+ ExplicitCategoriesProvider* pExplicitCategoriesProvider = aVCooSysList_X[nC]->getExplicitCategoriesProvider();
+
+ if( m_bChartTypeUsesShiftedXAxisTicksPerDefault || (aExplicitScale.AxisType==AxisType::CATEGORY && pExplicitCategoriesProvider && pExplicitCategoriesProvider->hasComplexCategories() ) )
aExplicitIncrement.ShiftedPosition = true;
aVCooSysList_X[nC]->setExplicitScaleAndIncrement( 0, nAxisIndex, aExplicitScale, aExplicitIncrement );
}
@@ -1775,7 +1779,8 @@ sal_Int32 lcl_getExplicitNumberFormatKeyForAxis(
if(!aLabeledSeq[nLSeqIdx].is())
continue;
Reference< data::XDataSequence > xSeq( aLabeledSeq[nLSeqIdx]->getValues());
- OSL_ASSERT( xSeq.is());
+ if(!xSeq.is())
+ continue;
Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY );
::rtl::OUString aRole;
bool bTakeIntoAccount =
diff --git a/chart2/source/view/main/PropertyMapper.cxx b/chart2/source/view/main/PropertyMapper.cxx
index 68368808f66a..6e53ce22aff7 100644
--- a/chart2/source/view/main/PropertyMapper.cxx
+++ b/chart2/source/view/main/PropertyMapper.cxx
@@ -165,6 +165,14 @@ uno::Any* PropertyMapper::getValuePointer( tAnySequence& rPropValues
return NULL;
}
+uno::Any* PropertyMapper::getValuePointerForLimitedSpace( tAnySequence& rPropValues
+ , const tNameSequence& rPropNames
+ , bool bLimitedHeight)
+{
+ return PropertyMapper::getValuePointer( rPropValues, rPropNames
+ , bLimitedHeight ? C2U("TextMaximumFrameHeight") : C2U("TextMaximumFrameWidth") );
+}
+
/*
//set some properties from service style::CharacterProperties:
//-------- tabpage: Zeichen -----------