fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / chart2 / source / controller / main / UndoGuard.hxx
blobacf3275dd3a40a777f13a9e7811f785d3ff90edd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <com/sun/star/document/XUndoManager.hpp>
25 #include <com/sun/star/frame/XModel.hpp>
27 #include <rtl/ustring.hxx>
29 #include <boost/shared_ptr.hpp>
31 namespace chart
34 /** A guard which 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.
37 class UndoGuard
39 public:
40 explicit UndoGuard(
41 const OUString& i_undoMessage,
42 const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager,
43 const ModelFacet i_facet = E_MODEL
45 ~UndoGuard();
47 void commit();
48 void rollback();
50 protected:
51 bool isActionPosted() const { return m_bActionPosted; }
53 private:
54 void discardSnapshot();
56 private:
57 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xChartModel;
58 const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager;
60 ::boost::shared_ptr< ChartModelClone > m_pDocumentSnapshot;
61 OUString m_aUndoString;
62 bool m_bActionPosted;
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 restouration is not performed.
68 class UndoLiveUpdateGuard : public UndoGuard
70 public:
71 explicit UndoLiveUpdateGuard(
72 const OUString& i_undoMessage,
73 const ::com::sun::star::uno::Reference< ::com::sun::star::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 :
82 public UndoGuard
84 public:
85 explicit UndoLiveUpdateGuardWithData(
86 const OUString& i_undoMessage,
87 const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager
89 ~UndoLiveUpdateGuardWithData();
92 class UndoGuardWithSelection : public UndoGuard
94 public:
95 explicit UndoGuardWithSelection(
96 const OUString& i_undoMessage,
97 const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager
99 virtual ~UndoGuardWithSelection();
102 class HiddenUndoContext
104 public:
105 HiddenUndoContext(
106 const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager
108 ~HiddenUndoContext();
110 private:
111 ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager;
115 // INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_UNDOGUARD_HXX
116 #endif
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */