LibreOffice Module reportdesign (master)  1
FormatCondition.hxx
Go to the documentation of this file.
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 
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 
42  public FormatConditionBase,
43  public FormatConditionPropertySet
44  {
46  OUString m_sFormula;
47  bool m_bEnabled;
48  private:
49  OFormatCondition(const OFormatCondition&) = delete;
51 
52  // internally, we store PROPERTY_PARAADJUST as css::style::ParagraphAdjust, but externally the property is visible as a sal_Int16
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  }
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  }
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 
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  // css::beans::XPropertySet
111  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
112  virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
113  virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
114  virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
115  virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
116  virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
117  virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
118 
119  // XFormatCondition
120  virtual sal_Bool SAL_CALL getEnabled() override;
121  virtual void SAL_CALL setEnabled( sal_Bool _enabled ) override;
122  virtual OUString SAL_CALL getFormula() override;
123  virtual void SAL_CALL setFormula( const OUString& _formula ) override;
124 
125  // XReportControlFormat
127  // XComponent
128  virtual void SAL_CALL dispose() override;
129  virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
130  {
131  cppu::WeakComponentImplHelperBase::addEventListener(aListener);
132  }
133  virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override
134  {
135  cppu::WeakComponentImplHelperBase::removeEventListener(aListener);
136  }
137  };
138 }
139 #endif // INCLUDED_REPORTDESIGN_SOURCE_CORE_INC_FORMATCONDITION_HXX
140 
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual OUString SAL_CALL getFormula() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
mutable::osl::Mutex m_aMutex
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
#define REPORTCONTROLFORMAT_HEADER()
OFormatCondition & operator=(const OFormatCondition &)=delete
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
::cppu::WeakComponentImplHelper< css::report::XFormatCondition,css::lang::XServiceInfo > FormatConditionBase
::cppu::PropertySetMixin< css::report::XFormatCondition > FormatConditionPropertySet
virtual void SAL_CALL setEnabled(sal_Bool _enabled) override
void set(const OUString &_sProperty, bool Value, bool &_member)
virtual sal_Bool SAL_CALL getEnabled() override
unsigned char sal_Bool
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
OFormatProperties m_aFormatProperties
void set(const OUString &_sProperty, const T &Value, T &_member)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual ~OFormatCondition() override
void prepareSet(rtl::OUString const &propertyName, css::uno::Any const &oldValue, css::uno::Any const &newValue, BoundListeners *boundListeners)
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
void set(const OUString &_sProperty, sal_Int16 Value, css::style::ParagraphAdjust &_member)
OFormatCondition(const OFormatCondition &)=delete
virtual void SAL_CALL dispose() override
virtual void SAL_CALL setFormula(const OUString &_formula) override
virtual OUString SAL_CALL getImplementationName() override
#define DECLARE_XINTERFACE()