1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: UndoEnv.hxx,v $
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>
38 #include <svtools/lstner.hxx>
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
52 const ::std::auto_ptr
<OXUndoEnvironmentImpl
> m_pImpl
;
54 OXUndoEnvironment(const OXUndoEnvironment
&);
55 OXUndoEnvironment
& operator=(const OXUndoEnvironment
&);
58 virtual ~OXUndoEnvironment();
60 void SetUndoMode(sal_Bool _bUndo
);
63 OXUndoEnvironment(OReportModel
& _rModel
);
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.
71 OXUndoEnvironment
& m_rUndoEnv
;
73 OUndoEnvLock(OXUndoEnvironment
& _rUndoEnv
): m_rUndoEnv(_rUndoEnv
){m_rUndoEnv
.Lock();}
74 ~OUndoEnvLock(){ m_rUndoEnv
.UnLock(); }
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()
83 OXUndoEnvironment
& m_rUndoEnv
;
85 OUndoMode(OXUndoEnvironment
& _rUndoEnv
)
86 :m_rUndoEnv(_rUndoEnv
)
89 m_rUndoEnv
.SetUndoMode(sal_True
);
93 m_rUndoEnv
.SetUndoMode(sal_False
);
100 sal_Bool
IsLocked() const;
102 // returns sal_True is we are in UNDO
103 sal_Bool
IsUndoMode() const;
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
118 void RemoveSection(OReportPage
* _pPage
);
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
);
133 virtual void SAL_CALL
modified( const ::com::sun::star::lang::EventObject
& aEvent
) throw (::com::sun::star::uno::RuntimeException
);
137 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
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;