1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef INCLUDED_UNDOENV_HXX
29 #define INCLUDED_UNDOENV_HXX
31 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
32 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
33 #include <com/sun/star/container/XContainerListener.hpp>
34 #include <com/sun/star/report/XReportDefinition.hpp>
36 #include <svl/lstner.hxx>
40 class OXUndoEnvironmentImpl
;
42 //========================================================================
43 class REPORTDESIGN_DLLPUBLIC OXUndoEnvironment
44 : public ::cppu::WeakImplHelper3
< ::com::sun::star::beans::XPropertyChangeListener
45 , ::com::sun::star::container::XContainerListener
46 , ::com::sun::star::util::XModifyListener
50 const ::std::auto_ptr
<OXUndoEnvironmentImpl
> m_pImpl
;
52 OXUndoEnvironment(const OXUndoEnvironment
&);
53 OXUndoEnvironment
& operator=(const OXUndoEnvironment
&);
56 virtual ~OXUndoEnvironment();
58 void SetUndoMode(sal_Bool _bUndo
);
61 OXUndoEnvironment(OReportModel
& _rModel
);
64 Create an object ob OUndoEnvLock locks the undo possibility
65 As long as in the OUndoEnvLock scope, no undo is possible for manipulated object.
69 OXUndoEnvironment
& m_rUndoEnv
;
71 OUndoEnvLock(OXUndoEnvironment
& _rUndoEnv
): m_rUndoEnv(_rUndoEnv
){m_rUndoEnv
.Lock();}
72 ~OUndoEnvLock(){ m_rUndoEnv
.UnLock(); }
76 This is near the same as OUndoEnvLock but it is also possible to ask for the current mode.
77 UndoMode will set if SID_UNDO is called in execute()
81 OXUndoEnvironment
& m_rUndoEnv
;
83 OUndoMode(OXUndoEnvironment
& _rUndoEnv
)
84 :m_rUndoEnv(_rUndoEnv
)
87 m_rUndoEnv
.SetUndoMode(sal_True
);
91 m_rUndoEnv
.SetUndoMode(sal_False
);
98 sal_Bool
IsLocked() const;
100 // returns sal_True is we are in UNDO
101 sal_Bool
IsUndoMode() const;
104 struct Accessor
{ friend class OReportModel
; private: Accessor() { } };
105 void Clear(const Accessor
& _r
);
107 void AddElement(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& Element
);
108 void RemoveElement(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& Element
);
110 void AddSection( const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>& _xSection
);
111 void RemoveSection( const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>& _xSection
);
112 /** removes the section from the page out of the undo env
116 void RemoveSection(OReportPage
* _pPage
);
120 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& Source
) throw( ::com::sun::star::uno::RuntimeException
);
122 // XPropertyChangeListener
123 virtual void SAL_CALL
propertyChange(const ::com::sun::star::beans::PropertyChangeEvent
& evt
) throw(::com::sun::star::uno::RuntimeException
);
125 // XContainerListener
126 virtual void SAL_CALL
elementInserted(const ::com::sun::star::container::ContainerEvent
& rEvent
) throw(::com::sun::star::uno::RuntimeException
);
127 virtual void SAL_CALL
elementReplaced(const ::com::sun::star::container::ContainerEvent
& rEvent
) throw(::com::sun::star::uno::RuntimeException
);
128 virtual void SAL_CALL
elementRemoved(const ::com::sun::star::container::ContainerEvent
& rEvent
) throw(::com::sun::star::uno::RuntimeException
);
131 virtual void SAL_CALL
modified( const ::com::sun::star::lang::EventObject
& aEvent
) throw (::com::sun::star::uno::RuntimeException
);
135 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
138 void TogglePropertyListening(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& Element
);
140 void implSetModified();
142 void switchListening( const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& _rxContainer
, bool _bStartListening
) SAL_THROW(());
143 void switchListening( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxObject
, bool _bStartListening
) SAL_THROW(());
145 ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::container::XChild
> >::const_iterator
146 getSection(const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XChild
>& _xContainer
) const;
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */