25#include <com/sun/star/document/XUndoManager.hpp>
32using ::com::sun::star::uno::Reference;
37UndoGuard::UndoGuard( OUString i_undoString,
const uno::Reference< document::XUndoManager > & i_undoManager,
39 :m_xUndoManager( i_undoManager )
40 ,m_aUndoString(
std::move( i_undoString ))
41 ,m_bActionPosted( false )
43 m_xChartModel =
dynamic_cast<::chart::ChartModel*
>(i_undoManager->getParent().get());
44 assert(m_xChartModel);
45 m_pDocumentSnapshot = std::make_shared<ChartModelClone>( m_xChartModel, i_facet );
48UndoGuard::~UndoGuard()
50 if ( m_pDocumentSnapshot )
54void UndoGuard::commit()
56 if ( !m_bActionPosted && m_pDocumentSnapshot )
61 m_pDocumentSnapshot.reset();
62 m_xUndoManager->addUndoAction( xAction );
64 catch(
const uno::Exception& )
69 m_bActionPosted =
true;
72void UndoGuard::rollback()
75 m_pDocumentSnapshot->applyToModel( m_xChartModel );
79void UndoGuard::discardSnapshot()
82 m_pDocumentSnapshot->dispose();
83 m_pDocumentSnapshot.reset();
122 :m_xUndoManager( i_undoManager )
129 catch(
const uno::Exception& )
144 catch(
const uno::Exception& )
HiddenUndoContext(const css::uno::Reference< css::document::XUndoManager > &i_undoManager)
css::uno::Reference< css::document::XUndoManager > m_xUndoManager
UndoGuardWithSelection(const OUString &i_undoMessage, const css::uno::Reference< css::document::XUndoManager > &i_undoManager)
virtual ~UndoGuardWithSelection()
A guard which does nothing, unless you explicitly call commitAction.
bool isActionPosted() const
UndoGuard(OUString i_undoMessage, const css::uno::Reference< css::document::XUndoManager > &i_undoManager, const ModelFacet i_facet=E_MODEL)
~UndoLiveUpdateGuardWithData()
UndoLiveUpdateGuardWithData(const OUString &i_undoMessage, const css::uno::Reference< css::document::XUndoManager > &i_undoManager)
#define ENSURE_OR_THROW(c, m)
#define DBG_UNHANDLED_EXCEPTION(...)
#define ENSURE_OR_RETURN_VOID(c, m)