1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef CHART2_IMPLUNDOMANAGER_HXX
24 #define CHART2_IMPLUNDOMANAGER_HXX
25 
26 #include "ConfigItemListener.hxx"
27 
28 #include <com/sun/star/frame/XModel.hpp>
29 #include <com/sun/star/document/XUndoAction.hpp>
30 #include <com/sun/star/uno/Sequence.hxx>
31 
32 #include <rtl/ustring.hxx>
33 #include <unotools/configitem.hxx>
34 #include <cppuhelper/compbase1.hxx>
35 #include <cppuhelper/basemutex.hxx>
36 
37 #include <utility>
38 #include <deque>
39 
40 #include <boost/noncopyable.hpp>
41 #include <boost/shared_ptr.hpp>
42 
43 class SdrUndoAction;
44 
45 namespace com { namespace sun { namespace star {
46 namespace chart2 {
47     class XInternalDataProvider;
48 }
49 }}}
50 
51 
52 namespace chart
53 {
54 class ChartModelClone;
55 
56 namespace impl
57 {
58 
59 typedef ::cppu::BaseMutex                                                           UndoElement_MBase;
60 typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > UndoElement_TBase;
61 
62 class UndoElement   :public UndoElement_MBase
63                     ,public UndoElement_TBase
64                     ,public ::boost::noncopyable
65 {
66 public:
67     /** creates a new undo action
68 
69         @param i_actionString
70             is the title of the Undo action
71         @param i_documentModel
72             is the actual document model which the undo actions operates on
73         @param i_modelClone
74             is the cloned model from before the changes, which the Undo action represents, have been applied.
75             Upon <member>invoking</member>, the clone model is applied to the document model.
76     */
77     UndoElement( const ::rtl::OUString & i_actionString,
78                  const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_documentModel,
79                  const ::boost::shared_ptr< ChartModelClone >& i_modelClone
80                );
81 
82     // XUndoAction
83     virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException);
84     virtual void SAL_CALL undo(  ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException);
85     virtual void SAL_CALL redo(  ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException);
86 
87     // OComponentHelper
88     virtual void SAL_CALL disposing();
89 
90 protected:
91     virtual ~UndoElement();
92 
93 private:
94     void    impl_toggleModelState();
95 
96 private:
97     ::rtl::OUString                                                     m_sActionString;
98     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDocumentModel;
99     ::boost::shared_ptr< ChartModelClone >                              m_pModelClone;
100 };
101 
102 
103 typedef ::cppu::BaseMutex                                                           ShapeUndoElement_MBase;
104 typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > ShapeUndoElement_TBase;
105 class ShapeUndoElement  :public ShapeUndoElement_MBase
106                         ,public ShapeUndoElement_TBase
107 {
108 public:
109     ShapeUndoElement( SdrUndoAction& i_sdrUndoAction );
110 
111     // XUndoAction
112     virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException);
113     virtual void SAL_CALL undo(  ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException);
114     virtual void SAL_CALL redo(  ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException);
115 
116     // OComponentHelper
117     virtual void SAL_CALL disposing();
118 
119 protected:
120     virtual ~ShapeUndoElement();
121 
122 private:
123     SdrUndoAction*  m_pAction;
124 };
125 
126 } // namespace impl
127 } //  namespace chart
128 
129 // CHART2_IMPLUNDOMANAGER_HXX
130 #endif
131