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