summaryrefslogtreecommitdiff
path: root/chart2/source/controller
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2010-11-16 13:10:17 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2010-11-16 13:10:17 +0100
commit2f09474ea14bf08a33e0788905a2a68bf5f93b2d (patch)
tree3f6e98d0ea92b4857afcb3dea0fbfbae20503f85 /chart2/source/controller
parentfa0b1d6e1d2850cae0cd11e33d662c8d8fad20a9 (diff)
undoapi: some cleanups after the previos refactoring (more to come)
Diffstat (limited to 'chart2/source/controller')
-rw-r--r--chart2/source/controller/dialogs/Strings.src4
-rw-r--r--chart2/source/controller/main/ChartController.cxx2
-rw-r--r--chart2/source/controller/main/ChartController_TextEdit.cxx5
-rwxr-xr-xchart2/source/controller/main/ChartModelClone.cxx280
-rwxr-xr-xchart2/source/controller/main/ChartModelClone.hxx89
-rw-r--r--chart2/source/controller/main/ImplDocumentActions.cxx211
-rw-r--r--chart2/source/controller/main/ImplDocumentActions.hxx39
-rw-r--r--chart2/source/controller/main/UndoGuard.cxx48
-rw-r--r--chart2/source/controller/main/makefile.mk6
9 files changed, 395 insertions, 289 deletions
diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src
index 4b4cec65426e..3b46d4441a0b 100644
--- a/chart2/source/controller/dialogs/Strings.src
+++ b/chart2/source/controller/dialogs/Strings.src
@@ -463,6 +463,10 @@ String STR_ACTION_NOTPOSSIBLE
{
Text [ en-US ] = "This function cannot be completed with the selected objects." ;
};
+String STR_ACTION_EDIT_TEXT
+{
+ Text [ en-US ] = "Edit text";
+};
String STR_COLUMN_LABEL
{
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index cebb2a574838..7df48b757174 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -616,7 +616,7 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent
m_pChartWindow->Invalidate();
uno::Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW );
- m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW );
+ m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW );
return sal_True;
}
diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx
index 8069fd43f8cf..6d7844c1307c 100644
--- a/chart2/source/controller/main/ChartController_TextEdit.cxx
+++ b/chart2/source/controller/main/ChartController_TextEdit.cxx
@@ -29,6 +29,7 @@
#include "precompiled_chart2.hxx"
#include "ChartController.hxx"
+#include "ResId.hxx"
#include "UndoGuard.hxx"
#include "DrawViewWrapper.hxx"
#include "ChartWindow.hxx"
@@ -37,6 +38,7 @@
#include "macros.hxx"
#include "ControllerLockGuard.hxx"
#include "AccessibleTextHelper.hxx"
+#include "Strings.hrc"
#include "chartview/DrawModelWrapper.hxx"
#include <svx/svdotext.hxx>
@@ -82,7 +84,8 @@ void ChartController::StartTextEdit( const Point* pMousePixel )
return;
OSL_PRECOND( !m_pTextActionUndoGuard.get(), "ChartController::StartTextEdit: already have a TextUndoGuard!?" );
- m_pTextActionUndoGuard.reset( new UndoGuard( C2U( "Text Edit" ), m_xUndoManager ) );
+ m_pTextActionUndoGuard.reset( new UndoGuard(
+ String( SchResId( STR_ACTION_EDIT_TEXT ) ), m_xUndoManager ) );
SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner();
//pOutliner->SetRefDevice(m_pChartWindow);
//pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)pStyleSheetPool);
diff --git a/chart2/source/controller/main/ChartModelClone.cxx b/chart2/source/controller/main/ChartModelClone.cxx
new file mode 100755
index 000000000000..f04f74ec72b1
--- /dev/null
+++ b/chart2/source/controller/main/ChartModelClone.cxx
@@ -0,0 +1,280 @@
+/*************************************************************************
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_chart2.hxx"
+
+#include "ChartModelClone.hxx"
+#include "ChartModelHelper.hxx"
+#include "ControllerLockGuard.hxx"
+#include "DataSourceHelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/util/XCloneable.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
+#include <com/sun/star/chart2/XTitled.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/chart2/data/XDataSource.hpp>
+#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/property.hxx>
+#include <tools/diagnose_ex.h>
+
+//......................................................................................................................
+namespace chart
+{
+//......................................................................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::util::XCloneable;
+ using ::com::sun::star::chart2::XChartDocument;
+ using ::com::sun::star::chart2::XInternalDataProvider;
+ using ::com::sun::star::chart::XComplexDescriptionAccess;
+ using ::com::sun::star::view::XSelectionSupplier;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::chart2::XTitled;
+ using ::com::sun::star::util::XModifiable;
+ using ::com::sun::star::chart2::data::XDataSource;
+ using ::com::sun::star::chart2::data::XLabeledDataSequence;
+ /** === end UNO using === **/
+
+ // =================================================================================================================
+ // = helper
+ // =================================================================================================================
+ namespace
+ {
+ Reference< XModel > lcl_cloneModel( const Reference< XModel > & xModel )
+ {
+ Reference< XModel > xResult;
+ try
+ {
+ const Reference< XCloneable > xCloneable( xModel, UNO_QUERY_THROW );
+ xResult.set( xCloneable->createClone(), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xResult;
+ }
+
+ }
+
+ // =================================================================================================================
+ // = ChartModelClone
+ // =================================================================================================================
+ // -----------------------------------------------------------------------------------------------------------------
+ ChartModelClone::ChartModelClone( const Reference< XModel >& i_model, const ModelFacet i_facet )
+ {
+ m_xModelClone.set( lcl_cloneModel( i_model ) );
+
+ try
+ {
+ if ( i_facet == E_MODEL_WITH_DATA )
+ {
+ const Reference< XChartDocument > xChartDoc( m_xModelClone, UNO_QUERY_THROW );
+ ENSURE_OR_THROW( xChartDoc->hasInternalDataProvider(), "invalid chart model" );
+
+ const Reference< XCloneable > xCloneable( xChartDoc->getDataProvider(), UNO_QUERY_THROW );
+ m_xDataClone.set( xCloneable->createClone(), UNO_QUERY_THROW );
+ }
+
+ if ( i_facet == E_MODEL_WITH_SELECTION )
+ {
+ const Reference< XSelectionSupplier > xSelSupp( m_xModelClone->getCurrentController(), UNO_QUERY_THROW );
+ m_aSelection = xSelSupp->getSelection();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+
+ // -----------------------------------------------------------------------------------------------------------------
+ ChartModelClone::~ChartModelClone()
+ {
+ if ( !impl_isDisposed() )
+ dispose();
+ }
+
+ // -----------------------------------------------------------------------------------------------------------------
+ void ChartModelClone::dispose()
+ {
+ if ( impl_isDisposed() )
+ return;
+
+ try
+ {
+ Reference< XComponent > xComp( m_xModelClone, UNO_QUERY_THROW );
+ xComp->dispose();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_xModelClone.clear();
+ m_xDataClone.clear();
+ m_aSelection.clear();
+ }
+
+ // -----------------------------------------------------------------------------------------------------------------
+ ModelFacet ChartModelClone::getFacet() const
+ {
+ if ( m_aSelection.hasValue() )
+ return E_MODEL_WITH_SELECTION;
+ if ( m_xDataClone.is() )
+ return E_MODEL_WITH_DATA;
+ return E_MODEL;
+ }
+
+ // -----------------------------------------------------------------------------------------------------------------
+ void ChartModelClone::applyToModel( const Reference< XModel >& i_model ) const
+ {
+ applyModelContentToModel( i_model, m_xModelClone, m_xDataClone );
+
+ if ( m_aSelection.hasValue() )
+ {
+ try
+ {
+ Reference< XSelectionSupplier > xCurrentSelectionSuppl( i_model->getCurrentController(), UNO_QUERY_THROW );
+ xCurrentSelectionSuppl->select( m_aSelection );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ // -----------------------------------------------------------------------------------------------------------------
+ namespace
+ {
+ void ImplApplyDataToModel( const Reference< XModel >& i_model, const Reference< XInternalDataProvider > & i_data )
+ {
+ Reference< XChartDocument > xDoc( i_model, UNO_QUERY );
+ OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider() );
+
+ // copy data from stored internal data provider
+ if( xDoc.is() && xDoc->hasInternalDataProvider())
+ {
+ Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), UNO_QUERY );
+ Reference< XComplexDescriptionAccess > xSavedData( i_data, UNO_QUERY );
+ if ( xCurrentData.is() && xSavedData.is() )
+ {
+ xCurrentData->setData( xSavedData->getData() );
+ xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions() );
+ xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions() );
+ }
+ }
+ }
+ }
+
+ // -----------------------------------------------------------------------------------------------------------------
+ void ChartModelClone::applyModelContentToModel( const Reference< XModel >& i_model,
+ const Reference< XModel >& i_modelToCopyFrom, const Reference< XInternalDataProvider >& i_data )
+ {
+ ENSURE_OR_RETURN_VOID( i_model.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" );
+ ENSURE_OR_RETURN_VOID( i_modelToCopyFrom.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" );
+ try
+ {
+ // /-- loccked controllers of destination
+ ControllerLockGuard aLockedControllers( i_model );
+ Reference< XChartDocument > xSource( i_modelToCopyFrom, UNO_QUERY_THROW );
+ Reference< XChartDocument > xDestination( i_model, UNO_QUERY_THROW );
+
+ // propagate the correct flag for plotting of hidden values to the data provider and all used sequences
+ ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( i_modelToCopyFrom ) , i_model );
+
+ // diagram
+ xDestination->setFirstDiagram( xSource->getFirstDiagram() );
+
+ // main title
+ Reference< XTitled > xDestinationTitled( xDestination, UNO_QUERY_THROW );
+ Reference< XTitled > xSourceTitled( xSource, UNO_QUERY_THROW );
+ xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject() );
+
+ // page background
+ ::comphelper::copyProperties(
+ xSource->getPageBackground(),
+ xDestination->getPageBackground() );
+
+ // apply data (not applied in standard Undo)
+ if ( i_data.is() )
+ ImplApplyDataToModel( i_model, i_data );
+
+ // register all sequences at the internal data provider to get adapted
+ // indexes when columns are added/removed
+ if ( xDestination->hasInternalDataProvider() )
+ {
+ Reference< XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), UNO_QUERY );
+ Reference< XDataSource > xUsedData( DataSourceHelper::getUsedData( i_model ) );
+ if ( xUsedData.is() && xNewDataProvider.is() )
+ {
+ Sequence< Reference< 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< XModifiable > xSourceMod( xSource, UNO_QUERY );
+ Reference< XModifiable > xDestMod( xDestination, UNO_QUERY );
+ if ( xSourceMod.is() && xDestMod.is() && !xSourceMod->isModified() )
+ {
+ xDestMod->setModified( sal_False );
+ }
+ // \-- loccked controllers of destination
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+
+//......................................................................................................................
+} // namespace chart
+//......................................................................................................................
diff --git a/chart2/source/controller/main/ChartModelClone.hxx b/chart2/source/controller/main/ChartModelClone.hxx
new file mode 100755
index 000000000000..d5653b8e1ccc
--- /dev/null
+++ b/chart2/source/controller/main/ChartModelClone.hxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ * 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_CHARTMODELCLONE_HXX
+#define CHART2_CHARTMODELCLONE_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/chart2/XInternalDataProvider.hpp>
+/** === end UNO includes === **/
+
+#include <boost/noncopyable.hpp>
+
+//......................................................................................................................
+namespace chart
+{
+//......................................................................................................................
+
+ //==================================================================================================================
+ //= ModelFacet
+ //==================================================================================================================
+ enum ModelFacet
+ {
+ E_MODEL,
+ E_MODEL_WITH_DATA,
+ E_MODEL_WITH_SELECTION
+ };
+
+ //==================================================================================================================
+ //= ChartModelClone
+ //==================================================================================================================
+ class ChartModelClone : public ::boost::noncopyable
+ {
+ public:
+ ChartModelClone(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model,
+ const ModelFacet i_facet
+ );
+
+ ~ChartModelClone();
+
+ ModelFacet getFacet() const;
+
+ void applyToModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model ) const;
+
+ static void applyModelContentToModel(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_model,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_modelToCopyFrom,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & i_data );
+
+ void dispose();
+
+ private:
+ bool impl_isDisposed() const { return !m_xModelClone.is(); }
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModelClone;
+ ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > m_xDataClone;
+ ::com::sun::star::uno::Any m_aSelection;
+ };
+
+//......................................................................................................................
+} // namespace chart
+//......................................................................................................................
+
+#endif // CHART2_CHARTMODELCLONE_HXX
diff --git a/chart2/source/controller/main/ImplDocumentActions.cxx b/chart2/source/controller/main/ImplDocumentActions.cxx
index f477052908ff..a565c81dad56 100644
--- a/chart2/source/controller/main/ImplDocumentActions.cxx
+++ b/chart2/source/controller/main/ImplDocumentActions.cxx
@@ -31,17 +31,11 @@
#include "ImplDocumentActions.hxx"
#include "DisposeHelper.hxx"
#include "CommonFunctors.hxx"
-#include "ControllerLockGuard.hxx"
#include "PropertyHelper.hxx"
-#include "DataSourceHelper.hxx"
-#include "ChartModelHelper.hxx"
+#include "ChartModelClone.hxx"
-#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
-#include <com/sun/star/chart2/XInternalDataProvider.hpp>
-#include <com/sun/star/chart2/XTitled.hpp>
#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/util/XModifiable.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
@@ -78,212 +72,9 @@ namespace impl
using ::com::sun::star::lang::DisposedException;
using ::com::sun::star::view::XSelectionSupplier;
using ::com::sun::star::chart2::XChartDocument;
- using ::com::sun::star::chart::XComplexDescriptionAccess;
- using ::com::sun::star::chart2::XTitled;
- using ::com::sun::star::chart2::XInternalDataProvider;
- using ::com::sun::star::util::XModifiable;
using ::com::sun::star::document::UndoFailedException;
/** === end UNO using === **/
-// =====================================================================================================================
-// = helper
-// =====================================================================================================================
-namespace
-{
- Reference< XModel > lcl_cloneModel( const Reference< XModel > & xModel )
- {
- Reference< XModel > xResult;
- try
- {
- const Reference< XCloneable > xCloneable( xModel, UNO_QUERY_THROW );
- xResult.set( xCloneable->createClone(), UNO_QUERY_THROW );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- return xResult;
- }
-
-}
-
-// =====================================================================================================================
-// = ChartModelClone
-// =====================================================================================================================
-
-// ---------------------------------------------------------------------------------------------------------------------
-ChartModelClone::ChartModelClone( const Reference< XModel >& i_model, const ModelFacet i_facet )
-{
- m_xModelClone.set( lcl_cloneModel( i_model ) );
-
- try
- {
- if ( i_facet == E_MODEL_WITH_DATA )
- {
- const Reference< XChartDocument > xChartDoc( m_xModelClone, UNO_QUERY_THROW );
- ENSURE_OR_THROW( xChartDoc->hasInternalDataProvider(), "invalid chart model" );
-
- const Reference< XCloneable > xCloneable( xChartDoc->getDataProvider(), UNO_QUERY_THROW );
- m_xDataClone.set( xCloneable->createClone(), UNO_QUERY_THROW );
- }
-
- if ( i_facet == E_MODEL_WITH_SELECTION )
- {
- const Reference< XSelectionSupplier > xSelSupp( m_xModelClone->getCurrentController(), UNO_QUERY_THROW );
- m_aSelection = xSelSupp->getSelection();
- }
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
-}
-
-
-// ---------------------------------------------------------------------------------------------------------------------
-ChartModelClone::~ChartModelClone()
-{
- if ( !impl_isDisposed() )
- dispose();
-}
-
-// ---------------------------------------------------------------------------------------------------------------------
-void ChartModelClone::dispose()
-{
- if ( impl_isDisposed() )
- return;
-
- try
- {
- Reference< XComponent > xComp( m_xModelClone, UNO_QUERY_THROW );
- xComp->dispose();
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- m_xModelClone.clear();
- m_xDataClone.clear();
- m_aSelection.clear();
-}
-
-// ---------------------------------------------------------------------------------------------------------------------
-ModelFacet ChartModelClone::getFacet() const
-{
- if ( m_aSelection.hasValue() )
- return E_MODEL_WITH_SELECTION;
- if ( m_xDataClone.is() )
- return E_MODEL_WITH_DATA;
- return E_MODEL;
-}
-
-// ---------------------------------------------------------------------------------------------------------------------
-void ChartModelClone::applyToModel( const Reference< XModel >& i_model ) const
-{
- applyModelContentToModel( i_model, m_xModelClone, m_xDataClone );
-
- if ( m_aSelection.hasValue() )
- {
- try
- {
- Reference< XSelectionSupplier > xCurrentSelectionSuppl( i_model->getCurrentController(), UNO_QUERY_THROW );
- xCurrentSelectionSuppl->select( m_aSelection );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- }
-}
-
-// ---------------------------------------------------------------------------------------------------------------------
-namespace
-{
- void ImplApplyDataToModel( const Reference< XModel >& i_model, const Reference< XInternalDataProvider > & i_data )
- {
- Reference< XChartDocument > xDoc( i_model, UNO_QUERY );
- OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider() );
-
- // copy data from stored internal data provider
- if( xDoc.is() && xDoc->hasInternalDataProvider())
- {
- Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), UNO_QUERY );
- Reference< XComplexDescriptionAccess > xSavedData( i_data, UNO_QUERY );
- if ( xCurrentData.is() && xSavedData.is() )
- {
- xCurrentData->setData( xSavedData->getData() );
- xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions() );
- xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions() );
- }
- }
- }
-}
-
-// ---------------------------------------------------------------------------------------------------------------------
-void ChartModelClone::applyModelContentToModel( const Reference< XModel >& i_model,
- const Reference< XModel >& i_modelToCopyFrom, const Reference< XInternalDataProvider >& i_data )
-{
- ENSURE_OR_RETURN_VOID( i_model.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" );
- ENSURE_OR_RETURN_VOID( i_modelToCopyFrom.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" );
- try
- {
- // /-- loccked controllers of destination
- ControllerLockGuard aLockedControllers( i_model );
- Reference< XChartDocument > xSource( i_modelToCopyFrom, UNO_QUERY_THROW );
- Reference< XChartDocument > xDestination( i_model, UNO_QUERY_THROW );
-
- // propagate the correct flag for plotting of hidden values to the data provider and all used sequences
- ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( i_modelToCopyFrom ) , i_model );
-
- // diagram
- xDestination->setFirstDiagram( xSource->getFirstDiagram() );
-
- // main title
- Reference< XTitled > xDestinationTitled( xDestination, UNO_QUERY_THROW );
- Reference< XTitled > xSourceTitled( xSource, UNO_QUERY_THROW );
- xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject() );
-
- // page background
- ::comphelper::copyProperties(
- xSource->getPageBackground(),
- xDestination->getPageBackground() );
-
- // apply data (not applied in standard Undo)
- if ( i_data.is() )
- ImplApplyDataToModel( i_model, i_data );
-
- // register all sequences at the internal data provider to get adapted
- // indexes when columns are added/removed
- if ( xDestination->hasInternalDataProvider() )
- {
- Reference< XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), UNO_QUERY );
- Reference< chart2::data::XDataSource > xUsedData( DataSourceHelper::getUsedData( i_model ) );
- 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< XModifiable > xSourceMod( xSource, UNO_QUERY );
- Reference< XModifiable > xDestMod( xDestination, UNO_QUERY );
- if ( xSourceMod.is() && xDestMod.is() && !xSourceMod->isModified() )
- {
- xDestMod->setModified( sal_False );
- }
- // \-- loccked controllers of destination
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
-}
-
// ---------------------------------------------------------------------------------------------------------------------
UndoElement::UndoElement( const OUString& i_actionString, const Reference< XModel >& i_documentModel, const ::boost::shared_ptr< ChartModelClone >& i_modelClone )
:UndoElement_MBase()
diff --git a/chart2/source/controller/main/ImplDocumentActions.hxx b/chart2/source/controller/main/ImplDocumentActions.hxx
index 889968dfe4c7..2c98d6af1d54 100644
--- a/chart2/source/controller/main/ImplDocumentActions.hxx
+++ b/chart2/source/controller/main/ImplDocumentActions.hxx
@@ -55,45 +55,10 @@ namespace chart2 {
namespace chart
{
-namespace impl
-{
-
-enum ModelFacet
-{
- E_MODEL,
- E_MODEL_WITH_DATA,
- E_MODEL_WITH_SELECTION
-};
+class ChartModelClone;
-class ChartModelClone : public ::boost::noncopyable
+namespace impl
{
-public:
- ChartModelClone(
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model,
- const ModelFacet i_facet
- );
-
- ~ChartModelClone();
-
- ModelFacet getFacet() const;
-
- void applyToModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model ) const;
-
- static void applyModelContentToModel(
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_model,
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_modelToCopyFrom,
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & i_data );
-
- void dispose();
-
-private:
- bool impl_isDisposed() const { return !m_xModelClone.is(); }
-
-private:
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModelClone;
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > m_xDataClone;
- ::com::sun::star::uno::Any m_aSelection;
-};
typedef ::cppu::BaseMutex UndoElement_MBase;
typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > UndoElement_TBase;
diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx
index 1be8af4de180..e331aee3a762 100644
--- a/chart2/source/controller/main/UndoGuard.cxx
+++ b/chart2/source/controller/main/UndoGuard.cxx
@@ -29,6 +29,7 @@
#include "precompiled_chart2.hxx"
#include "UndoGuard.hxx"
+#include "ChartModelClone.hxx"
#include "ImplDocumentActions.hxx"
#include <com/sun/star/container/XChild.hpp>
@@ -46,17 +47,20 @@ namespace chart
//-----------------------------------------------------------------------------
-UndoGuard_Base::UndoGuard_Base( const OUString& i_undoString, const uno::Reference< document::XUndoManager > & i_undoManager )
+UndoGuard::UndoGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager > & i_undoManager,
+ const ModelFacet i_facet )
:m_xChartModel( i_undoManager->getParent(), uno::UNO_QUERY_THROW )
,m_xUndoManager( i_undoManager )
+ ,m_pDocumentSnapshot()
,m_aUndoString( i_undoString )
,m_bActionPosted( false )
{
+ m_pDocumentSnapshot.reset( new ChartModelClone( m_xChartModel, i_facet ) );
}
//-----------------------------------------------------------------------------
-UndoGuard_Base::~UndoGuard_Base()
+UndoGuard::~UndoGuard()
{
if ( !!m_pDocumentSnapshot )
discardSnapshot();
@@ -64,7 +68,7 @@ UndoGuard_Base::~UndoGuard_Base()
//-----------------------------------------------------------------------------
-void UndoGuard_Base::commit()
+void UndoGuard::commit()
{
if ( !m_bActionPosted && !!m_pDocumentSnapshot && m_xUndoManager.is() )
{
@@ -77,7 +81,7 @@ void UndoGuard_Base::commit()
//-----------------------------------------------------------------------------
-void UndoGuard_Base::rollback()
+void UndoGuard::rollback()
{
ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" );
m_pDocumentSnapshot->applyToModel( m_xChartModel );
@@ -85,19 +89,7 @@ void UndoGuard_Base::rollback()
}
//-----------------------------------------------------------------------------
-
-void UndoGuard_Base::takeSnapshot( bool i_withData, bool i_withSelection )
-{
- impl::ModelFacet eModelFacet( impl::E_MODEL );
- if ( i_withData )
- eModelFacet = impl::E_MODEL_WITH_DATA;
- else if ( i_withSelection )
- eModelFacet = impl::E_MODEL_WITH_SELECTION;
- m_pDocumentSnapshot.reset( new impl::ChartModelClone( m_xChartModel, eModelFacet ) );
-}
-
-//-----------------------------------------------------------------------------
-void UndoGuard_Base::discardSnapshot()
+void UndoGuard::discardSnapshot()
{
ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" );
m_pDocumentSnapshot->dispose();
@@ -106,23 +98,9 @@ void UndoGuard_Base::discardSnapshot()
//-----------------------------------------------------------------------------
-UndoGuard::UndoGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
- :UndoGuard_Base( i_undoString, i_undoManager )
-{
- takeSnapshot( false, false );
-}
-
-UndoGuard::~UndoGuard()
-{
- // nothing to do ... TODO: can this class be removed?
-}
-
-//-----------------------------------------------------------------------------
-
UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
- :UndoGuard_Base( i_undoString, i_undoManager )
+ :UndoGuard( i_undoString, i_undoManager, E_MODEL )
{
- takeSnapshot( false, false );
}
UndoLiveUpdateGuard::~UndoLiveUpdateGuard()
@@ -135,9 +113,8 @@ UndoLiveUpdateGuard::~UndoLiveUpdateGuard()
UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData(
const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
- :UndoGuard_Base( i_undoString, i_undoManager )
+ :UndoGuard( i_undoString, i_undoManager, E_MODEL_WITH_DATA )
{
- takeSnapshot( true, false );
}
UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData()
@@ -150,9 +127,8 @@ UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData()
UndoGuardWithSelection::UndoGuardWithSelection(
const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
- :UndoGuard_Base( i_undoString, i_undoManager )
+ :UndoGuard( i_undoString, i_undoManager, E_MODEL_WITH_SELECTION )
{
- takeSnapshot( false, true );
}
UndoGuardWithSelection::~UndoGuardWithSelection()
diff --git a/chart2/source/controller/main/makefile.mk b/chart2/source/controller/main/makefile.mk
index b8bbd0615a76..af2dbcb39c8d 100644
--- a/chart2/source/controller/main/makefile.mk
+++ b/chart2/source/controller/main/makefile.mk
@@ -73,10 +73,8 @@ SLOFILES = \
$(SLO)$/ShapeController.obj \
$(SLO)$/ShapeToolbarController.obj \
$(SLO)$/ImplDocumentActions.obj \
- $(SLO)$/UndoGuard.obj
-
-# $(SLO)$/CommonConverters.obj \
-# $(SLO)$/Scaling.obj \
+ $(SLO)$/UndoGuard.obj \
+ $(SLO)$/ChartModelClone.obj \
# --- Targets -----------------------------------------------------------------