update dev300-m58
[ooovba.git] / chart2 / source / tools / ImplUndoManager.hxx
blobccb023d995ffc07514064c8130f26021c19fa2a8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ImplUndoManager.hxx,v $
10 * $Revision: 1.5.44.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef CHART2_IMPLUNDOMANAGER_HXX
31 #define CHART2_IMPLUNDOMANAGER_HXX
33 #include "ConfigItemListener.hxx"
35 #include <com/sun/star/frame/XModel.hpp>
36 #include <com/sun/star/uno/Sequence.hxx>
38 #include <rtl/ustring.hxx>
39 #include <unotools/configitem.hxx>
41 #include <utility>
42 #include <deque>
44 namespace com { namespace sun { namespace star {
45 namespace chart2 {
46 class XInternalDataProvider;
48 }}}
51 namespace chart
53 namespace impl
56 class UndoElement
58 public:
59 UndoElement( const ::rtl::OUString & rActionString,
60 const ::com::sun::star::uno::Reference<
61 ::com::sun::star::frame::XModel > & xModel );
62 UndoElement( const ::com::sun::star::uno::Reference<
63 ::com::sun::star::frame::XModel > & xModel );
64 UndoElement( const UndoElement & rOther );
65 virtual ~UndoElement();
67 virtual void dispose();
68 virtual UndoElement * createFromModel(
69 const ::com::sun::star::uno::Reference<
70 ::com::sun::star::frame::XModel > & xModel );
72 virtual void applyToModel(
73 ::com::sun::star::uno::Reference<
74 ::com::sun::star::frame::XModel > & xInOutModelToChange );
76 void setActionString( const ::rtl::OUString & rActionString );
77 ::rtl::OUString getActionString() const;
79 static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > cloneModel(
80 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel );
82 static void applyModelContentToModel(
83 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xInOutModelToChange,
84 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModelToCopyFrom,
85 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & xData = 0 );
87 protected:
88 ::com::sun::star::uno::Reference<
89 ::com::sun::star::frame::XModel > m_xModel;
91 private:
92 void initialize( const ::com::sun::star::uno::Reference<
93 ::com::sun::star::frame::XModel > & xModel );
95 ::rtl::OUString m_aActionString;
98 class UndoElementWithData : public UndoElement
100 public:
101 UndoElementWithData( const ::rtl::OUString & rActionString,
102 const ::com::sun::star::uno::Reference<
103 ::com::sun::star::frame::XModel > & xModel );
104 UndoElementWithData( const ::com::sun::star::uno::Reference<
105 ::com::sun::star::frame::XModel > & xModel );
106 UndoElementWithData( const UndoElementWithData & rOther );
107 virtual ~UndoElementWithData();
109 virtual void dispose();
110 virtual UndoElement * createFromModel(
111 const ::com::sun::star::uno::Reference<
112 ::com::sun::star::frame::XModel > & xModel );
114 virtual void applyToModel(
115 ::com::sun::star::uno::Reference<
116 ::com::sun::star::frame::XModel > & xInOutModelToChange );
118 private:
119 void initializeData();
121 ::com::sun::star::uno::Reference<
122 ::com::sun::star::chart2::XInternalDataProvider > m_xData;
125 class UndoElementWithSelection : public UndoElement
127 public:
128 UndoElementWithSelection( const ::rtl::OUString & rActionString,
129 const ::com::sun::star::uno::Reference<
130 ::com::sun::star::frame::XModel > & xModel );
131 UndoElementWithSelection( const ::com::sun::star::uno::Reference<
132 ::com::sun::star::frame::XModel > & xModel );
133 UndoElementWithSelection( const UndoElementWithSelection & rOther );
134 virtual ~UndoElementWithSelection();
136 virtual void dispose();
137 virtual UndoElement * createFromModel(
138 const ::com::sun::star::uno::Reference<
139 ::com::sun::star::frame::XModel > & xModel );
141 virtual void applyToModel(
142 ::com::sun::star::uno::Reference<
143 ::com::sun::star::frame::XModel > & xInOutModelToChange );
145 private:
146 void initialize( const ::com::sun::star::uno::Reference<
147 ::com::sun::star::frame::XModel > & xModel );
149 ::com::sun::star::uno::Any m_aSelection;
152 /** Note that all models that are put into this container are at some point
153 disposed of inside this class. (At least in the destructor). That means
154 the models retrieved here should never be used, but instead their content
155 should be copied to a living model.
157 class UndoStack
159 public:
160 UndoStack();
161 // disposes of all models left in the stack
162 ~UndoStack();
164 // removes he last undo action and disposes of the model
165 void pop();
166 void push( UndoElement * rElement );
168 // precondition: !empty()
169 UndoElement * top() const;
170 ::rtl::OUString topUndoString() const;
172 ::com::sun::star::uno::Sequence< ::rtl::OUString > getUndoStrings() const;
174 bool empty() const;
175 void disposeAndClear();
177 // removes all actions that have been inserted more than nMaxSize steps ago.
178 // The models of those actions are disposed of
179 void limitSize( sal_Int32 nMaxSize );
181 private:
182 void applyLimitation();
184 typedef ::std::deque< UndoElement * > tUndoStackType;
186 tUndoStackType m_aStack;
187 sal_Int32 m_nSizeLimit;
190 // ----------------------------------------
192 class UndoStepsConfigItem : public ::utl::ConfigItem
194 public:
195 explicit UndoStepsConfigItem( ConfigItemListener & rListener );
196 virtual ~UndoStepsConfigItem();
198 sal_Int32 getUndoSteps();
200 protected:
201 // ____ ::utl::ConfigItem ____
202 virtual void Notify( const ::com::sun::star::uno::Sequence< ::rtl::OUString > & aPropertyNames );
204 private:
205 ConfigItemListener & m_rListener;
209 } // namespace impl
210 } // namespace chart
212 // CHART2_IMPLUNDOMANAGER_HXX
213 #endif