summaryrefslogtreecommitdiff
path: root/chart2/source/controller
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2010-11-16 08:49:38 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2010-11-16 08:49:38 +0100
commit4d0ae2eac2ac03475b7496f81e803b9b71b7481f (patch)
treea3dec753cf2a69951829ca75e200648c1b647f88 /chart2/source/controller
parent3909360c32b8e018bab468db7aece015c6d1a2b4 (diff)
undoapi: step 2.3 of the migration of css.chart2.XUndoManager to css.document.XUndoManager:
migrate the clients of XDocumentActions to using the new XUndoManager, and completely remove the (X)DocumentActions still some more cleanup needed
Diffstat (limited to 'chart2/source/controller')
-rw-r--r--chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx8
-rw-r--r--chart2/source/controller/main/ChartController.cxx40
-rw-r--r--chart2/source/controller/main/ChartController.hxx7
-rw-r--r--chart2/source/controller/main/ChartController_EditData.cxx4
-rw-r--r--chart2/source/controller/main/ChartController_Insert.cxx134
-rw-r--r--chart2/source/controller/main/ChartController_Position.cxx4
-rw-r--r--chart2/source/controller/main/ChartController_Properties.cxx8
-rw-r--r--chart2/source/controller/main/ChartController_TextEdit.cxx27
-rw-r--r--chart2/source/controller/main/ChartController_Tools.cxx64
-rw-r--r--chart2/source/controller/main/ChartController_Window.cxx12
-rw-r--r--chart2/source/controller/main/CommandDispatchContainer.hxx2
-rw-r--r--chart2/source/controller/main/DocumentActions.cxx392
-rw-r--r--chart2/source/controller/main/UndoCommandDispatch.cxx51
-rw-r--r--chart2/source/controller/main/UndoCommandDispatch.hxx7
-rw-r--r--chart2/source/controller/main/UndoGuard.cxx133
-rw-r--r--chart2/source/controller/main/makefile.mk1
16 files changed, 267 insertions, 627 deletions
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index 2ba38e9582e1..29d7735e02a8 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -56,7 +56,6 @@
#include "WrappedAddInProperty.hxx"
#include "WrappedIgnoreProperty.hxx"
#include "ChartRenderer.hxx"
-#include "DocumentActions.hxx"
#include <com/sun/star/chart2/XTitled.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
@@ -1412,13 +1411,6 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance(
xResult.set( m_xChartView );
bServiceFound = true;
}
- else if ( aServiceSpecifier.equals( CHART_DOCUMENT_ACTIONS_SERVICE_NAME ) )
- {
- Reference< XModel > xModel( queryInterface( XModel::static_type() ), UNO_QUERY_THROW );
- Reference< chart2::XDocumentActions > xDocumentActions( new DocumentActions( xModel ) );
- xResult.set( xDocumentActions );
- bServiceFound = true;
- }
else
{
// try to create a shape
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index 4e29cc45907b..cebb2a574838 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -49,11 +49,10 @@
#include "macros.hxx"
#include "dlg_CreationWizard.hxx"
#include "dlg_ChartType.hxx"
-//#include "svx/ActionDescriptionProvider.hxx"
#include "AccessibleChartView.hxx"
#include "DrawCommandDispatch.hxx"
#include "ShapeController.hxx"
-#include "DocumentActions.hxx"
+#include "ImplDocumentActions.hxx"
#include <comphelper/InlineContainer.hxx>
@@ -66,6 +65,8 @@
#include <com/sun/star/util/XModeChangeBroadcaster.hpp>
#include <com/sun/star/util/XModifyBroadcaster.hpp>
#include <com/sun/star/frame/LayoutManagerEvents.hpp>
+#include <com/sun/star/document/XUndoManagerSupplier.hpp>
+#include <com/sun/star/document/XUndoAction.hpp>
//-------
// header for define RET_OK
@@ -85,6 +86,7 @@
// object in the DTOR
#include <svtools/acceleratorexecute.hxx>
#include <svx/ActionDescriptionProvider.hxx>
+#include <tools/diagnose_ex.h>
// enable the following define to let the controller listen to model changes and
// react on this by rebuilding the view
@@ -127,7 +129,7 @@ ChartController::ChartController(uno::Reference<uno::XComponentContext> const &
, m_bWaitingForDoubleClick(false)
, m_bWaitingForMouseUp(false)
, m_bConnectingToView(false)
- , m_xDocumentActions( 0 )
+ , m_xUndoManager( 0 )
, m_aDispatchContainer( m_xCC, this )
, m_eDrawMode( CHARTDRAW_SELECT )
{
@@ -613,7 +615,8 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent
if( m_pChartWindow )
m_pChartWindow->Invalidate();
- m_xDocumentActions.set( getModel(), uno::UNO_QUERY );
+ uno::Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW );
+ m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW );
return sal_True;
}
@@ -814,7 +817,7 @@ void ChartController::impl_deleteDrawViewController()
}
m_xFrame.clear();
- m_xDocumentActions.clear();
+ m_xUndoManager.clear();
TheModelRef aModelRef( m_aModel, m_aModelMutex);
m_aModel = NULL;
@@ -951,7 +954,7 @@ bool ChartController::impl_releaseThisModel( const uno::Reference< uno::XInterfa
if( m_aModel.is() && m_aModel->getModel() == xModel )
{
m_aModel = NULL;
- m_xDocumentActions.clear();
+ m_xUndoManager.clear();
bReleaseModel = true;
}
}
@@ -1323,7 +1326,7 @@ void SAL_CALL ChartController::executeDispatch_ChartType()
{
// using assignment for broken gcc 3.3
UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
- String( SchResId( STR_ACTION_EDIT_CHARTTYPE )), m_xDocumentActions );
+ String( SchResId( STR_ACTION_EDIT_CHARTTYPE )), m_xUndoManager );
// /--
::vos::OGuard aSolarGuard( Application::GetSolarMutex());
@@ -1332,7 +1335,7 @@ void SAL_CALL ChartController::executeDispatch_ChartType()
if( aDlg.Execute() == RET_OK )
{
impl_adaptDataSeriesAutoResize();
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
// \--
}
@@ -1348,7 +1351,7 @@ void SAL_CALL ChartController::executeDispatch_SourceData()
// using assignment for broken gcc 3.3
UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
- String( SchResId( STR_ACTION_EDIT_DATA_RANGES )), m_xDocumentActions );
+ String( SchResId( STR_ACTION_EDIT_DATA_RANGES )), m_xUndoManager );
if( xChartDoc.is())
{
// /--
@@ -1357,7 +1360,7 @@ void SAL_CALL ChartController::executeDispatch_SourceData()
if( aDlg.Execute() == RET_OK )
{
impl_adaptDataSeriesAutoResize();
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
// \--
}
@@ -1376,13 +1379,13 @@ void SAL_CALL ChartController::executeDispatch_MoveSeries( sal_Bool bForward )
ActionDescriptionProvider::createDescription(
(bForward ? ActionDescriptionProvider::MOVE_TOTOP : ActionDescriptionProvider::MOVE_TOBOTTOM),
String( SchResId( STR_OBJECT_DATASERIES ))),
- m_xDocumentActions );
+ m_xUndoManager );
bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( getModel() ), xGivenDataSeries, bForward );
if( bChanged )
{
m_aSelection.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID, bForward ) );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -1442,13 +1445,20 @@ void SAL_CALL ChartController::modified( const lang::EventObject& /* aEvent */ )
IMPL_LINK( ChartController, NotifyUndoActionHdl, SdrUndoAction*, pUndoAction )
{
+ ENSURE_OR_RETURN( pUndoAction, "invalid Undo action", 1L );
+
::rtl::OUString aObjectCID = m_aSelection.getSelectedCID();
if ( aObjectCID.getLength() == 0 )
{
- DocumentActions* pDocumentActions = DocumentActions::getImplementation( m_xDocumentActions );
- if ( pDocumentActions )
+ try
+ {
+ const Reference< document::XUndoManager > xUndoManager( getModel(), uno::UNO_QUERY_THROW );
+ const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( *pUndoAction ) );
+ xUndoManager->addUndoAction( xAction );
+ }
+ catch( const uno::Exception& )
{
- pDocumentActions->addShapeUndoAction( pUndoAction );
+ DBG_UNHANDLED_EXCEPTION();
}
}
return 0L;
diff --git a/chart2/source/controller/main/ChartController.hxx b/chart2/source/controller/main/ChartController.hxx
index aa9ade1f17b5..7c06a4ad4ca2 100644
--- a/chart2/source/controller/main/ChartController.hxx
+++ b/chart2/source/controller/main/ChartController.hxx
@@ -42,7 +42,7 @@
#include <cppuhelper/implbase12.hxx>
#include <com/sun/star/accessibility/XAccessible.hpp>
-#include <com/sun/star/chart2/XDocumentActions.hpp>
+#include <com/sun/star/document/XUndoManager.hpp>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
@@ -89,6 +89,8 @@ namespace chart
{
//.............................................................................
+class UndoGuard;
+
enum ChartDrawMode { CHARTDRAW_INSERT, CHARTDRAW_SELECT };
class WindowController
@@ -578,7 +580,8 @@ private:
bool volatile m_bConnectingToView;
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDocumentActions > m_xDocumentActions;
+ ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager;
+ ::std::auto_ptr< UndoGuard > m_pTextActionUndoGuard;
/// needed for dispatching URLs in FeatureStateEvents
mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
diff --git a/chart2/source/controller/main/ChartController_EditData.cxx b/chart2/source/controller/main/ChartController_EditData.cxx
index cbc66a2368b3..7c9bfe0c3986 100644
--- a/chart2/source/controller/main/ChartController_EditData.cxx
+++ b/chart2/source/controller/main/ChartController_EditData.cxx
@@ -67,11 +67,11 @@ void ChartController::executeDispatch_EditData()
// using assignment for broken gcc 3.3
UndoLiveUpdateGuardWithData aUndoGuard = UndoLiveUpdateGuardWithData(
String( SchResId( STR_ACTION_EDIT_CHART_DATA )),
- m_xDocumentActions );
+ m_xUndoManager );
DataEditor aDataEditorDialog( pParent, xChartDoc, m_xCC );
// the dialog has no OK/Cancel
aDataEditorDialog.Execute();
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
// \--
}
}
diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx
index adb6cf91a62e..b2bdaa02dd3c 100644
--- a/chart2/source/controller/main/ChartController_Insert.cxx
+++ b/chart2/source/controller/main/ChartController_Insert.cxx
@@ -122,7 +122,7 @@ void ChartController::executeDispatch_InsertAxes()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AXES ))),
- m_xDocumentActions );
+ m_xUndoManager );
try
{
@@ -146,7 +146,7 @@ void ChartController::executeDispatch_InsertAxes()
, aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC
, mpRefSizeProvider.get() );
if( bChanged )
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException& e)
@@ -160,7 +160,7 @@ void ChartController::executeDispatch_InsertGrid()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRIDS ))),
- m_xDocumentActions );
+ m_xUndoManager );
try
{
@@ -180,7 +180,7 @@ void ChartController::executeDispatch_InsertGrid()
bool bChanged = AxisHelper::changeVisibilityOfGrids( xDiagram
, aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC );
if( bChanged )
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException& e)
@@ -197,7 +197,7 @@ void ChartController::executeDispatch_InsertTitles()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_TITLES ))),
- m_xDocumentActions );
+ m_xUndoManager );
try
{
@@ -214,7 +214,7 @@ void ChartController::executeDispatch_InsertTitles()
aDlg.getResult( aDialogOutput );
bool bChanged = aDialogOutput.writeDifferenceToModel( getModel(), m_xCC, &aDialogInput );
if( bChanged )
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException& e)
@@ -228,10 +228,10 @@ void ChartController::executeDispatch_DeleteLegend()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))),
- m_xDocumentActions );
+ m_xUndoManager );
LegendHelper::hideLegend( getModel() );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_InsertLegend()
@@ -239,10 +239,10 @@ void ChartController::executeDispatch_InsertLegend()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))),
- m_xDocumentActions );
+ m_xUndoManager );
Reference< chart2::XLegend > xLegend = LegendHelper::showLegend( getModel(), m_xCC );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_OpenLegendDialog()
@@ -250,7 +250,7 @@ void ChartController::executeDispatch_OpenLegendDialog()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))),
- m_xDocumentActions );
+ m_xUndoManager );
try
{
@@ -264,7 +264,7 @@ void ChartController::executeDispatch_OpenLegendDialog()
ControllerLockGuard aCLGuard( getModel() );
bool bChanged = aDlg.writeToModel( getModel() );
if( bChanged )
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException& e)
@@ -281,7 +281,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_DATALABELS ))),
- m_xDocumentActions );
+ m_xUndoManager );
//if a series is selected insert labels for that series only:
uno::Reference< chart2::XDataSeries > xSeries(
@@ -298,7 +298,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels()
bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, true );
if( bSuccess )
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
return;
}
@@ -330,7 +330,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels()
ControllerLockGuard aCLGuard( getModel() );
bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now
if( bChanged )
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException& e)
@@ -354,7 +354,7 @@ void ChartController::executeDispatch_InsertMenu_YErrorBars()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_ERRORS ) ),
- m_xDocumentActions );
+ m_xUndoManager );
try
{
@@ -380,7 +380,7 @@ void ChartController::executeDispatch_InsertMenu_YErrorBars()
ControllerLockGuard aCLGuard( getModel() );
bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now
if( bChanged )
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException& e)
@@ -394,10 +394,10 @@ void ChartController::executeDispatch_InsertMeanValue()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))),
- m_xDocumentActions );
+ m_xUndoManager );
lcl_InsertMeanValueLine( m_xCC ).operator()(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ));
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_InsertMenu_MeanValues()
@@ -405,7 +405,7 @@ void ChartController::executeDispatch_InsertMenu_MeanValues()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))),
- m_xDocumentActions );
+ m_xUndoManager );
uno::Reference< chart2::XDataSeries > xSeries(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY );
@@ -420,7 +420,7 @@ void ChartController::executeDispatch_InsertMenu_MeanValues()
DiagramHelper::getDataSeriesFromDiagram( ChartModelHelper::findDiagram( getModel() )));
::std::for_each( aSeries.begin(), aSeries.end(), lcl_InsertMeanValueLine( m_xCC ));
}
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_InsertMenu_Trendlines()
@@ -437,7 +437,7 @@ void ChartController::executeDispatch_InsertMenu_Trendlines()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) ),
- m_xDocumentActions );
+ m_xUndoManager );
try
{
@@ -460,7 +460,7 @@ void ChartController::executeDispatch_InsertMenu_Trendlines()
ControllerLockGuard aCLGuard( getModel() );
bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now
if( bChanged )
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException& e)
@@ -478,7 +478,7 @@ void ChartController::executeDispatch_InsertTrendline()
UndoLiveUpdateGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE ))),
- m_xDocumentActions );
+ m_xUndoManager );
// add a linear curve
RegressionCurveHelper::addRegressionCurve(
@@ -518,7 +518,7 @@ void ChartController::executeDispatch_InsertTrendline()
ControllerLockGuard aCLGuard( getModel() );
aItemConverter.ApplyItemSet( *pOutItemSet );
}
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
}
@@ -532,7 +532,7 @@ void ChartController::executeDispatch_InsertYErrorBars()
UndoLiveUpdateGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_ERROR_BARS ))),
- m_xDocumentActions );
+ m_xUndoManager );
// add error bars with standard deviation
uno::Reference< beans::XPropertySet > xErrorBarProp(
@@ -568,7 +568,7 @@ void ChartController::executeDispatch_InsertYErrorBars()
ControllerLockGuard aCLGuard( getModel() );
aItemConverter.ApplyItemSet( *pOutItemSet );
}
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
}
@@ -592,10 +592,10 @@ void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 )
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))),
- m_xDocumentActions );
+ m_xUndoManager );
xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( true ));
xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bInsertR2 ));
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
}
@@ -609,9 +609,9 @@ void ChartController::executeDispatch_InsertR2Value()
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))),
- m_xDocumentActions );
+ m_xUndoManager );
xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( true ));
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -624,9 +624,9 @@ void ChartController::executeDispatch_DeleteR2Value()
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))),
- m_xDocumentActions );
+ m_xUndoManager );
xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false ));
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -639,9 +639,9 @@ void ChartController::executeDispatch_DeleteMeanValue()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AVERAGE_LINE ))),
- m_xDocumentActions );
+ m_xUndoManager );
RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -654,9 +654,9 @@ void ChartController::executeDispatch_DeleteTrendline()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE ))),
- m_xDocumentActions );
+ m_xUndoManager );
RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -669,9 +669,9 @@ void ChartController::executeDispatch_DeleteTrendlineEquation()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE_EQUATION ))),
- m_xDocumentActions );
+ m_xUndoManager );
RegressionCurveHelper::removeEquations( xRegCurveCnt );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -684,9 +684,9 @@ void ChartController::executeDispatch_DeleteYErrorBars()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE ))),
- m_xDocumentActions );
+ m_xUndoManager );
StatisticsHelper::removeErrorBars( xDataSeries );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -698,9 +698,9 @@ void ChartController::executeDispatch_InsertDataLabels()
{
UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT,
String( SchResId( STR_OBJECT_DATALABELS ))),
- m_xDocumentActions );
+ m_xUndoManager );
DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -708,9 +708,9 @@ void ChartController::executeDispatch_InsertDataLabel()
{
UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT,
String( SchResId( STR_OBJECT_LABEL ))),
- m_xDocumentActions );
+ m_xUndoManager );
DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_DeleteDataLabels()
@@ -721,9 +721,9 @@ void ChartController::executeDispatch_DeleteDataLabels()
{
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE,
String( SchResId( STR_OBJECT_DATALABELS ))),
- m_xDocumentActions );
+ m_xUndoManager );
DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints( xSeries );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -731,33 +731,33 @@ void ChartController::executeDispatch_DeleteDataLabel()
{
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE,
String( SchResId( STR_OBJECT_LABEL ))),
- m_xDocumentActions );
+ m_xUndoManager );
DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_ResetAllDataPoints()
{
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT,
String( SchResId( STR_OBJECT_DATAPOINTS ))),
- m_xDocumentActions );
+ m_xUndoManager );
uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY );
if( xSeries.is() )
xSeries->resetAllDataPoints();
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_ResetDataPoint()
{
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT,
String( SchResId( STR_OBJECT_DATAPOINT ))),
- m_xDocumentActions );
+ m_xUndoManager );
uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY );
if( xSeries.is() )
{
sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() );
xSeries->resetDataPoint( nPointIndex );
}
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_InsertAxisTitle()
@@ -769,7 +769,7 @@ void ChartController::executeDispatch_InsertAxisTitle()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_TITLE ))),
- m_xDocumentActions );
+ m_xUndoManager );
Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() );
sal_Int32 nDimensionIndex = -1;
@@ -787,7 +787,7 @@ void ChartController::executeDispatch_InsertAxisTitle()
::std::auto_ptr< ReferenceSizeProvider > apRefSizeProvider( impl_createReferenceSizeProvider());
xTitle = TitleHelper::createTitle( eTitleType, ObjectNameProvider::getTitleNameByType(eTitleType), getModel(), m_xCC, apRefSizeProvider.get() );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
/*
@@ -810,7 +810,7 @@ void ChartController::executeDispatch_InsertAxis()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AXIS ))),
- m_xDocumentActions );
+ m_xUndoManager );
try
{
@@ -818,7 +818,7 @@ void ChartController::executeDispatch_InsertAxis()
if( xAxis.is() )
{
AxisHelper::makeAxisVisible( xAxis );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException& e)
@@ -832,7 +832,7 @@ void ChartController::executeDispatch_DeleteAxis()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AXIS ))),
- m_xDocumentActions );
+ m_xUndoManager );
try
{
@@ -840,7 +840,7 @@ void ChartController::executeDispatch_DeleteAxis()
if( xAxis.is() )
{
AxisHelper::makeAxisInvisible( xAxis );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException& e)
@@ -854,7 +854,7 @@ void ChartController::executeDispatch_InsertMajorGrid()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRID ))),
- m_xDocumentActions );
+ m_xUndoManager );
try
{
@@ -862,7 +862,7 @@ void ChartController::executeDispatch_InsertMajorGrid()
if( xAxis.is() )
{
AxisHelper::makeGridVisible( xAxis->getGridProperties() );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException& e)
@@ -876,7 +876,7 @@ void ChartController::executeDispatch_DeleteMajorGrid()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_GRID ))),
- m_xDocumentActions );
+ m_xUndoManager );
try
{
@@ -884,7 +884,7 @@ void ChartController::executeDispatch_DeleteMajorGrid()
if( xAxis.is() )
{
AxisHelper::makeGridInvisible( xAxis->getGridProperties() );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException& e)
@@ -898,7 +898,7 @@ void ChartController::executeDispatch_InsertMinorGrid()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRID ))),
- m_xDocumentActions );
+ m_xUndoManager );
try
{
@@ -908,7 +908,7 @@ void ChartController::executeDispatch_InsertMinorGrid()
Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() );
for( sal_Int32 nN=0; nN<aSubGrids.getLength(); nN++)
AxisHelper::makeGridVisible( aSubGrids[nN] );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException& e)
@@ -922,7 +922,7 @@ void ChartController::executeDispatch_DeleteMinorGrid()
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_GRID ))),
- m_xDocumentActions );
+ m_xUndoManager );
try
{
@@ -932,7 +932,7 @@ void ChartController::executeDispatch_DeleteMinorGrid()
Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() );
for( sal_Int32 nN=0; nN<aSubGrids.getLength(); nN++)
AxisHelper::makeGridInvisible( aSubGrids[nN] );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException& e)
diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx
index 78f607773ca9..ceb6877e64e9 100644
--- a/chart2/source/controller/main/ChartController_Position.cxx
+++ b/chart2/source/controller/main/ChartController_Position.cxx
@@ -139,7 +139,7 @@ void SAL_CALL ChartController::executeDispatch_PositionAndSize()
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::POS_SIZE,
ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aCID ))),
- m_xDocumentActions );
+ m_xUndoManager );
SfxAbstractTabDialog * pDlg = NULL;
try
@@ -174,7 +174,7 @@ void SAL_CALL ChartController::executeDispatch_PositionAndSize()
, awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight())
, awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) );
if( bChanged )
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
delete pDlg;
diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx
index f6508c74f462..29f1bfa9f389 100644
--- a/chart2/source/controller/main/ChartController_Properties.cxx
+++ b/chart2/source/controller/main/ChartController_Properties.cxx
@@ -720,11 +720,11 @@ void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUStrin
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::FORMAT,
ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID ))),
- m_xDocumentActions );
+ m_xUndoManager );
bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, false );
if( bSuccess )
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( const ::rtl::OUString& rObjectCID, bool bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso )
@@ -839,14 +839,14 @@ void SAL_CALL ChartController::executeDispatch_View3D()
// using assignment for broken gcc 3.3
UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
String( SchResId( STR_ACTION_EDIT_3D_VIEW )),
- m_xDocumentActions );
+ m_xUndoManager );
// /--
//open dialog
::vos::OGuard aSolarGuard( Application::GetSolarMutex());
View3DDialog aDlg( m_pChartWindow, getModel(), m_pDrawModelWrapper->GetColorTable() );
if( aDlg.Execute() == RET_OK )
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
// \--
}
catch( uno::RuntimeException& e)
diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx
index 96175fb119ca..8069fd43f8cf 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 "UndoGuard.hxx"
#include "DrawViewWrapper.hxx"
#include "ChartWindow.hxx"
#include "TitleHelper.hxx"
@@ -80,7 +81,8 @@ void ChartController::StartTextEdit( const Point* pMousePixel )
if(!pTextObj)
return;
- m_xDocumentActions->preAction();
+ OSL_PRECOND( !m_pTextActionUndoGuard.get(), "ChartController::StartTextEdit: already have a TextUndoGuard!?" );
+ m_pTextActionUndoGuard.reset( new UndoGuard( C2U( "Text Edit" ), m_xUndoManager ) );
SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner();
//pOutliner->SetRefDevice(m_pChartWindow);
//pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)pStyleSheetPool);
@@ -164,26 +166,11 @@ bool ChartController::EndTextEdit()
TitleHelper::setCompleteString( aString, uno::Reference<
::com::sun::star::chart2::XTitle >::query( xPropSet ), m_xCC );
- try
- {
- m_xDocumentActions->postAction( C2U("Edit Text") );
- }
- catch( uno::RuntimeException& e)
- {
- ASSERT_EXCEPTION( e );
- }
- }
- else
- {
- try
- {
- m_xDocumentActions->cancelAction();
- }
- catch ( uno::RuntimeException& e )
- {
- ASSERT_EXCEPTION( e );
- }
+ OSL_ENSURE( m_pTextActionUndoGuard.get(), "ChartController::EndTextEdit: no TextUndoGuard!" );
+ if ( m_pTextActionUndoGuard.get() )
+ m_pTextActionUndoGuard->commit();
}
+ m_pTextActionUndoGuard.reset();
}
return true;
}
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index 9b2115fff83b..3723c1b5bfb7 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -102,7 +102,7 @@ namespace
bool lcl_deleteDataSeries(
const OUString & rCID,
const Reference< frame::XModel > & xModel,
- const Reference< chart2::XDocumentActions > & xDocumentActions )
+ const Reference< document::XUndoManager > & xUndoManager )
{
bool bResult = false;
uno::Reference< chart2::XDataSeries > xSeries( ::chart::ObjectIdentifier::getDataSeriesForCID( rCID, xModel ));
@@ -116,7 +116,7 @@ bool lcl_deleteDataSeries(
::chart::UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_DATASERIES ))),
- xDocumentActions );
+ xUndoManager );
Reference< chart2::XDiagram > xDiagram( ::chart::ChartModelHelper::findDiagram( xModel ) );
uno::Reference< chart2::XAxis > xAxis( ::chart::DiagramHelper::getAttachedAxis( xSeries, xDiagram ) );
@@ -126,7 +126,7 @@ bool lcl_deleteDataSeries(
::chart::AxisHelper::hideAxisIfNoDataIsAttached( xAxis, xDiagram );
bResult = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
return bResult;
@@ -135,7 +135,7 @@ bool lcl_deleteDataSeries(
bool lcl_deleteDataCurve(
const OUString & rCID,
const Reference< frame::XModel > & xModel,
- const Reference< chart2::XDocumentActions > & xDocumentActions )
+ const Reference< document::XUndoManager > & xUndoManager )
{
bool bResult = false;
uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
@@ -146,10 +146,10 @@ bool lcl_deleteDataCurve(
::chart::UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_CURVE ))),
- xDocumentActions );
+ xUndoManager );
::chart::RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt );
bResult = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
return bResult;
}
@@ -236,7 +236,7 @@ void ChartController::executeDispatch_NewArrangement()
// using assignment for broken gcc 3.3
UndoGuard aUndoGuard = UndoGuard(
String( SchResId( STR_ACTION_REARRANGE_CHART )),
- m_xDocumentActions );
+ m_xUndoManager );
ControllerLockGuard aCtlLockGuard( xModel );
// diagram
@@ -271,7 +271,7 @@ void ChartController::executeDispatch_NewArrangement()
::std::for_each( aRegressionCurves.begin(), aRegressionCurves.end(),
RegressionCurveHelper::resetEquationPosition );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
catch( uno::RuntimeException & ex )
@@ -286,13 +286,13 @@ void ChartController::executeDispatch_ScaleText()
// using assignment for broken gcc 3.3
UndoGuard aUndoGuard = UndoGuard(
String( SchResId( STR_ACTION_SCALE_TEXT )),
- m_xDocumentActions );
+ m_xUndoManager );
ControllerLockGuard aCtlLockGuard( getModel() );
::std::auto_ptr< ReferenceSizeProvider > apRefSizeProv( impl_createReferenceSizeProvider());
OSL_ASSERT( apRefSizeProv.get());
if( apRefSizeProv.get())
apRefSizeProv->toggleAutoResizeState();
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_Paste()
@@ -656,11 +656,11 @@ bool ChartController::executeDispatch_Delete()
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_TITLE ))),
- m_xDocumentActions );
+ m_xUndoManager );
TitleHelper::removeTitle(
ObjectIdentifier::getTitleTypeForCID( aCID ), getModel() );
bReturn = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
break;
}
case OBJECTTYPE_LEGEND:
@@ -675,17 +675,17 @@ bool ChartController::executeDispatch_Delete()
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))),
- m_xDocumentActions );
+ m_xUndoManager );
xLegendProp->setPropertyValue( C2U("Show"), uno::makeAny( false ));
bReturn = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
break;
}
case OBJECTTYPE_DATA_SERIES:
- bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xDocumentActions );
+ bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager );
break;
case OBJECTTYPE_LEGEND_ENTRY:
@@ -693,9 +693,9 @@ bool ChartController::executeDispatch_Delete()
ObjectType eParentObjectType = ObjectIdentifier::getObjectType(
ObjectIdentifier::getFullParentParticle( aCID ));
if( eParentObjectType == OBJECTTYPE_DATA_SERIES )
- bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xDocumentActions );
+ bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager );
else if( eParentObjectType == OBJECTTYPE_DATA_CURVE )
- bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xDocumentActions );
+ bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager );
break;
}
@@ -710,16 +710,16 @@ bool ChartController::executeDispatch_Delete()
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AVERAGE_LINE ))),
- m_xDocumentActions );
+ m_xUndoManager );
RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt );
bReturn = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
break;
}
case OBJECTTYPE_DATA_CURVE:
- bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xDocumentActions );
+ bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager );
break;
case OBJECTTYPE_DATA_CURVE_EQUATION:
@@ -733,14 +733,14 @@ bool ChartController::executeDispatch_Delete()
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE_EQUATION ))),
- m_xDocumentActions );
+ m_xUndoManager );
{
ControllerLockGuard aCtlLockGuard( xModel );
xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( false ));
xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false ));
}
bReturn = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
break;
}
@@ -756,7 +756,7 @@ bool ChartController::executeDispatch_Delete()
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_ERROR_BARS ))),
- m_xDocumentActions );
+ m_xUndoManager );
{
ControllerLockGuard aCtlLockGuard( xModel );
xErrorBarProp->setPropertyValue(
@@ -764,7 +764,7 @@ bool ChartController::executeDispatch_Delete()
uno::makeAny( ::com::sun::star::chart::ErrorBarStyle::NONE ));
}
bReturn = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
break;
}
@@ -780,7 +780,7 @@ bool ChartController::executeDispatch_Delete()
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, ::rtl::OUString( String(
SchResId( aObjectType == OBJECTTYPE_DATA_LABEL ? STR_OBJECT_LABEL : STR_OBJECT_DATALABELS )))),
- m_xDocumentActions );
+ m_xUndoManager );
chart2::DataPointLabel aLabel;
xObjectProperties->getPropertyValue( C2U( "Label" ) ) >>= aLabel;
aLabel.ShowNumber = false;
@@ -795,7 +795,7 @@ bool ChartController::executeDispatch_Delete()
else
xObjectProperties->setPropertyValue( C2U( "Label" ), uno::makeAny(aLabel) );
bReturn = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
break;
}
@@ -844,7 +844,7 @@ void ChartController::executeDispatch_ToggleLegend()
{
Reference< frame::XModel > xModel( getModel() );
UndoGuard aUndoGuard = UndoGuard(
- String( SchResId( STR_ACTION_TOGGLE_LEGEND )), m_xDocumentActions );
+ String( SchResId( STR_ACTION_TOGGLE_LEGEND )), m_xUndoManager );
Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend( xModel ), uno::UNO_QUERY );
bool bChanged = false;
if( xLegendProp.is())
@@ -871,14 +871,14 @@ void ChartController::executeDispatch_ToggleLegend()
}
if( bChanged )
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_ToggleGridHorizontal()
{
Reference< frame::XModel > xModel( getModel() );
UndoGuard aUndoGuard = UndoGuard(
- String( SchResId( STR_ACTION_TOGGLE_GRID_HORZ )), m_xDocumentActions );
+ String( SchResId( STR_ACTION_TOGGLE_GRID_HORZ )), m_xUndoManager );
Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( getModel() ));
if( xDiagram.is())
{
@@ -893,7 +893,7 @@ void ChartController::executeDispatch_ToggleGridHorizontal()
else
AxisHelper::showGrid( nDimensionIndex, nCooSysIndex, bIsMainGrid, xDiagram, m_xCC );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -911,9 +911,9 @@ void ChartController::impl_switchDiagramPositioningToExcludingPositioning()
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::POS_SIZE,
ObjectNameProvider::getName( OBJECTTYPE_DIAGRAM)),
- m_xDocumentActions );
+ m_xUndoManager );
if( DiagramHelper::switchDiagramPositioningToExcludingPositioning( m_aModel->getModel(), true, true ) )
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
} // namespace chart
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index c12ce38fa7cd..311bf38ea38c 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -839,12 +839,12 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
if( pChartDragMethod )
{
UndoGuard aUndoGuard( pChartDragMethod->getUndoDescription(),
- m_xDocumentActions );
+ m_xUndoManager );
if( pDrawViewWrapper->EndDragObj(false) )
{
bDraggingDone = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -872,7 +872,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
ActionDescriptionProvider::createDescription(
eActionType,
ObjectNameProvider::getName( ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ))),
- m_xDocumentActions );
+ m_xUndoManager );
bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID()
, getModel()
, awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight())
@@ -880,7 +880,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
if( bChanged )
{
bDraggingDone = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
}
@@ -1808,7 +1808,7 @@ bool ChartController::impl_moveOrResizeObject(
ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID );
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription(
- eActionType, ObjectNameProvider::getName( eObjectType )), m_xDocumentActions );
+ eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager );
{
ControllerLockGuard aCLGuard( xChartModel );
if( bNeedShift )
@@ -1816,7 +1816,7 @@ bool ChartController::impl_moveOrResizeObject(
if( bNeedResize || (eObjectType == OBJECTTYPE_DIAGRAM) )//Also set an explicat size at the diagram when an explicit position is set
xObjProp->setPropertyValue( C2U("RelativeSize"), uno::makeAny( aRelSize ));
}
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
return bResult;
diff --git a/chart2/source/controller/main/CommandDispatchContainer.hxx b/chart2/source/controller/main/CommandDispatchContainer.hxx
index 38f0c2ce8771..a5995253e059 100644
--- a/chart2/source/controller/main/CommandDispatchContainer.hxx
+++ b/chart2/source/controller/main/CommandDispatchContainer.hxx
@@ -28,7 +28,6 @@
#define CHART2_COMMANDDISPATCHCONTAINER_HXX
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/chart2/XDocumentActions.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/frame/DispatchDescriptor.hpp>
@@ -139,7 +138,6 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xModel;
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDocumentActions > m_xDocumentActions;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xChartDispatcher;
::std::set< ::rtl::OUString > m_aChartCommands;
diff --git a/chart2/source/controller/main/DocumentActions.cxx b/chart2/source/controller/main/DocumentActions.cxx
deleted file mode 100644
index a4864541fc70..000000000000
--- a/chart2/source/controller/main/DocumentActions.cxx
+++ /dev/null
@@ -1,392 +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 "DocumentActions.hxx"
-#include "ImplDocumentActions.hxx"
-#include "DisposeHelper.hxx"
-#include "MutexContainer.hxx"
-#include "macros.hxx"
-#include "ChartViewHelper.hxx"
-
-#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/chart2/XChartDocument.hpp>
-#include <com/sun/star/document/XUndoManagerSupplier.hpp>
-
-#include <unotools/configitem.hxx>
-#include <tools/diagnose_ex.h>
-#include <cppuhelper/compbase1.hxx>
-#include <comphelper/namedvaluecollection.hxx>
-#include <rtl/uuid.h>
-
-#include <functional>
-
-using namespace ::com::sun::star;
-
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-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::frame::XModel;
-using ::com::sun::star::document::XUndoManagerSupplier;
-using ::com::sun::star::document::XUndoAction;
-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();
-
-public:
- // ____ 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() )
- {
- uno::Reference< util::XModifyListener > xListener( aIt.next(), uno::UNO_QUERY );
- if( xListener.is() )
- xListener->modified( aEvent );
- }
- }
-}
-
-} // namespace impl
-
-DocumentActions::DocumentActions( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel )
- :impl::DocumentActions_Base( m_aMutex )
- ,m_pDocumentSnapshot()
- ,m_pModifyBroadcaster( NULL )
- ,m_aModel( rModel )
- ,m_xUndoManager()
-{
- Reference< XUndoManagerSupplier > xSuppUndo( rModel, UNO_QUERY_THROW );
- m_xUndoManager.set( xSuppUndo->getUndoManager(), UNO_SET_THROW );
-}
-
-DocumentActions::~DocumentActions()
-{
- if ( m_pModifyBroadcaster.is() )
- {
- m_pModifyBroadcaster->dispose();
- m_pModifyBroadcaster.clear();
- }
-}
-
-void DocumentActions::addShapeUndoAction( SdrUndoAction* pAction )
-{
- if ( !pAction )
- return;
- const Reference< XUndoAction > xAction( new impl::ShapeUndoElement( *pAction ) );
- m_xUndoManager->addUndoAction( xAction );
- impl_fireModifyEvent();
-}
-
-Reference< XModel > DocumentActions::impl_getModel() const
-{
- Reference< XModel > xModel( m_aModel );
- return xModel;
-}
-
-void DocumentActions::impl_fireModifyEvent()
-{
- if ( m_pModifyBroadcaster.is() )
- m_pModifyBroadcaster->fireEvent();
-}
-
-
-// ____ XModifyBroadcaster ____
-void SAL_CALL DocumentActions::addModifyListener( const Reference< util::XModifyListener >& aListener )
- throw (uno::RuntimeException)
-{
- if ( !m_pModifyBroadcaster.is() )
- m_pModifyBroadcaster.set( new impl::ModifyBroadcaster() );
-
- m_pModifyBroadcaster->addModifyListener( aListener );
-}
-
-void SAL_CALL DocumentActions::removeModifyListener( const Reference< util::XModifyListener >& aListener )
- throw (uno::RuntimeException)
-{
- if ( m_pModifyBroadcaster.is() )
- m_pModifyBroadcaster->removeModifyListener( aListener );
-}
-
-// ____ chart2::XDocumentActions ____
-void SAL_CALL DocumentActions::preAction( )
- throw (uno::RuntimeException)
-{
- ENSURE_OR_THROW( !m_pDocumentSnapshot, "DocumentActions::preAction: already started an action!" );
- m_pDocumentSnapshot.reset( new impl::ChartModelClone( impl_getModel(), impl::E_MODEL ) );
-}
-
-void SAL_CALL DocumentActions::preActionWithArguments( const Sequence< beans::PropertyValue >& aArguments ) throw (uno::RuntimeException, lang::IllegalArgumentException)
-{
- ENSURE_OR_THROW( !m_pDocumentSnapshot, "DocumentActions::preAction: already started an action!" );
-
- impl::ModelFacet eModelFacet( impl::E_MODEL );
- ::comphelper::NamedValueCollection aArgs( aArguments );
-
- const sal_Bool bWithData = aArgs.getOrDefault( "WithData", sal_False );
- if ( bWithData )
- eModelFacet = impl::E_MODEL_WITH_DATA;
-
- const sal_Bool bWithSelection = aArgs.getOrDefault( "WithSelection", sal_False );
- if ( bWithSelection )
- eModelFacet = impl::E_MODEL_WITH_SELECTION;
-
- const Reference< XModel > xModel( impl_getModel() );
- m_pDocumentSnapshot.reset( new impl::ChartModelClone( xModel, eModelFacet ) );
-}
-
-void SAL_CALL DocumentActions::postAction( const OUString& aUndoText )
- throw (uno::RuntimeException)
-{
- ENSURE_OR_THROW( !!m_pDocumentSnapshot.get(), "no current action" );
-
- const Reference< XUndoAction > xAction( new impl::UndoElement( aUndoText, impl_getModel(), m_pDocumentSnapshot ) );
- m_pDocumentSnapshot.reset();
-
- m_xUndoManager->addUndoAction( xAction );
-
- impl_fireModifyEvent();
-}
-
-void SAL_CALL DocumentActions::cancelAction()
- throw (uno::RuntimeException)
-{
- ENSURE_OR_THROW( !!m_pDocumentSnapshot.get(), "no current action" );
-
- m_pDocumentSnapshot->dispose();
- m_pDocumentSnapshot.reset();
-}
-
-void SAL_CALL DocumentActions::cancelActionWithUndo( )
- throw (uno::RuntimeException)
-{
- ENSURE_OR_THROW( !!m_pDocumentSnapshot.get(), "no current action" );
-
- m_pDocumentSnapshot->applyToModel( impl_getModel() );
- m_pDocumentSnapshot->dispose();
- m_pDocumentSnapshot.reset();
-}
-
-void SAL_CALL DocumentActions::undo( )
- throw (uno::RuntimeException)
-{
- try
- {
- m_xUndoManager->undo();
- }
- catch ( const RuntimeException& ) { throw; }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
-}
-
-void SAL_CALL DocumentActions::redo( )
- throw (uno::RuntimeException)
-{
- try
- {
- m_xUndoManager->redo();
- }
- catch ( const RuntimeException& ) { throw; }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
-}
-
-::sal_Bool SAL_CALL DocumentActions::undoPossible()
- throw (uno::RuntimeException)
-{
- return m_xUndoManager->isUndoPossible();
-}
-
-::sal_Bool SAL_CALL DocumentActions::redoPossible()
- throw (uno::RuntimeException)
-{
- return m_xUndoManager->isRedoPossible();
-}
-
-OUString SAL_CALL DocumentActions::getCurrentUndoString()
- throw (uno::RuntimeException)
-{
- OUString sTitle;
- try
- {
- sTitle = m_xUndoManager->getCurrentUndoActionTitle();
- }
- catch ( const RuntimeException& ) { throw; }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- return sTitle;
-}
-
-OUString SAL_CALL DocumentActions::getCurrentRedoString()
- throw (uno::RuntimeException)
-{
- OUString sTitle;
- try
- {
- sTitle = m_xUndoManager->getCurrentRedoActionTitle();
- }
- catch ( const RuntimeException& ) { throw; }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- return sTitle;
-}
-
-Sequence< OUString > SAL_CALL DocumentActions::getAllUndoStrings()
- throw (uno::RuntimeException)
-{
- Sequence< OUString > aStrings;
- try
- {
- aStrings = m_xUndoManager->getAllUndoActionTitles();
- }
- catch ( const RuntimeException& ) { throw; }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- return aStrings;
-}
-
-Sequence< OUString > SAL_CALL DocumentActions::getAllRedoStrings()
- throw (uno::RuntimeException)
-{
- Sequence< ::rtl::OUString > aStrings;
- try
- {
- aStrings = m_xUndoManager->getAllRedoActionTitles();
- }
- catch ( const RuntimeException& ) { throw; }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- return aStrings;
-}
-
-// ____ XUnoTunnel ____
-sal_Int64 DocumentActions::getSomething( const Sequence< sal_Int8 >& rId )
- throw (uno::RuntimeException)
-{
- if ( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) )
- {
- return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) );
- }
- return 0;
-}
-
-// static
-const Sequence< sal_Int8 >& DocumentActions::getUnoTunnelId()
-{
- static Sequence< sal_Int8 >* pSeq = 0;
- if( !pSeq )
- {
- osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
- if( !pSeq )
- {
- static Sequence< sal_Int8 > aSeq( 16 );
- rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
- pSeq = &aSeq;
- }
- }
- return *pSeq;
-}
-
-// static
-DocumentActions* DocumentActions::getImplementation( const Reference< uno::XInterface > xObj )
-{
- DocumentActions* pRet = NULL;
- Reference< lang::XUnoTunnel > xUT( xObj, uno::UNO_QUERY );
- if ( xUT.is() )
- {
- pRet = reinterpret_cast< DocumentActions* >( sal::static_int_cast< sal_IntPtr >( xUT->getSomething( getUnoTunnelId() ) ) );
- }
- return pRet;
-}
-
-} // namespace chart
diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx
index 0d1a26d6fc65..92a4a469ff1b 100644
--- a/chart2/source/controller/main/UndoCommandDispatch.cxx
+++ b/chart2/source/controller/main/UndoCommandDispatch.cxx
@@ -32,9 +32,11 @@
#include "macros.hxx"
#include <com/sun/star/util/XModifyBroadcaster.hpp>
+#include <com/sun/star/document/XUndoManagerSupplier.hpp>
#include <vos/mutex.hxx>
#include <vcl/svapp.hxx>
+#include <tools/diagnose_ex.h>
// for ressource strings STR_UNDO and STR_REDO
#include <sfx2/sfx.hrc>
@@ -56,7 +58,8 @@ UndoCommandDispatch::UndoCommandDispatch(
CommandDispatch( xContext ),
m_xModel( xModel )
{
- m_xDocumentActions.set( xModel, uno::UNO_QUERY );
+ uno::Reference< document::XUndoManagerSupplier > xSuppUndo( m_xModel, uno::UNO_QUERY_THROW );
+ m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW );
}
UndoCommandDispatch::~UndoCommandDispatch()
@@ -64,38 +67,36 @@ UndoCommandDispatch::~UndoCommandDispatch()
void UndoCommandDispatch::initialize()
{
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xDocumentActions, uno::UNO_QUERY );
- if( xBroadcaster.is() )
- {
- xBroadcaster->addModifyListener( this );
- }
+ Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY );
+ ENSURE_OR_RETURN_VOID( xBroadcaster.is(), "UndoCommandDispatch::initialize: missing modification broadcaster interface!" );
+ xBroadcaster->addModifyListener( this );
}
void UndoCommandDispatch::fireStatusEvent(
const OUString & rURL,
const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ )
{
- if( m_xDocumentActions.is() )
+ if( m_xUndoManager.is() )
{
bool bFireAll = (rURL.getLength() == 0);
uno::Any aUndoState, aRedoState;
- if( m_xDocumentActions->undoPossible())
+ if( m_xUndoManager->isUndoPossible())
{
// using assignment for broken gcc 3.3
OUString aUndo = OUString( String( SchResId( STR_UNDO )));
- aUndoState <<= ( aUndo + m_xDocumentActions->getCurrentUndoString());
+ aUndoState <<= ( aUndo + m_xUndoManager->getCurrentUndoActionTitle());
}
- if( m_xDocumentActions->redoPossible())
+ if( m_xUndoManager->isRedoPossible())
{
// using assignment for broken gcc 3.3
OUString aRedo = OUString( String( SchResId( STR_REDO )));
- aRedoState <<= ( aRedo + m_xDocumentActions->getCurrentRedoString());
+ aRedoState <<= ( aRedo + m_xUndoManager->getCurrentRedoActionTitle());
}
if( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Undo")))
- fireStatusEventForURL( C2U(".uno:Undo"), aUndoState, m_xDocumentActions->undoPossible(), xSingleListener );
+ fireStatusEventForURL( C2U(".uno:Undo"), aUndoState, m_xUndoManager->isUndoPossible(), xSingleListener );
if( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Redo")))
- fireStatusEventForURL( C2U(".uno:Redo"), aRedoState, m_xDocumentActions->redoPossible(), xSingleListener );
+ fireStatusEventForURL( C2U(".uno:Redo"), aRedoState, m_xUndoManager->isRedoPossible(), xSingleListener );
}
}
@@ -105,15 +106,22 @@ void SAL_CALL UndoCommandDispatch::dispatch(
const Sequence< beans::PropertyValue >& /* Arguments */ )
throw (uno::RuntimeException)
{
- if( m_xDocumentActions.is() )
+ if( m_xUndoManager.is() )
{
// why is it necessary to lock the solar mutex here?
// /--
::vos::OGuard aSolarGuard( Application::GetSolarMutex());
- if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" )))
- m_xDocumentActions->undo();
- else
- m_xDocumentActions->redo();
+ try
+ {
+ if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" )))
+ m_xUndoManager->undo();
+ else
+ m_xUndoManager->redo();
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
// \--
}
}
@@ -122,13 +130,14 @@ void SAL_CALL UndoCommandDispatch::dispatch(
/// is called when this is disposed
void SAL_CALL UndoCommandDispatch::disposing()
{
- Reference< util::XModifyBroadcaster > xBroadcaster( m_xDocumentActions, uno::UNO_QUERY );
+ Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY );
+ OSL_ENSURE( xBroadcaster.is(), "UndoCommandDispatch::initialize: missing modification broadcaster interface!" );
if( xBroadcaster.is() )
{
xBroadcaster->removeModifyListener( this );
}
- m_xDocumentActions.clear();
+ m_xUndoManager.clear();
m_xModel.clear();
}
@@ -136,7 +145,7 @@ void SAL_CALL UndoCommandDispatch::disposing()
void SAL_CALL UndoCommandDispatch::disposing( const lang::EventObject& /* Source */ )
throw (uno::RuntimeException)
{
- m_xDocumentActions.clear();
+ m_xUndoManager.clear();
m_xModel.clear();
}
diff --git a/chart2/source/controller/main/UndoCommandDispatch.hxx b/chart2/source/controller/main/UndoCommandDispatch.hxx
index 3130863dec61..891ab8b019e5 100644
--- a/chart2/source/controller/main/UndoCommandDispatch.hxx
+++ b/chart2/source/controller/main/UndoCommandDispatch.hxx
@@ -30,15 +30,12 @@
#include "CommandDispatch.hxx"
#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/chart2/XDocumentActions.hpp>
+#include <com/sun/star/document/XUndoManager.hpp>
namespace chart
{
/** This is a CommandDispatch implementation for Undo and Redo.
-
- You need to pass an DocumentActions to this class that is then used for Undo and
- Redo. The changes are applied to the given XModel.
*/
class UndoCommandDispatch : public CommandDispatch
{
@@ -77,7 +74,7 @@ private:
::com::sun::star::uno::Reference<
::com::sun::star::frame::XModel > m_xModel;
::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XDocumentActions > m_xDocumentActions;
+ ::com::sun::star::document::XUndoManager > m_xUndoManager;
};
} // namespace chart
diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx
index e38bb89d9249..b89b463cc0eb 100644
--- a/chart2/source/controller/main/UndoGuard.cxx
+++ b/chart2/source/controller/main/UndoGuard.cxx
@@ -29,6 +29,11 @@
#include "precompiled_chart2.hxx"
#include "UndoGuard.hxx"
+#include "ImplDocumentActions.hxx"
+
+#include <com/sun/star/container/XChild.hpp>
+
+#include <tools/diagnose_ex.h>
using namespace ::com::sun::star;
@@ -39,99 +44,131 @@ using ::rtl::OUString;
namespace chart
{
-UndoGuard_Base::UndoGuard_Base( const OUString& rUndoString
- , const uno::Reference< chart2::XDocumentActions > & xDocumentActions )
- : m_xDocumentActions( xDocumentActions )
- , m_aUndoString( rUndoString )
- , m_bActionPosted( false )
+//-----------------------------------------------------------------------------
+namespace
{
+ uno::Reference< uno::XInterface > lcl_getParent( const uno::Reference< uno::XInterface >& i_component )
+ {
+ const uno::Reference< container::XChild > xAsChild( i_component, uno::UNO_QUERY_THROW );
+ return xAsChild->getParent();
+ }
}
+//-----------------------------------------------------------------------------
+
+UndoGuard_Base::UndoGuard_Base( const OUString& i_undoString, const uno::Reference< document::XUndoManager > & i_undoManager )
+ :m_xChartModel( lcl_getParent( i_undoManager ), uno::UNO_QUERY_THROW )
+ ,m_xUndoManager( i_undoManager )
+ ,m_aUndoString( i_undoString )
+ ,m_bActionPosted( false )
+{
+}
+
+//-----------------------------------------------------------------------------
+
UndoGuard_Base::~UndoGuard_Base()
{
+ if ( !!m_pDocumentSnapshot )
+ discardSnapshot();
}
-void UndoGuard_Base::commitAction()
+//-----------------------------------------------------------------------------
+
+void UndoGuard_Base::commit()
{
- if( !m_bActionPosted && m_xDocumentActions.is() )
- m_xDocumentActions->postAction( m_aUndoString );
+ if ( !m_bActionPosted && !!m_pDocumentSnapshot && m_xUndoManager.is() )
+ {
+ const Reference< document::XUndoAction > xAction( new impl::UndoElement( m_aUndoString, m_xChartModel, m_pDocumentSnapshot ) );
+ m_pDocumentSnapshot.reset(); // don't dispose, it's data went over to the UndoElement
+ m_xUndoManager->addUndoAction( xAction );
+ }
m_bActionPosted = true;
}
//-----------------------------------------------------------------------------
-UndoGuard::UndoGuard( const OUString& rUndoString
- , const uno::Reference< chart2::XDocumentActions > & xDocumentActions )
- : UndoGuard_Base( rUndoString, xDocumentActions )
+void UndoGuard_Base::rollback()
+{
+ ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" );
+ m_pDocumentSnapshot->applyToModel( m_xChartModel );
+ discardSnapshot();
+}
+
+//-----------------------------------------------------------------------------
+
+void UndoGuard_Base::takeSnapshot( bool i_withData, bool i_withSelection )
{
- if( m_xDocumentActions.is() )
- m_xDocumentActions->preAction();
+ 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()
+{
+ ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" );
+ m_pDocumentSnapshot->dispose();
+ m_pDocumentSnapshot.reset();
+}
+
+//-----------------------------------------------------------------------------
+
+UndoGuard::UndoGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
+ :UndoGuard_Base( i_undoString, i_undoManager )
+{
+ takeSnapshot( false, false );
}
UndoGuard::~UndoGuard()
{
- if( !m_bActionPosted && m_xDocumentActions.is() )
- m_xDocumentActions->cancelAction();
+ // nothing to do ... TODO: can this class be removed?
}
//-----------------------------------------------------------------------------
-UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& rUndoString
- , const uno::Reference< chart2::XDocumentActions > & xDocumentActions )
- : UndoGuard_Base( rUndoString, xDocumentActions )
+UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
+ :UndoGuard_Base( i_undoString, i_undoManager )
{
- if( m_xDocumentActions.is() )
- m_xDocumentActions->preAction();
+ takeSnapshot( false, false );
}
UndoLiveUpdateGuard::~UndoLiveUpdateGuard()
{
- if( !m_bActionPosted && m_xDocumentActions.is() )
- m_xDocumentActions->cancelActionWithUndo();
+ if ( !isActionPosted() )
+ rollback();
}
//-----------------------------------------------------------------------------
-UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData( const OUString& rUndoString
- , const uno::Reference< chart2::XDocumentActions > & xDocumentActions )
- : UndoGuard_Base( rUndoString, xDocumentActions )
+UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData(
+ const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
+ :UndoGuard_Base( i_undoString, i_undoManager )
{
- if( m_xDocumentActions.is() )
- {
- Sequence< beans::PropertyValue > aArgs(1);
- aArgs[0] = beans::PropertyValue(
- OUString( RTL_CONSTASCII_USTRINGPARAM("WithData")), -1, uno::Any(),
- beans::PropertyState_DIRECT_VALUE );
- m_xDocumentActions->preActionWithArguments( aArgs );
- }
+ takeSnapshot( true, false );
}
UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData()
{
- if( !m_bActionPosted && m_xDocumentActions.is() )
- m_xDocumentActions->cancelActionWithUndo();
+ if ( !isActionPosted() )
+ rollback();
}
//-----------------------------------------------------------------------------
-UndoGuardWithSelection::UndoGuardWithSelection( const rtl::OUString& rUndoString
- , const uno::Reference< chart2::XDocumentActions > & xDocumentActions )
- : UndoGuard_Base( rUndoString, xDocumentActions )
+UndoGuardWithSelection::UndoGuardWithSelection(
+ const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
+ :UndoGuard_Base( i_undoString, i_undoManager )
{
- if( m_xDocumentActions.is() )
- {
- Sequence< beans::PropertyValue > aArgs(1);
- aArgs[0] = beans::PropertyValue(
- OUString( RTL_CONSTASCII_USTRINGPARAM("WithSelection")), -1, uno::Any(),
- beans::PropertyState_DIRECT_VALUE );
- m_xDocumentActions->preActionWithArguments( aArgs );
- }
+ takeSnapshot( false, true );
}
UndoGuardWithSelection::~UndoGuardWithSelection()
{
- if( !m_bActionPosted && m_xDocumentActions.is() )
- m_xDocumentActions->cancelAction();
+ if ( !isActionPosted() )
+ rollback();
}
} // namespace chart
diff --git a/chart2/source/controller/main/makefile.mk b/chart2/source/controller/main/makefile.mk
index a90d1537b89b..b8bbd0615a76 100644
--- a/chart2/source/controller/main/makefile.mk
+++ b/chart2/source/controller/main/makefile.mk
@@ -73,7 +73,6 @@ SLOFILES = \
$(SLO)$/ShapeController.obj \
$(SLO)$/ShapeToolbarController.obj \
$(SLO)$/ImplDocumentActions.obj \
- $(SLO)$/DocumentActions.obj \
$(SLO)$/UndoGuard.obj
# $(SLO)$/CommonConverters.obj \