merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / inc / UndoGuard.hxx
blob864d5ccff994016d0da0e6bcb2474eca8f8e4589
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef CHART2_UNDOGUARD_HXX
28 #define CHART2_UNDOGUARD_HXX
30 #include <com/sun/star/frame/XModel.hpp>
31 #include <com/sun/star/chart2/XUndoManager.hpp>
33 // header for class OUString
34 #include <rtl/ustring.hxx>
36 namespace chart
38 /** Base Class for UndoGuard and UndoLiveUpdateGuard
40 class UndoGuard_Base
42 public:
43 explicit UndoGuard_Base( const rtl::OUString & rUndoMessage
44 , const ::com::sun::star::uno::Reference<
45 ::com::sun::star::chart2::XUndoManager > & xUndoManager
46 , const ::com::sun::star::uno::Reference<
47 ::com::sun::star::frame::XModel > & xModel );
48 virtual ~UndoGuard_Base();
50 void commitAction();
52 protected:
53 ::com::sun::star::uno::Reference<
54 ::com::sun::star::frame::XModel > m_xModel;
55 ::com::sun::star::uno::Reference<
56 ::com::sun::star::chart2::XUndoManager > m_xUndoManager;
58 rtl::OUString m_aUndoString;
59 bool m_bActionPosted;
62 /** This guard calls preAction at the given Model in the CTOR and
63 cancelAction in the DTOR if no other method is called.
64 If commitAction is called the destructor does nothin anymore.
66 class UndoGuard : public UndoGuard_Base
68 public:
69 explicit UndoGuard( const rtl::OUString& rUndoMessage
70 , const ::com::sun::star::uno::Reference<
71 ::com::sun::star::chart2::XUndoManager > & xUndoManager
72 , const ::com::sun::star::uno::Reference<
73 ::com::sun::star::frame::XModel > & xModel );
74 virtual ~UndoGuard();
77 /** This guard calls preAction at the given Model in the CTOR and
78 cancelActionUndo in the DTOR if no other method is called.
79 If commitAction is called the destructor does nothin anymore.
81 class UndoLiveUpdateGuard : public UndoGuard_Base
83 public:
84 explicit UndoLiveUpdateGuard( const rtl::OUString& rUndoMessage
85 , const ::com::sun::star::uno::Reference<
86 ::com::sun::star::chart2::XUndoManager > & xUndoManager
87 , const ::com::sun::star::uno::Reference<
88 ::com::sun::star::frame::XModel > & xModel );
89 virtual ~UndoLiveUpdateGuard();
92 /** Same as UndoLiveUpdateGuard but with additional storage of the chart's data.
93 Only use this if the data has internal data.
95 class UndoLiveUpdateGuardWithData :
96 public UndoGuard_Base
98 public:
99 explicit UndoLiveUpdateGuardWithData( const rtl::OUString& rUndoMessage
100 , const ::com::sun::star::uno::Reference<
101 ::com::sun::star::chart2::XUndoManager > & xUndoManager
102 , const ::com::sun::star::uno::Reference<
103 ::com::sun::star::frame::XModel > & xModel );
104 virtual ~UndoLiveUpdateGuardWithData();
107 class UndoGuardWithSelection : public UndoGuard_Base
109 public:
110 explicit UndoGuardWithSelection( const rtl::OUString& rUndoMessage
111 , const ::com::sun::star::uno::Reference<
112 ::com::sun::star::chart2::XUndoManager > & xUndoManager
113 , const ::com::sun::star::uno::Reference<
114 ::com::sun::star::frame::XModel > & xModel );
115 virtual ~UndoGuardWithSelection();
119 // CHART2_UNDOGUARD_HXX
120 #endif