LibreOffice Module reportdesign (master)  1
GeometryHandler.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 
20 #ifndef INCLUDED_REPORTDESIGN_SOURCE_UI_INC_GEOMETRYHANDLER_HXX
21 #define INCLUDED_REPORTDESIGN_SOURCE_UI_INC_GEOMETRYHANDLER_HXX
22 
23 #include <sal/config.h>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <cppuhelper/compbase.hxx>
26 #include <cppuhelper/basemutex.hxx>
27 #include <com/sun/star/awt/Point.hpp>
28 #include <com/sun/star/awt/Size.hpp>
29 #include <com/sun/star/inspection/XPropertyHandler.hpp>
30 #include <com/sun/star/script/XTypeConverter.hpp>
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/report/XFunctionsSupplier.hpp>
34 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
35 #include <com/sun/star/sdbc/XRowSet.hpp>
36 #include <map>
37 #include <memory>
38 #include <string_view>
39 
40 #include <comphelper/stl_types.hxx>
42 
43 
44 namespace rptui
45 {
46 
47 
49  {
50  css::beans::Optional< OUString> m_sInitialFormula;
51  OUString m_sName;
52  OUString m_sSearchString;
53  OUString m_sFormula;
55 
56  const OUString& getName() const { return m_sName; }
57  } ;
58 
60  typedef ::std::pair< css::uno::Reference< css::report::XFunction>, css::uno::Reference< css::report::XFunctionsSupplier> > TFunctionPair;
61  typedef ::std::multimap< OUString,TFunctionPair, ::comphelper::UStringMixLess > TFunctions;
62  typedef ::comphelper::OSimpleListenerContainer < css::beans::XPropertyChangeListener
63  , css::beans::PropertyChangeEvent
65  typedef ::cppu::WeakComponentImplHelper< css::inspection::XPropertyHandler
66  , css::beans::XPropertyChangeListener
67  , css::lang::XServiceInfo> GeometryHandler_Base;
68 
70  private ::cppu::BaseMutex,
71  public GeometryHandler_Base
72  {
77 
86  bool impl_dialogFilter_nothrow( OUString& _out_rSelectedClause, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
87 
93  sal_uInt32 impl_getDataFieldType_throw(const OUString& _sDataField = OUString()) const;
94 
95  css::uno::Any getConstantValue(bool bToControlValue,const char** pResId,const css::uno::Any& _aValue,const OUString& _sConstantName,const OUString & PropertyName );
96  css::beans::Property getProperty(const OUString & PropertyName);
97  static void implCreateListLikeControl(
98  const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory
99  ,css::inspection::LineDescriptor & out_Descriptor
100  ,const char** pResId
101  ,bool _bReadOnlyControl
102  ,bool _bTrueIfListBoxFalseIfComboBox
103  );
104  static void implCreateListLikeControl(
105  const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory
106  ,css::inspection::LineDescriptor & out_Descriptor
107  ,const ::std::vector< OUString>& _aEntries
108  ,bool _bReadOnlyControl
109  ,bool _bTrueIfListBoxFalseIfComboBox
110  );
111  void checkPosAndSize( const css::awt::Point& _aNewPos,
112  const css::awt::Size& _aSize);
113 
114  OUString impl_convertToFormula( const css::uno::Any& _rControlValue );
115 
116  void impl_initFieldList_nothrow( css::uno::Sequence< OUString >& _rFieldNames ) const;
117 
124  void impl_createFunction(const OUString& _sFunctionName,std::u16string_view _sDataField,const DefaultFunction& _aFunction);
125 
132  bool impl_isCounterFunction_throw(const OUString& _sQuotedFunctionName,OUString& Out_sScope) const;
133 
141  void resetOwnProperties(::osl::ResettableMutexGuard& _aGuard,const OUString& _sOldFunctionName,const OUString& _sOldScope,const sal_uInt32 _nOldDataFieldType);
142 
148  bool impl_isDataField(const OUString& _sName) const;
149 
154  void impl_fillFormulaList_nothrow(::std::vector< OUString >& _out_rList) const;
155 
160  void impl_fillScopeList_nothrow(::std::vector< OUString >& _out_rList) const;
161 
166  void impl_fillMimeTypes_nothrow(::std::vector< OUString >& _out_rList) const;
167 
172  OUString impl_ConvertMimeTypeToUI_nothrow(const OUString& _sMimetype) const;
173 
178  OUString impl_ConvertUIToMimeType_nothrow(const OUString& _sUIName) const;
179 
185  css::uno::Reference< css::report::XFunctionsSupplier> fillScope_throw(OUString& _rsNamePostfix);
186 
195  bool isDefaultFunction(const OUString& _sQuotedFunction
196  ,OUString& Out_rDataField
197  ,const css::uno::Reference< css::report::XFunctionsSupplier>& _xFunctionsSupplier = css::uno::Reference< css::report::XFunctionsSupplier>()
198  ,bool _bSet = false) const;
199 
207  bool impl_isDefaultFunction_nothrow( const css::uno::Reference< css::report::XFunction>& _xFunction
208  ,OUString& _rDataField
209  ,OUString& _rsDefaultFunctionName) const;
210 
214  void loadDefaultFunctions();
215 
223  void createDefaultFunction(::osl::ResettableMutexGuard& _aGuard ,const OUString& _sFunction,std::u16string_view _sDataField);
224 
225  void removeFunction();
226 
227  class OBlocker
228  {
229  bool& m_bIn;
230  public:
231  OBlocker(bool& _bIn) : m_bIn(_bIn){ m_bIn = true; }
232  ~OBlocker() { m_bIn = false; }
233  };
234 
235 
236  // XEventListener
237  virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
238  // XPropertyChangeListener
239  virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override;
240 
241  public:
242  explicit GeometryHandler(css::uno::Reference< css::uno::XComponentContext > const & context);
243 
244  // XServiceInfo
245  virtual OUString SAL_CALL getImplementationName( ) override;
246  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
247  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
248 
249  // css::lang::XComponent:
250  virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & xListener) override;
251  virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override;
252 
253  // css::inspection::XPropertyHandler:
254  virtual void SAL_CALL inspect(const css::uno::Reference< css::uno::XInterface > & Component) override;
255  virtual css::uno::Any SAL_CALL getPropertyValue(const OUString & PropertyName) override;
256  virtual void SAL_CALL setPropertyValue(const OUString & PropertyName, const css::uno::Any & Value) override;
257  virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString & PropertyName) override;
258  virtual css::inspection::LineDescriptor SAL_CALL describePropertyLine(const OUString& PropertyName, const css::uno::Reference< css::inspection::XPropertyControlFactory >& ControlFactory ) override;
259  virtual css::uno::Any SAL_CALL convertToPropertyValue(const OUString & PropertyName, const css::uno::Any & ControlValue) override;
260  virtual css::uno::Any SAL_CALL convertToControlValue(const OUString & PropertyName, const css::uno::Any & PropertyValue, const css::uno::Type & ControlValueType) override;
261  virtual void SAL_CALL addPropertyChangeListener(const css::uno::Reference< css::beans::XPropertyChangeListener > & Listener) override;
262  virtual void SAL_CALL removePropertyChangeListener(const css::uno::Reference< css::beans::XPropertyChangeListener > & _rxListener) override;
263  virtual css::uno::Sequence< css::beans::Property > SAL_CALL getSupportedProperties() override;
264  virtual css::uno::Sequence< OUString > SAL_CALL getSupersededProperties() override;
265  virtual css::uno::Sequence< OUString > SAL_CALL getActuatingProperties() override;
266  virtual sal_Bool SAL_CALL isComposable(const OUString & PropertyName) override;
267  virtual css::inspection::InteractiveSelectionResult SAL_CALL onInteractivePropertySelection(const OUString & PropertyName, sal_Bool Primary, css::uno::Any & out_Data, const css::uno::Reference< css::inspection::XObjectInspectorUI > & InspectorUI) override;
268  virtual void SAL_CALL actuatingPropertyChanged(const OUString & ActuatingPropertyName, const css::uno::Any & NewValue, const css::uno::Any & OldValue, const css::uno::Reference< css::inspection::XObjectInspectorUI > & InspectorUI, sal_Bool FirstTimeInit) override;
269  virtual sal_Bool SAL_CALL suspend(sal_Bool Suspend) override;
270 
271  protected:
272  virtual ~GeometryHandler() override;
273  private:
274  GeometryHandler(GeometryHandler const &) = delete;
275  void operator =(GeometryHandler const &) = delete;
276 
277  // override WeakComponentImplHelperBase::disposing()
278  // This function is called upon disposing the component,
279  // if your component needs special work when it becomes
280  // disposed, do it here.
281  virtual void SAL_CALL disposing() override;
282 
284  css::uno::Sequence< OUString > m_aFieldNames;
285  css::uno::Sequence< OUString > m_aParamNames;
286  TFunctions m_aFunctionNames;
287  ::std::vector< DefaultFunction > m_aDefaultFunctions;
289  css::uno::Reference< css::uno::XComponentContext > m_xContext;
290  mutable css::uno::Reference< css::report::XFunction> m_xFunction;
291  css::uno::Reference< css::inspection::XPropertyHandler > m_xFormComponentHandler;
292  css::uno::Reference< css::beans::XPropertySet > m_xReportComponent;
293  mutable css::uno::Reference< css::sdbc::XRowSet > m_xRowSet;
295  css::uno::Reference< css::script::XTypeConverter > m_xTypeConverter;
296  mutable OUString m_sDefaultFunction;
297  mutable OUString m_sScope;
298  sal_uInt32 m_nDataFieldType;
299  mutable bool m_bNewFunction;
300  bool m_bIn;
301  };
302 
303 } // namespace rptui
304 
305 
306 #endif // RPT_GeometryHandler_HXX
307 
308 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool impl_isDataField(const OUString &_sName) const
checks whether the name is a field or a parameter
OUString impl_ConvertMimeTypeToUI_nothrow(const OUString &_sMimetype) const
return the one supported output formats of the report definition
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
void createDefaultFunction(::osl::ResettableMutexGuard &_aGuard, const OUString &_sFunction, std::u16string_view _sDataField)
creates a default function of the _sFunction for the data field _sDataField The new function will onl...
sal_uInt32 impl_getDataFieldType_throw(const OUString &_sDataField=OUString()) const
returns the data field type depending on the data field of the report control
virtual css::uno::Sequence< OUString > SAL_CALL getActuatingProperties() override
virtual css::inspection::InteractiveSelectionResult SAL_CALL onInteractivePropertySelection(const OUString &PropertyName, sal_Bool Primary, css::uno::Any &out_Data, const css::uno::Reference< css::inspection::XObjectInspectorUI > &InspectorUI) override
::comphelper::OSimpleListenerContainer< css::beans::XPropertyChangeListener, css::beans::PropertyChangeEvent > PropertyChangeListeners
::std::pair< css::uno::Reference< css::report::XFunction >, css::uno::Reference< css::report::XFunctionsSupplier > > TFunctionPair
bool impl_isDefaultFunction_nothrow(const css::uno::Reference< css::report::XFunction > &_xFunction, OUString &_rDataField, OUString &_rsDefaultFunctionName) const
checks if the given function is a default function we know.
css::uno::Reference< css::report::XFunction > m_xFunction
void checkPosAndSize(const css::awt::Point &_aNewPos, const css::awt::Size &_aSize)
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &evt) override
virtual void SAL_CALL actuatingPropertyChanged(const OUString &ActuatingPropertyName, const css::uno::Any &NewValue, const css::uno::Any &OldValue, const css::uno::Reference< css::inspection::XObjectInspectorUI > &InspectorUI, sal_Bool FirstTimeInit) override
css::beans::Property getProperty(const OUString &PropertyName)
virtual void SAL_CALL addPropertyChangeListener(const css::uno::Reference< css::beans::XPropertyChangeListener > &Listener) override
css::uno::Reference< css::inspection::XPropertyHandler > m_xFormComponentHandler
OUString impl_convertToFormula(const css::uno::Any &_rControlValue)
void operator=(GeometryHandler const &)=delete
bool impl_isCounterFunction_throw(const OUString &_sQuotedFunctionName, OUString &Out_sScope) const
check whether the given function name is a counter function.
virtual ~GeometryHandler() override
css::uno::Reference< css::uno::XComponentContext > m_xContext
void loadDefaultFunctions()
fills the member m_aDefaultFunctions
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
void resetOwnProperties(::osl::ResettableMutexGuard &_aGuard, const OUString &_sOldFunctionName, const OUString &_sOldScope, const sal_uInt32 _nOldDataFieldType)
clear the own properties like function and scope and send a notification
css::uno::Reference< css::sdbc::XRowSet > m_xRowSet
inspectee
void impl_setCounterFunction_throw()
sets the counter function at the data field.
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL isComposable(const OUString &PropertyName) override
OUString impl_ConvertUIToMimeType_nothrow(const OUString &_sUIName) const
return the MimeType for the given UI Name
virtual void SAL_CALL setPropertyValue(const OUString &PropertyName, const css::uno::Any &Value) override
const OUString & getName() const
DefaultFunction m_aCounterFunction
css::uno::Reference< css::beans::XPropertySet > m_xReportComponent
delegatee
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
bool impl_dialogFilter_nothrow(OUString &_out_rSelectedClause,::osl::ClearableMutexGuard &_rClearBeforeDialog) const
executes a dialog for choosing a filter criterion for a database report
css::uno::Any getConstantValue(bool bToControlValue, const char **pResId, const css::uno::Any &_aValue, const OUString &_sConstantName, const OUString &PropertyName)
PropertyChangeListeners m_aPropertyListeners
unsigned char sal_Bool
::std::vector< DefaultFunction > m_aDefaultFunctions
void impl_initFieldList_nothrow(css::uno::Sequence< OUString > &_rFieldNames) const
css::uno::Reference< css::script::XTypeConverter > m_xTypeConverter
type converter, needed on various occasions
virtual void SAL_CALL inspect(const css::uno::Reference< css::uno::XInterface > &Component) override
::cppu::WeakComponentImplHelper< css::inspection::XPropertyHandler, css::beans::XPropertyChangeListener, css::lang::XServiceInfo > GeometryHandler_Base
virtual css::uno::Sequence< OUString > SAL_CALL getSupersededProperties() override
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
void impl_fillFormulaList_nothrow(::std::vector< OUString > &_out_rList) const
return all formula in a semicolon separated list
void impl_fillMimeTypes_nothrow(::std::vector< OUString > &_out_rList) const
return all supported output formats of the report definition
virtual css::uno::Sequence< css::beans::Property > SAL_CALL getSupportedProperties() override
virtual void SAL_CALL disposing() override
virtual void SAL_CALL removePropertyChangeListener(const css::uno::Reference< css::beans::XPropertyChangeListener > &_rxListener) override
virtual css::uno::Any SAL_CALL convertToControlValue(const OUString &PropertyName, const css::uno::Any &PropertyValue, const css::uno::Type &ControlValueType) override
virtual css::inspection::LineDescriptor SAL_CALL describePropertyLine(const OUString &PropertyName, const css::uno::Reference< css::inspection::XPropertyControlFactory > &ControlFactory) override
void impl_fillScopeList_nothrow(::std::vector< OUString > &_out_rList) const
return all group names in a semicolon separated list starting with the group where this control is co...
bool isDefaultFunction(const OUString &_sQuotedFunction, OUString &Out_rDataField, const css::uno::Reference< css::report::XFunctionsSupplier > &_xFunctionsSupplier=css::uno::Reference< css::report::XFunctionsSupplier >(), bool _bSet=false) const
checks if the given function is a default function we know.
::std::pair< MetaAction *, int > Component
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
css::uno::Sequence< OUString > m_aFieldNames
void impl_createFunction(const OUString &_sFunctionName, std::u16string_view _sDataField, const DefaultFunction &_aFunction)
Creates the function defined by the function template.
static void implCreateListLikeControl(const css::uno::Reference< css::inspection::XPropertyControlFactory > &_rxControlFactory, css::inspection::LineDescriptor &out_Descriptor, const char **pResId, bool _bReadOnlyControl, bool _bTrueIfListBoxFalseIfComboBox)
virtual css::uno::Any SAL_CALL convertToPropertyValue(const OUString &PropertyName, const css::uno::Any &ControlValue) override
GeometryHandler(css::uno::Reference< css::uno::XComponentContext > const &context)
css::uno::Reference< css::report::XFunctionsSupplier > fillScope_throw(OUString &_rsNamePostfix)
get the functions supplier for the set scope, default is the surrounding group.
css::beans::Optional< OUString > m_sInitialFormula
virtual sal_Bool SAL_CALL suspend(sal_Bool Suspend) override
css::uno::Sequence< OUString > m_aParamNames
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
::std::multimap< OUString, TFunctionPair,::comphelper::UStringMixLess > TFunctions