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