Kaydet (Commit) 2f09474e authored tarafından Frank Schoenheit [fs]'s avatar Frank Schoenheit [fs]

undoapi: some cleanups after the previos refactoring (more to come)

üst fa0b1d6e
...@@ -463,6 +463,10 @@ String STR_ACTION_NOTPOSSIBLE ...@@ -463,6 +463,10 @@ String STR_ACTION_NOTPOSSIBLE
{ {
Text [ en-US ] = "This function cannot be completed with the selected objects." ; 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 String STR_COLUMN_LABEL
{ {
......
...@@ -616,7 +616,7 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent ...@@ -616,7 +616,7 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent
m_pChartWindow->Invalidate(); m_pChartWindow->Invalidate();
uno::Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW ); uno::Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW );
m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW );
return sal_True; return sal_True;
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "precompiled_chart2.hxx" #include "precompiled_chart2.hxx"
#include "ChartController.hxx" #include "ChartController.hxx"
#include "ResId.hxx"
#include "UndoGuard.hxx" #include "UndoGuard.hxx"
#include "DrawViewWrapper.hxx" #include "DrawViewWrapper.hxx"
#include "ChartWindow.hxx" #include "ChartWindow.hxx"
...@@ -37,6 +38,7 @@ ...@@ -37,6 +38,7 @@
#include "macros.hxx" #include "macros.hxx"
#include "ControllerLockGuard.hxx" #include "ControllerLockGuard.hxx"
#include "AccessibleTextHelper.hxx" #include "AccessibleTextHelper.hxx"
#include "Strings.hrc"
#include "chartview/DrawModelWrapper.hxx" #include "chartview/DrawModelWrapper.hxx"
#include <svx/svdotext.hxx> #include <svx/svdotext.hxx>
...@@ -82,7 +84,8 @@ void ChartController::StartTextEdit( const Point* pMousePixel ) ...@@ -82,7 +84,8 @@ void ChartController::StartTextEdit( const Point* pMousePixel )
return; return;
OSL_PRECOND( !m_pTextActionUndoGuard.get(), "ChartController::StartTextEdit: already have a TextUndoGuard!?" ); OSL_PRECOND( !m_pTextActionUndoGuard.get(), "ChartController::StartTextEdit: already have a TextUndoGuard!?" );
m_pTextActionUndoGuard.reset( new UndoGuard( C2U( "Text Edit" ), m_xUndoManager ) ); m_pTextActionUndoGuard.reset( new UndoGuard(
String( SchResId( STR_ACTION_EDIT_TEXT ) ), m_xUndoManager ) );
SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner();
//pOutliner->SetRefDevice(m_pChartWindow); //pOutliner->SetRefDevice(m_pChartWindow);
//pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)pStyleSheetPool); //pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)pStyleSheetPool);
......
This diff is collapsed.
/*************************************************************************
* 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
...@@ -31,17 +31,11 @@ ...@@ -31,17 +31,11 @@
#include "ImplDocumentActions.hxx" #include "ImplDocumentActions.hxx"
#include "DisposeHelper.hxx" #include "DisposeHelper.hxx"
#include "CommonFunctors.hxx" #include "CommonFunctors.hxx"
#include "ControllerLockGuard.hxx"
#include "PropertyHelper.hxx" #include "PropertyHelper.hxx"
#include "DataSourceHelper.hxx" #include "ChartModelClone.hxx"
#include "ChartModelHelper.hxx"
#include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
#include <com/sun/star/chart2/XChartDocument.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/XCloneable.hpp>
#include <com/sun/star/util/XModifiable.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/DisposedException.hpp>
...@@ -78,212 +72,9 @@ namespace impl ...@@ -78,212 +72,9 @@ namespace impl
using ::com::sun::star::lang::DisposedException; using ::com::sun::star::lang::DisposedException;
using ::com::sun::star::view::XSelectionSupplier; using ::com::sun::star::view::XSelectionSupplier;
using ::com::sun::star::chart2::XChartDocument; using ::com::sun::star::chart2::XChartDocument;
using ::com::sun::star::chart::XComplexDescriptionAccess;
using ::com::sun::star::chart2::XTitled;
using ::com::sun::star::chart2::XInternalDataProvider;
using ::com::sun::star::util::XModifiable;
using ::com::sun::star::document::UndoFailedException; using ::com::sun::star::document::UndoFailedException;
/** === end UNO using === **/ /** === end UNO using === **/
// =====================================================================================================================
// = helper
// =====================================================================================================================
namespace
{
Reference< XModel > lcl_cloneModel( const Reference< XModel > & xModel )
{
Reference< XModel > xResult;
try
{
const Reference< XCloneable > xCloneable( xModel, UNO_QUERY_THROW );
xResult.set( xCloneable->createClone(), UNO_QUERY_THROW );
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
return xResult;
}
}
// =====================================================================================================================
// = ChartModelClone
// =====================================================================================================================
// ---------------------------------------------------------------------------------------------------------------------
ChartModelClone::ChartModelClone( const Reference< XModel >& i_model, const ModelFacet i_facet )
{
m_xModelClone.set( lcl_cloneModel( i_model ) );
try
{
if ( i_facet == E_MODEL_WITH_DATA )
{
const Reference< XChartDocument > xChartDoc( m_xModelClone, UNO_QUERY_THROW );
ENSURE_OR_THROW( xChartDoc->hasInternalDataProvider(), "invalid chart model" );
const Reference< XCloneable > xCloneable( xChartDoc->getDataProvider(), UNO_QUERY_THROW );
m_xDataClone.set( xCloneable->createClone(), UNO_QUERY_THROW );
}
if ( i_facet == E_MODEL_WITH_SELECTION )
{
const Reference< XSelectionSupplier > xSelSupp( m_xModelClone->getCurrentController(), UNO_QUERY_THROW );
m_aSelection = xSelSupp->getSelection();
}
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
}
// ---------------------------------------------------------------------------------------------------------------------
ChartModelClone::~ChartModelClone()
{
if ( !impl_isDisposed() )
dispose();
}
// ---------------------------------------------------------------------------------------------------------------------
void ChartModelClone::dispose()
{
if ( impl_isDisposed() )
return;
try
{
Reference< XComponent > xComp( m_xModelClone, UNO_QUERY_THROW );
xComp->dispose();
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
m_xModelClone.clear();
m_xDataClone.clear();
m_aSelection.clear();
}
// ---------------------------------------------------------------------------------------------------------------------
ModelFacet ChartModelClone::getFacet() const
{
if ( m_aSelection.hasValue() )
return E_MODEL_WITH_SELECTION;
if ( m_xDataClone.is() )
return E_MODEL_WITH_DATA;
return E_MODEL;
}
// ---------------------------------------------------------------------------------------------------------------------
void ChartModelClone::applyToModel( const Reference< XModel >& i_model ) const
{
applyModelContentToModel( i_model, m_xModelClone, m_xDataClone );
if ( m_aSelection.hasValue() )
{
try
{
Reference< XSelectionSupplier > xCurrentSelectionSuppl( i_model->getCurrentController(), UNO_QUERY_THROW );
xCurrentSelectionSuppl->select( m_aSelection );
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
}
}
// ---------------------------------------------------------------------------------------------------------------------
namespace
{
void ImplApplyDataToModel( const Reference< XModel >& i_model, const Reference< XInternalDataProvider > & i_data )
{
Reference< XChartDocument > xDoc( i_model, UNO_QUERY );
OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider() );
// copy data from stored internal data provider
if( xDoc.is() && xDoc->hasInternalDataProvider())
{
Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), UNO_QUERY );
Reference< XComplexDescriptionAccess > xSavedData( i_data, UNO_QUERY );
if ( xCurrentData.is() && xSavedData.is() )
{
xCurrentData->setData( xSavedData->getData() );
xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions() );
xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions() );
}
}
}
}
// ---------------------------------------------------------------------------------------------------------------------
void ChartModelClone::applyModelContentToModel( const Reference< XModel >& i_model,
const Reference< XModel >& i_modelToCopyFrom, const Reference< XInternalDataProvider >& i_data )
{
ENSURE_OR_RETURN_VOID( i_model.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" );
ENSURE_OR_RETURN_VOID( i_modelToCopyFrom.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" );
try
{
// /-- loccked controllers of destination
ControllerLockGuard aLockedControllers( i_model );
Reference< XChartDocument > xSource( i_modelToCopyFrom, UNO_QUERY_THROW );
Reference< XChartDocument > xDestination( i_model, UNO_QUERY_THROW );
// propagate the correct flag for plotting of hidden values to the data provider and all used sequences
ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( i_modelToCopyFrom ) , i_model );
// diagram
xDestination->setFirstDiagram( xSource->getFirstDiagram() );
// main title
Reference< XTitled > xDestinationTitled( xDestination, UNO_QUERY_THROW );
Reference< XTitled > xSourceTitled( xSource, UNO_QUERY_THROW );
xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject() );
// page background
::comphelper::copyProperties(
xSource->getPageBackground(),
xDestination->getPageBackground() );
// apply data (not applied in standard Undo)
if ( i_data.is() )
ImplApplyDataToModel( i_model, i_data );
// register all sequences at the internal data provider to get adapted
// indexes when columns are added/removed
if ( xDestination->hasInternalDataProvider() )
{
Reference< XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), UNO_QUERY );
Reference< chart2::data::XDataSource > xUsedData( DataSourceHelper::getUsedData( i_model ) );
if ( xUsedData.is() && xNewDataProvider.is() )
{
Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xUsedData->getDataSequences() );
for( sal_Int32 i=0; i<aData.getLength(); ++i )
{
xNewDataProvider->registerDataSequenceForChanges( aData[i]->getValues() );
xNewDataProvider->registerDataSequenceForChanges( aData[i]->getLabel() );
}
}
}
// restore modify status
Reference< XModifiable > xSourceMod( xSource, UNO_QUERY );
Reference< XModifiable > xDestMod( xDestination, UNO_QUERY );
if ( xSourceMod.is() && xDestMod.is() && !xSourceMod->isModified() )
{
xDestMod->setModified( sal_False );
}
// \-- loccked controllers of destination
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
}
// --------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------
UndoElement::UndoElement( const OUString& i_actionString, const Reference< XModel >& i_documentModel, const ::boost::shared_ptr< ChartModelClone >& i_modelClone ) UndoElement::UndoElement( const OUString& i_actionString, const Reference< XModel >& i_documentModel, const ::boost::shared_ptr< ChartModelClone >& i_modelClone )
:UndoElement_MBase() :UndoElement_MBase()
......
...@@ -55,45 +55,10 @@ namespace chart2 { ...@@ -55,45 +55,10 @@ namespace chart2 {
namespace chart namespace chart
{ {
namespace impl class ChartModelClone;
{
enum ModelFacet
{
E_MODEL,
E_MODEL_WITH_DATA,
E_MODEL_WITH_SELECTION
};
class ChartModelClone : public ::boost::noncopyable namespace impl
{ {
public:
ChartModelClone(
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model,
const ModelFacet i_facet
);
~ChartModelClone();
ModelFacet getFacet() const;
void applyToModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model ) const;
static void applyModelContentToModel(
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_model,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_modelToCopyFrom,
const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & i_data );
void dispose();
private:
bool impl_isDisposed() const { return !m_xModelClone.is(); }
private:
::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModelClone;
::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > m_xDataClone;
::com::sun::star::uno::Any m_aSelection;
};
typedef ::cppu::BaseMutex UndoElement_MBase; typedef ::cppu::BaseMutex UndoElement_MBase;
typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > UndoElement_TBase; typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > UndoElement_TBase;
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "precompiled_chart2.hxx" #include "precompiled_chart2.hxx"
#include "UndoGuard.hxx" #include "UndoGuard.hxx"
#include "ChartModelClone.hxx"
#include "ImplDocumentActions.hxx" #include "ImplDocumentActions.hxx"
#include <com/sun/star/container/XChild.hpp> #include <com/sun/star/container/XChild.hpp>
...@@ -46,17 +47,20 @@ namespace chart ...@@ -46,17 +47,20 @@ namespace chart
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
UndoGuard_Base::UndoGuard_Base( const OUString& i_undoString, const uno::Reference< document::XUndoManager > & i_undoManager ) UndoGuard::UndoGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager > & i_undoManager,
const ModelFacet i_facet )
:m_xChartModel( i_undoManager->getParent(), uno::UNO_QUERY_THROW ) :m_xChartModel( i_undoManager->getParent(), uno::UNO_QUERY_THROW )
,m_xUndoManager( i_undoManager ) ,m_xUndoManager( i_undoManager )
,m_pDocumentSnapshot()
,m_aUndoString( i_undoString ) ,m_aUndoString( i_undoString )
,m_bActionPosted( false ) ,m_bActionPosted( false )
{ {
m_pDocumentSnapshot.reset( new ChartModelClone( m_xChartModel, i_facet ) );
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
UndoGuard_Base::~UndoGuard_Base() UndoGuard::~UndoGuard()
{ {
if ( !!m_pDocumentSnapshot ) if ( !!m_pDocumentSnapshot )
discardSnapshot(); discardSnapshot();
...@@ -64,7 +68,7 @@ UndoGuard_Base::~UndoGuard_Base() ...@@ -64,7 +68,7 @@ UndoGuard_Base::~UndoGuard_Base()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void UndoGuard_Base::commit() void UndoGuard::commit()
{ {
if ( !m_bActionPosted && !!m_pDocumentSnapshot && m_xUndoManager.is() ) if ( !m_bActionPosted && !!m_pDocumentSnapshot && m_xUndoManager.is() )
{ {
...@@ -77,7 +81,7 @@ void UndoGuard_Base::commit() ...@@ -77,7 +81,7 @@ void UndoGuard_Base::commit()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void UndoGuard_Base::rollback() void UndoGuard::rollback()
{ {
ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" ); ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" );
m_pDocumentSnapshot->applyToModel( m_xChartModel ); m_pDocumentSnapshot->applyToModel( m_xChartModel );
...@@ -85,19 +89,7 @@ void UndoGuard_Base::rollback() ...@@ -85,19 +89,7 @@ void UndoGuard_Base::rollback()
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void UndoGuard::discardSnapshot()
void UndoGuard_Base::takeSnapshot( bool i_withData, bool i_withSelection )
{
impl::ModelFacet eModelFacet( impl::E_MODEL );
if ( i_withData )
eModelFacet = impl::E_MODEL_WITH_DATA;
else if ( i_withSelection )
eModelFacet = impl::E_MODEL_WITH_SELECTION;
m_pDocumentSnapshot.reset( new impl::ChartModelClone( m_xChartModel, eModelFacet ) );
}
//-----------------------------------------------------------------------------
void UndoGuard_Base::discardSnapshot()
{ {
ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" ); ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" );
m_pDocumentSnapshot->dispose(); m_pDocumentSnapshot->dispose();
...@@ -106,23 +98,9 @@ void UndoGuard_Base::discardSnapshot() ...@@ -106,23 +98,9 @@ void UndoGuard_Base::discardSnapshot()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
UndoGuard::UndoGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
:UndoGuard_Base( i_undoString, i_undoManager )
{
takeSnapshot( false, false );
}
UndoGuard::~UndoGuard()
{
// nothing to do ... TODO: can this class be removed?
}
//-----------------------------------------------------------------------------
UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
:UndoGuard_Base( i_undoString, i_undoManager ) :UndoGuard( i_undoString, i_undoManager, E_MODEL )
{ {
takeSnapshot( false, false );
} }
UndoLiveUpdateGuard::~UndoLiveUpdateGuard() UndoLiveUpdateGuard::~UndoLiveUpdateGuard()
...@@ -135,9 +113,8 @@ UndoLiveUpdateGuard::~UndoLiveUpdateGuard() ...@@ -135,9 +113,8 @@ UndoLiveUpdateGuard::~UndoLiveUpdateGuard()
UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData( UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData(
const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
:UndoGuard_Base( i_undoString, i_undoManager ) :UndoGuard( i_undoString, i_undoManager, E_MODEL_WITH_DATA )
{ {
takeSnapshot( true, false );
} }
UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData() UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData()
...@@ -150,9 +127,8 @@ UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData() ...@@ -150,9 +127,8 @@ UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData()
UndoGuardWithSelection::UndoGuardWithSelection( UndoGuardWithSelection::UndoGuardWithSelection(
const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager )
:UndoGuard_Base( i_undoString, i_undoManager ) :UndoGuard( i_undoString, i_undoManager, E_MODEL_WITH_SELECTION )
{ {
takeSnapshot( false, true );
} }
UndoGuardWithSelection::~UndoGuardWithSelection() UndoGuardWithSelection::~UndoGuardWithSelection()
......
...@@ -73,10 +73,8 @@ SLOFILES = \ ...@@ -73,10 +73,8 @@ SLOFILES = \
$(SLO)$/ShapeController.obj \ $(SLO)$/ShapeController.obj \
$(SLO)$/ShapeToolbarController.obj \ $(SLO)$/ShapeToolbarController.obj \
$(SLO)$/ImplDocumentActions.obj \ $(SLO)$/ImplDocumentActions.obj \
$(SLO)$/UndoGuard.obj $(SLO)$/UndoGuard.obj \
$(SLO)$/ChartModelClone.obj \
# $(SLO)$/CommonConverters.obj \
# $(SLO)$/Scaling.obj \
# --- Targets ----------------------------------------------------------------- # --- Targets -----------------------------------------------------------------
......
...@@ -310,6 +310,7 @@ ...@@ -310,6 +310,7 @@
#define STR_ACTION_TOGGLE_GRID_HORZ (RID_APP_START + 86) #define STR_ACTION_TOGGLE_GRID_HORZ (RID_APP_START + 86)
#define STR_ACTION_SCALE_TEXT (RID_APP_START + 93) #define STR_ACTION_SCALE_TEXT (RID_APP_START + 93)
#define STR_ACTION_REARRANGE_CHART (RID_APP_START + 94) #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_CHOOSECOLOR (RID_APP_START + 233)
#define STR_TIP_LIGHTSOURCE_X (RID_APP_START + 234) #define STR_TIP_LIGHTSOURCE_X (RID_APP_START + 234)
......
...@@ -27,10 +27,11 @@ ...@@ -27,10 +27,11 @@
#ifndef CHART2_UNDOGUARD_HXX #ifndef CHART2_UNDOGUARD_HXX
#define CHART2_UNDOGUARD_HXX #define CHART2_UNDOGUARD_HXX
#include "ChartModelClone.hxx"
#include <com/sun/star/document/XUndoManager.hpp> #include <com/sun/star/document/XUndoManager.hpp>
#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XModel.hpp>
// header for class OUString
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
...@@ -38,28 +39,23 @@ ...@@ -38,28 +39,23 @@
namespace chart namespace chart
{ {
namespace impl /** 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 ChartModelClone; */
} class UndoGuard
/** Base Class for UndoGuard and UndoLiveUpdateGuard
*/
class UndoGuard_Base
{ {
public: public:
explicit UndoGuard_Base( explicit UndoGuard(
const ::rtl::OUString& i_undoMessage, const ::rtl::OUString& i_undoMessage,
const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager,
const ModelFacet i_facet = E_MODEL
); );
~UndoGuard_Base(); ~UndoGuard();
void commit(); void commit();
void rollback(); void rollback();
protected: protected:
void takeSnapshot( bool i_withData, bool i_withSelection );
bool isActionPosted() const { return m_bActionPosted; } bool isActionPosted() const { return m_bActionPosted; }
private: private:
...@@ -69,28 +65,15 @@ private: ...@@ -69,28 +65,15 @@ private:
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xChartModel; 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; const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager;
::boost::shared_ptr< impl::ChartModelClone > m_pDocumentSnapshot; ::boost::shared_ptr< ChartModelClone > m_pDocumentSnapshot;
rtl::OUString m_aUndoString; rtl::OUString m_aUndoString;
bool m_bActionPosted; bool m_bActionPosted;
};
/** 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 UndoGuard_Base
{
public:
explicit UndoGuard(
const ::rtl::OUString& i_undoMessage,
const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager
);
~UndoGuard();
}; };
/** A guard which, in its destructor, restores the model state it found in the constructor. If /** 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. <member>commitAction</member> is called inbetween, the restouration is not performed.
*/ */
class UndoLiveUpdateGuard : public UndoGuard_Base class UndoLiveUpdateGuard : public UndoGuard
{ {
public: public:
explicit UndoLiveUpdateGuard( explicit UndoLiveUpdateGuard(
...@@ -104,7 +87,7 @@ public: ...@@ -104,7 +87,7 @@ public:
Only use this if the data has internal data. Only use this if the data has internal data.
*/ */
class UndoLiveUpdateGuardWithData : class UndoLiveUpdateGuardWithData :
public UndoGuard_Base public UndoGuard
{ {
public: public:
explicit UndoLiveUpdateGuardWithData( explicit UndoLiveUpdateGuardWithData(
...@@ -114,7 +97,7 @@ public: ...@@ -114,7 +97,7 @@ public:
~UndoLiveUpdateGuardWithData(); ~UndoLiveUpdateGuardWithData();
}; };
class UndoGuardWithSelection : public UndoGuard_Base class UndoGuardWithSelection : public UndoGuard
{ {
public: public:
explicit UndoGuardWithSelection( explicit UndoGuardWithSelection(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment