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_FUNCTION_HXX 24 #define RPT_FUNCTION_HXX 25 26 #include <cppuhelper/propertysetmixin.hxx> 27 #ifndef _COM_SUN_STAR_REPORT_XFunction_HPP_ 28 #include <com/sun/star/report/XFunction.hpp> 29 #endif 30 #include <cppuhelper/basemutex.hxx> 31 #include "ReportControlModel.hxx" 32 #include <cppuhelper/compbase2.hxx> 33 #include <com/sun/star/lang/XServiceInfo.hpp> 34 35 namespace reportdesign 36 { 37 typedef ::cppu::PropertySetMixin< com::sun::star::report::XFunction > FunctionPropertySet; 38 typedef ::cppu::WeakComponentImplHelper2< com::sun::star::report::XFunction 39 ,com::sun::star::lang::XServiceInfo > FunctionBase; 40 41 /** \class OFunction Defines the implementation of a \interface com:::sun::star::report::XFunction 42 * \ingroup reportdesign_api 43 * 44 */ 45 class OFunction : public cppu::BaseMutex, 46 public FunctionBase, 47 public FunctionPropertySet 48 { 49 com::sun::star::beans::Optional< ::rtl::OUString> m_sInitialFormula; 50 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 51 ::com::sun::star::uno::WeakReference< ::com::sun::star::report::XFunctions > m_xParent; 52 ::rtl::OUString m_sName; 53 ::rtl::OUString m_sFormula; 54 ::sal_Bool m_bPreEvaluated; 55 ::sal_Bool m_bDeepTraversing; 56 private: 57 OFunction(const OFunction&); 58 OFunction& operator=(const OFunction&); 59 set(const::rtl::OUString & _sProperty,const T & _Value,T & _member)60 template <typename T> void set( const ::rtl::OUString& _sProperty 61 ,const T& _Value 62 ,T& _member) 63 { 64 BoundListeners l; 65 { 66 ::osl::MutexGuard aGuard(m_aMutex); 67 prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); 68 _member = _Value; 69 } 70 l.notify(); 71 } 72 protected: 73 virtual ~OFunction(); 74 public: 75 explicit OFunction(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & _xContext); 76 77 DECLARE_XINTERFACE( ) 78 // ::com::sun::star::lang::XServiceInfo 79 virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 80 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); 81 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException); 82 83 static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); 84 static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); 85 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL 86 create(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext); 87 // com::sun::star::beans::XPropertySet 88 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 89 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); 90 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); 91 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); 92 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); 93 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); 94 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); 95 96 // ::com::sun::star::report::XFunction: 97 virtual ::sal_Bool SAL_CALL getPreEvaluated() throw (::com::sun::star::uno::RuntimeException); 98 virtual void SAL_CALL setPreEvaluated(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); 99 virtual ::sal_Bool SAL_CALL getDeepTraversing() throw (::com::sun::star::uno::RuntimeException); 100 virtual void SAL_CALL setDeepTraversing(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); 101 virtual ::rtl::OUString SAL_CALL getName() throw (::com::sun::star::uno::RuntimeException); 102 virtual void SAL_CALL setName(const ::rtl::OUString & the_value) throw (::com::sun::star::uno::RuntimeException); 103 virtual ::rtl::OUString SAL_CALL getFormula() throw (::com::sun::star::uno::RuntimeException); 104 virtual void SAL_CALL setFormula(const ::rtl::OUString & the_value) throw (::com::sun::star::uno::RuntimeException); 105 virtual com::sun::star::beans::Optional< ::rtl::OUString> SAL_CALL getInitialFormula() throw (::com::sun::star::uno::RuntimeException); 106 virtual void SAL_CALL setInitialFormula(const com::sun::star::beans::Optional< ::rtl::OUString> & the_value) throw (::com::sun::star::uno::RuntimeException); 107 108 // XComponent 109 virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); addEventListener(const::com::sun::star::uno::Reference<::com::sun::star::lang::XEventListener> & aListener)110 virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) 111 { 112 cppu::WeakComponentImplHelperBase::addEventListener(aListener); 113 } removeEventListener(const::com::sun::star::uno::Reference<::com::sun::star::lang::XEventListener> & aListener)114 virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw(::com::sun::star::uno::RuntimeException) 115 { 116 cppu::WeakComponentImplHelperBase::removeEventListener(aListener); 117 } 118 119 // XChild 120 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException); 121 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); 122 }; 123 } 124 #endif //RPT_FUNCTION_HXX 125 126