summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorVladimir Glazunov <vg@openoffice.org>2011-01-28 11:59:17 +0100
committerVladimir Glazunov <vg@openoffice.org>2011-01-28 11:59:17 +0100
commit81c443356b9c0155d6b44c15126cfc1b9d50bb04 (patch)
treeac66242e68c0785b08565c4576e6a4611e3400db /chart2
parent475a6d822f4a439dca6c91cc4905a7c526fe46ea (diff)
parent3f3ec2b85f8f5b828cb4af4d045d11c979c71110 (diff)
CWS-TOOLING: integrate CWS undoapi
Diffstat (limited to 'chart2')
-rwxr-xr-xchart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx8
-rw-r--r--chart2/source/controller/dialogs/Strings.src4
-rw-r--r--chart2/source/controller/dialogs/res_ErrorBar.cxx4
-rw-r--r--chart2/source/controller/dialogs/tp_RangeChooser.cxx2
-rw-r--r--chart2/source/controller/main/ChartController.cxx41
-rw-r--r--chart2/source/controller/main/ChartController.hxx7
-rw-r--r--chart2/source/controller/main/ChartController_EditData.cxx6
-rw-r--r--chart2/source/controller/main/ChartController_Insert.cxx196
-rw-r--r--chart2/source/controller/main/ChartController_Position.cxx4
-rw-r--r--chart2/source/controller/main/ChartController_Properties.cxx10
-rw-r--r--chart2/source/controller/main/ChartController_TextEdit.cxx30
-rw-r--r--chart2/source/controller/main/ChartController_Tools.cxx74
-rw-r--r--chart2/source/controller/main/ChartController_Window.cxx18
-rwxr-xr-xchart2/source/controller/main/ChartModelClone.cxx280
-rwxr-xr-xchart2/source/controller/main/ChartModelClone.hxx89
-rw-r--r--chart2/source/controller/main/CommandDispatchContainer.cxx6
-rw-r--r--chart2/source/controller/main/CommandDispatchContainer.hxx9
-rw-r--r--chart2/source/controller/main/ImplUndoManager.cxx503
-rw-r--r--chart2/source/controller/main/ImplUndoManager.hxx227
-rw-r--r--chart2/source/controller/main/UndoActions.cxx178
-rw-r--r--chart2/source/controller/main/UndoActions.hxx134
-rw-r--r--chart2/source/controller/main/UndoCommandDispatch.cxx48
-rw-r--r--chart2/source/controller/main/UndoCommandDispatch.hxx7
-rw-r--r--chart2/source/controller/main/UndoGuard.cxx165
-rw-r--r--chart2/source/controller/main/UndoGuard.hxx137
-rw-r--r--chart2/source/controller/main/UndoManager.cxx438
-rw-r--r--chart2/source/controller/main/makefile.mk9
-rw-r--r--chart2/source/inc/ChartModelHelper.hxx1
-rw-r--r--chart2/source/inc/Strings.hrc1
-rw-r--r--chart2/source/inc/UndoGuard.hxx120
-rw-r--r--chart2/source/inc/UndoManager.hxx180
-rw-r--r--chart2/source/inc/servicenames.hxx2
-rwxr-xr-xchart2/source/model/main/ChartModel.cxx130
-rwxr-xr-xchart2/source/model/main/ChartModel.hxx21
-rwxr-xr-xchart2/source/model/main/UndoManager.cxx427
-rwxr-xr-xchart2/source/model/main/UndoManager.hxx109
-rw-r--r--chart2/source/model/main/makefile.mk1
-rw-r--r--chart2/source/model/makefile.mk3
-rwxr-xr-x[-rw-r--r--]chart2/source/tools/ResId.cxx2
39 files changed, 1784 insertions, 1847 deletions
diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index e8d91cd6c124..ce65463bce91 100755
--- 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 "UndoManager.hxx"
#include <com/sun/star/chart2/XTitled.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
@@ -83,6 +82,7 @@ using namespace ::com::sun::star::chart;
using ::com::sun::star::chart::XComplexDescriptionAccess;
using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::beans::Property;
@@ -1413,12 +1413,6 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance(
xResult.set( m_xChartView );
bServiceFound = true;
}
- else if ( aServiceSpecifier.equals( CHART_UNDOMANAGER_SERVICE_NAME ) )
- {
- Reference< chart2::XUndoManager > xUndoManager( new UndoManager() );
- xResult.set( xUndoManager );
- bServiceFound = true;
- }
else
{
// try to create a shape
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/dialogs/res_ErrorBar.cxx b/chart2/source/controller/dialogs/res_ErrorBar.cxx
index 8b649072538e..c71e9de73a31 100644
--- a/chart2/source/controller/dialogs/res_ErrorBar.cxx
+++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx
@@ -474,12 +474,12 @@ IMPL_LINK( ErrorBarResources, ChooseRange, RangeSelectionButton *, pButton )
if( pButton == &m_aIbRangePositive )
{
m_pCurrentRangeChoosingField = &m_aEdRangePositive;
- aUIString = ::rtl::OUString( String( SchResId( STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS )));
+ aUIString = String( SchResId( STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS ));
}
else
{
m_pCurrentRangeChoosingField = &m_aEdRangeNegative;
- aUIString = ::rtl::OUString( String( SchResId( STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS )));
+ aUIString = String( SchResId( STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS ));
}
OSL_ASSERT( m_pParentDialog );
diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.cxx b/chart2/source/controller/dialogs/tp_RangeChooser.cxx
index 3ba6ca0f74b2..82a1d19ffdb3 100644
--- a/chart2/source/controller/dialogs/tp_RangeChooser.cxx
+++ b/chart2/source/controller/dialogs/tp_RangeChooser.cxx
@@ -366,7 +366,7 @@ IMPL_LINK( RangeChooserTabPage, ChooseRangeHdl, void *, EMPTYARG )
{
rtl::OUString aRange = m_aED_Range.GetText();
// using assignment for broken gcc 3.3
- rtl::OUString aTitle = ::rtl::OUString( String( SchResId( STR_PAGE_DATA_RANGE ) ));
+ rtl::OUString aTitle = String( SchResId( STR_PAGE_DATA_RANGE ) );
lcl_enableRangeChoosing( true, m_pParentDialog );
m_rDialogModel.getRangeSelectionHelper()->chooseRange( aRange, aTitle, *this );
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index 675bcf40e7a2..ac3ef57a1bd9 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -49,17 +49,15 @@
#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 "UndoManager.hxx"
+#include "UndoActions.hxx"
#include <comphelper/InlineContainer.hxx>
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
-#include <com/sun/star/chart2/XUndoSupplier.hpp>
#include <com/sun/star/chart2/data/XDataReceiver.hpp>
#include <com/sun/star/frame/XLoadable.hpp>
#include <com/sun/star/util/XCloneable.hpp>
@@ -67,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
@@ -86,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
@@ -133,7 +134,6 @@ ChartController::ChartController(uno::Reference<uno::XComponentContext> const &
, m_eDrawMode( CHARTDRAW_SELECT )
{
DBG_CTOR(ChartController,NULL);
-// m_aDispatchContainer.setUndoManager( m_xUndoManager );
m_aDoubleClickTimer.SetTimeoutHdl( LINK( this, ChartController, DoubleClickWaitingHdl ) );
}
@@ -622,9 +622,8 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent
m_pChartWindow->Invalidate();
}
- uno::Reference< chart2::XUndoSupplier > xUndoSupplier( getModel(), uno::UNO_QUERY );
- if( xUndoSupplier.is())
- m_xUndoManager.set( xUndoSupplier->getUndoManager());
+ uno::Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW );
+ m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW );
return sal_True;
}
@@ -1335,7 +1334,7 @@ void SAL_CALL ChartController::executeDispatch_ChartType()
{
// using assignment for broken gcc 3.3
UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
- ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHARTTYPE ))), m_xUndoManager, getModel() );
+ String( SchResId( STR_ACTION_EDIT_CHARTTYPE )), m_xUndoManager );
// /--
::vos::OGuard aSolarGuard( Application::GetSolarMutex());
@@ -1344,7 +1343,7 @@ void SAL_CALL ChartController::executeDispatch_ChartType()
if( aDlg.Execute() == RET_OK )
{
impl_adaptDataSeriesAutoResize();
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
// \--
}
@@ -1360,7 +1359,7 @@ void SAL_CALL ChartController::executeDispatch_SourceData()
// using assignment for broken gcc 3.3
UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
- ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_DATA_RANGES ))), m_xUndoManager, getModel() );
+ String( SchResId( STR_ACTION_EDIT_DATA_RANGES )), m_xUndoManager );
if( xChartDoc.is())
{
// /--
@@ -1369,7 +1368,7 @@ void SAL_CALL ChartController::executeDispatch_SourceData()
if( aDlg.Execute() == RET_OK )
{
impl_adaptDataSeriesAutoResize();
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
// \--
}
@@ -1387,14 +1386,14 @@ void SAL_CALL ChartController::executeDispatch_MoveSeries( sal_Bool bForward )
UndoGuardWithSelection aUndoGuard(
ActionDescriptionProvider::createDescription(
(bForward ? ActionDescriptionProvider::MOVE_TOTOP : ActionDescriptionProvider::MOVE_TOBOTTOM),
- ::rtl::OUString( String( SchResId( STR_OBJECT_DATASERIES )))),
- m_xUndoManager, getModel());
+ String( SchResId( STR_OBJECT_DATASERIES ))),
+ m_xUndoManager );
bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( getModel() ), xGivenDataSeries, bForward );
if( bChanged )
{
m_aSelection.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID, bForward ) );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -1454,13 +1453,21 @@ 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 )
{
- UndoManager* pUndoManager = UndoManager::getImplementation( m_xUndoManager );
- if ( pUndoManager )
+ try
+ {
+ const Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW );
+ const Reference< document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW );
+ const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( *pUndoAction ) );
+ xUndoManager->addUndoAction( xAction );
+ }
+ catch( const uno::Exception& )
{
- pUndoManager->addShapeUndoAction( pUndoAction );
+ DBG_UNHANDLED_EXCEPTION();
}
}
return 0L;
diff --git a/chart2/source/controller/main/ChartController.hxx b/chart2/source/controller/main/ChartController.hxx
index f2b64eb7a9c5..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/XUndoManager.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::XUndoManager > m_xUndoManager;
+ ::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 0248732a63a7..7c9bfe0c3986 100644
--- a/chart2/source/controller/main/ChartController_EditData.cxx
+++ b/chart2/source/controller/main/ChartController_EditData.cxx
@@ -66,12 +66,12 @@ void ChartController::executeDispatch_EditData()
::vos::OGuard aSolarGuard( Application::GetSolarMutex());
// using assignment for broken gcc 3.3
UndoLiveUpdateGuardWithData aUndoGuard = UndoLiveUpdateGuardWithData(
- ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHART_DATA ))),
- m_xUndoManager, getModel() );
+ String( SchResId( STR_ACTION_EDIT_CHART_DATA )),
+ 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 0a7a4057ef9a..b2bdaa02dd3c 100644
--- a/chart2/source/controller/main/ChartController_Insert.cxx
+++ b/chart2/source/controller/main/ChartController_Insert.cxx
@@ -121,8 +121,8 @@ void ChartController::executeDispatch_InsertAxes()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AXES )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AXES ))),
+ 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)
@@ -159,8 +159,8 @@ void ChartController::executeDispatch_InsertGrid()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRIDS )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRIDS ))),
+ 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)
@@ -196,8 +196,8 @@ void ChartController::executeDispatch_InsertTitles()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLES )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_TITLES ))),
+ 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)
@@ -227,30 +227,30 @@ void ChartController::executeDispatch_DeleteLegend()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))),
+ m_xUndoManager );
LegendHelper::hideLegend( getModel() );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_InsertLegend()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))),
+ m_xUndoManager );
Reference< chart2::XLegend > xLegend = LegendHelper::showLegend( getModel(), m_xCC );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_OpenLegendDialog()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))),
+ 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)
@@ -280,8 +280,8 @@ void ChartController::executeDispatch_InsertMenu_DataLabels()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_DATALABELS ))),
+ 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_xUndoManager, getModel() );
+ 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)
@@ -393,19 +393,19 @@ void ChartController::executeDispatch_InsertMeanValue()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))),
+ m_xUndoManager );
lcl_InsertMeanValueLine( m_xCC ).operator()(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ));
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_InsertMenu_MeanValues()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))),
+ 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_xUndoManager, getModel() );
+ 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)
@@ -477,8 +477,8 @@ void ChartController::executeDispatch_InsertTrendline()
{
UndoLiveUpdateGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE ))),
+ 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();
}
}
}
@@ -531,8 +531,8 @@ void ChartController::executeDispatch_InsertYErrorBars()
{
UndoLiveUpdateGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_BARS )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_ERROR_BARS ))),
+ 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();
}
}
}
@@ -591,11 +591,11 @@ void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 )
// using assignment for broken gcc 3.3
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))),
+ m_xUndoManager );
xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( true ));
xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bInsertR2 ));
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
}
@@ -608,10 +608,10 @@ void ChartController::executeDispatch_InsertR2Value()
{
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))),
+ m_xUndoManager );
xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( true ));
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -623,10 +623,10 @@ void ChartController::executeDispatch_DeleteR2Value()
{
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))),
+ m_xUndoManager );
xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false ));
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -638,10 +638,10 @@ void ChartController::executeDispatch_DeleteMeanValue()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AVERAGE_LINE ))),
+ m_xUndoManager );
RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -653,10 +653,10 @@ void ChartController::executeDispatch_DeleteTrendline()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE ))),
+ m_xUndoManager );
RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -668,10 +668,10 @@ void ChartController::executeDispatch_DeleteTrendlineEquation()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE_EQUATION ))),
+ m_xUndoManager );
RegressionCurveHelper::removeEquations( xRegCurveCnt );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -683,10 +683,10 @@ void ChartController::executeDispatch_DeleteYErrorBars()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE ))),
+ m_xUndoManager );
StatisticsHelper::removeErrorBars( xDataSeries );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -697,20 +697,20 @@ void ChartController::executeDispatch_InsertDataLabels()
if( xSeries.is() )
{
UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT,
- ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))),
- m_xUndoManager, getModel() );
+ String( SchResId( STR_OBJECT_DATALABELS ))),
+ m_xUndoManager );
DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
void ChartController::executeDispatch_InsertDataLabel()
{
UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT,
- ::rtl::OUString( String( SchResId( STR_OBJECT_LABEL )))),
- m_xUndoManager, getModel() );
+ String( SchResId( STR_OBJECT_LABEL ))),
+ m_xUndoManager );
DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_DeleteDataLabels()
@@ -720,44 +720,44 @@ void ChartController::executeDispatch_DeleteDataLabels()
if( xSeries.is() )
{
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE,
- ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))),
- m_xUndoManager, getModel() );
+ String( SchResId( STR_OBJECT_DATALABELS ))),
+ m_xUndoManager );
DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints( xSeries );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
void ChartController::executeDispatch_DeleteDataLabel()
{
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE,
- ::rtl::OUString( String( SchResId( STR_OBJECT_LABEL )))),
- m_xUndoManager, getModel() );
+ String( SchResId( STR_OBJECT_LABEL ))),
+ m_xUndoManager );
DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) );
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
void ChartController::executeDispatch_ResetAllDataPoints()
{
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT,
- ::rtl::OUString( String( SchResId( STR_OBJECT_DATAPOINTS )))),
- m_xUndoManager, getModel() );
+ String( SchResId( STR_OBJECT_DATAPOINTS ))),
+ 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,
- ::rtl::OUString( String( SchResId( STR_OBJECT_DATAPOINT )))),
- m_xUndoManager, getModel() );
+ String( SchResId( STR_OBJECT_DATAPOINT ))),
+ 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()
@@ -768,8 +768,8 @@ void ChartController::executeDispatch_InsertAxisTitle()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLE )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_TITLE ))),
+ 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();
}
/*
@@ -809,8 +809,8 @@ void ChartController::executeDispatch_InsertAxis()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AXIS )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AXIS ))),
+ 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)
@@ -831,8 +831,8 @@ void ChartController::executeDispatch_DeleteAxis()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AXIS )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AXIS ))),
+ 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)
@@ -853,8 +853,8 @@ void ChartController::executeDispatch_InsertMajorGrid()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRID ))),
+ 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)
@@ -875,8 +875,8 @@ void ChartController::executeDispatch_DeleteMajorGrid()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_GRID ))),
+ 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)
@@ -897,8 +897,8 @@ void ChartController::executeDispatch_InsertMinorGrid()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRID ))),
+ 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)
@@ -921,8 +921,8 @@ void ChartController::executeDispatch_DeleteMinorGrid()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_GRID ))),
+ 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 619d308ffad2..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_xUndoManager, getModel() );
+ 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 649b9cb62f9d..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_xUndoManager, getModel() );
+ 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 )
@@ -838,15 +838,15 @@ void SAL_CALL ChartController::executeDispatch_View3D()
{
// using assignment for broken gcc 3.3
UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
- ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_3D_VIEW ))),
- m_xUndoManager, getModel());
+ String( SchResId( STR_ACTION_EDIT_3D_VIEW )),
+ 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 6091fd8ef3f8..9354c911ad67 100644
--- a/chart2/source/controller/main/ChartController_TextEdit.cxx
+++ b/chart2/source/controller/main/ChartController_TextEdit.cxx
@@ -29,6 +29,8 @@
#include "precompiled_chart2.hxx"
#include "ChartController.hxx"
+#include "ResId.hxx"
+#include "UndoGuard.hxx"
#include "DrawViewWrapper.hxx"
#include "ChartWindow.hxx"
#include "TitleHelper.hxx"
@@ -36,6 +38,7 @@
#include "macros.hxx"
#include "ControllerLockGuard.hxx"
#include "AccessibleTextHelper.hxx"
+#include "Strings.hrc"
#include "chartview/DrawModelWrapper.hxx"
#include <svx/svdotext.hxx>
@@ -81,7 +84,9 @@ void ChartController::StartTextEdit( const Point* pMousePixel )
if(!pTextObj)
return;
- m_xUndoManager->preAction( getModel());
+ OSL_PRECOND( !m_pTextActionUndoGuard.get(), "ChartController::StartTextEdit: already have a TextUndoGuard!?" );
+ 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);
@@ -165,26 +170,11 @@ bool ChartController::EndTextEdit()
TitleHelper::setCompleteString( aString, uno::Reference<
::com::sun::star::chart2::XTitle >::query( xPropSet ), m_xCC );
- try
- {
- m_xUndoManager->postAction( C2U("Edit Text") );
- }
- catch( uno::RuntimeException& e)
- {
- ASSERT_EXCEPTION( e );
- }
- }
- else
- {
- try
- {
- m_xUndoManager->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 735cb9634671..945ccf4b4b34 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::XUndoManager > & xUndoManager )
+ const Reference< document::XUndoManager > & xUndoManager )
{
bool bResult = false;
uno::Reference< chart2::XDataSeries > xSeries( ::chart::ObjectIdentifier::getDataSeriesForCID( rCID, xModel ));
@@ -115,8 +115,8 @@ bool lcl_deleteDataSeries(
{
::chart::UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( ::chart::SchResId( STR_OBJECT_DATASERIES )))),
- xUndoManager, xModel );
+ ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_DATASERIES ))),
+ 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::XUndoManager > & xUndoManager )
+ const Reference< document::XUndoManager > & xUndoManager )
{
bool bResult = false;
uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
@@ -145,11 +145,11 @@ bool lcl_deleteDataCurve(
{
::chart::UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( ::chart::SchResId( STR_OBJECT_CURVE )))),
- xUndoManager, xModel );
+ ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_CURVE ))),
+ xUndoManager );
::chart::RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt );
bResult = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
return bResult;
}
@@ -235,8 +235,8 @@ void ChartController::executeDispatch_NewArrangement()
{
// using assignment for broken gcc 3.3
UndoGuard aUndoGuard = UndoGuard(
- ::rtl::OUString( String( SchResId( STR_ACTION_REARRANGE_CHART ))),
- m_xUndoManager, xModel );
+ String( SchResId( STR_ACTION_REARRANGE_CHART )),
+ 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 )
@@ -285,14 +285,14 @@ void ChartController::executeDispatch_ScaleText()
::vos::OGuard aSolarGuard( Application::GetSolarMutex());
// using assignment for broken gcc 3.3
UndoGuard aUndoGuard = UndoGuard(
- ::rtl::OUString( String( SchResId( STR_ACTION_SCALE_TEXT ))),
- m_xUndoManager, getModel() );
+ String( SchResId( STR_ACTION_SCALE_TEXT )),
+ 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()
@@ -655,12 +655,12 @@ bool ChartController::executeDispatch_Delete()
// using assignment for broken gcc 3.3
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLE )))),
- m_xUndoManager, getModel());
+ ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_TITLE ))),
+ m_xUndoManager );
TitleHelper::removeTitle(
ObjectIdentifier::getTitleTypeForCID( aCID ), getModel() );
bReturn = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
break;
}
case OBJECTTYPE_LEGEND:
@@ -674,11 +674,11 @@ bool ChartController::executeDispatch_Delete()
// using assignment for broken gcc 3.3
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))),
+ m_xUndoManager );
xLegendProp->setPropertyValue( C2U("Show"), uno::makeAny( false ));
bReturn = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
break;
@@ -709,11 +709,11 @@ bool ChartController::executeDispatch_Delete()
// using assignment for broken gcc 3.3
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))),
- m_xUndoManager, getModel() );
+ ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AVERAGE_LINE ))),
+ m_xUndoManager );
RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt );
bReturn = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
break;
}
@@ -732,15 +732,15 @@ bool ChartController::executeDispatch_Delete()
// using assignment for broken gcc 3.3
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))),
- m_xUndoManager, xModel );
+ ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE_EQUATION ))),
+ 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;
}
@@ -755,8 +755,8 @@ bool ChartController::executeDispatch_Delete()
// using assignment for broken gcc 3.3
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
- ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_BARS )))),
- m_xUndoManager, xModel );
+ ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_ERROR_BARS ))),
+ 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_xUndoManager, getModel() );
+ 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(
- ::rtl::OUString( String( SchResId( STR_ACTION_TOGGLE_LEGEND ))), m_xUndoManager, xModel );
+ 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(
- ::rtl::OUString( String( SchResId( STR_ACTION_TOGGLE_GRID_HORZ ))), m_xUndoManager, xModel );
+ 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_xUndoManager, m_aModel->getModel() );
+ 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 885e37126dc2..0a81048d771b 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -801,7 +801,11 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
if ( m_eDrawMode == CHARTDRAW_INSERT && pDrawViewWrapper->IsCreateObj() )
{
pDrawViewWrapper->EndCreateObj( SDRCREATE_FORCEEND );
- impl_switchDiagramPositioningToExcludingPositioning();
+ {
+ HiddenUndoContext aUndoContext( m_xUndoManager );
+ // don't want the positioning Undo action to appear in the UI
+ impl_switchDiagramPositioningToExcludingPositioning();
+ }
if ( pDrawViewWrapper->AreObjectsMarked() )
{
if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT )
@@ -838,12 +842,12 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
if( pChartDragMethod )
{
UndoGuard aUndoGuard( pChartDragMethod->getUndoDescription(),
- m_xUndoManager, getModel() );
+ m_xUndoManager );
if( pDrawViewWrapper->EndDragObj(false) )
{
bDraggingDone = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
@@ -871,7 +875,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
ActionDescriptionProvider::createDescription(
eActionType,
ObjectNameProvider::getName( ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ))),
- m_xUndoManager, getModel() );
+ m_xUndoManager );
bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID()
, getModel()
, awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight())
@@ -879,7 +883,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt )
if( bChanged )
{
bDraggingDone = true;
- aUndoGuard.commitAction();
+ aUndoGuard.commit();
}
}
}
@@ -1832,7 +1836,7 @@ bool ChartController::impl_moveOrResizeObject(
ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID );
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription(
- eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager, xChartModel );
+ eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager );
{
ControllerLockGuard aCLGuard( xChartModel );
if( bNeedShift )
@@ -1840,7 +1844,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/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/CommandDispatchContainer.cxx b/chart2/source/controller/main/CommandDispatchContainer.cxx
index e0d689340760..c0847a490ea1 100644
--- a/chart2/source/controller/main/CommandDispatchContainer.cxx
+++ b/chart2/source/controller/main/CommandDispatchContainer.cxx
@@ -75,12 +75,6 @@ void CommandDispatchContainer::setModel(
m_xModel = xModel;
}
-// void CommandDispatchContainer::setUndoManager(
-// const Reference< chart2::XUndoManager > & xUndoManager )
-// {
-// m_xUndoManager = xUndoManager;
-// }
-
void CommandDispatchContainer::setChartDispatch(
const Reference< frame::XDispatch > xChartDispatch,
const ::std::set< OUString > & rChartCommands )
diff --git a/chart2/source/controller/main/CommandDispatchContainer.hxx b/chart2/source/controller/main/CommandDispatchContainer.hxx
index 1c8769e0a6d9..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/XUndoManager.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/frame/DispatchDescriptor.hpp>
@@ -86,9 +85,6 @@ public:
void setModel(
const ::com::sun::star::uno::Reference<
::com::sun::star::frame::XModel > & xModel );
-// void setUndoManager(
-// const ::com::sun::star::uno::Reference<
-// ::com::sun::star::chart2::XUndoManager > & xUndoManager );
/** Set a chart dispatcher that is used for all commands contained in
rChartCommands
@@ -140,9 +136,8 @@ private:
mutable tDispatchMap m_aCachedDispatches;
mutable tDisposeVector m_aToBeDisposedDispatches;
- ::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::XUndoManager > m_xUndoManager;
+ ::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::frame::XDispatch > m_xChartDispatcher;
::std::set< ::rtl::OUString > m_aChartCommands;
diff --git a/chart2/source/controller/main/ImplUndoManager.cxx b/chart2/source/controller/main/ImplUndoManager.cxx
deleted file mode 100644
index 0976b7db286e..000000000000
--- a/chart2/source/controller/main/ImplUndoManager.cxx
+++ /dev/null
@@ -1,503 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_chart2.hxx"
-
-#include "ImplUndoManager.hxx"
-#include "DisposeHelper.hxx"
-#include "CommonFunctors.hxx"
-#include "ControllerLockGuard.hxx"
-#include "PropertyHelper.hxx"
-#include "DataSourceHelper.hxx"
-#include "ChartModelHelper.hxx"
-
-#include <com/sun/star/chart/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 <boost/bind.hpp>
-#include <algorithm>
-
-using namespace ::com::sun::star;
-
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-using ::rtl::OUString;
-using ::com::sun::star::chart::XComplexDescriptionAccess;
-
-namespace chart
-{
-namespace impl
-{
-
-void ImplApplyDataToModel(
- Reference< frame::XModel > & xInOutModelToChange,
- const Reference< chart2::XInternalDataProvider > & xData )
-{
- Reference< chart2::XChartDocument > xDoc( xInOutModelToChange, uno::UNO_QUERY );
- OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider());
-
- // copy data from stored internal data provider
- if( xDoc.is() && xDoc->hasInternalDataProvider())
- {
- Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY );
- Reference< XComplexDescriptionAccess > xSavedData( xData, uno::UNO_QUERY );
- if( xCurrentData.is() && xSavedData.is())
- {
- xCurrentData->setData( xSavedData->getData());
- xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions());
- xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions());
- }
- }
-}
-
-// ----------------------------------------
-
-UndoElement::UndoElement(
- const OUString & rActionString,
- const Reference< frame::XModel > & xModel ) :
- m_aActionString( rActionString )
-{
- initialize( xModel );
-}
-
-UndoElement::UndoElement(
- const Reference< frame::XModel > & xModel )
-{
- initialize( xModel );
-}
-
-UndoElement::UndoElement( const UndoElement & rOther ) :
- m_aActionString( rOther.m_aActionString )
-{
- initialize( rOther.m_xModel );
-}
-
-UndoElement::~UndoElement()
-{}
-
-void UndoElement::initialize( const Reference< frame::XModel > & xModel )
-{
- if ( xModel.is() )
- {
- m_xModel.set( UndoElement::cloneModel( xModel ) );
- }
-}
-
-void UndoElement::dispose()
-{
- Reference< lang::XComponent > xComp( m_xModel, uno::UNO_QUERY );
- if( xComp.is())
- xComp->dispose();
- m_xModel.set( 0 );
-}
-
-void UndoElement::applyToModel(
- Reference< frame::XModel > & xInOutModelToChange )
-{
- UndoElement::applyModelContentToModel( xInOutModelToChange, m_xModel );
-}
-
-UndoElement * UndoElement::createFromModel(
- const Reference< frame::XModel > & xModel )
-{
- return new UndoElement( getActionString(), xModel );
-}
-
-void UndoElement::setActionString( const ::rtl::OUString & rActionString )
-{
- m_aActionString = rActionString;
-}
-
-OUString UndoElement::getActionString() const
-{
- return m_aActionString;
-}
-
-Reference< frame::XModel > UndoElement::cloneModel( const Reference< frame::XModel > & xModel )
-{
- Reference< frame::XModel > xResult;
- uno::Reference< util::XCloneable > xCloneable( xModel, uno::UNO_QUERY );
- OSL_ENSURE( xCloneable.is(), "Cannot clone model" );
- if( xCloneable.is())
- xResult.set( xCloneable->createClone(), uno::UNO_QUERY );
-
- return xResult;
-}
-
-void UndoElement::applyModelContentToModel(
- Reference< frame::XModel > & xInOutModelToChange,
- const Reference< frame::XModel > & xModelToCopyFrom,
- const Reference< chart2::XInternalDataProvider > & xData /* = 0 */ )
-{
-
- if( xModelToCopyFrom.is() && xInOutModelToChange.is())
- {
- try
- {
- // /-- loccked controllers of destination
- ControllerLockGuard aLockedControllers( xInOutModelToChange );
- Reference< chart2::XChartDocument > xSource( xModelToCopyFrom, uno::UNO_QUERY_THROW );
- Reference< chart2::XChartDocument > xDestination( xInOutModelToChange, uno::UNO_QUERY_THROW );
-
- // propagate the correct flag for plotting of hidden values to the data provider and all used sequences
- ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( xModelToCopyFrom ) , xInOutModelToChange );
-
- // diagram
- xDestination->setFirstDiagram( xSource->getFirstDiagram());
-
- // main title
- Reference< chart2::XTitled > xDestinationTitled( xDestination, uno::UNO_QUERY_THROW );
- Reference< chart2::XTitled > xSourceTitled( xSource, uno::UNO_QUERY_THROW );
- xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject());
-
- // page background
- comphelper::copyProperties(
- xSource->getPageBackground(),
- xDestination->getPageBackground() );
-
- // apply data (not applied in standard Undo)
- if( xData.is())
- ImplApplyDataToModel( xInOutModelToChange, xData );
-
- // register all sequences at the internal data provider to get adapted
- // indexes when columns are added/removed
- if( xDestination->hasInternalDataProvider())
- {
- Reference< chart2::XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), uno::UNO_QUERY );
- Reference< chart2::data::XDataSource > xUsedData( DataSourceHelper::getUsedData( xInOutModelToChange ));
- if( xUsedData.is() && xNewDataProvider.is())
- {
- Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xUsedData->getDataSequences());
- for( sal_Int32 i=0; i<aData.getLength(); ++i )
- {
- xNewDataProvider->registerDataSequenceForChanges( aData[i]->getValues());
- xNewDataProvider->registerDataSequenceForChanges( aData[i]->getLabel());
- }
- }
- }
-
- // restore modify status
- Reference< util::XModifiable > xSourceMod( xSource, uno::UNO_QUERY );
- Reference< util::XModifiable > xDestMod( xDestination, uno::UNO_QUERY );
- if( xSourceMod.is() && xDestMod.is() &&
- ! xSourceMod->isModified() )
- {
- xDestMod->setModified( sal_False );
- }
- // \-- loccked controllers of destination
- }
- catch( uno::Exception & )
- {
- }
- }
-}
-
-// ----------------------------------------
-
-UndoElementWithData::UndoElementWithData(
- const OUString & rActionString,
- const Reference< frame::XModel > & xModel ) :
- UndoElement( rActionString, xModel )
-{
- initializeData();
-}
-
-UndoElementWithData::UndoElementWithData(
- const Reference< frame::XModel > & xModel ) :
- UndoElement( xModel )
-{
- initializeData();
-}
-
-
-UndoElementWithData::UndoElementWithData(
- const UndoElementWithData & rOther ) :
- UndoElement( rOther )
-{
- initializeData();
-}
-
-UndoElementWithData::~UndoElementWithData()
-{}
-
-void UndoElementWithData::initializeData()
-{
- try
- {
- Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY_THROW );
- OSL_ASSERT( xChartDoc->hasInternalDataProvider());
- if( xChartDoc->hasInternalDataProvider())
- {
- Reference< util::XCloneable > xCloneable( xChartDoc->getDataProvider(), uno::UNO_QUERY );
- OSL_ENSURE( xCloneable.is(), "Cannot clone data" );
- if( xCloneable.is())
- m_xData.set( xCloneable->createClone(), uno::UNO_QUERY );
- }
- }
- catch( uno::Exception & )
- {
- }
-}
-
-void UndoElementWithData::dispose()
-{
- UndoElement::dispose();
- m_xData.set( 0 );
-}
-
-void UndoElementWithData::applyToModel(
- Reference< frame::XModel > & xInOutModelToChange )
-{
- UndoElement::applyModelContentToModel( xInOutModelToChange, m_xModel, m_xData );
-}
-
-UndoElement * UndoElementWithData::createFromModel(
- const Reference< frame::XModel > & xModel )
-{
- return new UndoElementWithData( getActionString(), xModel );
-}
-
-// ========================================
-
-// ----------------------------------------
-
-UndoElementWithSelection::UndoElementWithSelection(
- const OUString & rActionString,
- const Reference< frame::XModel > & xModel ) :
- UndoElement( rActionString, xModel )
-{
- initialize( xModel );
-}
-
-UndoElementWithSelection::UndoElementWithSelection(
- const Reference< frame::XModel > & xModel ) :
- UndoElement( xModel )
-{
- initialize( xModel );
-}
-
-UndoElementWithSelection::UndoElementWithSelection(
- const UndoElementWithSelection & rOther ) :
- UndoElement( rOther )
-{
- initialize( rOther.m_xModel );
-}
-
-UndoElementWithSelection::~UndoElementWithSelection()
-{}
-
-void UndoElementWithSelection::initialize( const Reference< frame::XModel > & xModel )
-{
- try
- {
- uno::Reference< view::XSelectionSupplier > xSelSupp( xModel->getCurrentController(), uno::UNO_QUERY );
- OSL_ASSERT( xSelSupp.is() );
-
- if( xSelSupp.is() )
- m_aSelection = xSelSupp->getSelection();
- }
- catch( const uno::Exception & )
- {
- }
-}
-
-void UndoElementWithSelection::dispose()
-{
- UndoElement::dispose();
- m_aSelection.clear();
-}
-
-void UndoElementWithSelection::applyToModel(
- Reference< frame::XModel > & xInOutModelToChange )
-{
- UndoElement::applyModelContentToModel( xInOutModelToChange, m_xModel );
- Reference< view::XSelectionSupplier > xCurrentSelectionSuppl( xInOutModelToChange->getCurrentController(), uno::UNO_QUERY );
- OSL_ASSERT( xCurrentSelectionSuppl.is() );
-
- if( xCurrentSelectionSuppl.is())
- xCurrentSelectionSuppl->select( m_aSelection );
-}
-
-UndoElement * UndoElementWithSelection::createFromModel(
- const Reference< frame::XModel > & xModel )
-{
- return new UndoElementWithSelection( getActionString(), xModel );
-}
-
-// ----------------------------------------
-
-ShapeUndoElement::ShapeUndoElement( const OUString& rActionString, SdrUndoAction* pAction )
- :UndoElement( rActionString, Reference< frame::XModel >() )
- ,m_pAction( pAction )
-{
-}
-
-ShapeUndoElement::ShapeUndoElement( const ShapeUndoElement& rOther )
- :UndoElement( rOther )
- ,m_pAction( rOther.m_pAction )
-{
-}
-
-ShapeUndoElement::~ShapeUndoElement()
-{
-}
-
-SdrUndoAction* ShapeUndoElement::getSdrUndoAction()
-{
- return m_pAction;
-}
-
-// ========================================
-
-UndoStack::UndoStack() :
- m_nSizeLimit( 1000 )
-{
-}
-
-UndoStack::~UndoStack()
-{
- disposeAndClear();
-}
-
-void UndoStack::pop()
-{
- if( ! empty())
- {
- top()->dispose();
- delete top();
- m_aStack.pop_back();
- }
-}
-
-void UndoStack::push( UndoElement * pElement )
-{
- m_aStack.push_back( pElement );
- applyLimitation();
-}
-
-UndoElement * UndoStack::top() const
-{
- return m_aStack.back();
-}
-
-OUString UndoStack::topUndoString() const
-{
- if( ! empty())
- return top()->getActionString();
- return OUString();
-}
-
-Sequence< OUString > UndoStack::getUndoStrings() const
-{
- sal_Int32 nSize( static_cast< sal_Int32 >( m_aStack.size()));
- Sequence< OUString > aResult( nSize );
- for( sal_Int32 i=0; i<nSize; ++i )
- aResult[i] = m_aStack[i]->getActionString();
- return aResult;
-}
-
-bool UndoStack::empty() const
-{
- return m_aStack.empty();
-}
-
-void UndoStack::disposeAndClear()
-{
- ::std::for_each( m_aStack.begin(), m_aStack.end(), ::boost::mem_fn( & UndoElement::dispose ));
- ::std::for_each( m_aStack.begin(), m_aStack.end(), CommonFunctors::DeletePtr< UndoElement >() );
- m_aStack.clear();
-}
-
-void UndoStack::limitSize( sal_Int32 nMaxSize )
-{
- m_nSizeLimit = nMaxSize;
- applyLimitation();
-}
-
-void UndoStack::applyLimitation()
-{
- if( m_aStack.size() > static_cast< sal_uInt32 >( m_nSizeLimit ))
- {
- tUndoStackType::iterator aBegin( m_aStack.begin());
- tUndoStackType::iterator aEnd( aBegin + (m_aStack.size() - m_nSizeLimit));
- // dispose and remove all undo elements that are over the limit
- ::std::for_each( aBegin, aEnd, ::boost::mem_fn( & UndoElement::dispose ));
- ::std::for_each( aBegin, aEnd, CommonFunctors::DeletePtr< UndoElement >() );
- m_aStack.erase( aBegin, aEnd );
- }
-}
-
-// ================================================================================
-
-namespace
-{
-static const OUString aUndoStepsPropName( RTL_CONSTASCII_USTRINGPARAM("Steps"));
-} // anonymous namespace
-
-UndoStepsConfigItem::UndoStepsConfigItem( ConfigItemListener & rListener ) :
- ::utl::ConfigItem( OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Undo"))),
- m_rListener( rListener )
-{
- EnableNotification( Sequence< OUString >( & aUndoStepsPropName, 1 ));
-}
-
-UndoStepsConfigItem::~UndoStepsConfigItem()
-{
-}
-
-void UndoStepsConfigItem::Notify( const Sequence< OUString > & aPropertyNames )
-{
- for( sal_Int32 nIdx=0; nIdx<aPropertyNames.getLength(); ++nIdx )
- {
- if( aPropertyNames[nIdx].equals( aUndoStepsPropName ))
- m_rListener.notify( aPropertyNames[nIdx] );
- }
-}
-
-void UndoStepsConfigItem::Commit()
-{
-}
-
-// mtehod is not const, because GetProperties is not const
-sal_Int32 UndoStepsConfigItem::getUndoSteps()
-{
- sal_Int32 nSteps = -1;
- Sequence< uno::Any > aValues(
- GetProperties( Sequence< OUString >( & aUndoStepsPropName, 1 )));
- if( aValues.getLength())
- aValues[0] >>= nSteps;
- return nSteps;
-}
-
-} // namespace impl
-} // namespace chart
diff --git a/chart2/source/controller/main/ImplUndoManager.hxx b/chart2/source/controller/main/ImplUndoManager.hxx
deleted file mode 100644
index 4dde0bc65719..000000000000
--- a/chart2/source/controller/main/ImplUndoManager.hxx
+++ /dev/null
@@ -1,227 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-#ifndef CHART2_IMPLUNDOMANAGER_HXX
-#define CHART2_IMPLUNDOMANAGER_HXX
-
-#include "ConfigItemListener.hxx"
-
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/uno/Sequence.hxx>
-
-#include <rtl/ustring.hxx>
-#include <unotools/configitem.hxx>
-
-#include <utility>
-#include <deque>
-
-
-class SdrUndoAction;
-
-namespace com { namespace sun { namespace star {
-namespace chart2 {
- class XInternalDataProvider;
-}
-}}}
-
-
-namespace chart
-{
-namespace impl
-{
-
-class UndoElement
-{
-public:
- UndoElement( const ::rtl::OUString & rActionString,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
- UndoElement( const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
- UndoElement( const UndoElement & rOther );
- virtual ~UndoElement();
-
- virtual void dispose();
- virtual UndoElement * createFromModel(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
-
- virtual void applyToModel(
- ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xInOutModelToChange );
-
- void setActionString( const ::rtl::OUString & rActionString );
- ::rtl::OUString getActionString() const;
-
- static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > cloneModel(
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel );
-
- static void applyModelContentToModel(
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xInOutModelToChange,
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModelToCopyFrom,
- const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & xData = 0 );
-
-protected:
- ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > m_xModel;
-
-private:
- void initialize( const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
-
- ::rtl::OUString m_aActionString;
-};
-
-class UndoElementWithData : public UndoElement
-{
-public:
- UndoElementWithData( const ::rtl::OUString & rActionString,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
- UndoElementWithData( const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
- UndoElementWithData( const UndoElementWithData & rOther );
- virtual ~UndoElementWithData();
-
- virtual void dispose();
- virtual UndoElement * createFromModel(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
-
- virtual void applyToModel(
- ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xInOutModelToChange );
-
-private:
- void initializeData();
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XInternalDataProvider > m_xData;
-};
-
-class UndoElementWithSelection : public UndoElement
-{
-public:
- UndoElementWithSelection( const ::rtl::OUString & rActionString,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
- UndoElementWithSelection( const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
- UndoElementWithSelection( const UndoElementWithSelection & rOther );
- virtual ~UndoElementWithSelection();
-
- virtual void dispose();
- virtual UndoElement * createFromModel(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
-
- virtual void applyToModel(
- ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xInOutModelToChange );
-
-private:
- void initialize( const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
-
- ::com::sun::star::uno::Any m_aSelection;
-};
-
-class ShapeUndoElement : public UndoElement
-{
-public:
- ShapeUndoElement( const ::rtl::OUString& rActionString, SdrUndoAction* pAction );
- ShapeUndoElement( const ShapeUndoElement& rOther );
- virtual ~ShapeUndoElement();
-
- SdrUndoAction* getSdrUndoAction();
-
-private:
- SdrUndoAction* m_pAction;
-};
-
-/** Note that all models that are put into this container are at some point
- disposed of inside this class. (At least in the destructor). That means
- the models retrieved here should never be used, but instead their content
- should be copied to a living model.
- */
-class UndoStack
-{
-public:
- UndoStack();
- // disposes of all models left in the stack
- ~UndoStack();
-
- // removes he last undo action and disposes of the model
- void pop();
- void push( UndoElement * rElement );
-
- // precondition: !empty()
- UndoElement * top() const;
- ::rtl::OUString topUndoString() const;
-
- ::com::sun::star::uno::Sequence< ::rtl::OUString > getUndoStrings() const;
-
- bool empty() const;
- void disposeAndClear();
-
- // removes all actions that have been inserted more than nMaxSize steps ago.
- // The models of those actions are disposed of
- void limitSize( sal_Int32 nMaxSize );
-
-private:
- void applyLimitation();
-
- typedef ::std::deque< UndoElement * > tUndoStackType;
-
- tUndoStackType m_aStack;
- sal_Int32 m_nSizeLimit;
-};
-
-// ----------------------------------------
-
-class UndoStepsConfigItem : public ::utl::ConfigItem
-{
-public:
- explicit UndoStepsConfigItem( ConfigItemListener & rListener );
- virtual ~UndoStepsConfigItem();
-
- sal_Int32 getUndoSteps();
-
-protected:
- // ____ ::utl::ConfigItem ____
- virtual void Notify( const ::com::sun::star::uno::Sequence< ::rtl::OUString > & aPropertyNames );
- virtual void Commit();
-
-private:
- ConfigItemListener & m_rListener;
-};
-
-
-} // namespace impl
-} // namespace chart
-
-// CHART2_IMPLUNDOMANAGER_HXX
-#endif
diff --git a/chart2/source/controller/main/UndoActions.cxx b/chart2/source/controller/main/UndoActions.cxx
new file mode 100644
index 000000000000..86c0e365f590
--- /dev/null
+++ b/chart2/source/controller/main/UndoActions.cxx
@@ -0,0 +1,178 @@
+/*************************************************************************
+ *
+ * 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 "UndoActions.hxx"
+#include "DisposeHelper.hxx"
+#include "CommonFunctors.hxx"
+#include "PropertyHelper.hxx"
+#include "ChartModelClone.hxx"
+
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+
+#include <tools/diagnose_ex.h>
+#include <svx/svdundo.hxx>
+
+#include <boost/bind.hpp>
+#include <algorithm>
+
+using namespace ::com::sun::star;
+
+using ::rtl::OUString;
+
+namespace chart
+{
+namespace impl
+{
+
+ /** === 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::lang::XComponent;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::view::XSelectionSupplier;
+ using ::com::sun::star::chart2::XChartDocument;
+ using ::com::sun::star::document::UndoFailedException;
+ /** === end UNO using === **/
+
+// ---------------------------------------------------------------------------------------------------------------------
+UndoElement::UndoElement( const OUString& i_actionString, const Reference< XModel >& i_documentModel, const ::boost::shared_ptr< ChartModelClone >& i_modelClone )
+ :UndoElement_MBase()
+ ,UndoElement_TBase( m_aMutex )
+ ,m_sActionString( i_actionString )
+ ,m_xDocumentModel( i_documentModel )
+ ,m_pModelClone( i_modelClone )
+{
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+UndoElement::~UndoElement()
+{
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+void SAL_CALL UndoElement::disposing()
+{
+ if ( !!m_pModelClone )
+ m_pModelClone->dispose();
+ m_pModelClone.reset();
+ m_xDocumentModel.clear();
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL UndoElement::getTitle() throw (RuntimeException)
+{
+ return m_sActionString;
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+void UndoElement::impl_toggleModelState()
+{
+ // get a snapshot of the current state of our model
+ ::boost::shared_ptr< ChartModelClone > pNewClone( new ChartModelClone( m_xDocumentModel, m_pModelClone->getFacet() ) );
+ // apply the previous snapshot to our model
+ m_pModelClone->applyToModel( m_xDocumentModel );
+ // remember the new snapshot, for the next toggle
+ m_pModelClone = pNewClone;
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+void SAL_CALL UndoElement::undo( ) throw (UndoFailedException, RuntimeException)
+{
+ impl_toggleModelState();
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+void SAL_CALL UndoElement::redo( ) throw (UndoFailedException, RuntimeException)
+{
+ impl_toggleModelState();
+}
+
+// =====================================================================================================================
+// = ShapeUndoElement
+// =====================================================================================================================
+
+// ---------------------------------------------------------------------------------------------------------------------
+ShapeUndoElement::ShapeUndoElement( SdrUndoAction& i_sdrUndoAction )
+ :ShapeUndoElement_MBase()
+ ,ShapeUndoElement_TBase( m_aMutex )
+ ,m_pAction( &i_sdrUndoAction )
+{
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+ShapeUndoElement::~ShapeUndoElement()
+{
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ShapeUndoElement::getTitle() throw (RuntimeException)
+{
+ if ( !m_pAction )
+ throw DisposedException( ::rtl::OUString(), *this );
+ return m_pAction->GetComment();
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+void SAL_CALL ShapeUndoElement::undo( ) throw (UndoFailedException, RuntimeException)
+{
+ if ( !m_pAction )
+ throw DisposedException( ::rtl::OUString(), *this );
+ m_pAction->Undo();
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+void SAL_CALL ShapeUndoElement::redo( ) throw (UndoFailedException, RuntimeException)
+{
+ if ( !m_pAction )
+ throw DisposedException( ::rtl::OUString(), *this );
+ m_pAction->Redo();
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+void SAL_CALL ShapeUndoElement::disposing()
+{
+}
+
+} // namespace impl
+} // namespace chart
diff --git a/chart2/source/controller/main/UndoActions.hxx b/chart2/source/controller/main/UndoActions.hxx
new file mode 100644
index 000000000000..2c98d6af1d54
--- /dev/null
+++ b/chart2/source/controller/main/UndoActions.hxx
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CHART2_IMPLUNDOMANAGER_HXX
+#define CHART2_IMPLUNDOMANAGER_HXX
+
+#include "ConfigItemListener.hxx"
+
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/document/XUndoAction.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <rtl/ustring.hxx>
+#include <unotools/configitem.hxx>
+#include <cppuhelper/compbase1.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+#include <utility>
+#include <deque>
+
+#include <boost/noncopyable.hpp>
+#include <boost/shared_ptr.hpp>
+
+class SdrUndoAction;
+
+namespace com { namespace sun { namespace star {
+namespace chart2 {
+ class XInternalDataProvider;
+}
+}}}
+
+
+namespace chart
+{
+class ChartModelClone;
+
+namespace impl
+{
+
+typedef ::cppu::BaseMutex UndoElement_MBase;
+typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > UndoElement_TBase;
+
+class UndoElement :public UndoElement_MBase
+ ,public UndoElement_TBase
+ ,public ::boost::noncopyable
+{
+public:
+ /** creates a new undo action
+
+ @param i_actionString
+ is the title of the Undo action
+ @param i_documentModel
+ is the actual document model which the undo actions operates on
+ @param i_modelClone
+ is the cloned model from before the changes, which the Undo action represents, have been applied.
+ Upon <member>invoking</member>, the clone model is applied to the document model.
+ */
+ UndoElement( const ::rtl::OUString & i_actionString,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_documentModel,
+ const ::boost::shared_ptr< ChartModelClone >& i_modelClone
+ );
+
+ // XUndoAction
+ virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL undo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL redo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+protected:
+ virtual ~UndoElement();
+
+private:
+ void impl_toggleModelState();
+
+private:
+ ::rtl::OUString m_sActionString;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDocumentModel;
+ ::boost::shared_ptr< ChartModelClone > m_pModelClone;
+};
+
+
+typedef ::cppu::BaseMutex ShapeUndoElement_MBase;
+typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > ShapeUndoElement_TBase;
+class ShapeUndoElement :public ShapeUndoElement_MBase
+ ,public ShapeUndoElement_TBase
+{
+public:
+ ShapeUndoElement( SdrUndoAction& i_sdrUndoAction );
+
+ // XUndoAction
+ virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL undo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL redo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+protected:
+ virtual ~ShapeUndoElement();
+
+private:
+ SdrUndoAction* m_pAction;
+};
+
+} // namespace impl
+} // namespace chart
+
+// CHART2_IMPLUNDOMANAGER_HXX
+#endif
diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx
index 128a4b4091d0..487def377d5c 100644
--- a/chart2/source/controller/main/UndoCommandDispatch.cxx
+++ b/chart2/source/controller/main/UndoCommandDispatch.cxx
@@ -29,13 +29,15 @@
#include "precompiled_chart2.hxx"
#include "UndoCommandDispatch.hxx"
+#include "ResId.hxx"
#include "macros.hxx"
-#include <com/sun/star/chart2/XUndoSupplier.hpp>
#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 <svtools/svtools.hrc>
@@ -56,10 +58,8 @@ UndoCommandDispatch::UndoCommandDispatch(
CommandDispatch( xContext ),
m_xModel( xModel )
{
- Reference< chart2::XUndoSupplier > xUndoSupplier( xModel, uno::UNO_QUERY );
- OSL_ASSERT( xUndoSupplier.is());
- if( xUndoSupplier.is())
- m_xUndoManager.set( xUndoSupplier->getUndoManager());
+ uno::Reference< document::XUndoManagerSupplier > xSuppUndo( m_xModel, uno::UNO_QUERY_THROW );
+ m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW );
}
UndoCommandDispatch::~UndoCommandDispatch()
@@ -68,10 +68,8 @@ UndoCommandDispatch::~UndoCommandDispatch()
void UndoCommandDispatch::initialize()
{
Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY );
- if( xBroadcaster.is() )
- {
- xBroadcaster->addModifyListener( this );
- }
+ ENSURE_OR_RETURN_VOID( xBroadcaster.is(), "UndoCommandDispatch::initialize: missing modification broadcaster interface!" );
+ xBroadcaster->addModifyListener( this );
}
void UndoCommandDispatch::fireStatusEvent(
@@ -82,23 +80,23 @@ void UndoCommandDispatch::fireStatusEvent(
{
bool bFireAll = (rURL.getLength() == 0);
uno::Any aUndoState, aRedoState;
- if( m_xUndoManager->undoPossible())
+ if( m_xUndoManager->isUndoPossible())
{
// using assignment for broken gcc 3.3
OUString aUndo = OUString( String( SvtResId( STR_UNDO )));
- aUndoState <<= ( aUndo + m_xUndoManager->getCurrentUndoString());
+ aUndoState <<= ( aUndo + m_xUndoManager->getCurrentUndoActionTitle());
}
- if( m_xUndoManager->redoPossible())
+ if( m_xUndoManager->isRedoPossible())
{
// using assignment for broken gcc 3.3
OUString aRedo = OUString( String( SvtResId( STR_REDO )));
- aRedoState <<= ( aRedo + m_xUndoManager->getCurrentRedoString());
+ aRedoState <<= ( aRedo + m_xUndoManager->getCurrentRedoActionTitle());
}
if( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Undo")))
- fireStatusEventForURL( C2U(".uno:Undo"), aUndoState, m_xUndoManager->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_xUndoManager->redoPossible(), xSingleListener );
+ fireStatusEventForURL( C2U(".uno:Redo"), aRedoState, m_xUndoManager->isRedoPossible(), xSingleListener );
}
}
@@ -113,10 +111,21 @@ void SAL_CALL UndoCommandDispatch::dispatch(
// why is it necessary to lock the solar mutex here?
// /--
::vos::OGuard aSolarGuard( Application::GetSolarMutex());
- if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" )))
- m_xUndoManager->undo( m_xModel );
- else
- m_xUndoManager->redo( m_xModel );
+ try
+ {
+ if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" )))
+ m_xUndoManager->undo();
+ else
+ m_xUndoManager->redo();
+ }
+ catch( const document::UndoFailedException& )
+ {
+ // silently ignore
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
// \--
}
}
@@ -126,6 +135,7 @@ void SAL_CALL UndoCommandDispatch::dispatch(
void SAL_CALL UndoCommandDispatch::disposing()
{
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 );
diff --git a/chart2/source/controller/main/UndoCommandDispatch.hxx b/chart2/source/controller/main/UndoCommandDispatch.hxx
index 28fb813f63de..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/XUndoManager.hpp>
+#include <com/sun/star/document/XUndoManager.hpp>
namespace chart
{
/** This is a CommandDispatch implementation for Undo and Redo.
-
- You need to pass an UndoManager 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::XUndoManager > m_xUndoManager;
+ ::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 8513b6ba9093..52ea27aa8d49 100644
--- a/chart2/source/controller/main/UndoGuard.cxx
+++ b/chart2/source/controller/main/UndoGuard.cxx
@@ -29,6 +29,12 @@
#include "precompiled_chart2.hxx"
#include "UndoGuard.hxx"
+#include "ChartModelClone.hxx"
+#include "UndoActions.hxx"
+
+#include <com/sun/star/container/XChild.hpp>
+
+#include <tools/diagnose_ex.h>
using namespace ::com::sun::star;
@@ -39,105 +45,154 @@ using ::rtl::OUString;
namespace chart
{
-UndoGuard_Base::UndoGuard_Base( const OUString& rUndoString
- , const uno::Reference< chart2::XUndoManager > & xUndoManager
- , const uno::Reference< frame::XModel > & xModel )
- : m_xModel( xModel )
- , m_xUndoManager( xUndoManager )
- , m_aUndoString( rUndoString )
- , m_bActionPosted( false )
+//-----------------------------------------------------------------------------
+
+UndoGuard::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();
}
-void UndoGuard_Base::commitAction()
+//-----------------------------------------------------------------------------
+
+void UndoGuard::commit()
{
- if( !m_bActionPosted && m_xUndoManager.is() )
- m_xUndoManager->postAction( m_aUndoString );
+ if ( !m_bActionPosted && !!m_pDocumentSnapshot )
+ {
+ try
+ {
+ 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 );
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
m_bActionPosted = true;
}
//-----------------------------------------------------------------------------
-UndoGuard::UndoGuard( const OUString& rUndoString
- , const uno::Reference< chart2::XUndoManager > & xUndoManager
- , const uno::Reference< frame::XModel > & xModel )
- : UndoGuard_Base( rUndoString, xUndoManager, xModel )
+void UndoGuard::rollback()
{
- if( m_xUndoManager.is() )
- m_xUndoManager->preAction( m_xModel );
+ ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" );
+ m_pDocumentSnapshot->applyToModel( m_xChartModel );
+ discardSnapshot();
}
-UndoGuard::~UndoGuard()
+//-----------------------------------------------------------------------------
+void UndoGuard::discardSnapshot()
{
- if( !m_bActionPosted && m_xUndoManager.is() )
- m_xUndoManager->cancelAction();
+ ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" );
+ m_pDocumentSnapshot->dispose();
+ m_pDocumentSnapshot.reset();
}
//-----------------------------------------------------------------------------
-UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& rUndoString
- , const uno::Reference< chart2::XUndoManager > & xUndoManager
- , const uno::Reference< frame::XModel > & xModel )
- : UndoGuard_Base( rUndoString, xUndoManager, xModel )
+UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
+ :UndoGuard( i_undoString, i_undoManager, E_MODEL )
{
- if( m_xUndoManager.is() )
- m_xUndoManager->preAction( m_xModel );
}
UndoLiveUpdateGuard::~UndoLiveUpdateGuard()
{
- if( !m_bActionPosted && m_xUndoManager.is() )
- m_xUndoManager->cancelActionWithUndo( m_xModel );
+ if ( !isActionPosted() )
+ rollback();
}
//-----------------------------------------------------------------------------
-UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData( const OUString& rUndoString
- , const uno::Reference< chart2::XUndoManager > & xUndoManager
- , const uno::Reference< frame::XModel > & xModel )
- : UndoGuard_Base( rUndoString, xUndoManager, xModel )
+UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData(
+ const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
+ :UndoGuard( i_undoString, i_undoManager, E_MODEL_WITH_DATA )
{
- if( m_xUndoManager.is() )
- {
- Sequence< beans::PropertyValue > aArgs(1);
- aArgs[0] = beans::PropertyValue(
- OUString( RTL_CONSTASCII_USTRINGPARAM("WithData")), -1, uno::Any(),
- beans::PropertyState_DIRECT_VALUE );
- m_xUndoManager->preActionWithArguments( m_xModel, aArgs );
- }
}
UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData()
{
- if( !m_bActionPosted && m_xUndoManager.is() )
- m_xUndoManager->cancelActionWithUndo( m_xModel );
+ if ( !isActionPosted() )
+ rollback();
}
//-----------------------------------------------------------------------------
-UndoGuardWithSelection::UndoGuardWithSelection( const rtl::OUString& rUndoString
- , const uno::Reference< chart2::XUndoManager > & xUndoManager
- , const uno::Reference< frame::XModel > & xModel )
- : UndoGuard_Base( rUndoString, xUndoManager, xModel )
+UndoGuardWithSelection::UndoGuardWithSelection(
+ const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
+ :UndoGuard( i_undoString, i_undoManager, E_MODEL_WITH_SELECTION )
{
- if( m_xUndoManager.is() )
+}
+
+//-----------------------------------------------------------------------------
+
+UndoGuardWithSelection::~UndoGuardWithSelection()
+{
+ if ( !isActionPosted() )
+ rollback();
+}
+
+//-----------------------------------------------------------------------------
+
+UndoContext::UndoContext( const Reference< document::XUndoManager > & i_undoManager, const ::rtl::OUString& i_undoTitle )
+ :m_xUndoManager( i_undoManager )
+{
+ ENSURE_OR_THROW( m_xUndoManager.is(), "invalid undo manager!" );
+ m_xUndoManager->enterUndoContext( i_undoTitle );
+}
+
+//-----------------------------------------------------------------------------
+
+UndoContext::~UndoContext()
+{
+ m_xUndoManager->leaveUndoContext();
+}
+
+//-----------------------------------------------------------------------------
+
+HiddenUndoContext::HiddenUndoContext( const Reference< document::XUndoManager > & i_undoManager )
+ :m_xUndoManager( i_undoManager )
+{
+ ENSURE_OR_THROW( m_xUndoManager.is(), "invalid undo manager!" );
+ try
+ {
+ m_xUndoManager->enterHiddenUndoContext();
+ }
+ catch( const uno::Exception& )
{
- Sequence< beans::PropertyValue > aArgs(1);
- aArgs[0] = beans::PropertyValue(
- OUString( RTL_CONSTASCII_USTRINGPARAM("WithSelection")), -1, uno::Any(),
- beans::PropertyState_DIRECT_VALUE );
- m_xUndoManager->preActionWithArguments( m_xModel, aArgs );
+ DBG_UNHANDLED_EXCEPTION();
+ m_xUndoManager.clear();
+ // prevents the leaveUndoContext in the dtor
}
}
-UndoGuardWithSelection::~UndoGuardWithSelection()
+//-----------------------------------------------------------------------------
+
+HiddenUndoContext::~HiddenUndoContext()
{
- if( !m_bActionPosted && m_xUndoManager.is() )
- m_xUndoManager->cancelAction();
+ try
+ {
+ if ( m_xUndoManager.is() )
+ m_xUndoManager->leaveUndoContext();
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
}
} // namespace chart
diff --git a/chart2/source/controller/main/UndoGuard.hxx b/chart2/source/controller/main/UndoGuard.hxx
new file mode 100644
index 000000000000..c5c00dd62d1b
--- /dev/null
+++ b/chart2/source/controller/main/UndoGuard.hxx
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * 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_UNDOGUARD_HXX
+#define CHART2_UNDOGUARD_HXX
+
+#include "ChartModelClone.hxx"
+
+#include <com/sun/star/document/XUndoManager.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+
+#include <rtl/ustring.hxx>
+
+#include <boost/shared_ptr.hpp>
+
+namespace chart
+{
+
+/** A guard which which does nothing, unless you explicitly call commitAction. In particular, in its destructor, it
+ does neither auto-commit nor auto-rollback the model changes.
+ */
+class UndoGuard
+{
+public:
+ explicit UndoGuard(
+ const ::rtl::OUString& i_undoMessage,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager,
+ const ModelFacet i_facet = E_MODEL
+ );
+ ~UndoGuard();
+
+ void commit();
+ void rollback();
+
+protected:
+ bool isActionPosted() const { return m_bActionPosted; }
+
+private:
+ void discardSnapshot();
+
+private:
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xChartModel;
+ const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager;
+
+ ::boost::shared_ptr< ChartModelClone > m_pDocumentSnapshot;
+ rtl::OUString m_aUndoString;
+ bool m_bActionPosted;
+};
+
+/** A guard which, in its destructor, restores the model state it found in the constructor. If
+ <member>commitAction</member> is called inbetween, the restouration is not performed.
+ */
+class UndoLiveUpdateGuard : public UndoGuard
+{
+public:
+ explicit UndoLiveUpdateGuard(
+ const ::rtl::OUString& i_undoMessage,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager
+ );
+ ~UndoLiveUpdateGuard();
+};
+
+/** Same as UndoLiveUpdateGuard but with additional storage of the chart's data.
+ Only use this if the data has internal data.
+ */
+class UndoLiveUpdateGuardWithData :
+ public UndoGuard
+{
+public:
+ explicit UndoLiveUpdateGuardWithData(
+ const ::rtl::OUString& i_undoMessage,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager
+ );
+ ~UndoLiveUpdateGuardWithData();
+};
+
+class UndoGuardWithSelection : public UndoGuard
+{
+public:
+ explicit UndoGuardWithSelection(
+ const ::rtl::OUString& i_undoMessage,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager
+ );
+ virtual ~UndoGuardWithSelection();
+};
+
+class UndoContext
+{
+public:
+ UndoContext(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager,
+ const ::rtl::OUString& i_undoTitle
+ );
+ ~UndoContext();
+
+private:
+ const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager;
+};
+
+class HiddenUndoContext
+{
+public:
+ HiddenUndoContext(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager
+ );
+ ~HiddenUndoContext();
+
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager;
+};
+
+}
+// CHART2_UNDOGUARD_HXX
+#endif
diff --git a/chart2/source/controller/main/UndoManager.cxx b/chart2/source/controller/main/UndoManager.cxx
deleted file mode 100644
index 21b3bbc1f725..000000000000
--- a/chart2/source/controller/main/UndoManager.cxx
+++ /dev/null
@@ -1,438 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_chart2.hxx"
-
-#include "UndoManager.hxx"
-#include "ImplUndoManager.hxx"
-#include "DisposeHelper.hxx"
-#include "MutexContainer.hxx"
-#include "macros.hxx"
-#include "ChartViewHelper.hxx"
-
-#include <com/sun/star/util/XCloneable.hpp>
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/chart2/XChartDocument.hpp>
-
-#include <unotools/configitem.hxx>
-#include <cppuhelper/compbase1.hxx>
-#include <rtl/uuid.h>
-#include <svx/svdundo.hxx>
-
-#include <functional>
-
-using namespace ::com::sun::star;
-
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-using ::rtl::OUString;
-
-
-// --------------------------------------------------------------------------------
-
-namespace chart
-{
-
-namespace impl
-{
-typedef ::cppu::WeakComponentImplHelper1<
- util::XModifyBroadcaster >
- ModifyBroadcaster_Base;
-
-class ModifyBroadcaster :
- public ::chart::MutexContainer,
- public ModifyBroadcaster_Base
-{
-public:
- ModifyBroadcaster();
-
- void fireEvent();
-
-protected:
- // ____ XModifyBroadcaster ____
- virtual void SAL_CALL addModifyListener( const Reference< util::XModifyListener >& xListener )
- throw (uno::RuntimeException);
- virtual void SAL_CALL removeModifyListener( const Reference< util::XModifyListener >& xListener )
- throw (uno::RuntimeException);
-};
-
-ModifyBroadcaster::ModifyBroadcaster() :
- ModifyBroadcaster_Base( m_aMutex )
-{}
-
-void SAL_CALL ModifyBroadcaster::addModifyListener(
- const Reference< util::XModifyListener >& xListener )
- throw (uno::RuntimeException)
-{
- rBHelper.addListener( ::getCppuType( & xListener ), xListener);
-}
-
-void SAL_CALL ModifyBroadcaster::removeModifyListener(
- const Reference< util::XModifyListener >& xListener )
- throw (uno::RuntimeException)
-{
- rBHelper.removeListener( ::getCppuType( & xListener ), xListener );
-}
-
-void ModifyBroadcaster::fireEvent()
-{
- ::cppu::OInterfaceContainerHelper* pIC = rBHelper.getContainer(
- ::getCppuType((const uno::Reference< util::XModifyListener >*)0) );
- if( pIC )
- {
- lang::EventObject aEvent( static_cast< lang::XComponent* >( this ) );
- ::cppu::OInterfaceIteratorHelper aIt( *pIC );
- while( aIt.hasMoreElements() )
- {
- uno::Reference< util::XModifyListener > xListener( aIt.next(), uno::UNO_QUERY );
- if( xListener.is() )
- xListener->modified( aEvent );
- }
- }
-}
-
-} // namespace impl
-
-UndoManager::UndoManager() :
- impl::UndoManager_Base( m_aMutex ),
- m_apUndoStack( new impl::UndoStack()),
- m_apRedoStack( new impl::UndoStack()),
- m_pLastRemeberedUndoElement( 0 ),
- m_nMaxNumberOfUndos( 100 ),
- m_pModifyBroadcaster( 0 )
-{}
-
-UndoManager::~UndoManager()
-{
- DisposeHelper::Dispose( m_xModifyBroadcaster );
- m_apUndoStack->disposeAndClear();
- m_apRedoStack->disposeAndClear();
-
- delete m_pLastRemeberedUndoElement;
- m_pLastRemeberedUndoElement = 0;
-}
-
-void UndoManager::addShapeUndoAction( SdrUndoAction* pAction )
-{
- if ( !pAction )
- {
- return;
- }
-
- impl::ShapeUndoElement* pShapeUndoElement = new impl::ShapeUndoElement( pAction->GetComment(), pAction );
- if ( pShapeUndoElement )
- {
- m_apUndoStack->push( pShapeUndoElement );
- m_apRedoStack->disposeAndClear();
- if ( !m_apUndoStepsConfigItem.get() )
- {
- retrieveConfigUndoSteps();
- }
- fireModifyEvent();
- }
-}
-
-void UndoManager::impl_undoRedo(
- Reference< frame::XModel > & xCurrentModel,
- impl::UndoStack * pStackToRemoveFrom,
- impl::UndoStack * pStackToAddTo,
- bool bUndo )
-{
- if( pStackToRemoveFrom && ! pStackToRemoveFrom->empty() )
- {
- // get model from undo/redo
- impl::UndoElement * pTop( pStackToRemoveFrom->top());
- if( pTop )
- {
- impl::ShapeUndoElement* pShapeUndoElement = dynamic_cast< impl::ShapeUndoElement* >( pTop );
- if ( pShapeUndoElement )
- {
- impl::ShapeUndoElement* pNewShapeUndoElement = new impl::ShapeUndoElement( *pShapeUndoElement );
- pStackToAddTo->push( pNewShapeUndoElement );
- SdrUndoAction* pAction = pNewShapeUndoElement->getSdrUndoAction();
- if ( pAction )
- {
- if ( bUndo )
- {
- pAction->Undo();
- }
- else
- {
- pAction->Redo();
- }
- }
- }
- else
- {
- // put a clone of current model into redo/undo stack with the same
- // action string as the undo/redo
- pStackToAddTo->push( pTop->createFromModel( xCurrentModel ));
- // change current model by properties of the model from undo
- pTop->applyToModel( xCurrentModel );
- }
- // remove the top undo element
- pStackToRemoveFrom->pop(), pTop = 0;
- ChartViewHelper::setViewToDirtyState( xCurrentModel );
- fireModifyEvent();
- }
- }
- else
- {
- OSL_ENSURE( false, "Can't Undo/Redo" );
- }
-}
-
-void UndoManager::fireModifyEvent()
-{
- if( m_xModifyBroadcaster.is())
- m_pModifyBroadcaster->fireEvent();
-}
-
-
-// ____ ConfigItemListener ____
-void UndoManager::notify( const ::rtl::OUString & rPropertyName )
-{
- OSL_ENSURE( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Steps" )),
- "Unwanted config property change Notified" );
- if( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Steps" )))
- retrieveConfigUndoSteps();
-}
-
-void UndoManager::retrieveConfigUndoSteps()
-{
- if( ! m_apUndoStepsConfigItem.get())
- m_apUndoStepsConfigItem.reset( new impl::UndoStepsConfigItem( *this ));
- m_nMaxNumberOfUndos = m_apUndoStepsConfigItem->getUndoSteps();
- m_apUndoStack->limitSize( m_nMaxNumberOfUndos );
- m_apRedoStack->limitSize( m_nMaxNumberOfUndos );
-
- // a list of available undo steps could shrink here
- fireModifyEvent();
-}
-
-// ____ XModifyBroadcaster ____
-void SAL_CALL UndoManager::addModifyListener( const Reference< util::XModifyListener >& aListener )
- throw (uno::RuntimeException)
-{
- if( ! m_xModifyBroadcaster.is())
- {
- m_pModifyBroadcaster = new impl::ModifyBroadcaster();
- m_xModifyBroadcaster.set( static_cast< cppu::OWeakObject* >( m_pModifyBroadcaster ), uno::UNO_QUERY );
- }
- m_xModifyBroadcaster->addModifyListener( aListener );
-}
-
-void SAL_CALL UndoManager::removeModifyListener( const Reference< util::XModifyListener >& aListener )
- throw (uno::RuntimeException)
-{
- if( ! m_xModifyBroadcaster.is())
- {
- m_pModifyBroadcaster = new impl::ModifyBroadcaster();
- m_xModifyBroadcaster.set( static_cast< cppu::OWeakObject* >( m_pModifyBroadcaster ), uno::UNO_QUERY );
- }
- m_xModifyBroadcaster->removeModifyListener( aListener );
-}
-
-// ____ chart2::XUndoManager ____
-void SAL_CALL UndoManager::preAction( const Reference< frame::XModel >& xModelBeforeChange )
- throw (uno::RuntimeException)
-{
- OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" );
- m_pLastRemeberedUndoElement = new impl::UndoElement( xModelBeforeChange );
-}
-
-void SAL_CALL UndoManager::preActionWithArguments(
- const Reference< frame::XModel >& xModelBeforeChange,
- const Sequence< beans::PropertyValue >& aArguments )
- throw (uno::RuntimeException)
-{
- bool bActionHandled( false );
- OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" );
- if( aArguments.getLength() > 0 )
- {
- OSL_ENSURE( aArguments.getLength() == 1, "More than one argument is not supported yet" );
- if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithData")))
- {
- m_pLastRemeberedUndoElement = new impl::UndoElementWithData( xModelBeforeChange );
- bActionHandled = true;
- }
- else if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithSelection")))
- {
- m_pLastRemeberedUndoElement = new impl::UndoElementWithSelection( xModelBeforeChange );
- bActionHandled = true;
- }
- }
-
- if( !bActionHandled )
- preAction( xModelBeforeChange );
-}
-
-void SAL_CALL UndoManager::postAction( const OUString& aUndoText )
- throw (uno::RuntimeException)
-{
- OSL_ENSURE( m_pLastRemeberedUndoElement, "Looks like preAction call was missing" );
- if( m_pLastRemeberedUndoElement )
- {
- m_pLastRemeberedUndoElement->setActionString( aUndoText );
- m_apUndoStack->push( m_pLastRemeberedUndoElement );
- m_pLastRemeberedUndoElement = 0;
-
- // redo no longer possible
- m_apRedoStack->disposeAndClear();
-
- // it suffices to get the number of undo steps from config after the
- // first time postAction has been called
- if( ! m_apUndoStepsConfigItem.get())
- retrieveConfigUndoSteps();
-
- fireModifyEvent();
- }
-}
-
-void SAL_CALL UndoManager::cancelAction()
- throw (uno::RuntimeException)
-{
- delete m_pLastRemeberedUndoElement;
- m_pLastRemeberedUndoElement = 0;
-}
-
-void SAL_CALL UndoManager::cancelActionWithUndo( Reference< frame::XModel >& xModelToRestore )
- throw (uno::RuntimeException)
-{
- if( m_pLastRemeberedUndoElement )
- {
- m_pLastRemeberedUndoElement->applyToModel( xModelToRestore );
- cancelAction();
- }
-}
-
-void SAL_CALL UndoManager::undo( Reference< frame::XModel >& xCurrentModel )
- throw (uno::RuntimeException)
-{
- OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get());
- impl_undoRedo( xCurrentModel, m_apUndoStack.get(), m_apRedoStack.get(), true );
-}
-
-void SAL_CALL UndoManager::redo( Reference< frame::XModel >& xCurrentModel )
- throw (uno::RuntimeException)
-{
- OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get());
- impl_undoRedo( xCurrentModel, m_apRedoStack.get(), m_apUndoStack.get(), false );
-}
-
-::sal_Bool SAL_CALL UndoManager::undoPossible()
- throw (uno::RuntimeException)
-{
- return ! m_apUndoStack->empty();
-}
-
-::sal_Bool SAL_CALL UndoManager::redoPossible()
- throw (uno::RuntimeException)
-{
- return ! m_apRedoStack->empty();
-}
-
-OUString SAL_CALL UndoManager::getCurrentUndoString()
- throw (uno::RuntimeException)
-{
- return m_apUndoStack->topUndoString();
-}
-
-OUString SAL_CALL UndoManager::getCurrentRedoString()
- throw (uno::RuntimeException)
-{
- return m_apRedoStack->topUndoString();
-}
-
-Sequence< OUString > SAL_CALL UndoManager::getAllUndoStrings()
- throw (uno::RuntimeException)
-{
- return m_apUndoStack->getUndoStrings();
-}
-
-Sequence< OUString > SAL_CALL UndoManager::getAllRedoStrings()
- throw (uno::RuntimeException)
-{
- return m_apRedoStack->getUndoStrings();
-}
-
-// ____ XUndoHelper ____
-Reference< frame::XModel > SAL_CALL UndoManager::getModelCloneForUndo(
- const Reference< frame::XModel >& xModelBeforeChange )
- throw (uno::RuntimeException)
-{
- return impl::UndoElement::cloneModel( xModelBeforeChange );
-}
-
-void SAL_CALL UndoManager::applyModelContent(
- Reference< frame::XModel >& xModelToChange,
- const Reference< frame::XModel >& xModelToCopyFrom )
- throw (uno::RuntimeException)
-{
- impl::UndoElement::applyModelContentToModel( xModelToChange, xModelToCopyFrom );
-}
-
-// ____ XUnoTunnel ____
-sal_Int64 UndoManager::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;
-}
-
-const Sequence< sal_Int8 >& UndoManager::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;
-}
-
-UndoManager* UndoManager::getImplementation( const Reference< uno::XInterface > xObj )
-{
- UndoManager* pRet = NULL;
- Reference< lang::XUnoTunnel > xUT( xObj, uno::UNO_QUERY );
- if ( xUT.is() )
- {
- pRet = reinterpret_cast< UndoManager* >( sal::static_int_cast< sal_IntPtr >( xUT->getSomething( getUnoTunnelId() ) ) );
- }
- return pRet;
-}
-
-} // namespace chart
diff --git a/chart2/source/controller/main/makefile.mk b/chart2/source/controller/main/makefile.mk
index 729276d5bd0e..557d6cf6216f 100644
--- a/chart2/source/controller/main/makefile.mk
+++ b/chart2/source/controller/main/makefile.mk
@@ -72,12 +72,9 @@ SLOFILES = \
$(SLO)$/DrawCommandDispatch.obj \
$(SLO)$/ShapeController.obj \
$(SLO)$/ShapeToolbarController.obj \
- $(SLO)$/ImplUndoManager.obj \
- $(SLO)$/UndoManager.obj \
- $(SLO)$/UndoGuard.obj
-
-# $(SLO)$/CommonConverters.obj \
-# $(SLO)$/Scaling.obj \
+ $(SLO)$/UndoActions.obj \
+ $(SLO)$/UndoGuard.obj \
+ $(SLO)$/ChartModelClone.obj \
# --- Targets -----------------------------------------------------------------
diff --git a/chart2/source/inc/ChartModelHelper.hxx b/chart2/source/inc/ChartModelHelper.hxx
index fb087abf15fd..7dbf0459d870 100644
--- a/chart2/source/inc/ChartModelHelper.hxx
+++ b/chart2/source/inc/ChartModelHelper.hxx
@@ -31,7 +31,6 @@
#include <com/sun/star/chart2/XDataSeries.hpp>
#include <com/sun/star/chart2/XDiagram.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
-#include <com/sun/star/chart2/XUndoManager.hpp>
#include <com/sun/star/chart2/data/XDataProvider.hpp>
#include <com/sun/star/chart2/data/XRangeHighlighter.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
diff --git a/chart2/source/inc/Strings.hrc b/chart2/source/inc/Strings.hrc
index 47ed75e80a9a..204133bd1cd5 100644
--- a/chart2/source/inc/Strings.hrc
+++ b/chart2/source/inc/Strings.hrc
@@ -310,6 +310,7 @@
#define STR_ACTION_TOGGLE_GRID_HORZ (RID_APP_START + 86)
#define STR_ACTION_SCALE_TEXT (RID_APP_START + 93)
#define STR_ACTION_REARRANGE_CHART (RID_APP_START + 94)
+#define STR_ACTION_EDIT_TEXT (RID_APP_START + 95)
#define STR_TIP_CHOOSECOLOR (RID_APP_START + 233)
#define STR_TIP_LIGHTSOURCE_X (RID_APP_START + 234)
diff --git a/chart2/source/inc/UndoGuard.hxx b/chart2/source/inc/UndoGuard.hxx
deleted file mode 100644
index 864d5ccff994..000000000000
--- a/chart2/source/inc/UndoGuard.hxx
+++ /dev/null
@@ -1,120 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-#ifndef CHART2_UNDOGUARD_HXX
-#define CHART2_UNDOGUARD_HXX
-
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/chart2/XUndoManager.hpp>
-
-// header for class OUString
-#include <rtl/ustring.hxx>
-
-namespace chart
-{
-/** Base Class for UndoGuard and UndoLiveUpdateGuard
-*/
-class UndoGuard_Base
-{
-public:
- explicit UndoGuard_Base( const rtl::OUString & rUndoMessage
- , const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XUndoManager > & xUndoManager
- , const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
- virtual ~UndoGuard_Base();
-
- void commitAction();
-
-protected:
- ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > m_xModel;
- ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XUndoManager > m_xUndoManager;
-
- rtl::OUString m_aUndoString;
- bool m_bActionPosted;
-};
-
-/** This guard calls preAction at the given Model in the CTOR and
- cancelAction in the DTOR if no other method is called.
- If commitAction is called the destructor does nothin anymore.
- */
-class UndoGuard : public UndoGuard_Base
-{
-public:
- explicit UndoGuard( const rtl::OUString& rUndoMessage
- , const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XUndoManager > & xUndoManager
- , const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
- virtual ~UndoGuard();
-};
-
-/** This guard calls preAction at the given Model in the CTOR and
- cancelActionUndo in the DTOR if no other method is called.
- If commitAction is called the destructor does nothin anymore.
- */
-class UndoLiveUpdateGuard : public UndoGuard_Base
-{
-public:
- explicit UndoLiveUpdateGuard( const rtl::OUString& rUndoMessage
- , const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XUndoManager > & xUndoManager
- , const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
- virtual ~UndoLiveUpdateGuard();
-};
-
-/** Same as UndoLiveUpdateGuard but with additional storage of the chart's data.
- Only use this if the data has internal data.
- */
-class UndoLiveUpdateGuardWithData :
- public UndoGuard_Base
-{
-public:
- explicit UndoLiveUpdateGuardWithData( const rtl::OUString& rUndoMessage
- , const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XUndoManager > & xUndoManager
- , const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
- virtual ~UndoLiveUpdateGuardWithData();
-};
-
-class UndoGuardWithSelection : public UndoGuard_Base
-{
-public:
- explicit UndoGuardWithSelection( const rtl::OUString& rUndoMessage
- , const ::com::sun::star::uno::Reference<
- ::com::sun::star::chart2::XUndoManager > & xUndoManager
- , const ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xModel );
- virtual ~UndoGuardWithSelection();
-};
-
-}
-// CHART2_UNDOGUARD_HXX
-#endif
diff --git a/chart2/source/inc/UndoManager.hxx b/chart2/source/inc/UndoManager.hxx
deleted file mode 100644
index a28a0d78c470..000000000000
--- a/chart2/source/inc/UndoManager.hxx
+++ /dev/null
@@ -1,180 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-#ifndef CHART2_UNDOMANAGER_HXX
-#define CHART2_UNDOMANAGER_HXX
-
-#include "ConfigItemListener.hxx"
-#include "MutexContainer.hxx"
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/uno/Sequence.hxx>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
-#include <com/sun/star/util/XModifyListener.hpp>
-#include <com/sun/star/chart2/XUndoManager.hpp>
-#include <com/sun/star/chart2/XUndoHelper.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
-
-#include <cppuhelper/compbase4.hxx>
-#include <rtl/ustring.hxx>
-
-// for pair
-#include <utility>
-// for auto_ptr
-#include <memory>
-
-class SdrUndoAction;
-
-namespace com { namespace sun { namespace star {
-namespace frame {
- class XModel;
-}
-}}}
-
-namespace chart
-{
-// ----------------------------------------
-namespace impl
-{
-
-class UndoStepsConfigItem;
-class UndoElement;
-class UndoStack;
-class ModifyBroadcaster;
-
-typedef ::cppu::WeakComponentImplHelper4<
- ::com::sun::star::util::XModifyBroadcaster,
- ::com::sun::star::chart2::XUndoManager,
- ::com::sun::star::chart2::XUndoHelper,
- ::com::sun::star::lang::XUnoTunnel >
- UndoManager_Base;
-
-} // namespace impl
-// ----------------------------------------
-
-/** Manages undo by storing the entire XModel in the undo- and redo-buffers.
- Note, that therefore this should not be used for "big" XModels.
-
- A prerequisite for this to work is that the XModels added to the undo-
- redo-stacks support the css::util::XCloneable interface, which is
- implemented such that the entire model is cloned.
- */
-class UndoManager :
- public MutexContainer,
- public ConfigItemListener,
- public impl::UndoManager_Base
-{
-public:
- explicit UndoManager();
- virtual ~UndoManager();
-
- void addShapeUndoAction( SdrUndoAction* pAction );
-
- // ____ XUnoTunnel ____
- virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId )
- throw (::com::sun::star::uno::RuntimeException);
-
- static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
- static UndoManager* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xObj );
-
-protected:
- // ____ ConfigItemListener ____
- virtual void notify( const ::rtl::OUString & rPropertyName );
-
- // ____ util::XModifyBroadcaster ____
- virtual void SAL_CALL addModifyListener(
- const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
- throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeModifyListener(
- const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
- throw (::com::sun::star::uno::RuntimeException);
-
- // ____ chart2::XUndoManager ____
- virtual void SAL_CALL preAction( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModelBeforeChange )
- throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL preActionWithArguments(
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModelBeforeChange,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
- throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL postAction( const ::rtl::OUString& aUndoText )
- throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL cancelAction()
- throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL cancelActionWithUndo( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModelToRestore )
- throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL undo( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xCurrentModel )
- throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL redo( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xCurrentModel )
- throw (::com::sun::star::uno::RuntimeException);
- virtual ::sal_Bool SAL_CALL undoPossible()
- throw (::com::sun::star::uno::RuntimeException);
- virtual ::sal_Bool SAL_CALL redoPossible()
- throw (::com::sun::star::uno::RuntimeException);
- virtual ::rtl::OUString SAL_CALL getCurrentUndoString()
- throw (::com::sun::star::uno::RuntimeException);
- virtual ::rtl::OUString SAL_CALL getCurrentRedoString()
- throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoStrings()
- throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoStrings()
- throw (::com::sun::star::uno::RuntimeException);
-
- // ____ XUndoHelper ____
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SAL_CALL getModelCloneForUndo(
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModelBeforeChange )
- throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL applyModelContent(
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModelToChange,
- const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModelToCopyFrom )
- throw (::com::sun::star::uno::RuntimeException);
-
-private:
- void retrieveConfigUndoSteps();
- void fireModifyEvent();
- void impl_undoRedo(
- ::com::sun::star::uno::Reference<
- ::com::sun::star::frame::XModel > & xCurrentModel,
- impl::UndoStack * pStackToRemoveFrom,
- impl::UndoStack * pStackToAddTo,
- bool bUndo = true );
-
- ::std::auto_ptr< impl::UndoStack > m_apUndoStack;
- ::std::auto_ptr< impl::UndoStack > m_apRedoStack;
-
- impl::UndoElement * m_pLastRemeberedUndoElement;
-
- ::std::auto_ptr< impl::UndoStepsConfigItem > m_apUndoStepsConfigItem;
- sal_Int32 m_nMaxNumberOfUndos;
- ::com::sun::star::uno::Reference<
- ::com::sun::star::util::XModifyBroadcaster > m_xModifyBroadcaster;
- // pointer is valid as long as m_xModifyBroadcaster.is()
- impl::ModifyBroadcaster * m_pModifyBroadcaster;
-};
-
-} // namespace chart
-
-// CHART2_UNDOMANAGER_HXX
-#endif
diff --git a/chart2/source/inc/servicenames.hxx b/chart2/source/inc/servicenames.hxx
index d1af0edb3335..43de8c3485d8 100644
--- a/chart2/source/inc/servicenames.hxx
+++ b/chart2/source/inc/servicenames.hxx
@@ -62,8 +62,6 @@ namespace chart
#define CHART_RENDERER_SERVICE_IMPLEMENTATION_NAME ::rtl::OUString::createFromAscii("com.sun.star.comp.chart2.ChartRenderer")
-#define CHART_UNDOMANAGER_SERVICE_NAME ::rtl::OUString::createFromAscii( "com.sun.star.chart2.UndoManager" )
-
//.............................................................................
} //namespace chart
//.............................................................................
diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx
index 95bc1315ad51..78cb87eeca85 100755
--- a/chart2/source/model/main/ChartModel.cxx
+++ b/chart2/source/model/main/ChartModel.cxx
@@ -42,6 +42,7 @@
#include "PageBackground.hxx"
#include "CloneHelper.hxx"
#include "NameContainer.hxx"
+#include "UndoManager.hxx"
#include <com/sun/star/chart/ChartDataRowSource.hpp>
@@ -73,6 +74,7 @@
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::Any;
using ::rtl::OUString;
using ::osl::MutexGuard;
@@ -103,6 +105,7 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
, m_bModified( sal_False )
, m_nInLoad(0)
, m_bUpdateNotificationsPending(false)
+ , m_pUndoManager( NULL )
, m_aControllers( m_aModelMutex )
, m_nControllerLockCount(0)
, m_xContext( xContext )
@@ -114,14 +117,21 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext)
C2U( "com.sun.star.xml.NamespaceMap" ), C2U( "com.sun.star.comp.chart.XMLNameSpaceMap" ) ), uno::UNO_QUERY)
{
OSL_TRACE( "ChartModel: CTOR called" );
- osl_incrementInterlockedCount(&m_refCount);
- ModifyListenerHelper::addListener( m_xPageBackground, this );
- m_xChartTypeManager.set( xContext->getServiceManager()->createInstanceWithContext(
- C2U( "com.sun.star.chart2.ChartTypeManager" ), m_xContext ), uno::UNO_QUERY );
- m_xUndoManager = Reference< chart2::XUndoManager >(
- this->createInstance( CHART_UNDOMANAGER_SERVICE_NAME ), uno::UNO_QUERY );
+ osl_incrementInterlockedCount(&m_refCount);
+ {
+ m_xOldModelAgg.set(
+ m_xContext->getServiceManager()->createInstanceWithContext(
+ CHART_CHARTAPIWRAPPER_SERVICE_NAME,
+ m_xContext ), uno::UNO_QUERY_THROW );
+ m_xOldModelAgg->setDelegator( *this );
+ }
+ {
+ ModifyListenerHelper::addListener( m_xPageBackground, this );
+ m_xChartTypeManager.set( xContext->getServiceManager()->createInstanceWithContext(
+ C2U( "com.sun.star.chart2.ChartTypeManager" ), m_xContext ), uno::UNO_QUERY );
+ }
osl_decrementInterlockedCount(&m_refCount);
}
@@ -145,33 +155,39 @@ ChartModel::ChartModel( const ChartModel & rOther )
, m_aGraphicObjectVector( rOther.m_aGraphicObjectVector )
, m_xDataProvider( rOther.m_xDataProvider )
, m_xInternalDataProvider( rOther.m_xInternalDataProvider )
- , m_xUndoManager( rOther.m_xUndoManager )
{
OSL_TRACE( "ChartModel: Copy-CTOR called" );
- osl_incrementInterlockedCount(&m_refCount);
-
- Reference< util::XModifyListener > xListener;
- Reference< chart2::XTitle > xNewTitle = CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle );
- Reference< chart2::XDiagram > xNewDiagram = CreateRefClone< Reference< chart2::XDiagram > >()( rOther.m_xDiagram );
- Reference< beans::XPropertySet > xNewPageBackground = CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xPageBackground );
- Reference< chart2::XChartTypeManager > xChartTypeManager = CreateRefClone< Reference< chart2::XChartTypeManager > >()( rOther.m_xChartTypeManager );
- Reference< container::XNameAccess > xXMLNamespaceMap = CreateRefClone< Reference< container::XNameAccess > >()( rOther.m_xXMLNamespaceMap );
+ osl_incrementInterlockedCount(&m_refCount);
{
- MutexGuard aGuard( m_aModelMutex );
- xListener = this;
- m_xTitle = xNewTitle;
- m_xDiagram = xNewDiagram;
- m_xPageBackground = xNewPageBackground;
- m_xChartTypeManager = xChartTypeManager;
- m_xXMLNamespaceMap = xXMLNamespaceMap;
- }
+ m_xOldModelAgg.set(
+ m_xContext->getServiceManager()->createInstanceWithContext(
+ CHART_CHARTAPIWRAPPER_SERVICE_NAME,
+ m_xContext ), uno::UNO_QUERY_THROW );
+ m_xOldModelAgg->setDelegator( *this );
+
+ Reference< util::XModifyListener > xListener;
+ Reference< chart2::XTitle > xNewTitle = CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle );
+ Reference< chart2::XDiagram > xNewDiagram = CreateRefClone< Reference< chart2::XDiagram > >()( rOther.m_xDiagram );
+ Reference< beans::XPropertySet > xNewPageBackground = CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xPageBackground );
+ Reference< chart2::XChartTypeManager > xChartTypeManager = CreateRefClone< Reference< chart2::XChartTypeManager > >()( rOther.m_xChartTypeManager );
+ Reference< container::XNameAccess > xXMLNamespaceMap = CreateRefClone< Reference< container::XNameAccess > >()( rOther.m_xXMLNamespaceMap );
- ModifyListenerHelper::addListener( xNewTitle, xListener );
- ModifyListenerHelper::addListener( xNewDiagram, xListener );
- ModifyListenerHelper::addListener( xNewPageBackground, xListener );
- xListener.clear();
+ {
+ MutexGuard aGuard( m_aModelMutex );
+ xListener = this;
+ m_xTitle = xNewTitle;
+ m_xDiagram = xNewDiagram;
+ m_xPageBackground = xNewPageBackground;
+ m_xChartTypeManager = xChartTypeManager;
+ m_xXMLNamespaceMap = xXMLNamespaceMap;
+ }
+ ModifyListenerHelper::addListener( xNewTitle, xListener );
+ ModifyListenerHelper::addListener( xNewDiagram, xListener );
+ ModifyListenerHelper::addListener( xNewPageBackground, xListener );
+ xListener.clear();
+ }
osl_decrementInterlockedCount(&m_refCount);
}
@@ -179,7 +195,7 @@ ChartModel::~ChartModel()
{
OSL_TRACE( "ChartModel: DTOR called" );
if( m_xOldModelAgg.is())
- m_xOldModelAgg->setDelegator( 0 );
+ m_xOldModelAgg->setDelegator( NULL );
}
void SAL_CALL ChartModel::initialize( const Sequence< Any >& /*rArguments*/ )
@@ -518,6 +534,8 @@ uno::Reference< uno::XInterface > SAL_CALL ChartModel::getCurrentSelection() thr
//-----------------------------------------------------------------
void SAL_CALL ChartModel::dispose() throw(uno::RuntimeException)
{
+ Reference< XInterface > xKeepAlive( *this );
+
//This object should release all resources and references in the
//easiest possible manner
//This object must notify all registered listeners using the method
@@ -530,6 +548,9 @@ void SAL_CALL ChartModel::dispose() throw(uno::RuntimeException)
//--release all resources and references
//// @todo
+ if ( m_xDiagram.is() )
+ ModifyListenerHelper::removeListener( m_xDiagram, this );
+
m_xDataProvider.clear();
m_xInternalDataProvider.clear();
m_xNumberFormatsSupplier.clear();
@@ -540,26 +561,17 @@ void SAL_CALL ChartModel::dispose() throw(uno::RuntimeException)
DisposeHelper::DisposeAndClear( m_xPageBackground );
DisposeHelper::DisposeAndClear( m_xXMLNamespaceMap );
- // not owner of storage
-// if( m_xStorage.is())
-// {
-// Reference< lang::XComponent > xComp( m_xStorage, uno::UNO_QUERY );
-// if( xComp.is())
-// xComp->dispose();
-// }
m_xStorage.clear();
+ // just clear, don't dispose - we're not the owner
- if( m_xOldModelAgg.is())
- {
- m_xOldModelAgg->setDelegator( 0 );
- m_xOldModelAgg.clear();
- }
+ if ( m_pUndoManager.is() )
+ m_pUndoManager->disposing();
+ m_pUndoManager.clear();
+ // that's important, since the UndoManager implementation delegates its ref counting to ourself.
m_aControllers.disposeAndClear( lang::EventObject( static_cast< cppu::OWeakObject * >( this )));
m_xCurrentController.clear();
- m_xStorage.clear();
- m_xParent.clear();
DisposeHelper::DisposeAndClear( m_xRangeHighlighter );
OSL_TRACE( "ChartModel: dispose() called" );
}
@@ -689,6 +701,7 @@ uno::Sequence< uno::Type > SAL_CALL ChartModel::getTypes()
uno::Reference< document::XDocumentProperties > SAL_CALL
ChartModel::getDocumentProperties() throw (uno::RuntimeException)
{
+ ::osl::MutexGuard aGuard( m_aModelMutex );
if ( !m_xDocumentProperties.is() )
{
uno::Reference< document::XDocumentProperties > xDocProps(
@@ -700,6 +713,17 @@ uno::Reference< document::XDocumentProperties > SAL_CALL
}
//-----------------------------------------------------------------
+// document::XDocumentPropertiesSupplier
+//-----------------------------------------------------------------
+Reference< document::XUndoManager > SAL_CALL ChartModel::getUndoManager( ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aModelMutex );
+ if ( !m_pUndoManager.is() )
+ m_pUndoManager.set( new UndoManager( *this, m_aModelMutex ) );
+ return m_pUndoManager.get();
+}
+
+//-----------------------------------------------------------------
// chart2::XChartDocument
//-----------------------------------------------------------------
@@ -1001,18 +1025,6 @@ void SAL_CALL ChartModel::setTitleObject( const uno::Reference< chart2::XTitle >
setModified( sal_True );
}
-void ChartModel::impl_createOldModelAgg()
-{
- if( ! m_xOldModelAgg.is())
- {
- m_xOldModelAgg.set(
- m_xContext->getServiceManager()->createInstanceWithContext(
- CHART_CHARTAPIWRAPPER_SERVICE_NAME,
- m_xContext ), uno::UNO_QUERY_THROW );
- m_xOldModelAgg->setDelegator( static_cast< ::cppu::OWeakObject* >( this ));
- }
-}
-
// ____ XInterface (for old API wrapper) ____
uno::Any SAL_CALL ChartModel::queryInterface( const uno::Type& aType )
throw (uno::RuntimeException)
@@ -1024,7 +1036,6 @@ uno::Any SAL_CALL ChartModel::queryInterface( const uno::Type& aType )
// try old API wrapper
try
{
- impl_createOldModelAgg();
if( m_xOldModelAgg.is())
aResult = m_xOldModelAgg->queryAggregation( aType );
}
@@ -1263,7 +1274,6 @@ Reference< uno::XInterface > SAL_CALL ChartModel::createInstance( const OUString
}
else
{
- impl_createOldModelAgg();
if( m_xOldModelAgg.is() )
{
Any aAny = m_xOldModelAgg->queryAggregation( ::getCppuType((const uno::Reference< lang::XMultiServiceFactory >*)0) );
@@ -1291,7 +1301,6 @@ Sequence< OUString > SAL_CALL ChartModel::getAvailableServiceNames()
{
uno::Sequence< ::rtl::OUString > aResult;
- impl_createOldModelAgg();
if( m_xOldModelAgg.is())
{
Any aAny = m_xOldModelAgg->queryAggregation( ::getCppuType((const uno::Reference< lang::XMultiServiceFactory >*)0) );
@@ -1368,13 +1377,6 @@ void SAL_CALL ChartModel::setParent( const Reference< uno::XInterface >& Parent
m_xParent.set( Parent, uno::UNO_QUERY );
}
-// ____ XUndoManager ____
-Reference< chart2::XUndoManager > SAL_CALL ChartModel::getUndoManager()
- throw (uno::RuntimeException)
-{
- return m_xUndoManager;
-}
-
// ____ XDataSource ____
uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > SAL_CALL ChartModel::getDataSequences()
throw (uno::RuntimeException)
diff --git a/chart2/source/model/main/ChartModel.hxx b/chart2/source/model/main/ChartModel.hxx
index 190d4f597c94..2cec0ec9f73c 100755
--- a/chart2/source/model/main/ChartModel.hxx
+++ b/chart2/source/model/main/ChartModel.hxx
@@ -35,6 +35,7 @@
#include <com/sun/star/util/XModifiable.hpp>
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/document/XUndoManagerSupplier.hpp>
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -46,7 +47,6 @@
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
#include <com/sun/star/container/XChild.hpp>
-#include <com/sun/star/chart2/XUndoSupplier.hpp>
#include <com/sun/star/chart2/data/XDataSource.hpp>
#include <com/sun/star/chart2/XChartTypeTemplate.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
@@ -69,6 +69,7 @@
#include "comphelper/implbase_var.hxx"
#endif
#include <osl/mutex.hxx>
+#include <rtl/ref.hxx>
#include <cppuhelper/interfacecontainer.hxx>
#include <svtools/grfmgr.hxx>
@@ -78,8 +79,6 @@
class SvNumberFormatter;
//=============================================================================
-/** this is an example implementation for the service ::com::sun::star::document::OfficeDocument
-*/
namespace chart
{
@@ -112,13 +111,15 @@ typedef ::comphelper::WeakImplHelper21<
,::com::sun::star::container::XChild
,::com::sun::star::util::XModifyListener
,::com::sun::star::datatransfer::XTransferable
- ,::com::sun::star::chart2::XUndoSupplier
,::com::sun::star::document::XDocumentPropertiesSupplier
,::com::sun::star::chart2::data::XDataSource
+ ,::com::sun::star::document::XUndoManagerSupplier
>
ChartModel_Base;
}
+class UndoManager;
+
class ChartModel : public impl::ChartModel_Base
{
@@ -134,6 +135,7 @@ private:
::rtl::OUString m_aResource;
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_aMediaDescriptor;
::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentProperties > m_xDocumentProperties;
+ ::rtl::Reference< UndoManager > m_pUndoManager;
::cppu::OInterfaceContainerHelper m_aControllers;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xCurrentController;
@@ -176,8 +178,6 @@ private:
bool m_bIsDisposed;
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
m_xPageBackground;
- ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager >
- m_xUndoManager;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xXMLNamespaceMap;
@@ -208,7 +208,6 @@ private:
void impl_killInternalData() throw( com::sun::star::util::CloseVetoException );
- void impl_createOldModelAgg();
void impl_store(
const ::com::sun::star::uno::Sequence<
::com::sun::star::beans::PropertyValue >& rMediaDescriptor,
@@ -439,6 +438,10 @@ public:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentProperties > SAL_CALL
getDocumentProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ // ____ document::XUndoManagerSupplier ____
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > SAL_CALL
+ getUndoManager( ) throw (::com::sun::star::uno::RuntimeException);
+
//-----------------------------------------------------------------
// ::com::sun::star::chart2::XChartDocument
//-----------------------------------------------------------------
@@ -606,10 +609,6 @@ public:
throw (::com::sun::star::lang::NoSupportException,
::com::sun::star::uno::RuntimeException);
- // ____ XUndoSupplier ____
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > SAL_CALL getUndoManager()
- throw (::com::sun::star::uno::RuntimeException);
-
// ____ XDataSource ____ allows access to the curently used data and data ranges
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences()
throw (::com::sun::star::uno::RuntimeException);
diff --git a/chart2/source/model/main/UndoManager.cxx b/chart2/source/model/main/UndoManager.cxx
new file mode 100755
index 000000000000..702dd2e5ab54
--- /dev/null
+++ b/chart2/source/model/main/UndoManager.cxx
@@ -0,0 +1,427 @@
+/*************************************************************************
+ * 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 "UndoManager.hxx"
+#include "ChartViewHelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/DisposedException.hpp>
+/** === end UNO includes === **/
+
+#include <framework/undomanagerhelper.hxx>
+#include <svl/undo.hxx>
+#include <unotools/undoopt.hxx>
+
+//......................................................................................................................
+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::lang::DisposedException;
+ using ::com::sun::star::document::XUndoManager;
+ using ::com::sun::star::document::EmptyUndoStackException;
+ using ::com::sun::star::document::UndoContextNotClosedException;
+ using ::com::sun::star::document::UndoFailedException;
+ using ::com::sun::star::util::InvalidStateException;
+ using ::com::sun::star::document::XUndoAction;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::document::XUndoManagerListener;
+ using ::com::sun::star::util::NotLockedException;
+ using ::com::sun::star::lang::NoSupportException;
+ using ::com::sun::star::util::XModifyListener;
+ using ::com::sun::star::frame::XModel;
+ /** === end UNO using === **/
+
+ namespace impl
+ {
+ //==============================================================================================================
+ //= UndoManager_Impl
+ //==============================================================================================================
+ class UndoManager_Impl : public ::framework::IUndoManagerImplementation
+ {
+ public:
+ UndoManager_Impl( UndoManager& i_antiImpl, ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ :m_rAntiImpl( i_antiImpl )
+ ,m_rParent( i_parent )
+ ,m_rMutex( i_mutex )
+ ,m_bDisposed( false )
+ ,m_aUndoManager()
+ ,m_aUndoHelper( *this )
+ {
+ m_aUndoManager.SetMaxUndoActionCount( (USHORT)SvtUndoOptions().GetUndoCount() );
+ }
+
+ virtual ~UndoManager_Impl()
+ {
+ }
+
+ // .........................................................................................................
+ // IUndoManagerImplementation
+ virtual ::osl::Mutex& getMutex();
+ virtual ::svl::IUndoManager& getImplUndoManager();
+ virtual Reference< XUndoManager > getThis();
+
+ // .........................................................................................................
+ // attribute access
+ ::cppu::OWeakObject& getParent() { return m_rParent; }
+ ::framework::UndoManagerHelper& getUndoHelper() { return m_aUndoHelper; }
+
+ // .........................................................................................................
+ // public interface
+
+ /// is called when the owner of the UndoManager is being disposed
+ void disposing();
+
+ /// checks whether we're already disposed, throws a DisposedException if so
+ void checkDisposed_lck();
+
+ private:
+ UndoManager& m_rAntiImpl;
+ ::cppu::OWeakObject& m_rParent;
+ ::osl::Mutex& m_rMutex;
+ bool m_bDisposed;
+
+ SfxUndoManager m_aUndoManager;
+ ::framework::UndoManagerHelper m_aUndoHelper;
+ };
+
+ //--------------------------------------------------------------------------------------------------------------
+ ::osl::Mutex& UndoManager_Impl::getMutex()
+ {
+ return m_rMutex;
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ ::svl::IUndoManager& UndoManager_Impl::getImplUndoManager()
+ {
+ return m_aUndoManager;
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ Reference< XUndoManager > UndoManager_Impl::getThis()
+ {
+ return &m_rAntiImpl;
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ void UndoManager_Impl::disposing()
+ {
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ m_bDisposed = true;
+ }
+ m_aUndoHelper.disposing();
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ void UndoManager_Impl::checkDisposed_lck()
+ {
+ if ( m_bDisposed )
+ throw DisposedException( ::rtl::OUString(), getThis() );
+ }
+
+ //==============================================================================================================
+ //= UndoManagerMethodGuard
+ //==============================================================================================================
+ /** guard for public UNO methods of the UndoManager
+
+ The only purpose of this guard is to check for the instance being disposed already. Everything else,
+ in particular the IMutexGuard functionality required by the UndoManagerHelper class, is a dummy only,
+ as all involved classes (means we ourselves, the UndoManagerHelper, the SfxUndoManager, and the Undo actions
+ we create) are inherently thread-safe, thus need no external lock (in particular no SolarMutex!).
+ */
+ class UndoManagerMethodGuard : public ::framework::IMutexGuard
+ {
+ public:
+ UndoManagerMethodGuard( UndoManager_Impl& i_impl )
+ {
+ ::osl::MutexGuard aGuard( i_impl.getMutex() );
+ // throw if the instance is already disposed
+ i_impl.checkDisposed_lck();
+ }
+ virtual ~UndoManagerMethodGuard()
+ {
+ }
+
+ // IMutexGuard
+ virtual ::framework::IMutex& getGuardedMutex();
+
+ // IGuard
+ virtual void clear();
+ virtual void reset();
+ };
+
+ class DummyMutex : public ::framework::IMutex
+ {
+ public:
+ virtual void acquire() { }
+ virtual void release() { }
+ };
+
+ //--------------------------------------------------------------------------------------------------------------
+ ::framework::IMutex& UndoManagerMethodGuard::getGuardedMutex()
+ {
+ static DummyMutex s_aDummyMutex;
+ return s_aDummyMutex;
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ void UndoManagerMethodGuard::clear()
+ {
+ // nothing to do. This interface implementation is a dummy.
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ void UndoManagerMethodGuard::reset()
+ {
+ // nothing to do. This interface implementation is a dummy.
+ }
+ }
+
+ //==================================================================================================================
+ //= UndoManager
+ //==================================================================================================================
+ using impl::UndoManagerMethodGuard;
+
+ //------------------------------------------------------------------------------------------------------------------
+ UndoManager::UndoManager( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex )
+ :m_pImpl( new impl::UndoManager_Impl( *this, i_parent, i_mutex ) )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ UndoManager::~UndoManager()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::acquire() throw ()
+ {
+ m_pImpl->getParent().acquire();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::release() throw ()
+ {
+ m_pImpl->getParent().release();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void UndoManager::disposing()
+ {
+ m_pImpl->disposing();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::enterUndoContext( const ::rtl::OUString& i_title ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().enterUndoContext( i_title, aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::enterHiddenUndoContext( ) throw (EmptyUndoStackException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().enterHiddenUndoContext( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::leaveUndoContext( ) throw (InvalidStateException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().leaveUndoContext( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::addUndoAction( const Reference< XUndoAction >& i_action ) throw (IllegalArgumentException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().addUndoAction( i_action, aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::undo( ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().undo( aGuard );
+
+ ChartViewHelper::setViewToDirtyState( Reference< XModel >( getParent(), UNO_QUERY ) );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::redo( ) throw (EmptyUndoStackException, UndoContextNotClosedException, UndoFailedException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().redo( aGuard );
+
+ ChartViewHelper::setViewToDirtyState( Reference< XModel >( getParent(), UNO_QUERY ) );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL UndoManager::isUndoPossible( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().isUndoPossible();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL UndoManager::isRedoPossible( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().isRedoPossible();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL UndoManager::getCurrentUndoActionTitle( ) throw (EmptyUndoStackException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().getCurrentUndoActionTitle();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL UndoManager::getCurrentRedoActionTitle( ) throw (EmptyUndoStackException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().getCurrentRedoActionTitle();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL UndoManager::getAllUndoActionTitles( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().getAllUndoActionTitles();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL UndoManager::getAllRedoActionTitles( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().getAllRedoActionTitles();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::clear( ) throw (UndoContextNotClosedException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().clear( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::clearRedo( ) throw (UndoContextNotClosedException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().clearRedo( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::reset( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().reset( aGuard );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::addUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().addUndoManagerListener( i_listener );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::removeUndoManagerListener( const Reference< XUndoManagerListener >& i_listener ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().removeUndoManagerListener( i_listener );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::lock( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().lock();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::unlock( ) throw (NotLockedException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().unlock();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL UndoManager::isLocked( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return m_pImpl->getUndoHelper().isLocked();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL UndoManager::getParent( ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ return *&m_pImpl->getParent();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::setParent( const Reference< XInterface >& i_parent ) throw (NoSupportException, RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ (void)i_parent;
+ throw NoSupportException( ::rtl::OUString(), m_pImpl->getThis() );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::addModifyListener( const Reference< XModifyListener >& i_listener ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().addModifyListener( i_listener );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL UndoManager::removeModifyListener( const Reference< XModifyListener >& i_listener ) throw (RuntimeException)
+ {
+ UndoManagerMethodGuard aGuard( *m_pImpl );
+ m_pImpl->getUndoHelper().removeModifyListener( i_listener );
+ }
+
+//......................................................................................................................
+} // namespace chart
+//......................................................................................................................
diff --git a/chart2/source/model/main/UndoManager.hxx b/chart2/source/model/main/UndoManager.hxx
new file mode 100755
index 000000000000..07091207ebd0
--- /dev/null
+++ b/chart2/source/model/main/UndoManager.hxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ * 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_UNDOMANAGER_HXX
+#define CHART2_UNDOMANAGER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/document/XUndoManager.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
+#include <com/sun/star/container/XChild.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase2.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+//......................................................................................................................
+namespace chart
+{
+//......................................................................................................................
+
+ namespace impl
+ {
+ class UndoManager_Impl;
+ typedef ::cppu::ImplHelper2 < ::com::sun::star::document::XUndoManager
+ , ::com::sun::star::util::XModifyBroadcaster
+ > UndoManager_Base;
+ }
+
+ //==================================================================================================================
+ //= UndoManager
+ //==================================================================================================================
+ class UndoManager : public impl::UndoManager_Base
+ {
+ public:
+ UndoManager( ::cppu::OWeakObject& i_parent, ::osl::Mutex& i_mutex );
+ virtual ~UndoManager();
+
+ // XInterface
+ virtual void SAL_CALL acquire( ) throw ();
+ virtual void SAL_CALL release( ) throw ();
+
+ // XComponent equivalents
+ void disposing();
+
+ // XUndoManager
+ virtual void SAL_CALL enterUndoContext( const ::rtl::OUString& i_title ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL enterHiddenUndoContext( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL leaveUndoContext( ) throw (::com::sun::star::util::InvalidStateException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addUndoAction( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoAction >& i_action ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL undo( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL redo( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isUndoPossible( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isRedoPossible( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCurrentUndoActionTitle( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCurrentRedoActionTitle( ) throw (::com::sun::star::document::EmptyUndoStackException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllUndoActionTitles( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllRedoActionTitles( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clear( ) throw (::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearRedo( ) throw (::com::sun::star::document::UndoContextNotClosedException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL reset( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeUndoManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManagerListener >& i_listener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XLockable (base of XUndoManager)
+ virtual void SAL_CALL lock( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL unlock( ) throw (::com::sun::star::util::NotLockedException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isLocked( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XChild (base of XUndoManager)
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
+
+ // XModifyBroadcaster
+ virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ ::boost::scoped_ptr< impl::UndoManager_Impl > m_pImpl;
+ };
+
+//......................................................................................................................
+} // namespace chart
+//......................................................................................................................
+
+#endif // CHART2_UNDOMANAGER_HXX
diff --git a/chart2/source/model/main/makefile.mk b/chart2/source/model/main/makefile.mk
index 8e963dfa0f5c..5ca78bbdea25 100644
--- a/chart2/source/model/main/makefile.mk
+++ b/chart2/source/model/main/makefile.mk
@@ -60,6 +60,7 @@ SLOFILES= \
$(SLO)$/StockBar.obj \
$(SLO)$/Title.obj \
$(SLO)$/Wall.obj \
+ $(SLO)$/UndoManager.obj \
$(SLO)$/_serviceregistration_model.obj
# --- Targets -----------------------------------------------------------------
diff --git a/chart2/source/model/makefile.mk b/chart2/source/model/makefile.mk
index 52cc85c10904..25d4b1b2949a 100644
--- a/chart2/source/model/makefile.mk
+++ b/chart2/source/model/makefile.mk
@@ -79,7 +79,8 @@ SHL1STDLIBS= $(CHARTTOOLS) \
$(SVLLIB) \
$(SVTOOLLIB) \
$(SALLIB) \
- $(UCBHELPERLIB)
+ $(UCBHELPERLIB) \
+ $(FWELIB) \
#--------exports
diff --git a/chart2/source/tools/ResId.cxx b/chart2/source/tools/ResId.cxx
index 0d6e35974aaa..b7d4c725d367 100644..100755
--- a/chart2/source/tools/ResId.cxx
+++ b/chart2/source/tools/ResId.cxx
@@ -41,7 +41,7 @@ SchResId::SchResId( sal_Int16 nId )
::rtl::OUString SchResId::getResString( sal_Int16 nId )
{
- return ::rtl::OUString( String( SchResId( nId )));
+ return String( SchResId( nId ));
}
} // namespace chart