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 "FormatCondition.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 <com/sun/star/text/ParagraphVertAlign.hpp>
34 #include "ReportHelperImpl.hxx"
35 #include "corestrings.hrc"
36 // =============================================================================
37 namespace reportdesign
38 {
39 // =============================================================================
40 	using namespace com::sun::star;
41 	using namespace comphelper;
42 //------------------------------------------------------------------------------
create(uno::Reference<uno::XComponentContext> const & xContext)43 uno::Reference< uno::XInterface > OFormatCondition::create(uno::Reference< uno::XComponentContext > const & xContext)
44 {
45 	return *(new OFormatCondition(xContext));
46 }
47 
DBG_NAME(rpt_OFormatCondition)48 DBG_NAME( rpt_OFormatCondition )
49 // -----------------------------------------------------------------------------
50 OFormatCondition::OFormatCondition(uno::Reference< uno::XComponentContext > const & _xContext)
51 :FormatConditionBase(m_aMutex)
52 ,FormatConditionPropertySet(_xContext,static_cast< Implements >(IMPLEMENTS_PROPERTY_SET),uno::Sequence< ::rtl::OUString >())
53 ,m_bEnabled(sal_True)
54 {
55 	DBG_CTOR( rpt_OFormatCondition,NULL);
56 }
57 // -----------------------------------------------------------------------------
~OFormatCondition()58 OFormatCondition::~OFormatCondition()
59 {
60     DBG_DTOR( rpt_OFormatCondition,NULL);
61 }
62 // -----------------------------------------------------------------------------
IMPLEMENT_FORWARD_XINTERFACE2(OFormatCondition,FormatConditionBase,FormatConditionPropertySet)63 IMPLEMENT_FORWARD_XINTERFACE2(OFormatCondition,FormatConditionBase,FormatConditionPropertySet)
64 // -----------------------------------------------------------------------------
65 void SAL_CALL OFormatCondition::dispose() throw(uno::RuntimeException)
66 {
67 	FormatConditionPropertySet::dispose();
68 	cppu::WeakComponentImplHelperBase::dispose();
69 }
70 // -----------------------------------------------------------------------------
getImplementationName_Static()71 ::rtl::OUString OFormatCondition::getImplementationName_Static(  ) throw(uno::RuntimeException)
72 {
73 	return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.OFormatCondition"));
74 }
75 
76 //--------------------------------------------------------------------------
getImplementationName()77 ::rtl::OUString SAL_CALL OFormatCondition::getImplementationName(  ) throw(uno::RuntimeException)
78 {
79 	return getImplementationName_Static();
80 }
81 //--------------------------------------------------------------------------
getSupportedServiceNames_Static()82 uno::Sequence< ::rtl::OUString > OFormatCondition::getSupportedServiceNames_Static(  ) throw(uno::RuntimeException)
83 {
84 	uno::Sequence< ::rtl::OUString > aServices(1);
85 	aServices.getArray()[0] = SERVICE_FORMATCONDITION;
86 
87 	return aServices;
88 }
89 //--------------------------------------------------------------------------
getSupportedServiceNames()90 uno::Sequence< ::rtl::OUString > SAL_CALL OFormatCondition::getSupportedServiceNames(  ) throw(uno::RuntimeException)
91 {
92 	return getSupportedServiceNames_Static();
93 }
94 //------------------------------------------------------------------------------
supportsService(const::rtl::OUString & ServiceName)95 sal_Bool SAL_CALL OFormatCondition::supportsService(const ::rtl::OUString& ServiceName) throw( uno::RuntimeException )
96 {
97 	return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_Static());
98 }
99 // -----------------------------------------------------------------------------
getPropertySetInfo()100 uno::Reference< beans::XPropertySetInfo > SAL_CALL OFormatCondition::getPropertySetInfo(  ) throw(uno::RuntimeException)
101 {
102 	return FormatConditionPropertySet::getPropertySetInfo();
103 }
104 // -----------------------------------------------------------------------------
setPropertyValue(const::rtl::OUString & aPropertyName,const uno::Any & aValue)105 void SAL_CALL OFormatCondition::setPropertyValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
106 {
107 	FormatConditionPropertySet::setPropertyValue( aPropertyName, aValue );
108 }
109 // -----------------------------------------------------------------------------
getPropertyValue(const::rtl::OUString & PropertyName)110 uno::Any SAL_CALL OFormatCondition::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
111 {
112 	return FormatConditionPropertySet::getPropertyValue( PropertyName);
113 }
114 // -----------------------------------------------------------------------------
addPropertyChangeListener(const::rtl::OUString & aPropertyName,const uno::Reference<beans::XPropertyChangeListener> & xListener)115 void SAL_CALL OFormatCondition::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
116 {
117 	FormatConditionPropertySet::addPropertyChangeListener( aPropertyName, xListener );
118 }
119 // -----------------------------------------------------------------------------
removePropertyChangeListener(const::rtl::OUString & aPropertyName,const uno::Reference<beans::XPropertyChangeListener> & aListener)120 void SAL_CALL OFormatCondition::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
121 {
122 	FormatConditionPropertySet::removePropertyChangeListener( aPropertyName, aListener );
123 }
124 // -----------------------------------------------------------------------------
addVetoableChangeListener(const::rtl::OUString & PropertyName,const uno::Reference<beans::XVetoableChangeListener> & aListener)125 void SAL_CALL OFormatCondition::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
126 {
127 	FormatConditionPropertySet::addVetoableChangeListener( PropertyName, aListener );
128 }
129 // -----------------------------------------------------------------------------
removeVetoableChangeListener(const::rtl::OUString & PropertyName,const uno::Reference<beans::XVetoableChangeListener> & aListener)130 void SAL_CALL OFormatCondition::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
131 {
132 	FormatConditionPropertySet::removeVetoableChangeListener( PropertyName, aListener );
133 }
134 // -----------------------------------------------------------------------------
135 // XFormatCondition
getEnabled()136 ::sal_Bool SAL_CALL OFormatCondition::getEnabled() throw (uno::RuntimeException)
137 {
138 	::osl::MutexGuard aGuard(m_aMutex);
139 	return m_bEnabled;
140 }
141 // -----------------------------------------------------------------------------
setEnabled(::sal_Bool _enabled)142 void SAL_CALL OFormatCondition::setEnabled( ::sal_Bool _enabled ) throw (uno::RuntimeException)
143 {
144 	set(PROPERTY_ENABLED,_enabled,m_bEnabled);
145 }
146 // -----------------------------------------------------------------------------
getFormula()147 ::rtl::OUString SAL_CALL OFormatCondition::getFormula() throw (uno::RuntimeException)
148 {
149 	::osl::MutexGuard aGuard(m_aMutex);
150 	return m_sFormula;
151 }
152 // -----------------------------------------------------------------------------
setFormula(const::rtl::OUString & _formula)153 void SAL_CALL OFormatCondition::setFormula( const ::rtl::OUString& _formula ) throw (uno::RuntimeException)
154 {
155 	set(PROPERTY_FORMULA,_formula,m_sFormula);
156 }
157 // -----------------------------------------------------------------------------
158 // XReportControlFormat
159 REPORTCONTROLFORMAT_IMPL(OFormatCondition,m_aFormatProperties)
160 // =============================================================================
161 } // namespace reportdesign
162 // =============================================================================
163