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 REPORTDESIGN_API_SECTION_HXX
24 #define REPORTDESIGN_API_SECTION_HXX
25 
26 #include <com/sun/star/report/XSection.hpp>
27 #include <cppuhelper/compbase3.hxx>
28 #include <comphelper/broadcasthelper.hxx>
29 #include <comphelper/uno3.hxx>
30 #include <comphelper/types.hxx>
31 #include <cppuhelper/propertysetmixin.hxx>
32 #include <com/sun/star/uno/XComponentContext.hpp>
33 #include <com/sun/star/drawing/XShapes.hpp>
34 #include <com/sun/star/uno/XAggregation.hpp>
35 #include <comphelper/stl_types.hxx>
36 #include <comphelper/implementationreference.hxx>
37 #include <com/sun/star/lang/XUnoTunnel.hpp>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 
40 namespace reportdesign
41 {
42     typedef ::cppu::WeakComponentImplHelper3<   ::com::sun::star::report::XSection
43                                             ,   ::com::sun::star::lang::XServiceInfo
44                                             ,	::com::sun::star::lang::XUnoTunnel> SectionBase;
45 	typedef ::cppu::PropertySetMixin<com::sun::star::report::XSection> SectionPropertySet;
46 
47 	class OSection : public comphelper::OMutexAndBroadcastHelper,
48 					public SectionBase,
49 					public SectionPropertySet
50 	{
51         ::cppu::OInterfaceContainerHelper													m_aContainerListeners;
52 		::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >		m_xContext;
53         ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >		        m_xDrawPage;
54         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >             m_xProxy;
55 		::com::sun::star::uno::WeakReference< ::com::sun::star::report::XGroup >			m_xGroup;
56 		::com::sun::star::uno::WeakReference< ::com::sun::star::report::XReportDefinition > m_xReportDefinition;
57 		::rtl::OUString 																	m_sName;
58 		::rtl::OUString 																	m_sConditionalPrintExpression;
59 		::sal_uInt32																		m_nHeight;
60 		::sal_Int32 																		m_nBackgroundColor;
61 		::sal_Int16 																		m_nForceNewPage;
62 		::sal_Int16 																		m_nNewRowOrCol;
63 		::sal_Bool 																			m_bKeepTogether;
64 		::sal_Bool 																			m_bCanGrow;
65 		::sal_Bool 																			m_bCanShrink;
66 		::sal_Bool 																			m_bRepeatSection;
67 		::sal_Bool																			m_bVisible;
68         ::sal_Bool																			m_bBacktransparent;
69         bool                                                                                m_bInRemoveNotify;
70         bool                                                                                m_bInInsertNotify;
71 
72 	private:
73 		OSection(const OSection&);
74 		OSection& operator=(const OSection&);
75 
set(const::rtl::OUString & _sProperty,const T & _Value,T & _member)76 		template <typename T> void set(	 const ::rtl::OUString& _sProperty
77 										,const T& _Value
78 										,T& _member)
79 		{
80 			BoundListeners l;
81 			{
82 				::osl::MutexGuard aGuard(m_aMutex);
83                 if ( _member != _Value )
84                 {
85 				    prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l);
86 				    _member = _Value;
87                 }
88 			}
89 			l.notify();
90 		}
91 
92         /** checks if this section is either the page header or footer and if so it throws an UnknownPropertyException
93         *
94         */
95         void checkNotPageHeaderFooter();
96 
97         void init();
98 	protected:
99         // TODO: VirtualFunctionFinder: This is virtual function!
100         //
101         virtual ~OSection();
102 
103         /** this function is called upon disposing the component
104         */
105         // TODO: VirtualFunctionFinder: This is virtual function!
106         //
107         virtual void SAL_CALL disposing();
108 	public:
109 		typedef ::comphelper::ImplementationReference< OSection	,::com::sun::star::report::XSection,::com::sun::star::uno::XWeak > TSection;
110 
111 		OSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xParent
112 				,const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& context,bool _bPageSection=false);
113 		OSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xParent
114 				,const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& context,bool _bPageSection=false);
115 
116 		DECLARE_XINTERFACE( )
117 
118 		// ::com::sun::star::lang::XServiceInfo
119 		virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
120 		virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
121 		virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
122 
123 		static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
124 		// com::sun::star::beans::XPropertySet
125 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
126 		virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
127 		virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
128 		virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
129 		virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
130 		virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
131 		virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
132 
133 		// XSection
134 		virtual ::sal_Bool SAL_CALL getVisible() throw (::com::sun::star::uno::RuntimeException);
135 		virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (::com::sun::star::uno::RuntimeException);
136 		virtual ::rtl::OUString SAL_CALL getName() throw (::com::sun::star::uno::RuntimeException);
137 		virtual void SAL_CALL setName( const ::rtl::OUString& _name ) throw (::com::sun::star::uno::RuntimeException);
138 		virtual ::sal_uInt32 SAL_CALL getHeight() throw (::com::sun::star::uno::RuntimeException);
139 		virtual void SAL_CALL setHeight( ::sal_uInt32 _height ) throw (::com::sun::star::uno::RuntimeException);
140 		virtual ::sal_Int32 SAL_CALL getBackColor() throw (::com::sun::star::uno::RuntimeException);
141 		virtual void SAL_CALL setBackColor( ::sal_Int32 _backgroundcolor ) throw (::com::sun::star::uno::RuntimeException);
142         virtual ::sal_Bool SAL_CALL getBackTransparent() throw (::com::sun::star::uno::RuntimeException);
143         virtual void SAL_CALL setBackTransparent( ::sal_Bool _backtransparent ) throw (::com::sun::star::uno::RuntimeException);
144 		virtual ::rtl::OUString SAL_CALL getConditionalPrintExpression() throw (::com::sun::star::uno::RuntimeException);
145 		virtual void SAL_CALL setConditionalPrintExpression( const ::rtl::OUString& _conditionalprintexpression ) throw (::com::sun::star::uno::RuntimeException);
146 		virtual ::sal_Int16 SAL_CALL getForceNewPage() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
147 		virtual void SAL_CALL setForceNewPage( ::sal_Int16 _forcenewpage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
148 		virtual ::sal_Int16 SAL_CALL getNewRowOrCol() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
149 		virtual void SAL_CALL setNewRowOrCol( ::sal_Int16 _newroworcol ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
150 		virtual ::sal_Bool SAL_CALL getKeepTogether() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
151 		virtual void SAL_CALL setKeepTogether( ::sal_Bool _keeptogether ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
152 		virtual ::sal_Bool SAL_CALL getCanGrow() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
153 		virtual void SAL_CALL setCanGrow( ::sal_Bool _cangrow ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
154 		virtual ::sal_Bool SAL_CALL getCanShrink() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
155 		virtual void SAL_CALL setCanShrink( ::sal_Bool _canshrink ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
156 		virtual ::sal_Bool SAL_CALL getRepeatSection() throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
157 		virtual void SAL_CALL setRepeatSection( ::sal_Bool _repeatsection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
158 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup > SAL_CALL getGroup() throw (::com::sun::star::uno::RuntimeException);
159 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition > SAL_CALL getReportDefinition() throw (::com::sun::star::uno::RuntimeException);
160 
161 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent > SAL_CALL createReportComponent( const ::rtl::OUString& _sReportComponentSpecifier ) throw (::com::sun::star::uno::Exception, ::com::sun::star::lang::IllegalArgumentException,::com::sun::star::uno::RuntimeException);
162 	    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableReportComponentNames(  ) throw (::com::sun::star::uno::RuntimeException);
163 		// XChild
164 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent(  ) throw (::com::sun::star::uno::RuntimeException);
165 		virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
166 		// XContainer
167 		virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
168 		virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
169 		// XElementAccess
170 		virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw (::com::sun::star::uno::RuntimeException);
171 		virtual ::sal_Bool SAL_CALL hasElements(  ) throw (::com::sun::star::uno::RuntimeException);
172         // XShapes
173         virtual void SAL_CALL add( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException);
174         virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw (::com::sun::star::uno::RuntimeException);
175 		// XIndexAccess
176 		virtual ::sal_Int32 SAL_CALL getCount(  ) throw (::com::sun::star::uno::RuntimeException);
177 		virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
178 		// XEnumerationAccess
179 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(  ) throw (::com::sun::star::uno::RuntimeException);
180 
181         // XComponent
182 		virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
addEventListener(const::com::sun::star::uno::Reference<::com::sun::star::lang::XEventListener> & aListener)183 		virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException)
184 		{
185 			cppu::WeakComponentImplHelperBase::addEventListener(aListener);
186 		}
removeEventListener(const::com::sun::star::uno::Reference<::com::sun::star::lang::XEventListener> & aListener)187 		virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException)
188 		{
189 			cppu::WeakComponentImplHelperBase::removeEventListener(aListener);
190 		}
191 
192         // com::sun::star::lang::XUnoTunnel
193 		virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
194         static OSection* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent );
195         static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
196 
197 		static void lcl_copySection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSource
198 										 ,::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xDest);
199 
200         void notifyElementAdded(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape);
201         void notifyElementRemoved(const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape);
202 	};
203 }
204 #endif //REPORTDESIGN_API_SECTION_HXX
205