bump product version to 4.1.6.2
[LibreOffice.git] / reportdesign / source / ui / inc / GeometryHandler.hxx
blob6be178128d2051e63e37b738a35143523a3405c2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef RPT_GEOMETRYHANDLER_HXX
21 #define RPT_GEOMETRYHANDLER_HXX
23 #include "sal/config.h"
24 #include "com/sun/star/uno/XComponentContext.hpp"
25 #include "cppuhelper/compbase3.hxx"
26 #include "cppuhelper/basemutex.hxx"
27 #include "com/sun/star/inspection/XPropertyHandler.hpp"
28 #include "com/sun/star/script/XTypeConverter.hpp"
29 #include "com/sun/star/beans/XPropertySet.hpp"
30 #include "com/sun/star/lang/XServiceInfo.hpp"
31 #include "com/sun/star/report/XReportComponent.hpp"
32 #include "com/sun/star/report/XFunction.hpp"
33 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
34 #include <com/sun/star/sdbc/XRowSet.hpp>
35 #include <memory>
36 #include <comphelper/stl_types.hxx>
37 #include <comphelper/listenernotification.hxx>
38 #include "metadata.hxx"
40 //........................................................................
41 namespace rptui
43 //........................................................................
45 struct DefaultFunction
47 com::sun::star::beans::Optional< OUString> m_sInitialFormula;
48 OUString m_sName;
49 OUString m_sSearchString;
50 OUString m_sFormula;
51 ::sal_Bool m_bPreEvaluated;
52 ::sal_Bool m_bDeepTraversing;
54 inline OUString getName() const { return m_sName; }
55 } ;
57 class OPropertyInfoService;
58 typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction>, ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunctionsSupplier> > TFunctionPair;
59 typedef ::std::multimap< OUString,TFunctionPair, ::comphelper::UStringMixLess > TFunctions;
60 typedef ::comphelper::OSimpleListenerContainer < ::com::sun::star::beans::XPropertyChangeListener
61 , ::com::sun::star::beans::PropertyChangeEvent
62 > PropertyChangeListeners;
63 typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::inspection::XPropertyHandler
64 , ::com::sun::star::beans::XPropertyChangeListener
65 , ::com::sun::star::lang::XServiceInfo> GeometryHandler_Base;
67 class GeometryHandler:
68 private ::cppu::BaseMutex,
69 public GeometryHandler_Base
71 /** sets the counter function at the data field.
72 * If the counter function doesn't exist it will be created.
74 void impl_setCounterFunction_throw();
76 /** executes a dialog for chosing a filter criterion for a database report
77 @param _out_rSelectedClause
78 the filter or order clause as chosen by the user
79 @precond
80 we're really inspecting a database form (well, a RowSet at least)
81 @return
82 <TRUE/> if and only if the user successfully chose a clause
84 bool impl_dialogFilter_nothrow( OUString& _out_rSelectedClause, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
86 /** returns the data field type depending on the data field of the report control
88 * \param _sDataField if the data field is not empty it will be used as data field, otherwise the data field will be used.
89 * \return the data field type
91 sal_uInt32 impl_getDataFieldType_throw(const OUString& _sDataField = OUString()) const;
93 ::com::sun::star::uno::Any getConstantValue(sal_Bool bToControlValue,sal_uInt16 nResId,const ::com::sun::star::uno::Any& _aValue,const OUString& _sConstantName,const OUString & PropertyName );
94 ::com::sun::star::beans::Property getProperty(const OUString & PropertyName);
95 void implCreateListLikeControl(
96 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory
97 ,::com::sun::star::inspection::LineDescriptor & out_Descriptor
98 ,sal_uInt16 _nResId
99 ,sal_Bool _bReadOnlyControl
100 ,sal_Bool _bTrueIfListBoxFalseIfComboBox
102 void implCreateListLikeControl(
103 const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory
104 ,::com::sun::star::inspection::LineDescriptor & out_Descriptor
105 ,const ::std::vector< OUString>& _aEntries
106 ,sal_Bool _bReadOnlyControl
107 ,sal_Bool _bTrueIfListBoxFalseIfComboBox
109 void checkPosAndSize( const ::com::sun::star::awt::Point& _aNewPos,
110 const ::com::sun::star::awt::Size& _aSize);
112 OUString impl_convertToFormula( const ::com::sun::star::uno::Any& _rControlValue );
114 void impl_initFieldList_nothrow( ::com::sun::star::uno::Sequence< OUString >& _rFieldNames ) const;
116 /** Creates the function defined by the function template
118 * \param _sFunctionName the function name
119 * \param _sDataField the data field
120 * \param _aFunction the function template
122 void impl_createFunction(const OUString& _sFunctionName,const OUString& _sDataField,const DefaultFunction& _aFunction);
124 /** check whether the given function name is a countr function.
126 * \param _sQuotedFunctionName the quoted function name to check
127 * \param _Out_sScope the scope of the function
128 * \return When true it is a counter functions otherwise false.
130 bool impl_isCounterFunction_throw(const OUString& _sQuotedFunctionName,OUString& _Out_sScope) const;
132 /** clear the own properties like function and scope and send a notification
134 * \param _aGuard
135 * \param _sOldFunctionName
136 * \param _sOldScope
137 * \param _nOldDataFieldType
139 void resetOwnProperties(::osl::ResettableMutexGuard& _aGuard,const OUString& _sOldFunctionName,const OUString& _sOldScope,const sal_uInt32 _nOldDataFieldType);
141 /** checks whether the name is a field or a parameter
143 * \param _sName the name to check
144 * \return true when it is a field or parameter otherwise false
146 bool impl_isDataField(const OUString& _sName) const;
148 /**return all formula in a semicolon separated list
150 * \param _rList the localized function names
152 void impl_fillFormulaList_nothrow(::std::vector< OUString >& _out_rList) const;
154 /** return all group names in a semicolon separated list starting with the group where this control is contained in.
156 * \param _rList fills the list with all scope names.
158 void impl_fillScopeList_nothrow(::std::vector< OUString >& _out_rList) const;
160 /** return all supported output formats of the report definition
162 * \param _rList fills the list with all mime types
164 void impl_fillMimeTypes_nothrow(::std::vector< OUString >& _out_rList) const;
166 /** return the one supported output formats of the report definition
168 * \param _sMimetype the mimetype
170 OUString impl_ConvertMimeTypeToUI_nothrow(const OUString& _sMimetype) const;
172 /** return the MimeType for the given UI Name
174 * \param _sUIName the doc ui name
176 OUString impl_ConvertUIToMimeType_nothrow(const OUString& _sUIName) const;
178 /** get the functions supplier for the set scope, default is the surrounding group.
180 * \param _rsNamePostFix the name post fix which canbe used when the scope as name part is needed
181 * \return the function supplier
183 ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunctionsSupplier> fillScope_throw(OUString& _rsNamePostFix);
185 /** checks if the given function is a default function we know.
187 * \param _sQuotedFunction the quoted function name
188 * \param _Out_rDataField the data field which is used in the function
189 * \param _xFunctionsSupplier the function supplier to search or empty if not used
190 * \param _bSet If set to sal_True than the m_sDefaultFunction and m_sScope vars will be set if successful.
191 * \return sal_True with known otherwise sal_False
193 sal_Bool isDefaultFunction(const OUString& _sQuotedFunction
194 ,OUString& _Out_rDataField
195 ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunctionsSupplier>& _xFunctionsSupplier = ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunctionsSupplier>()
196 ,bool _bSet = false) const;
198 /** checks if the given function is a default function we know.
200 * \param _xFunction
201 * \param _rDataField
202 * \param _rsDefaultFunctionName
203 * \return
205 sal_Bool impl_isDefaultFunction_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction>& _xFunction
206 ,OUString& _rDataField
207 ,OUString& _rsDefaultFunctionName) const;
209 /** fills the member m_aDefaultFunctions
212 void loadDefaultFunctions();
214 /** creates a default functionof the _sFunction for the data field _sDataField
215 * The new function will only be created if it didn't exist.
217 * \param _aGuard Will be cleared, when a new function was created.
218 * \param _sFunction The name of the function.
219 * \param _sDataField The name of the data field.
221 void createDefaultFunction(::osl::ResettableMutexGuard& _aGuard ,const OUString& _sFunction,const OUString& _sDataField);
223 void removeFunction();
225 class OBlocker
227 bool& m_bIn;
228 public:
229 OBlocker(bool& _bIn) : m_bIn(_bIn){ m_bIn = true; }
230 ~OBlocker() { m_bIn = false; }
234 // XEventListener
235 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
236 // XPropertyChangeListener
237 virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
239 public:
240 // XServiceInfo - static versions
241 static OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
242 static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
243 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
244 create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
246 public:
247 explicit GeometryHandler(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);
249 // XServiceInfo
250 virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
251 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
252 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
254 // ::com::sun::star::lang::XComponent:
255 virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener) throw (::com::sun::star::uno::RuntimeException);
256 virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw (::com::sun::star::uno::RuntimeException);
258 // ::com::sun::star::inspection::XPropertyHandler:
259 virtual void SAL_CALL inspect(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & Component) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::NullPointerException);
260 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(const OUString & PropertyName) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException);
261 virtual void SAL_CALL setPropertyValue(const OUString & PropertyName, const ::com::sun::star::uno::Any & Value) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException);
262 virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState(const OUString & PropertyName) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException);
263 virtual ::com::sun::star::inspection::LineDescriptor SAL_CALL describePropertyLine(const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& ControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
264 virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue(const OUString & PropertyName, const ::com::sun::star::uno::Any & ControlValue) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException);
265 virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue(const OUString & PropertyName, const ::com::sun::star::uno::Any & PropertyValue, const ::com::sun::star::uno::Type & ControlValueType) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException);
266 virtual void SAL_CALL addPropertyChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > & Listener) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::NullPointerException);
267 virtual void SAL_CALL removePropertyChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > & _rxListener) throw (::com::sun::star::uno::RuntimeException);
268 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
269 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupersededProperties() throw (::com::sun::star::uno::RuntimeException);
270 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getActuatingProperties() throw (::com::sun::star::uno::RuntimeException);
271 virtual ::sal_Bool SAL_CALL isComposable(const OUString & PropertyName) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException);
272 virtual ::com::sun::star::inspection::InteractiveSelectionResult SAL_CALL onInteractivePropertySelection(const OUString & PropertyName, ::sal_Bool Primary, ::com::sun::star::uno::Any & out_Data, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI > & InspectorUI) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException);
273 virtual void SAL_CALL actuatingPropertyChanged(const OUString & ActuatingPropertyName, const ::com::sun::star::uno::Any & NewValue, const ::com::sun::star::uno::Any & OldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI > & InspectorUI, ::sal_Bool FirstTimeInit) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::NullPointerException);
274 virtual ::sal_Bool SAL_CALL suspend(::sal_Bool Suspend) throw (::com::sun::star::uno::RuntimeException);
276 protected:
277 virtual ~GeometryHandler();
278 private:
279 GeometryHandler(GeometryHandler &); // not defined
280 void operator =(GeometryHandler &); // not defined
282 // overload WeakComponentImplHelperBase::disposing()
283 // This function is called upon disposing the component,
284 // if your component needs special work when it becomes
285 // disposed, do it here.
286 virtual void SAL_CALL disposing();
288 PropertyChangeListeners m_aPropertyListeners;
289 ::com::sun::star::uno::Sequence< OUString > m_aFieldNames;
290 ::com::sun::star::uno::Sequence< OUString > m_aParamNames;
291 TFunctions m_aFunctionNames;
292 ::std::vector< DefaultFunction > m_aDefaultFunctions;
293 DefaultFunction m_aCounterFunction;
294 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
295 mutable ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction> m_xFunction;
296 ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > m_xFormComponentHandler; /// delegatee
297 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xReportComponent; /// inspectee
298 mutable ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xRowSet;
299 /// type converter, needed on various occasions
300 ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > m_xTypeConverter;
301 /// access to property meta data
302 SAL_WNODEPRECATED_DECLARATIONS_PUSH
303 ::std::auto_ptr< OPropertyInfoService > m_pInfoService;
304 SAL_WNODEPRECATED_DECLARATIONS_POP
305 mutable OUString m_sDefaultFunction;
306 mutable OUString m_sScope;
307 sal_uInt32 m_nDataFieldType;
308 mutable bool m_bNewFunction;
309 bool m_bIn;
311 //........................................................................
312 } // namespace rptui
313 //........................................................................
315 #endif // RPT_GeometryHandler_HXX
317 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */