Line data Source code
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 : #include "GeometryHandler.hxx"
20 :
21 : #include <comphelper/sequence.hxx>
22 : #include <comphelper/types.hxx>
23 : #include <comphelper/property.hxx>
24 : #include <comphelper/mimeconfighelper.hxx>
25 :
26 : #include "uistrings.hrc"
27 : #include "reportformula.hxx"
28 :
29 : #include <unotools/textsearch.hxx>
30 : #include <unotools/configmgr.hxx>
31 :
32 : #include <toolkit/helper/vclunohelper.hxx>
33 : #include <unotools/syslocale.hxx>
34 : #include <tools/diagnose_ex.h>
35 : #include <tools/StringListResource.hxx>
36 : #include <com/sun/star/lang/XInitialization.hpp>
37 : #include "com/sun/star/inspection/StringRepresentation.hpp"
38 : #include <com/sun/star/inspection/PropertyLineElement.hpp>
39 : #include <com/sun/star/inspection/PropertyControlType.hpp>
40 : #include <com/sun/star/inspection/XStringListControl.hpp>
41 : #include <com/sun/star/report/Function.hpp>
42 : #include <com/sun/star/report/XReportDefinition.hpp>
43 : #include <com/sun/star/report/XShape.hpp>
44 : #include <com/sun/star/report/XSection.hpp>
45 : #include <com/sun/star/report/XFormattedField.hpp>
46 : #include <com/sun/star/report/XFixedLine.hpp>
47 : #include <com/sun/star/script/Converter.hpp>
48 : #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
49 : #include <com/sun/star/sdb/CommandType.hpp>
50 : #include <com/sun/star/sdb/FilterDialog.hpp>
51 : #include <com/sun/star/sdb/SQLContext.hpp>
52 : #include <com/sun/star/sdbc/XConnection.hpp>
53 : #include <com/sun/star/util/SearchOptions.hpp>
54 : #include <com/sun/star/util/MeasureUnit.hpp>
55 : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
56 : #include <com/sun/star/container/XNameContainer.hpp>
57 : #include <com/sun/star/inspection/XNumericControl.hpp>
58 : #include <com/sun/star/style/ParagraphAdjust.hpp>
59 :
60 : #include <vcl/msgbox.hxx>
61 : #include <vcl/waitobj.hxx>
62 : #include <tools/fldunit.hxx>
63 : #include <vcl/stdtext.hxx>
64 :
65 : #include "ModuleHelper.hxx"
66 : #include "RptResId.hrc"
67 : #include "RptDef.hxx"
68 : #include "UITools.hxx"
69 :
70 : #include <connectivity/dbexception.hxx>
71 : #include <connectivity/dbconversion.hxx>
72 : #include <connectivity/dbtools.hxx>
73 :
74 : #include <boost/bind.hpp>
75 : #include <tools/string.hxx>
76 : #include "metadata.hxx"
77 : #include <svl/itempool.hxx>
78 : #include <svl/itemset.hxx>
79 :
80 : #define ITEMID_COLOR_TABLE SID_COLOR_TABLE
81 : #define ITEMID_DASH_LIST SID_DASH_LIST
82 : #define ITEMID_LINEEND_LIST SID_LINEEND_LIST
83 : #include <svx/xdef.hxx>
84 : #include <svx/xpool.hxx>
85 : #include <svx/xtable.hxx>
86 : #include <svx/xlnwtit.hxx>
87 : #include <svx/xlntrit.hxx>
88 : #include <svx/xlnclit.hxx>
89 : #include <svx/xlnstit.hxx>
90 : #include <svx/xlnedit.hxx>
91 : #include <svx/xlnstwit.hxx>
92 : #include <svx/xlnedwit.hxx>
93 : #include <svx/xlnstcit.hxx>
94 : #include <svx/xlnedcit.hxx>
95 : #include <svx/xlndsit.hxx>
96 : #include <svx/xlineit0.hxx>
97 : #include <svx/svxids.hrc>
98 :
99 : #define ITEMID_COLOR_TABLE SID_COLOR_TABLE
100 : #define ITEMID_DASH_LIST SID_DASH_LIST
101 : #define ITEMID_LINEEND_LIST SID_LINEEND_LIST
102 : #include <svx/drawitem.hxx>
103 : #define ITEMID_BRUSH SID_ATTR_BRUSH
104 : #include <editeng/brshitem.hxx>
105 : #include <sfx2/docfilt.hxx>
106 :
107 : #include "dlgpage.hxx"
108 : #include "helpids.hrc"
109 : #include <toolkit/helper/convert.hxx>
110 :
111 : #include <o3tl/compat_functional.hxx>
112 :
113 : #define DATA_OR_FORMULA 0
114 : #define FUNCTION 1
115 : #define COUNTER 2
116 : #define USER_DEF_FUNCTION 3
117 : #define UNDEF_DATA 4
118 :
119 : //........................................................................
120 : namespace rptui
121 : {
122 : //........................................................................
123 : using namespace ::com::sun::star;
124 :
125 : namespace{
126 : // comparing two property instances
127 : struct PropertyCompare : public ::std::binary_function< beans::Property, ::rtl::OUString , bool >
128 : {
129 0 : bool operator() (const beans::Property& x, const ::rtl::OUString& y) const
130 : {
131 0 : return x.Name.equals(y);
132 : }
133 : bool operator() (const ::rtl::OUString& x,const beans::Property& y) const
134 : {
135 : return x.equals(y.Name);
136 : }
137 : };
138 :
139 : // -----------------------------------------------------------------------------
140 0 : ::rtl::OUString lcl_getQuotedFunctionName(const ::rtl::OUString& _sFunction)
141 : {
142 0 : ::rtl::OUString sQuotedFunctionName(RTL_CONSTASCII_USTRINGPARAM("["));
143 0 : sQuotedFunctionName += _sFunction + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("]"));
144 0 : return sQuotedFunctionName;
145 : }
146 : // -----------------------------------------------------------------------------
147 0 : ::rtl::OUString lcl_getQuotedFunctionName(const uno::Reference< report::XFunction>& _xFunction)
148 : {
149 0 : return lcl_getQuotedFunctionName(_xFunction->getName());
150 : }
151 : // -----------------------------------------------------------------------------
152 0 : void lcl_collectFunctionNames(const uno::Reference< report::XFunctions>& _xFunctions,TFunctions& _rFunctionNames)
153 : {
154 0 : uno::Reference< report::XFunctionsSupplier> xParent(_xFunctions->getParent(),uno::UNO_QUERY_THROW);
155 0 : const sal_Int32 nCount = _xFunctions->getCount();
156 0 : for (sal_Int32 i = 0; i < nCount ; ++i)
157 : {
158 0 : uno::Reference< report::XFunction > xFunction(_xFunctions->getByIndex(i),uno::UNO_QUERY_THROW);
159 0 : _rFunctionNames.insert(TFunctions::value_type(lcl_getQuotedFunctionName(xFunction),TFunctionPair(xFunction,xParent)));
160 0 : }
161 0 : }
162 : // -----------------------------------------------------------------------------
163 0 : void lcl_collectFunctionNames(const uno::Reference< report::XSection>& _xSection,TFunctions& _rFunctionNames)
164 : {
165 0 : const uno::Reference< report::XReportDefinition> xReportDefinition = _xSection->getReportDefinition();
166 0 : const uno::Reference< report::XGroups> xGroups = xReportDefinition->getGroups();
167 0 : sal_Int32 nPos = -1;
168 0 : uno::Reference< report::XGroup> xGroup = _xSection->getGroup();
169 0 : if ( xGroup.is() )
170 0 : nPos = getPositionInIndexAccess(xGroups.get(),xGroup);
171 0 : else if ( _xSection == xReportDefinition->getDetail() )
172 0 : nPos = xGroups->getCount()-1;
173 :
174 0 : for (sal_Int32 i = 0 ; i <= nPos ; ++i)
175 : {
176 0 : xGroup.set(xGroups->getByIndex(i),uno::UNO_QUERY_THROW);
177 0 : lcl_collectFunctionNames(xGroup->getFunctions(),_rFunctionNames);
178 : }
179 0 : lcl_collectFunctionNames(xReportDefinition->getFunctions(),_rFunctionNames);
180 0 : }
181 : // -----------------------------------------------------------------------------
182 0 : void lcl_convertFormulaTo(const uno::Any& _aPropertyValue,uno::Any& _rControlValue)
183 : {
184 0 : ::rtl::OUString sName;
185 0 : _aPropertyValue >>= sName;
186 0 : const sal_Int32 nLen = sName.getLength();
187 0 : if ( nLen )
188 : {
189 0 : ReportFormula aFormula( sName );
190 0 : _rControlValue <<= aFormula.getUndecoratedContent();
191 0 : }
192 0 : }
193 :
194 : // return value rounded to the nearest multiple of base
195 : // if equidistant of two multiples, round up (for positive numbers)
196 : // T is assumed to be an integer type
197 0 : template <typename T, T base> T lcl_round(T value)
198 : {
199 : OSL_ENSURE(value >= 0, "lcl_round: positive numbers only please");
200 0 : const T threshold = (base % 2 == 0) ? (base/2) : (base/2 + 1);
201 0 : const T rest = value % base;
202 0 : if ( rest >= threshold )
203 0 : return value + (base - rest);
204 : else
205 0 : return value - rest;
206 : }
207 :
208 : } // anonymous namespace
209 : // -----------------------------------------------------------------------------
210 0 : bool GeometryHandler::impl_isDataField(const ::rtl::OUString& _sName) const
211 : {
212 0 : const ::rtl::OUString* pEnd = m_aFieldNames.getConstArray() + m_aFieldNames.getLength();
213 0 : bool bIsField = ( ::std::find( m_aFieldNames.getConstArray(), pEnd, _sName ) != pEnd );
214 :
215 0 : if ( !bIsField )
216 : {
217 0 : pEnd = m_aParamNames.getConstArray() + m_aParamNames.getLength();
218 0 : bIsField = ( ::std::find( m_aParamNames.getConstArray(), pEnd, _sName ) != pEnd );
219 : }
220 0 : return bIsField;
221 : }
222 : // -----------------------------------------------------------------------------
223 0 : ::rtl::OUString GeometryHandler::impl_convertToFormula( const uno::Any& _rControlValue )
224 : {
225 0 : ::rtl::OUString sName;
226 0 : _rControlValue >>= sName;
227 :
228 0 : if ( sName.isEmpty() )
229 0 : return sName;
230 :
231 0 : ReportFormula aParser( sName );
232 0 : if ( aParser.isValid() )
233 0 : return sName;
234 :
235 0 : aParser = ReportFormula( impl_isDataField(sName) ? ReportFormula::Field : ReportFormula::Expression, sName );
236 0 : return aParser.getCompleteFormula();
237 : }
238 : DBG_NAME(rpt_GeometryHandler)
239 0 : GeometryHandler::GeometryHandler(uno::Reference< uno::XComponentContext > const & context) :
240 : GeometryHandler_Base(m_aMutex)
241 : ,m_aPropertyListeners( m_aMutex )
242 : ,m_xContext(context)
243 0 : ,m_pInfoService(new OPropertyInfoService())
244 : ,m_nDataFieldType(0)
245 0 : ,m_bIn(false)
246 : {
247 : DBG_CTOR(rpt_GeometryHandler,NULL);
248 : try
249 : {
250 0 : const uno::Reference< lang::XMultiComponentFactory > xFac = m_xContext->getServiceManager();
251 0 : m_xFormComponentHandler.set(xFac->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.inspection.FormComponentPropertyHandler")),m_xContext),uno::UNO_QUERY_THROW);
252 0 : m_xTypeConverter.set(script::Converter::create(context));
253 0 : loadDefaultFunctions();
254 : }
255 0 : catch(const uno::Exception&)
256 : {
257 : }
258 0 : }
259 : // -----------------------------------------------------------------------------
260 0 : GeometryHandler::~GeometryHandler()
261 : {
262 : DBG_DTOR(rpt_GeometryHandler,NULL);
263 0 : }
264 : //------------------------------------------------------------------------
265 0 : ::rtl::OUString SAL_CALL GeometryHandler::getImplementationName( ) throw(uno::RuntimeException)
266 : {
267 0 : return getImplementationName_Static();
268 : }
269 :
270 : //------------------------------------------------------------------------
271 0 : sal_Bool SAL_CALL GeometryHandler::supportsService( const ::rtl::OUString& ServiceName ) throw(uno::RuntimeException)
272 : {
273 0 : return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_static());
274 : }
275 :
276 : //------------------------------------------------------------------------
277 0 : uno::Sequence< ::rtl::OUString > SAL_CALL GeometryHandler::getSupportedServiceNames( ) throw(uno::RuntimeException)
278 : {
279 0 : return getSupportedServiceNames_static();
280 : }
281 :
282 : //------------------------------------------------------------------------
283 0 : ::rtl::OUString GeometryHandler::getImplementationName_Static( ) throw(uno::RuntimeException)
284 : {
285 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.GeometryHandler"));
286 : }
287 :
288 : //------------------------------------------------------------------------
289 0 : uno::Sequence< ::rtl::OUString > GeometryHandler::getSupportedServiceNames_static( ) throw(uno::RuntimeException)
290 : {
291 0 : uno::Sequence< ::rtl::OUString > aSupported(1);
292 0 : aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.inspection.GeometryHandler"));
293 0 : return aSupported;
294 : }
295 :
296 : //------------------------------------------------------------------------
297 0 : uno::Reference< uno::XInterface > SAL_CALL GeometryHandler::create( const uno::Reference< uno::XComponentContext >& _rxContext )
298 : {
299 0 : return *(new GeometryHandler( _rxContext ));
300 : }
301 : // overload WeakComponentImplHelperBase::disposing()
302 : // This function is called upon disposing the component,
303 : // if your component needs special work when it becomes
304 : // disposed, do it here.
305 0 : void SAL_CALL GeometryHandler::disposing()
306 : {
307 : try
308 : {
309 0 : ::comphelper::disposeComponent(m_xFormComponentHandler);
310 0 : ::comphelper::disposeComponent(m_xTypeConverter);
311 0 : if ( m_xReportComponent.is() && m_xReportComponent->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD) )
312 0 : m_xReportComponent->removePropertyChangeListener(PROPERTY_DATAFIELD,static_cast< beans::XPropertyChangeListener* >( this ));
313 :
314 0 : m_xReportComponent.clear();
315 0 : m_xRowSet.clear();
316 0 : m_aPropertyListeners.clear();
317 : }
318 0 : catch(uno::Exception&)
319 : {}
320 0 : }
321 0 : void SAL_CALL GeometryHandler::addEventListener(const uno::Reference< lang::XEventListener > & xListener) throw (uno::RuntimeException)
322 : {
323 0 : m_xFormComponentHandler->addEventListener(xListener);
324 0 : }
325 :
326 0 : void SAL_CALL GeometryHandler::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw (uno::RuntimeException)
327 : {
328 0 : m_xFormComponentHandler->removeEventListener(aListener);
329 0 : }
330 :
331 : // inspection::XPropertyHandler:
332 :
333 : /********************************************************************************/
334 0 : void SAL_CALL GeometryHandler::inspect( const uno::Reference< uno::XInterface > & _rxInspectee ) throw (uno::RuntimeException, lang::NullPointerException)
335 : {
336 0 : ::osl::MutexGuard aGuard( m_aMutex );
337 0 : m_sScope = m_sDefaultFunction = ::rtl::OUString();
338 0 : m_bNewFunction = false;
339 0 : m_nDataFieldType = 0;
340 0 : m_xFunction.clear();
341 0 : m_aFunctionNames.clear();
342 : try
343 : {
344 0 : if ( m_xReportComponent.is() && m_xReportComponent->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD) )
345 0 : m_xReportComponent->removePropertyChangeListener(PROPERTY_DATAFIELD,static_cast< beans::XPropertyChangeListener* >( this ));
346 :
347 0 : const uno::Reference< container::XNameContainer > xObjectAsContainer( _rxInspectee, uno::UNO_QUERY );
348 0 : m_xReportComponent.set( xObjectAsContainer->getByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ReportComponent" ) ) ), uno::UNO_QUERY );
349 :
350 0 : const ::rtl::OUString sRowSet(RTL_CONSTASCII_USTRINGPARAM("RowSet"));
351 0 : if ( xObjectAsContainer->hasByName( sRowSet ) )
352 : {
353 0 : const uno::Any aRowSet( xObjectAsContainer->getByName(sRowSet) );
354 0 : aRowSet >>= m_xRowSet;
355 : // forward the rowset to our delegator handler
356 0 : uno::Reference< beans::XPropertySet > xProp( m_xFormComponentHandler,uno::UNO_QUERY );
357 0 : xProp->setPropertyValue( sRowSet, aRowSet );
358 :
359 0 : m_aParamNames = getParameterNames( m_xRowSet );
360 0 : impl_initFieldList_nothrow(m_aFieldNames);
361 0 : if ( m_xReportComponent->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD) )
362 0 : m_xReportComponent->addPropertyChangeListener(PROPERTY_DATAFIELD,static_cast< beans::XPropertyChangeListener* >( this ));
363 : }
364 :
365 0 : const uno::Reference< report::XReportComponent> xReportComponent( m_xReportComponent, uno::UNO_QUERY);
366 0 : uno::Reference< report::XSection> xSection( m_xReportComponent, uno::UNO_QUERY );
367 0 : if ( !xSection.is() && xReportComponent.is() )
368 0 : xSection = xReportComponent->getSection();
369 0 : if ( xSection.is() )
370 0 : lcl_collectFunctionNames( xSection, m_aFunctionNames );
371 : }
372 0 : catch(const uno::Exception &)
373 : {
374 0 : throw lang::NullPointerException();
375 : }
376 0 : m_xFormComponentHandler->inspect(m_xReportComponent);
377 0 : }
378 :
379 0 : uno::Any SAL_CALL GeometryHandler::getPropertyValue(const ::rtl::OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
380 : {
381 0 : ::osl::MutexGuard aGuard( m_aMutex );
382 0 : uno::Any aPropertyValue;
383 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
384 0 : switch(nId)
385 : {
386 : case PROPERTY_ID_CONDITIONALPRINTEXPRESSION:
387 : case PROPERTY_ID_INITIALFORMULA:
388 : case PROPERTY_ID_FORMULA:
389 : case PROPERTY_ID_DATAFIELD:
390 0 : aPropertyValue = m_xReportComponent->getPropertyValue( PropertyName );
391 0 : lcl_convertFormulaTo(aPropertyValue,aPropertyValue);
392 0 : if ( PROPERTY_ID_DATAFIELD == nId )
393 : {
394 0 : ::rtl::OUString sDataField;
395 0 : aPropertyValue >>= sDataField;
396 0 : switch(m_nDataFieldType)
397 : {
398 : case DATA_OR_FORMULA:
399 0 : break;
400 : case FUNCTION:
401 0 : if ( isDefaultFunction(sDataField,sDataField) )
402 0 : aPropertyValue <<= sDataField;
403 0 : else if ( sDataField.isEmpty() )
404 0 : aPropertyValue = uno::Any();
405 0 : break;
406 : case COUNTER:
407 : case USER_DEF_FUNCTION:
408 0 : aPropertyValue = uno::Any();
409 0 : break;
410 0 : }
411 :
412 : }
413 0 : break;
414 : case PROPERTY_ID_TYPE:
415 : {
416 0 : const sal_uInt32 nOldDataFieldType = m_nDataFieldType;
417 0 : m_nDataFieldType = impl_getDataFieldType_throw();
418 0 : if ( UNDEF_DATA == m_nDataFieldType )
419 0 : m_nDataFieldType = nOldDataFieldType;
420 0 : aPropertyValue <<= m_nDataFieldType;
421 : }
422 0 : break;
423 : case PROPERTY_ID_FORMULALIST:
424 : case PROPERTY_ID_SCOPE:
425 : {
426 0 : uno::Any aDataField = m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD );
427 0 : lcl_convertFormulaTo(aDataField,aDataField);
428 0 : ::rtl::OUString sDataField;
429 0 : aDataField >>= sDataField;
430 0 : switch(m_nDataFieldType)
431 : {
432 : case DATA_OR_FORMULA:
433 0 : break;
434 : case FUNCTION:
435 0 : if ( isDefaultFunction(sDataField,sDataField,uno::Reference< report::XFunctionsSupplier>(),true) )
436 0 : aPropertyValue <<= (PROPERTY_ID_FORMULALIST == nId ? m_sDefaultFunction : m_sScope);
437 0 : break;
438 : case USER_DEF_FUNCTION:
439 0 : if ( !sDataField.isEmpty() && PROPERTY_ID_FORMULALIST == nId )
440 0 : aPropertyValue = aDataField;
441 0 : break;
442 : case COUNTER:
443 0 : if ( PROPERTY_ID_SCOPE == nId && impl_isCounterFunction_throw(sDataField,m_sScope) )
444 0 : aPropertyValue <<= m_sScope;
445 0 : break;
446 0 : }
447 :
448 : }
449 0 : break;
450 : case PROPERTY_ID_BACKCOLOR:
451 : case PROPERTY_ID_CONTROLBACKGROUND:
452 : {
453 0 : aPropertyValue = m_xReportComponent->getPropertyValue( PropertyName );
454 0 : sal_Int32 nColor = COL_TRANSPARENT;
455 0 : if ( (aPropertyValue >>= nColor) && static_cast<sal_Int32>(COL_TRANSPARENT) == nColor )
456 0 : aPropertyValue.clear();
457 : }
458 0 : break;
459 : case PROPERTY_ID_MIMETYPE:
460 : {
461 0 : ::rtl::OUString sValue;
462 0 : m_xReportComponent->getPropertyValue( PropertyName ) >>= sValue;
463 0 : aPropertyValue <<= impl_ConvertMimeTypeToUI_nothrow(sValue);
464 : }
465 0 : break;
466 : default:
467 0 : aPropertyValue = m_xReportComponent->getPropertyValue( PropertyName );
468 0 : break;
469 : }
470 0 : return aPropertyValue;
471 : }
472 :
473 0 : void SAL_CALL GeometryHandler::setPropertyValue(const ::rtl::OUString & PropertyName, const uno::Any & Value) throw (uno::RuntimeException, beans::UnknownPropertyException, beans::PropertyVetoException)
474 : {
475 0 : ::osl::ResettableMutexGuard aGuard( m_aMutex );
476 0 : uno::Any aNewValue = Value;
477 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
478 0 : bool bHandled = false;
479 0 : switch(nId)
480 : {
481 : case PROPERTY_ID_INITIALFORMULA:
482 : case PROPERTY_ID_FORMULA:
483 0 : break;
484 : case PROPERTY_ID_DATAFIELD:
485 : {
486 0 : OBlocker aBlocker(m_bIn);
487 0 : m_xReportComponent->setPropertyValue(PropertyName, aNewValue);
488 0 : bHandled = true;
489 0 : const ::rtl::OUString sOldFunctionName = m_sDefaultFunction;
490 0 : const ::rtl::OUString sOldScope = m_sScope;
491 :
492 0 : uno::Any aPropertyValue;
493 0 : lcl_convertFormulaTo(Value,aPropertyValue);
494 0 : ::rtl::OUString sDataField;
495 0 : aPropertyValue >>= sDataField;
496 :
497 0 : m_sScope = m_sDefaultFunction = ::rtl::OUString();
498 0 : m_xFunction.clear();
499 0 : const sal_uInt32 nOldDataFieldType = m_nDataFieldType;
500 0 : if ( !sDataField.isEmpty() )
501 : {
502 0 : if ( isDefaultFunction(sDataField,sDataField,uno::Reference< report::XFunctionsSupplier>(),true) )
503 0 : m_nDataFieldType = FUNCTION;
504 0 : else if ( m_aFunctionNames.find(sDataField) != m_aFunctionNames.end() )
505 0 : m_nDataFieldType = USER_DEF_FUNCTION;
506 : }
507 :
508 0 : resetOwnProperties(aGuard,sOldFunctionName,sOldScope,nOldDataFieldType);
509 : }
510 0 : break;
511 : case PROPERTY_ID_TYPE:
512 : {
513 0 : bHandled = true;
514 0 : Value >>= m_nDataFieldType;
515 :
516 0 : const ::rtl::OUString sOldFunctionName = m_sDefaultFunction;
517 0 : const ::rtl::OUString sOldScope = m_sScope;
518 0 : m_sDefaultFunction = m_sScope = ::rtl::OUString();
519 :
520 0 : if ( m_nDataFieldType == COUNTER )
521 : {
522 0 : impl_setCounterFunction_throw();
523 : }
524 : else
525 : {
526 0 : if ( m_bNewFunction )
527 0 : removeFunction();
528 0 : m_xFunction.clear();
529 0 : OBlocker aBlocker(m_bIn);
530 0 : m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(::rtl::OUString()));
531 : }
532 0 : resetOwnProperties(aGuard,sOldFunctionName,sOldScope,m_nDataFieldType);
533 : }
534 0 : break;
535 : case PROPERTY_ID_FORMULALIST:
536 : {
537 0 : bHandled = true;
538 0 : ::rtl::OUString sFunction;
539 0 : if ( !(Value >>= sFunction) || sFunction.isEmpty() )
540 : {
541 0 : if ( m_nDataFieldType == FUNCTION )
542 : {
543 0 : m_sDefaultFunction = ::rtl::OUString();
544 0 : if ( m_bNewFunction )
545 0 : removeFunction();
546 0 : m_xFunction.clear();
547 :
548 0 : beans::PropertyChangeEvent aEvent;
549 0 : aEvent.PropertyName = PROPERTY_SCOPE;
550 0 : aEvent.OldValue <<= m_sScope;
551 0 : m_sScope = ::rtl::OUString();
552 0 : aEvent.NewValue <<= m_sScope;
553 0 : aGuard.clear();
554 0 : m_aPropertyListeners.notify( aEvent, &beans::XPropertyChangeListener::propertyChange );
555 : }
556 0 : else if ( m_nDataFieldType == USER_DEF_FUNCTION )
557 : {
558 0 : OBlocker aBlocker(m_bIn);
559 0 : m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(::rtl::OUString()));
560 : }
561 : }
562 0 : else if ( m_nDataFieldType == USER_DEF_FUNCTION )
563 : {
564 0 : ::rtl::OUString sDataField;
565 0 : OBlocker aBlocker(m_bIn);
566 0 : const sal_uInt32 nNewDataType = impl_getDataFieldType_throw(sFunction);
567 0 : if ( nNewDataType != UNDEF_DATA && nNewDataType != m_nDataFieldType )
568 : {
569 0 : const ::rtl::OUString sOldFunctionName = m_sDefaultFunction;
570 0 : const ::rtl::OUString sOldScope = m_sScope;
571 0 : m_sScope = m_sDefaultFunction = ::rtl::OUString();
572 0 : m_xFunction.clear();
573 0 : if ( nNewDataType == COUNTER )
574 0 : impl_isCounterFunction_throw(sFunction,m_sScope);
575 : else
576 : {
577 0 : ::rtl::OUString sNamePostFix;
578 0 : const uno::Reference< report::XFunctionsSupplier> xFunctionsSupplier = fillScope_throw(sNamePostFix);
579 0 : isDefaultFunction(sFunction,sDataField,xFunctionsSupplier,true);
580 : }
581 0 : const sal_uInt32 nOldDataFieldType = m_nDataFieldType;
582 0 : m_nDataFieldType = nNewDataType;
583 0 : m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(impl_convertToFormula( uno::makeAny(sFunction))));
584 0 : resetOwnProperties(aGuard,sOldFunctionName,sOldScope,nOldDataFieldType);
585 : }
586 : else
587 0 : m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(impl_convertToFormula( uno::makeAny(sFunction))));
588 : }
589 0 : else if ( m_nDataFieldType == FUNCTION )
590 : {
591 0 : uno::Any aPropertyValue = m_xReportComponent->getPropertyValue(PROPERTY_DATAFIELD);
592 0 : lcl_convertFormulaTo(aPropertyValue,aPropertyValue);
593 0 : ::rtl::OUString sDataField;
594 0 : aPropertyValue >>= sDataField;
595 0 : if ( m_nDataFieldType == FUNCTION && (!isDefaultFunction(sDataField,sDataField) || m_sDefaultFunction != sFunction) )
596 : {
597 0 : if ( m_bNewFunction )
598 0 : removeFunction();
599 : // function currently does not exist
600 0 : createDefaultFunction(aGuard,sFunction,sDataField);
601 0 : m_sDefaultFunction = sFunction;
602 0 : }
603 0 : }
604 : }
605 :
606 0 : break;
607 : case PROPERTY_ID_SCOPE:
608 0 : if ( !(Value >>= m_sScope) )
609 0 : m_sScope = ::rtl::OUString();
610 : else
611 : {
612 0 : if ( m_bNewFunction )
613 0 : removeFunction();
614 0 : if ( m_nDataFieldType == COUNTER )
615 0 : impl_setCounterFunction_throw();
616 : else
617 : {
618 : OSL_ENSURE(m_xFunction.is(),"Where is my function gone!");
619 :
620 0 : ::rtl::OUString sNamePostFix;
621 0 : const uno::Reference< report::XFunctionsSupplier> xFunctionsSupplier = fillScope_throw(sNamePostFix);
622 :
623 0 : ::rtl::OUString sQuotedFunctionName(lcl_getQuotedFunctionName(m_xFunction));
624 0 : if ( isDefaultFunction(sQuotedFunctionName,sQuotedFunctionName,xFunctionsSupplier,true) )
625 0 : m_bNewFunction = false;
626 : else
627 : {
628 0 : ::rtl::OUString sDefaultFunctionName;
629 0 : ::rtl::OUString sDataField;
630 0 : OSL_VERIFY( impl_isDefaultFunction_nothrow(m_xFunction,sDataField,sDefaultFunctionName) );
631 0 : m_sDefaultFunction = sDefaultFunctionName;
632 0 : createDefaultFunction(aGuard,m_sDefaultFunction,sDataField);
633 0 : }
634 : }
635 : }
636 0 : bHandled = true;
637 0 : break;
638 : case PROPERTY_ID_POSITIONX:
639 : case PROPERTY_ID_POSITIONY:
640 : case PROPERTY_ID_HEIGHT:
641 : case PROPERTY_ID_WIDTH:
642 : {
643 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
644 0 : if ( xSourceReportComponent.is() ) // check only report components
645 : {
646 0 : sal_Int32 nNewValue = 0;
647 0 : Value >>= nNewValue;
648 : OSL_ENSURE(nNewValue >= 0, "A position/dimension should not be negative!");
649 0 : nNewValue = lcl_round<sal_Int32, 10>(nNewValue);
650 0 : awt::Point aAwtPoint = xSourceReportComponent->getPosition();
651 0 : awt::Size aAwtSize = xSourceReportComponent->getSize();
652 0 : if ( nId == PROPERTY_ID_POSITIONX )
653 0 : aAwtPoint.X = nNewValue;
654 0 : else if ( nId == PROPERTY_ID_POSITIONY )
655 0 : aAwtPoint.Y = nNewValue;
656 0 : else if ( nId == PROPERTY_ID_HEIGHT )
657 0 : aAwtSize.Height = nNewValue;
658 0 : else if ( nId == PROPERTY_ID_WIDTH )
659 0 : aAwtSize.Width = nNewValue;
660 :
661 0 : checkPosAndSize(aAwtPoint,aAwtSize);
662 0 : }
663 : }
664 0 : break;
665 : case PROPERTY_ID_FONT:
666 : {
667 0 : const uno::Reference< report::XReportControlFormat > xReportControlFormat( m_xReportComponent,uno::UNO_QUERY_THROW );
668 0 : uno::Sequence< beans::NamedValue > aFontSettings;
669 0 : OSL_VERIFY( Value >>= aFontSettings );
670 0 : applyCharacterSettings( xReportControlFormat, aFontSettings );
671 0 : bHandled = true;
672 : }
673 0 : break;
674 : case PROPERTY_ID_MIMETYPE:
675 : {
676 0 : ::rtl::OUString sValue;
677 0 : Value >>= sValue;
678 0 : aNewValue <<= impl_ConvertUIToMimeType_nothrow(sValue);
679 : }
680 : default:
681 0 : break;
682 : }
683 :
684 0 : if ( !bHandled )
685 0 : m_xReportComponent->setPropertyValue(PropertyName, aNewValue);
686 0 : }
687 :
688 : // -----------------------------------------------------------------------------
689 0 : beans::PropertyState SAL_CALL GeometryHandler::getPropertyState(const ::rtl::OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
690 : {
691 0 : ::osl::MutexGuard aGuard( m_aMutex );
692 0 : return m_xFormComponentHandler->getPropertyState(PropertyName);
693 : }
694 : // -----------------------------------------------------------------------------
695 0 : void GeometryHandler::implCreateListLikeControl(
696 : const uno::Reference< inspection::XPropertyControlFactory >& _rxControlFactory
697 : ,inspection::LineDescriptor & out_Descriptor
698 : ,sal_uInt16 _nResId
699 : ,sal_Bool _bReadOnlyControl
700 : ,sal_Bool _bTrueIfListBoxFalseIfComboBox
701 : )
702 : {
703 0 : ::std::vector< ::rtl::OUString > aList;
704 0 : tools::StringListResource aRes(ModuleRes(_nResId),aList);
705 :
706 0 : implCreateListLikeControl(_rxControlFactory,out_Descriptor,aList,_bReadOnlyControl,_bTrueIfListBoxFalseIfComboBox);
707 0 : }
708 : // -----------------------------------------------------------------------------
709 0 : void GeometryHandler::implCreateListLikeControl(
710 : const uno::Reference< inspection::XPropertyControlFactory >& _rxControlFactory
711 : ,inspection::LineDescriptor & out_Descriptor
712 : ,const ::std::vector< ::rtl::OUString>& _aEntries
713 : ,sal_Bool _bReadOnlyControl
714 : ,sal_Bool _bTrueIfListBoxFalseIfComboBox
715 : )
716 : {
717 : const uno::Reference< inspection::XStringListControl > xListControl(
718 0 : _rxControlFactory->createPropertyControl(
719 : _bTrueIfListBoxFalseIfComboBox ? inspection::PropertyControlType::ListBox : inspection::PropertyControlType::ComboBox, _bReadOnlyControl
720 0 : ),
721 : uno::UNO_QUERY_THROW
722 0 : );
723 :
724 0 : out_Descriptor.Control = xListControl.get();
725 0 : ::std::for_each( _aEntries.begin(), _aEntries.end(),::boost::bind( &inspection::XStringListControl::appendListEntry, xListControl,_1 ));
726 0 : }
727 : // -----------------------------------------------------------------------------
728 :
729 0 : inspection::LineDescriptor SAL_CALL GeometryHandler::describePropertyLine(const ::rtl::OUString & PropertyName, const uno::Reference< inspection::XPropertyControlFactory > & _xControlFactory) throw (beans::UnknownPropertyException, lang::NullPointerException,uno::RuntimeException)
730 : {
731 0 : inspection::LineDescriptor aOut;
732 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
733 0 : switch(nId)
734 : {
735 : case PROPERTY_ID_FORCENEWPAGE:
736 : case PROPERTY_ID_NEWROWORCOL:
737 0 : implCreateListLikeControl(_xControlFactory,aOut,RID_STR_FORCENEWPAGE_CONST,sal_False,sal_True);
738 0 : break;
739 : case PROPERTY_ID_GROUPKEEPTOGETHER:
740 0 : implCreateListLikeControl(_xControlFactory,aOut,RID_STR_GROUPKEEPTOGETHER_CONST,sal_False,sal_True);
741 0 : break;
742 : case PROPERTY_ID_PAGEHEADEROPTION:
743 : case PROPERTY_ID_PAGEFOOTEROPTION:
744 0 : implCreateListLikeControl(_xControlFactory,aOut,RID_STR_REPORTPRINTOPTION_CONST,sal_False,sal_True);
745 0 : break;
746 : case PROPERTY_ID_FORMULALIST:
747 : {
748 0 : ::std::vector< ::rtl::OUString > aList;
749 0 : impl_fillFormulaList_nothrow(aList);
750 0 : implCreateListLikeControl(_xControlFactory,aOut,aList,sal_False,sal_True);
751 : }
752 0 : break;
753 : case PROPERTY_ID_SCOPE:
754 : {
755 0 : ::std::vector< ::rtl::OUString > aList;
756 0 : impl_fillScopeList_nothrow(aList);
757 0 : implCreateListLikeControl(_xControlFactory,aOut,aList,sal_False,sal_True);
758 : }
759 0 : break;
760 : case PROPERTY_ID_MIMETYPE:
761 : {
762 0 : ::std::vector< ::rtl::OUString > aList;
763 0 : impl_fillMimeTypes_nothrow(aList);
764 0 : implCreateListLikeControl(_xControlFactory,aOut,aList,sal_False,sal_True);
765 : }
766 0 : break;
767 : case PROPERTY_ID_TYPE:
768 0 : implCreateListLikeControl(_xControlFactory,aOut,RID_STR_TYPE_CONST,sal_False,sal_True);
769 0 : break;
770 : case PROPERTY_ID_VISIBLE:
771 : case PROPERTY_ID_CANGROW:
772 : case PROPERTY_ID_CANSHRINK:
773 : case PROPERTY_ID_REPEATSECTION:
774 : case PROPERTY_ID_PRINTREPEATEDVALUES:
775 : case PROPERTY_ID_STARTNEWCOLUMN:
776 : case PROPERTY_ID_RESETPAGENUMBER:
777 : case PROPERTY_ID_PRINTWHENGROUPCHANGE:
778 : case PROPERTY_ID_KEEPTOGETHER:
779 : case PROPERTY_ID_DEEPTRAVERSING:
780 : case PROPERTY_ID_PREEVALUATED:
781 : case PROPERTY_ID_PRESERVEIRI:
782 : case PROPERTY_ID_BACKTRANSPARENT:
783 : case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT:
784 : {
785 0 : sal_uInt16 nResId = RID_STR_BOOL;
786 0 : if ( PROPERTY_ID_KEEPTOGETHER == nId && uno::Reference< report::XGroup>(m_xReportComponent,uno::UNO_QUERY).is())
787 0 : nResId = RID_STR_KEEPTOGETHER_CONST;
788 0 : implCreateListLikeControl(_xControlFactory,aOut,nResId,sal_False,sal_True);
789 : }
790 0 : break;
791 : case PROPERTY_ID_INITIALFORMULA:
792 : case PROPERTY_ID_FORMULA:
793 0 : aOut.PrimaryButtonId = rtl::OUString::createFromAscii(UID_RPT_PROP_FORMULA);
794 0 : aOut.HasPrimaryButton = sal_True;
795 0 : aOut.Control = _xControlFactory->createPropertyControl(inspection::PropertyControlType::MultiLineTextField , sal_False);
796 0 : break;
797 : case PROPERTY_ID_CONDITIONALPRINTEXPRESSION:
798 0 : aOut.PrimaryButtonId = rtl::OUString::createFromAscii(UID_RPT_PROP_FORMULA);
799 0 : aOut.HasPrimaryButton = sal_True;
800 0 : aOut.Control = _xControlFactory->createPropertyControl(inspection::PropertyControlType::MultiLineTextField , sal_False);
801 0 : break;
802 : case PROPERTY_ID_DATAFIELD:
803 : {
804 : uno::Reference< inspection::XStringListControl > xListControl(
805 0 : _xControlFactory->createPropertyControl(
806 : m_nDataFieldType == DATA_OR_FORMULA ? inspection::PropertyControlType::ComboBox : inspection::PropertyControlType::ListBox, sal_False
807 0 : ),
808 : uno::UNO_QUERY_THROW
809 0 : );
810 :
811 0 : if ( m_nDataFieldType == DATA_OR_FORMULA )
812 : {
813 0 : aOut.PrimaryButtonId = rtl::OUString::createFromAscii(UID_RPT_PROP_FORMULA);
814 0 : aOut.HasPrimaryButton = sal_True;
815 : }
816 :
817 0 : aOut.Control = xListControl.get();
818 0 : if ( m_nDataFieldType == USER_DEF_FUNCTION )
819 : {
820 : // add function names
821 : ::std::for_each( m_aFunctionNames.begin(), m_aFunctionNames.end(),
822 : ::o3tl::compose1(
823 : ::boost::bind( &inspection::XStringListControl::appendListEntry, xListControl,_1 ),
824 0 : ::o3tl::select1st<TFunctions::value_type>()));
825 : }
826 : else
827 : {
828 0 : ::std::for_each( m_aFieldNames.getConstArray(), m_aFieldNames.getConstArray() + m_aFieldNames.getLength(),
829 0 : ::boost::bind( &inspection::XStringListControl::appendListEntry, xListControl, _1 ) );
830 0 : ::std::for_each( m_aParamNames.getConstArray(), m_aParamNames.getConstArray() + m_aParamNames.getLength(),
831 0 : ::boost::bind( &inspection::XStringListControl::appendListEntry, xListControl, _1 ) );
832 0 : }
833 : }
834 0 : break;
835 : case PROPERTY_ID_BACKCOLOR:
836 : case PROPERTY_ID_CONTROLBACKGROUND:
837 0 : aOut.Control = _xControlFactory->createPropertyControl( inspection::PropertyControlType::ColorListBox, sal_False );
838 0 : break;
839 : case PROPERTY_ID_FONT:
840 0 : aOut.PrimaryButtonId = rtl::OUString::createFromAscii(UID_RPT_RPT_PROP_DLG_FONT_TYPE);
841 0 : aOut.Control = _xControlFactory->createPropertyControl( inspection::PropertyControlType::TextField, sal_True );
842 0 : aOut.HasPrimaryButton = sal_True;
843 0 : break;
844 : case PROPERTY_ID_AREA:
845 0 : aOut.PrimaryButtonId = rtl::OUString::createFromAscii(UID_RPT_RPT_PROP_DLG_AREA);
846 0 : aOut.Control = _xControlFactory->createPropertyControl( inspection::PropertyControlType::TextField, sal_True );
847 0 : aOut.HasPrimaryButton = sal_True;
848 0 : break;
849 : case PROPERTY_ID_VERTICALALIGN:
850 0 : implCreateListLikeControl(_xControlFactory,aOut,RID_STR_VERTICAL_ALIGN_CONST,sal_False,sal_True);
851 0 : break;
852 : case PROPERTY_ID_PARAADJUST:
853 0 : implCreateListLikeControl(_xControlFactory,aOut,RID_STR_PARAADJUST_CONST,sal_False,sal_True);
854 0 : break;
855 : default:
856 : {
857 0 : aOut = m_xFormComponentHandler->describePropertyLine(PropertyName, _xControlFactory);
858 : }
859 : }
860 :
861 0 : if ( nId != -1 )
862 : {
863 0 : aOut.Category = ((m_pInfoService->getPropertyUIFlags(nId ) & PROP_FLAG_DATA_PROPERTY) != 0) ?
864 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data"))
865 : :
866 0 : ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("General"));
867 0 : aOut.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nId ) );
868 0 : aOut.DisplayName = m_pInfoService->getPropertyTranslation(nId);
869 : }
870 :
871 0 : if ( ( nId == PROPERTY_ID_POSITIONX )
872 : || ( nId == PROPERTY_ID_POSITIONY )
873 : || ( nId == PROPERTY_ID_WIDTH )
874 : || ( nId == PROPERTY_ID_HEIGHT )
875 : )
876 : {
877 0 : const MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
878 0 : const sal_Int16 nDisplayUnit = VCLUnoHelper::ConvertToMeasurementUnit( MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH, 1 );
879 0 : uno::Reference< inspection::XNumericControl > xNumericControl(aOut.Control,uno::UNO_QUERY);
880 0 : xNumericControl->setDecimalDigits( 2 );
881 0 : xNumericControl->setValueUnit( util::MeasureUnit::MM_100TH );
882 0 : uno::Reference< drawing::XShapeDescriptor> xShapeDesc(m_xReportComponent,uno::UNO_QUERY);
883 0 : bool bSetMin = !xShapeDesc.is() || xShapeDesc->getShapeType() != ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CustomShape"));
884 0 : if ( bSetMin )
885 0 : xNumericControl->setMinValue(beans::Optional<double>(sal_True,0.0));
886 0 : if ( nDisplayUnit != -1 )
887 0 : xNumericControl->setDisplayUnit( nDisplayUnit );
888 0 : uno::Reference< report::XReportComponent> xComp(m_xReportComponent,uno::UNO_QUERY);
889 0 : if ( xComp.is() && xComp->getSection().is() )
890 : {
891 0 : uno::Reference< report::XReportDefinition > xReport = xComp->getSection()->getReportDefinition();
892 : OSL_ENSURE(xReport.is(),"Why is the report definition NULL!");
893 0 : if ( xReport.is() )
894 : {
895 0 : const awt::Size aSize = getStyleProperty<awt::Size>(xReport,PROPERTY_PAPERSIZE);
896 0 : const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReport,PROPERTY_LEFTMARGIN);
897 0 : const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReport,PROPERTY_RIGHTMARGIN);
898 0 : switch(nId)
899 : {
900 : case PROPERTY_ID_POSITIONX:
901 : case PROPERTY_ID_POSITIONY:
902 : case PROPERTY_ID_WIDTH:
903 0 : if ( bSetMin )
904 0 : xNumericControl->setMinValue(beans::Optional<double>(sal_True,0.0));
905 0 : xNumericControl->setMaxValue(beans::Optional<double>(sal_True,double(aSize.Width - nLeftMargin - nRightMargin)));
906 0 : if ( PROPERTY_ID_WIDTH == nId )
907 : {
908 0 : uno::Reference<report::XFixedLine> xFixedLine(m_xReportComponent,uno::UNO_QUERY);
909 0 : if ( xFixedLine.is() && xFixedLine->getOrientation() == 1 ) // vertical
910 0 : xNumericControl->setMinValue(beans::Optional<double>(sal_True,0.08 ));
911 : }
912 0 : break;
913 : default:
914 0 : break;
915 : }
916 0 : }
917 : }
918 0 : else if ( PROPERTY_ID_HEIGHT == nId )
919 : {
920 0 : const uno::Reference< report::XSection> xSection(m_xReportComponent,uno::UNO_QUERY);
921 0 : if ( xSection.is() )
922 : {
923 0 : sal_Int32 nHeight = 0;
924 0 : const sal_Int32 nCount = xSection->getCount();
925 0 : for (sal_Int32 i = 0; i < nCount; ++i)
926 : {
927 0 : uno::Reference<drawing::XShape> xShape(xSection->getByIndex(i),uno::UNO_QUERY);
928 0 : nHeight = ::std::max<sal_Int32>(nHeight,xShape->getPosition().Y + xShape->getSize().Height);
929 0 : }
930 0 : xNumericControl->setMinValue(beans::Optional<double>(sal_True,nHeight ));
931 0 : }
932 0 : }
933 : }
934 0 : return aOut;
935 : }
936 : // -----------------------------------------------------------------------------
937 0 : beans::Property GeometryHandler::getProperty(const ::rtl::OUString & PropertyName)
938 : {
939 0 : uno::Sequence< beans::Property > aProps = getSupportedProperties();
940 0 : const beans::Property* pIter = aProps.getConstArray();
941 0 : const beans::Property* pEnd = pIter + aProps.getLength();
942 0 : const beans::Property* pFind = ::std::find_if(pIter,pEnd,::std::bind2nd(PropertyCompare(),boost::cref(PropertyName)));
943 0 : if ( pFind == pEnd )
944 0 : return beans::Property();
945 0 : return *pFind;
946 : }
947 0 : uno::Any GeometryHandler::getConstantValue(sal_Bool _bToControlValue,sal_uInt16 _nResId,const uno::Any& _aValue,const ::rtl::OUString& _sConstantName,const ::rtl::OUString & PropertyName )
948 : {
949 0 : ::std::vector< ::rtl::OUString > aList;
950 0 : tools::StringListResource aRes(ModuleRes(_nResId),aList);
951 0 : uno::Sequence< ::rtl::OUString > aSeq(aList.size());
952 0 : ::std::copy( aList.begin(), aList.end(), aSeq.getArray() );
953 :
954 0 : uno::Reference< inspection::XStringRepresentation > xConversionHelper = inspection::StringRepresentation::createConstant( m_xContext,m_xTypeConverter,_sConstantName,aSeq);
955 0 : if ( _bToControlValue )
956 : {
957 0 : return uno::makeAny( xConversionHelper->convertToControlValue( _aValue ) );
958 : }
959 : else
960 : {
961 0 : ::rtl::OUString sControlValue;
962 0 : _aValue >>= sControlValue;
963 0 : const beans::Property aProp = getProperty(PropertyName);
964 0 : return xConversionHelper->convertToPropertyValue( sControlValue, aProp.Type );
965 0 : }
966 : }
967 :
968 0 : uno::Any SAL_CALL GeometryHandler::convertToPropertyValue(const ::rtl::OUString & PropertyName, const uno::Any & _rControlValue) throw (uno::RuntimeException, beans::UnknownPropertyException)
969 : {
970 0 : ::osl::MutexGuard aGuard( m_aMutex );
971 0 : uno::Any aPropertyValue( _rControlValue );
972 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
973 0 : switch(nId)
974 : {
975 : case PROPERTY_ID_FORCENEWPAGE:
976 : case PROPERTY_ID_NEWROWORCOL:
977 0 : aPropertyValue = getConstantValue(sal_False,RID_STR_FORCENEWPAGE_CONST,_rControlValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.ForceNewPage")),PropertyName);
978 0 : break;
979 : case PROPERTY_ID_GROUPKEEPTOGETHER:
980 0 : aPropertyValue = getConstantValue(sal_False,RID_STR_GROUPKEEPTOGETHER_CONST,_rControlValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.GroupKeepTogether")),PropertyName);
981 0 : break;
982 : case PROPERTY_ID_PAGEHEADEROPTION:
983 : case PROPERTY_ID_PAGEFOOTEROPTION:
984 0 : aPropertyValue = getConstantValue(sal_False,RID_STR_REPORTPRINTOPTION_CONST,_rControlValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.ReportPrintOption")),PropertyName);
985 0 : break;
986 : case PROPERTY_ID_BACKCOLOR:
987 : case PROPERTY_ID_CONTROLBACKGROUND:
988 0 : if ( !_rControlValue.hasValue() )
989 : {
990 0 : aPropertyValue <<= static_cast<sal_Int32>(COL_TRANSPARENT);
991 0 : break;
992 : }
993 : // run through
994 :
995 : case PROPERTY_ID_KEEPTOGETHER:
996 0 : if ( uno::Reference< report::XGroup>(m_xReportComponent,uno::UNO_QUERY).is())
997 : {
998 0 : aPropertyValue = getConstantValue(sal_False,RID_STR_KEEPTOGETHER_CONST,_rControlValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.KeepTogether")),PropertyName);
999 0 : break;
1000 : }
1001 : // run through
1002 :
1003 : case PROPERTY_ID_VISIBLE:
1004 : case PROPERTY_ID_CANGROW:
1005 : case PROPERTY_ID_CANSHRINK:
1006 : case PROPERTY_ID_REPEATSECTION:
1007 : case PROPERTY_ID_PRINTREPEATEDVALUES:
1008 : case PROPERTY_ID_STARTNEWCOLUMN:
1009 : case PROPERTY_ID_RESETPAGENUMBER:
1010 : case PROPERTY_ID_PRINTWHENGROUPCHANGE:
1011 : case PROPERTY_ID_DEEPTRAVERSING:
1012 : case PROPERTY_ID_PREEVALUATED:
1013 : case PROPERTY_ID_PRESERVEIRI:
1014 : case PROPERTY_ID_BACKTRANSPARENT:
1015 : case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT:
1016 : {
1017 0 : if ( aPropertyValue.hasValue() )
1018 : {
1019 0 : const beans::Property aProp = getProperty(PropertyName);
1020 0 : if ( aPropertyValue.getValueType().equals( aProp.Type ) )
1021 : // nothing to do, type is already as desired
1022 0 : return aPropertyValue;
1023 :
1024 0 : if ( _rControlValue.getValueType().getTypeClass() == uno::TypeClass_STRING )
1025 : {
1026 0 : ::rtl::OUString sControlValue;
1027 0 : _rControlValue >>= sControlValue;
1028 :
1029 0 : const uno::Reference< inspection::XStringRepresentation > xConversionHelper = inspection::StringRepresentation::create( m_xContext,m_xTypeConverter );
1030 0 : aPropertyValue = xConversionHelper->convertToPropertyValue( sControlValue, aProp.Type );
1031 : }
1032 : else
1033 : {
1034 : try
1035 : {
1036 0 : aPropertyValue = m_xTypeConverter->convertTo( _rControlValue, aProp.Type );
1037 : }
1038 0 : catch( const uno::Exception& )
1039 : {
1040 : OSL_FAIL( "GeometryHandler::convertToPropertyValue: caught an exception while converting via TypeConverter!" );
1041 : }
1042 0 : }
1043 : }
1044 :
1045 0 : break;
1046 : }
1047 : case PROPERTY_ID_CONDITIONALPRINTEXPRESSION:
1048 : case PROPERTY_ID_INITIALFORMULA:
1049 : case PROPERTY_ID_FORMULA:
1050 0 : return uno::makeAny( impl_convertToFormula( _rControlValue ) );
1051 : case PROPERTY_ID_DATAFIELD:
1052 : {
1053 0 : ::rtl::OUString sDataField;
1054 0 : _rControlValue >>= sDataField;
1055 0 : if ( isDefaultFunction(sDataField,sDataField) )
1056 : {
1057 : OSL_ENSURE(m_xFunction.is(),"No function set!");
1058 0 : aPropertyValue <<= impl_convertToFormula( uno::makeAny(lcl_getQuotedFunctionName(m_xFunction)) );
1059 : }
1060 : else
1061 0 : aPropertyValue <<= impl_convertToFormula( _rControlValue );
1062 : }
1063 0 : break;
1064 : case PROPERTY_ID_POSITIONX:
1065 : {
1066 0 : aPropertyValue = m_xFormComponentHandler->convertToPropertyValue(PropertyName, _rControlValue);
1067 0 : sal_Int32 nPosX = 0;
1068 0 : aPropertyValue >>= nPosX;
1069 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
1070 0 : if ( xSourceReportComponent->getSection().is() )
1071 0 : nPosX += getStyleProperty<sal_Int32>(xSourceReportComponent->getSection()->getReportDefinition(),PROPERTY_LEFTMARGIN);
1072 0 : aPropertyValue <<= nPosX;
1073 : }
1074 0 : break;
1075 : case PROPERTY_ID_FONT:
1076 0 : aPropertyValue = m_xFormComponentHandler->convertToPropertyValue(PROPERTY_FONT, _rControlValue);
1077 0 : break;
1078 : case PROPERTY_ID_SCOPE:
1079 : case PROPERTY_ID_FORMULALIST:
1080 : case PROPERTY_ID_AREA:
1081 0 : aPropertyValue = _rControlValue;
1082 0 : break;
1083 : case PROPERTY_ID_TYPE:
1084 : {
1085 0 : ::rtl::OUString sValue;
1086 0 : _rControlValue >>= sValue;
1087 0 : ::std::vector< ::rtl::OUString > aList;
1088 0 : tools::StringListResource aRes(ModuleRes(RID_STR_TYPE_CONST),aList);
1089 0 : ::std::vector< ::rtl::OUString >::iterator aFind = ::std::find(aList.begin(),aList.end(),sValue);
1090 0 : if ( aFind != aList.end() )
1091 0 : aPropertyValue <<= static_cast<sal_uInt32>(aFind - aList.begin());
1092 : }
1093 0 : break;
1094 : case PROPERTY_ID_MIMETYPE:
1095 0 : aPropertyValue = _rControlValue;
1096 0 : break;
1097 : case PROPERTY_ID_VERTICALALIGN:
1098 : {
1099 0 : ::rtl::OUString sValue;
1100 0 : _rControlValue >>= sValue;
1101 0 : ::std::vector< ::rtl::OUString > aList;
1102 0 : tools::StringListResource aRes(ModuleRes(RID_STR_VERTICAL_ALIGN_CONST),aList);
1103 0 : ::std::vector< ::rtl::OUString >::iterator aFind = ::std::find(aList.begin(),aList.end(),sValue);
1104 0 : if ( aFind != aList.end() )
1105 0 : aPropertyValue <<= static_cast<style::VerticalAlignment>(aFind - aList.begin());
1106 : }
1107 0 : break;
1108 : case PROPERTY_ID_PARAADJUST:
1109 : {
1110 0 : ::rtl::OUString sValue;
1111 0 : _rControlValue >>= sValue;
1112 0 : ::std::vector< ::rtl::OUString > aList;
1113 0 : tools::StringListResource aRes(ModuleRes(RID_STR_PARAADJUST_CONST),aList);
1114 0 : ::std::vector< ::rtl::OUString >::iterator aFind = ::std::find(aList.begin(),aList.end(),sValue);
1115 0 : if ( aFind != aList.end() )
1116 0 : aPropertyValue <<= static_cast<sal_Int16>(aFind - aList.begin());
1117 : }
1118 0 : break;
1119 : default:
1120 0 : return m_xFormComponentHandler->convertToPropertyValue(PropertyName, _rControlValue);
1121 : }
1122 0 : return aPropertyValue;
1123 : }
1124 :
1125 0 : uno::Any SAL_CALL GeometryHandler::convertToControlValue(const ::rtl::OUString & PropertyName, const uno::Any & _rPropertyValue, const uno::Type & _rControlValueType) throw (uno::RuntimeException, beans::UnknownPropertyException)
1126 : {
1127 0 : uno::Any aControlValue( _rPropertyValue );
1128 0 : if ( !aControlValue.hasValue() )
1129 : // NULL is converted to NULL
1130 : return aControlValue;
1131 :
1132 0 : uno::Any aPropertyValue(_rPropertyValue);
1133 :
1134 0 : ::osl::MutexGuard aGuard( m_aMutex );
1135 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(PropertyName);
1136 0 : switch(nId)
1137 : {
1138 : case PROPERTY_ID_AREA:
1139 0 : break;
1140 : case PROPERTY_ID_FORCENEWPAGE:
1141 : case PROPERTY_ID_NEWROWORCOL:
1142 0 : aControlValue = getConstantValue(sal_True,RID_STR_FORCENEWPAGE_CONST,aPropertyValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.ForceNewPage")),PropertyName);
1143 0 : break;
1144 : case PROPERTY_ID_GROUPKEEPTOGETHER:
1145 0 : aControlValue = getConstantValue(sal_True,RID_STR_GROUPKEEPTOGETHER_CONST,aPropertyValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.GroupKeepTogether")),PropertyName);
1146 0 : break;
1147 : case PROPERTY_ID_PAGEHEADEROPTION:
1148 : case PROPERTY_ID_PAGEFOOTEROPTION:
1149 0 : aControlValue = getConstantValue(sal_True,RID_STR_REPORTPRINTOPTION_CONST,aPropertyValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.ReportPrintOption")),PropertyName);
1150 0 : break;
1151 : case PROPERTY_ID_KEEPTOGETHER:
1152 0 : if ( uno::Reference< report::XGroup>(m_xReportComponent,uno::UNO_QUERY).is())
1153 : {
1154 0 : aControlValue = getConstantValue(sal_True,RID_STR_KEEPTOGETHER_CONST,aPropertyValue,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.KeepTogether")),PropertyName);
1155 0 : break;
1156 : }
1157 : // run through
1158 : case PROPERTY_ID_VISIBLE:
1159 : case PROPERTY_ID_CANGROW:
1160 : case PROPERTY_ID_CANSHRINK:
1161 : case PROPERTY_ID_REPEATSECTION:
1162 : case PROPERTY_ID_PRINTREPEATEDVALUES:
1163 : case PROPERTY_ID_STARTNEWCOLUMN:
1164 : case PROPERTY_ID_RESETPAGENUMBER:
1165 : case PROPERTY_ID_PRINTWHENGROUPCHANGE:
1166 : case PROPERTY_ID_DEEPTRAVERSING:
1167 : case PROPERTY_ID_PREEVALUATED:
1168 : case PROPERTY_ID_PRESERVEIRI:
1169 : case PROPERTY_ID_BACKTRANSPARENT:
1170 : case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT:
1171 : {
1172 0 : if ( _rControlValueType.getTypeClass() == uno::TypeClass_STRING )
1173 : {
1174 0 : const uno::Reference< inspection::XStringRepresentation > xConversionHelper = inspection::StringRepresentation::create( m_xContext,m_xTypeConverter );
1175 0 : aControlValue <<= xConversionHelper->convertToControlValue( aPropertyValue );
1176 : }
1177 : else
1178 : {
1179 : try
1180 : {
1181 0 : aControlValue = m_xTypeConverter->convertTo( aPropertyValue, _rControlValueType );
1182 : }
1183 0 : catch( const uno::Exception& )
1184 : {
1185 : OSL_FAIL( "GeometryHandler::convertToControlValue: caught an exception while converting via TypeConverter!" );
1186 : }
1187 : }
1188 0 : break;
1189 : }
1190 : case PROPERTY_ID_CONDITIONALPRINTEXPRESSION:
1191 : case PROPERTY_ID_INITIALFORMULA:
1192 : case PROPERTY_ID_FORMULA:
1193 0 : lcl_convertFormulaTo(aPropertyValue,aControlValue);
1194 0 : break;
1195 : case PROPERTY_ID_DATAFIELD:
1196 : {
1197 0 : ::rtl::OUString sValue;
1198 0 : aControlValue >>= sValue;
1199 0 : if ( isDefaultFunction(sValue,sValue) )
1200 0 : aControlValue <<= sValue;
1201 : else
1202 0 : lcl_convertFormulaTo(aPropertyValue,aControlValue);
1203 : }
1204 0 : break;
1205 : case PROPERTY_ID_FONT:
1206 0 : aControlValue = m_xFormComponentHandler->convertToControlValue(PROPERTY_FONT, aPropertyValue, _rControlValueType);
1207 0 : break;
1208 : case PROPERTY_ID_POSITIONX:
1209 : {
1210 0 : sal_Int32 nPosX = 0;
1211 0 : aPropertyValue >>= nPosX;
1212 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
1213 0 : if ( xSourceReportComponent->getSection().is() )
1214 0 : nPosX -= getStyleProperty<sal_Int32>(xSourceReportComponent->getSection()->getReportDefinition(),PROPERTY_LEFTMARGIN);
1215 0 : aPropertyValue <<= nPosX;
1216 0 : aControlValue = m_xFormComponentHandler->convertToControlValue(PropertyName, aPropertyValue, _rControlValueType);
1217 : }
1218 0 : break;
1219 : case PROPERTY_ID_FORMULALIST:
1220 0 : aControlValue <<= m_sDefaultFunction;
1221 0 : break;
1222 : case PROPERTY_ID_SCOPE:
1223 0 : aControlValue <<= m_sScope;
1224 0 : break;
1225 : case PROPERTY_ID_MIMETYPE:
1226 0 : aControlValue = aPropertyValue;
1227 0 : break;
1228 : case PROPERTY_ID_TYPE:
1229 : {
1230 0 : ::std::vector< ::rtl::OUString > aList;
1231 0 : tools::StringListResource aRes(ModuleRes(RID_STR_TYPE_CONST),aList);
1232 0 : if ( m_nDataFieldType < aList.size() )
1233 0 : aControlValue <<= aList[m_nDataFieldType];
1234 : }
1235 0 : break;
1236 : case PROPERTY_ID_VERTICALALIGN:
1237 : {
1238 0 : style::VerticalAlignment nParagraphVertAlign = style::VerticalAlignment_TOP;
1239 0 : aPropertyValue >>= nParagraphVertAlign;
1240 0 : ::std::vector< ::rtl::OUString > aList;
1241 0 : tools::StringListResource aRes(ModuleRes(RID_STR_VERTICAL_ALIGN_CONST),aList);
1242 0 : if ( static_cast<sal_Int16>(nParagraphVertAlign) < static_cast<sal_Int16>(aList.size()) )
1243 0 : aControlValue <<= aList[nParagraphVertAlign];
1244 : }
1245 0 : break;
1246 : case PROPERTY_ID_PARAADJUST:
1247 : {
1248 0 : sal_Int16 nParagraphAdjust = style::ParagraphAdjust_LEFT;
1249 0 : aPropertyValue >>= nParagraphAdjust;
1250 0 : ::std::vector< ::rtl::OUString > aList;
1251 0 : tools::StringListResource aRes(ModuleRes(RID_STR_PARAADJUST_CONST),aList);
1252 0 : if ( nParagraphAdjust < static_cast<sal_Int16>(aList.size()) )
1253 0 : aControlValue <<= aList[nParagraphAdjust];
1254 : }
1255 0 : break;
1256 : case PROPERTY_ID_BACKCOLOR:
1257 : case PROPERTY_ID_CONTROLBACKGROUND:
1258 : {
1259 0 : sal_Int32 nColor = COL_TRANSPARENT;
1260 0 : if ( (aPropertyValue >>= nColor) && static_cast<sal_Int32>(COL_TRANSPARENT) == nColor )
1261 0 : aPropertyValue.clear();
1262 : }
1263 : // run through
1264 : default:
1265 0 : aControlValue = m_xFormComponentHandler->convertToControlValue(PropertyName, aPropertyValue, _rControlValueType);
1266 : }
1267 0 : return aControlValue;
1268 : }
1269 0 : void SAL_CALL GeometryHandler::addPropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & _rxListener) throw (uno::RuntimeException, lang::NullPointerException)
1270 : {
1271 0 : ::osl::MutexGuard aGuard( m_aMutex );
1272 0 : m_aPropertyListeners.addListener( _rxListener );
1273 0 : m_xFormComponentHandler->addPropertyChangeListener(_rxListener);
1274 0 : }
1275 :
1276 0 : void SAL_CALL GeometryHandler::removePropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & _rxListener) throw (uno::RuntimeException)
1277 : {
1278 0 : ::osl::MutexGuard aGuard( m_aMutex );
1279 0 : m_aPropertyListeners.removeListener( _rxListener );
1280 0 : m_xFormComponentHandler->removePropertyChangeListener(_rxListener);
1281 0 : }
1282 : // -----------------------------------------------------------------------------
1283 : //--------------------------------------------------------------------------
1284 0 : uno::Sequence< beans::Property > SAL_CALL GeometryHandler::getSupportedProperties() throw (uno::RuntimeException)
1285 : {
1286 0 : ::std::vector< beans::Property > aNewProps;
1287 0 : aNewProps.reserve(20); // only a guess
1288 0 : m_pInfoService->getExcludeProperties( aNewProps, m_xFormComponentHandler );
1289 :
1290 : const ::rtl::OUString pIncludeProperties[] =
1291 : {
1292 : PROPERTY_FORCENEWPAGE
1293 : ,PROPERTY_KEEPTOGETHER
1294 : ,PROPERTY_CANGROW
1295 : ,PROPERTY_CANSHRINK
1296 : ,PROPERTY_REPEATSECTION
1297 : ,PROPERTY_PRINTREPEATEDVALUES
1298 : ,PROPERTY_CONDITIONALPRINTEXPRESSION
1299 : ,PROPERTY_STARTNEWCOLUMN
1300 : ,PROPERTY_RESETPAGENUMBER
1301 : ,PROPERTY_PRINTWHENGROUPCHANGE
1302 : ,PROPERTY_VISIBLE
1303 : ,PROPERTY_PAGEHEADEROPTION
1304 : ,PROPERTY_PAGEFOOTEROPTION
1305 : ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlLabel"))
1306 : ,PROPERTY_POSITIONX
1307 : ,PROPERTY_POSITIONY
1308 : ,PROPERTY_WIDTH
1309 : ,PROPERTY_HEIGHT
1310 : ,PROPERTY_PREEVALUATED
1311 : ,PROPERTY_DEEPTRAVERSING
1312 : ,PROPERTY_FORMULA
1313 : ,PROPERTY_INITIALFORMULA
1314 : ,PROPERTY_PRESERVEIRI
1315 : ,PROPERTY_DATAFIELD
1316 : ,PROPERTY_FONT
1317 : ,PROPERTY_BACKCOLOR
1318 : ,PROPERTY_BACKTRANSPARENT
1319 : ,PROPERTY_CONTROLBACKGROUND
1320 : ,PROPERTY_CONTROLBACKGROUNDTRANSPARENT
1321 : ,PROPERTY_LABEL
1322 : ,PROPERTY_MIMETYPE
1323 : ,PROPERTY_VERTICALALIGN
1324 : ,PROPERTY_PARAADJUST
1325 0 : };
1326 0 : const uno::Reference < beans::XPropertySetInfo > xInfo = m_xReportComponent->getPropertySetInfo();
1327 0 : const uno::Sequence< beans::Property> aSeq = xInfo->getProperties();
1328 0 : for (size_t i = 0; i < sizeof(pIncludeProperties)/sizeof(pIncludeProperties[0]) ;++i )
1329 : {
1330 0 : const beans::Property* pIter = aSeq.getConstArray();
1331 0 : const beans::Property* pEnd = pIter + aSeq.getLength();
1332 0 : const beans::Property* pFind = ::std::find_if(pIter,pEnd,::std::bind2nd(PropertyCompare(),boost::cref(pIncludeProperties[i])));
1333 0 : if ( pFind != pEnd )
1334 : {
1335 : // special case for controls which contain a data field
1336 0 : if ( PROPERTY_DATAFIELD == pIncludeProperties[i] )
1337 : {
1338 0 : beans::Property aValue;
1339 0 : aValue.Name = PROPERTY_FORMULALIST;
1340 0 : aNewProps.push_back(aValue);
1341 0 : aValue.Name = PROPERTY_SCOPE;
1342 0 : aNewProps.push_back(aValue);
1343 0 : aValue.Name = PROPERTY_TYPE;
1344 0 : aNewProps.push_back(aValue);
1345 : }
1346 0 : aNewProps.push_back(*pFind);
1347 : }
1348 : }
1349 :
1350 : // special property for shapes
1351 : // if ( uno::Reference< report::XShape>(m_xReportComponent,uno::UNO_QUERY).is() )
1352 : // {
1353 : // beans::Property aValue;
1354 : // aValue.Name = PROPERTY_AREA;
1355 : // aNewProps.push_back(aValue);
1356 : // }
1357 : // re-enable when the remaining issues of #i88727# are fixed
1358 :
1359 0 : return uno::Sequence< beans::Property > (&(*aNewProps.begin()),aNewProps.size());
1360 : }
1361 :
1362 0 : uno::Sequence< ::rtl::OUString > SAL_CALL GeometryHandler::getSupersededProperties() throw (uno::RuntimeException)
1363 : {
1364 0 : uno::Sequence< ::rtl::OUString > aRet;
1365 0 : const uno::Reference<report::XReportDefinition> xReport(m_xReportComponent,uno::UNO_QUERY);
1366 0 : if ( xReport.is() && !uno::Reference< report::XSection>(xReport->getParent(),uno::UNO_QUERY).is() )
1367 : {
1368 0 : aRet.realloc(5);
1369 0 : ::rtl::OUString* pIter = aRet.getArray();
1370 0 : *pIter++ = PROPERTY_POSITIONX;
1371 0 : *pIter++ = PROPERTY_POSITIONY;
1372 0 : *pIter++ = PROPERTY_WIDTH;
1373 0 : *pIter++ = PROPERTY_HEIGHT;
1374 0 : *pIter++ = PROPERTY_DATAFIELD;
1375 : }
1376 0 : return aRet;
1377 : }
1378 :
1379 0 : uno::Sequence< ::rtl::OUString > SAL_CALL GeometryHandler::getActuatingProperties() throw (uno::RuntimeException)
1380 : {
1381 0 : ::osl::MutexGuard aGuard( m_aMutex );
1382 :
1383 0 : uno::Sequence< ::rtl::OUString > aSeq(5);
1384 0 : aSeq[0] = PROPERTY_BACKTRANSPARENT;
1385 0 : aSeq[1] = PROPERTY_CONTROLBACKGROUNDTRANSPARENT;
1386 0 : aSeq[2] = PROPERTY_FORMULALIST;
1387 0 : aSeq[3] = PROPERTY_TYPE;
1388 0 : aSeq[4] = PROPERTY_DATAFIELD;
1389 :
1390 0 : return ::comphelper::concatSequences(m_xFormComponentHandler->getActuatingProperties(),aSeq);
1391 : }
1392 :
1393 0 : ::sal_Bool SAL_CALL GeometryHandler::isComposable(const ::rtl::OUString & _rPropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
1394 : {
1395 0 : return m_pInfoService->isComposable( _rPropertyName, m_xFormComponentHandler );
1396 : }
1397 :
1398 0 : inspection::InteractiveSelectionResult SAL_CALL GeometryHandler::onInteractivePropertySelection(const ::rtl::OUString & PropertyName, ::sal_Bool Primary, uno::Any & _rData, const uno::Reference< inspection::XObjectInspectorUI > & _rxInspectorUI) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::NullPointerException)
1399 : {
1400 0 : if ( !_rxInspectorUI.is() )
1401 0 : throw lang::NullPointerException();
1402 0 : if (PropertyName.equalsAsciiL(PROPERTY_FILTER.ascii, PROPERTY_FILTER.length))
1403 : {
1404 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
1405 :
1406 0 : inspection::InteractiveSelectionResult eResult = inspection::InteractiveSelectionResult_Cancelled;
1407 0 : ::rtl::OUString sClause;
1408 0 : if ( impl_dialogFilter_nothrow( sClause, aGuard ) )
1409 : {
1410 0 : _rData <<= sClause;
1411 0 : eResult = inspection::InteractiveSelectionResult_ObtainedValue;
1412 : }
1413 0 : return eResult;
1414 : }
1415 0 : else if (PropertyName.equalsAsciiL(PROPERTY_FONT.ascii, PROPERTY_FONT.length))
1416 : {
1417 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
1418 :
1419 0 : inspection::InteractiveSelectionResult eResult = inspection::InteractiveSelectionResult_Cancelled;
1420 0 : const uno::Reference< awt::XWindow> xInspectorWindow(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow"))) ,uno::UNO_QUERY);
1421 0 : const uno::Reference< report::XReportControlFormat> xReportControlFormat(m_xReportComponent,uno::UNO_QUERY);
1422 0 : aGuard.clear();
1423 :
1424 0 : uno::Sequence< beans::NamedValue > aFontSettings;
1425 0 : if ( rptui::openCharDialog( xReportControlFormat, xInspectorWindow, aFontSettings ) )
1426 : {
1427 0 : _rData <<= aFontSettings;
1428 0 : eResult = inspection::InteractiveSelectionResult_ObtainedValue;
1429 : }
1430 0 : return eResult;
1431 : }
1432 0 : else if ( PropertyName.equalsAsciiL(PROPERTY_FORMULA.ascii, PROPERTY_FORMULA.length)
1433 0 : || PropertyName.equalsAsciiL(PROPERTY_INITIALFORMULA.ascii, PROPERTY_INITIALFORMULA.length)
1434 0 : || PropertyName.equalsAsciiL(PROPERTY_DATAFIELD.ascii, PROPERTY_INITIALFORMULA.length)
1435 0 : || PropertyName.equalsAsciiL(PROPERTY_CONDITIONALPRINTEXPRESSION.ascii, PROPERTY_CONDITIONALPRINTEXPRESSION.length))
1436 : {
1437 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
1438 :
1439 :
1440 0 : ::rtl::OUString sFormula;
1441 0 : m_xReportComponent->getPropertyValue(PropertyName) >>= sFormula;
1442 0 : const uno::Reference< awt::XWindow> xInspectorWindow(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow"))) ,uno::UNO_QUERY);
1443 0 : uno::Reference< uno::XComponentContext > xContext = m_xContext;
1444 0 : uno::Reference< beans::XPropertySet > xRowSet( m_xRowSet,uno::UNO_QUERY);
1445 0 : aGuard.clear();
1446 :
1447 0 : inspection::InteractiveSelectionResult eResult = inspection::InteractiveSelectionResult_Cancelled;
1448 0 : if ( rptui::openDialogFormula_nothrow( sFormula, xContext,xInspectorWindow,xRowSet ) )
1449 : {
1450 0 : _rData <<= sFormula;
1451 0 : eResult = inspection::InteractiveSelectionResult_ObtainedValue;
1452 : }
1453 0 : return eResult;
1454 : }
1455 0 : else if (PropertyName.equalsAsciiL(PROPERTY_AREA.ascii, PROPERTY_AREA.length))
1456 : {
1457 0 : ::osl::ClearableMutexGuard aGuard( m_aMutex );
1458 :
1459 0 : inspection::InteractiveSelectionResult eResult = inspection::InteractiveSelectionResult_Cancelled;
1460 0 : const uno::Reference< awt::XWindow> xInspectorWindow(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow"))) ,uno::UNO_QUERY);
1461 0 : const uno::Reference< report::XShape> xShape(m_xReportComponent,uno::UNO_QUERY);
1462 0 : aGuard.clear();
1463 :
1464 0 : if ( rptui::openAreaDialog( xShape, xInspectorWindow) )
1465 : {
1466 0 : eResult = inspection::InteractiveSelectionResult_ObtainedValue;
1467 0 : beans::PropertyChangeEvent aScopeEvent;
1468 0 : aScopeEvent.PropertyName = PROPERTY_FILLCOLOR;
1469 0 : aScopeEvent.NewValue <<= xShape->getPropertyValue(PROPERTY_FILLCOLOR);
1470 0 : m_aPropertyListeners.notify( aScopeEvent, &beans::XPropertyChangeListener::propertyChange );
1471 : }
1472 0 : return eResult;
1473 : }
1474 :
1475 :
1476 0 : return m_xFormComponentHandler->onInteractivePropertySelection(PropertyName, Primary, _rData, _rxInspectorUI);
1477 : }
1478 :
1479 0 : void SAL_CALL GeometryHandler::actuatingPropertyChanged(const ::rtl::OUString & ActuatingPropertyName, const uno::Any & NewValue, const uno::Any & OldValue, const uno::Reference< inspection::XObjectInspectorUI > & _rxInspectorUI, ::sal_Bool _bFirstTimeInit) throw (uno::RuntimeException, lang::NullPointerException)
1480 : {
1481 0 : if ( !_rxInspectorUI.is() )
1482 0 : throw lang::NullPointerException();
1483 :
1484 0 : ::osl::MutexGuard aGuard( m_aMutex );
1485 0 : const sal_Int32 nId = m_pInfoService->getPropertyId(ActuatingPropertyName);
1486 0 : switch(nId)
1487 : {
1488 : case PROPERTY_ID_TYPE:
1489 : {
1490 0 : sal_uInt32 nNewVal = 0;
1491 0 : NewValue >>= nNewVal;
1492 0 : switch(nNewVal)
1493 : {
1494 : case DATA_OR_FORMULA:
1495 0 : _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD);
1496 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_True);
1497 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_False);
1498 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_False);
1499 : OSL_ENSURE(m_sDefaultFunction.isEmpty(),"Why is the m_sDefaultFunction set?");
1500 : OSL_ENSURE(m_sScope.isEmpty(),"Why is the m_sScope set?");
1501 0 : break;
1502 : case FUNCTION:
1503 0 : _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD);
1504 0 : _rxInspectorUI->rebuildPropertyUI(PROPERTY_FORMULALIST);
1505 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_True);
1506 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,!m_sDefaultFunction.isEmpty());
1507 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,!m_sScope.isEmpty());
1508 0 : break;
1509 : case USER_DEF_FUNCTION:
1510 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_False);
1511 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_True);
1512 0 : _rxInspectorUI->rebuildPropertyUI(PROPERTY_FORMULALIST);
1513 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_False);
1514 0 : break;
1515 : case COUNTER:
1516 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_DATAFIELD,sal_False);
1517 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,sal_False);
1518 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,sal_True);
1519 0 : break;
1520 : }
1521 : }
1522 0 : break;
1523 : case PROPERTY_ID_DATAFIELD:
1524 : {
1525 0 : sal_Bool bEnable = (m_nDataFieldType != DATA_OR_FORMULA && m_nDataFieldType != COUNTER );
1526 0 : if ( bEnable )
1527 : {
1528 0 : ::rtl::OUString sValue;
1529 0 : m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD ) >>= sValue;
1530 0 : bEnable = !sValue.isEmpty();
1531 : }
1532 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_FORMULALIST,bEnable);
1533 0 : if ( bEnable )
1534 : {
1535 0 : _rxInspectorUI->rebuildPropertyUI(PROPERTY_DATAFIELD);
1536 0 : _rxInspectorUI->rebuildPropertyUI(PROPERTY_FORMULALIST);
1537 : }
1538 0 : m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, _rxInspectorUI, _bFirstTimeInit);
1539 : }
1540 0 : break;
1541 : case PROPERTY_ID_FORMULALIST:
1542 : {
1543 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_SCOPE,m_nDataFieldType == FUNCTION || m_nDataFieldType == COUNTER);
1544 : }
1545 0 : break;
1546 : case PROPERTY_ID_BACKTRANSPARENT:
1547 : case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT:
1548 : {
1549 0 : sal_Bool bValue = sal_False;
1550 0 : NewValue >>= bValue;
1551 0 : bValue = !bValue;
1552 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_BACKCOLOR,bValue);
1553 0 : _rxInspectorUI->enablePropertyUI(PROPERTY_CONTROLBACKGROUND,bValue);
1554 : }
1555 0 : break;
1556 : default:
1557 0 : m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, _rxInspectorUI, _bFirstTimeInit);
1558 0 : break;
1559 0 : }
1560 0 : }
1561 :
1562 0 : ::sal_Bool SAL_CALL GeometryHandler::suspend(::sal_Bool Suspend) throw (uno::RuntimeException)
1563 : {
1564 0 : return m_xFormComponentHandler->suspend(Suspend);
1565 : }
1566 : // -----------------------------------------------------------------------------
1567 0 : bool GeometryHandler::impl_dialogFilter_nothrow( ::rtl::OUString& _out_rSelectedClause, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
1568 : {
1569 0 : _out_rSelectedClause = ::rtl::OUString();
1570 0 : bool bSuccess = false;
1571 0 : ::dbtools::SQLExceptionInfo aErrorInfo;
1572 0 : uno::Reference< awt::XWindow > xInspectorWindow;
1573 0 : uno::Reference< lang::XMultiComponentFactory > xFactory;
1574 : try
1575 : {
1576 0 : xFactory = m_xContext->getServiceManager();
1577 0 : xInspectorWindow.set(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow"))) ,uno::UNO_QUERY);
1578 0 : uno::Reference<sdbc::XConnection> xCon(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ActiveConnection"))) ,uno::UNO_QUERY);
1579 0 : if ( !xCon.is() )
1580 0 : return false;
1581 :
1582 0 : uno::Reference< beans::XPropertySet> xRowSetProp(m_xRowSet,uno::UNO_QUERY);
1583 0 : if ( !m_xRowSet.is() )
1584 : {
1585 0 : m_xRowSet.set(xFactory->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.RowSet")),m_xContext),uno::UNO_QUERY);
1586 0 : xRowSetProp.set(m_xRowSet,uno::UNO_QUERY);
1587 0 : xRowSetProp->setPropertyValue(PROPERTY_ACTIVECONNECTION,uno::makeAny(xCon));
1588 0 : ::comphelper::copyProperties(m_xReportComponent,xRowSetProp);
1589 : }
1590 :
1591 : // get a composer for the statement which the form is currently based on
1592 0 : uno::Reference< sdb::XSingleSelectQueryComposer > xComposer( ::dbtools::getCurrentSettingsComposer( xRowSetProp, m_xContext ) );
1593 : OSL_ENSURE( xComposer.is(), "GeometryHandler::impl_dialogFilter_nothrow: could not obtain a composer!" );
1594 0 : if ( !xComposer.is() )
1595 0 : return false;
1596 :
1597 : // create the dialog
1598 0 : uno::Reference< ui::dialogs::XExecutableDialog > xDialog = sdb::FilterDialog::createWithQuery(m_xContext, xComposer, m_xRowSet, xInspectorWindow);
1599 :
1600 0 : const String aGcc3WorkaroundTemporary( ModuleRes(RID_STR_FILTER));
1601 0 : const ::rtl::OUString sPropertyUIName( aGcc3WorkaroundTemporary );
1602 : // initialize the dialog
1603 0 : xDialog->setTitle( sPropertyUIName );
1604 :
1605 0 : _rClearBeforeDialog.clear();
1606 0 : bSuccess = ( xDialog->execute() != 0 );
1607 0 : if ( bSuccess )
1608 0 : _out_rSelectedClause = xComposer->getFilter();
1609 : }
1610 0 : catch (const sdb::SQLContext& e) { aErrorInfo = e; }
1611 0 : catch (const sdbc::SQLWarning& e) { aErrorInfo = e; }
1612 0 : catch (const sdbc::SQLException& e) { aErrorInfo = e; }
1613 0 : catch( const uno::Exception& )
1614 : {
1615 : OSL_FAIL( "GeometryHandler::impl_dialogFilter_nothrow: caught an exception!" );
1616 : }
1617 :
1618 0 : if ( aErrorInfo.isValid() )
1619 0 : ::dbtools::showError( aErrorInfo, xInspectorWindow, m_xContext );
1620 :
1621 0 : return bSuccess;
1622 : }
1623 : // -----------------------------------------------------------------------------
1624 0 : void GeometryHandler::checkPosAndSize( const awt::Point& _aNewPos,
1625 : const awt::Size& _aSize)
1626 : {
1627 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY);
1628 0 : const uno::Reference< report::XSection> xSection(xSourceReportComponent->getParent(),uno::UNO_QUERY);
1629 0 : if ( !xSection.is() || uno::Reference< report::XShape>(xSourceReportComponent,uno::UNO_QUERY).is() ) // shapes can overlap.
1630 0 : return;
1631 :
1632 0 : ::Point aPos(VCLPoint(_aNewPos));
1633 0 : if ( aPos.X() < 0 || aPos.Y() < 0 ) // TODO: have to check size with pos aka || (aPos.X() + aAwtSize.Width) > m_xSection->getReportDefinition()->
1634 0 : throw beans::PropertyVetoException(String(ModuleRes(RID_STR_ILLEGAL_POSITION)),xSourceReportComponent);
1635 :
1636 0 : ::Rectangle aSourceRect(aPos,VCLSize(_aSize));
1637 :
1638 0 : const sal_Int32 nCount = xSection->getCount();
1639 0 : for (sal_Int32 i = 0; i < nCount ; ++i)
1640 : {
1641 0 : const uno::Reference< report::XReportComponent> xReportComponent(xSection->getByIndex(i),uno::UNO_QUERY);
1642 0 : if ( xReportComponent.is() && xReportComponent != xSourceReportComponent )
1643 : {
1644 0 : const ::Rectangle aBoundRect(VCLPoint(xReportComponent->getPosition()),VCLSize(xReportComponent->getSize()));
1645 0 : const ::Rectangle aRect = aSourceRect.GetIntersection(aBoundRect);
1646 0 : if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && aRect.Top() != aRect.Bottom() ) )
1647 0 : throw beans::PropertyVetoException(String(ModuleRes( RID_STR_OVERLAP_OTHER_CONTROL)),xSourceReportComponent);
1648 : }
1649 0 : }
1650 : }
1651 : // -----------------------------------------------------------------------------
1652 0 : void GeometryHandler::impl_fillFormulaList_nothrow(::std::vector< ::rtl::OUString >& _out_rList) const
1653 : {
1654 0 : if ( m_nDataFieldType == FUNCTION )
1655 0 : ::std::transform(m_aDefaultFunctions.begin(),m_aDefaultFunctions.end(),::std::back_inserter(_out_rList),::boost::bind( &DefaultFunction::getName, _1 ));
1656 0 : else if ( m_nDataFieldType == USER_DEF_FUNCTION )
1657 0 : ::std::transform(m_aFunctionNames.begin(),m_aFunctionNames.end(),::std::back_inserter(_out_rList),::o3tl::select1st<TFunctions::value_type>());
1658 0 : }
1659 : // -----------------------------------------------------------------------------
1660 0 : ::rtl::OUString GeometryHandler::impl_ConvertUIToMimeType_nothrow(const ::rtl::OUString& _sUIName) const
1661 : {
1662 0 : ::std::vector< ::rtl::OUString > aList;
1663 0 : impl_fillMimeTypes_nothrow(aList);
1664 0 : ::rtl::OUString sRet;
1665 0 : ::std::vector< ::rtl::OUString >::const_iterator aFind = ::std::find(aList.begin(),aList.end(),_sUIName);
1666 0 : if ( aFind != aList.end() )
1667 : {
1668 0 : const sal_Size nPos = aFind - aList.begin();
1669 0 : const uno::Reference< report::XReportDefinition> xReportDefinition(m_xReportComponent,uno::UNO_QUERY);
1670 0 : if ( xReportDefinition.is() )
1671 : {
1672 0 : const uno::Sequence< ::rtl::OUString > aMimeTypes( xReportDefinition->getAvailableMimeTypes() );
1673 0 : sRet = aMimeTypes[nPos];
1674 0 : }
1675 : }
1676 0 : return sRet;
1677 : }
1678 : // -----------------------------------------------------------------------------
1679 0 : ::rtl::OUString GeometryHandler::impl_ConvertMimeTypeToUI_nothrow(const ::rtl::OUString& _sMimetype) const
1680 : {
1681 0 : uno::Reference<lang::XMultiServiceFactory> xServiceFactory(m_xContext->getServiceManager(),uno::UNO_QUERY_THROW);
1682 0 : ::comphelper::MimeConfigurationHelper aMimeHelper(xServiceFactory);
1683 0 : ::rtl::OUString sRet;
1684 0 : const SfxFilter* pFilter = SfxFilter::GetDefaultFilter( aMimeHelper.GetDocServiceNameFromMediaType(_sMimetype) );
1685 0 : if ( pFilter )
1686 0 : sRet = pFilter->GetUIName();
1687 0 : if ( sRet.isEmpty() )
1688 0 : sRet = _sMimetype;
1689 0 : return sRet;
1690 : }
1691 : // -----------------------------------------------------------------------------
1692 0 : void GeometryHandler::impl_fillMimeTypes_nothrow(::std::vector< ::rtl::OUString >& _out_rList) const
1693 : {
1694 : try
1695 : {
1696 0 : const uno::Reference< report::XReportDefinition> xReportDefinition(m_xReportComponent,uno::UNO_QUERY);
1697 0 : if ( xReportDefinition.is() )
1698 : {
1699 0 : uno::Sequence< ::rtl::OUString > aMimeTypes( xReportDefinition->getAvailableMimeTypes() );
1700 0 : const ::rtl::OUString* pIter = aMimeTypes.getConstArray();
1701 0 : const ::rtl::OUString* pEnd = pIter + aMimeTypes.getLength();
1702 0 : for(;pIter != pEnd; ++pIter)
1703 : {
1704 0 : const ::rtl::OUString sDocName( impl_ConvertMimeTypeToUI_nothrow(*pIter) );
1705 0 : if ( !sDocName.isEmpty() )
1706 0 : _out_rList.push_back(sDocName);
1707 0 : }
1708 0 : }
1709 : }
1710 0 : catch(uno::Exception&)
1711 : {
1712 : OSL_FAIL("Exception caught!");
1713 : }
1714 0 : }
1715 : // -----------------------------------------------------------------------------
1716 0 : void GeometryHandler::impl_fillScopeList_nothrow(::std::vector< ::rtl::OUString >& _out_rList) const
1717 : {
1718 : try
1719 : {
1720 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY_THROW);
1721 0 : const uno::Reference< report::XSection> xSection(xSourceReportComponent->getParent(),uno::UNO_QUERY_THROW);
1722 :
1723 0 : const uno::Reference< report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
1724 0 : const uno::Reference< report::XGroups> xGroups = xReportDefinition->getGroups();
1725 0 : sal_Int32 nPos = -1;
1726 0 : uno::Reference< report::XGroup> xGroup = xSection->getGroup();
1727 0 : if ( xGroup.is() )
1728 0 : nPos = getPositionInIndexAccess(xGroups.get(),xGroup);
1729 0 : else if ( xSection == xReportDefinition->getDetail() )
1730 0 : nPos = xGroups->getCount()-1;
1731 :
1732 0 : const String sGroup = String(ModuleRes(RID_STR_SCOPE_GROUP));
1733 0 : for (sal_Int32 i = 0 ; i <= nPos ; ++i)
1734 : {
1735 0 : xGroup.set(xGroups->getByIndex(i),uno::UNO_QUERY_THROW);
1736 0 : String sGroupName = sGroup;
1737 0 : sGroupName.SearchAndReplaceAscii("%1",xGroup->getExpression());
1738 0 : _out_rList.push_back(sGroupName);
1739 0 : }
1740 0 : _out_rList.push_back(xReportDefinition->getName());
1741 : }
1742 0 : catch(uno::Exception&)
1743 : {
1744 : OSL_FAIL("Exception caught!");
1745 : }
1746 0 : }
1747 : // -----------------------------------------------------------------------------
1748 0 : uno::Reference< report::XFunctionsSupplier> GeometryHandler::fillScope_throw(::rtl::OUString& _rsNamePostFix)
1749 : {
1750 0 : uno::Reference< report::XFunctionsSupplier> xReturn;
1751 :
1752 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY_THROW);
1753 0 : const uno::Reference< report::XSection> xSection(xSourceReportComponent->getParent(),uno::UNO_QUERY_THROW);
1754 0 : const uno::Reference< report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
1755 0 : if ( m_sScope.isEmpty() )
1756 : {
1757 0 : const uno::Reference< report::XGroup> xGroup(xSection->getGroup(),uno::UNO_QUERY);
1758 0 : if ( xGroup.is() )
1759 : {
1760 0 : String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
1761 0 : _rsNamePostFix = xGroup->getExpression();
1762 0 : sGroupName.SearchAndReplaceAscii("%1",_rsNamePostFix);
1763 0 : m_sScope = sGroupName;
1764 0 : xReturn = xGroup.get();
1765 : }
1766 0 : else if ( xSection == xReportDefinition->getDetail() )
1767 : {
1768 0 : const uno::Reference< report::XGroups> xGroups = xReportDefinition->getGroups();
1769 0 : const sal_Int32 nCount = xGroups->getCount();
1770 0 : if ( nCount )
1771 : {
1772 0 : const uno::Reference< report::XGroup> xGroup2(xGroups->getByIndex(nCount - 1),uno::UNO_QUERY_THROW);
1773 0 : String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
1774 0 : _rsNamePostFix = xGroup2->getExpression();
1775 0 : sGroupName.SearchAndReplaceAscii("%1",_rsNamePostFix);
1776 0 : m_sScope = sGroupName;
1777 0 : xReturn = xGroup2.get();
1778 0 : }
1779 : }
1780 0 : if ( m_sScope.isEmpty() )
1781 : {
1782 0 : xReturn = xReportDefinition.get();
1783 0 : _rsNamePostFix = m_sScope = xReportDefinition->getName();
1784 0 : }
1785 : }
1786 0 : else if ( m_sScope == xReportDefinition->getName() )
1787 : {
1788 0 : xReturn = xReportDefinition.get();
1789 0 : _rsNamePostFix = m_sScope;
1790 : }
1791 : else
1792 : {
1793 0 : uno::Reference< report::XGroups> xGroups = xReportDefinition->getGroups();
1794 0 : const sal_Int32 nCount = xGroups->getCount();
1795 :
1796 0 : for (sal_Int32 i = 0 ; i < nCount; ++i)
1797 : {
1798 0 : const uno::Reference< report::XGroup> xGroup(xGroups->getByIndex(i),uno::UNO_QUERY_THROW);
1799 0 : String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
1800 0 : sGroupName.SearchAndReplaceAscii("%1",xGroup->getExpression());
1801 0 : if ( m_sScope == ::rtl::OUString(sGroupName) )
1802 : {
1803 0 : _rsNamePostFix = xGroup->getExpression();
1804 0 : xReturn = xGroup.get();
1805 : break;
1806 : }
1807 0 : }
1808 :
1809 : }
1810 : OSL_ENSURE(xReturn.is(),"Why don't we have a functionssupplier here!");
1811 :
1812 0 : return xReturn;
1813 : }
1814 : // -----------------------------------------------------------------------------
1815 0 : sal_Bool GeometryHandler::isDefaultFunction( const ::rtl::OUString& _sQuotedFunction
1816 : ,::rtl::OUString& _rDataField
1817 : ,const uno::Reference< report::XFunctionsSupplier>& _xFunctionsSupplier
1818 : ,bool _bSet) const
1819 : {
1820 0 : sal_Bool bDefaultFunction = sal_False;
1821 : try
1822 : {
1823 0 : const uno::Reference< report::XReportComponent> xSourceReportComponent(m_xReportComponent,uno::UNO_QUERY_THROW);
1824 0 : const uno::Reference< report::XSection> xSection(xSourceReportComponent->getParent(),uno::UNO_QUERY_THROW);
1825 0 : const uno::Reference< report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
1826 :
1827 0 : ::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> aFind = m_aFunctionNames.equal_range(_sQuotedFunction);
1828 0 : while ( aFind.first != aFind.second )
1829 : {
1830 0 : if ( !_xFunctionsSupplier.is() || _xFunctionsSupplier == aFind.first->second.second )
1831 : {
1832 0 : const beans::Optional< ::rtl::OUString> aInitalFormula = aFind.first->second.first->getInitialFormula();
1833 0 : if ( aInitalFormula.IsPresent )
1834 : {
1835 0 : ::rtl::OUString sDefaultFunctionName;
1836 0 : bDefaultFunction = impl_isDefaultFunction_nothrow(aFind.first->second.first,_rDataField,sDefaultFunctionName);
1837 0 : if ( bDefaultFunction )
1838 : {
1839 0 : m_xFunction = aFind.first->second.first;
1840 0 : if ( _bSet )
1841 : {
1842 0 : m_sDefaultFunction = sDefaultFunctionName;
1843 0 : uno::Reference< report::XGroup> xGroup(aFind.first->second.second,uno::UNO_QUERY);
1844 0 : if ( xGroup.is() )
1845 : {
1846 0 : String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
1847 0 : sGroupName.SearchAndReplaceAscii("%1",xGroup->getExpression());
1848 0 : m_sScope = sGroupName;
1849 : }
1850 : else
1851 0 : m_sScope = xReportDefinition->getName();
1852 : }
1853 : }
1854 0 : break;
1855 0 : }
1856 : }
1857 0 : ++(aFind.first);
1858 0 : }
1859 : }
1860 0 : catch(uno::Exception&)
1861 : {
1862 : OSL_FAIL("Exception caught!");
1863 : }
1864 0 : return bDefaultFunction;
1865 : }
1866 : // -----------------------------------------------------------------------------
1867 0 : sal_Bool GeometryHandler::impl_isDefaultFunction_nothrow( const uno::Reference< report::XFunction>& _xFunction
1868 : ,::rtl::OUString& _rDataField
1869 : ,::rtl::OUString& _rsDefaultFunctionName) const
1870 : {
1871 0 : sal_Bool bDefaultFunction = sal_False;
1872 : try
1873 : {
1874 0 : const String sFormula( _xFunction->getFormula() );
1875 0 : util::SearchOptions aSearchOptions;
1876 0 : aSearchOptions.algorithmType = util::SearchAlgorithms_REGEXP;
1877 0 : aSearchOptions.searchFlag = 0x00000100;
1878 0 : ::std::vector< DefaultFunction >::const_iterator aIter = m_aDefaultFunctions.begin();
1879 0 : ::std::vector< DefaultFunction >::const_iterator aDeEnd = m_aDefaultFunctions.end();
1880 0 : for (; aIter != aDeEnd; ++aIter)
1881 : {
1882 0 : aSearchOptions.searchString = aIter->m_sSearchString;
1883 0 : utl::TextSearch aTextSearch(aSearchOptions);
1884 0 : xub_StrLen start = 0;
1885 0 : xub_StrLen end = sFormula.Len();
1886 0 : if ( aTextSearch.SearchFrwrd(sFormula,&start,&end) && start == 0 && end == sFormula.Len()) // default function found
1887 : {
1888 0 : aSearchOptions.searchString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]"));
1889 0 : utl::TextSearch aDataSearch(aSearchOptions);
1890 0 : aDataSearch.SearchFrwrd(sFormula,&start,&end );
1891 0 : ++start;
1892 0 : _rDataField = sFormula.Copy(start,end-start-1);
1893 0 : _rsDefaultFunctionName = aIter->m_sName;
1894 0 : break;
1895 : }
1896 0 : }
1897 :
1898 0 : bDefaultFunction = aIter != aDeEnd;
1899 : }
1900 0 : catch(uno::Exception&)
1901 : {
1902 : OSL_FAIL("Exception caught!");
1903 : }
1904 0 : return bDefaultFunction;
1905 : }
1906 : // -----------------------------------------------------------------------------
1907 0 : void GeometryHandler::loadDefaultFunctions()
1908 : {
1909 0 : if ( m_aDefaultFunctions.empty() )
1910 : {
1911 0 : m_aCounterFunction.m_bPreEvaluated = sal_False;
1912 0 : m_aCounterFunction.m_bDeepTraversing = sal_False;
1913 0 : m_aCounterFunction.m_sName = String(ModuleRes(RID_STR_F_COUNTER));
1914 0 : m_aCounterFunction.m_sFormula = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%FunctionName] + 1"));
1915 0 : m_aCounterFunction.m_sSearchString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*[:digit:]*"));
1916 0 : m_aCounterFunction.m_sInitialFormula.IsPresent = sal_True;
1917 0 : m_aCounterFunction.m_sInitialFormula.Value = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:1"));
1918 :
1919 0 : DefaultFunction aDefault;
1920 0 : aDefault.m_bDeepTraversing = sal_False;
1921 :
1922 0 : aDefault.m_bPreEvaluated = sal_True;
1923 :
1924 0 : aDefault.m_sName = String(ModuleRes(RID_STR_F_ACCUMULATION));
1925 0 : aDefault.m_sFormula = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%Column] + [%FunctionName]"));
1926 0 : aDefault.m_sSearchString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]"));
1927 0 : aDefault.m_sInitialFormula.IsPresent = sal_True;
1928 0 : aDefault.m_sInitialFormula.Value = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%Column]"));
1929 0 : m_aDefaultFunctions.push_back(aDefault);
1930 :
1931 0 : aDefault.m_sName = String(ModuleRes(RID_STR_F_MINIMUM));
1932 0 : aDefault.m_sFormula = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF([%Column] < [%FunctionName];[%Column];[%FunctionName])"));
1933 0 : aDefault.m_sSearchString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*<[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)"));
1934 0 : aDefault.m_sInitialFormula.IsPresent = sal_True;
1935 0 : aDefault.m_sInitialFormula.Value = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%Column]"));
1936 0 : m_aDefaultFunctions.push_back(aDefault);
1937 :
1938 0 : aDefault.m_sName = String(ModuleRes(RID_STR_F_MAXIMUM));
1939 0 : aDefault.m_sFormula = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF([%Column] > [%FunctionName];[%Column];[%FunctionName])"));
1940 0 : aDefault.m_sSearchString = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*>[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)"));
1941 0 : aDefault.m_sInitialFormula.IsPresent = sal_True;
1942 0 : aDefault.m_sInitialFormula.Value = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:[%Column]"));
1943 0 : m_aDefaultFunctions.push_back(aDefault);
1944 : }
1945 0 : }
1946 : // -----------------------------------------------------------------------------
1947 0 : void GeometryHandler::createDefaultFunction(::osl::ResettableMutexGuard& _aGuard ,const ::rtl::OUString& _sFunction,const ::rtl::OUString& _sDataField)
1948 : {
1949 : try
1950 : {
1951 0 : ::rtl::OUString sNamePostFix;
1952 0 : const uno::Reference< report::XFunctionsSupplier> xFunctionsSupplier = fillScope_throw(sNamePostFix);
1953 :
1954 0 : ::std::vector< DefaultFunction >::const_iterator aIter = m_aDefaultFunctions.begin();
1955 0 : ::std::vector< DefaultFunction >::const_iterator aDeEnd = m_aDefaultFunctions.end();
1956 0 : for (; aIter != aDeEnd; ++aIter)
1957 : {
1958 0 : if ( aIter->m_sName == _sFunction )
1959 : {
1960 0 : const ::rtl::OUString sFunctionName( _sFunction + _sDataField + sNamePostFix);
1961 0 : const ::rtl::OUString sQuotedFunctionName(lcl_getQuotedFunctionName(sFunctionName));
1962 :
1963 0 : beans::PropertyChangeEvent aEvent;
1964 0 : aEvent.PropertyName = PROPERTY_SCOPE;
1965 0 : aEvent.OldValue <<= m_sScope;
1966 :
1967 0 : ::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> aFind = m_aFunctionNames.equal_range(sQuotedFunctionName);
1968 0 : while ( aFind.first != aFind.second )
1969 : {
1970 0 : if ( xFunctionsSupplier == aFind.first->second.second )
1971 : {
1972 0 : m_xFunction = aFind.first->second.first;
1973 0 : ::rtl::OUString sTemp;
1974 0 : isDefaultFunction(sQuotedFunctionName,sTemp,uno::Reference< report::XFunctionsSupplier>(),true); // implicitly sets the m_sScope
1975 0 : break;
1976 : }
1977 0 : ++(aFind.first);
1978 : }
1979 0 : if ( aFind.first == aFind.second )
1980 0 : impl_createFunction(sFunctionName,_sDataField,*aIter);
1981 :
1982 0 : OBlocker aBlocker(m_bIn);
1983 0 : m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny( impl_convertToFormula( uno::makeAny(sQuotedFunctionName) )));
1984 0 : aEvent.NewValue <<= m_sScope;
1985 0 : _aGuard.clear();
1986 0 : m_aPropertyListeners.notify( aEvent, &beans::XPropertyChangeListener::propertyChange );
1987 0 : break;
1988 : }
1989 0 : }
1990 : }
1991 0 : catch(uno::Exception&)
1992 : {
1993 : OSL_FAIL("Exception caught!");
1994 : }
1995 0 : }
1996 : // -----------------------------------------------------------------------------
1997 0 : void GeometryHandler::removeFunction()
1998 : {
1999 0 : if ( m_xFunction.is() )
2000 : {
2001 0 : const ::rtl::OUString sQuotedFunctionName(lcl_getQuotedFunctionName(m_xFunction));
2002 0 : ::std::pair<TFunctions::iterator,TFunctions::iterator> aFind = m_aFunctionNames.equal_range(sQuotedFunctionName);
2003 0 : while ( aFind.first != aFind.second )
2004 : {
2005 0 : if ( aFind.first->second.first == m_xFunction )
2006 : {
2007 0 : uno::Reference< report::XFunctions> xFunctions = aFind.first->second.second->getFunctions();
2008 0 : xFunctions->removeByIndex(xFunctions->getCount() - 1 ); /// TODO: insert new method in XFunctions: removeFunction(xfunction)
2009 0 : m_aFunctionNames.erase(aFind.first);
2010 0 : m_bNewFunction = false;
2011 0 : break;
2012 : }
2013 0 : ++(aFind.first);
2014 0 : }
2015 : }
2016 0 : }
2017 : // -----------------------------------------------------------------------------
2018 0 : void GeometryHandler::resetOwnProperties(::osl::ResettableMutexGuard& _aGuard,const ::rtl::OUString& _sOldFunctionName,const ::rtl::OUString& _sOldScope,const sal_uInt32 _nOldDataFieldType)
2019 : {
2020 0 : const ::rtl::OUString sNewFunction = m_sDefaultFunction;
2021 0 : const ::rtl::OUString sNewScope = m_sScope;
2022 0 : const sal_uInt32 nNewDataFieldType = m_nDataFieldType;
2023 0 : _aGuard.clear();
2024 0 : if ( _nOldDataFieldType != nNewDataFieldType )
2025 : {
2026 0 : beans::PropertyChangeEvent aScopeEvent;
2027 0 : aScopeEvent.PropertyName = PROPERTY_TYPE;
2028 0 : aScopeEvent.OldValue <<= _nOldDataFieldType;
2029 0 : aScopeEvent.NewValue <<= nNewDataFieldType;
2030 0 : m_aPropertyListeners.notify( aScopeEvent, &beans::XPropertyChangeListener::propertyChange );
2031 : }
2032 0 : if ( _sOldFunctionName != sNewFunction )
2033 : {
2034 0 : beans::PropertyChangeEvent aFormulaEvent;
2035 0 : aFormulaEvent.PropertyName = PROPERTY_FORMULALIST;
2036 0 : aFormulaEvent.OldValue <<= _sOldFunctionName;
2037 0 : aFormulaEvent.NewValue <<= sNewFunction;
2038 :
2039 0 : m_aPropertyListeners.notify( aFormulaEvent, &beans::XPropertyChangeListener::propertyChange );
2040 : }
2041 0 : if ( _sOldScope != sNewScope )
2042 : {
2043 0 : beans::PropertyChangeEvent aScopeEvent;
2044 0 : aScopeEvent.PropertyName = PROPERTY_SCOPE;
2045 0 : aScopeEvent.OldValue <<= _sOldScope;
2046 0 : aScopeEvent.NewValue <<= sNewScope;
2047 0 : m_aPropertyListeners.notify( aScopeEvent, &beans::XPropertyChangeListener::propertyChange );
2048 : }
2049 :
2050 0 : _aGuard.reset();
2051 0 : }
2052 : //------------------------------------------------------------------------
2053 0 : void GeometryHandler::impl_initFieldList_nothrow( uno::Sequence< ::rtl::OUString >& _rFieldNames ) const
2054 : {
2055 0 : _rFieldNames.realloc(0);
2056 : try
2057 : {
2058 0 : uno::Reference< awt::XWindow> xInspectorWindow(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DialogParentWindow"))) ,uno::UNO_QUERY);
2059 0 : Window* pInspectorWindow = VCLUnoHelper::GetWindow( xInspectorWindow );
2060 0 : WaitObject aWaitCursor( pInspectorWindow );
2061 :
2062 0 : uno::Reference< sdbc::XPreparedStatement > xStatement;
2063 :
2064 : // get the form of the control we're inspecting
2065 0 : uno::Reference< beans::XPropertySet > xFormSet( m_xRowSet, uno::UNO_QUERY );
2066 0 : if ( !xFormSet.is() )
2067 0 : return;
2068 :
2069 0 : ::rtl::OUString sObjectName;
2070 0 : OSL_VERIFY( xFormSet->getPropertyValue( PROPERTY_COMMAND ) >>= sObjectName );
2071 : // when there is no command we don't need to ask for columns
2072 0 : uno::Reference<sdbc::XConnection> xCon(m_xContext->getValueByName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ActiveConnection"))) ,uno::UNO_QUERY);
2073 0 : if ( !sObjectName.isEmpty() && xCon.is() )
2074 : {
2075 0 : sal_Int32 nObjectType = sdb::CommandType::COMMAND;
2076 0 : OSL_VERIFY( xFormSet->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nObjectType );
2077 :
2078 0 : _rFieldNames = ::dbtools::getFieldNamesByCommandDescriptor( xCon, nObjectType, sObjectName );
2079 0 : }
2080 : }
2081 0 : catch (uno::Exception&)
2082 : {
2083 : OSL_FAIL( "GeometryHandler::impl_initFieldList_nothrow: caught an exception!" );
2084 : }
2085 : }
2086 : // -----------------------------------------------------------------------------
2087 0 : bool GeometryHandler::impl_isCounterFunction_throw(const ::rtl::OUString& _sQuotedFunctionName,::rtl::OUString& _Out_sScope) const
2088 : {
2089 0 : ::std::pair<TFunctions::const_iterator,TFunctions::const_iterator> aFind = m_aFunctionNames.equal_range(_sQuotedFunctionName);
2090 0 : while ( aFind.first != aFind.second )
2091 : {
2092 0 : const beans::Optional< ::rtl::OUString> aInitalFormula = aFind.first->second.first->getInitialFormula();
2093 0 : if ( aInitalFormula.IsPresent )
2094 : {
2095 0 : const String sFormula( aFind.first->second.first->getFormula() );
2096 0 : util::SearchOptions aSearchOptions;
2097 0 : aSearchOptions.algorithmType = util::SearchAlgorithms_REGEXP;
2098 0 : aSearchOptions.searchFlag = 0x00000100;
2099 0 : aSearchOptions.searchString = m_aCounterFunction.m_sSearchString;
2100 0 : utl::TextSearch aTextSearch(aSearchOptions);
2101 0 : xub_StrLen start = 0;
2102 0 : xub_StrLen end = sFormula.Len();
2103 0 : if ( aTextSearch.SearchFrwrd(sFormula,&start,&end) && start == 0 && end == sFormula.Len()) // counter function found
2104 : {
2105 0 : const uno::Reference< report::XGroup > xGroup(aFind.first->second.second,uno::UNO_QUERY);
2106 0 : if ( xGroup.is() )
2107 : {
2108 0 : String sGroupName = String(ModuleRes(RID_STR_SCOPE_GROUP));
2109 0 : sGroupName.SearchAndReplaceAscii("%1",xGroup->getExpression());
2110 0 : _Out_sScope = sGroupName;
2111 : }
2112 : else
2113 0 : _Out_sScope = uno::Reference< report::XReportDefinition >(aFind.first->second.second,uno::UNO_QUERY_THROW)->getName();
2114 0 : break;
2115 0 : }
2116 : }
2117 0 : ++(aFind.first);
2118 0 : }
2119 0 : return aFind.first != aFind.second;
2120 : }
2121 : // -----------------------------------------------------------------------------
2122 0 : void GeometryHandler::impl_createFunction(const ::rtl::OUString& _sFunctionName,const ::rtl::OUString& _sDataField,const DefaultFunction& _aFunction)
2123 : {
2124 0 : if ( m_bNewFunction )
2125 0 : removeFunction();
2126 :
2127 0 : const ::rtl::OUString sQuotedFunctionName(lcl_getQuotedFunctionName(_sFunctionName));
2128 0 : m_xFunction.set(report::Function::create(m_xContext));
2129 0 : m_xFunction->setName( _sFunctionName );
2130 :
2131 0 : const String sPlaceHolder1(RTL_CONSTASCII_USTRINGPARAM("%Column"));
2132 0 : const String sPlaceHolder2(RTL_CONSTASCII_USTRINGPARAM("%FunctionName"));
2133 0 : String sFormula(_aFunction.m_sFormula);
2134 0 : sFormula.SearchAndReplaceAll(sPlaceHolder1,_sDataField);
2135 0 : sFormula.SearchAndReplaceAll(sPlaceHolder2,_sFunctionName);
2136 :
2137 0 : m_xFunction->setFormula(sFormula);
2138 0 : m_xFunction->setPreEvaluated(_aFunction.m_bPreEvaluated);
2139 0 : m_xFunction->setDeepTraversing(_aFunction.m_bDeepTraversing);
2140 0 : if ( _aFunction.m_sInitialFormula.IsPresent )
2141 : {
2142 0 : beans::Optional< ::rtl::OUString> aInitialFormula = _aFunction.m_sInitialFormula;
2143 0 : String sInitialFormula = aInitialFormula.Value;
2144 0 : sInitialFormula.SearchAndReplaceAll(sPlaceHolder1,_sDataField);
2145 0 : sInitialFormula.SearchAndReplaceAll(sPlaceHolder2,_sFunctionName);
2146 0 : aInitialFormula.Value = sInitialFormula;
2147 0 : m_xFunction->setInitialFormula( aInitialFormula );
2148 : }
2149 0 : ::rtl::OUString sNamePostFix;
2150 0 : const uno::Reference< report::XFunctionsSupplier> xFunctionsSupplier = fillScope_throw(sNamePostFix);
2151 0 : const uno::Reference< container::XIndexContainer> xFunctions(xFunctionsSupplier->getFunctions(),uno::UNO_QUERY_THROW);
2152 0 : xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(m_xFunction));
2153 0 : m_aFunctionNames.insert(TFunctions::value_type(sQuotedFunctionName,TFunctionPair(m_xFunction,xFunctionsSupplier)));
2154 0 : m_bNewFunction = true;
2155 0 : }
2156 : // -----------------------------------------------------------------------------
2157 0 : void GeometryHandler::impl_setCounterFunction_throw()
2158 : {
2159 0 : ::rtl::OUString sNamePostFix;
2160 0 : fillScope_throw(sNamePostFix);
2161 0 : ::rtl::OUString sFunctionName = m_aCounterFunction.m_sName;
2162 0 : sFunctionName += sNamePostFix;
2163 0 : const ::rtl::OUString sQuotedFunctionName = lcl_getQuotedFunctionName(sFunctionName);
2164 0 : ::rtl::OUString sScope;
2165 0 : if ( !(!sFunctionName.isEmpty() && m_aFunctionNames.find(sQuotedFunctionName) != m_aFunctionNames.end() && impl_isCounterFunction_throw(sQuotedFunctionName,sScope)) )
2166 0 : impl_createFunction(sFunctionName,::rtl::OUString(),m_aCounterFunction);
2167 :
2168 0 : OBlocker aBlocker(m_bIn);
2169 0 : m_xReportComponent->setPropertyValue(PROPERTY_DATAFIELD,uno::makeAny(impl_convertToFormula( uno::makeAny(sQuotedFunctionName))));
2170 0 : }
2171 : // -----------------------------------------------------------------------------
2172 0 : sal_uInt32 GeometryHandler::impl_getDataFieldType_throw(const ::rtl::OUString& _sDataField) const
2173 : {
2174 0 : sal_uInt32 nDataFieldType = UNDEF_DATA;
2175 0 : ::rtl::OUString sDataField;
2176 0 : if ( !_sDataField.isEmpty() )
2177 0 : sDataField = _sDataField;
2178 : else
2179 : {
2180 0 : uno::Any aDataField( m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD ) );
2181 0 : lcl_convertFormulaTo(aDataField,aDataField);
2182 0 : aDataField >>= sDataField;
2183 : }
2184 :
2185 0 : if ( !sDataField.isEmpty() )
2186 : {
2187 0 : if ( impl_isDataField(sDataField) )
2188 0 : nDataFieldType = DATA_OR_FORMULA;
2189 0 : else if ( isDefaultFunction(sDataField,sDataField) )
2190 0 : nDataFieldType = FUNCTION;
2191 0 : else if ( m_aFunctionNames.find(sDataField) != m_aFunctionNames.end() )
2192 : {
2193 0 : nDataFieldType = USER_DEF_FUNCTION;
2194 0 : ::rtl::OUString sScope;
2195 0 : if ( impl_isCounterFunction_throw(sDataField,sScope) )
2196 0 : nDataFieldType = COUNTER;
2197 : }
2198 : else
2199 0 : nDataFieldType = DATA_OR_FORMULA;
2200 : }
2201 0 : return nDataFieldType;
2202 : }
2203 : // -----------------------------------------------------------------------------
2204 : // XEventListener
2205 0 : void SAL_CALL GeometryHandler::disposing(const lang::EventObject& ) throw( uno::RuntimeException )
2206 : {
2207 0 : }
2208 : // XPropertyChangeListener
2209 0 : void SAL_CALL GeometryHandler::propertyChange(const beans::PropertyChangeEvent& /*evt*/) throw(uno::RuntimeException)
2210 : {
2211 0 : ::osl::ResettableMutexGuard aGuard( m_aMutex );
2212 0 : if ( !m_bIn )
2213 : {
2214 0 : const sal_uInt32 nOldDataFieldType = m_nDataFieldType;
2215 0 : const ::rtl::OUString sOldFunctionName = m_sDefaultFunction;
2216 0 : const ::rtl::OUString sOldScope = m_sScope;
2217 0 : m_sDefaultFunction = m_sScope = ::rtl::OUString();
2218 0 : m_nDataFieldType = impl_getDataFieldType_throw();
2219 0 : if ( UNDEF_DATA == m_nDataFieldType )
2220 0 : m_nDataFieldType = nOldDataFieldType;
2221 0 : uno::Any aDataField = m_xReportComponent->getPropertyValue( PROPERTY_DATAFIELD );
2222 0 : lcl_convertFormulaTo(aDataField,aDataField);
2223 0 : ::rtl::OUString sDataField;
2224 0 : aDataField >>= sDataField;
2225 0 : switch(m_nDataFieldType)
2226 : {
2227 : case FUNCTION:
2228 0 : isDefaultFunction(sDataField,sDataField,uno::Reference< report::XFunctionsSupplier>(),true);
2229 0 : break;
2230 : case COUNTER:
2231 0 : impl_isCounterFunction_throw(sDataField,m_sScope);
2232 0 : break;
2233 : default:
2234 : ;
2235 : }
2236 :
2237 0 : resetOwnProperties(aGuard,sOldFunctionName,sOldScope,nOldDataFieldType);
2238 0 : }
2239 0 : }
2240 : //........................................................................
2241 0 : } // namespace rptui
2242 : //........................................................................
2243 :
2244 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|