1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 #ifndef INCLUDED_REPORTCONTROLLEROBSERVER_HXX
28 #define INCLUDED_REPORTCONTROLLEROBSERVER_HXX
29 
30 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
31 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
32 #include <com/sun/star/report/XReportDefinition.hpp>
33 #include <cppuhelper/implbase3.hxx>
34 
35 #include <memory>
36 #include <dllapi.h>
37 #include <vector>
38 
39 // #include <svl/lstner.hxx>
40 #include <vcl/svapp.hxx>
41 #include <tools/link.hxx>
42 
43 #include <FormattedFieldBeautifier.hxx>
44 #include <FixedTextColor.hxx>
45 
46 namespace rptui
47 {
48     class OReportController;
49     class OXReportControllerObserverImpl;
50 
51 	//========================================================================
52 	class /* REPORTDESIGN_DLLPUBLIC */ OXReportControllerObserver
53         : public ::cppu::WeakImplHelper3<	::com::sun::star::beans::XPropertyChangeListener
54                                         ,   ::com::sun::star::container::XContainerListener
55 										,	::com::sun::star::util::XModifyListener
56                                         >
57         /*,public SfxListener*/
58 	{
59 
60         const ::std::auto_ptr<OXReportControllerObserverImpl> m_pImpl;
61 
62         FormattedFieldBeautifier m_aFormattedFieldBeautifier;
63         FixedTextColor           m_aFixedTextColor;
64 
65         // do not allow copy
66         OXReportControllerObserver(const OXReportControllerObserver&);
67 		OXReportControllerObserver& operator=(const OXReportControllerObserver&);
68         virtual  ~OXReportControllerObserver(); // UNO Object must have private destructor!
69 	public:
70 		OXReportControllerObserver(const OReportController& _rController);
71 
72 // protected:
73 		// XPropertyChangeListener
74 		virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
75 
76         // XEventListener
77 		virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
78 
79 		// XContainerListener
80 		virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
81 		virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
82 		virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
83 
84 		// XModifyListener
85 		virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
86 
87 
88         void AddElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
89         void RemoveElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
90 
91 		void AddSection( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection);
92 		void RemoveSection( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection );
93 
94         // SfxListener
95         // virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
96 
97         /**
98            Create an object ob OUndoEnvLock locks the undo possibility
99            As long as in the OUndoEnvLock scope, no undo is possible for manipulated object.
100          */
101         class OEnvLock
102         {
103             OXReportControllerObserver& m_rObserver;
104         public:
105             OEnvLock(OXReportControllerObserver& _rObserver): m_rObserver(_rObserver){m_rObserver.Lock();}
106             ~OEnvLock(){ m_rObserver.UnLock(); }
107         };
108 
109 		void Lock();
110 		void UnLock();
111 		sal_Bool IsLocked() const;
112 
113         void Clear();
114 	private:
115 
116 		void TogglePropertyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
117 		void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxContainer, bool _bStartListening ) SAL_THROW(());
118 		void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject, bool _bStartListening ) SAL_THROW(());
119 
120         // void ModeChanged(); // will be called from 'Notify'
121 		DECL_LINK(SettingsChanged, VclWindowEvent* );
122     private:
123 
124         ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild> >::const_iterator getSection(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild>& _xContainer) const;
125 
126     };
127 
128 } // namespace rptui
129 
130 #endif /* INCLUDED_REPORTCONTROLLEROBSERVER_HXX */
131 
132 
133