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 RPT_SHAPE_HXX
24 #define RPT_SHAPE_HXX
25 
26 #include <cppuhelper/propertysetmixin.hxx>
27 #include <com/sun/star/report/XShape.hpp>
28 #include "ReportControlModel.hxx"
29 #include <cppuhelper/compbase2.hxx>
30 #include <comphelper/broadcasthelper.hxx>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include "ReportHelperDefines.hxx"
33 #include <comphelper/propagg.hxx>
34 #include <memory>
35 
36 namespace reportdesign
37 {
38 	typedef ::cppu::PropertySetMixin<		 com::sun::star::report::XShape	> ShapePropertySet;
39 	typedef ::cppu::WeakComponentImplHelper2<    com::sun::star::report::XShape
40 												,com::sun::star::lang::XServiceInfo	> ShapeBase;
41 
42     /** \class OShape Defines the implementation of a \interface com:::sun::star::report::XShape
43 	 * \ingroup reportdesign_api
44 	 *
45 	 */
46 	class OShape :	public comphelper::OBaseMutex,
47 					public ShapeBase,
48 					public ShapePropertySet
49 	{
50         friend class OShapeHelper;
51         ::std::auto_ptr< ::comphelper::OPropertyArrayAggregationHelper> m_pAggHelper;
52 		OReportControlModel                                             m_aProps;
53         com::sun::star::drawing::HomogenMatrix3                         m_Transformation;
54         ::sal_Int32                                                     m_nZOrder;
55         ::sal_Bool                                                      m_bOpaque;
56 
57         ::rtl::OUString                                                 m_sServiceName;
58         ::rtl::OUString                                                 m_CustomShapeEngine;
59         ::rtl::OUString                                                 m_CustomShapeData;
60         com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >
61                                                                         m_CustomShapeGeometry;
62 
63 	private:
64 		OShape(const OShape&);
65 		OShape& operator=(const OShape&);
66 
set(const::rtl::OUString & _sProperty,const T & _Value,T & _member)67 		template <typename T> void set(	 const ::rtl::OUString& _sProperty
68 										,const T& _Value
69 										,T& _member)
70 		{
71 			BoundListeners l;
72 			{
73 				::osl::MutexGuard aGuard(m_aMutex);
74 				prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l);
75 				_member = _Value;
76 			}
77 			l.notify();
78 		}
79         void checkIndex(sal_Int32 _nIndex);
80         cppu::IPropertyArrayHelper& getInfoHelper();
81 	protected:
82 		virtual ~OShape();
83 	public:
84 		explicit OShape(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext);
85         explicit OShape(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext
86                         ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _xFactory
87                         ,::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _xShape
88                         ,const ::rtl::OUString& _sServiceName);
89 
90 		DECLARE_XINTERFACE( )
91 		// ::com::sun::star::lang::XServiceInfo
92 		virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
93 		virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
94 		virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
95 
96 		static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
97 		static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException );
98         static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
99 			create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext);
100 		// com::sun::star::beans::XPropertySet
101 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
102 		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);
103 		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);
104 		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);
105 		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);
106 		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);
107 		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);
108 
109 		// XReportComponent
110         REPORTCOMPONENT_HEADER()
111 
112         // XShape
113         SHAPE_HEADER()
114 
115         virtual ::rtl::OUString SAL_CALL getCustomShapeEngine() throw (::com::sun::star::uno::RuntimeException);
116         virtual void SAL_CALL setCustomShapeEngine( const ::rtl::OUString& _customshapeengine ) throw (::com::sun::star::uno::RuntimeException);
117         virtual ::rtl::OUString SAL_CALL getCustomShapeData() throw (::com::sun::star::uno::RuntimeException);
118         virtual void SAL_CALL setCustomShapeData( const ::rtl::OUString& _customshapedata ) throw (::com::sun::star::uno::RuntimeException);
119         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getCustomShapeGeometry() throw (::com::sun::star::uno::RuntimeException);
120         virtual void SAL_CALL setCustomShapeGeometry( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _customshapegeometry ) throw (::com::sun::star::uno::RuntimeException);
121 
122         virtual ::sal_Bool SAL_CALL getOpaque() throw (::com::sun::star::uno::RuntimeException);
123         virtual void SAL_CALL setOpaque( ::sal_Bool _opaque ) throw (::com::sun::star::uno::RuntimeException);
124 
125         // XShapeDescriptor
126         virtual ::rtl::OUString SAL_CALL getShapeType(  ) throw (::com::sun::star::uno::RuntimeException);
127 
128 		// XReportControlModel
129 		REPORTCONTROLMODEL_HEADER()
130 
131         // XReportControlFormat
132         REPORTCONTROLFORMAT_HEADER()
133 		// XShape
134         virtual ::sal_Int32 SAL_CALL getZOrder() throw (::com::sun::star::uno::RuntimeException);
135         virtual void SAL_CALL setZOrder( ::sal_Int32 _zorder ) throw (::com::sun::star::uno::RuntimeException);
136         virtual ::com::sun::star::drawing::HomogenMatrix3 SAL_CALL getTransformation() throw (::com::sun::star::uno::RuntimeException);
137         virtual void SAL_CALL setTransformation( const ::com::sun::star::drawing::HomogenMatrix3& _transformation ) throw (::com::sun::star::uno::RuntimeException);
138 
139 		// XCloneable
140 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone(  ) throw (::com::sun::star::uno::RuntimeException);
141 
142 		// XComponent
143 		virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
addEventListener(const::com::sun::star::uno::Reference<::com::sun::star::lang::XEventListener> & aListener)144 		virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException)
145 		{
146 			cppu::WeakComponentImplHelperBase::addEventListener(aListener);
147 		}
removeEventListener(const::com::sun::star::uno::Reference<::com::sun::star::lang::XEventListener> & aListener)148 		virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException)
149 		{
150 			cppu::WeakComponentImplHelperBase::removeEventListener(aListener);
151 		}
152 
153 		// XChild
154 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent(  ) throw (::com::sun::star::uno::RuntimeException);
155 		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);
156 
157         // XContainer
158 		virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
159 		virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
160 
161 		// XElementAccess
162 		virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw (::com::sun::star::uno::RuntimeException);
163 		virtual ::sal_Bool SAL_CALL hasElements(  ) throw (::com::sun::star::uno::RuntimeException);
164 
165 		// XIndexReplace
166 		virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
167 
168 		// XIndexContainer
169 		virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
170 		virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
171 
172 		// XIndexAccess
173 		virtual ::sal_Int32 SAL_CALL getCount(  ) throw (::com::sun::star::uno::RuntimeException);
174 		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);
175 	};
176 }
177 #endif //RPT_SHAPE_HXX
178 
179