Update ooo320-m1
[ooovba.git] / reportdesign / inc / UndoEnv.hxx
blob7d2ab171640929e652d4bd7553304e04992cfee3
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: UndoEnv.hxx,v $
10 * $Revision: 1.4 $
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 INCLUDED_UNDOENV_HXX
31 #define INCLUDED_UNDOENV_HXX
33 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
34 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
35 #include <com/sun/star/container/XContainerListener.hpp>
36 #include <com/sun/star/report/XReportDefinition.hpp>
37 #include <memory>
38 #include <svtools/lstner.hxx>
40 namespace rptui
42 class OXUndoEnvironmentImpl;
44 //========================================================================
45 class REPORTDESIGN_DLLPUBLIC OXUndoEnvironment
46 : public ::cppu::WeakImplHelper3< ::com::sun::star::beans::XPropertyChangeListener
47 , ::com::sun::star::container::XContainerListener
48 , ::com::sun::star::util::XModifyListener
50 , public SfxListener
52 const ::std::auto_ptr<OXUndoEnvironmentImpl> m_pImpl;
54 OXUndoEnvironment(const OXUndoEnvironment&);
55 OXUndoEnvironment& operator=(const OXUndoEnvironment&);
57 protected:
58 virtual ~OXUndoEnvironment();
60 void SetUndoMode(sal_Bool _bUndo);
62 public:
63 OXUndoEnvironment(OReportModel& _rModel);
65 /**
66 Create an object ob OUndoEnvLock locks the undo possibility
67 As long as in the OUndoEnvLock scope, no undo is possible for manipulated object.
69 class OUndoEnvLock
71 OXUndoEnvironment& m_rUndoEnv;
72 public:
73 OUndoEnvLock(OXUndoEnvironment& _rUndoEnv): m_rUndoEnv(_rUndoEnv){m_rUndoEnv.Lock();}
74 ~OUndoEnvLock(){ m_rUndoEnv.UnLock(); }
77 /**
78 This is near the same as OUndoEnvLock but it is also possible to ask for the current mode.
79 UndoMode will set if SID_UNDO is called in execute()
81 class OUndoMode
83 OXUndoEnvironment& m_rUndoEnv;
84 public:
85 OUndoMode(OXUndoEnvironment& _rUndoEnv)
86 :m_rUndoEnv(_rUndoEnv)
88 m_rUndoEnv.Lock();
89 m_rUndoEnv.SetUndoMode(sal_True);
91 ~OUndoMode()
93 m_rUndoEnv.SetUndoMode(sal_False);
94 m_rUndoEnv.UnLock();
98 void Lock();
99 void UnLock();
100 sal_Bool IsLocked() const;
102 // returns sal_True is we are in UNDO
103 sal_Bool IsUndoMode() const;
105 // access control
106 struct Accessor { friend class OReportModel; private: Accessor() { } };
107 void Clear(const Accessor& _r);
109 void AddElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
110 void RemoveElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
112 void AddSection( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection);
113 void RemoveSection( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection );
114 /** removes the section from the page out of the undo env
116 * \param _pPage
118 void RemoveSection(OReportPage* _pPage);
120 protected:
121 // XEventListener
122 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
124 // XPropertyChangeListener
125 virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
127 // XContainerListener
128 virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
129 virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
130 virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
132 // XModifyListener
133 virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
135 void ModeChanged();
137 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
139 private:
140 void TogglePropertyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
142 void implSetModified();
144 void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxContainer, bool _bStartListening ) SAL_THROW(());
145 void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject, bool _bStartListening ) SAL_THROW(());
147 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild> >::const_iterator
148 getSection(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild>& _xContainer) const;
152 #endif //