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 #include "Function.hxx" 28 #include <com/sun/star/beans/PropertyAttribute.hpp> 29 #ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC 30 #include "corestrings.hrc" 31 #endif 32 #include <tools/debug.hxx> 33 #include <connectivity/dbtools.hxx> 34 #include <comphelper/sequence.hxx> 35 #include <comphelper/property.hxx> 36 #include "Tools.hxx" 37 #include "corestrings.hrc" 38 // ============================================================================= 39 namespace reportdesign 40 { 41 // ============================================================================= 42 using namespace com::sun::star; 43 using namespace comphelper; 44 //------------------------------------------------------------------------------ 45 uno::Reference< uno::XInterface > OFunction::create(uno::Reference< uno::XComponentContext > const & xContext) 46 { 47 return *(new OFunction(xContext)); 48 } 49 50 DBG_NAME( rpt_OFunction ) 51 // ----------------------------------------------------------------------------- 52 OFunction::OFunction(uno::Reference< uno::XComponentContext > const & _xContext) 53 :FunctionBase(m_aMutex) 54 ,FunctionPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< ::rtl::OUString >()) 55 ,m_xContext(_xContext) 56 ,m_bPreEvaluated(sal_False) 57 ,m_bDeepTraversing(sal_False) 58 { 59 m_sInitialFormula.IsPresent = sal_False; 60 DBG_CTOR( rpt_OFunction,NULL); 61 } 62 // ----------------------------------------------------------------------------- 63 OFunction::~OFunction() 64 { 65 DBG_DTOR( rpt_OFunction,NULL); 66 } 67 // ----------------------------------------------------------------------------- 68 IMPLEMENT_FORWARD_XINTERFACE2(OFunction,FunctionBase,FunctionPropertySet) 69 // ----------------------------------------------------------------------------- 70 void SAL_CALL OFunction::dispose() throw(uno::RuntimeException) 71 { 72 FunctionPropertySet::dispose(); 73 cppu::WeakComponentImplHelperBase::dispose(); 74 } 75 // ----------------------------------------------------------------------------- 76 ::rtl::OUString OFunction::getImplementationName_Static( ) throw(uno::RuntimeException) 77 { 78 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OFunction")); 79 } 80 81 //-------------------------------------------------------------------------- 82 ::rtl::OUString SAL_CALL OFunction::getImplementationName( ) throw(uno::RuntimeException) 83 { 84 return getImplementationName_Static(); 85 } 86 //-------------------------------------------------------------------------- 87 uno::Sequence< ::rtl::OUString > OFunction::getSupportedServiceNames_Static( ) throw(uno::RuntimeException) 88 { 89 uno::Sequence< ::rtl::OUString > aServices(1); 90 aServices.getArray()[0] = SERVICE_FUNCTION; 91 92 return aServices; 93 } 94 //-------------------------------------------------------------------------- 95 uno::Sequence< ::rtl::OUString > SAL_CALL OFunction::getSupportedServiceNames( ) throw(uno::RuntimeException) 96 { 97 return getSupportedServiceNames_Static(); 98 } 99 //------------------------------------------------------------------------------ 100 sal_Bool SAL_CALL OFunction::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException ) 101 { 102 return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static()); 103 } 104 // ----------------------------------------------------------------------------- 105 uno::Reference< beans::XPropertySetInfo > SAL_CALL OFunction::getPropertySetInfo( ) throw(uno::RuntimeException) 106 { 107 return FunctionPropertySet::getPropertySetInfo(); 108 } 109 // ----------------------------------------------------------------------------- 110 void SAL_CALL OFunction::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 111 { 112 FunctionPropertySet::setPropertyValue( aPropertyName, aValue ); 113 } 114 // ----------------------------------------------------------------------------- 115 uno::Any SAL_CALL OFunction::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 116 { 117 return FunctionPropertySet::getPropertyValue( PropertyName); 118 } 119 // ----------------------------------------------------------------------------- 120 void SAL_CALL OFunction::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 121 { 122 FunctionPropertySet::addPropertyChangeListener( aPropertyName, xListener ); 123 } 124 // ----------------------------------------------------------------------------- 125 void SAL_CALL OFunction::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 126 { 127 FunctionPropertySet::removePropertyChangeListener( aPropertyName, aListener ); 128 } 129 // ----------------------------------------------------------------------------- 130 void SAL_CALL OFunction::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 131 { 132 FunctionPropertySet::addVetoableChangeListener( PropertyName, aListener ); 133 } 134 // ----------------------------------------------------------------------------- 135 void SAL_CALL OFunction::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 136 { 137 FunctionPropertySet::removeVetoableChangeListener( PropertyName, aListener ); 138 } 139 // ----------------------------------------------------------------------------- 140 // report::XFunction: 141 ::sal_Bool SAL_CALL OFunction::getPreEvaluated() throw (uno::RuntimeException) 142 { 143 osl::MutexGuard g(m_aMutex); 144 return m_bPreEvaluated; 145 } 146 // ----------------------------------------------------------------------------- 147 148 void SAL_CALL OFunction::setPreEvaluated(::sal_Bool the_value) throw (uno::RuntimeException) 149 { 150 set(PROPERTY_PREEVALUATED,the_value,m_bPreEvaluated); 151 } 152 // ----------------------------------------------------------------------------- 153 ::sal_Bool SAL_CALL OFunction::getDeepTraversing() throw (uno::RuntimeException) 154 { 155 osl::MutexGuard g(m_aMutex); 156 return m_bDeepTraversing; 157 } 158 // ----------------------------------------------------------------------------- 159 160 void SAL_CALL OFunction::setDeepTraversing(::sal_Bool the_value) throw (uno::RuntimeException) 161 { 162 set(PROPERTY_DEEPTRAVERSING,the_value,m_bDeepTraversing); 163 } 164 // ----------------------------------------------------------------------------- 165 166 ::rtl::OUString SAL_CALL OFunction::getName() throw (uno::RuntimeException) 167 { 168 osl::MutexGuard g(m_aMutex); 169 return m_sName; 170 } 171 // ----------------------------------------------------------------------------- 172 173 void SAL_CALL OFunction::setName(const ::rtl::OUString & the_value) throw (uno::RuntimeException) 174 { 175 set(PROPERTY_NAME,the_value,m_sName); 176 } 177 // ----------------------------------------------------------------------------- 178 ::rtl::OUString SAL_CALL OFunction::getFormula() throw (uno::RuntimeException) 179 { 180 osl::MutexGuard g(m_aMutex); 181 return m_sFormula; 182 } 183 // ----------------------------------------------------------------------------- 184 void SAL_CALL OFunction::setFormula(const ::rtl::OUString & the_value) throw (uno::RuntimeException) 185 { 186 set(PROPERTY_FORMULA,the_value,m_sFormula); 187 } 188 // ----------------------------------------------------------------------------- 189 beans::Optional< ::rtl::OUString> SAL_CALL OFunction::getInitialFormula() throw (uno::RuntimeException) 190 { 191 osl::MutexGuard g(m_aMutex); 192 return m_sInitialFormula; 193 } 194 // ----------------------------------------------------------------------------- 195 void SAL_CALL OFunction::setInitialFormula(const beans::Optional< ::rtl::OUString> & the_value) throw (uno::RuntimeException) 196 { 197 set(PROPERTY_INITIALFORMULA,the_value,m_sInitialFormula); 198 } 199 // ----------------------------------------------------------------------------- 200 // XChild 201 uno::Reference< uno::XInterface > SAL_CALL OFunction::getParent( ) throw (uno::RuntimeException) 202 { 203 osl::MutexGuard g(m_aMutex); 204 return m_xParent; 205 } 206 // ----------------------------------------------------------------------------- 207 void SAL_CALL OFunction::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException) 208 { 209 osl::MutexGuard g(m_aMutex); 210 if ( Parent.is() ) 211 { 212 uno::Reference< report::XFunctions> xFunctions(Parent,uno::UNO_QUERY_THROW); 213 m_xParent = xFunctions; 214 } 215 else 216 m_xParent = uno::WeakReference< report::XFunctions >(); 217 } 218 // ----------------------------------------------------------------------------- 219 220 // ============================================================================= 221 } // namespace reportdesign 222 // ============================================================================= 223