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