1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef INCLUDED_REPORTCONTROLLEROBSERVER_HXX
24 #define INCLUDED_REPORTCONTROLLEROBSERVER_HXX
25 
26 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
27 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
28 #include <com/sun/star/report/XReportDefinition.hpp>
29 #include <cppuhelper/implbase3.hxx>
30 
31 #include <memory>
32 #include <dllapi.h>
33 #include <vector>
34 
35 // #include <svl/lstner.hxx>
36 #include <vcl/svapp.hxx>
37 #include <tools/link.hxx>
38 
39 #include <FormattedFieldBeautifier.hxx>
40 #include <FixedTextColor.hxx>
41 
42 namespace rptui
43 {
44     class OReportController;
45     class OXReportControllerObserverImpl;
46 
47 	//========================================================================
48 	class /* REPORTDESIGN_DLLPUBLIC */ OXReportControllerObserver
49         : public ::cppu::WeakImplHelper3<	::com::sun::star::beans::XPropertyChangeListener
50                                         ,   ::com::sun::star::container::XContainerListener
51 										,	::com::sun::star::util::XModifyListener
52                                         >
53         /*,public SfxListener*/
54 	{
55 
56         const ::std::auto_ptr<OXReportControllerObserverImpl> m_pImpl;
57 
58         FormattedFieldBeautifier m_aFormattedFieldBeautifier;
59         FixedTextColor           m_aFixedTextColor;
60 
61         // do not allow copy
62         OXReportControllerObserver(const OXReportControllerObserver&);
63 		OXReportControllerObserver& operator=(const OXReportControllerObserver&);
64         virtual  ~OXReportControllerObserver(); // UNO Object must have private destructor!
65 	public:
66 		OXReportControllerObserver(const OReportController& _rController);
67 
68 // protected:
69 		// XPropertyChangeListener
70 		virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
71 
72         // XEventListener
73 		virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
74 
75 		// XContainerListener
76 		virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
77 		virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
78 		virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
79 
80 		// XModifyListener
81 		virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
82 
83 
84         void AddElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
85         void RemoveElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
86 
87 		void AddSection( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection);
88 		void RemoveSection( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection );
89 
90         // SfxListener
91         // virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
92 
93         /**
94            Create an object ob OUndoEnvLock locks the undo possibility
95            As long as in the OUndoEnvLock scope, no undo is possible for manipulated object.
96          */
97         class OEnvLock
98         {
99             OXReportControllerObserver& m_rObserver;
100         public:
OEnvLock(OXReportControllerObserver & _rObserver)101             OEnvLock(OXReportControllerObserver& _rObserver): m_rObserver(_rObserver){m_rObserver.Lock();}
~OEnvLock()102             ~OEnvLock(){ m_rObserver.UnLock(); }
103         };
104 
105 		void Lock();
106 		void UnLock();
107 		sal_Bool IsLocked() const;
108 
109         void Clear();
110 	private:
111 
112 		void TogglePropertyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
113 		void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxContainer, bool _bStartListening ) SAL_THROW(());
114 		void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject, bool _bStartListening ) SAL_THROW(());
115 
116         // void ModeChanged(); // will be called from 'Notify'
117 		DECL_LINK(SettingsChanged, VclWindowEvent* );
118     private:
119 
120         ::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;
121 
122     };
123 
124 } // namespace rptui
125 
126 #endif /* INCLUDED_REPORTCONTROLLEROBSERVER_HXX */
127 
128 
129