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