1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 #ifndef INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_FORMATCONDITION_HXX 20 #define INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_FORMATCONDITION_HXX 21 22 #include <cppuhelper/propertysetmixin.hxx> 23 #include <com/sun/star/report/XFormatCondition.hpp> 24 #include "ReportControlModel.hxx" 25 #include <comphelper/uno3.hxx> 26 #include <cppuhelper/compbase.hxx> 27 #include <cppuhelper/basemutex.hxx> 28 #include <com/sun/star/lang/XServiceInfo.hpp> 29 #include <ReportHelperDefines.hxx> 30 31 namespace reportdesign 32 { 33 typedef ::cppu::PropertySetMixin< css::report::XFormatCondition > FormatConditionPropertySet; 34 typedef ::cppu::WeakComponentImplHelper< css::report::XFormatCondition 35 ,css::lang::XServiceInfo > FormatConditionBase; 36 37 /** \class OFormatCondition Defines the implementation of a \interface com:::sun::star::report::XFormatCondition 38 * \ingroup reportdesign_api 39 * 40 */ 41 class OFormatCondition : public cppu::BaseMutex, 42 public FormatConditionBase, 43 public FormatConditionPropertySet 44 { 45 OFormatProperties m_aFormatProperties; 46 OUString m_sFormula; 47 bool m_bEnabled; 48 private: 49 OFormatCondition(const OFormatCondition&) = delete; 50 OFormatCondition& operator=(const OFormatCondition&) = delete; 51 52 // internally, we store PROPERTY_PARAADJUST as css::style::ParagraphAdjust, but externally the property is visible as a sal_Int16 set(const OUString & _sProperty,sal_Int16 Value,css::style::ParagraphAdjust & _member)53 void set( const OUString& _sProperty 54 ,sal_Int16 Value 55 ,css::style::ParagraphAdjust& _member) 56 { 57 BoundListeners l; 58 { 59 ::osl::MutexGuard aGuard(m_aMutex); 60 if ( static_cast<sal_Int16>(_member) != Value ) 61 { 62 prepareSet(_sProperty, css::uno::makeAny(static_cast<sal_Int16>(_member)), css::uno::makeAny(Value), &l); 63 _member = static_cast<css::style::ParagraphAdjust>(Value); 64 } 65 } 66 l.notify(); 67 } set(const OUString & _sProperty,const T & Value,T & _member)68 template <typename T> void set( const OUString& _sProperty 69 ,const T& Value 70 ,T& _member) 71 { 72 BoundListeners l; 73 { 74 ::osl::MutexGuard aGuard(m_aMutex); 75 if ( _member != Value ) 76 { 77 prepareSet(_sProperty, css::uno::makeAny(_member), css::uno::makeAny(Value), &l); 78 _member = Value; 79 } 80 } 81 l.notify(); 82 } set(const OUString & _sProperty,bool Value,bool & _member)83 void set( const OUString& _sProperty 84 ,bool Value 85 ,bool& _member) 86 { 87 BoundListeners l; 88 { 89 ::osl::MutexGuard aGuard(m_aMutex); 90 if ( _member != Value ) 91 { 92 prepareSet(_sProperty, css::uno::makeAny(_member), css::uno::makeAny(Value), &l); 93 _member = Value; 94 } 95 } 96 l.notify(); 97 } 98 protected: 99 virtual ~OFormatCondition() override; 100 public: 101 explicit OFormatCondition(css::uno::Reference< css::uno::XComponentContext > const & _xContext 102 ); 103 104 DECLARE_XINTERFACE( ) 105 // css::lang::XServiceInfo 106 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; 107 virtual OUString SAL_CALL getImplementationName( ) override; 108 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; 109 110 /// @throws css::uno::RuntimeException 111 static css::uno::Sequence< OUString > getSupportedServiceNames_Static(); 112 /// @throws css::uno::RuntimeException 113 static OUString getImplementationName_Static(); 114 static css::uno::Reference< css::uno::XInterface > 115 create(css::uno::Reference< css::uno::XComponentContext > const & xContext); 116 // css::beans::XPropertySet 117 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; 118 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; 119 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; 120 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; 121 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; 122 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; 123 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; 124 125 // XFormatCondition 126 virtual sal_Bool SAL_CALL getEnabled() override; 127 virtual void SAL_CALL setEnabled( sal_Bool _enabled ) override; 128 virtual OUString SAL_CALL getFormula() override; 129 virtual void SAL_CALL setFormula( const OUString& _formula ) override; 130 131 // XReportControlFormat 132 REPORTCONTROLFORMAT_HEADER() 133 // XComponent 134 virtual void SAL_CALL dispose() override; addEventListener(const css::uno::Reference<css::lang::XEventListener> & aListener)135 virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override 136 { 137 cppu::WeakComponentImplHelperBase::addEventListener(aListener); 138 } removeEventListener(const css::uno::Reference<css::lang::XEventListener> & aListener)139 virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override 140 { 141 cppu::WeakComponentImplHelperBase::removeEventListener(aListener); 142 } 143 }; 144 } 145 #endif // INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_FORMATCONDITION_HXX 146 147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 148