Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef RPT_GEOMETRYHANDLER_HXX
30 : : #define RPT_GEOMETRYHANDLER_HXX
31 : :
32 : : #include "sal/config.h"
33 : : #include "com/sun/star/uno/XComponentContext.hpp"
34 : : #include "cppuhelper/compbase3.hxx"
35 : : #include "cppuhelper/basemutex.hxx"
36 : : #include "com/sun/star/inspection/XPropertyHandler.hpp"
37 : : #include "com/sun/star/script/XTypeConverter.hpp"
38 : : #include "com/sun/star/beans/XPropertySet.hpp"
39 : : #include "com/sun/star/lang/XServiceInfo.hpp"
40 : : #include "com/sun/star/report/XReportComponent.hpp"
41 : : #include "com/sun/star/report/XFunction.hpp"
42 : : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
43 : : #include <com/sun/star/sdbc/XRowSet.hpp>
44 : : #include <memory>
45 : : #include <comphelper/stl_types.hxx>
46 : : #include <comphelper/listenernotification.hxx>
47 : : #include "metadata.hxx"
48 : :
49 : : //........................................................................
50 : : namespace rptui
51 : : {
52 : : //........................................................................
53 : :
54 : 0 : struct DefaultFunction
55 : : {
56 : : com::sun::star::beans::Optional< ::rtl::OUString> m_sInitialFormula;
57 : : ::rtl::OUString m_sName;
58 : : ::rtl::OUString m_sSearchString;
59 : : ::rtl::OUString m_sFormula;
60 : : ::sal_Bool m_bPreEvaluated;
61 : : ::sal_Bool m_bDeepTraversing;
62 : :
63 : 0 : inline ::rtl::OUString getName() const { return m_sName; }
64 : : } ;
65 : :
66 : : class OPropertyInfoService;
67 : : typedef ::std::pair< ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction>, ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunctionsSupplier> > TFunctionPair;
68 : : typedef ::std::multimap< ::rtl::OUString,TFunctionPair, ::comphelper::UStringMixLess > TFunctions;
69 : : typedef ::comphelper::OSimpleListenerContainer < ::com::sun::star::beans::XPropertyChangeListener
70 : : , ::com::sun::star::beans::PropertyChangeEvent
71 : : > PropertyChangeListeners;
72 : : typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::inspection::XPropertyHandler
73 : : , ::com::sun::star::beans::XPropertyChangeListener
74 : : , ::com::sun::star::lang::XServiceInfo> GeometryHandler_Base;
75 : :
76 : : class GeometryHandler:
77 : : private ::cppu::BaseMutex,
78 : : public GeometryHandler_Base
79 : : {
80 : : /** sets the counter function at the data field.
81 : : * If the counter function doesn't exist it will be created.
82 : : */
83 : : void impl_setCounterFunction_throw();
84 : :
85 : : /** executes a dialog for chosing a filter criterion for a database report
86 : : @param _out_rSelectedClause
87 : : the filter or order clause as chosen by the user
88 : : @precond
89 : : we're really inspecting a database form (well, a RowSet at least)
90 : : @return
91 : : <TRUE/> if and only if the user successfully chose a clause
92 : : */
93 : : bool impl_dialogFilter_nothrow( ::rtl::OUString& _out_rSelectedClause, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
94 : :
95 : : /** returns the data field type depending on the data field of the report control
96 : : *
97 : : * \param _sDataField if the data field is not empty it will be used as data field, otherwise the data field will be used.
98 : : * \return the data field type
99 : : */
100 : : sal_uInt32 impl_getDataFieldType_throw(const ::rtl::OUString& _sDataField = ::rtl::OUString()) const;
101 : :
102 : : ::com::sun::star::uno::Any getConstantValue(sal_Bool bToControlValue,sal_uInt16 nResId,const ::com::sun::star::uno::Any& _aValue,const ::rtl::OUString& _sConstantName,const ::rtl::OUString & PropertyName );
103 : : ::com::sun::star::beans::Property getProperty(const ::rtl::OUString & PropertyName);
104 : : void implCreateListLikeControl(
105 : : const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory
106 : : ,::com::sun::star::inspection::LineDescriptor & out_Descriptor
107 : : ,sal_uInt16 _nResId
108 : : ,sal_Bool _bReadOnlyControl
109 : : ,sal_Bool _bTrueIfListBoxFalseIfComboBox
110 : : );
111 : : void implCreateListLikeControl(
112 : : const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory
113 : : ,::com::sun::star::inspection::LineDescriptor & out_Descriptor
114 : : ,const ::std::vector< ::rtl::OUString>& _aEntries
115 : : ,sal_Bool _bReadOnlyControl
116 : : ,sal_Bool _bTrueIfListBoxFalseIfComboBox
117 : : );
118 : : void checkPosAndSize( const ::com::sun::star::awt::Point& _aNewPos,
119 : : const ::com::sun::star::awt::Size& _aSize);
120 : :
121 : : ::rtl::OUString impl_convertToFormula( const ::com::sun::star::uno::Any& _rControlValue );
122 : :
123 : : void impl_initFieldList_nothrow( ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rFieldNames ) const;
124 : :
125 : : /** Creates the function defined by the function template
126 : : *
127 : : * \param _sFunctionName the function name
128 : : * \param _sDataField the data field
129 : : * \param _aFunction the function template
130 : : */
131 : : void impl_createFunction(const ::rtl::OUString& _sFunctionName,const ::rtl::OUString& _sDataField,const DefaultFunction& _aFunction);
132 : :
133 : : /** check whether the given function name is a countr function.
134 : : *
135 : : * \param _sQuotedFunctionName the quoted function name to check
136 : : * \param _Out_sScope the scope of the function
137 : : * \return When true it is a counter functions otherwise false.
138 : : */
139 : : bool impl_isCounterFunction_throw(const ::rtl::OUString& _sQuotedFunctionName,::rtl::OUString& _Out_sScope) const;
140 : :
141 : : /** clear the own properties like function and scope and send a notification
142 : : *
143 : : * \param _aGuard
144 : : * \param _sOldFunctionName
145 : : * \param _sOldScope
146 : : * \param _nOldDataFieldType
147 : : */
148 : : void resetOwnProperties(::osl::ResettableMutexGuard& _aGuard,const ::rtl::OUString& _sOldFunctionName,const ::rtl::OUString& _sOldScope,const sal_uInt32 _nOldDataFieldType);
149 : :
150 : : /** checks whether the name is a field or a parameter
151 : : *
152 : : * \param _sName the name to check
153 : : * \return true when it is a field or parameter otherwise false
154 : : */
155 : : bool impl_isDataField(const ::rtl::OUString& _sName) const;
156 : :
157 : : /**return all formula in a semicolon seperated list
158 : : *
159 : : * \param _rList the localized function names
160 : : */
161 : : void impl_fillFormulaList_nothrow(::std::vector< ::rtl::OUString >& _out_rList) const;
162 : :
163 : : /** return all group names in a semicolon seperated list starting with the group where this control is contained in.
164 : : *
165 : : * \param _rList fills the list with all scope names.
166 : : */
167 : : void impl_fillScopeList_nothrow(::std::vector< ::rtl::OUString >& _out_rList) const;
168 : :
169 : : /** return all supported output formats of the report definition
170 : : *
171 : : * \param _rList fills the list with all mime types
172 : : */
173 : : void impl_fillMimeTypes_nothrow(::std::vector< ::rtl::OUString >& _out_rList) const;
174 : :
175 : : /** return the one supported output formats of the report definition
176 : : *
177 : : * \param _sMimetype the mimetype
178 : : */
179 : : ::rtl::OUString impl_ConvertMimeTypeToUI_nothrow(const ::rtl::OUString& _sMimetype) const;
180 : :
181 : : /** return the MimeType for the given UI Name
182 : : *
183 : : * \param _sUIName the doc ui name
184 : : */
185 : : ::rtl::OUString impl_ConvertUIToMimeType_nothrow(const ::rtl::OUString& _sUIName) const;
186 : :
187 : : /** get the functions supplier for the set scope, default is the surrounding group.
188 : : *
189 : : * \param _rsNamePostFix the name post fix which canbe used when the scope as name part is needed
190 : : * \return the function supplier
191 : : */
192 : : ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunctionsSupplier> fillScope_throw(::rtl::OUString& _rsNamePostFix);
193 : :
194 : : /** checks if the given function is a default function we know.
195 : : *
196 : : * \param _sQuotedFunction the quoted function name
197 : : * \param _Out_rDataField the data field which is used in the function
198 : : * \param _xFunctionsSupplier teh function supplier to search or empty if not used
199 : : * \param _bSet If set to sal_True than the m_sDefaultFunction and m_sScope vars will be set if successful.
200 : : * \return sal_True with known otherwise sal_False
201 : : */
202 : : sal_Bool isDefaultFunction(const ::rtl::OUString& _sQuotedFunction
203 : : ,::rtl::OUString& _Out_rDataField
204 : : ,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunctionsSupplier>& _xFunctionsSupplier = ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunctionsSupplier>()
205 : : ,bool _bSet = false) const;
206 : :
207 : : /** checks if the given function is a default function we know.
208 : : *
209 : : * \param _xFunction
210 : : * \param _rDataField
211 : : * \param _rsDefaultFunctionName
212 : : * \return
213 : : */
214 : : sal_Bool impl_isDefaultFunction_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction>& _xFunction
215 : : ,::rtl::OUString& _rDataField
216 : : ,::rtl::OUString& _rsDefaultFunctionName) const;
217 : :
218 : : /** fills the memeber m_aDefaultFunctions
219 : : *
220 : : */
221 : : void loadDefaultFunctions();
222 : :
223 : : /** creates a default functionof the _sFunction for the data field _sDataField
224 : : * The new function will only be created if it didn't exist.
225 : : *
226 : : * \param _aGuard Will be cleared, when a new function was created.
227 : : * \param _sFunction The name of the function.
228 : : * \param _sDataField The name of the data field.
229 : : */
230 : : void createDefaultFunction(::osl::ResettableMutexGuard& _aGuard ,const ::rtl::OUString& _sFunction,const ::rtl::OUString& _sDataField);
231 : :
232 : : void removeFunction();
233 : :
234 : : class OBlocker
235 : : {
236 : : bool& m_bIn;
237 : : public:
238 : 0 : OBlocker(bool& _bIn) : m_bIn(_bIn){ m_bIn = true; }
239 : 0 : ~OBlocker() { m_bIn = false; }
240 : : };
241 : :
242 : :
243 : : // XEventListener
244 : : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
245 : : // XPropertyChangeListener
246 : : virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
247 : :
248 : : public:
249 : : // XServiceInfo - static versions
250 : : static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
251 : : static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
252 : : static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
253 : : create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
254 : :
255 : : public:
256 : : explicit GeometryHandler(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);
257 : :
258 : : // XServiceInfo
259 : : virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
260 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
261 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
262 : :
263 : : // ::com::sun::star::lang::XComponent:
264 : : virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener) throw (::com::sun::star::uno::RuntimeException);
265 : : virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw (::com::sun::star::uno::RuntimeException);
266 : :
267 : : // ::com::sun::star::inspection::XPropertyHandler:
268 : : 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);
269 : : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString & PropertyName) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException);
270 : : virtual void SAL_CALL setPropertyValue(const ::rtl::OUString & PropertyName, const ::com::sun::star::uno::Any & Value) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException);
271 : : virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState(const ::rtl::OUString & PropertyName) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException);
272 : : virtual ::com::sun::star::inspection::LineDescriptor SAL_CALL describePropertyLine(const ::rtl::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);
273 : : virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue(const ::rtl::OUString & PropertyName, const ::com::sun::star::uno::Any & ControlValue) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException);
274 : : virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue(const ::rtl::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);
275 : : 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);
276 : : virtual void SAL_CALL removePropertyChangeListener(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > & _rxListener) throw (::com::sun::star::uno::RuntimeException);
277 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
278 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties() throw (::com::sun::star::uno::RuntimeException);
279 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties() throw (::com::sun::star::uno::RuntimeException);
280 : : virtual ::sal_Bool SAL_CALL isComposable(const ::rtl::OUString & PropertyName) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::beans::UnknownPropertyException);
281 : : virtual ::com::sun::star::inspection::InteractiveSelectionResult SAL_CALL onInteractivePropertySelection(const ::rtl::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);
282 : : virtual void SAL_CALL actuatingPropertyChanged(const ::rtl::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);
283 : : virtual ::sal_Bool SAL_CALL suspend(::sal_Bool Suspend) throw (::com::sun::star::uno::RuntimeException);
284 : :
285 : : protected:
286 : : virtual ~GeometryHandler();
287 : : private:
288 : : GeometryHandler(GeometryHandler &); // not defined
289 : : void operator =(GeometryHandler &); // not defined
290 : :
291 : : // overload WeakComponentImplHelperBase::disposing()
292 : : // This function is called upon disposing the component,
293 : : // if your component needs special work when it becomes
294 : : // disposed, do it here.
295 : : virtual void SAL_CALL disposing();
296 : :
297 : : PropertyChangeListeners m_aPropertyListeners;
298 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aFieldNames;
299 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aParamNames;
300 : : TFunctions m_aFunctionNames;
301 : : ::std::vector< DefaultFunction > m_aDefaultFunctions;
302 : : DefaultFunction m_aCounterFunction;
303 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
304 : : mutable ::com::sun::star::uno::Reference< ::com::sun::star::report::XFunction> m_xFunction;
305 : : ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > m_xFormComponentHandler; /// delegatee
306 : : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xReportComponent; /// inspectee
307 : : mutable ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xRowSet;
308 : : /// type converter, needed on various occasions
309 : : ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > m_xTypeConverter;
310 : : /// access to property meta data
311 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
312 : : ::std::auto_ptr< OPropertyInfoService > m_pInfoService;
313 : : SAL_WNODEPRECATED_DECLARATIONS_POP
314 : : mutable ::rtl::OUString m_sDefaultFunction;
315 : : mutable ::rtl::OUString m_sScope;
316 : : sal_uInt32 m_nDataFieldType;
317 : : mutable bool m_bNewFunction;
318 : : bool m_bIn;
319 : : };
320 : : //........................................................................
321 : : } // namespace rptui
322 : : //........................................................................
323 : :
324 : : #endif // RPT_GeometryHandler_HXX
325 : :
326 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|