merge the formfield patch from ooo-build
[ooovba.git] / reportdesign / source / core / api / Function.cxx
blob8d3714582b92ae49e9c80e26be0bd30f57edb622
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: Function.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "Function.hxx"
31 #include <com/sun/star/beans/PropertyAttribute.hpp>
32 #ifndef REPORTDESIGN_SHARED_CORESTRINGS_HRC
33 #include "corestrings.hrc"
34 #endif
35 #include <tools/debug.hxx>
36 #include <connectivity/dbtools.hxx>
37 #include <comphelper/sequence.hxx>
38 #include <comphelper/property.hxx>
39 #include "Tools.hxx"
40 #include "corestrings.hrc"
41 // =============================================================================
42 namespace reportdesign
44 // =============================================================================
45 using namespace com::sun::star;
46 using namespace comphelper;
47 //------------------------------------------------------------------------------
48 uno::Reference< uno::XInterface > OFunction::create(uno::Reference< uno::XComponentContext > const & xContext)
50 return *(new OFunction(xContext));
53 DBG_NAME( rpt_OFunction )
54 // -----------------------------------------------------------------------------
55 OFunction::OFunction(uno::Reference< uno::XComponentContext > const & _xContext)
56 :FunctionBase(m_aMutex)
57 ,FunctionPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< ::rtl::OUString >())
58 ,m_xContext(_xContext)
59 ,m_bPreEvaluated(sal_False)
60 ,m_bDeepTraversing(sal_False)
62 m_sInitialFormula.IsPresent = sal_False;
63 DBG_CTOR( rpt_OFunction,NULL);
65 // -----------------------------------------------------------------------------
66 OFunction::~OFunction()
68 DBG_DTOR( rpt_OFunction,NULL);
70 // -----------------------------------------------------------------------------
71 IMPLEMENT_FORWARD_XINTERFACE2(OFunction,FunctionBase,FunctionPropertySet)
72 // -----------------------------------------------------------------------------
73 void SAL_CALL OFunction::dispose() throw(uno::RuntimeException)
75 FunctionPropertySet::dispose();
76 cppu::WeakComponentImplHelperBase::dispose();
78 // -----------------------------------------------------------------------------
79 ::rtl::OUString OFunction::getImplementationName_Static( ) throw(uno::RuntimeException)
81 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OFunction"));
84 //--------------------------------------------------------------------------
85 ::rtl::OUString SAL_CALL OFunction::getImplementationName( ) throw(uno::RuntimeException)
87 return getImplementationName_Static();
89 //--------------------------------------------------------------------------
90 uno::Sequence< ::rtl::OUString > OFunction::getSupportedServiceNames_Static( ) throw(uno::RuntimeException)
92 uno::Sequence< ::rtl::OUString > aServices(1);
93 aServices.getArray()[0] = SERVICE_FUNCTION;
95 return aServices;
97 //--------------------------------------------------------------------------
98 uno::Sequence< ::rtl::OUString > SAL_CALL OFunction::getSupportedServiceNames( ) throw(uno::RuntimeException)
100 return getSupportedServiceNames_Static();
102 //------------------------------------------------------------------------------
103 sal_Bool SAL_CALL OFunction::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException )
105 return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static());
107 // -----------------------------------------------------------------------------
108 uno::Reference< beans::XPropertySetInfo > SAL_CALL OFunction::getPropertySetInfo( ) throw(uno::RuntimeException)
110 return FunctionPropertySet::getPropertySetInfo();
112 // -----------------------------------------------------------------------------
113 void SAL_CALL OFunction::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
115 FunctionPropertySet::setPropertyValue( aPropertyName, aValue );
117 // -----------------------------------------------------------------------------
118 uno::Any SAL_CALL OFunction::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
120 return FunctionPropertySet::getPropertyValue( PropertyName);
122 // -----------------------------------------------------------------------------
123 void SAL_CALL OFunction::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
125 FunctionPropertySet::addPropertyChangeListener( aPropertyName, xListener );
127 // -----------------------------------------------------------------------------
128 void SAL_CALL OFunction::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
130 FunctionPropertySet::removePropertyChangeListener( aPropertyName, aListener );
132 // -----------------------------------------------------------------------------
133 void SAL_CALL OFunction::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
135 FunctionPropertySet::addVetoableChangeListener( PropertyName, aListener );
137 // -----------------------------------------------------------------------------
138 void SAL_CALL OFunction::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
140 FunctionPropertySet::removeVetoableChangeListener( PropertyName, aListener );
142 // -----------------------------------------------------------------------------
143 // report::XFunction:
144 ::sal_Bool SAL_CALL OFunction::getPreEvaluated() throw (uno::RuntimeException)
146 osl::MutexGuard g(m_aMutex);
147 return m_bPreEvaluated;
149 // -----------------------------------------------------------------------------
151 void SAL_CALL OFunction::setPreEvaluated(::sal_Bool the_value) throw (uno::RuntimeException)
153 set(PROPERTY_PREEVALUATED,the_value,m_bPreEvaluated);
155 // -----------------------------------------------------------------------------
156 ::sal_Bool SAL_CALL OFunction::getDeepTraversing() throw (uno::RuntimeException)
158 osl::MutexGuard g(m_aMutex);
159 return m_bDeepTraversing;
161 // -----------------------------------------------------------------------------
163 void SAL_CALL OFunction::setDeepTraversing(::sal_Bool the_value) throw (uno::RuntimeException)
165 set(PROPERTY_DEEPTRAVERSING,the_value,m_bDeepTraversing);
167 // -----------------------------------------------------------------------------
169 ::rtl::OUString SAL_CALL OFunction::getName() throw (uno::RuntimeException)
171 osl::MutexGuard g(m_aMutex);
172 return m_sName;
174 // -----------------------------------------------------------------------------
176 void SAL_CALL OFunction::setName(const ::rtl::OUString & the_value) throw (uno::RuntimeException)
178 set(PROPERTY_NAME,the_value,m_sName);
180 // -----------------------------------------------------------------------------
181 ::rtl::OUString SAL_CALL OFunction::getFormula() throw (uno::RuntimeException)
183 osl::MutexGuard g(m_aMutex);
184 return m_sFormula;
186 // -----------------------------------------------------------------------------
187 void SAL_CALL OFunction::setFormula(const ::rtl::OUString & the_value) throw (uno::RuntimeException)
189 set(PROPERTY_FORMULA,the_value,m_sFormula);
191 // -----------------------------------------------------------------------------
192 beans::Optional< ::rtl::OUString> SAL_CALL OFunction::getInitialFormula() throw (uno::RuntimeException)
194 osl::MutexGuard g(m_aMutex);
195 return m_sInitialFormula;
197 // -----------------------------------------------------------------------------
198 void SAL_CALL OFunction::setInitialFormula(const beans::Optional< ::rtl::OUString> & the_value) throw (uno::RuntimeException)
200 set(PROPERTY_INITIALFORMULA,the_value,m_sInitialFormula);
202 // -----------------------------------------------------------------------------
203 // XChild
204 uno::Reference< uno::XInterface > SAL_CALL OFunction::getParent( ) throw (uno::RuntimeException)
206 osl::MutexGuard g(m_aMutex);
207 return m_xParent;
209 // -----------------------------------------------------------------------------
210 void SAL_CALL OFunction::setParent( const uno::Reference< uno::XInterface >& Parent ) throw (lang::NoSupportException, uno::RuntimeException)
212 osl::MutexGuard g(m_aMutex);
213 if ( Parent.is() )
215 uno::Reference< report::XFunctions> xFunctions(Parent,uno::UNO_QUERY_THROW);
216 m_xParent = xFunctions;
218 else
219 m_xParent = uno::WeakReference< report::XFunctions >();
221 // -----------------------------------------------------------------------------
223 // =============================================================================
224 } // namespace reportdesign
225 // =============================================================================