merged tag ooo/OOO330_m14
[LibreOffice.git] / reportdesign / inc / UndoEnv.hxx
blobaba6f31970e943ba543cd54012f140039464c7de
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 INCLUDED_UNDOENV_HXX
28 #define INCLUDED_UNDOENV_HXX
30 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
31 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
32 #include <com/sun/star/container/XContainerListener.hpp>
33 #include <com/sun/star/report/XReportDefinition.hpp>
34 #include <memory>
35 #include <svl/lstner.hxx>
37 namespace rptui
39 class OXUndoEnvironmentImpl;
41 //========================================================================
42 class REPORTDESIGN_DLLPUBLIC OXUndoEnvironment
43 : public ::cppu::WeakImplHelper3< ::com::sun::star::beans::XPropertyChangeListener
44 , ::com::sun::star::container::XContainerListener
45 , ::com::sun::star::util::XModifyListener
47 , public SfxListener
49 const ::std::auto_ptr<OXUndoEnvironmentImpl> m_pImpl;
51 OXUndoEnvironment(const OXUndoEnvironment&);
52 OXUndoEnvironment& operator=(const OXUndoEnvironment&);
54 protected:
55 virtual ~OXUndoEnvironment();
57 void SetUndoMode(sal_Bool _bUndo);
59 public:
60 OXUndoEnvironment(OReportModel& _rModel);
62 /**
63 Create an object ob OUndoEnvLock locks the undo possibility
64 As long as in the OUndoEnvLock scope, no undo is possible for manipulated object.
66 class OUndoEnvLock
68 OXUndoEnvironment& m_rUndoEnv;
69 public:
70 OUndoEnvLock(OXUndoEnvironment& _rUndoEnv): m_rUndoEnv(_rUndoEnv){m_rUndoEnv.Lock();}
71 ~OUndoEnvLock(){ m_rUndoEnv.UnLock(); }
74 /**
75 This is near the same as OUndoEnvLock but it is also possible to ask for the current mode.
76 UndoMode will set if SID_UNDO is called in execute()
78 class OUndoMode
80 OXUndoEnvironment& m_rUndoEnv;
81 public:
82 OUndoMode(OXUndoEnvironment& _rUndoEnv)
83 :m_rUndoEnv(_rUndoEnv)
85 m_rUndoEnv.Lock();
86 m_rUndoEnv.SetUndoMode(sal_True);
88 ~OUndoMode()
90 m_rUndoEnv.SetUndoMode(sal_False);
91 m_rUndoEnv.UnLock();
95 void Lock();
96 void UnLock();
97 sal_Bool IsLocked() const;
99 // returns sal_True is we are in UNDO
100 sal_Bool IsUndoMode() const;
102 // access control
103 struct Accessor { friend class OReportModel; private: Accessor() { } };
104 void Clear(const Accessor& _r);
106 void AddElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
107 void RemoveElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
109 void AddSection( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection);
110 void RemoveSection( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection );
111 /** removes the section from the page out of the undo env
113 * \param _pPage
115 void RemoveSection(OReportPage* _pPage);
117 protected:
118 // XEventListener
119 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
121 // XPropertyChangeListener
122 virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
124 // XContainerListener
125 virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
126 virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
127 virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
129 // XModifyListener
130 virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
132 void ModeChanged();
134 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
136 private:
137 void TogglePropertyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
139 void implSetModified();
141 void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxContainer, bool _bStartListening ) SAL_THROW(());
142 void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject, bool _bStartListening ) SAL_THROW(());
144 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild> >::const_iterator
145 getSection(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild>& _xContainer) const;
149 #endif //