1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: UndoManager.hxx,v $
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_UNDOMANAGER_HXX
31 #define CHART2_UNDOMANAGER_HXX
33 #include "ConfigItemListener.hxx"
34 #include "MutexContainer.hxx"
36 #include <com/sun/star/uno/Reference.hxx>
37 #include <com/sun/star/uno/Sequence.hxx>
38 #include <com/sun/star/util/XModifyBroadcaster.hpp>
39 #include <com/sun/star/util/XModifyListener.hpp>
40 #include <com/sun/star/chart2/XUndoManager.hpp>
41 #include <com/sun/star/chart2/XUndoHelper.hpp>
43 #include <cppuhelper/compbase3.hxx>
44 #include <rtl/ustring.hxx>
51 namespace com
{ namespace sun
{ namespace star
{
59 // ----------------------------------------
63 class UndoStepsConfigItem
;
66 class ModifyBroadcaster
;
68 typedef ::cppu::WeakComponentImplHelper3
<
69 ::com::sun::star::util::XModifyBroadcaster
,
70 ::com::sun::star::chart2::XUndoManager
,
71 ::com::sun::star::chart2::XUndoHelper
>
75 // ----------------------------------------
77 /** Manages undo by storing the entire XModel in the undo- and redo-buffers.
78 Note, that therefore this should not be used for "big" XModels.
80 A prerequisite for this to work is that the XModels added to the undo-
81 redo-stacks support the css::util::XCloneable interface, which is
82 implemented such that the entire model is cloned.
85 public MutexContainer
,
86 public ConfigItemListener
,
87 public impl::UndoManager_Base
90 explicit UndoManager();
91 virtual ~UndoManager();
94 // ____ ConfigItemListener ____
95 virtual void notify( const ::rtl::OUString
& rPropertyName
);
97 // ____ util::XModifyBroadcaster ____
98 virtual void SAL_CALL
addModifyListener(
99 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyListener
>& aListener
)
100 throw (::com::sun::star::uno::RuntimeException
);
101 virtual void SAL_CALL
removeModifyListener(
102 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyListener
>& aListener
)
103 throw (::com::sun::star::uno::RuntimeException
);
105 // ____ chart2::XUndoManager ____
106 virtual void SAL_CALL
preAction( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModelBeforeChange
)
107 throw (::com::sun::star::uno::RuntimeException
);
108 virtual void SAL_CALL
preActionWithArguments(
109 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModelBeforeChange
,
110 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aArguments
)
111 throw (::com::sun::star::uno::RuntimeException
);
112 virtual void SAL_CALL
postAction( const ::rtl::OUString
& aUndoText
)
113 throw (::com::sun::star::uno::RuntimeException
);
114 virtual void SAL_CALL
cancelAction()
115 throw (::com::sun::star::uno::RuntimeException
);
116 virtual void SAL_CALL
cancelActionWithUndo( ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModelToRestore
)
117 throw (::com::sun::star::uno::RuntimeException
);
118 virtual void SAL_CALL
undo( ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xCurrentModel
)
119 throw (::com::sun::star::uno::RuntimeException
);
120 virtual void SAL_CALL
redo( ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xCurrentModel
)
121 throw (::com::sun::star::uno::RuntimeException
);
122 virtual ::sal_Bool SAL_CALL
undoPossible()
123 throw (::com::sun::star::uno::RuntimeException
);
124 virtual ::sal_Bool SAL_CALL
redoPossible()
125 throw (::com::sun::star::uno::RuntimeException
);
126 virtual ::rtl::OUString SAL_CALL
getCurrentUndoString()
127 throw (::com::sun::star::uno::RuntimeException
);
128 virtual ::rtl::OUString SAL_CALL
getCurrentRedoString()
129 throw (::com::sun::star::uno::RuntimeException
);
130 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getAllUndoStrings()
131 throw (::com::sun::star::uno::RuntimeException
);
132 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getAllRedoStrings()
133 throw (::com::sun::star::uno::RuntimeException
);
135 // ____ XUndoHelper ____
136 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> SAL_CALL
getModelCloneForUndo(
137 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModelBeforeChange
)
138 throw (::com::sun::star::uno::RuntimeException
);
139 virtual void SAL_CALL
applyModelContent(
140 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModelToChange
,
141 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModelToCopyFrom
)
142 throw (::com::sun::star::uno::RuntimeException
);
145 void retrieveConfigUndoSteps();
146 void fireModifyEvent();
148 ::com::sun::star::uno::Reference
<
149 ::com::sun::star::frame::XModel
> & xCurrentModel
,
150 impl::UndoStack
* pStackToRemoveFrom
,
151 impl::UndoStack
* pStackToAddTo
);
153 ::std::auto_ptr
< impl::UndoStack
> m_apUndoStack
;
154 ::std::auto_ptr
< impl::UndoStack
> m_apRedoStack
;
156 impl::UndoElement
* m_pLastRemeberedUndoElement
;
158 ::std::auto_ptr
< impl::UndoStepsConfigItem
> m_apUndoStepsConfigItem
;
159 sal_Int32 m_nMaxNumberOfUndos
;
160 ::com::sun::star::uno::Reference
<
161 ::com::sun::star::util::XModifyBroadcaster
> m_xModifyBroadcaster
;
162 // pointer is valid as long as m_xModifyBroadcaster.is()
163 impl::ModifyBroadcaster
* m_pModifyBroadcaster
;
168 // CHART2_UNDOMANAGER_HXX