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_UNDOMANAGER_HXX
28 #define CHART2_UNDOMANAGER_HXX
30 #include "ConfigItemListener.hxx"
31 #include "MutexContainer.hxx"
33 #include <com/sun/star/uno/Reference.hxx>
34 #include <com/sun/star/uno/Sequence.hxx>
35 #include <com/sun/star/util/XModifyBroadcaster.hpp>
36 #include <com/sun/star/util/XModifyListener.hpp>
37 #include <com/sun/star/chart2/XUndoManager.hpp>
38 #include <com/sun/star/chart2/XUndoHelper.hpp>
39 #include <com/sun/star/lang/XUnoTunnel.hpp>
41 #include <cppuhelper/compbase4.hxx>
42 #include <rtl/ustring.hxx>
51 namespace com
{ namespace sun
{ namespace star
{
59 // ----------------------------------------
63 class UndoStepsConfigItem
;
66 class ModifyBroadcaster
;
68 typedef ::cppu::WeakComponentImplHelper4
<
69 ::com::sun::star::util::XModifyBroadcaster
,
70 ::com::sun::star::chart2::XUndoManager
,
71 ::com::sun::star::chart2::XUndoHelper
,
72 ::com::sun::star::lang::XUnoTunnel
>
76 // ----------------------------------------
78 /** Manages undo by storing the entire XModel in the undo- and redo-buffers.
79 Note, that therefore this should not be used for "big" XModels.
81 A prerequisite for this to work is that the XModels added to the undo-
82 redo-stacks support the css::util::XCloneable interface, which is
83 implemented such that the entire model is cloned.
86 public MutexContainer
,
87 public ConfigItemListener
,
88 public impl::UndoManager_Base
91 explicit UndoManager();
92 virtual ~UndoManager();
94 void addShapeUndoAction( SdrUndoAction
* pAction
);
96 // ____ XUnoTunnel ____
97 virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& rId
)
98 throw (::com::sun::star::uno::RuntimeException
);
100 static const ::com::sun::star::uno::Sequence
< sal_Int8
>& getUnoTunnelId();
101 static UndoManager
* getImplementation( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> xObj
);
104 // ____ ConfigItemListener ____
105 virtual void notify( const ::rtl::OUString
& rPropertyName
);
107 // ____ util::XModifyBroadcaster ____
108 virtual void SAL_CALL
addModifyListener(
109 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyListener
>& aListener
)
110 throw (::com::sun::star::uno::RuntimeException
);
111 virtual void SAL_CALL
removeModifyListener(
112 const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyListener
>& aListener
)
113 throw (::com::sun::star::uno::RuntimeException
);
115 // ____ chart2::XUndoManager ____
116 virtual void SAL_CALL
preAction( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModelBeforeChange
)
117 throw (::com::sun::star::uno::RuntimeException
);
118 virtual void SAL_CALL
preActionWithArguments(
119 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModelBeforeChange
,
120 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aArguments
)
121 throw (::com::sun::star::uno::RuntimeException
);
122 virtual void SAL_CALL
postAction( const ::rtl::OUString
& aUndoText
)
123 throw (::com::sun::star::uno::RuntimeException
);
124 virtual void SAL_CALL
cancelAction()
125 throw (::com::sun::star::uno::RuntimeException
);
126 virtual void SAL_CALL
cancelActionWithUndo( ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModelToRestore
)
127 throw (::com::sun::star::uno::RuntimeException
);
128 virtual void SAL_CALL
undo( ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xCurrentModel
)
129 throw (::com::sun::star::uno::RuntimeException
);
130 virtual void SAL_CALL
redo( ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xCurrentModel
)
131 throw (::com::sun::star::uno::RuntimeException
);
132 virtual ::sal_Bool SAL_CALL
undoPossible()
133 throw (::com::sun::star::uno::RuntimeException
);
134 virtual ::sal_Bool SAL_CALL
redoPossible()
135 throw (::com::sun::star::uno::RuntimeException
);
136 virtual ::rtl::OUString SAL_CALL
getCurrentUndoString()
137 throw (::com::sun::star::uno::RuntimeException
);
138 virtual ::rtl::OUString SAL_CALL
getCurrentRedoString()
139 throw (::com::sun::star::uno::RuntimeException
);
140 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getAllUndoStrings()
141 throw (::com::sun::star::uno::RuntimeException
);
142 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getAllRedoStrings()
143 throw (::com::sun::star::uno::RuntimeException
);
145 // ____ XUndoHelper ____
146 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> SAL_CALL
getModelCloneForUndo(
147 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModelBeforeChange
)
148 throw (::com::sun::star::uno::RuntimeException
);
149 virtual void SAL_CALL
applyModelContent(
150 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModelToChange
,
151 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModelToCopyFrom
)
152 throw (::com::sun::star::uno::RuntimeException
);
155 void retrieveConfigUndoSteps();
156 void fireModifyEvent();
158 ::com::sun::star::uno::Reference
<
159 ::com::sun::star::frame::XModel
> & xCurrentModel
,
160 impl::UndoStack
* pStackToRemoveFrom
,
161 impl::UndoStack
* pStackToAddTo
,
164 ::std::auto_ptr
< impl::UndoStack
> m_apUndoStack
;
165 ::std::auto_ptr
< impl::UndoStack
> m_apRedoStack
;
167 impl::UndoElement
* m_pLastRemeberedUndoElement
;
169 ::std::auto_ptr
< impl::UndoStepsConfigItem
> m_apUndoStepsConfigItem
;
170 sal_Int32 m_nMaxNumberOfUndos
;
171 ::com::sun::star::uno::Reference
<
172 ::com::sun::star::util::XModifyBroadcaster
> m_xModifyBroadcaster
;
173 // pointer is valid as long as m_xModifyBroadcaster.is()
174 impl::ModifyBroadcaster
* m_pModifyBroadcaster
;
179 // CHART2_UNDOMANAGER_HXX