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>
35 #include <svl/lstner.hxx>
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
49 const ::std::auto_ptr
<OXUndoEnvironmentImpl
> m_pImpl
;
51 OXUndoEnvironment(const OXUndoEnvironment
&);
52 OXUndoEnvironment
& operator=(const OXUndoEnvironment
&);
55 virtual ~OXUndoEnvironment();
57 void SetUndoMode(sal_Bool _bUndo
);
60 OXUndoEnvironment(OReportModel
& _rModel
);
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.
68 OXUndoEnvironment
& m_rUndoEnv
;
70 OUndoEnvLock(OXUndoEnvironment
& _rUndoEnv
): m_rUndoEnv(_rUndoEnv
){m_rUndoEnv
.Lock();}
71 ~OUndoEnvLock(){ m_rUndoEnv
.UnLock(); }
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()
80 OXUndoEnvironment
& m_rUndoEnv
;
82 OUndoMode(OXUndoEnvironment
& _rUndoEnv
)
83 :m_rUndoEnv(_rUndoEnv
)
86 m_rUndoEnv
.SetUndoMode(sal_True
);
90 m_rUndoEnv
.SetUndoMode(sal_False
);
97 sal_Bool
IsLocked() const;
99 // returns sal_True is we are in UNDO
100 sal_Bool
IsUndoMode() const;
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
115 void RemoveSection(OReportPage
* _pPage
);
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
);
130 virtual void SAL_CALL
modified( const ::com::sun::star::lang::EventObject
& aEvent
) throw (::com::sun::star::uno::RuntimeException
);
134 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
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;