diff options
Diffstat (limited to 'chart2/source/tools')
-rw-r--r-- | chart2/source/tools/ChartModelHelper.cxx | 7 | ||||
-rw-r--r-- | chart2/source/tools/ImplUndoManager.cxx | 479 | ||||
-rw-r--r-- | chart2/source/tools/ImplUndoManager.hxx | 211 | ||||
-rw-r--r-- | chart2/source/tools/ObjectIdentifier.cxx | 158 | ||||
-rw-r--r-- | chart2/source/tools/RangeHighlighter.cxx | 114 | ||||
-rw-r--r-- | chart2/source/tools/UndoGuard.cxx | 135 | ||||
-rw-r--r-- | chart2/source/tools/UndoManager.cxx | 352 | ||||
-rw-r--r-- | chart2/source/tools/makefile.mk | 3 |
8 files changed, 222 insertions, 1237 deletions
diff --git a/chart2/source/tools/ChartModelHelper.cxx b/chart2/source/tools/ChartModelHelper.cxx index 109b2d644433..8ce45e85038d 100644 --- a/chart2/source/tools/ChartModelHelper.cxx +++ b/chart2/source/tools/ChartModelHelper.cxx @@ -32,7 +32,6 @@ #include "DiagramHelper.hxx" #include "DataSourceHelper.hxx" #include "ControllerLockGuard.hxx" -#include "UndoManager.hxx" #include "RangeHighlighter.hxx" #include "InternalDataProvider.hxx" @@ -56,12 +55,6 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; //static -uno::Reference< chart2::XUndoManager > ChartModelHelper::createUndoManager() -{ - return new UndoManager(); -} - -//static uno::Reference< chart2::data::XRangeHighlighter > ChartModelHelper::createRangeHighlighter( const uno::Reference< view::XSelectionSupplier > & xSelectionSupplier ) { diff --git a/chart2/source/tools/ImplUndoManager.cxx b/chart2/source/tools/ImplUndoManager.cxx deleted file mode 100644 index 7d128bd2a9d1..000000000000 --- a/chart2/source/tools/ImplUndoManager.cxx +++ /dev/null @@ -1,479 +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 "ImplUndoManager.hxx" -#include "DisposeHelper.hxx" -#include "CommonFunctors.hxx" -#include "ControllerLockGuard.hxx" -#include "PropertyHelper.hxx" -#include "DataSourceHelper.hxx" -#include "ChartModelHelper.hxx" - -#include <com/sun/star/chart/XChartDataArray.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/XInternalDataProvider.hpp> -#include <com/sun/star/chart2/XTitled.hpp> -#include <com/sun/star/util/XCloneable.hpp> -#include <com/sun/star/util/XModifiable.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> - -#include <boost/bind.hpp> -#include <algorithm> - -using namespace ::com::sun::star; - -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::rtl::OUString; -using ::com::sun::star::chart::XChartDataArray; - -namespace chart -{ -namespace impl -{ - -void ImplApplyDataToModel( - Reference< frame::XModel > & xInOutModelToChange, - const Reference< chart2::XInternalDataProvider > & xData ) -{ - Reference< chart2::XChartDocument > xDoc( xInOutModelToChange, uno::UNO_QUERY ); - OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider()); - - // copy data from stored internal data provider - if( xDoc.is() && xDoc->hasInternalDataProvider()) - { - Reference< XChartDataArray > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY ); - Reference< XChartDataArray > xSavedData( xData, uno::UNO_QUERY ); - if( xCurrentData.is() && xSavedData.is()) - { - xCurrentData->setData( xSavedData->getData()); - xCurrentData->setRowDescriptions( xSavedData->getRowDescriptions()); - xCurrentData->setColumnDescriptions( xSavedData->getColumnDescriptions()); - } - } -} - -// ---------------------------------------- - -UndoElement::UndoElement( - const OUString & rActionString, - const Reference< frame::XModel > & xModel ) : - m_aActionString( rActionString ) -{ - initialize( xModel ); -} - -UndoElement::UndoElement( - const Reference< frame::XModel > & xModel ) -{ - initialize( xModel ); -} - -UndoElement::UndoElement( const UndoElement & rOther ) : - m_aActionString( rOther.m_aActionString ) -{ - initialize( rOther.m_xModel ); -} - -UndoElement::~UndoElement() -{} - -void UndoElement::initialize( const Reference< frame::XModel > & xModel ) -{ - m_xModel.set( UndoElement::cloneModel( xModel )); -} - -void UndoElement::dispose() -{ - Reference< lang::XComponent > xComp( m_xModel, uno::UNO_QUERY ); - if( xComp.is()) - xComp->dispose(); - m_xModel.set( 0 ); -} - -void UndoElement::applyToModel( - Reference< frame::XModel > & xInOutModelToChange ) -{ - UndoElement::applyModelContentToModel( xInOutModelToChange, m_xModel ); -} - -UndoElement * UndoElement::createFromModel( - const Reference< frame::XModel > & xModel ) -{ - return new UndoElement( getActionString(), xModel ); -} - -void UndoElement::setActionString( const ::rtl::OUString & rActionString ) -{ - m_aActionString = rActionString; -} - -OUString UndoElement::getActionString() const -{ - return m_aActionString; -} - -// static -Reference< frame::XModel > UndoElement::cloneModel( const Reference< frame::XModel > & xModel ) -{ - Reference< frame::XModel > xResult; - uno::Reference< util::XCloneable > xCloneable( xModel, uno::UNO_QUERY ); - OSL_ENSURE( xCloneable.is(), "Cannot clone model" ); - if( xCloneable.is()) - xResult.set( xCloneable->createClone(), uno::UNO_QUERY ); - - return xResult; -} - -// static -void UndoElement::applyModelContentToModel( - Reference< frame::XModel > & xInOutModelToChange, - const Reference< frame::XModel > & xModelToCopyFrom, - const Reference< chart2::XInternalDataProvider > & xData /* = 0 */ ) -{ - - if( xModelToCopyFrom.is() && xInOutModelToChange.is()) - { - try - { - // /-- loccked controllers of destination - ControllerLockGuard aLockedControllers( xInOutModelToChange ); - Reference< chart2::XChartDocument > xSource( xModelToCopyFrom, uno::UNO_QUERY_THROW ); - Reference< chart2::XChartDocument > xDestination( xInOutModelToChange, uno::UNO_QUERY_THROW ); - - // propagate the correct flag for plotting of hidden values to the data provider and all used sequences - ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( xModelToCopyFrom ) , xInOutModelToChange ); - - // diagram - xDestination->setFirstDiagram( xSource->getFirstDiagram()); - - // main title - Reference< chart2::XTitled > xDestinationTitled( xDestination, uno::UNO_QUERY_THROW ); - Reference< chart2::XTitled > xSourceTitled( xSource, uno::UNO_QUERY_THROW ); - xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject()); - - // page background - comphelper::copyProperties( - xSource->getPageBackground(), - xDestination->getPageBackground() ); - - // apply data (not applied in standard Undo) - if( xData.is()) - ImplApplyDataToModel( xInOutModelToChange, xData ); - - // register all sequences at the internal data provider to get adapted - // indexes when columns are added/removed - if( xDestination->hasInternalDataProvider()) - { - Reference< chart2::XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), uno::UNO_QUERY ); - Reference< chart2::data::XDataSource > xUsedData( DataSourceHelper::getUsedData( xInOutModelToChange )); - if( xUsedData.is() && xNewDataProvider.is()) - { - Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xUsedData->getDataSequences()); - for( sal_Int32 i=0; i<aData.getLength(); ++i ) - { - xNewDataProvider->registerDataSequenceForChanges( aData[i]->getValues()); - xNewDataProvider->registerDataSequenceForChanges( aData[i]->getLabel()); - } - } - } - - // restore modify status - Reference< util::XModifiable > xSourceMod( xSource, uno::UNO_QUERY ); - Reference< util::XModifiable > xDestMod( xDestination, uno::UNO_QUERY ); - if( xSourceMod.is() && xDestMod.is() && - ! xSourceMod->isModified() ) - { - xDestMod->setModified( sal_False ); - } - // \-- loccked controllers of destination - } - catch( uno::Exception & ) - { - } - } -} - -// ---------------------------------------- - -UndoElementWithData::UndoElementWithData( - const OUString & rActionString, - const Reference< frame::XModel > & xModel ) : - UndoElement( rActionString, xModel ) -{ - initializeData(); -} - -UndoElementWithData::UndoElementWithData( - const Reference< frame::XModel > & xModel ) : - UndoElement( xModel ) -{ - initializeData(); -} - - -UndoElementWithData::UndoElementWithData( - const UndoElementWithData & rOther ) : - UndoElement( rOther ) -{ - initializeData(); -} - -UndoElementWithData::~UndoElementWithData() -{} - -void UndoElementWithData::initializeData() -{ - try - { - Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY_THROW ); - OSL_ASSERT( xChartDoc->hasInternalDataProvider()); - if( xChartDoc->hasInternalDataProvider()) - { - Reference< util::XCloneable > xCloneable( xChartDoc->getDataProvider(), uno::UNO_QUERY ); - OSL_ENSURE( xCloneable.is(), "Cannot clone data" ); - if( xCloneable.is()) - m_xData.set( xCloneable->createClone(), uno::UNO_QUERY ); - } - } - catch( uno::Exception & ) - { - } -} - -void UndoElementWithData::dispose() -{ - UndoElement::dispose(); - m_xData.set( 0 ); -} - -void UndoElementWithData::applyToModel( - Reference< frame::XModel > & xInOutModelToChange ) -{ - UndoElement::applyModelContentToModel( xInOutModelToChange, m_xModel, m_xData ); -} - -UndoElement * UndoElementWithData::createFromModel( - const Reference< frame::XModel > & xModel ) -{ - return new UndoElementWithData( getActionString(), xModel ); -} - -// ======================================== - -// ---------------------------------------- - -UndoElementWithSelection::UndoElementWithSelection( - const OUString & rActionString, - const Reference< frame::XModel > & xModel ) : - UndoElement( rActionString, xModel ) -{ - initialize( xModel ); -} - -UndoElementWithSelection::UndoElementWithSelection( - const Reference< frame::XModel > & xModel ) : - UndoElement( xModel ) -{ - initialize( xModel ); -} - -UndoElementWithSelection::UndoElementWithSelection( - const UndoElementWithSelection & rOther ) : - UndoElement( rOther ) -{ - initialize( rOther.m_xModel ); -} - -UndoElementWithSelection::~UndoElementWithSelection() -{} - -void UndoElementWithSelection::initialize( const Reference< frame::XModel > & xModel ) -{ - try - { - uno::Reference< view::XSelectionSupplier > xSelSupp( xModel->getCurrentController(), uno::UNO_QUERY ); - OSL_ASSERT( xSelSupp.is() ); - - if( xSelSupp.is() ) - m_aSelection = xSelSupp->getSelection(); - } - catch( const uno::Exception & ) - { - } -} - -void UndoElementWithSelection::dispose() -{ - UndoElement::dispose(); - m_aSelection.clear(); -} - -void UndoElementWithSelection::applyToModel( - Reference< frame::XModel > & xInOutModelToChange ) -{ - UndoElement::applyModelContentToModel( xInOutModelToChange, m_xModel ); - Reference< view::XSelectionSupplier > xCurrentSelectionSuppl( xInOutModelToChange->getCurrentController(), uno::UNO_QUERY ); - OSL_ASSERT( xCurrentSelectionSuppl.is() ); - - if( xCurrentSelectionSuppl.is()) - xCurrentSelectionSuppl->select( m_aSelection ); -} - -UndoElement * UndoElementWithSelection::createFromModel( - const Reference< frame::XModel > & xModel ) -{ - return new UndoElementWithSelection( getActionString(), xModel ); -} - -// ======================================== - -UndoStack::UndoStack() : - m_nSizeLimit( 1000 ) -{ -} - -UndoStack::~UndoStack() -{ - disposeAndClear(); -} - -void UndoStack::pop() -{ - if( ! empty()) - { - top()->dispose(); - delete top(); - m_aStack.pop_back(); - } -} - -void UndoStack::push( UndoElement * pElement ) -{ - m_aStack.push_back( pElement ); - applyLimitation(); -} - -UndoElement * UndoStack::top() const -{ - return m_aStack.back(); -} - -OUString UndoStack::topUndoString() const -{ - if( ! empty()) - return top()->getActionString(); - return OUString(); -} - -Sequence< OUString > UndoStack::getUndoStrings() const -{ - sal_Int32 nSize( static_cast< sal_Int32 >( m_aStack.size())); - Sequence< OUString > aResult( nSize ); - for( sal_Int32 i=0; i<nSize; ++i ) - aResult[i] = m_aStack[i]->getActionString(); - return aResult; -} - -bool UndoStack::empty() const -{ - return m_aStack.empty(); -} - -void UndoStack::disposeAndClear() -{ - ::std::for_each( m_aStack.begin(), m_aStack.end(), ::boost::mem_fn( & UndoElement::dispose )); - ::std::for_each( m_aStack.begin(), m_aStack.end(), CommonFunctors::DeletePtr< UndoElement >() ); - m_aStack.clear(); -} - -void UndoStack::limitSize( sal_Int32 nMaxSize ) -{ - m_nSizeLimit = nMaxSize; - applyLimitation(); -} - -void UndoStack::applyLimitation() -{ - if( m_aStack.size() > static_cast< sal_uInt32 >( m_nSizeLimit )) - { - tUndoStackType::iterator aBegin( m_aStack.begin()); - tUndoStackType::iterator aEnd( aBegin + (m_aStack.size() - m_nSizeLimit)); - // dispose and remove all undo elements that are over the limit - ::std::for_each( aBegin, aEnd, ::boost::mem_fn( & UndoElement::dispose )); - ::std::for_each( aBegin, aEnd, CommonFunctors::DeletePtr< UndoElement >() ); - m_aStack.erase( aBegin, aEnd ); - } -} - -// ================================================================================ - -namespace -{ -static const OUString aUndoStepsPropName( RTL_CONSTASCII_USTRINGPARAM("Steps")); -} // anonymous namespace - -UndoStepsConfigItem::UndoStepsConfigItem( ConfigItemListener & rListener ) : - ::utl::ConfigItem( OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Undo"))), - m_rListener( rListener ) -{ - EnableNotification( Sequence< OUString >( & aUndoStepsPropName, 1 )); -} - -UndoStepsConfigItem::~UndoStepsConfigItem() -{ -} - -void UndoStepsConfigItem::Notify( const Sequence< OUString > & aPropertyNames ) -{ - for( sal_Int32 nIdx=0; nIdx<aPropertyNames.getLength(); ++nIdx ) - { - if( aPropertyNames[nIdx].equals( aUndoStepsPropName )) - m_rListener.notify( aPropertyNames[nIdx] ); - } -} - -void UndoStepsConfigItem::Commit() -{ -} - -// mtehod is not const, because GetProperties is not const -sal_Int32 UndoStepsConfigItem::getUndoSteps() -{ - sal_Int32 nSteps = -1; - Sequence< uno::Any > aValues( - GetProperties( Sequence< OUString >( & aUndoStepsPropName, 1 ))); - if( aValues.getLength()) - aValues[0] >>= nSteps; - return nSteps; -} - -} // namespace impl -} // namespace chart diff --git a/chart2/source/tools/ImplUndoManager.hxx b/chart2/source/tools/ImplUndoManager.hxx deleted file mode 100644 index 8c6cfa48979f..000000000000 --- a/chart2/source/tools/ImplUndoManager.hxx +++ /dev/null @@ -1,211 +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_IMPLUNDOMANAGER_HXX -#define CHART2_IMPLUNDOMANAGER_HXX - -#include "ConfigItemListener.hxx" - -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/uno/Sequence.hxx> - -#include <rtl/ustring.hxx> -#include <unotools/configitem.hxx> - -#include <utility> -#include <deque> - -namespace com { namespace sun { namespace star { -namespace chart2 { - class XInternalDataProvider; -} -}}} - - -namespace chart -{ -namespace impl -{ - -class UndoElement -{ -public: - UndoElement( const ::rtl::OUString & rActionString, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElement( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElement( const UndoElement & rOther ); - virtual ~UndoElement(); - - virtual void dispose(); - virtual UndoElement * createFromModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - virtual void applyToModel( - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xInOutModelToChange ); - - void setActionString( const ::rtl::OUString & rActionString ); - ::rtl::OUString getActionString() const; - - static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > cloneModel( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel ); - - static void applyModelContentToModel( - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xInOutModelToChange, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModelToCopyFrom, - const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & xData = 0 ); - -protected: - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > m_xModel; - -private: - void initialize( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - ::rtl::OUString m_aActionString; -}; - -class UndoElementWithData : public UndoElement -{ -public: - UndoElementWithData( const ::rtl::OUString & rActionString, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithData( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithData( const UndoElementWithData & rOther ); - virtual ~UndoElementWithData(); - - virtual void dispose(); - virtual UndoElement * createFromModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - virtual void applyToModel( - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xInOutModelToChange ); - -private: - void initializeData(); - - ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XInternalDataProvider > m_xData; -}; - -class UndoElementWithSelection : public UndoElement -{ -public: - UndoElementWithSelection( const ::rtl::OUString & rActionString, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithSelection( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithSelection( const UndoElementWithSelection & rOther ); - virtual ~UndoElementWithSelection(); - - virtual void dispose(); - virtual UndoElement * createFromModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - virtual void applyToModel( - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xInOutModelToChange ); - -private: - void initialize( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - ::com::sun::star::uno::Any m_aSelection; -}; - -/** Note that all models that are put into this container are at some point - disposed of inside this class. (At least in the destructor). That means - the models retrieved here should never be used, but instead their content - should be copied to a living model. - */ -class UndoStack -{ -public: - UndoStack(); - // disposes of all models left in the stack - ~UndoStack(); - - // removes he last undo action and disposes of the model - void pop(); - void push( UndoElement * rElement ); - - // precondition: !empty() - UndoElement * top() const; - ::rtl::OUString topUndoString() const; - - ::com::sun::star::uno::Sequence< ::rtl::OUString > getUndoStrings() const; - - bool empty() const; - void disposeAndClear(); - - // removes all actions that have been inserted more than nMaxSize steps ago. - // The models of those actions are disposed of - void limitSize( sal_Int32 nMaxSize ); - -private: - void applyLimitation(); - - typedef ::std::deque< UndoElement * > tUndoStackType; - - tUndoStackType m_aStack; - sal_Int32 m_nSizeLimit; -}; - -// ---------------------------------------- - -class UndoStepsConfigItem : public ::utl::ConfigItem -{ -public: - explicit UndoStepsConfigItem( ConfigItemListener & rListener ); - virtual ~UndoStepsConfigItem(); - - sal_Int32 getUndoSteps(); - -protected: - // ____ ::utl::ConfigItem ____ - virtual void Notify( const ::com::sun::star::uno::Sequence< ::rtl::OUString > & aPropertyNames ); - virtual void Commit(); - -private: - ConfigItemListener & m_rListener; -}; - - -} // namespace impl -} // namespace chart - -// CHART2_IMPLUNDOMANAGER_HXX -#endif diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index 59e608248167..0599f9317aed 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -59,6 +59,7 @@ using namespace ::com::sun::star::chart2; using rtl::OUString; using rtl::OUStringBuffer; using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Any; static OUString m_aMultiClick( C2U("MultiClick") ); static OUString m_aDragMethodEquals( C2U("DragMethod=") ); @@ -251,6 +252,94 @@ void lcl_getDiagramAndCooSys( const OUString& rObjectCID } //anonymous namespace +ObjectIdentifier::ObjectIdentifier() + :m_aObjectCID( OUString() ) + ,m_xAdditionalShape( 0 ) +{ +} + +ObjectIdentifier::ObjectIdentifier( const OUString& rObjectCID ) + :m_aObjectCID( rObjectCID ) + ,m_xAdditionalShape( 0 ) +{ +} + +ObjectIdentifier::ObjectIdentifier( const Reference< drawing::XShape >& rxShape ) + :m_aObjectCID( OUString() ) + ,m_xAdditionalShape( rxShape ) +{ +} + +ObjectIdentifier::ObjectIdentifier( const Any& rAny ) + :m_aObjectCID( OUString() ) + ,m_xAdditionalShape( 0 ) +{ + const uno::Type& rType = rAny.getValueType(); + if ( rType == ::getCppuType( static_cast< const OUString* >( 0 ) ) ) + { + rAny >>= m_aObjectCID; + } + else if ( rType == ::getCppuType( static_cast< const Reference< drawing::XShape >* >( 0 ) ) ) + { + rAny >>= m_xAdditionalShape; + } +} + +ObjectIdentifier::~ObjectIdentifier() +{ +} + +ObjectIdentifier::ObjectIdentifier( const ObjectIdentifier& rOID ) + :m_aObjectCID( rOID.m_aObjectCID ) + ,m_xAdditionalShape( rOID.m_xAdditionalShape ) +{ + +} + +ObjectIdentifier& ObjectIdentifier::operator=( const ObjectIdentifier& rOID ) +{ + m_aObjectCID = rOID.m_aObjectCID; + m_xAdditionalShape = rOID.m_xAdditionalShape; + return *this; +} + +bool ObjectIdentifier::operator==( const ObjectIdentifier& rOID ) const +{ + if ( areIdenticalObjects( m_aObjectCID, rOID.m_aObjectCID ) && + ( m_xAdditionalShape == rOID.m_xAdditionalShape ) ) + { + return true; + } + return false; +} + +bool ObjectIdentifier::operator!=( const ObjectIdentifier& rOID ) const +{ + return !operator==( rOID ); +} + +bool ObjectIdentifier::operator<( const ObjectIdentifier& rOID ) const +{ + bool bReturn = false; + if ( m_aObjectCID.getLength() && rOID.m_aObjectCID.getLength() ) + { + bReturn = ( m_aObjectCID.compareTo( rOID.m_aObjectCID ) < 0 ); + } + else if ( m_aObjectCID.getLength() ) + { + bReturn = true; + } + else if ( rOID.m_aObjectCID.getLength() ) + { + bReturn = false; + } + else if ( m_xAdditionalShape.is() && rOID.m_xAdditionalShape.is() ) + { + bReturn = ( m_xAdditionalShape < rOID.m_xAdditionalShape ); + } + return bReturn; +} + //static OUString ObjectIdentifier::createClassifiedIdentifierForObject( const Reference< uno::XInterface >& xObject @@ -665,6 +754,20 @@ bool ObjectIdentifier::isDragableObject( const OUString& rClassifiedIdentifier ) return false; } +bool ObjectIdentifier::isDragableObject() +{ + bool bReturn = false; + if ( isAutoGeneratedObject() ) + { + bReturn = isDragableObject( m_aObjectCID ); + } + else if ( isAdditionalShape() ) + { + bReturn = true; + } + return bReturn; +} + //static bool ObjectIdentifier::isRotateableObject( const OUString& rClassifiedIdentifier ) { @@ -903,6 +1006,20 @@ ObjectType ObjectIdentifier::getObjectType( const OUString& rCID ) return eRet; } +ObjectType ObjectIdentifier::getObjectType() +{ + ObjectType eObjectType( OBJECTTYPE_UNKNOWN ); + if ( isAutoGeneratedObject() ) + { + eObjectType = getObjectType( m_aObjectCID ); + } + else if ( isAdditionalShape() ) + { + eObjectType = OBJECTTYPE_SHAPE; + } + return eObjectType; +} + //static OUString ObjectIdentifier::createDataCurveCID( const OUString& rSeriesParticle @@ -1329,7 +1446,46 @@ OUString ObjectIdentifier::getMovedSeriesCID( const ::rtl::OUString& rObjectCID, OUString aRet = ObjectIdentifier::createParticleForSeries( nDiagramIndex, nCooSysIndex, nChartTypeIndex, nSeriesIndex ); return ObjectIdentifier::createClassifiedIdentifierForParticle( aRet ); } -//static + +bool ObjectIdentifier::isValid() const +{ + return ( isAutoGeneratedObject() || isAdditionalShape() ); +} + +bool ObjectIdentifier::isAutoGeneratedObject() const +{ + return ( m_aObjectCID.getLength() > 0 ); +} + +bool ObjectIdentifier::isAdditionalShape() const +{ + return m_xAdditionalShape.is(); +} + +OUString ObjectIdentifier::getObjectCID() const +{ + return m_aObjectCID; +} + +Reference< drawing::XShape > ObjectIdentifier::getAdditionalShape() const +{ + return m_xAdditionalShape; +} + +Any ObjectIdentifier::getAny() const +{ + Any aAny; + if ( isAutoGeneratedObject() ) + { + aAny = uno::makeAny( getObjectCID() ); + } + else if ( isAdditionalShape() ) + { + aAny = uno::makeAny( getAdditionalShape() ); + } + return aAny; +} + //............................................................................. } //namespace chart //............................................................................. diff --git a/chart2/source/tools/RangeHighlighter.cxx b/chart2/source/tools/RangeHighlighter.cxx index 73c8f064faf0..20359bfa6b4c 100644 --- a/chart2/source/tools/RangeHighlighter.cxx +++ b/chart2/source/tools/RangeHighlighter.cxx @@ -39,6 +39,7 @@ #include <com/sun/star/chart2/XDataSeries.hpp> #include <com/sun/star/chart/ErrorBarStyle.hpp> +#include <com/sun/star/drawing/XShape.hpp> #define PREFERED_DEFAULT_COLOR 0x0000ff @@ -106,66 +107,81 @@ void RangeHighlighter::determineRanges() m_bIncludeHiddenCells = ChartModelHelper::isIncludeHiddenCells( xChartModel ); uno::Any aSelection( m_xSelectionSupplier->getSelection()); - OUString aCID; - if(( aSelection >>= aCID ) && - aCID.getLength() > 0 ) + const uno::Type& rType = aSelection.getValueType(); + + if ( rType == ::getCppuType( static_cast< const OUString* >( 0 ) ) ) { // @todo??: maybe getSelection() should return a model object rather than a CID - ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID ); - sal_Int32 nIndex = ObjectIdentifier::getIndexFromParticleOrCID( aCID ); - Reference< chart2::XDataSeries > xDataSeries( ObjectIdentifier::getDataSeriesForCID( aCID, xChartModel ) ); - if( OBJECTTYPE_LEGEND_ENTRY == eObjectType ) + OUString aCID; + aSelection >>= aCID; + if ( aCID.getLength() > 0 ) { - OUString aParentParticel( ObjectIdentifier::getFullParentParticle( aCID ) ); - ObjectType eParentObjectType = ObjectIdentifier::getObjectType( aParentParticel ); - eObjectType = eParentObjectType; - if( OBJECTTYPE_DATA_POINT == eObjectType ) - nIndex = ObjectIdentifier::getIndexFromParticleOrCID( aParentParticel ); - } + ObjectType eObjectType = ObjectIdentifier::getObjectType( aCID ); + sal_Int32 nIndex = ObjectIdentifier::getIndexFromParticleOrCID( aCID ); + Reference< chart2::XDataSeries > xDataSeries( ObjectIdentifier::getDataSeriesForCID( aCID, xChartModel ) ); + if( OBJECTTYPE_LEGEND_ENTRY == eObjectType ) + { + OUString aParentParticel( ObjectIdentifier::getFullParentParticle( aCID ) ); + ObjectType eParentObjectType = ObjectIdentifier::getObjectType( aParentParticel ); + eObjectType = eParentObjectType; + if( OBJECTTYPE_DATA_POINT == eObjectType ) + nIndex = ObjectIdentifier::getIndexFromParticleOrCID( aParentParticel ); + } - if( OBJECTTYPE_DATA_POINT == eObjectType || OBJECTTYPE_DATA_LABEL == eObjectType ) - { - // Data Point - fillRangesForDataPoint( xDataSeries, nIndex ); - return; - } - else if( OBJECTTYPE_DATA_ERRORS == eObjectType ) - { - // select error bar ranges, or data series, if the style is - // not set to FROM_DATA - fillRangesForErrorBars( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), xDataSeries ); - return; - } - else if( xDataSeries.is() ) - { - // Data Series - fillRangesForDataSeries( xDataSeries ); - return; - } - else if( OBJECTTYPE_AXIS == eObjectType ) - { - // Axis (Categories) - Reference< chart2::XAxis > xAxis( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), uno::UNO_QUERY ); - if( xAxis.is()) + if( OBJECTTYPE_DATA_POINT == eObjectType || OBJECTTYPE_DATA_LABEL == eObjectType ) { - fillRangesForCategories( xAxis ); + // Data Point + fillRangesForDataPoint( xDataSeries, nIndex ); return; } - } - else if( OBJECTTYPE_PAGE == eObjectType - || OBJECTTYPE_DIAGRAM == eObjectType - || OBJECTTYPE_DIAGRAM_WALL == eObjectType - || OBJECTTYPE_DIAGRAM_FLOOR == eObjectType - ) - { - // Diagram - Reference< chart2::XDiagram > xDia( ObjectIdentifier::getDiagramForCID( aCID, xChartModel ) ); - if( xDia.is()) + else if( OBJECTTYPE_DATA_ERRORS == eObjectType ) { - fillRangesForDiagram( xDia ); + // select error bar ranges, or data series, if the style is + // not set to FROM_DATA + fillRangesForErrorBars( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), xDataSeries ); return; } + else if( xDataSeries.is() ) + { + // Data Series + fillRangesForDataSeries( xDataSeries ); + return; + } + else if( OBJECTTYPE_AXIS == eObjectType ) + { + // Axis (Categories) + Reference< chart2::XAxis > xAxis( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ), uno::UNO_QUERY ); + if( xAxis.is()) + { + fillRangesForCategories( xAxis ); + return; + } + } + else if( OBJECTTYPE_PAGE == eObjectType + || OBJECTTYPE_DIAGRAM == eObjectType + || OBJECTTYPE_DIAGRAM_WALL == eObjectType + || OBJECTTYPE_DIAGRAM_FLOOR == eObjectType + ) + { + // Diagram + Reference< chart2::XDiagram > xDia( ObjectIdentifier::getDiagramForCID( aCID, xChartModel ) ); + if( xDia.is()) + { + fillRangesForDiagram( xDia ); + return; + } + } + } + } + else if ( rType == ::getCppuType( static_cast< const Reference< drawing::XShape >* >( 0 ) ) ) + { + // #i12587# support for shapes in chart + Reference< drawing::XShape > xShape; + aSelection >>= xShape; + if ( xShape.is() ) + { + return; } } else diff --git a/chart2/source/tools/UndoGuard.cxx b/chart2/source/tools/UndoGuard.cxx deleted file mode 100644 index 61bed4029db5..000000000000 --- a/chart2/source/tools/UndoGuard.cxx +++ /dev/null @@ -1,135 +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 "UndoGuard.hxx" - -using namespace ::com::sun::star; - -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::rtl::OUString; - -namespace chart -{ - -UndoGuard_Base::UndoGuard_Base( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : m_xModel( xModel ) - , m_xUndoManager( xUndoManager ) - , m_aUndoString( rUndoString ) - , m_bActionPosted( false ) -{ -} - -UndoGuard_Base::~UndoGuard_Base() -{ -} - -void UndoGuard_Base::commitAction() -{ - if( !m_bActionPosted ) - m_xUndoManager->postAction( m_aUndoString ); - m_bActionPosted = true; -} - -//----------------------------------------------------------------------------- - -UndoGuard::UndoGuard( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : UndoGuard_Base( rUndoString, xUndoManager, xModel ) -{ - m_xUndoManager->preAction( m_xModel ); -} - -UndoGuard::~UndoGuard() -{ - if( !m_bActionPosted ) - m_xUndoManager->cancelAction(); -} - -//----------------------------------------------------------------------------- - -UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : UndoGuard_Base( rUndoString, xUndoManager, xModel ) -{ - m_xUndoManager->preAction( m_xModel ); -} - -UndoLiveUpdateGuard::~UndoLiveUpdateGuard() -{ - if( !m_bActionPosted ) - m_xUndoManager->cancelActionWithUndo( m_xModel ); -} - -//----------------------------------------------------------------------------- - -UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : UndoGuard_Base( rUndoString, xUndoManager, xModel ) -{ - Sequence< beans::PropertyValue > aArgs(1); - aArgs[0] = beans::PropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("WithData")), -1, uno::Any(), - beans::PropertyState_DIRECT_VALUE ); - m_xUndoManager->preActionWithArguments( m_xModel, aArgs ); -} - -UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData() -{ - if( !m_bActionPosted ) - m_xUndoManager->cancelActionWithUndo( m_xModel ); -} - -//----------------------------------------------------------------------------- - -UndoGuardWithSelection::UndoGuardWithSelection( const rtl::OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : UndoGuard_Base( rUndoString, xUndoManager, xModel ) -{ - Sequence< beans::PropertyValue > aArgs(1); - aArgs[0] = beans::PropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("WithSelection")), -1, uno::Any(), - beans::PropertyState_DIRECT_VALUE ); - m_xUndoManager->preActionWithArguments( m_xModel, aArgs ); -} - -UndoGuardWithSelection::~UndoGuardWithSelection() -{ - if( !m_bActionPosted ) - m_xUndoManager->cancelAction(); -} - -} // namespace chart diff --git a/chart2/source/tools/UndoManager.cxx b/chart2/source/tools/UndoManager.cxx deleted file mode 100644 index 8c6f191a1a19..000000000000 --- a/chart2/source/tools/UndoManager.cxx +++ /dev/null @@ -1,352 +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 "UndoManager.hxx" -#include "ImplUndoManager.hxx" -#include "DisposeHelper.hxx" -#include "MutexContainer.hxx" -#include "macros.hxx" -#include "ChartViewHelper.hxx" - -#include <com/sun/star/util/XCloneable.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> - -#include <unotools/configitem.hxx> -#include <cppuhelper/compbase1.hxx> - -#include <functional> - -using namespace ::com::sun::star; - -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::rtl::OUString; - - -// -------------------------------------------------------------------------------- - -namespace chart -{ - -namespace impl -{ -typedef ::cppu::WeakComponentImplHelper1< - util::XModifyBroadcaster > - ModifyBroadcaster_Base; - -class ModifyBroadcaster : - public ::chart::MutexContainer, - public ModifyBroadcaster_Base -{ -public: - ModifyBroadcaster(); - - void fireEvent(); - -protected: - // ____ XModifyBroadcaster ____ - virtual void SAL_CALL addModifyListener( const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException); - virtual void SAL_CALL removeModifyListener( const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException); -}; - -ModifyBroadcaster::ModifyBroadcaster() : - ModifyBroadcaster_Base( m_aMutex ) -{} - -void SAL_CALL ModifyBroadcaster::addModifyListener( - const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException) -{ - rBHelper.addListener( ::getCppuType( & xListener ), xListener); -} - -void SAL_CALL ModifyBroadcaster::removeModifyListener( - const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException) -{ - rBHelper.removeListener( ::getCppuType( & xListener ), xListener ); -} - -void ModifyBroadcaster::fireEvent() -{ - ::cppu::OInterfaceContainerHelper* pIC = rBHelper.getContainer( - ::getCppuType((const uno::Reference< util::XModifyListener >*)0) ); - if( pIC ) - { - lang::EventObject aEvent( static_cast< lang::XComponent* >( this ) ); - ::cppu::OInterfaceIteratorHelper aIt( *pIC ); - while( aIt.hasMoreElements() ) - (static_cast< util::XModifyListener*>(aIt.next()))->modified( aEvent ); - } -} - -} // namespace impl - -UndoManager::UndoManager() : - impl::UndoManager_Base( m_aMutex ), - m_apUndoStack( new impl::UndoStack()), - m_apRedoStack( new impl::UndoStack()), - m_pLastRemeberedUndoElement( 0 ), - m_nMaxNumberOfUndos( 100 ), - m_pModifyBroadcaster( 0 ) -{} - -UndoManager::~UndoManager() -{ - DisposeHelper::Dispose( m_xModifyBroadcaster ); - m_apUndoStack->disposeAndClear(); - m_apRedoStack->disposeAndClear(); - - delete m_pLastRemeberedUndoElement; - m_pLastRemeberedUndoElement = 0; -} - -void UndoManager::impl_undoRedo( - Reference< frame::XModel > & xCurrentModel, - impl::UndoStack * pStackToRemoveFrom, - impl::UndoStack * pStackToAddTo ) -{ - if( pStackToRemoveFrom && ! pStackToRemoveFrom->empty() ) - { - // get model from undo/redo - impl::UndoElement * pTop( pStackToRemoveFrom->top()); - if( pTop ) - { - // put a clone of current model into redo/undo stack with the same - // action string as the undo/redo - pStackToAddTo->push( pTop->createFromModel( xCurrentModel )); - // change current model by properties of the model from undo - pTop->applyToModel( xCurrentModel ); - // remove the top undo element - pStackToRemoveFrom->pop(), pTop = 0; - ChartViewHelper::setViewToDirtyState( xCurrentModel ); - fireModifyEvent(); - } - } - else - { - OSL_ENSURE( false, "Can't Undo/Redo" ); - } -} - -void UndoManager::fireModifyEvent() -{ - if( m_xModifyBroadcaster.is()) - m_pModifyBroadcaster->fireEvent(); -} - - -// ____ ConfigItemListener ____ -void UndoManager::notify( const ::rtl::OUString & rPropertyName ) -{ - OSL_ENSURE( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Steps" )), - "Unwanted config property change Notified" ); - if( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Steps" ))) - retrieveConfigUndoSteps(); -} - -void UndoManager::retrieveConfigUndoSteps() -{ - if( ! m_apUndoStepsConfigItem.get()) - m_apUndoStepsConfigItem.reset( new impl::UndoStepsConfigItem( *this )); - m_nMaxNumberOfUndos = m_apUndoStepsConfigItem->getUndoSteps(); - m_apUndoStack->limitSize( m_nMaxNumberOfUndos ); - m_apRedoStack->limitSize( m_nMaxNumberOfUndos ); - - // a list of available undo steps could shrink here - fireModifyEvent(); -} - -// ____ XModifyBroadcaster ____ -void SAL_CALL UndoManager::addModifyListener( const Reference< util::XModifyListener >& aListener ) - throw (uno::RuntimeException) -{ - if( ! m_xModifyBroadcaster.is()) - { - m_pModifyBroadcaster = new impl::ModifyBroadcaster(); - m_xModifyBroadcaster.set( static_cast< cppu::OWeakObject* >( m_pModifyBroadcaster ), uno::UNO_QUERY ); - } - m_xModifyBroadcaster->addModifyListener( aListener ); -} - -void SAL_CALL UndoManager::removeModifyListener( const Reference< util::XModifyListener >& aListener ) - throw (uno::RuntimeException) -{ - if( ! m_xModifyBroadcaster.is()) - { - m_pModifyBroadcaster = new impl::ModifyBroadcaster(); - m_xModifyBroadcaster.set( static_cast< cppu::OWeakObject* >( m_pModifyBroadcaster ), uno::UNO_QUERY ); - } - m_xModifyBroadcaster->removeModifyListener( aListener ); -} - -// ____ chart2::XUndoManager ____ -void SAL_CALL UndoManager::preAction( const Reference< frame::XModel >& xModelBeforeChange ) - throw (uno::RuntimeException) -{ - OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" ); - m_pLastRemeberedUndoElement = new impl::UndoElement( xModelBeforeChange ); -} - -void SAL_CALL UndoManager::preActionWithArguments( - const Reference< frame::XModel >& xModelBeforeChange, - const Sequence< beans::PropertyValue >& aArguments ) - throw (uno::RuntimeException) -{ - bool bActionHandled( false ); - OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" ); - if( aArguments.getLength() > 0 ) - { - OSL_ENSURE( aArguments.getLength() == 1, "More than one argument is not supported yet" ); - if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithData"))) - { - m_pLastRemeberedUndoElement = new impl::UndoElementWithData( xModelBeforeChange ); - bActionHandled = true; - } - else if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithSelection"))) - { - m_pLastRemeberedUndoElement = new impl::UndoElementWithSelection( xModelBeforeChange ); - bActionHandled = true; - } - } - - if( !bActionHandled ) - preAction( xModelBeforeChange ); -} - -void SAL_CALL UndoManager::postAction( const OUString& aUndoText ) - throw (uno::RuntimeException) -{ - OSL_ENSURE( m_pLastRemeberedUndoElement, "Looks like preAction call was missing" ); - if( m_pLastRemeberedUndoElement ) - { - m_pLastRemeberedUndoElement->setActionString( aUndoText ); - m_apUndoStack->push( m_pLastRemeberedUndoElement ); - m_pLastRemeberedUndoElement = 0; - - // redo no longer possible - m_apRedoStack->disposeAndClear(); - - // it suffices to get the number of undo steps from config after the - // first time postAction has been called - if( ! m_apUndoStepsConfigItem.get()) - retrieveConfigUndoSteps(); - - fireModifyEvent(); - } -} - -void SAL_CALL UndoManager::cancelAction() - throw (uno::RuntimeException) -{ - delete m_pLastRemeberedUndoElement; - m_pLastRemeberedUndoElement = 0; -} - -void SAL_CALL UndoManager::cancelActionWithUndo( Reference< frame::XModel >& xModelToRestore ) - throw (uno::RuntimeException) -{ - if( m_pLastRemeberedUndoElement ) - { - m_pLastRemeberedUndoElement->applyToModel( xModelToRestore ); - cancelAction(); - } -} - -void SAL_CALL UndoManager::undo( Reference< frame::XModel >& xCurrentModel ) - throw (uno::RuntimeException) -{ - OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get()); - impl_undoRedo( xCurrentModel, m_apUndoStack.get(), m_apRedoStack.get()); -} - -void SAL_CALL UndoManager::redo( Reference< frame::XModel >& xCurrentModel ) - throw (uno::RuntimeException) -{ - OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get()); - impl_undoRedo( xCurrentModel, m_apRedoStack.get(), m_apUndoStack.get()); -} - -::sal_Bool SAL_CALL UndoManager::undoPossible() - throw (uno::RuntimeException) -{ - return ! m_apUndoStack->empty(); -} - -::sal_Bool SAL_CALL UndoManager::redoPossible() - throw (uno::RuntimeException) -{ - return ! m_apRedoStack->empty(); -} - -OUString SAL_CALL UndoManager::getCurrentUndoString() - throw (uno::RuntimeException) -{ - return m_apUndoStack->topUndoString(); -} - -OUString SAL_CALL UndoManager::getCurrentRedoString() - throw (uno::RuntimeException) -{ - return m_apRedoStack->topUndoString(); -} - -Sequence< OUString > SAL_CALL UndoManager::getAllUndoStrings() - throw (uno::RuntimeException) -{ - return m_apUndoStack->getUndoStrings(); -} - -Sequence< OUString > SAL_CALL UndoManager::getAllRedoStrings() - throw (uno::RuntimeException) -{ - return m_apRedoStack->getUndoStrings(); -} - -// ____ XUndoHelper ____ -Reference< frame::XModel > SAL_CALL UndoManager::getModelCloneForUndo( - const Reference< frame::XModel >& xModelBeforeChange ) - throw (uno::RuntimeException) -{ - return impl::UndoElement::cloneModel( xModelBeforeChange ); -} - -void SAL_CALL UndoManager::applyModelContent( - Reference< frame::XModel >& xModelToChange, - const Reference< frame::XModel >& xModelToCopyFrom ) - throw (uno::RuntimeException) -{ - impl::UndoElement::applyModelContentToModel( xModelToChange, xModelToCopyFrom ); -} - -} // namespace chart diff --git a/chart2/source/tools/makefile.mk b/chart2/source/tools/makefile.mk index b459d489e773..2b6e0cf518c1 100644 --- a/chart2/source/tools/makefile.mk +++ b/chart2/source/tools/makefile.mk @@ -101,9 +101,6 @@ SLOFILES= \ $(SLO)$/ChartDebugTrace.obj \ $(SLO)$/_serviceregistration_tools.obj \ $(SLO)$/UncachedDataSequence.obj \ - $(SLO)$/UndoManager.obj \ - $(SLO)$/UndoGuard.obj \ - $(SLO)$/ImplUndoManager.obj \ $(SLO)$/XMLRangeHelper.obj \ $(SLO)$/ModifyListenerHelper.obj \ $(SLO)$/ModifyListenerCallBack.obj \ |