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