1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
25 #include <GeometryHandler.hxx>
27 #include <comphelper/types.hxx>
28 #include <comphelper/property.hxx>
29 #include <comphelper/mimeconfighelper.hxx>
30 #include <cppuhelper/supportsservice.hxx>
32 #include <strings.hxx>
33 #include <reportformula.hxx>
35 #include <i18nutil/searchopt.hxx>
36 #include <unotools/textsearch.hxx>
37 #include <unotools/configmgr.hxx>
39 #include <toolkit/helper/vclunohelper.hxx>
40 #include <unotools/syslocale.hxx>
41 #include <tools/diagnose_ex.h>
42 #include <tools/resary.hxx>
43 #include <com/sun/star/lang/NullPointerException.hpp>
44 #include <com/sun/star/lang/XInitialization.hpp>
45 #include <com/sun/star/form/inspection/FormComponentPropertyHandler.hpp>
46 #include <com/sun/star/inspection/StringRepresentation.hpp>
47 #include <com/sun/star/inspection/PropertyControlType.hpp>
48 #include <com/sun/star/inspection/XStringListControl.hpp>
49 #include <com/sun/star/report/Function.hpp>
50 #include <com/sun/star/report/XReportDefinition.hpp>
51 #include <com/sun/star/report/XShape.hpp>
52 #include <com/sun/star/report/XSection.hpp>
53 #include <com/sun/star/report/XFixedLine.hpp>
54 #include <com/sun/star/script/Converter.hpp>
55 #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
56 #include <com/sun/star/sdb/CommandType.hpp>
57 #include <com/sun/star/sdb/FilterDialog.hpp>
58 #include <com/sun/star/sdb/SQLContext.hpp>
59 #include <com/sun/star/sdbc/XConnection.hpp>
60 #include <com/sun/star/util/SearchAlgorithms2.hpp>
61 #include <com/sun/star/util/MeasureUnit.hpp>
62 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
63 #include <com/sun/star/container/XNameContainer.hpp>
64 #include <com/sun/star/inspection/XNumericControl.hpp>
65 #include <com/sun/star/style/ParagraphAdjust.hpp>
67 #include <vcl/msgbox.hxx>
68 #include <vcl/waitobj.hxx>
69 #include <tools/fldunit.hxx>
70 #include <vcl/stdtext.hxx>
72 #include <core_resource.hxx>
73 #include <stringarray.hrc>
74 #include <strings.hrc>
76 #include <UITools.hxx>
78 #include <connectivity/dbexception.hxx>
79 #include <connectivity/dbconversion.hxx>
80 #include <connectivity/dbtools.hxx>
82 #include <metadata.hxx>
83 #include <svl/itempool.hxx>
84 #include <svl/itemset.hxx>
85 #include <svx/xdef.hxx>
86 #include <svx/xpool.hxx>
87 #include <svx/xtable.hxx>
88 #include <svx/xlnwtit.hxx>
89 #include <svx/xlntrit.hxx>
90 #include <svx/xlnclit.hxx>
91 #include <svx/xlnstit.hxx>
92 #include <svx/xlnedit.hxx>
93 #include <svx/xlnstwit.hxx>
94 #include <svx/xlnedwit.hxx>
95 #include <svx/xlnstcit.hxx>
96 #include <svx/xlnedcit.hxx>
97 #include <svx/xlndsit.hxx>
98 #include <svx/xlineit0.hxx>
99 #include <svx/svxids.hrc>
100 #include <svx/drawitem.hxx>
101 #include <editeng/brushitem.hxx>
102 #include <sfx2/docfilt.hxx>
104 #include <dlgpage.hxx>
106 #include <toolkit/helper/convert.hxx>
107 #include <o3tl/functional.hxx>
109 #define DATA_OR_FORMULA 0
112 #define USER_DEF_FUNCTION 3
119 using namespace ::com::sun::star
;
123 OUString
lcl_getQuotedFunctionName(const OUString
& _sFunction
)
125 return "[" + _sFunction
+ "]";
128 OUString
lcl_getQuotedFunctionName(const uno::Reference
< report::XFunction
>& _xFunction
)
130 return lcl_getQuotedFunctionName(_xFunction
->getName());
133 void lcl_collectFunctionNames(const uno::Reference
< report::XFunctions
>& _xFunctions
,TFunctions
& _rFunctionNames
)
135 uno::Reference
< report::XFunctionsSupplier
> xParent(_xFunctions
->getParent(),uno::UNO_QUERY_THROW
);
136 const sal_Int32 nCount
= _xFunctions
->getCount();
137 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
139 uno::Reference
< report::XFunction
> xFunction(_xFunctions
->getByIndex(i
),uno::UNO_QUERY_THROW
);
140 _rFunctionNames
.emplace( lcl_getQuotedFunctionName(xFunction
),TFunctionPair(xFunction
,xParent
) );
144 void lcl_collectFunctionNames(const uno::Reference
< report::XSection
>& _xSection
,TFunctions
& _rFunctionNames
)
146 const uno::Reference
< report::XReportDefinition
> xReportDefinition
= _xSection
->getReportDefinition();
147 const uno::Reference
< report::XGroups
> xGroups
= xReportDefinition
->getGroups();
149 uno::Reference
< report::XGroup
> xGroup
= _xSection
->getGroup();
151 nPos
= getPositionInIndexAccess(xGroups
.get(),xGroup
);
152 else if ( _xSection
== xReportDefinition
->getDetail() )
153 nPos
= xGroups
->getCount()-1;
155 for (sal_Int32 i
= 0 ; i
<= nPos
; ++i
)
157 xGroup
.set(xGroups
->getByIndex(i
),uno::UNO_QUERY_THROW
);
158 lcl_collectFunctionNames(xGroup
->getFunctions(),_rFunctionNames
);
160 lcl_collectFunctionNames(xReportDefinition
->getFunctions(),_rFunctionNames
);
163 void lcl_convertFormulaTo(const uno::Any
& _aPropertyValue
,uno::Any
& _rControlValue
)
166 _aPropertyValue
>>= sName
;
167 const sal_Int32 nLen
= sName
.getLength();
170 ReportFormula
aFormula( sName
);
171 _rControlValue
<<= aFormula
.getUndecoratedContent();
175 // return value rounded to the nearest multiple of base
176 // if equidistant of two multiples, round up (for positive numbers)
177 // T is assumed to be an integer type
178 template <typename T
, T base
> T
lcl_round(T value
)
180 OSL_ENSURE(value
>= 0, "lcl_round: positive numbers only please");
181 const T threshold
= (base
% 2 == 0) ? (base
/2) : (base
/2 + 1);
182 const T rest
= value
% base
;
183 if ( rest
>= threshold
)
184 return value
+ (base
- rest
);
189 } // anonymous namespace
191 bool GeometryHandler::impl_isDataField(const OUString
& _sName
) const
193 bool bIsField
= ( ::std::find( m_aFieldNames
.begin(), m_aFieldNames
.end(), _sName
) != m_aFieldNames
.end() );
197 bIsField
= ( ::std::find( m_aParamNames
.begin(), m_aParamNames
.end(), _sName
) != m_aParamNames
.end() );
202 OUString
GeometryHandler::impl_convertToFormula( const uno::Any
& _rControlValue
)
205 _rControlValue
>>= sName
;
207 if ( sName
.isEmpty() )
210 ReportFormula
aParser( sName
);
211 if ( aParser
.isValid() )
214 return ReportFormula(impl_isDataField(sName
) ? ReportFormula::Field
: ReportFormula::Expression
, sName
).getCompleteFormula();
217 GeometryHandler::GeometryHandler(uno::Reference
< uno::XComponentContext
> const & context
)
218 : GeometryHandler_Base(m_aMutex
)
219 , m_aPropertyListeners(m_aMutex
)
220 , m_xContext(context
)
221 , m_nDataFieldType(0)
222 , m_bNewFunction(false)
227 m_xFormComponentHandler
= form::inspection::FormComponentPropertyHandler::create(m_xContext
);
228 m_xTypeConverter
= script::Converter::create(context
);
229 loadDefaultFunctions();
231 catch(const uno::Exception
&)
236 GeometryHandler::~GeometryHandler()
240 OUString SAL_CALL
GeometryHandler::getImplementationName( )
242 return getImplementationName_Static();
245 sal_Bool SAL_CALL
GeometryHandler::supportsService( const OUString
& ServiceName
)
247 return cppu::supportsService(this, ServiceName
);
250 uno::Sequence
< OUString
> SAL_CALL
GeometryHandler::getSupportedServiceNames( )
252 return getSupportedServiceNames_static();
255 OUString
GeometryHandler::getImplementationName_Static( )
257 return OUString("com.sun.star.comp.report.GeometryHandler");
260 uno::Sequence
< OUString
> GeometryHandler::getSupportedServiceNames_static( )
262 uno::Sequence
< OUString
> aSupported
{ "com.sun.star.report.inspection.GeometryHandler" };
266 uno::Reference
< uno::XInterface
> SAL_CALL
GeometryHandler::create( const uno::Reference
< uno::XComponentContext
>& _rxContext
)
268 return *(new GeometryHandler( _rxContext
));
270 // override WeakComponentImplHelperBase::disposing()
271 // This function is called upon disposing the component,
272 // if your component needs special work when it becomes
273 // disposed, do it here.
274 void SAL_CALL
GeometryHandler::disposing()
278 ::comphelper::disposeComponent(m_xFormComponentHandler
);
279 ::comphelper::disposeComponent(m_xTypeConverter
);
280 if ( m_xReportComponent
.is() && m_xReportComponent
->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD
) )
281 m_xReportComponent
->removePropertyChangeListener(PROPERTY_DATAFIELD
,static_cast< beans::XPropertyChangeListener
* >( this ));
283 m_xReportComponent
.clear();
285 m_aPropertyListeners
.clear();
287 catch(uno::Exception
&)
290 void SAL_CALL
GeometryHandler::addEventListener(const uno::Reference
< lang::XEventListener
> & xListener
)
292 m_xFormComponentHandler
->addEventListener(xListener
);
295 void SAL_CALL
GeometryHandler::removeEventListener(const uno::Reference
< lang::XEventListener
> & aListener
)
297 m_xFormComponentHandler
->removeEventListener(aListener
);
300 // inspection::XPropertyHandler:
302 /********************************************************************************/
303 void SAL_CALL
GeometryHandler::inspect( const uno::Reference
< uno::XInterface
> & _rxInspectee
)
305 ::osl::MutexGuard
aGuard( m_aMutex
);
307 m_sDefaultFunction
.clear();
308 m_bNewFunction
= false;
309 m_nDataFieldType
= 0;
311 m_aFunctionNames
.clear();
314 if ( m_xReportComponent
.is() && m_xReportComponent
->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD
) )
315 m_xReportComponent
->removePropertyChangeListener(PROPERTY_DATAFIELD
,static_cast< beans::XPropertyChangeListener
* >( this ));
317 const uno::Reference
< container::XNameContainer
> xObjectAsContainer( _rxInspectee
, uno::UNO_QUERY
);
318 m_xReportComponent
.set( xObjectAsContainer
->getByName("ReportComponent"), uno::UNO_QUERY
);
320 const OUString
sRowSet("RowSet");
321 if ( xObjectAsContainer
->hasByName( sRowSet
) )
323 const uno::Any
aRowSet( xObjectAsContainer
->getByName(sRowSet
) );
324 aRowSet
>>= m_xRowSet
;
325 // forward the rowset to our delegator handler
326 uno::Reference
< beans::XPropertySet
> xProp( m_xFormComponentHandler
,uno::UNO_QUERY
);
327 xProp
->setPropertyValue( sRowSet
, aRowSet
);
329 m_aParamNames
= getParameterNames( m_xRowSet
);
330 impl_initFieldList_nothrow(m_aFieldNames
);
331 if ( m_xReportComponent
->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD
) )
332 m_xReportComponent
->addPropertyChangeListener(PROPERTY_DATAFIELD
,static_cast< beans::XPropertyChangeListener
* >( this ));
335 const uno::Reference
< report::XReportComponent
> xReportComponent( m_xReportComponent
, uno::UNO_QUERY
);
336 uno::Reference
< report::XSection
> xSection( m_xReportComponent
, uno::UNO_QUERY
);
337 if ( !xSection
.is() && xReportComponent
.is() )
338 xSection
= xReportComponent
->getSection();
340 lcl_collectFunctionNames( xSection
, m_aFunctionNames
);
342 catch(const uno::Exception
&)
344 throw lang::NullPointerException();
346 m_xFormComponentHandler
->inspect(m_xReportComponent
);
349 uno::Any SAL_CALL
GeometryHandler::getPropertyValue(const OUString
& PropertyName
)
351 ::osl::MutexGuard
aGuard( m_aMutex
);
352 uno::Any aPropertyValue
;
353 const sal_Int32 nId
= OPropertyInfoService::getPropertyId(PropertyName
);
356 case PROPERTY_ID_CONDITIONALPRINTEXPRESSION
:
357 case PROPERTY_ID_INITIALFORMULA
:
358 case PROPERTY_ID_FORMULA
:
359 case PROPERTY_ID_DATAFIELD
:
360 aPropertyValue
= m_xReportComponent
->getPropertyValue( PropertyName
);
361 lcl_convertFormulaTo(aPropertyValue
,aPropertyValue
);
362 if ( PROPERTY_ID_DATAFIELD
== nId
)
365 aPropertyValue
>>= sDataField
;
366 switch(m_nDataFieldType
)
368 case DATA_OR_FORMULA
:
371 if ( isDefaultFunction(sDataField
,sDataField
) )
372 aPropertyValue
<<= sDataField
;
373 else if ( sDataField
.isEmpty() )
374 aPropertyValue
= uno::Any();
377 case USER_DEF_FUNCTION
:
378 aPropertyValue
= uno::Any();
384 case PROPERTY_ID_TYPE
:
386 const sal_uInt32 nOldDataFieldType
= m_nDataFieldType
;
387 m_nDataFieldType
= impl_getDataFieldType_throw();
388 if ( UNDEF_DATA
== m_nDataFieldType
)
389 m_nDataFieldType
= nOldDataFieldType
;
390 aPropertyValue
<<= m_nDataFieldType
;
393 case PROPERTY_ID_FORMULALIST
:
394 case PROPERTY_ID_SCOPE
:
396 uno::Any aDataField
= m_xReportComponent
->getPropertyValue( PROPERTY_DATAFIELD
);
397 lcl_convertFormulaTo(aDataField
,aDataField
);
399 aDataField
>>= sDataField
;
400 switch(m_nDataFieldType
)
402 case DATA_OR_FORMULA
:
405 if ( isDefaultFunction(sDataField
,sDataField
,uno::Reference
< report::XFunctionsSupplier
>(),true) )
406 aPropertyValue
<<= (PROPERTY_ID_FORMULALIST
== nId
? m_sDefaultFunction
: m_sScope
);
408 case USER_DEF_FUNCTION
:
409 if ( !sDataField
.isEmpty() && PROPERTY_ID_FORMULALIST
== nId
)
410 aPropertyValue
= aDataField
;
413 if ( PROPERTY_ID_SCOPE
== nId
&& impl_isCounterFunction_throw(sDataField
,m_sScope
) )
414 aPropertyValue
<<= m_sScope
;
420 case PROPERTY_ID_BACKCOLOR
:
421 case PROPERTY_ID_CONTROLBACKGROUND
:
423 aPropertyValue
= m_xReportComponent
->getPropertyValue( PropertyName
);
424 sal_Int32 nColor
= COL_TRANSPARENT
;
425 if ( (aPropertyValue
>>= nColor
) && static_cast<sal_Int32
>(COL_TRANSPARENT
) == nColor
)
426 aPropertyValue
.clear();
429 case PROPERTY_ID_MIMETYPE
:
432 m_xReportComponent
->getPropertyValue( PropertyName
) >>= sValue
;
433 aPropertyValue
<<= impl_ConvertMimeTypeToUI_nothrow(sValue
);
437 aPropertyValue
= m_xReportComponent
->getPropertyValue( PropertyName
);
440 return aPropertyValue
;
443 void SAL_CALL
GeometryHandler::setPropertyValue(const OUString
& PropertyName
, const uno::Any
& Value
)
445 ::osl::ResettableMutexGuard
aGuard( m_aMutex
);
446 uno::Any aNewValue
= Value
;
447 const sal_Int32 nId
= OPropertyInfoService::getPropertyId(PropertyName
);
448 bool bHandled
= false;
451 case PROPERTY_ID_INITIALFORMULA
:
452 case PROPERTY_ID_FORMULA
:
454 case PROPERTY_ID_DATAFIELD
:
456 OBlocker
aBlocker(m_bIn
);
457 m_xReportComponent
->setPropertyValue(PropertyName
, aNewValue
);
459 const OUString sOldFunctionName
= m_sDefaultFunction
;
460 const OUString sOldScope
= m_sScope
;
462 uno::Any aPropertyValue
;
463 lcl_convertFormulaTo(Value
,aPropertyValue
);
465 aPropertyValue
>>= sDataField
;
468 m_sDefaultFunction
.clear();
470 const sal_uInt32 nOldDataFieldType
= m_nDataFieldType
;
471 if ( !sDataField
.isEmpty() )
473 if ( isDefaultFunction(sDataField
,sDataField
,uno::Reference
< report::XFunctionsSupplier
>(),true) )
474 m_nDataFieldType
= FUNCTION
;
475 else if ( m_aFunctionNames
.find(sDataField
) != m_aFunctionNames
.end() )
476 m_nDataFieldType
= USER_DEF_FUNCTION
;
479 resetOwnProperties(aGuard
,sOldFunctionName
,sOldScope
,nOldDataFieldType
);
482 case PROPERTY_ID_TYPE
:
485 Value
>>= m_nDataFieldType
;
487 const OUString sOldFunctionName
= m_sDefaultFunction
;
488 const OUString sOldScope
= m_sScope
;
489 m_sDefaultFunction
.clear();
492 if ( m_nDataFieldType
== COUNTER
)
494 impl_setCounterFunction_throw();
498 if ( m_bNewFunction
)
501 OBlocker
aBlocker(m_bIn
);
502 m_xReportComponent
->setPropertyValue(PROPERTY_DATAFIELD
,uno::makeAny(OUString()));
504 resetOwnProperties(aGuard
,sOldFunctionName
,sOldScope
,m_nDataFieldType
);
507 case PROPERTY_ID_FORMULALIST
:
511 if ( !(Value
>>= sFunction
) || sFunction
.isEmpty() )
513 if ( m_nDataFieldType
== FUNCTION
)
515 m_sDefaultFunction
.clear();
516 if ( m_bNewFunction
)
520 beans::PropertyChangeEvent aEvent
;
521 aEvent
.PropertyName
= PROPERTY_SCOPE
;
522 aEvent
.OldValue
<<= m_sScope
;
524 aEvent
.NewValue
<<= m_sScope
;
526 m_aPropertyListeners
.notify( aEvent
, &beans::XPropertyChangeListener::propertyChange
);
528 else if ( m_nDataFieldType
== USER_DEF_FUNCTION
)
530 OBlocker
aBlocker(m_bIn
);
531 m_xReportComponent
->setPropertyValue(PROPERTY_DATAFIELD
,uno::makeAny(OUString()));
534 else if ( m_nDataFieldType
== USER_DEF_FUNCTION
)
537 OBlocker
aBlocker(m_bIn
);
538 const sal_uInt32 nNewDataType
= impl_getDataFieldType_throw(sFunction
);
539 if ( nNewDataType
!= UNDEF_DATA
&& nNewDataType
!= m_nDataFieldType
)
541 const OUString sOldFunctionName
= m_sDefaultFunction
;
542 const OUString sOldScope
= m_sScope
;
544 m_sDefaultFunction
.clear();
546 if ( nNewDataType
== COUNTER
)
547 impl_isCounterFunction_throw(sFunction
,m_sScope
);
550 OUString sNamePostfix
;
551 const uno::Reference
< report::XFunctionsSupplier
> xFunctionsSupplier
= fillScope_throw(sNamePostfix
);
552 isDefaultFunction(sFunction
,sDataField
,xFunctionsSupplier
,true);
554 const sal_uInt32 nOldDataFieldType
= m_nDataFieldType
;
555 m_nDataFieldType
= nNewDataType
;
556 m_xReportComponent
->setPropertyValue(PROPERTY_DATAFIELD
,uno::makeAny(impl_convertToFormula( uno::makeAny(sFunction
))));
557 resetOwnProperties(aGuard
,sOldFunctionName
,sOldScope
,nOldDataFieldType
);
560 m_xReportComponent
->setPropertyValue(PROPERTY_DATAFIELD
,uno::makeAny(impl_convertToFormula( uno::makeAny(sFunction
))));
562 else if ( m_nDataFieldType
== FUNCTION
)
564 uno::Any aPropertyValue
= m_xReportComponent
->getPropertyValue(PROPERTY_DATAFIELD
);
565 lcl_convertFormulaTo(aPropertyValue
,aPropertyValue
);
567 aPropertyValue
>>= sDataField
;
568 if ( m_nDataFieldType
== FUNCTION
&& (!isDefaultFunction(sDataField
,sDataField
) || m_sDefaultFunction
!= sFunction
) )
570 if ( m_bNewFunction
)
572 // function currently does not exist
573 createDefaultFunction(aGuard
,sFunction
,sDataField
);
574 m_sDefaultFunction
= sFunction
;
580 case PROPERTY_ID_SCOPE
:
581 if ( !(Value
>>= m_sScope
) )
585 if ( m_bNewFunction
)
587 if ( m_nDataFieldType
== COUNTER
)
588 impl_setCounterFunction_throw();
591 OSL_ENSURE(m_xFunction
.is(),"Where is my function gone!");
593 OUString sNamePostfix
;
594 const uno::Reference
< report::XFunctionsSupplier
> xFunctionsSupplier
= fillScope_throw(sNamePostfix
);
596 OUString
sQuotedFunctionName(lcl_getQuotedFunctionName(m_xFunction
));
597 if ( isDefaultFunction(sQuotedFunctionName
,sQuotedFunctionName
,xFunctionsSupplier
,true) )
598 m_bNewFunction
= false;
601 OUString sDefaultFunctionName
;
603 OSL_VERIFY( impl_isDefaultFunction_nothrow(m_xFunction
,sDataField
,sDefaultFunctionName
) );
604 m_sDefaultFunction
= sDefaultFunctionName
;
605 createDefaultFunction(aGuard
,m_sDefaultFunction
,sDataField
);
611 case PROPERTY_ID_POSITIONX
:
612 case PROPERTY_ID_POSITIONY
:
613 case PROPERTY_ID_HEIGHT
:
614 case PROPERTY_ID_WIDTH
:
616 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY
);
617 if ( xSourceReportComponent
.is() ) // check only report components
619 sal_Int32 nNewValue
= 0;
621 OSL_ENSURE(nNewValue
>= 0, "A position/dimension should not be negative!");
622 nNewValue
= lcl_round
<sal_Int32
, 10>(nNewValue
);
623 awt::Point aAwtPoint
= xSourceReportComponent
->getPosition();
624 awt::Size aAwtSize
= xSourceReportComponent
->getSize();
625 if ( nId
== PROPERTY_ID_POSITIONX
)
626 aAwtPoint
.X
= nNewValue
;
627 else if ( nId
== PROPERTY_ID_POSITIONY
)
628 aAwtPoint
.Y
= nNewValue
;
629 else if ( nId
== PROPERTY_ID_HEIGHT
)
630 aAwtSize
.Height
= nNewValue
;
631 else if ( nId
== PROPERTY_ID_WIDTH
)
632 aAwtSize
.Width
= nNewValue
;
634 checkPosAndSize(aAwtPoint
,aAwtSize
);
638 case PROPERTY_ID_FONT
:
640 const uno::Reference
< report::XReportControlFormat
> xReportControlFormat( m_xReportComponent
,uno::UNO_QUERY_THROW
);
641 uno::Sequence
< beans::NamedValue
> aFontSettings
;
642 OSL_VERIFY( Value
>>= aFontSettings
);
643 applyCharacterSettings( xReportControlFormat
, aFontSettings
);
647 case PROPERTY_ID_MIMETYPE
:
651 aNewValue
<<= impl_ConvertUIToMimeType_nothrow(sValue
);
659 m_xReportComponent
->setPropertyValue(PropertyName
, aNewValue
);
663 beans::PropertyState SAL_CALL
GeometryHandler::getPropertyState(const OUString
& PropertyName
)
665 ::osl::MutexGuard
aGuard( m_aMutex
);
666 return m_xFormComponentHandler
->getPropertyState(PropertyName
);
669 void GeometryHandler::implCreateListLikeControl(
670 const uno::Reference
< inspection::XPropertyControlFactory
>& _rxControlFactory
671 ,inspection::LineDescriptor
& out_Descriptor
673 ,bool _bReadOnlyControl
674 ,bool _bTrueIfListBoxFalseIfComboBox
677 std::vector
<OUString
> aList
;
678 for (const char** pItem
= pResId
; *pItem
; ++pItem
)
679 aList
.push_back(RptResId(*pItem
));
680 implCreateListLikeControl(_rxControlFactory
, out_Descriptor
, aList
, _bReadOnlyControl
, _bTrueIfListBoxFalseIfComboBox
);
683 void GeometryHandler::implCreateListLikeControl(
684 const uno::Reference
< inspection::XPropertyControlFactory
>& _rxControlFactory
685 ,inspection::LineDescriptor
& out_Descriptor
686 ,const ::std::vector
< OUString
>& _aEntries
687 ,bool _bReadOnlyControl
688 ,bool _bTrueIfListBoxFalseIfComboBox
691 const uno::Reference
< inspection::XStringListControl
> xListControl(
692 _rxControlFactory
->createPropertyControl(
693 _bTrueIfListBoxFalseIfComboBox
? inspection::PropertyControlType::ListBox
: inspection::PropertyControlType::ComboBox
, _bReadOnlyControl
698 out_Descriptor
.Control
= xListControl
.get();
699 for (auto const& it
: _aEntries
)
701 xListControl
->appendListEntry(it
);
706 inspection::LineDescriptor SAL_CALL
GeometryHandler::describePropertyLine(const OUString
& PropertyName
, const uno::Reference
< inspection::XPropertyControlFactory
> & _xControlFactory
)
708 inspection::LineDescriptor aOut
;
709 const sal_Int32 nId
= OPropertyInfoService::getPropertyId(PropertyName
);
712 case PROPERTY_ID_FORCENEWPAGE
:
713 case PROPERTY_ID_NEWROWORCOL
:
714 implCreateListLikeControl(_xControlFactory
,aOut
,RID_STR_FORCENEWPAGE_CONST
,false,true);
716 case PROPERTY_ID_GROUPKEEPTOGETHER
:
717 implCreateListLikeControl(_xControlFactory
,aOut
,RID_STR_GROUPKEEPTOGETHER_CONST
,false,true);
719 case PROPERTY_ID_PAGEHEADEROPTION
:
720 case PROPERTY_ID_PAGEFOOTEROPTION
:
721 implCreateListLikeControl(_xControlFactory
,aOut
,RID_STR_REPORTPRINTOPTION_CONST
,false,true);
723 case PROPERTY_ID_FORMULALIST
:
725 ::std::vector
< OUString
> aList
;
726 impl_fillFormulaList_nothrow(aList
);
727 implCreateListLikeControl(_xControlFactory
,aOut
,aList
,false,true);
730 case PROPERTY_ID_SCOPE
:
732 ::std::vector
< OUString
> aList
;
733 impl_fillScopeList_nothrow(aList
);
734 implCreateListLikeControl(_xControlFactory
,aOut
,aList
,false,true);
737 case PROPERTY_ID_MIMETYPE
:
739 ::std::vector
< OUString
> aList
;
740 impl_fillMimeTypes_nothrow(aList
);
741 implCreateListLikeControl(_xControlFactory
,aOut
,aList
,false,true);
744 case PROPERTY_ID_TYPE
:
745 implCreateListLikeControl(_xControlFactory
,aOut
,RID_STR_TYPE_CONST
,false,true);
747 case PROPERTY_ID_VISIBLE
:
748 case PROPERTY_ID_CANGROW
:
749 case PROPERTY_ID_CANSHRINK
:
750 case PROPERTY_ID_REPEATSECTION
:
751 case PROPERTY_ID_PRINTREPEATEDVALUES
:
752 case PROPERTY_ID_STARTNEWCOLUMN
:
753 case PROPERTY_ID_RESETPAGENUMBER
:
754 case PROPERTY_ID_PRINTWHENGROUPCHANGE
:
755 case PROPERTY_ID_KEEPTOGETHER
:
756 case PROPERTY_ID_DEEPTRAVERSING
:
757 case PROPERTY_ID_PREEVALUATED
:
758 case PROPERTY_ID_PRESERVEIRI
:
759 case PROPERTY_ID_BACKTRANSPARENT
:
760 case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT
:
762 const char** pResId
= RID_STR_BOOL
;
763 if ( PROPERTY_ID_KEEPTOGETHER
== nId
&& uno::Reference
< report::XGroup
>(m_xReportComponent
,uno::UNO_QUERY
).is())
764 pResId
= RID_STR_KEEPTOGETHER_CONST
;
765 implCreateListLikeControl(_xControlFactory
,aOut
,pResId
,false,true);
768 case PROPERTY_ID_INITIALFORMULA
:
769 case PROPERTY_ID_FORMULA
:
770 aOut
.PrimaryButtonId
= UID_RPT_PROP_FORMULA
;
771 aOut
.HasPrimaryButton
= true;
772 aOut
.Control
= _xControlFactory
->createPropertyControl(inspection::PropertyControlType::MultiLineTextField
, false);
774 case PROPERTY_ID_CONDITIONALPRINTEXPRESSION
:
775 aOut
.PrimaryButtonId
= UID_RPT_PROP_FORMULA
;
776 aOut
.HasPrimaryButton
= true;
777 aOut
.Control
= _xControlFactory
->createPropertyControl(inspection::PropertyControlType::MultiLineTextField
, false);
779 case PROPERTY_ID_DATAFIELD
:
781 uno::Reference
< inspection::XStringListControl
> xListControl(
782 _xControlFactory
->createPropertyControl(
783 m_nDataFieldType
== DATA_OR_FORMULA
? inspection::PropertyControlType::ComboBox
: inspection::PropertyControlType::ListBox
, false
788 if ( m_nDataFieldType
== DATA_OR_FORMULA
)
790 aOut
.PrimaryButtonId
= UID_RPT_PROP_FORMULA
;
791 aOut
.HasPrimaryButton
= true;
794 aOut
.Control
= xListControl
.get();
795 if ( m_nDataFieldType
== USER_DEF_FUNCTION
)
797 // add function names
798 ::std::for_each(m_aFunctionNames
.begin(), m_aFunctionNames
.end(),
799 [&xListControl
] (const TFunctions::value_type
& func
) {
800 xListControl
->appendListEntry(func
.first
);
805 for (auto const& it
: m_aFieldNames
)
807 xListControl
->appendListEntry(it
);
809 for (auto const& it
: m_aParamNames
)
811 xListControl
->appendListEntry(it
);
816 case PROPERTY_ID_BACKCOLOR
:
817 case PROPERTY_ID_CONTROLBACKGROUND
:
818 aOut
.Control
= _xControlFactory
->createPropertyControl( inspection::PropertyControlType::ColorListBox
, false );
820 case PROPERTY_ID_FONT
:
821 aOut
.PrimaryButtonId
= UID_RPT_RPT_PROP_DLG_FONT_TYPE
;
822 aOut
.Control
= _xControlFactory
->createPropertyControl( inspection::PropertyControlType::TextField
, true );
823 aOut
.HasPrimaryButton
= true;
825 case PROPERTY_ID_AREA
:
826 aOut
.PrimaryButtonId
= UID_RPT_RPT_PROP_DLG_AREA
;
827 aOut
.Control
= _xControlFactory
->createPropertyControl( inspection::PropertyControlType::TextField
, true );
828 aOut
.HasPrimaryButton
= true;
830 case PROPERTY_ID_VERTICALALIGN
:
831 implCreateListLikeControl(_xControlFactory
,aOut
,RID_STR_VERTICAL_ALIGN_CONST
,false,true);
833 case PROPERTY_ID_PARAADJUST
:
834 implCreateListLikeControl(_xControlFactory
,aOut
,RID_STR_PARAADJUST_CONST
,false,true);
838 aOut
= m_xFormComponentHandler
->describePropertyLine(PropertyName
, _xControlFactory
);
844 aOut
.Category
= (OPropertyInfoService::getPropertyUIFlags(nId
) & PropUIFlags::DataProperty
) ?
848 aOut
.HelpURL
= HelpIdUrl::getHelpURL( OPropertyInfoService::getPropertyHelpId( nId
) );
849 aOut
.DisplayName
= OPropertyInfoService::getPropertyTranslation(nId
);
852 if ( ( nId
== PROPERTY_ID_POSITIONX
)
853 || ( nId
== PROPERTY_ID_POSITIONY
)
854 || ( nId
== PROPERTY_ID_WIDTH
)
855 || ( nId
== PROPERTY_ID_HEIGHT
)
858 const MeasurementSystem eSystem
= SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
859 const sal_Int16 nDisplayUnit
= VCLUnoHelper::ConvertToMeasurementUnit( MeasurementSystem::Metric
== eSystem
? FUNIT_CM
: FUNIT_INCH
, 1 );
860 uno::Reference
< inspection::XNumericControl
> xNumericControl(aOut
.Control
,uno::UNO_QUERY
);
861 xNumericControl
->setDecimalDigits( 2 );
862 xNumericControl
->setValueUnit( util::MeasureUnit::MM_100TH
);
863 uno::Reference
< drawing::XShapeDescriptor
> xShapeDesc(m_xReportComponent
,uno::UNO_QUERY
);
864 bool bSetMin
= !xShapeDesc
.is() || xShapeDesc
->getShapeType() != "com.sun.star.drawing.CustomShape";
866 xNumericControl
->setMinValue(beans::Optional
<double>(true,0.0));
867 if ( nDisplayUnit
!= -1 )
868 xNumericControl
->setDisplayUnit( nDisplayUnit
);
869 uno::Reference
< report::XReportComponent
> xComp(m_xReportComponent
,uno::UNO_QUERY
);
870 if ( xComp
.is() && xComp
->getSection().is() )
872 uno::Reference
< report::XReportDefinition
> xReport
= xComp
->getSection()->getReportDefinition();
873 OSL_ENSURE(xReport
.is(),"Why is the report definition NULL!");
876 const awt::Size aSize
= getStyleProperty
<awt::Size
>(xReport
,PROPERTY_PAPERSIZE
);
877 const sal_Int32 nLeftMargin
= getStyleProperty
<sal_Int32
>(xReport
,PROPERTY_LEFTMARGIN
);
878 const sal_Int32 nRightMargin
= getStyleProperty
<sal_Int32
>(xReport
,PROPERTY_RIGHTMARGIN
);
881 case PROPERTY_ID_POSITIONX
:
882 case PROPERTY_ID_WIDTH
:
884 xNumericControl
->setMinValue(beans::Optional
<double>(true,0.0));
885 xNumericControl
->setMaxValue(beans::Optional
<double>(true,double(aSize
.Width
- nLeftMargin
- nRightMargin
)));
886 if ( PROPERTY_ID_WIDTH
== nId
)
888 uno::Reference
<report::XFixedLine
> xFixedLine(m_xReportComponent
,uno::UNO_QUERY
);
889 if ( xFixedLine
.is() && xFixedLine
->getOrientation() == 1 ) // vertical
890 xNumericControl
->setMinValue(beans::Optional
<double>(true,0.08 ));
898 else if ( PROPERTY_ID_HEIGHT
== nId
)
900 const uno::Reference
< report::XSection
> xSection(m_xReportComponent
,uno::UNO_QUERY
);
903 sal_Int32 nHeight
= 0;
904 const sal_Int32 nCount
= xSection
->getCount();
905 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
907 uno::Reference
<drawing::XShape
> xShape(xSection
->getByIndex(i
),uno::UNO_QUERY
);
908 nHeight
= ::std::max
<sal_Int32
>(nHeight
,xShape
->getPosition().Y
+ xShape
->getSize().Height
);
910 xNumericControl
->setMinValue(beans::Optional
<double>(true,nHeight
));
917 beans::Property
GeometryHandler::getProperty(const OUString
& PropertyName
)
919 uno::Sequence
< beans::Property
> aProps
= getSupportedProperties();
920 const beans::Property
* pIter
= aProps
.getConstArray();
921 const beans::Property
* pEnd
= pIter
+ aProps
.getLength();
922 const beans::Property
* pFind
= ::std::find_if(pIter
, pEnd
,
923 [&PropertyName
] (const beans::Property
& x
) -> bool {
924 return x
.Name
== PropertyName
;
927 return beans::Property();
930 uno::Any
GeometryHandler::getConstantValue(bool _bToControlValue
,const char** pResId
,const uno::Any
& _aValue
,const OUString
& _sConstantName
,const OUString
& PropertyName
)
932 std::vector
<OUString
> aList
;
933 for (const char** pItem
= pResId
; *pItem
; ++pItem
)
934 aList
.push_back(RptResId(*pItem
));
935 uno::Sequence
< OUString
> aSeq(aList
.size());
936 for (size_t i
= 0; i
< aList
.size(); ++i
)
939 uno::Reference
< inspection::XStringRepresentation
> xConversionHelper
= inspection::StringRepresentation::createConstant( m_xContext
,m_xTypeConverter
,_sConstantName
,aSeq
);
940 if ( _bToControlValue
)
942 return uno::makeAny( xConversionHelper
->convertToControlValue( _aValue
) );
946 OUString sControlValue
;
947 _aValue
>>= sControlValue
;
948 const beans::Property aProp
= getProperty(PropertyName
);
949 return xConversionHelper
->convertToPropertyValue( sControlValue
, aProp
.Type
);
953 uno::Any SAL_CALL
GeometryHandler::convertToPropertyValue(const OUString
& PropertyName
, const uno::Any
& _rControlValue
)
955 ::osl::MutexGuard
aGuard( m_aMutex
);
956 uno::Any
aPropertyValue( _rControlValue
);
957 const sal_Int32 nId
= OPropertyInfoService::getPropertyId(PropertyName
);
960 case PROPERTY_ID_FORCENEWPAGE
:
961 case PROPERTY_ID_NEWROWORCOL
:
962 aPropertyValue
= getConstantValue(false,RID_STR_FORCENEWPAGE_CONST
,_rControlValue
,"com.sun.star.report.ForceNewPage",PropertyName
);
964 case PROPERTY_ID_GROUPKEEPTOGETHER
:
965 aPropertyValue
= getConstantValue(false,RID_STR_GROUPKEEPTOGETHER_CONST
,_rControlValue
,"com.sun.star.report.GroupKeepTogether",PropertyName
);
967 case PROPERTY_ID_PAGEHEADEROPTION
:
968 case PROPERTY_ID_PAGEFOOTEROPTION
:
969 aPropertyValue
= getConstantValue(false,RID_STR_REPORTPRINTOPTION_CONST
,_rControlValue
,"com.sun.star.report.ReportPrintOption",PropertyName
);
971 case PROPERTY_ID_BACKCOLOR
:
972 case PROPERTY_ID_CONTROLBACKGROUND
:
973 if ( !_rControlValue
.hasValue() )
975 aPropertyValue
<<= static_cast<sal_Int32
>(COL_TRANSPARENT
);
980 case PROPERTY_ID_KEEPTOGETHER
:
981 if ( uno::Reference
< report::XGroup
>(m_xReportComponent
,uno::UNO_QUERY
).is())
983 aPropertyValue
= getConstantValue(false,RID_STR_KEEPTOGETHER_CONST
,_rControlValue
,"com.sun.star.report.KeepTogether",PropertyName
);
988 case PROPERTY_ID_VISIBLE
:
989 case PROPERTY_ID_CANGROW
:
990 case PROPERTY_ID_CANSHRINK
:
991 case PROPERTY_ID_REPEATSECTION
:
992 case PROPERTY_ID_PRINTREPEATEDVALUES
:
993 case PROPERTY_ID_STARTNEWCOLUMN
:
994 case PROPERTY_ID_RESETPAGENUMBER
:
995 case PROPERTY_ID_PRINTWHENGROUPCHANGE
:
996 case PROPERTY_ID_DEEPTRAVERSING
:
997 case PROPERTY_ID_PREEVALUATED
:
998 case PROPERTY_ID_PRESERVEIRI
:
999 case PROPERTY_ID_BACKTRANSPARENT
:
1000 case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT
:
1002 if ( aPropertyValue
.hasValue() )
1004 const beans::Property aProp
= getProperty(PropertyName
);
1005 if ( aPropertyValue
.getValueType().equals( aProp
.Type
) )
1006 // nothing to do, type is already as desired
1007 return aPropertyValue
;
1009 if ( _rControlValue
.getValueType().getTypeClass() == uno::TypeClass_STRING
)
1011 OUString sControlValue
;
1012 _rControlValue
>>= sControlValue
;
1014 const uno::Reference
< inspection::XStringRepresentation
> xConversionHelper
= inspection::StringRepresentation::create( m_xContext
,m_xTypeConverter
);
1015 aPropertyValue
= xConversionHelper
->convertToPropertyValue( sControlValue
, aProp
.Type
);
1021 aPropertyValue
= m_xTypeConverter
->convertTo( _rControlValue
, aProp
.Type
);
1023 catch( const uno::Exception
& )
1025 OSL_FAIL( "GeometryHandler::convertToPropertyValue: caught an exception while converting via TypeConverter!" );
1032 case PROPERTY_ID_CONDITIONALPRINTEXPRESSION
:
1033 case PROPERTY_ID_INITIALFORMULA
:
1034 case PROPERTY_ID_FORMULA
:
1035 return uno::makeAny( impl_convertToFormula( _rControlValue
) );
1036 case PROPERTY_ID_DATAFIELD
:
1038 OUString sDataField
;
1039 _rControlValue
>>= sDataField
;
1040 if ( isDefaultFunction(sDataField
,sDataField
) )
1042 OSL_ENSURE(m_xFunction
.is(),"No function set!");
1043 aPropertyValue
<<= impl_convertToFormula( uno::makeAny(lcl_getQuotedFunctionName(m_xFunction
)) );
1046 aPropertyValue
<<= impl_convertToFormula( _rControlValue
);
1049 case PROPERTY_ID_POSITIONX
:
1051 aPropertyValue
= m_xFormComponentHandler
->convertToPropertyValue(PropertyName
, _rControlValue
);
1052 sal_Int32 nPosX
= 0;
1053 aPropertyValue
>>= nPosX
;
1054 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY
);
1055 if ( xSourceReportComponent
->getSection().is() )
1056 nPosX
+= getStyleProperty
<sal_Int32
>(xSourceReportComponent
->getSection()->getReportDefinition(),PROPERTY_LEFTMARGIN
);
1057 aPropertyValue
<<= nPosX
;
1060 case PROPERTY_ID_FONT
:
1061 aPropertyValue
= m_xFormComponentHandler
->convertToPropertyValue(PROPERTY_FONT
, _rControlValue
);
1063 case PROPERTY_ID_SCOPE
:
1064 case PROPERTY_ID_FORMULALIST
:
1065 case PROPERTY_ID_AREA
:
1066 aPropertyValue
= _rControlValue
;
1068 case PROPERTY_ID_TYPE
:
1071 _rControlValue
>>= sValue
;
1073 sal_uInt32
nFound(RESARRAY_INDEX_NOTFOUND
);
1075 for (const char** pItem
= RID_STR_TYPE_CONST
; *pItem
; ++pItem
)
1077 if (sValue
== RptResId(*pItem
))
1084 if (nFound
!= RESARRAY_INDEX_NOTFOUND
)
1085 aPropertyValue
<<= nFound
;
1088 case PROPERTY_ID_MIMETYPE
:
1089 aPropertyValue
= _rControlValue
;
1091 case PROPERTY_ID_VERTICALALIGN
:
1094 _rControlValue
>>= sValue
;
1096 sal_uInt32
nFound(RESARRAY_INDEX_NOTFOUND
);
1098 for (const char** pItem
= RID_STR_VERTICAL_ALIGN_CONST
; *pItem
; ++pItem
)
1100 if (sValue
== RptResId(*pItem
))
1107 if (nFound
!= RESARRAY_INDEX_NOTFOUND
)
1108 aPropertyValue
<<= static_cast<style::VerticalAlignment
>(nFound
);
1111 case PROPERTY_ID_PARAADJUST
:
1114 _rControlValue
>>= sValue
;
1116 sal_uInt32
nFound(RESARRAY_INDEX_NOTFOUND
);
1118 for (const char** pItem
= RID_STR_PARAADJUST_CONST
; *pItem
; ++pItem
)
1120 if (sValue
== RptResId(*pItem
))
1128 if (nFound
!= RESARRAY_INDEX_NOTFOUND
)
1129 aPropertyValue
<<= static_cast<sal_Int16
>(nFound
);
1133 return m_xFormComponentHandler
->convertToPropertyValue(PropertyName
, _rControlValue
);
1135 return aPropertyValue
;
1138 uno::Any SAL_CALL
GeometryHandler::convertToControlValue(const OUString
& PropertyName
, const uno::Any
& _rPropertyValue
, const uno::Type
& _rControlValueType
)
1140 uno::Any
aControlValue( _rPropertyValue
);
1141 if ( !aControlValue
.hasValue() )
1142 // NULL is converted to NULL
1143 return aControlValue
;
1145 uno::Any
aPropertyValue(_rPropertyValue
);
1147 ::osl::MutexGuard
aGuard( m_aMutex
);
1148 const sal_Int32 nId
= OPropertyInfoService::getPropertyId(PropertyName
);
1151 case PROPERTY_ID_AREA
:
1153 case PROPERTY_ID_FORCENEWPAGE
:
1154 case PROPERTY_ID_NEWROWORCOL
:
1155 aControlValue
= getConstantValue(true,RID_STR_FORCENEWPAGE_CONST
,aPropertyValue
,"com.sun.star.report.ForceNewPage",PropertyName
);
1157 case PROPERTY_ID_GROUPKEEPTOGETHER
:
1158 aControlValue
= getConstantValue(true,RID_STR_GROUPKEEPTOGETHER_CONST
,aPropertyValue
,"com.sun.star.report.GroupKeepTogether",PropertyName
);
1160 case PROPERTY_ID_PAGEHEADEROPTION
:
1161 case PROPERTY_ID_PAGEFOOTEROPTION
:
1162 aControlValue
= getConstantValue(true,RID_STR_REPORTPRINTOPTION_CONST
,aPropertyValue
,"com.sun.star.report.ReportPrintOption",PropertyName
);
1164 case PROPERTY_ID_KEEPTOGETHER
:
1165 if ( uno::Reference
< report::XGroup
>(m_xReportComponent
,uno::UNO_QUERY
).is())
1167 aControlValue
= getConstantValue(true,RID_STR_KEEPTOGETHER_CONST
,aPropertyValue
,"com.sun.star.report.KeepTogether",PropertyName
);
1171 case PROPERTY_ID_VISIBLE
:
1172 case PROPERTY_ID_CANGROW
:
1173 case PROPERTY_ID_CANSHRINK
:
1174 case PROPERTY_ID_REPEATSECTION
:
1175 case PROPERTY_ID_PRINTREPEATEDVALUES
:
1176 case PROPERTY_ID_STARTNEWCOLUMN
:
1177 case PROPERTY_ID_RESETPAGENUMBER
:
1178 case PROPERTY_ID_PRINTWHENGROUPCHANGE
:
1179 case PROPERTY_ID_DEEPTRAVERSING
:
1180 case PROPERTY_ID_PREEVALUATED
:
1181 case PROPERTY_ID_PRESERVEIRI
:
1182 case PROPERTY_ID_BACKTRANSPARENT
:
1183 case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT
:
1185 if ( _rControlValueType
.getTypeClass() == uno::TypeClass_STRING
)
1187 const uno::Reference
< inspection::XStringRepresentation
> xConversionHelper
= inspection::StringRepresentation::create( m_xContext
,m_xTypeConverter
);
1188 aControlValue
<<= xConversionHelper
->convertToControlValue( aPropertyValue
);
1194 aControlValue
= m_xTypeConverter
->convertTo( aPropertyValue
, _rControlValueType
);
1196 catch( const uno::Exception
& )
1198 OSL_FAIL( "GeometryHandler::convertToControlValue: caught an exception while converting via TypeConverter!" );
1203 case PROPERTY_ID_CONDITIONALPRINTEXPRESSION
:
1204 case PROPERTY_ID_INITIALFORMULA
:
1205 case PROPERTY_ID_FORMULA
:
1206 lcl_convertFormulaTo(aPropertyValue
,aControlValue
);
1208 case PROPERTY_ID_DATAFIELD
:
1211 aControlValue
>>= sValue
;
1212 if ( isDefaultFunction(sValue
,sValue
) )
1213 aControlValue
<<= sValue
;
1215 lcl_convertFormulaTo(aPropertyValue
,aControlValue
);
1218 case PROPERTY_ID_FONT
:
1219 aControlValue
= m_xFormComponentHandler
->convertToControlValue(PROPERTY_FONT
, aPropertyValue
, _rControlValueType
);
1221 case PROPERTY_ID_POSITIONX
:
1223 sal_Int32 nPosX
= 0;
1224 aPropertyValue
>>= nPosX
;
1225 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY
);
1226 if ( xSourceReportComponent
->getSection().is() )
1227 nPosX
-= getStyleProperty
<sal_Int32
>(xSourceReportComponent
->getSection()->getReportDefinition(),PROPERTY_LEFTMARGIN
);
1228 aPropertyValue
<<= nPosX
;
1229 aControlValue
= m_xFormComponentHandler
->convertToControlValue(PropertyName
, aPropertyValue
, _rControlValueType
);
1232 case PROPERTY_ID_FORMULALIST
:
1233 aControlValue
<<= m_sDefaultFunction
;
1235 case PROPERTY_ID_SCOPE
:
1236 aControlValue
<<= m_sScope
;
1238 case PROPERTY_ID_MIMETYPE
:
1239 aControlValue
= aPropertyValue
;
1241 case PROPERTY_ID_TYPE
:
1243 if (m_nDataFieldType
< SAL_N_ELEMENTS(RID_STR_TYPE_CONST
) - 1)
1244 aControlValue
<<= RptResId(RID_STR_TYPE_CONST
[m_nDataFieldType
]);
1247 case PROPERTY_ID_VERTICALALIGN
:
1249 style::VerticalAlignment nParagraphVertAlign
= style::VerticalAlignment_TOP
;
1250 aPropertyValue
>>= nParagraphVertAlign
;
1251 if (sal_uInt32(nParagraphVertAlign
) < SAL_N_ELEMENTS(RID_STR_VERTICAL_ALIGN_CONST
) - 1)
1252 aControlValue
<<= RptResId(RID_STR_VERTICAL_ALIGN_CONST
[(sal_uInt32
)nParagraphVertAlign
]);
1255 case PROPERTY_ID_PARAADJUST
:
1257 sal_Int16 nParagraphAdjust
= (sal_Int16
)style::ParagraphAdjust_LEFT
;
1258 aPropertyValue
>>= nParagraphAdjust
;
1259 if (static_cast<sal_uInt32
>(nParagraphAdjust
) < SAL_N_ELEMENTS(RID_STR_PARAADJUST_CONST
) - 1)
1260 aControlValue
<<= RptResId(RID_STR_PARAADJUST_CONST
[nParagraphAdjust
]);
1263 case PROPERTY_ID_BACKCOLOR
:
1264 case PROPERTY_ID_CONTROLBACKGROUND
:
1266 sal_Int32 nColor
= COL_TRANSPARENT
;
1267 if ( (aPropertyValue
>>= nColor
) && static_cast<sal_Int32
>(COL_TRANSPARENT
) == nColor
)
1268 aPropertyValue
.clear();
1272 aControlValue
= m_xFormComponentHandler
->convertToControlValue(PropertyName
, aPropertyValue
, _rControlValueType
);
1274 return aControlValue
;
1276 void SAL_CALL
GeometryHandler::addPropertyChangeListener(const uno::Reference
< beans::XPropertyChangeListener
> & _rxListener
)
1278 ::osl::MutexGuard
aGuard( m_aMutex
);
1279 m_aPropertyListeners
.addListener( _rxListener
);
1280 m_xFormComponentHandler
->addPropertyChangeListener(_rxListener
);
1283 void SAL_CALL
GeometryHandler::removePropertyChangeListener(const uno::Reference
< beans::XPropertyChangeListener
> & _rxListener
)
1285 ::osl::MutexGuard
aGuard( m_aMutex
);
1286 m_aPropertyListeners
.removeListener( _rxListener
);
1287 m_xFormComponentHandler
->removePropertyChangeListener(_rxListener
);
1291 uno::Sequence
< beans::Property
> SAL_CALL
GeometryHandler::getSupportedProperties()
1293 ::std::vector
< beans::Property
> aNewProps
;
1294 aNewProps
.reserve(20); // only a guess
1295 rptui::OPropertyInfoService::getExcludeProperties( aNewProps
, m_xFormComponentHandler
);
1297 const OUString pIncludeProperties
[] =
1299 OUString(PROPERTY_FORCENEWPAGE
)
1300 ,OUString(PROPERTY_KEEPTOGETHER
)
1301 ,OUString(PROPERTY_CANGROW
)
1302 ,OUString(PROPERTY_CANSHRINK
)
1303 ,OUString(PROPERTY_REPEATSECTION
)
1304 ,OUString(PROPERTY_PRINTREPEATEDVALUES
)
1305 ,OUString(PROPERTY_CONDITIONALPRINTEXPRESSION
)
1306 ,OUString(PROPERTY_STARTNEWCOLUMN
)
1307 ,OUString(PROPERTY_RESETPAGENUMBER
)
1308 ,OUString(PROPERTY_PRINTWHENGROUPCHANGE
)
1309 ,OUString(PROPERTY_VISIBLE
)
1310 ,OUString(PROPERTY_PAGEHEADEROPTION
)
1311 ,OUString(PROPERTY_PAGEFOOTEROPTION
)
1312 ,OUString("ControlLabel")
1313 ,OUString(PROPERTY_POSITIONX
)
1314 ,OUString(PROPERTY_POSITIONY
)
1315 ,OUString(PROPERTY_WIDTH
)
1316 ,OUString(PROPERTY_HEIGHT
)
1317 ,OUString(PROPERTY_PREEVALUATED
)
1318 ,OUString(PROPERTY_DEEPTRAVERSING
)
1319 ,OUString(PROPERTY_FORMULA
)
1320 ,OUString(PROPERTY_INITIALFORMULA
)
1321 ,OUString(PROPERTY_PRESERVEIRI
)
1322 ,OUString(PROPERTY_DATAFIELD
)
1323 ,OUString(PROPERTY_FONT
)
1324 ,OUString(PROPERTY_BACKCOLOR
)
1325 ,OUString(PROPERTY_BACKTRANSPARENT
)
1326 ,OUString(PROPERTY_CONTROLBACKGROUND
)
1327 ,OUString(PROPERTY_CONTROLBACKGROUNDTRANSPARENT
)
1328 ,OUString(PROPERTY_LABEL
)
1329 ,OUString(PROPERTY_MIMETYPE
)
1330 ,OUString(PROPERTY_VERTICALALIGN
)
1331 ,OUString(PROPERTY_PARAADJUST
)
1333 const uno::Reference
< beans::XPropertySetInfo
> xInfo
= m_xReportComponent
->getPropertySetInfo();
1334 const uno::Sequence
< beans::Property
> aSeq
= xInfo
->getProperties();
1335 for (const auto & rIncludeProp
: pIncludeProperties
)
1337 const beans::Property
* pFind
= ::std::find_if(aSeq
.begin(), aSeq
.end(),
1338 [&rIncludeProp
] (const beans::Property
& x
) -> bool {
1339 return x
.Name
== rIncludeProp
;
1341 if ( pFind
!= aSeq
.end() )
1343 // special case for controls which contain a data field
1344 if ( PROPERTY_DATAFIELD
== rIncludeProp
)
1346 beans::Property aValue
;
1347 aValue
.Name
= PROPERTY_FORMULALIST
;
1348 aNewProps
.push_back(aValue
);
1349 aValue
.Name
= PROPERTY_SCOPE
;
1350 aNewProps
.push_back(aValue
);
1351 aValue
.Name
= PROPERTY_TYPE
;
1352 aNewProps
.push_back(aValue
);
1354 aNewProps
.push_back(*pFind
);
1358 // special property for shapes
1359 // if ( uno::Reference< report::XShape>(m_xReportComponent,uno::UNO_QUERY).is() )
1361 // beans::Property aValue;
1362 // aValue.Name = PROPERTY_AREA;
1363 // aNewProps.push_back(aValue);
1365 // re-enable when the remaining issues of #i88727# are fixed
1367 return uno::Sequence
< beans::Property
> (&(*aNewProps
.begin()),aNewProps
.size());
1370 uno::Sequence
< OUString
> SAL_CALL
GeometryHandler::getSupersededProperties()
1372 uno::Sequence
< OUString
> aRet
;
1373 const uno::Reference
<report::XReportDefinition
> xReport(m_xReportComponent
,uno::UNO_QUERY
);
1374 if ( xReport
.is() && !uno::Reference
< report::XSection
>(xReport
->getParent(),uno::UNO_QUERY
).is() )
1377 OUString
* pIter
= aRet
.getArray();
1378 *pIter
++ = PROPERTY_POSITIONX
;
1379 *pIter
++ = PROPERTY_POSITIONY
;
1380 *pIter
++ = PROPERTY_WIDTH
;
1381 *pIter
++ = PROPERTY_HEIGHT
;
1382 *pIter
++ = PROPERTY_DATAFIELD
;
1387 uno::Sequence
< OUString
> SAL_CALL
GeometryHandler::getActuatingProperties()
1389 ::osl::MutexGuard
aGuard( m_aMutex
);
1391 uno::Sequence
< OUString
> aSeq(5);
1392 aSeq
[0] = PROPERTY_BACKTRANSPARENT
;
1393 aSeq
[1] = PROPERTY_CONTROLBACKGROUNDTRANSPARENT
;
1394 aSeq
[2] = PROPERTY_FORMULALIST
;
1395 aSeq
[3] = PROPERTY_TYPE
;
1396 aSeq
[4] = PROPERTY_DATAFIELD
;
1398 return ::comphelper::concatSequences(m_xFormComponentHandler
->getActuatingProperties(),aSeq
);
1401 sal_Bool SAL_CALL
GeometryHandler::isComposable(const OUString
& _rPropertyName
)
1403 return OPropertyInfoService::isComposable( _rPropertyName
, m_xFormComponentHandler
);
1406 inspection::InteractiveSelectionResult SAL_CALL
GeometryHandler::onInteractivePropertySelection(const OUString
& PropertyName
, sal_Bool Primary
, uno::Any
& _rData
, const uno::Reference
< inspection::XObjectInspectorUI
> & _rxInspectorUI
)
1408 if ( !_rxInspectorUI
.is() )
1409 throw lang::NullPointerException();
1410 if (PropertyName
== PROPERTY_FILTER
)
1412 ::osl::ClearableMutexGuard
aGuard( m_aMutex
);
1414 inspection::InteractiveSelectionResult eResult
= inspection::InteractiveSelectionResult_Cancelled
;
1416 if ( impl_dialogFilter_nothrow( sClause
, aGuard
) )
1419 eResult
= inspection::InteractiveSelectionResult_ObtainedValue
;
1423 else if (PropertyName
== PROPERTY_FONT
)
1425 ::osl::ClearableMutexGuard
aGuard( m_aMutex
);
1427 inspection::InteractiveSelectionResult eResult
= inspection::InteractiveSelectionResult_Cancelled
;
1428 const uno::Reference
< awt::XWindow
> xInspectorWindow(m_xContext
->getValueByName("DialogParentWindow") ,uno::UNO_QUERY
);
1429 const uno::Reference
< report::XReportControlFormat
> xReportControlFormat(m_xReportComponent
,uno::UNO_QUERY
);
1432 uno::Sequence
< beans::NamedValue
> aFontSettings
;
1433 if ( rptui::openCharDialog( xReportControlFormat
, xInspectorWindow
, aFontSettings
) )
1435 _rData
<<= aFontSettings
;
1436 eResult
= inspection::InteractiveSelectionResult_ObtainedValue
;
1440 else if ( PropertyName
== PROPERTY_FORMULA
1441 || PropertyName
== PROPERTY_INITIALFORMULA
1442 || PropertyName
== PROPERTY_DATAFIELD
1443 || PropertyName
== PROPERTY_CONDITIONALPRINTEXPRESSION
)
1445 ::osl::ClearableMutexGuard
aGuard( m_aMutex
);
1449 m_xReportComponent
->getPropertyValue(PropertyName
) >>= sFormula
;
1450 const uno::Reference
< awt::XWindow
> xInspectorWindow(m_xContext
->getValueByName("DialogParentWindow") ,uno::UNO_QUERY
);
1451 uno::Reference
< uno::XComponentContext
> xContext
= m_xContext
;
1452 uno::Reference
< beans::XPropertySet
> xRowSet( m_xRowSet
,uno::UNO_QUERY
);
1455 inspection::InteractiveSelectionResult eResult
= inspection::InteractiveSelectionResult_Cancelled
;
1456 if ( rptui::openDialogFormula_nothrow( sFormula
, xContext
,xInspectorWindow
,xRowSet
) )
1458 _rData
<<= sFormula
;
1459 eResult
= inspection::InteractiveSelectionResult_ObtainedValue
;
1463 else if (PropertyName
== PROPERTY_AREA
)
1465 ::osl::ClearableMutexGuard
aGuard( m_aMutex
);
1467 inspection::InteractiveSelectionResult eResult
= inspection::InteractiveSelectionResult_Cancelled
;
1468 const uno::Reference
< awt::XWindow
> xInspectorWindow(m_xContext
->getValueByName("DialogParentWindow") ,uno::UNO_QUERY
);
1469 const uno::Reference
< report::XShape
> xShape(m_xReportComponent
,uno::UNO_QUERY
);
1472 if ( rptui::openAreaDialog( xShape
, xInspectorWindow
) )
1474 eResult
= inspection::InteractiveSelectionResult_ObtainedValue
;
1475 beans::PropertyChangeEvent aScopeEvent
;
1476 aScopeEvent
.PropertyName
= PROPERTY_FILLCOLOR
;
1477 aScopeEvent
.NewValue
= xShape
->getPropertyValue(PROPERTY_FILLCOLOR
);
1478 m_aPropertyListeners
.notify( aScopeEvent
, &beans::XPropertyChangeListener::propertyChange
);
1484 return m_xFormComponentHandler
->onInteractivePropertySelection(PropertyName
, Primary
, _rData
, _rxInspectorUI
);
1487 void SAL_CALL
GeometryHandler::actuatingPropertyChanged(const OUString
& ActuatingPropertyName
, const uno::Any
& NewValue
, const uno::Any
& OldValue
, const uno::Reference
< inspection::XObjectInspectorUI
> & _rxInspectorUI
, sal_Bool _bFirstTimeInit
)
1489 if ( !_rxInspectorUI
.is() )
1490 throw lang::NullPointerException();
1492 ::osl::MutexGuard
aGuard( m_aMutex
);
1493 const sal_Int32 nId
= OPropertyInfoService::getPropertyId(ActuatingPropertyName
);
1496 case PROPERTY_ID_TYPE
:
1498 sal_uInt32 nNewVal
= 0;
1499 NewValue
>>= nNewVal
;
1502 case DATA_OR_FORMULA
:
1503 _rxInspectorUI
->rebuildPropertyUI(PROPERTY_DATAFIELD
);
1504 _rxInspectorUI
->enablePropertyUI(PROPERTY_DATAFIELD
,true);
1505 _rxInspectorUI
->enablePropertyUI(PROPERTY_FORMULALIST
,false);
1506 _rxInspectorUI
->enablePropertyUI(PROPERTY_SCOPE
,false);
1507 OSL_ENSURE(m_sDefaultFunction
.isEmpty(),"Why is the m_sDefaultFunction set?");
1508 OSL_ENSURE(m_sScope
.isEmpty(),"Why is the m_sScope set?");
1511 _rxInspectorUI
->rebuildPropertyUI(PROPERTY_DATAFIELD
);
1512 _rxInspectorUI
->rebuildPropertyUI(PROPERTY_FORMULALIST
);
1513 _rxInspectorUI
->enablePropertyUI(PROPERTY_DATAFIELD
,true);
1514 _rxInspectorUI
->enablePropertyUI(PROPERTY_FORMULALIST
,!m_sDefaultFunction
.isEmpty());
1515 _rxInspectorUI
->enablePropertyUI(PROPERTY_SCOPE
,!m_sScope
.isEmpty());
1517 case USER_DEF_FUNCTION
:
1518 _rxInspectorUI
->enablePropertyUI(PROPERTY_DATAFIELD
,false);
1519 _rxInspectorUI
->enablePropertyUI(PROPERTY_FORMULALIST
,true);
1520 _rxInspectorUI
->rebuildPropertyUI(PROPERTY_FORMULALIST
);
1521 _rxInspectorUI
->enablePropertyUI(PROPERTY_SCOPE
,false);
1524 _rxInspectorUI
->enablePropertyUI(PROPERTY_DATAFIELD
,false);
1525 _rxInspectorUI
->enablePropertyUI(PROPERTY_FORMULALIST
,false);
1526 _rxInspectorUI
->enablePropertyUI(PROPERTY_SCOPE
,true);
1531 case PROPERTY_ID_DATAFIELD
:
1533 bool bEnable
= (m_nDataFieldType
!= DATA_OR_FORMULA
&& m_nDataFieldType
!= COUNTER
);
1537 m_xReportComponent
->getPropertyValue( PROPERTY_DATAFIELD
) >>= sValue
;
1538 bEnable
= !sValue
.isEmpty();
1540 _rxInspectorUI
->enablePropertyUI(PROPERTY_FORMULALIST
,bEnable
);
1543 _rxInspectorUI
->rebuildPropertyUI(PROPERTY_DATAFIELD
);
1544 _rxInspectorUI
->rebuildPropertyUI(PROPERTY_FORMULALIST
);
1546 m_xFormComponentHandler
->actuatingPropertyChanged(ActuatingPropertyName
, NewValue
, OldValue
, _rxInspectorUI
, _bFirstTimeInit
);
1549 case PROPERTY_ID_FORMULALIST
:
1551 _rxInspectorUI
->enablePropertyUI(PROPERTY_SCOPE
,m_nDataFieldType
== FUNCTION
|| m_nDataFieldType
== COUNTER
);
1554 case PROPERTY_ID_BACKTRANSPARENT
:
1555 case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT
:
1557 bool bValue
= false;
1558 NewValue
>>= bValue
;
1560 _rxInspectorUI
->enablePropertyUI(PROPERTY_BACKCOLOR
,bValue
);
1561 _rxInspectorUI
->enablePropertyUI(PROPERTY_CONTROLBACKGROUND
,bValue
);
1565 m_xFormComponentHandler
->actuatingPropertyChanged(ActuatingPropertyName
, NewValue
, OldValue
, _rxInspectorUI
, _bFirstTimeInit
);
1570 sal_Bool SAL_CALL
GeometryHandler::suspend(sal_Bool Suspend
)
1572 return m_xFormComponentHandler
->suspend(Suspend
);
1575 bool GeometryHandler::impl_dialogFilter_nothrow( OUString
& _out_rSelectedClause
, ::osl::ClearableMutexGuard
& _rClearBeforeDialog
) const
1577 _out_rSelectedClause
.clear();
1578 bool bSuccess
= false;
1579 ::dbtools::SQLExceptionInfo aErrorInfo
;
1580 uno::Reference
< awt::XWindow
> xInspectorWindow
;
1581 uno::Reference
< lang::XMultiComponentFactory
> xFactory
;
1584 xFactory
= m_xContext
->getServiceManager();
1585 xInspectorWindow
.set(m_xContext
->getValueByName("DialogParentWindow") ,uno::UNO_QUERY
);
1586 uno::Reference
<sdbc::XConnection
> xCon(m_xContext
->getValueByName("ActiveConnection") ,uno::UNO_QUERY
);
1590 uno::Reference
< beans::XPropertySet
> xRowSetProp(m_xRowSet
,uno::UNO_QUERY
);
1591 if ( !m_xRowSet
.is() )
1593 m_xRowSet
.set(xFactory
->createInstanceWithContext("com.sun.star.sdb.RowSet",m_xContext
),uno::UNO_QUERY
);
1594 xRowSetProp
.set(m_xRowSet
,uno::UNO_QUERY
);
1595 xRowSetProp
->setPropertyValue(PROPERTY_ACTIVECONNECTION
,uno::makeAny(xCon
));
1596 ::comphelper::copyProperties(m_xReportComponent
,xRowSetProp
);
1599 // get a composer for the statement which the form is currently based on
1600 uno::Reference
< sdb::XSingleSelectQueryComposer
> xComposer( ::dbtools::getCurrentSettingsComposer( xRowSetProp
, m_xContext
) );
1601 OSL_ENSURE( xComposer
.is(), "GeometryHandler::impl_dialogFilter_nothrow: could not obtain a composer!" );
1602 if ( !xComposer
.is() )
1605 // create the dialog
1606 uno::Reference
< ui::dialogs::XExecutableDialog
> xDialog
= sdb::FilterDialog::createWithQuery(m_xContext
, xComposer
, m_xRowSet
, xInspectorWindow
);
1608 const OUString
sPropertyUIName(RptResId(RID_STR_FILTER
));
1609 // initialize the dialog
1610 xDialog
->setTitle( sPropertyUIName
);
1612 _rClearBeforeDialog
.clear();
1613 bSuccess
= ( xDialog
->execute() != 0 );
1615 _out_rSelectedClause
= xComposer
->getFilter();
1617 catch (const sdb::SQLContext
& e
) { aErrorInfo
= e
; }
1618 catch (const sdbc::SQLWarning
& e
) { aErrorInfo
= e
; }
1619 catch (const sdbc::SQLException
& e
) { aErrorInfo
= e
; }
1620 catch( const uno::Exception
& )
1622 OSL_FAIL( "GeometryHandler::impl_dialogFilter_nothrow: caught an exception!" );
1625 if ( aErrorInfo
.isValid() )
1626 ::dbtools::showError( aErrorInfo
, xInspectorWindow
, m_xContext
);
1631 void GeometryHandler::checkPosAndSize( const awt::Point
& _aNewPos
,
1632 const awt::Size
& _aSize
)
1634 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY
);
1635 const uno::Reference
< report::XSection
> xSection(xSourceReportComponent
->getParent(),uno::UNO_QUERY
);
1636 if ( !xSection
.is() || uno::Reference
< report::XShape
>(xSourceReportComponent
,uno::UNO_QUERY
).is() ) // shapes can overlap.
1639 ::Point
aPos(VCLPoint(_aNewPos
));
1640 if ( aPos
.X() < 0 || aPos
.Y() < 0 ) // TODO: have to check size with pos aka || (aPos.X() + aAwtSize.Width) > m_xSection->getReportDefinition()->
1641 throw beans::PropertyVetoException(RptResId(RID_STR_ILLEGAL_POSITION
),xSourceReportComponent
);
1643 ::tools::Rectangle
aSourceRect(aPos
,VCLSize(_aSize
));
1645 const sal_Int32 nCount
= xSection
->getCount();
1646 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
1648 const uno::Reference
< report::XReportComponent
> xReportComponent(xSection
->getByIndex(i
),uno::UNO_QUERY
);
1649 if ( xReportComponent
.is() && xReportComponent
!= xSourceReportComponent
)
1651 const ::tools::Rectangle
aBoundRect(VCLPoint(xReportComponent
->getPosition()),VCLSize(xReportComponent
->getSize()));
1652 const ::tools::Rectangle aRect
= aSourceRect
.GetIntersection(aBoundRect
);
1653 if ( !aRect
.IsEmpty() && (aRect
.Left() != aRect
.Right() && aRect
.Top() != aRect
.Bottom() ) )
1654 throw beans::PropertyVetoException(RptResId( RID_STR_OVERLAP_OTHER_CONTROL
),xSourceReportComponent
);
1659 void GeometryHandler::impl_fillFormulaList_nothrow(::std::vector
< OUString
>& out_rList
) const
1661 if ( m_nDataFieldType
== FUNCTION
)
1663 for (auto const& it
: m_aDefaultFunctions
)
1665 out_rList
.push_back(it
.getName());
1668 else if ( m_nDataFieldType
== USER_DEF_FUNCTION
)
1669 ::std::transform( m_aFunctionNames
.begin(),
1670 m_aFunctionNames
.end(),
1671 ::std::back_inserter(out_rList
),
1672 ::o3tl::select1st
< TFunctions::value_type
>() );
1675 OUString
GeometryHandler::impl_ConvertUIToMimeType_nothrow(const OUString
& _sUIName
) const
1677 ::std::vector
< OUString
> aList
;
1678 impl_fillMimeTypes_nothrow(aList
);
1680 ::std::vector
< OUString
>::const_iterator aFind
= ::std::find(aList
.begin(),aList
.end(),_sUIName
);
1681 if ( aFind
!= aList
.end() )
1683 const std::size_t nPos
= aFind
- aList
.begin();
1684 const uno::Reference
< report::XReportDefinition
> xReportDefinition(m_xReportComponent
,uno::UNO_QUERY
);
1685 if ( xReportDefinition
.is() )
1687 const uno::Sequence
< OUString
> aMimeTypes( xReportDefinition
->getAvailableMimeTypes() );
1688 sRet
= aMimeTypes
[nPos
];
1694 OUString
GeometryHandler::impl_ConvertMimeTypeToUI_nothrow(const OUString
& _sMimetype
) const
1696 ::comphelper::MimeConfigurationHelper
aMimeHelper(m_xContext
);
1698 std::shared_ptr
<const SfxFilter
> pFilter
= SfxFilter::GetDefaultFilter( aMimeHelper
.GetDocServiceNameFromMediaType(_sMimetype
) );
1700 sRet
= pFilter
->GetUIName();
1701 if ( sRet
.isEmpty() )
1706 void GeometryHandler::impl_fillMimeTypes_nothrow(::std::vector
< OUString
>& _out_rList
) const
1710 const uno::Reference
< report::XReportDefinition
> xReportDefinition(m_xReportComponent
,uno::UNO_QUERY
);
1711 if ( xReportDefinition
.is() )
1713 uno::Sequence
< OUString
> aMimeTypes( xReportDefinition
->getAvailableMimeTypes() );
1714 const OUString
* pIter
= aMimeTypes
.getConstArray();
1715 const OUString
* pEnd
= pIter
+ aMimeTypes
.getLength();
1716 for(;pIter
!= pEnd
; ++pIter
)
1718 const OUString
sDocName( impl_ConvertMimeTypeToUI_nothrow(*pIter
) );
1719 if ( !sDocName
.isEmpty() )
1720 _out_rList
.push_back(sDocName
);
1724 catch(uno::Exception
&)
1726 OSL_FAIL("Exception caught!");
1730 void GeometryHandler::impl_fillScopeList_nothrow(::std::vector
< OUString
>& _out_rList
) const
1734 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY_THROW
);
1735 const uno::Reference
< report::XSection
> xSection(xSourceReportComponent
->getParent(),uno::UNO_QUERY_THROW
);
1737 const uno::Reference
< report::XReportDefinition
> xReportDefinition
= xSection
->getReportDefinition();
1738 const uno::Reference
< report::XGroups
> xGroups
= xReportDefinition
->getGroups();
1739 sal_Int32 nPos
= -1;
1740 uno::Reference
< report::XGroup
> xGroup
= xSection
->getGroup();
1742 nPos
= getPositionInIndexAccess(xGroups
.get(),xGroup
);
1743 else if ( xSection
== xReportDefinition
->getDetail() )
1744 nPos
= xGroups
->getCount()-1;
1746 const OUString sGroup
= RptResId(RID_STR_SCOPE_GROUP
);
1747 for (sal_Int32 i
= 0 ; i
<= nPos
; ++i
)
1749 xGroup
.set(xGroups
->getByIndex(i
),uno::UNO_QUERY_THROW
);
1750 OUString sGroupName
= sGroup
.replaceFirst("%1",xGroup
->getExpression());
1751 _out_rList
.push_back(sGroupName
);
1753 _out_rList
.push_back(xReportDefinition
->getName());
1755 catch(uno::Exception
&)
1757 OSL_FAIL("Exception caught!");
1761 uno::Reference
< report::XFunctionsSupplier
> GeometryHandler::fillScope_throw(OUString
& _rsNamePostfix
)
1763 uno::Reference
< report::XFunctionsSupplier
> xReturn
;
1765 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY_THROW
);
1766 const uno::Reference
< report::XSection
> xSection(xSourceReportComponent
->getParent(),uno::UNO_QUERY_THROW
);
1767 const uno::Reference
< report::XReportDefinition
> xReportDefinition
= xSection
->getReportDefinition();
1768 if ( m_sScope
.isEmpty() )
1770 const uno::Reference
< report::XGroup
> xGroup(xSection
->getGroup(),uno::UNO_QUERY
);
1773 OUString sGroupName
= RptResId(RID_STR_SCOPE_GROUP
);
1774 _rsNamePostfix
= xGroup
->getExpression();
1775 m_sScope
= sGroupName
.replaceFirst("%1",_rsNamePostfix
);
1776 xReturn
= xGroup
.get();
1778 else if ( xSection
== xReportDefinition
->getDetail() )
1780 const uno::Reference
< report::XGroups
> xGroups
= xReportDefinition
->getGroups();
1781 const sal_Int32 nCount
= xGroups
->getCount();
1784 const uno::Reference
< report::XGroup
> xGroup2(xGroups
->getByIndex(nCount
- 1),uno::UNO_QUERY_THROW
);
1785 OUString sGroupName
= RptResId(RID_STR_SCOPE_GROUP
);
1786 _rsNamePostfix
= xGroup2
->getExpression();
1787 m_sScope
= sGroupName
.replaceFirst("%1",_rsNamePostfix
);
1788 xReturn
= xGroup2
.get();
1791 if ( m_sScope
.isEmpty() )
1793 xReturn
= xReportDefinition
.get();
1794 _rsNamePostfix
= m_sScope
= xReportDefinition
->getName();
1797 else if ( m_sScope
== xReportDefinition
->getName() )
1799 xReturn
= xReportDefinition
.get();
1800 _rsNamePostfix
= m_sScope
;
1804 uno::Reference
< report::XGroups
> xGroups
= xReportDefinition
->getGroups();
1805 const sal_Int32 nCount
= xGroups
->getCount();
1807 for (sal_Int32 i
= 0 ; i
< nCount
; ++i
)
1809 const uno::Reference
< report::XGroup
> xGroup(xGroups
->getByIndex(i
),uno::UNO_QUERY_THROW
);
1810 OUString sGroupName
= RptResId(RID_STR_SCOPE_GROUP
);
1811 if ( m_sScope
== sGroupName
.replaceFirst("%1",xGroup
->getExpression()) )
1813 _rsNamePostfix
= xGroup
->getExpression();
1814 xReturn
= xGroup
.get();
1820 OSL_ENSURE(xReturn
.is(),"Why don't we have a functionssupplier here!");
1825 bool GeometryHandler::isDefaultFunction( const OUString
& _sQuotedFunction
1826 ,OUString
& _rDataField
1827 ,const uno::Reference
< report::XFunctionsSupplier
>& _xFunctionsSupplier
1830 bool bDefaultFunction
= false;
1833 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY_THROW
);
1834 const uno::Reference
< report::XSection
> xSection(xSourceReportComponent
->getParent(),uno::UNO_QUERY_THROW
);
1835 const uno::Reference
< report::XReportDefinition
> xReportDefinition
= xSection
->getReportDefinition();
1837 ::std::pair
<TFunctions::const_iterator
,TFunctions::const_iterator
> aFind
= m_aFunctionNames
.equal_range(_sQuotedFunction
);
1838 while ( aFind
.first
!= aFind
.second
)
1840 if ( !_xFunctionsSupplier
.is() || _xFunctionsSupplier
== aFind
.first
->second
.second
)
1842 const beans::Optional
< OUString
> aInitalFormula
= aFind
.first
->second
.first
->getInitialFormula();
1843 if ( aInitalFormula
.IsPresent
)
1845 OUString sDefaultFunctionName
;
1846 bDefaultFunction
= impl_isDefaultFunction_nothrow(aFind
.first
->second
.first
,_rDataField
,sDefaultFunctionName
);
1847 if ( bDefaultFunction
)
1849 m_xFunction
= aFind
.first
->second
.first
;
1852 m_sDefaultFunction
= sDefaultFunctionName
;
1853 uno::Reference
< report::XGroup
> xGroup(aFind
.first
->second
.second
,uno::UNO_QUERY
);
1856 OUString sGroupName
= RptResId(RID_STR_SCOPE_GROUP
);
1857 m_sScope
= sGroupName
.replaceFirst("%1",xGroup
->getExpression());
1860 m_sScope
= xReportDefinition
->getName();
1869 catch(uno::Exception
&)
1871 OSL_FAIL("Exception caught!");
1873 return bDefaultFunction
;
1876 bool GeometryHandler::impl_isDefaultFunction_nothrow( const uno::Reference
< report::XFunction
>& _xFunction
1877 ,OUString
& _rDataField
1878 ,OUString
& _rsDefaultFunctionName
) const
1880 bool bDefaultFunction
= false;
1883 const OUString
sFormula( _xFunction
->getFormula() );
1884 i18nutil::SearchOptions2 aSearchOptions
;
1885 aSearchOptions
.AlgorithmType2
= util::SearchAlgorithms2::REGEXP
;
1886 aSearchOptions
.searchFlag
= 0x00000100;
1887 ::std::vector
< DefaultFunction
>::const_iterator aIter
= m_aDefaultFunctions
.begin();
1888 ::std::vector
< DefaultFunction
>::const_iterator aDeEnd
= m_aDefaultFunctions
.end();
1889 for (; aIter
!= aDeEnd
; ++aIter
)
1891 aSearchOptions
.searchString
= aIter
->m_sSearchString
;
1892 utl::TextSearch
aTextSearch( aSearchOptions
);
1893 sal_Int32 start
= 0;
1894 sal_Int32 end
= sFormula
.getLength();
1895 if (aTextSearch
.SearchForward(sFormula
, &start
, &end
) && start
== 0 && end
== sFormula
.getLength()) // default function found
1897 aSearchOptions
.searchString
= "\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]";
1898 utl::TextSearch
aDataSearch( aSearchOptions
);
1899 (void)aDataSearch
.SearchForward(sFormula
, &start
, &end
);
1901 _rDataField
= sFormula
.copy(start
,end
-start
-1);
1902 _rsDefaultFunctionName
= aIter
->m_sName
;
1907 bDefaultFunction
= aIter
!= aDeEnd
;
1909 catch(uno::Exception
&)
1911 OSL_FAIL("Exception caught!");
1913 return bDefaultFunction
;
1916 void GeometryHandler::loadDefaultFunctions()
1918 if ( m_aDefaultFunctions
.empty() )
1920 m_aCounterFunction
.m_bPreEvaluated
= false;
1921 m_aCounterFunction
.m_sName
= RptResId(RID_STR_F_COUNTER
);
1922 m_aCounterFunction
.m_sFormula
= "rpt:[%FunctionName] + 1";
1923 m_aCounterFunction
.m_sSearchString
= "rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*[:digit:]*";
1924 m_aCounterFunction
.m_sInitialFormula
.IsPresent
= true;
1925 m_aCounterFunction
.m_sInitialFormula
.Value
= "rpt:1";
1927 DefaultFunction aDefault
;
1929 aDefault
.m_bPreEvaluated
= true;
1931 aDefault
.m_sName
= RptResId(RID_STR_F_ACCUMULATION
);
1932 aDefault
.m_sFormula
= "rpt:[%Column] + [%FunctionName]";
1933 aDefault
.m_sSearchString
= "rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]";
1934 aDefault
.m_sInitialFormula
.IsPresent
= true;
1935 aDefault
.m_sInitialFormula
.Value
= "rpt:[%Column]";
1936 m_aDefaultFunctions
.push_back(aDefault
);
1938 aDefault
.m_sName
= RptResId(RID_STR_F_MINIMUM
);
1939 aDefault
.m_sFormula
= "rpt:IF([%Column] < [%FunctionName];[%Column];[%FunctionName])";
1940 aDefault
.m_sSearchString
= "rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*<[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)";
1941 aDefault
.m_sInitialFormula
.IsPresent
= true;
1942 aDefault
.m_sInitialFormula
.Value
= "rpt:[%Column]";
1943 m_aDefaultFunctions
.push_back(aDefault
);
1945 aDefault
.m_sName
= RptResId(RID_STR_F_MAXIMUM
);
1946 aDefault
.m_sFormula
= "rpt:IF([%Column] > [%FunctionName];[%Column];[%FunctionName])";
1947 aDefault
.m_sSearchString
= "rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*>[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)";
1948 aDefault
.m_sInitialFormula
.IsPresent
= true;
1949 aDefault
.m_sInitialFormula
.Value
= "rpt:[%Column]";
1950 m_aDefaultFunctions
.push_back(aDefault
);
1954 void GeometryHandler::createDefaultFunction(::osl::ResettableMutexGuard
& _aGuard
,const OUString
& _sFunction
,const OUString
& _sDataField
)
1958 OUString sNamePostfix
;
1959 const uno::Reference
< report::XFunctionsSupplier
> xFunctionsSupplier
= fillScope_throw(sNamePostfix
);
1961 ::std::vector
< DefaultFunction
>::const_iterator aIter
= m_aDefaultFunctions
.begin();
1962 ::std::vector
< DefaultFunction
>::const_iterator aDeEnd
= m_aDefaultFunctions
.end();
1963 for (; aIter
!= aDeEnd
; ++aIter
)
1965 if ( aIter
->m_sName
== _sFunction
)
1967 const OUString
sFunctionName( _sFunction
+ _sDataField
+ sNamePostfix
);
1968 const OUString
sQuotedFunctionName(lcl_getQuotedFunctionName(sFunctionName
));
1970 beans::PropertyChangeEvent aEvent
;
1971 aEvent
.PropertyName
= PROPERTY_SCOPE
;
1972 aEvent
.OldValue
<<= m_sScope
;
1974 ::std::pair
<TFunctions::const_iterator
,TFunctions::const_iterator
> aFind
= m_aFunctionNames
.equal_range(sQuotedFunctionName
);
1975 while ( aFind
.first
!= aFind
.second
)
1977 if ( xFunctionsSupplier
== aFind
.first
->second
.second
)
1979 m_xFunction
= aFind
.first
->second
.first
;
1981 isDefaultFunction(sQuotedFunctionName
,sTemp
,uno::Reference
< report::XFunctionsSupplier
>(),true); // implicitly sets the m_sScope
1986 if ( aFind
.first
== aFind
.second
)
1987 impl_createFunction(sFunctionName
,_sDataField
,*aIter
);
1989 OBlocker
aBlocker(m_bIn
);
1990 m_xReportComponent
->setPropertyValue(PROPERTY_DATAFIELD
,uno::makeAny( impl_convertToFormula( uno::makeAny(sQuotedFunctionName
) )));
1991 aEvent
.NewValue
<<= m_sScope
;
1993 m_aPropertyListeners
.notify( aEvent
, &beans::XPropertyChangeListener::propertyChange
);
1998 catch(uno::Exception
&)
2000 OSL_FAIL("Exception caught!");
2004 void GeometryHandler::removeFunction()
2006 if ( m_xFunction
.is() )
2008 const OUString
sQuotedFunctionName(lcl_getQuotedFunctionName(m_xFunction
));
2009 ::std::pair
<TFunctions::iterator
,TFunctions::iterator
> aFind
= m_aFunctionNames
.equal_range(sQuotedFunctionName
);
2010 while ( aFind
.first
!= aFind
.second
)
2012 if ( aFind
.first
->second
.first
== m_xFunction
)
2014 uno::Reference
< report::XFunctions
> xFunctions
= aFind
.first
->second
.second
->getFunctions();
2015 xFunctions
->removeByIndex(xFunctions
->getCount() - 1 ); /// TODO: insert new method in XFunctions: removeFunction(xfunction)
2016 m_aFunctionNames
.erase(aFind
.first
);
2017 m_bNewFunction
= false;
2025 void GeometryHandler::resetOwnProperties(::osl::ResettableMutexGuard
& _aGuard
,const OUString
& _sOldFunctionName
,const OUString
& _sOldScope
,const sal_uInt32 _nOldDataFieldType
)
2027 const OUString sNewFunction
= m_sDefaultFunction
;
2028 const OUString sNewScope
= m_sScope
;
2029 const sal_uInt32 nNewDataFieldType
= m_nDataFieldType
;
2031 if ( _nOldDataFieldType
!= nNewDataFieldType
)
2033 beans::PropertyChangeEvent aScopeEvent
;
2034 aScopeEvent
.PropertyName
= PROPERTY_TYPE
;
2035 aScopeEvent
.OldValue
<<= _nOldDataFieldType
;
2036 aScopeEvent
.NewValue
<<= nNewDataFieldType
;
2037 m_aPropertyListeners
.notify( aScopeEvent
, &beans::XPropertyChangeListener::propertyChange
);
2039 if ( _sOldFunctionName
!= sNewFunction
)
2041 beans::PropertyChangeEvent aFormulaEvent
;
2042 aFormulaEvent
.PropertyName
= PROPERTY_FORMULALIST
;
2043 aFormulaEvent
.OldValue
<<= _sOldFunctionName
;
2044 aFormulaEvent
.NewValue
<<= sNewFunction
;
2046 m_aPropertyListeners
.notify( aFormulaEvent
, &beans::XPropertyChangeListener::propertyChange
);
2048 if ( _sOldScope
!= sNewScope
)
2050 beans::PropertyChangeEvent aScopeEvent
;
2051 aScopeEvent
.PropertyName
= PROPERTY_SCOPE
;
2052 aScopeEvent
.OldValue
<<= _sOldScope
;
2053 aScopeEvent
.NewValue
<<= sNewScope
;
2054 m_aPropertyListeners
.notify( aScopeEvent
, &beans::XPropertyChangeListener::propertyChange
);
2060 void GeometryHandler::impl_initFieldList_nothrow( uno::Sequence
< OUString
>& _rFieldNames
) const
2062 _rFieldNames
.realloc(0);
2065 uno::Reference
< awt::XWindow
> xInspectorWindow(m_xContext
->getValueByName("DialogParentWindow") ,uno::UNO_QUERY
);
2066 VclPtr
<vcl::Window
> pInspectorWindow
= VCLUnoHelper::GetWindow( xInspectorWindow
);
2067 WaitObject
aWaitCursor( pInspectorWindow
);
2069 // get the form of the control we're inspecting
2070 uno::Reference
< beans::XPropertySet
> xFormSet( m_xRowSet
, uno::UNO_QUERY
);
2071 if ( !xFormSet
.is() )
2074 OUString sObjectName
;
2075 OSL_VERIFY( xFormSet
->getPropertyValue( PROPERTY_COMMAND
) >>= sObjectName
);
2076 // when there is no command we don't need to ask for columns
2077 uno::Reference
<sdbc::XConnection
> xCon(m_xContext
->getValueByName("ActiveConnection") ,uno::UNO_QUERY
);
2078 if ( !sObjectName
.isEmpty() && xCon
.is() )
2080 sal_Int32 nObjectType
= sdb::CommandType::COMMAND
;
2081 OSL_VERIFY( xFormSet
->getPropertyValue( PROPERTY_COMMANDTYPE
) >>= nObjectType
);
2083 _rFieldNames
= ::dbtools::getFieldNamesByCommandDescriptor( xCon
, nObjectType
, sObjectName
);
2086 catch (uno::Exception
&)
2088 OSL_FAIL( "GeometryHandler::impl_initFieldList_nothrow: caught an exception!" );
2092 bool GeometryHandler::impl_isCounterFunction_throw(const OUString
& _sQuotedFunctionName
,OUString
& Out_sScope
) const
2094 ::std::pair
<TFunctions::const_iterator
,TFunctions::const_iterator
> aFind
= m_aFunctionNames
.equal_range(_sQuotedFunctionName
);
2095 while ( aFind
.first
!= aFind
.second
)
2097 const beans::Optional
< OUString
> aInitalFormula
= aFind
.first
->second
.first
->getInitialFormula();
2098 if ( aInitalFormula
.IsPresent
)
2100 const OUString
sFormula( aFind
.first
->second
.first
->getFormula() );
2101 i18nutil::SearchOptions2 aSearchOptions
;
2102 aSearchOptions
.AlgorithmType2
= util::SearchAlgorithms2::REGEXP
;
2103 aSearchOptions
.searchFlag
= 0x00000100;
2104 aSearchOptions
.searchString
= m_aCounterFunction
.m_sSearchString
;
2105 utl::TextSearch
aTextSearch( aSearchOptions
);
2106 sal_Int32 start
= 0;
2107 sal_Int32 end
= sFormula
.getLength();
2108 if ( aTextSearch
.SearchForward(sFormula
,&start
,&end
) && start
== 0 && end
== sFormula
.getLength()) // counter function found
2110 const uno::Reference
< report::XGroup
> xGroup(aFind
.first
->second
.second
,uno::UNO_QUERY
);
2113 OUString sGroupName
= RptResId(RID_STR_SCOPE_GROUP
);
2114 Out_sScope
= sGroupName
.replaceFirst("%1",xGroup
->getExpression());
2117 Out_sScope
= uno::Reference
< report::XReportDefinition
>(aFind
.first
->second
.second
,uno::UNO_QUERY_THROW
)->getName();
2123 return aFind
.first
!= aFind
.second
;
2126 void GeometryHandler::impl_createFunction(const OUString
& _sFunctionName
,const OUString
& _sDataField
,const DefaultFunction
& _aFunction
)
2128 if ( m_bNewFunction
)
2131 const OUString
sQuotedFunctionName(lcl_getQuotedFunctionName(_sFunctionName
));
2132 m_xFunction
.set(report::Function::create(m_xContext
));
2133 m_xFunction
->setName( _sFunctionName
);
2135 const OUString
sPlaceHolder1("%Column");
2136 const OUString
sPlaceHolder2("%FunctionName");
2137 OUString
sFormula(_aFunction
.m_sFormula
);
2138 sFormula
= sFormula
.replaceAll(sPlaceHolder1
,_sDataField
);
2139 sFormula
= sFormula
.replaceAll(sPlaceHolder2
,_sFunctionName
);
2141 m_xFunction
->setFormula(sFormula
);
2142 m_xFunction
->setPreEvaluated(_aFunction
.m_bPreEvaluated
);
2143 m_xFunction
->setDeepTraversing(false);
2144 if ( _aFunction
.m_sInitialFormula
.IsPresent
)
2146 beans::Optional
< OUString
> aInitialFormula
= _aFunction
.m_sInitialFormula
;
2147 OUString sInitialFormula
= aInitialFormula
.Value
;
2148 sInitialFormula
= sInitialFormula
.replaceAll(sPlaceHolder1
,_sDataField
);
2149 sInitialFormula
= sInitialFormula
.replaceAll(sPlaceHolder2
,_sFunctionName
);
2150 aInitialFormula
.Value
= sInitialFormula
;
2151 m_xFunction
->setInitialFormula( aInitialFormula
);
2153 OUString sNamePostfix
;
2154 const uno::Reference
< report::XFunctionsSupplier
> xFunctionsSupplier
= fillScope_throw(sNamePostfix
);
2155 const uno::Reference
< container::XIndexContainer
> xFunctions(xFunctionsSupplier
->getFunctions(),uno::UNO_QUERY_THROW
);
2156 xFunctions
->insertByIndex(xFunctions
->getCount(),uno::makeAny(m_xFunction
));
2157 m_aFunctionNames
.emplace(sQuotedFunctionName
,TFunctionPair(m_xFunction
,xFunctionsSupplier
));
2158 m_bNewFunction
= true;
2161 void GeometryHandler::impl_setCounterFunction_throw()
2163 OUString sNamePostfix
;
2164 fillScope_throw(sNamePostfix
);
2165 OUString sFunctionName
= m_aCounterFunction
.m_sName
;
2166 sFunctionName
+= sNamePostfix
;
2167 const OUString sQuotedFunctionName
= lcl_getQuotedFunctionName(sFunctionName
);
2169 if ( !(!sFunctionName
.isEmpty() && m_aFunctionNames
.find(sQuotedFunctionName
) != m_aFunctionNames
.end() && impl_isCounterFunction_throw(sQuotedFunctionName
,sScope
)) )
2170 impl_createFunction(sFunctionName
,OUString(),m_aCounterFunction
);
2172 OBlocker
aBlocker(m_bIn
);
2173 m_xReportComponent
->setPropertyValue(PROPERTY_DATAFIELD
,uno::makeAny(impl_convertToFormula( uno::makeAny(sQuotedFunctionName
))));
2176 sal_uInt32
GeometryHandler::impl_getDataFieldType_throw(const OUString
& _sDataField
) const
2178 sal_uInt32 nDataFieldType
= UNDEF_DATA
;
2179 OUString sDataField
;
2180 if ( !_sDataField
.isEmpty() )
2181 sDataField
= _sDataField
;
2184 uno::Any
aDataField( m_xReportComponent
->getPropertyValue( PROPERTY_DATAFIELD
) );
2185 lcl_convertFormulaTo(aDataField
,aDataField
);
2186 aDataField
>>= sDataField
;
2189 if ( !sDataField
.isEmpty() )
2191 if ( impl_isDataField(sDataField
) )
2192 nDataFieldType
= DATA_OR_FORMULA
;
2193 else if ( isDefaultFunction(sDataField
,sDataField
) )
2194 nDataFieldType
= FUNCTION
;
2195 else if ( m_aFunctionNames
.find(sDataField
) != m_aFunctionNames
.end() )
2197 nDataFieldType
= USER_DEF_FUNCTION
;
2199 if ( impl_isCounterFunction_throw(sDataField
,sScope
) )
2200 nDataFieldType
= COUNTER
;
2203 nDataFieldType
= DATA_OR_FORMULA
;
2205 return nDataFieldType
;
2209 void SAL_CALL
GeometryHandler::disposing(const lang::EventObject
& )
2212 // XPropertyChangeListener
2213 void SAL_CALL
GeometryHandler::propertyChange(const beans::PropertyChangeEvent
& /*evt*/)
2215 ::osl::ResettableMutexGuard
aGuard( m_aMutex
);
2218 const sal_uInt32 nOldDataFieldType
= m_nDataFieldType
;
2219 const OUString sOldFunctionName
= m_sDefaultFunction
;
2220 const OUString sOldScope
= m_sScope
;
2221 m_sDefaultFunction
.clear();
2223 m_nDataFieldType
= impl_getDataFieldType_throw();
2224 if ( UNDEF_DATA
== m_nDataFieldType
)
2225 m_nDataFieldType
= nOldDataFieldType
;
2226 uno::Any aDataField
= m_xReportComponent
->getPropertyValue( PROPERTY_DATAFIELD
);
2227 lcl_convertFormulaTo(aDataField
,aDataField
);
2228 OUString sDataField
;
2229 aDataField
>>= sDataField
;
2230 switch(m_nDataFieldType
)
2233 isDefaultFunction(sDataField
,sDataField
,uno::Reference
< report::XFunctionsSupplier
>(),true);
2236 impl_isCounterFunction_throw(sDataField
,m_sScope
);
2242 resetOwnProperties(aGuard
,sOldFunctionName
,sOldScope
,nOldDataFieldType
);
2246 } // namespace rptui
2249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */