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