1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_UNDOGUARD_HXX
20 #define INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_UNDOGUARD_HXX
22 #include "ChartModelClone.hxx"
24 #include <rtl/ustring.hxx>
28 namespace com
{ namespace sun
{ namespace star
{ namespace document
{ class XUndoManager
; } } } }
29 namespace com
{ namespace sun
{ namespace star
{ namespace frame
{ class XModel
; } } } }
34 /** A guard which does nothing, unless you explicitly call commitAction. In particular, in its destructor, it
35 does neither auto-commit nor auto-rollback the model changes.
41 const OUString
& i_undoMessage
,
42 const css::uno::Reference
< css::document::XUndoManager
> & i_undoManager
,
43 const ModelFacet i_facet
= E_MODEL
51 bool isActionPosted() const { return m_bActionPosted
; }
54 void discardSnapshot();
57 const css::uno::Reference
< css::frame::XModel
> m_xChartModel
;
58 const css::uno::Reference
< css::document::XUndoManager
> m_xUndoManager
;
60 std::shared_ptr
< ChartModelClone
> m_pDocumentSnapshot
;
61 OUString m_aUndoString
;
65 /** A guard which, in its destructor, restores the model state it found in the constructor. If
66 <member>commitAction</member> is called inbetween, the restoration is not performed.
68 class UndoLiveUpdateGuard
: public UndoGuard
71 explicit UndoLiveUpdateGuard(
72 const OUString
& i_undoMessage
,
73 const css::uno::Reference
< css::document::XUndoManager
> & i_undoManager
75 ~UndoLiveUpdateGuard();
78 /** Same as UndoLiveUpdateGuard but with additional storage of the chart's data.
79 Only use this if the data has internal data.
81 class UndoLiveUpdateGuardWithData
:
85 explicit UndoLiveUpdateGuardWithData(
86 const OUString
& i_undoMessage
,
87 const css::uno::Reference
< css::document::XUndoManager
> & i_undoManager
89 ~UndoLiveUpdateGuardWithData();
92 class UndoGuardWithSelection
: public UndoGuard
95 explicit UndoGuardWithSelection(
96 const OUString
& i_undoMessage
,
97 const css::uno::Reference
< css::document::XUndoManager
> & i_undoManager
99 virtual ~UndoGuardWithSelection();
102 class HiddenUndoContext
105 explicit HiddenUndoContext(
106 const css::uno::Reference
< css::document::XUndoManager
> & i_undoManager
108 ~HiddenUndoContext();
111 css::uno::Reference
< css::document::XUndoManager
> m_xUndoManager
;
115 // INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_UNDOGUARD_HXX
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */