diff options
Diffstat (limited to 'chart2/source/model')
22 files changed, 416 insertions, 1647 deletions
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 ) |