summaryrefslogtreecommitdiff
path: root/chart2/source
diff options
context:
space:
mode:
authorIngrid Halama [iha] <Ingrid.Halama@oracle.com>2010-12-10 14:10:17 +0100
committerIngrid Halama [iha] <Ingrid.Halama@oracle.com>2010-12-10 14:10:17 +0100
commitb2b21642beea1db9120e99e5a0a64d7ece700d09 (patch)
treecf573cf8b82a951c82999e75a70ec24bc6606c07 /chart2/source
parent928cbecafc2f64e4a38bb91b4ec6a9b6093f0728 (diff)
chart46: #i25706# implement date axis - cleanup
Diffstat (limited to 'chart2/source')
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx27
-rw-r--r--chart2/source/controller/main/ChartDropTargetHelper.cxx77
-rw-r--r--chart2/source/model/inc/Diagram.hxx11
-rwxr-xr-xchart2/source/model/main/ChartModel.cxx23
-rw-r--r--chart2/source/model/main/Diagram.cxx17
-rw-r--r--chart2/source/tools/DataSourceHelper.cxx19
6 files changed, 66 insertions, 108 deletions
diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
index 6ab0e6c5f483..fd94ae0e3076 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx
@@ -739,30 +739,9 @@ void ChartDataWrapper::applyData( lcl_Operator& rDataOperator )
return;
uno::Reference< chart2::data::XDataSource > xSource( xDataProvider->createDataSource( aArguments ) );
- // determine a template
- uno::Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY );
- uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram());
- DiagramHelper::tTemplateWithServiceName aTemplateAndService =
- DiagramHelper::getTemplateForDiagram( xDia, xFact );
- ::rtl::OUString aServiceName( aTemplateAndService.second );
- uno::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 );
- }
+ uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram() );
+ if( xDia.is() )
+ xDia->setDiagramData( xSource, aArguments );
//correct stacking mode
if( bStacked || bPercent || bDeep )
diff --git a/chart2/source/controller/main/ChartDropTargetHelper.cxx b/chart2/source/controller/main/ChartDropTargetHelper.cxx
index 8749ca1bc062..fd7dc3ad1744 100644
--- a/chart2/source/controller/main/ChartDropTargetHelper.cxx
+++ b/chart2/source/controller/main/ChartDropTargetHelper.cxx
@@ -137,58 +137,47 @@ sal_Int8 ChartDropTargetHelper::ExecuteDrop( const ExecuteDropEvent& rEvt )
// parent)
if( bDataComesFromParent )
{
+ Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram() );
Reference< chart2::data::XDataProvider > xDataProvider( m_xChartDocument->getDataProvider());
- if( xDataProvider.is() &&
+ if( xDataProvider.is() && xDiagram.is() &&
DataSourceHelper::allArgumentsForRectRangeDetected( m_xChartDocument ))
{
- DiagramHelper::tTemplateWithServiceName aTempWithServ(
- DiagramHelper::getTemplateForDiagram(
- m_xChartDocument->getFirstDiagram(),
- Reference< lang::XMultiServiceFactory >(
- m_xChartDocument->getChartTypeManager(), uno::UNO_QUERY )));
- if( aTempWithServ.first.is())
+ Reference< chart2::data::XDataSource > xDataSource(
+ DataSourceHelper::pressUsedDataIntoRectangularFormat( m_xChartDocument ));
+ Sequence< beans::PropertyValue > aArguments(
+ xDataProvider->detectArguments( xDataSource ));
+
+ OUString aOldRange;
+ beans::PropertyValue * pCellRange = 0;
+ for( sal_Int32 i=0; i<aArguments.getLength(); ++i )
{
- Reference< chart2::data::XDataSource > xDataSource(
- DataSourceHelper::pressUsedDataIntoRectangularFormat( m_xChartDocument ));
- Sequence< beans::PropertyValue > aArguments(
- xDataProvider->detectArguments( xDataSource ));
-
- OUString aOldRange;
- beans::PropertyValue * pCellRange = 0;
- for( sal_Int32 i=0; i<aArguments.getLength(); ++i )
+ if( aArguments[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CellRangeRepresentation")))
{
- if( aArguments[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CellRangeRepresentation")))
- {
- pCellRange = (aArguments.getArray() + i);
- aArguments[i].Value >>= aOldRange;
- break;
- }
+ pCellRange = (aArguments.getArray() + i);
+ aArguments[i].Value >>= aOldRange;
+ break;
}
- if( pCellRange )
+ }
+ if( pCellRange )
+ {
+ // copy means add ranges, move means replace
+ if( rEvt.mnAction == DND_ACTION_COPY )
+ {
+ // @todo: using implcit knowledge that ranges can be
+ // merged with ";". This should be done more general
+ pCellRange->Value <<= (aOldRange + OUString( sal_Unicode(';')) + aRangeString );
+ }
+ // move means replace range
+ else
{
- // copy means add ranges, move means replace
- if( rEvt.mnAction == DND_ACTION_COPY )
- {
- // @todo: using implcit knowledge that ranges can be
- // merged with ";". This should be done more general
- pCellRange->Value <<= (aOldRange + OUString( sal_Unicode(';')) + aRangeString );
- }
- // move means replace range
- else
- {
- pCellRange->Value <<= aRangeString;
- }
-
- xDataSource.set( xDataProvider->createDataSource( aArguments ));
- aTempWithServ.first->changeDiagramData(
- m_xChartDocument->getFirstDiagram(),
- xDataSource,
- aArguments );
-
- // always return copy state to avoid deletion of the
- // dragged range
- nResult = DND_ACTION_COPY;
+ pCellRange->Value <<= aRangeString;
}
+
+ xDataSource.set( xDataProvider->createDataSource( aArguments ));
+ xDiagram->setDiagramData( xDataSource, aArguments );
+
+ // always return copy state to avoid deletion of the dragged range
+ nResult = DND_ACTION_COPY;
}
}
}
diff --git a/chart2/source/model/inc/Diagram.hxx b/chart2/source/model/inc/Diagram.hxx
index fc672e29b24c..658cfb2b4d6e 100644
--- a/chart2/source/model/inc/Diagram.hxx
+++ b/chart2/source/model/inc/Diagram.hxx
@@ -31,11 +31,13 @@
#include "MutexContainer.hxx"
#include <cppuhelper/implbase8.hxx>
#include <comphelper/uno3.hxx>
-#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/chart2/data/XDataSource.hpp>
#include <com/sun/star/chart2/XDiagram.hpp>
#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/chart2/XTitled.hpp>
#include <com/sun/star/chart/X3DDefaultSetter.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/util/XCloneable.hpp>
#include <com/sun/star/util/XModifyBroadcaster.hpp>
@@ -117,8 +119,6 @@ protected:
// throw (::com::sun::star::lang::IllegalArgumentException);
// ____ XDiagram ____
-// virtual ::rtl::OUString SAL_CALL getChartTypeTemplateServiceName()
-// throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet > SAL_CALL getWall()
throw (::com::sun::star::uno::RuntimeException);
@@ -136,7 +136,10 @@ 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 setDiagramData(
+ 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);
// ____ XCoordinateSystemContainer ____
virtual void SAL_CALL addCoordinateSystem(
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index 5a30d97118c5..046fe7034012 100755
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -865,28 +865,15 @@ void SAL_CALL ChartModel::setArguments( const Sequence< beans::PropertyValue >&
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())
+ 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
+ Reference< chart2::XChartTypeTemplate > xTemplate( impl_createDefaultChartTypeTemplate() );
+ if( xTemplate.is())
setFirstDiagram( xTemplate->createDiagramByDataSource( xDataSource, aArguments ) );
}
+ else
+ xDia->setDiagramData( xDataSource, aArguments );
}
}
catch( lang::IllegalArgumentException & )
diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx
index ff8a0c4030bc..94334a836b3e 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -33,6 +33,7 @@
#include "Wall.hxx"
#include "UserDefinedProperties.hxx"
#include "ConfigColorScheme.hxx"
+#include "DiagramHelper.hxx"
#include "ContainerHelper.hxx"
#include "ThreeDHelper.hxx"
#include "CloneHelper.hxx"
@@ -397,6 +398,22 @@ void SAL_CALL Diagram::setDefaultColorScheme( const Reference< chart2::XColorSch
fireModifyEvent();
}
+void SAL_CALL Diagram::setDiagramData(
+ const Reference< chart2::data::XDataSource >& xDataSource,
+ const Sequence< beans::PropertyValue >& aArguments )
+ throw (uno::RuntimeException)
+{
+ uno::Reference< lang::XMultiServiceFactory > xChartTypeManager( m_xContext->getServiceManager()->createInstanceWithContext(
+ C2U( "com.sun.star.chart2.ChartTypeManager" ), m_xContext ), uno::UNO_QUERY );
+ DiagramHelper::tTemplateWithServiceName aTemplateAndService = DiagramHelper::getTemplateForDiagram( this, xChartTypeManager );
+ uno::Reference< chart2::XChartTypeTemplate > xTemplate( aTemplateAndService.first );
+ if( !xTemplate.is() )
+ xTemplate.set( xChartTypeManager->createInstance( C2U("com.sun.star.chart2.template.Column") ), uno::UNO_QUERY );
+ if(!xTemplate.is())
+ return;
+ xTemplate->changeDiagramData( this, xDataSource, aArguments );
+}
+
// ____ XTitled ____
uno::Reference< chart2::XTitle > SAL_CALL Diagram::getTitleObject()
throw (uno::RuntimeException)
diff --git a/chart2/source/tools/DataSourceHelper.cxx b/chart2/source/tools/DataSourceHelper.cxx
index 0cc6ef4a4315..21fc16156397 100644
--- a/chart2/source/tools/DataSourceHelper.cxx
+++ b/chart2/source/tools/DataSourceHelper.cxx
@@ -461,25 +461,8 @@ void DataSourceHelper::setRangeSegmentation(
if( !xDataSource.is() )
return;
- DiagramHelper::tTemplateWithServiceName aTemplateAndService =
- DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateFactory );
-
- rtl::OUString aServiceName( aTemplateAndService.second );
- uno::Reference< chart2::XChartTypeTemplate > xTemplate = aTemplateAndService.first;
-
- if( !xTemplate.is() )
- {
- if( aServiceName.getLength() == 0 )
- aServiceName = C2U("com.sun.star.chart2.template.Column");
- xTemplate.set( xTemplateFactory->createInstance( aServiceName ), uno::UNO_QUERY );
- }
- if( !xTemplate.is() )
- return;
-
- // /-- locked controllers
ControllerLockGuard aCtrlLockGuard( xChartModel );
- xTemplate->changeDiagramData( xDiagram, xDataSource, aArguments );
- // \-- locked controllers
+ xDiagram->setDiagramData( xDataSource, aArguments );
}
Sequence< OUString > DataSourceHelper::getRangesFromLabeledDataSequence(