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>
24 #include "GeometryHandler.hxx"
26 #include <comphelper/types.hxx>
27 #include <comphelper/property.hxx>
28 #include <comphelper/mimeconfighelper.hxx>
29 #include <cppuhelper/supportsservice.hxx>
31 #include "uistrings.hrc"
32 #include "reportformula.hxx"
34 #include <unotools/textsearch.hxx>
35 #include <unotools/configmgr.hxx>
37 #include <toolkit/helper/vclunohelper.hxx>
38 #include <unotools/syslocale.hxx>
39 #include <tools/diagnose_ex.h>
40 #include <tools/StringListResource.hxx>
41 #include <com/sun/star/lang/XInitialization.hpp>
42 #include <com/sun/star/form/inspection/FormComponentPropertyHandler.hpp>
43 #include <com/sun/star/inspection/StringRepresentation.hpp>
44 #include <com/sun/star/inspection/PropertyLineElement.hpp>
45 #include <com/sun/star/inspection/PropertyControlType.hpp>
46 #include <com/sun/star/inspection/XStringListControl.hpp>
47 #include <com/sun/star/report/Function.hpp>
48 #include <com/sun/star/report/XReportDefinition.hpp>
49 #include <com/sun/star/report/XShape.hpp>
50 #include <com/sun/star/report/XSection.hpp>
51 #include <com/sun/star/report/XFormattedField.hpp>
52 #include <com/sun/star/report/XFixedLine.hpp>
53 #include <com/sun/star/script/Converter.hpp>
54 #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
55 #include <com/sun/star/sdb/CommandType.hpp>
56 #include <com/sun/star/sdb/FilterDialog.hpp>
57 #include <com/sun/star/sdb/SQLContext.hpp>
58 #include <com/sun/star/sdbc/XConnection.hpp>
59 #include <com/sun/star/util/SearchOptions.hpp>
60 #include <com/sun/star/util/MeasureUnit.hpp>
61 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
62 #include <com/sun/star/container/XNameContainer.hpp>
63 #include <com/sun/star/inspection/XNumericControl.hpp>
64 #include <com/sun/star/style/ParagraphAdjust.hpp>
66 #include <vcl/msgbox.hxx>
67 #include <vcl/waitobj.hxx>
68 #include <tools/fldunit.hxx>
69 #include <vcl/stdtext.hxx>
71 #include "ModuleHelper.hxx"
72 #include "RptResId.hrc"
74 #include "UITools.hxx"
76 #include <connectivity/dbexception.hxx>
77 #include <connectivity/dbconversion.hxx>
78 #include <connectivity/dbtools.hxx>
80 #include <boost/bind.hpp>
81 #include "metadata.hxx"
82 #include <svl/itempool.hxx>
83 #include <svl/itemset.hxx>
84 #include <svx/xdef.hxx>
85 #include <svx/xpool.hxx>
86 #include <svx/xtable.hxx>
87 #include <svx/xlnwtit.hxx>
88 #include <svx/xlntrit.hxx>
89 #include <svx/xlnclit.hxx>
90 #include <svx/xlnstit.hxx>
91 #include <svx/xlnedit.hxx>
92 #include <svx/xlnstwit.hxx>
93 #include <svx/xlnedwit.hxx>
94 #include <svx/xlnstcit.hxx>
95 #include <svx/xlnedcit.hxx>
96 #include <svx/xlndsit.hxx>
97 #include <svx/xlineit0.hxx>
98 #include <svx/svxids.hrc>
99 #include <svx/drawitem.hxx>
100 #include <editeng/brushitem.hxx>
101 #include <sfx2/docfilt.hxx>
103 #include "dlgpage.hxx"
104 #include "helpids.hrc"
105 #include <toolkit/helper/convert.hxx>
107 #include <o3tl/compat_functional.hxx>
109 #define DATA_OR_FORMULA 0
112 #define USER_DEF_FUNCTION 3
119 using namespace ::com::sun::star
;
122 // comparing two property instances
123 struct PropertyCompare
: public ::std::binary_function
< beans::Property
, OUString
, bool >
125 bool operator() (const beans::Property
& x
, const OUString
& y
) const
127 return x
.Name
.equals(y
);
132 OUString
lcl_getQuotedFunctionName(const OUString
& _sFunction
)
134 return "[" + _sFunction
+ "]";
137 OUString
lcl_getQuotedFunctionName(const uno::Reference
< report::XFunction
>& _xFunction
)
139 return lcl_getQuotedFunctionName(_xFunction
->getName());
142 void lcl_collectFunctionNames(const uno::Reference
< report::XFunctions
>& _xFunctions
,TFunctions
& _rFunctionNames
)
144 uno::Reference
< report::XFunctionsSupplier
> xParent(_xFunctions
->getParent(),uno::UNO_QUERY_THROW
);
145 const sal_Int32 nCount
= _xFunctions
->getCount();
146 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
148 uno::Reference
< report::XFunction
> xFunction(_xFunctions
->getByIndex(i
),uno::UNO_QUERY_THROW
);
149 _rFunctionNames
.insert(TFunctions::value_type(lcl_getQuotedFunctionName(xFunction
),TFunctionPair(xFunction
,xParent
)));
153 void lcl_collectFunctionNames(const uno::Reference
< report::XSection
>& _xSection
,TFunctions
& _rFunctionNames
)
155 const uno::Reference
< report::XReportDefinition
> xReportDefinition
= _xSection
->getReportDefinition();
156 const uno::Reference
< report::XGroups
> xGroups
= xReportDefinition
->getGroups();
158 uno::Reference
< report::XGroup
> xGroup
= _xSection
->getGroup();
160 nPos
= getPositionInIndexAccess(xGroups
.get(),xGroup
);
161 else if ( _xSection
== xReportDefinition
->getDetail() )
162 nPos
= xGroups
->getCount()-1;
164 for (sal_Int32 i
= 0 ; i
<= nPos
; ++i
)
166 xGroup
.set(xGroups
->getByIndex(i
),uno::UNO_QUERY_THROW
);
167 lcl_collectFunctionNames(xGroup
->getFunctions(),_rFunctionNames
);
169 lcl_collectFunctionNames(xReportDefinition
->getFunctions(),_rFunctionNames
);
172 void lcl_convertFormulaTo(const uno::Any
& _aPropertyValue
,uno::Any
& _rControlValue
)
175 _aPropertyValue
>>= sName
;
176 const sal_Int32 nLen
= sName
.getLength();
179 ReportFormula
aFormula( sName
);
180 _rControlValue
<<= aFormula
.getUndecoratedContent();
184 // return value rounded to the nearest multiple of base
185 // if equidistant of two multiples, round up (for positive numbers)
186 // T is assumed to be an integer type
187 template <typename T
, T base
> T
lcl_round(T value
)
189 OSL_ENSURE(value
>= 0, "lcl_round: positive numbers only please");
190 const T threshold
= (base
% 2 == 0) ? (base
/2) : (base
/2 + 1);
191 const T rest
= value
% base
;
192 if ( rest
>= threshold
)
193 return value
+ (base
- rest
);
198 } // anonymous namespace
200 bool GeometryHandler::impl_isDataField(const OUString
& _sName
) const
202 const OUString
* pEnd
= m_aFieldNames
.getConstArray() + m_aFieldNames
.getLength();
203 bool bIsField
= ( ::std::find( m_aFieldNames
.getConstArray(), pEnd
, _sName
) != pEnd
);
207 pEnd
= m_aParamNames
.getConstArray() + m_aParamNames
.getLength();
208 bIsField
= ( ::std::find( m_aParamNames
.getConstArray(), pEnd
, _sName
) != pEnd
);
213 OUString
GeometryHandler::impl_convertToFormula( const uno::Any
& _rControlValue
)
216 _rControlValue
>>= sName
;
218 if ( sName
.isEmpty() )
221 ReportFormula
aParser( sName
);
222 if ( aParser
.isValid() )
225 aParser
= ReportFormula( impl_isDataField(sName
) ? ReportFormula::Field
: ReportFormula::Expression
, sName
);
226 return aParser
.getCompleteFormula();
229 GeometryHandler::GeometryHandler(uno::Reference
< uno::XComponentContext
> const & context
)
230 : GeometryHandler_Base(m_aMutex
)
231 , m_aPropertyListeners(m_aMutex
)
232 , m_xContext(context
)
233 , m_pInfoService(new OPropertyInfoService())
234 , m_nDataFieldType(0)
235 , m_bNewFunction(false)
240 m_xFormComponentHandler
= form::inspection::FormComponentPropertyHandler::create(m_xContext
);
241 m_xTypeConverter
= script::Converter::create(context
);
242 loadDefaultFunctions();
244 catch(const uno::Exception
&)
249 GeometryHandler::~GeometryHandler()
253 OUString SAL_CALL
GeometryHandler::getImplementationName( ) throw(uno::RuntimeException
, std::exception
)
255 return getImplementationName_Static();
258 sal_Bool SAL_CALL
GeometryHandler::supportsService( const OUString
& ServiceName
) throw(uno::RuntimeException
, std::exception
)
260 return cppu::supportsService(this, ServiceName
);
263 uno::Sequence
< OUString
> SAL_CALL
GeometryHandler::getSupportedServiceNames( ) throw(uno::RuntimeException
, std::exception
)
265 return getSupportedServiceNames_static();
268 OUString
GeometryHandler::getImplementationName_Static( ) throw(uno::RuntimeException
)
270 return OUString("com.sun.star.comp.report.GeometryHandler");
273 uno::Sequence
< OUString
> GeometryHandler::getSupportedServiceNames_static( ) throw(uno::RuntimeException
)
275 uno::Sequence
< OUString
> aSupported(1);
276 aSupported
[0] = "com.sun.star.report.inspection.GeometryHandler";
280 uno::Reference
< uno::XInterface
> SAL_CALL
GeometryHandler::create( const uno::Reference
< uno::XComponentContext
>& _rxContext
)
282 return *(new GeometryHandler( _rxContext
));
284 // override WeakComponentImplHelperBase::disposing()
285 // This function is called upon disposing the component,
286 // if your component needs special work when it becomes
287 // disposed, do it here.
288 void SAL_CALL
GeometryHandler::disposing()
292 ::comphelper::disposeComponent(m_xFormComponentHandler
);
293 ::comphelper::disposeComponent(m_xTypeConverter
);
294 if ( m_xReportComponent
.is() && m_xReportComponent
->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD
) )
295 m_xReportComponent
->removePropertyChangeListener(PROPERTY_DATAFIELD
,static_cast< beans::XPropertyChangeListener
* >( this ));
297 m_xReportComponent
.clear();
299 m_aPropertyListeners
.clear();
301 catch(uno::Exception
&)
304 void SAL_CALL
GeometryHandler::addEventListener(const uno::Reference
< lang::XEventListener
> & xListener
) throw (uno::RuntimeException
, std::exception
)
306 m_xFormComponentHandler
->addEventListener(xListener
);
309 void SAL_CALL
GeometryHandler::removeEventListener(const uno::Reference
< lang::XEventListener
> & aListener
) throw (uno::RuntimeException
, std::exception
)
311 m_xFormComponentHandler
->removeEventListener(aListener
);
314 // inspection::XPropertyHandler:
316 /********************************************************************************/
317 void SAL_CALL
GeometryHandler::inspect( const uno::Reference
< uno::XInterface
> & _rxInspectee
) throw (uno::RuntimeException
, lang::NullPointerException
, std::exception
)
319 ::osl::MutexGuard
aGuard( m_aMutex
);
321 m_sDefaultFunction
.clear();
322 m_bNewFunction
= false;
323 m_nDataFieldType
= 0;
325 m_aFunctionNames
.clear();
328 if ( m_xReportComponent
.is() && m_xReportComponent
->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD
) )
329 m_xReportComponent
->removePropertyChangeListener(PROPERTY_DATAFIELD
,static_cast< beans::XPropertyChangeListener
* >( this ));
331 const uno::Reference
< container::XNameContainer
> xObjectAsContainer( _rxInspectee
, uno::UNO_QUERY
);
332 m_xReportComponent
.set( xObjectAsContainer
->getByName("ReportComponent"), uno::UNO_QUERY
);
334 const OUString
sRowSet("RowSet");
335 if ( xObjectAsContainer
->hasByName( sRowSet
) )
337 const uno::Any
aRowSet( xObjectAsContainer
->getByName(sRowSet
) );
338 aRowSet
>>= m_xRowSet
;
339 // forward the rowset to our delegator handler
340 uno::Reference
< beans::XPropertySet
> xProp( m_xFormComponentHandler
,uno::UNO_QUERY
);
341 xProp
->setPropertyValue( sRowSet
, aRowSet
);
343 m_aParamNames
= getParameterNames( m_xRowSet
);
344 impl_initFieldList_nothrow(m_aFieldNames
);
345 if ( m_xReportComponent
->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD
) )
346 m_xReportComponent
->addPropertyChangeListener(PROPERTY_DATAFIELD
,static_cast< beans::XPropertyChangeListener
* >( this ));
349 const uno::Reference
< report::XReportComponent
> xReportComponent( m_xReportComponent
, uno::UNO_QUERY
);
350 uno::Reference
< report::XSection
> xSection( m_xReportComponent
, uno::UNO_QUERY
);
351 if ( !xSection
.is() && xReportComponent
.is() )
352 xSection
= xReportComponent
->getSection();
354 lcl_collectFunctionNames( xSection
, m_aFunctionNames
);
356 catch(const uno::Exception
&)
358 throw lang::NullPointerException();
360 m_xFormComponentHandler
->inspect(m_xReportComponent
);
363 uno::Any SAL_CALL
GeometryHandler::getPropertyValue(const OUString
& PropertyName
) throw (uno::RuntimeException
, beans::UnknownPropertyException
, std::exception
)
365 ::osl::MutexGuard
aGuard( m_aMutex
);
366 uno::Any aPropertyValue
;
367 const sal_Int32 nId
= OPropertyInfoService::getPropertyId(PropertyName
);
370 case PROPERTY_ID_CONDITIONALPRINTEXPRESSION
:
371 case PROPERTY_ID_INITIALFORMULA
:
372 case PROPERTY_ID_FORMULA
:
373 case PROPERTY_ID_DATAFIELD
:
374 aPropertyValue
= m_xReportComponent
->getPropertyValue( PropertyName
);
375 lcl_convertFormulaTo(aPropertyValue
,aPropertyValue
);
376 if ( PROPERTY_ID_DATAFIELD
== nId
)
379 aPropertyValue
>>= sDataField
;
380 switch(m_nDataFieldType
)
382 case DATA_OR_FORMULA
:
385 if ( isDefaultFunction(sDataField
,sDataField
) )
386 aPropertyValue
<<= sDataField
;
387 else if ( sDataField
.isEmpty() )
388 aPropertyValue
= uno::Any();
391 case USER_DEF_FUNCTION
:
392 aPropertyValue
= uno::Any();
398 case PROPERTY_ID_TYPE
:
400 const sal_uInt32 nOldDataFieldType
= m_nDataFieldType
;
401 m_nDataFieldType
= impl_getDataFieldType_throw();
402 if ( UNDEF_DATA
== m_nDataFieldType
)
403 m_nDataFieldType
= nOldDataFieldType
;
404 aPropertyValue
<<= m_nDataFieldType
;
407 case PROPERTY_ID_FORMULALIST
:
408 case PROPERTY_ID_SCOPE
:
410 uno::Any aDataField
= m_xReportComponent
->getPropertyValue( PROPERTY_DATAFIELD
);
411 lcl_convertFormulaTo(aDataField
,aDataField
);
413 aDataField
>>= sDataField
;
414 switch(m_nDataFieldType
)
416 case DATA_OR_FORMULA
:
419 if ( isDefaultFunction(sDataField
,sDataField
,uno::Reference
< report::XFunctionsSupplier
>(),true) )
420 aPropertyValue
<<= (PROPERTY_ID_FORMULALIST
== nId
? m_sDefaultFunction
: m_sScope
);
422 case USER_DEF_FUNCTION
:
423 if ( !sDataField
.isEmpty() && PROPERTY_ID_FORMULALIST
== nId
)
424 aPropertyValue
= aDataField
;
427 if ( PROPERTY_ID_SCOPE
== nId
&& impl_isCounterFunction_throw(sDataField
,m_sScope
) )
428 aPropertyValue
<<= m_sScope
;
434 case PROPERTY_ID_BACKCOLOR
:
435 case PROPERTY_ID_CONTROLBACKGROUND
:
437 aPropertyValue
= m_xReportComponent
->getPropertyValue( PropertyName
);
438 sal_Int32 nColor
= COL_TRANSPARENT
;
439 if ( (aPropertyValue
>>= nColor
) && static_cast<sal_Int32
>(COL_TRANSPARENT
) == nColor
)
440 aPropertyValue
.clear();
443 case PROPERTY_ID_MIMETYPE
:
446 m_xReportComponent
->getPropertyValue( PropertyName
) >>= sValue
;
447 aPropertyValue
<<= impl_ConvertMimeTypeToUI_nothrow(sValue
);
451 aPropertyValue
= m_xReportComponent
->getPropertyValue( PropertyName
);
454 return aPropertyValue
;
457 void SAL_CALL
GeometryHandler::setPropertyValue(const OUString
& PropertyName
, const uno::Any
& Value
) throw (uno::RuntimeException
, beans::UnknownPropertyException
, beans::PropertyVetoException
, std::exception
)
459 ::osl::ResettableMutexGuard
aGuard( m_aMutex
);
460 uno::Any aNewValue
= Value
;
461 const sal_Int32 nId
= OPropertyInfoService::getPropertyId(PropertyName
);
462 bool bHandled
= false;
465 case PROPERTY_ID_INITIALFORMULA
:
466 case PROPERTY_ID_FORMULA
:
468 case PROPERTY_ID_DATAFIELD
:
470 OBlocker
aBlocker(m_bIn
);
471 m_xReportComponent
->setPropertyValue(PropertyName
, aNewValue
);
473 const OUString sOldFunctionName
= m_sDefaultFunction
;
474 const OUString sOldScope
= m_sScope
;
476 uno::Any aPropertyValue
;
477 lcl_convertFormulaTo(Value
,aPropertyValue
);
479 aPropertyValue
>>= sDataField
;
482 m_sDefaultFunction
.clear();
484 const sal_uInt32 nOldDataFieldType
= m_nDataFieldType
;
485 if ( !sDataField
.isEmpty() )
487 if ( isDefaultFunction(sDataField
,sDataField
,uno::Reference
< report::XFunctionsSupplier
>(),true) )
488 m_nDataFieldType
= FUNCTION
;
489 else if ( m_aFunctionNames
.find(sDataField
) != m_aFunctionNames
.end() )
490 m_nDataFieldType
= USER_DEF_FUNCTION
;
493 resetOwnProperties(aGuard
,sOldFunctionName
,sOldScope
,nOldDataFieldType
);
496 case PROPERTY_ID_TYPE
:
499 Value
>>= m_nDataFieldType
;
501 const OUString sOldFunctionName
= m_sDefaultFunction
;
502 const OUString sOldScope
= m_sScope
;
503 m_sDefaultFunction
.clear();
506 if ( m_nDataFieldType
== COUNTER
)
508 impl_setCounterFunction_throw();
512 if ( m_bNewFunction
)
515 OBlocker
aBlocker(m_bIn
);
516 m_xReportComponent
->setPropertyValue(PROPERTY_DATAFIELD
,uno::makeAny(OUString()));
518 resetOwnProperties(aGuard
,sOldFunctionName
,sOldScope
,m_nDataFieldType
);
521 case PROPERTY_ID_FORMULALIST
:
525 if ( !(Value
>>= sFunction
) || sFunction
.isEmpty() )
527 if ( m_nDataFieldType
== FUNCTION
)
529 m_sDefaultFunction
.clear();
530 if ( m_bNewFunction
)
534 beans::PropertyChangeEvent aEvent
;
535 aEvent
.PropertyName
= PROPERTY_SCOPE
;
536 aEvent
.OldValue
<<= m_sScope
;
538 aEvent
.NewValue
<<= m_sScope
;
540 m_aPropertyListeners
.notify( aEvent
, &beans::XPropertyChangeListener::propertyChange
);
542 else if ( m_nDataFieldType
== USER_DEF_FUNCTION
)
544 OBlocker
aBlocker(m_bIn
);
545 m_xReportComponent
->setPropertyValue(PROPERTY_DATAFIELD
,uno::makeAny(OUString()));
548 else if ( m_nDataFieldType
== USER_DEF_FUNCTION
)
551 OBlocker
aBlocker(m_bIn
);
552 const sal_uInt32 nNewDataType
= impl_getDataFieldType_throw(sFunction
);
553 if ( nNewDataType
!= UNDEF_DATA
&& nNewDataType
!= m_nDataFieldType
)
555 const OUString sOldFunctionName
= m_sDefaultFunction
;
556 const OUString sOldScope
= m_sScope
;
558 m_sDefaultFunction
.clear();
560 if ( nNewDataType
== COUNTER
)
561 impl_isCounterFunction_throw(sFunction
,m_sScope
);
564 OUString sNamePostfix
;
565 const uno::Reference
< report::XFunctionsSupplier
> xFunctionsSupplier
= fillScope_throw(sNamePostfix
);
566 isDefaultFunction(sFunction
,sDataField
,xFunctionsSupplier
,true);
568 const sal_uInt32 nOldDataFieldType
= m_nDataFieldType
;
569 m_nDataFieldType
= nNewDataType
;
570 m_xReportComponent
->setPropertyValue(PROPERTY_DATAFIELD
,uno::makeAny(impl_convertToFormula( uno::makeAny(sFunction
))));
571 resetOwnProperties(aGuard
,sOldFunctionName
,sOldScope
,nOldDataFieldType
);
574 m_xReportComponent
->setPropertyValue(PROPERTY_DATAFIELD
,uno::makeAny(impl_convertToFormula( uno::makeAny(sFunction
))));
576 else if ( m_nDataFieldType
== FUNCTION
)
578 uno::Any aPropertyValue
= m_xReportComponent
->getPropertyValue(PROPERTY_DATAFIELD
);
579 lcl_convertFormulaTo(aPropertyValue
,aPropertyValue
);
581 aPropertyValue
>>= sDataField
;
582 if ( m_nDataFieldType
== FUNCTION
&& (!isDefaultFunction(sDataField
,sDataField
) || m_sDefaultFunction
!= sFunction
) )
584 if ( m_bNewFunction
)
586 // function currently does not exist
587 createDefaultFunction(aGuard
,sFunction
,sDataField
);
588 m_sDefaultFunction
= sFunction
;
594 case PROPERTY_ID_SCOPE
:
595 if ( !(Value
>>= m_sScope
) )
599 if ( m_bNewFunction
)
601 if ( m_nDataFieldType
== COUNTER
)
602 impl_setCounterFunction_throw();
605 OSL_ENSURE(m_xFunction
.is(),"Where is my function gone!");
607 OUString sNamePostfix
;
608 const uno::Reference
< report::XFunctionsSupplier
> xFunctionsSupplier
= fillScope_throw(sNamePostfix
);
610 OUString
sQuotedFunctionName(lcl_getQuotedFunctionName(m_xFunction
));
611 if ( isDefaultFunction(sQuotedFunctionName
,sQuotedFunctionName
,xFunctionsSupplier
,true) )
612 m_bNewFunction
= false;
615 OUString sDefaultFunctionName
;
617 OSL_VERIFY( impl_isDefaultFunction_nothrow(m_xFunction
,sDataField
,sDefaultFunctionName
) );
618 m_sDefaultFunction
= sDefaultFunctionName
;
619 createDefaultFunction(aGuard
,m_sDefaultFunction
,sDataField
);
625 case PROPERTY_ID_POSITIONX
:
626 case PROPERTY_ID_POSITIONY
:
627 case PROPERTY_ID_HEIGHT
:
628 case PROPERTY_ID_WIDTH
:
630 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY
);
631 if ( xSourceReportComponent
.is() ) // check only report components
633 sal_Int32 nNewValue
= 0;
635 OSL_ENSURE(nNewValue
>= 0, "A position/dimension should not be negative!");
636 nNewValue
= lcl_round
<sal_Int32
, 10>(nNewValue
);
637 awt::Point aAwtPoint
= xSourceReportComponent
->getPosition();
638 awt::Size aAwtSize
= xSourceReportComponent
->getSize();
639 if ( nId
== PROPERTY_ID_POSITIONX
)
640 aAwtPoint
.X
= nNewValue
;
641 else if ( nId
== PROPERTY_ID_POSITIONY
)
642 aAwtPoint
.Y
= nNewValue
;
643 else if ( nId
== PROPERTY_ID_HEIGHT
)
644 aAwtSize
.Height
= nNewValue
;
645 else if ( nId
== PROPERTY_ID_WIDTH
)
646 aAwtSize
.Width
= nNewValue
;
648 checkPosAndSize(aAwtPoint
,aAwtSize
);
652 case PROPERTY_ID_FONT
:
654 const uno::Reference
< report::XReportControlFormat
> xReportControlFormat( m_xReportComponent
,uno::UNO_QUERY_THROW
);
655 uno::Sequence
< beans::NamedValue
> aFontSettings
;
656 OSL_VERIFY( Value
>>= aFontSettings
);
657 applyCharacterSettings( xReportControlFormat
, aFontSettings
);
661 case PROPERTY_ID_MIMETYPE
:
665 aNewValue
<<= impl_ConvertUIToMimeType_nothrow(sValue
);
672 m_xReportComponent
->setPropertyValue(PropertyName
, aNewValue
);
676 beans::PropertyState SAL_CALL
GeometryHandler::getPropertyState(const OUString
& PropertyName
) throw (uno::RuntimeException
, beans::UnknownPropertyException
, std::exception
)
678 ::osl::MutexGuard
aGuard( m_aMutex
);
679 return m_xFormComponentHandler
->getPropertyState(PropertyName
);
682 void GeometryHandler::implCreateListLikeControl(
683 const uno::Reference
< inspection::XPropertyControlFactory
>& _rxControlFactory
684 ,inspection::LineDescriptor
& out_Descriptor
686 ,bool _bReadOnlyControl
687 ,bool _bTrueIfListBoxFalseIfComboBox
690 ::std::vector
< OUString
> aList
;
691 tools::StringListResource
aRes(ModuleRes(_nResId
),aList
);
693 implCreateListLikeControl(_rxControlFactory
,out_Descriptor
,aList
,_bReadOnlyControl
,_bTrueIfListBoxFalseIfComboBox
);
696 void GeometryHandler::implCreateListLikeControl(
697 const uno::Reference
< inspection::XPropertyControlFactory
>& _rxControlFactory
698 ,inspection::LineDescriptor
& out_Descriptor
699 ,const ::std::vector
< OUString
>& _aEntries
700 ,bool _bReadOnlyControl
701 ,bool _bTrueIfListBoxFalseIfComboBox
704 const uno::Reference
< inspection::XStringListControl
> xListControl(
705 _rxControlFactory
->createPropertyControl(
706 _bTrueIfListBoxFalseIfComboBox
? inspection::PropertyControlType::ListBox
: inspection::PropertyControlType::ComboBox
, _bReadOnlyControl
711 out_Descriptor
.Control
= xListControl
.get();
712 ::std::for_each( _aEntries
.begin(), _aEntries
.end(),::boost::bind( &inspection::XStringListControl::appendListEntry
, xListControl
,_1
));
716 inspection::LineDescriptor SAL_CALL
GeometryHandler::describePropertyLine(const OUString
& PropertyName
, const uno::Reference
< inspection::XPropertyControlFactory
> & _xControlFactory
) throw (beans::UnknownPropertyException
, lang::NullPointerException
,uno::RuntimeException
, std::exception
)
718 inspection::LineDescriptor aOut
;
719 const sal_Int32 nId
= OPropertyInfoService::getPropertyId(PropertyName
);
722 case PROPERTY_ID_FORCENEWPAGE
:
723 case PROPERTY_ID_NEWROWORCOL
:
724 implCreateListLikeControl(_xControlFactory
,aOut
,RID_STR_FORCENEWPAGE_CONST
,false,true);
726 case PROPERTY_ID_GROUPKEEPTOGETHER
:
727 implCreateListLikeControl(_xControlFactory
,aOut
,RID_STR_GROUPKEEPTOGETHER_CONST
,false,true);
729 case PROPERTY_ID_PAGEHEADEROPTION
:
730 case PROPERTY_ID_PAGEFOOTEROPTION
:
731 implCreateListLikeControl(_xControlFactory
,aOut
,RID_STR_REPORTPRINTOPTION_CONST
,false,true);
733 case PROPERTY_ID_FORMULALIST
:
735 ::std::vector
< OUString
> aList
;
736 impl_fillFormulaList_nothrow(aList
);
737 implCreateListLikeControl(_xControlFactory
,aOut
,aList
,false,true);
740 case PROPERTY_ID_SCOPE
:
742 ::std::vector
< OUString
> aList
;
743 impl_fillScopeList_nothrow(aList
);
744 implCreateListLikeControl(_xControlFactory
,aOut
,aList
,false,true);
747 case PROPERTY_ID_MIMETYPE
:
749 ::std::vector
< OUString
> aList
;
750 impl_fillMimeTypes_nothrow(aList
);
751 implCreateListLikeControl(_xControlFactory
,aOut
,aList
,false,true);
754 case PROPERTY_ID_TYPE
:
755 implCreateListLikeControl(_xControlFactory
,aOut
,RID_STR_TYPE_CONST
,false,true);
757 case PROPERTY_ID_VISIBLE
:
758 case PROPERTY_ID_CANGROW
:
759 case PROPERTY_ID_CANSHRINK
:
760 case PROPERTY_ID_REPEATSECTION
:
761 case PROPERTY_ID_PRINTREPEATEDVALUES
:
762 case PROPERTY_ID_STARTNEWCOLUMN
:
763 case PROPERTY_ID_RESETPAGENUMBER
:
764 case PROPERTY_ID_PRINTWHENGROUPCHANGE
:
765 case PROPERTY_ID_KEEPTOGETHER
:
766 case PROPERTY_ID_DEEPTRAVERSING
:
767 case PROPERTY_ID_PREEVALUATED
:
768 case PROPERTY_ID_PRESERVEIRI
:
769 case PROPERTY_ID_BACKTRANSPARENT
:
770 case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT
:
772 sal_uInt16 nResId
= RID_STR_BOOL
;
773 if ( PROPERTY_ID_KEEPTOGETHER
== nId
&& uno::Reference
< report::XGroup
>(m_xReportComponent
,uno::UNO_QUERY
).is())
774 nResId
= RID_STR_KEEPTOGETHER_CONST
;
775 implCreateListLikeControl(_xControlFactory
,aOut
,nResId
,false,true);
778 case PROPERTY_ID_INITIALFORMULA
:
779 case PROPERTY_ID_FORMULA
:
780 aOut
.PrimaryButtonId
= UID_RPT_PROP_FORMULA
;
781 aOut
.HasPrimaryButton
= sal_True
;
782 aOut
.Control
= _xControlFactory
->createPropertyControl(inspection::PropertyControlType::MultiLineTextField
, sal_False
);
784 case PROPERTY_ID_CONDITIONALPRINTEXPRESSION
:
785 aOut
.PrimaryButtonId
= UID_RPT_PROP_FORMULA
;
786 aOut
.HasPrimaryButton
= sal_True
;
787 aOut
.Control
= _xControlFactory
->createPropertyControl(inspection::PropertyControlType::MultiLineTextField
, sal_False
);
789 case PROPERTY_ID_DATAFIELD
:
791 uno::Reference
< inspection::XStringListControl
> xListControl(
792 _xControlFactory
->createPropertyControl(
793 m_nDataFieldType
== DATA_OR_FORMULA
? inspection::PropertyControlType::ComboBox
: inspection::PropertyControlType::ListBox
, sal_False
798 if ( m_nDataFieldType
== DATA_OR_FORMULA
)
800 aOut
.PrimaryButtonId
= UID_RPT_PROP_FORMULA
;
801 aOut
.HasPrimaryButton
= sal_True
;
804 aOut
.Control
= xListControl
.get();
805 if ( m_nDataFieldType
== USER_DEF_FUNCTION
)
807 // add function names
808 ::std::for_each( m_aFunctionNames
.begin(), m_aFunctionNames
.end(),
810 ::boost::bind( &inspection::XStringListControl::appendListEntry
, xListControl
,_1
),
811 ::o3tl::select1st
<TFunctions::value_type
>()));
815 ::std::for_each( m_aFieldNames
.getConstArray(), m_aFieldNames
.getConstArray() + m_aFieldNames
.getLength(),
816 ::boost::bind( &inspection::XStringListControl::appendListEntry
, xListControl
, _1
) );
817 ::std::for_each( m_aParamNames
.getConstArray(), m_aParamNames
.getConstArray() + m_aParamNames
.getLength(),
818 ::boost::bind( &inspection::XStringListControl::appendListEntry
, xListControl
, _1
) );
822 case PROPERTY_ID_BACKCOLOR
:
823 case PROPERTY_ID_CONTROLBACKGROUND
:
824 aOut
.Control
= _xControlFactory
->createPropertyControl( inspection::PropertyControlType::ColorListBox
, sal_False
);
826 case PROPERTY_ID_FONT
:
827 aOut
.PrimaryButtonId
= UID_RPT_RPT_PROP_DLG_FONT_TYPE
;
828 aOut
.Control
= _xControlFactory
->createPropertyControl( inspection::PropertyControlType::TextField
, sal_True
);
829 aOut
.HasPrimaryButton
= sal_True
;
831 case PROPERTY_ID_AREA
:
832 aOut
.PrimaryButtonId
= UID_RPT_RPT_PROP_DLG_AREA
;
833 aOut
.Control
= _xControlFactory
->createPropertyControl( inspection::PropertyControlType::TextField
, sal_True
);
834 aOut
.HasPrimaryButton
= sal_True
;
836 case PROPERTY_ID_VERTICALALIGN
:
837 implCreateListLikeControl(_xControlFactory
,aOut
,RID_STR_VERTICAL_ALIGN_CONST
,false,true);
839 case PROPERTY_ID_PARAADJUST
:
840 implCreateListLikeControl(_xControlFactory
,aOut
,RID_STR_PARAADJUST_CONST
,false,true);
844 aOut
= m_xFormComponentHandler
->describePropertyLine(PropertyName
, _xControlFactory
);
850 aOut
.Category
= ((OPropertyInfoService::getPropertyUIFlags(nId
) & PROP_FLAG_DATA_PROPERTY
) != 0) ?
854 aOut
.HelpURL
= HelpIdUrl::getHelpURL( OPropertyInfoService::getPropertyHelpId( nId
) );
855 aOut
.DisplayName
= OPropertyInfoService::getPropertyTranslation(nId
);
858 if ( ( nId
== PROPERTY_ID_POSITIONX
)
859 || ( nId
== PROPERTY_ID_POSITIONY
)
860 || ( nId
== PROPERTY_ID_WIDTH
)
861 || ( nId
== PROPERTY_ID_HEIGHT
)
864 const MeasurementSystem eSystem
= SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
865 const sal_Int16 nDisplayUnit
= VCLUnoHelper::ConvertToMeasurementUnit( MEASURE_METRIC
== eSystem
? FUNIT_CM
: FUNIT_INCH
, 1 );
866 uno::Reference
< inspection::XNumericControl
> xNumericControl(aOut
.Control
,uno::UNO_QUERY
);
867 xNumericControl
->setDecimalDigits( 2 );
868 xNumericControl
->setValueUnit( util::MeasureUnit::MM_100TH
);
869 uno::Reference
< drawing::XShapeDescriptor
> xShapeDesc(m_xReportComponent
,uno::UNO_QUERY
);
870 bool bSetMin
= !xShapeDesc
.is() || xShapeDesc
->getShapeType() != "com.sun.star.drawing.CustomShape";
872 xNumericControl
->setMinValue(beans::Optional
<double>(sal_True
,0.0));
873 if ( nDisplayUnit
!= -1 )
874 xNumericControl
->setDisplayUnit( nDisplayUnit
);
875 uno::Reference
< report::XReportComponent
> xComp(m_xReportComponent
,uno::UNO_QUERY
);
876 if ( xComp
.is() && xComp
->getSection().is() )
878 uno::Reference
< report::XReportDefinition
> xReport
= xComp
->getSection()->getReportDefinition();
879 OSL_ENSURE(xReport
.is(),"Why is the report definition NULL!");
882 const awt::Size aSize
= getStyleProperty
<awt::Size
>(xReport
,PROPERTY_PAPERSIZE
);
883 const sal_Int32 nLeftMargin
= getStyleProperty
<sal_Int32
>(xReport
,PROPERTY_LEFTMARGIN
);
884 const sal_Int32 nRightMargin
= getStyleProperty
<sal_Int32
>(xReport
,PROPERTY_RIGHTMARGIN
);
887 case PROPERTY_ID_POSITIONX
:
888 case PROPERTY_ID_WIDTH
:
890 xNumericControl
->setMinValue(beans::Optional
<double>(sal_True
,0.0));
891 xNumericControl
->setMaxValue(beans::Optional
<double>(sal_True
,double(aSize
.Width
- nLeftMargin
- nRightMargin
)));
892 if ( PROPERTY_ID_WIDTH
== nId
)
894 uno::Reference
<report::XFixedLine
> xFixedLine(m_xReportComponent
,uno::UNO_QUERY
);
895 if ( xFixedLine
.is() && xFixedLine
->getOrientation() == 1 ) // vertical
896 xNumericControl
->setMinValue(beans::Optional
<double>(sal_True
,0.08 ));
904 else if ( PROPERTY_ID_HEIGHT
== nId
)
906 const uno::Reference
< report::XSection
> xSection(m_xReportComponent
,uno::UNO_QUERY
);
909 sal_Int32 nHeight
= 0;
910 const sal_Int32 nCount
= xSection
->getCount();
911 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
913 uno::Reference
<drawing::XShape
> xShape(xSection
->getByIndex(i
),uno::UNO_QUERY
);
914 nHeight
= ::std::max
<sal_Int32
>(nHeight
,xShape
->getPosition().Y
+ xShape
->getSize().Height
);
916 xNumericControl
->setMinValue(beans::Optional
<double>(sal_True
,nHeight
));
923 beans::Property
GeometryHandler::getProperty(const OUString
& PropertyName
)
925 uno::Sequence
< beans::Property
> aProps
= getSupportedProperties();
926 const beans::Property
* pIter
= aProps
.getConstArray();
927 const beans::Property
* pEnd
= pIter
+ aProps
.getLength();
928 const beans::Property
* pFind
= ::std::find_if(pIter
,pEnd
,::std::bind2nd(PropertyCompare(),boost::cref(PropertyName
)));
930 return beans::Property();
933 uno::Any
GeometryHandler::getConstantValue(bool _bToControlValue
,sal_uInt16 _nResId
,const uno::Any
& _aValue
,const OUString
& _sConstantName
,const OUString
& PropertyName
)
935 ::std::vector
< OUString
> aList
;
936 tools::StringListResource
aRes(ModuleRes(_nResId
),aList
);
937 uno::Sequence
< OUString
> aSeq(aList
.size());
938 ::std::copy( aList
.begin(), aList
.end(), aSeq
.getArray() );
940 uno::Reference
< inspection::XStringRepresentation
> xConversionHelper
= inspection::StringRepresentation::createConstant( m_xContext
,m_xTypeConverter
,_sConstantName
,aSeq
);
941 if ( _bToControlValue
)
943 return uno::makeAny( xConversionHelper
->convertToControlValue( _aValue
) );
947 OUString sControlValue
;
948 _aValue
>>= sControlValue
;
949 const beans::Property aProp
= getProperty(PropertyName
);
950 return xConversionHelper
->convertToPropertyValue( sControlValue
, aProp
.Type
);
954 uno::Any SAL_CALL
GeometryHandler::convertToPropertyValue(const OUString
& PropertyName
, const uno::Any
& _rControlValue
) throw (uno::RuntimeException
, beans::UnknownPropertyException
, std::exception
)
956 ::osl::MutexGuard
aGuard( m_aMutex
);
957 uno::Any
aPropertyValue( _rControlValue
);
958 const sal_Int32 nId
= OPropertyInfoService::getPropertyId(PropertyName
);
961 case PROPERTY_ID_FORCENEWPAGE
:
962 case PROPERTY_ID_NEWROWORCOL
:
963 aPropertyValue
= getConstantValue(false,RID_STR_FORCENEWPAGE_CONST
,_rControlValue
,OUString("com.sun.star.report.ForceNewPage"),PropertyName
);
965 case PROPERTY_ID_GROUPKEEPTOGETHER
:
966 aPropertyValue
= getConstantValue(false,RID_STR_GROUPKEEPTOGETHER_CONST
,_rControlValue
,OUString("com.sun.star.report.GroupKeepTogether"),PropertyName
);
968 case PROPERTY_ID_PAGEHEADEROPTION
:
969 case PROPERTY_ID_PAGEFOOTEROPTION
:
970 aPropertyValue
= getConstantValue(false,RID_STR_REPORTPRINTOPTION_CONST
,_rControlValue
,OUString("com.sun.star.report.ReportPrintOption"),PropertyName
);
972 case PROPERTY_ID_BACKCOLOR
:
973 case PROPERTY_ID_CONTROLBACKGROUND
:
974 if ( !_rControlValue
.hasValue() )
976 aPropertyValue
<<= static_cast<sal_Int32
>(COL_TRANSPARENT
);
981 case PROPERTY_ID_KEEPTOGETHER
:
982 if ( uno::Reference
< report::XGroup
>(m_xReportComponent
,uno::UNO_QUERY
).is())
984 aPropertyValue
= getConstantValue(false,RID_STR_KEEPTOGETHER_CONST
,_rControlValue
,OUString("com.sun.star.report.KeepTogether"),PropertyName
);
989 case PROPERTY_ID_VISIBLE
:
990 case PROPERTY_ID_CANGROW
:
991 case PROPERTY_ID_CANSHRINK
:
992 case PROPERTY_ID_REPEATSECTION
:
993 case PROPERTY_ID_PRINTREPEATEDVALUES
:
994 case PROPERTY_ID_STARTNEWCOLUMN
:
995 case PROPERTY_ID_RESETPAGENUMBER
:
996 case PROPERTY_ID_PRINTWHENGROUPCHANGE
:
997 case PROPERTY_ID_DEEPTRAVERSING
:
998 case PROPERTY_ID_PREEVALUATED
:
999 case PROPERTY_ID_PRESERVEIRI
:
1000 case PROPERTY_ID_BACKTRANSPARENT
:
1001 case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT
:
1003 if ( aPropertyValue
.hasValue() )
1005 const beans::Property aProp
= getProperty(PropertyName
);
1006 if ( aPropertyValue
.getValueType().equals( aProp
.Type
) )
1007 // nothing to do, type is already as desired
1008 return aPropertyValue
;
1010 if ( _rControlValue
.getValueType().getTypeClass() == uno::TypeClass_STRING
)
1012 OUString sControlValue
;
1013 _rControlValue
>>= sControlValue
;
1015 const uno::Reference
< inspection::XStringRepresentation
> xConversionHelper
= inspection::StringRepresentation::create( m_xContext
,m_xTypeConverter
);
1016 aPropertyValue
= xConversionHelper
->convertToPropertyValue( sControlValue
, aProp
.Type
);
1022 aPropertyValue
= m_xTypeConverter
->convertTo( _rControlValue
, aProp
.Type
);
1024 catch( const uno::Exception
& )
1026 OSL_FAIL( "GeometryHandler::convertToPropertyValue: caught an exception while converting via TypeConverter!" );
1033 case PROPERTY_ID_CONDITIONALPRINTEXPRESSION
:
1034 case PROPERTY_ID_INITIALFORMULA
:
1035 case PROPERTY_ID_FORMULA
:
1036 return uno::makeAny( impl_convertToFormula( _rControlValue
) );
1037 case PROPERTY_ID_DATAFIELD
:
1039 OUString sDataField
;
1040 _rControlValue
>>= sDataField
;
1041 if ( isDefaultFunction(sDataField
,sDataField
) )
1043 OSL_ENSURE(m_xFunction
.is(),"No function set!");
1044 aPropertyValue
<<= impl_convertToFormula( uno::makeAny(lcl_getQuotedFunctionName(m_xFunction
)) );
1047 aPropertyValue
<<= impl_convertToFormula( _rControlValue
);
1050 case PROPERTY_ID_POSITIONX
:
1052 aPropertyValue
= m_xFormComponentHandler
->convertToPropertyValue(PropertyName
, _rControlValue
);
1053 sal_Int32 nPosX
= 0;
1054 aPropertyValue
>>= nPosX
;
1055 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY
);
1056 if ( xSourceReportComponent
->getSection().is() )
1057 nPosX
+= getStyleProperty
<sal_Int32
>(xSourceReportComponent
->getSection()->getReportDefinition(),PROPERTY_LEFTMARGIN
);
1058 aPropertyValue
<<= nPosX
;
1061 case PROPERTY_ID_FONT
:
1062 aPropertyValue
= m_xFormComponentHandler
->convertToPropertyValue(PROPERTY_FONT
, _rControlValue
);
1064 case PROPERTY_ID_SCOPE
:
1065 case PROPERTY_ID_FORMULALIST
:
1066 case PROPERTY_ID_AREA
:
1067 aPropertyValue
= _rControlValue
;
1069 case PROPERTY_ID_TYPE
:
1072 _rControlValue
>>= sValue
;
1073 ::std::vector
< OUString
> aList
;
1074 tools::StringListResource
aRes(ModuleRes(RID_STR_TYPE_CONST
),aList
);
1075 ::std::vector
< OUString
>::iterator aFind
= ::std::find(aList
.begin(),aList
.end(),sValue
);
1076 if ( aFind
!= aList
.end() )
1077 aPropertyValue
<<= static_cast<sal_uInt32
>(aFind
- aList
.begin());
1080 case PROPERTY_ID_MIMETYPE
:
1081 aPropertyValue
= _rControlValue
;
1083 case PROPERTY_ID_VERTICALALIGN
:
1086 _rControlValue
>>= sValue
;
1087 ::std::vector
< OUString
> aList
;
1088 tools::StringListResource
aRes(ModuleRes(RID_STR_VERTICAL_ALIGN_CONST
),aList
);
1089 ::std::vector
< OUString
>::iterator aFind
= ::std::find(aList
.begin(),aList
.end(),sValue
);
1090 if ( aFind
!= aList
.end() )
1091 aPropertyValue
<<= static_cast<style::VerticalAlignment
>(aFind
- aList
.begin());
1094 case PROPERTY_ID_PARAADJUST
:
1097 _rControlValue
>>= sValue
;
1098 ::std::vector
< OUString
> aList
;
1099 tools::StringListResource
aRes(ModuleRes(RID_STR_PARAADJUST_CONST
),aList
);
1100 ::std::vector
< OUString
>::iterator aFind
= ::std::find(aList
.begin(),aList
.end(),sValue
);
1101 if ( aFind
!= aList
.end() )
1102 aPropertyValue
<<= static_cast<sal_Int16
>(aFind
- aList
.begin());
1106 return m_xFormComponentHandler
->convertToPropertyValue(PropertyName
, _rControlValue
);
1108 return aPropertyValue
;
1111 uno::Any SAL_CALL
GeometryHandler::convertToControlValue(const OUString
& PropertyName
, const uno::Any
& _rPropertyValue
, const uno::Type
& _rControlValueType
) throw (uno::RuntimeException
, beans::UnknownPropertyException
, std::exception
)
1113 uno::Any
aControlValue( _rPropertyValue
);
1114 if ( !aControlValue
.hasValue() )
1115 // NULL is converted to NULL
1116 return aControlValue
;
1118 uno::Any
aPropertyValue(_rPropertyValue
);
1120 ::osl::MutexGuard
aGuard( m_aMutex
);
1121 const sal_Int32 nId
= OPropertyInfoService::getPropertyId(PropertyName
);
1124 case PROPERTY_ID_AREA
:
1126 case PROPERTY_ID_FORCENEWPAGE
:
1127 case PROPERTY_ID_NEWROWORCOL
:
1128 aControlValue
= getConstantValue(true,RID_STR_FORCENEWPAGE_CONST
,aPropertyValue
,OUString("com.sun.star.report.ForceNewPage"),PropertyName
);
1130 case PROPERTY_ID_GROUPKEEPTOGETHER
:
1131 aControlValue
= getConstantValue(true,RID_STR_GROUPKEEPTOGETHER_CONST
,aPropertyValue
,OUString("com.sun.star.report.GroupKeepTogether"),PropertyName
);
1133 case PROPERTY_ID_PAGEHEADEROPTION
:
1134 case PROPERTY_ID_PAGEFOOTEROPTION
:
1135 aControlValue
= getConstantValue(true,RID_STR_REPORTPRINTOPTION_CONST
,aPropertyValue
,OUString("com.sun.star.report.ReportPrintOption"),PropertyName
);
1137 case PROPERTY_ID_KEEPTOGETHER
:
1138 if ( uno::Reference
< report::XGroup
>(m_xReportComponent
,uno::UNO_QUERY
).is())
1140 aControlValue
= getConstantValue(true,RID_STR_KEEPTOGETHER_CONST
,aPropertyValue
,OUString("com.sun.star.report.KeepTogether"),PropertyName
);
1144 case PROPERTY_ID_VISIBLE
:
1145 case PROPERTY_ID_CANGROW
:
1146 case PROPERTY_ID_CANSHRINK
:
1147 case PROPERTY_ID_REPEATSECTION
:
1148 case PROPERTY_ID_PRINTREPEATEDVALUES
:
1149 case PROPERTY_ID_STARTNEWCOLUMN
:
1150 case PROPERTY_ID_RESETPAGENUMBER
:
1151 case PROPERTY_ID_PRINTWHENGROUPCHANGE
:
1152 case PROPERTY_ID_DEEPTRAVERSING
:
1153 case PROPERTY_ID_PREEVALUATED
:
1154 case PROPERTY_ID_PRESERVEIRI
:
1155 case PROPERTY_ID_BACKTRANSPARENT
:
1156 case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT
:
1158 if ( _rControlValueType
.getTypeClass() == uno::TypeClass_STRING
)
1160 const uno::Reference
< inspection::XStringRepresentation
> xConversionHelper
= inspection::StringRepresentation::create( m_xContext
,m_xTypeConverter
);
1161 aControlValue
<<= xConversionHelper
->convertToControlValue( aPropertyValue
);
1167 aControlValue
= m_xTypeConverter
->convertTo( aPropertyValue
, _rControlValueType
);
1169 catch( const uno::Exception
& )
1171 OSL_FAIL( "GeometryHandler::convertToControlValue: caught an exception while converting via TypeConverter!" );
1176 case PROPERTY_ID_CONDITIONALPRINTEXPRESSION
:
1177 case PROPERTY_ID_INITIALFORMULA
:
1178 case PROPERTY_ID_FORMULA
:
1179 lcl_convertFormulaTo(aPropertyValue
,aControlValue
);
1181 case PROPERTY_ID_DATAFIELD
:
1184 aControlValue
>>= sValue
;
1185 if ( isDefaultFunction(sValue
,sValue
) )
1186 aControlValue
<<= sValue
;
1188 lcl_convertFormulaTo(aPropertyValue
,aControlValue
);
1191 case PROPERTY_ID_FONT
:
1192 aControlValue
= m_xFormComponentHandler
->convertToControlValue(PROPERTY_FONT
, aPropertyValue
, _rControlValueType
);
1194 case PROPERTY_ID_POSITIONX
:
1196 sal_Int32 nPosX
= 0;
1197 aPropertyValue
>>= nPosX
;
1198 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY
);
1199 if ( xSourceReportComponent
->getSection().is() )
1200 nPosX
-= getStyleProperty
<sal_Int32
>(xSourceReportComponent
->getSection()->getReportDefinition(),PROPERTY_LEFTMARGIN
);
1201 aPropertyValue
<<= nPosX
;
1202 aControlValue
= m_xFormComponentHandler
->convertToControlValue(PropertyName
, aPropertyValue
, _rControlValueType
);
1205 case PROPERTY_ID_FORMULALIST
:
1206 aControlValue
<<= m_sDefaultFunction
;
1208 case PROPERTY_ID_SCOPE
:
1209 aControlValue
<<= m_sScope
;
1211 case PROPERTY_ID_MIMETYPE
:
1212 aControlValue
= aPropertyValue
;
1214 case PROPERTY_ID_TYPE
:
1216 ::std::vector
< OUString
> aList
;
1217 tools::StringListResource
aRes(ModuleRes(RID_STR_TYPE_CONST
),aList
);
1218 if ( m_nDataFieldType
< aList
.size() )
1219 aControlValue
<<= aList
[m_nDataFieldType
];
1222 case PROPERTY_ID_VERTICALALIGN
:
1224 style::VerticalAlignment nParagraphVertAlign
= style::VerticalAlignment_TOP
;
1225 aPropertyValue
>>= nParagraphVertAlign
;
1226 ::std::vector
< OUString
> aList
;
1227 tools::StringListResource
aRes(ModuleRes(RID_STR_VERTICAL_ALIGN_CONST
),aList
);
1228 if ( static_cast<sal_Int16
>(nParagraphVertAlign
) < static_cast<sal_Int16
>(aList
.size()) )
1229 aControlValue
<<= aList
[nParagraphVertAlign
];
1232 case PROPERTY_ID_PARAADJUST
:
1234 sal_Int16 nParagraphAdjust
= style::ParagraphAdjust_LEFT
;
1235 aPropertyValue
>>= nParagraphAdjust
;
1236 ::std::vector
< OUString
> aList
;
1237 tools::StringListResource
aRes(ModuleRes(RID_STR_PARAADJUST_CONST
),aList
);
1238 if ( nParagraphAdjust
< static_cast<sal_Int16
>(aList
.size()) )
1239 aControlValue
<<= aList
[nParagraphAdjust
];
1242 case PROPERTY_ID_BACKCOLOR
:
1243 case PROPERTY_ID_CONTROLBACKGROUND
:
1245 sal_Int32 nColor
= COL_TRANSPARENT
;
1246 if ( (aPropertyValue
>>= nColor
) && static_cast<sal_Int32
>(COL_TRANSPARENT
) == nColor
)
1247 aPropertyValue
.clear();
1251 aControlValue
= m_xFormComponentHandler
->convertToControlValue(PropertyName
, aPropertyValue
, _rControlValueType
);
1253 return aControlValue
;
1255 void SAL_CALL
GeometryHandler::addPropertyChangeListener(const uno::Reference
< beans::XPropertyChangeListener
> & _rxListener
) throw (uno::RuntimeException
, lang::NullPointerException
, std::exception
)
1257 ::osl::MutexGuard
aGuard( m_aMutex
);
1258 m_aPropertyListeners
.addListener( _rxListener
);
1259 m_xFormComponentHandler
->addPropertyChangeListener(_rxListener
);
1262 void SAL_CALL
GeometryHandler::removePropertyChangeListener(const uno::Reference
< beans::XPropertyChangeListener
> & _rxListener
) throw (uno::RuntimeException
, std::exception
)
1264 ::osl::MutexGuard
aGuard( m_aMutex
);
1265 m_aPropertyListeners
.removeListener( _rxListener
);
1266 m_xFormComponentHandler
->removePropertyChangeListener(_rxListener
);
1270 uno::Sequence
< beans::Property
> SAL_CALL
GeometryHandler::getSupportedProperties() throw (uno::RuntimeException
, std::exception
)
1272 ::std::vector
< beans::Property
> aNewProps
;
1273 aNewProps
.reserve(20); // only a guess
1274 rptui::OPropertyInfoService::getExcludeProperties( aNewProps
, m_xFormComponentHandler
);
1276 const OUString pIncludeProperties
[] =
1278 OUString(PROPERTY_FORCENEWPAGE
)
1279 ,OUString(PROPERTY_KEEPTOGETHER
)
1280 ,OUString(PROPERTY_CANGROW
)
1281 ,OUString(PROPERTY_CANSHRINK
)
1282 ,OUString(PROPERTY_REPEATSECTION
)
1283 ,OUString(PROPERTY_PRINTREPEATEDVALUES
)
1284 ,OUString(PROPERTY_CONDITIONALPRINTEXPRESSION
)
1285 ,OUString(PROPERTY_STARTNEWCOLUMN
)
1286 ,OUString(PROPERTY_RESETPAGENUMBER
)
1287 ,OUString(PROPERTY_PRINTWHENGROUPCHANGE
)
1288 ,OUString(PROPERTY_VISIBLE
)
1289 ,OUString(PROPERTY_PAGEHEADEROPTION
)
1290 ,OUString(PROPERTY_PAGEFOOTEROPTION
)
1291 ,OUString("ControlLabel")
1292 ,OUString(PROPERTY_POSITIONX
)
1293 ,OUString(PROPERTY_POSITIONY
)
1294 ,OUString(PROPERTY_WIDTH
)
1295 ,OUString(PROPERTY_HEIGHT
)
1296 ,OUString(PROPERTY_PREEVALUATED
)
1297 ,OUString(PROPERTY_DEEPTRAVERSING
)
1298 ,OUString(PROPERTY_FORMULA
)
1299 ,OUString(PROPERTY_INITIALFORMULA
)
1300 ,OUString(PROPERTY_PRESERVEIRI
)
1301 ,OUString(PROPERTY_DATAFIELD
)
1302 ,OUString(PROPERTY_FONT
)
1303 ,OUString(PROPERTY_BACKCOLOR
)
1304 ,OUString(PROPERTY_BACKTRANSPARENT
)
1305 ,OUString(PROPERTY_CONTROLBACKGROUND
)
1306 ,OUString(PROPERTY_CONTROLBACKGROUNDTRANSPARENT
)
1307 ,OUString(PROPERTY_LABEL
)
1308 ,OUString(PROPERTY_MIMETYPE
)
1309 ,OUString(PROPERTY_VERTICALALIGN
)
1310 ,OUString(PROPERTY_PARAADJUST
)
1312 const uno::Reference
< beans::XPropertySetInfo
> xInfo
= m_xReportComponent
->getPropertySetInfo();
1313 const uno::Sequence
< beans::Property
> aSeq
= xInfo
->getProperties();
1314 for (size_t i
= 0; i
< sizeof(pIncludeProperties
)/sizeof(pIncludeProperties
[0]) ;++i
)
1316 const beans::Property
* pIter
= aSeq
.getConstArray();
1317 const beans::Property
* pEnd
= pIter
+ aSeq
.getLength();
1318 const beans::Property
* pFind
= ::std::find_if(pIter
,pEnd
,::std::bind2nd(PropertyCompare(),boost::cref(pIncludeProperties
[i
])));
1319 if ( pFind
!= pEnd
)
1321 // special case for controls which contain a data field
1322 if ( PROPERTY_DATAFIELD
== pIncludeProperties
[i
] )
1324 beans::Property aValue
;
1325 aValue
.Name
= PROPERTY_FORMULALIST
;
1326 aNewProps
.push_back(aValue
);
1327 aValue
.Name
= PROPERTY_SCOPE
;
1328 aNewProps
.push_back(aValue
);
1329 aValue
.Name
= PROPERTY_TYPE
;
1330 aNewProps
.push_back(aValue
);
1332 aNewProps
.push_back(*pFind
);
1336 // special property for shapes
1337 // if ( uno::Reference< report::XShape>(m_xReportComponent,uno::UNO_QUERY).is() )
1339 // beans::Property aValue;
1340 // aValue.Name = PROPERTY_AREA;
1341 // aNewProps.push_back(aValue);
1343 // re-enable when the remaining issues of #i88727# are fixed
1345 return uno::Sequence
< beans::Property
> (&(*aNewProps
.begin()),aNewProps
.size());
1348 uno::Sequence
< OUString
> SAL_CALL
GeometryHandler::getSupersededProperties() throw (uno::RuntimeException
, std::exception
)
1350 uno::Sequence
< OUString
> aRet
;
1351 const uno::Reference
<report::XReportDefinition
> xReport(m_xReportComponent
,uno::UNO_QUERY
);
1352 if ( xReport
.is() && !uno::Reference
< report::XSection
>(xReport
->getParent(),uno::UNO_QUERY
).is() )
1355 OUString
* pIter
= aRet
.getArray();
1356 *pIter
++ = PROPERTY_POSITIONX
;
1357 *pIter
++ = PROPERTY_POSITIONY
;
1358 *pIter
++ = PROPERTY_WIDTH
;
1359 *pIter
++ = PROPERTY_HEIGHT
;
1360 *pIter
++ = PROPERTY_DATAFIELD
;
1365 uno::Sequence
< OUString
> SAL_CALL
GeometryHandler::getActuatingProperties() throw (uno::RuntimeException
, std::exception
)
1367 ::osl::MutexGuard
aGuard( m_aMutex
);
1369 uno::Sequence
< OUString
> aSeq(5);
1370 aSeq
[0] = PROPERTY_BACKTRANSPARENT
;
1371 aSeq
[1] = PROPERTY_CONTROLBACKGROUNDTRANSPARENT
;
1372 aSeq
[2] = PROPERTY_FORMULALIST
;
1373 aSeq
[3] = PROPERTY_TYPE
;
1374 aSeq
[4] = PROPERTY_DATAFIELD
;
1376 return ::comphelper::concatSequences(m_xFormComponentHandler
->getActuatingProperties(),aSeq
);
1379 sal_Bool SAL_CALL
GeometryHandler::isComposable(const OUString
& _rPropertyName
) throw (uno::RuntimeException
, beans::UnknownPropertyException
, std::exception
)
1381 return OPropertyInfoService::isComposable( _rPropertyName
, m_xFormComponentHandler
);
1384 inspection::InteractiveSelectionResult SAL_CALL
GeometryHandler::onInteractivePropertySelection(const OUString
& PropertyName
, sal_Bool Primary
, uno::Any
& _rData
, const uno::Reference
< inspection::XObjectInspectorUI
> & _rxInspectorUI
) throw (uno::RuntimeException
, beans::UnknownPropertyException
, lang::NullPointerException
, std::exception
)
1386 if ( !_rxInspectorUI
.is() )
1387 throw lang::NullPointerException();
1388 if (PropertyName
== PROPERTY_FILTER
)
1390 ::osl::ClearableMutexGuard
aGuard( m_aMutex
);
1392 inspection::InteractiveSelectionResult eResult
= inspection::InteractiveSelectionResult_Cancelled
;
1394 if ( impl_dialogFilter_nothrow( sClause
, aGuard
) )
1397 eResult
= inspection::InteractiveSelectionResult_ObtainedValue
;
1401 else if (PropertyName
== PROPERTY_FONT
)
1403 ::osl::ClearableMutexGuard
aGuard( m_aMutex
);
1405 inspection::InteractiveSelectionResult eResult
= inspection::InteractiveSelectionResult_Cancelled
;
1406 const uno::Reference
< awt::XWindow
> xInspectorWindow(m_xContext
->getValueByName("DialogParentWindow") ,uno::UNO_QUERY
);
1407 const uno::Reference
< report::XReportControlFormat
> xReportControlFormat(m_xReportComponent
,uno::UNO_QUERY
);
1410 uno::Sequence
< beans::NamedValue
> aFontSettings
;
1411 if ( rptui::openCharDialog( xReportControlFormat
, xInspectorWindow
, aFontSettings
) )
1413 _rData
<<= aFontSettings
;
1414 eResult
= inspection::InteractiveSelectionResult_ObtainedValue
;
1418 else if ( PropertyName
== PROPERTY_FORMULA
1419 || PropertyName
== PROPERTY_INITIALFORMULA
1420 || PropertyName
== PROPERTY_DATAFIELD
1421 || PropertyName
== PROPERTY_CONDITIONALPRINTEXPRESSION
)
1423 ::osl::ClearableMutexGuard
aGuard( m_aMutex
);
1427 m_xReportComponent
->getPropertyValue(PropertyName
) >>= sFormula
;
1428 const uno::Reference
< awt::XWindow
> xInspectorWindow(m_xContext
->getValueByName("DialogParentWindow") ,uno::UNO_QUERY
);
1429 uno::Reference
< uno::XComponentContext
> xContext
= m_xContext
;
1430 uno::Reference
< beans::XPropertySet
> xRowSet( m_xRowSet
,uno::UNO_QUERY
);
1433 inspection::InteractiveSelectionResult eResult
= inspection::InteractiveSelectionResult_Cancelled
;
1434 if ( rptui::openDialogFormula_nothrow( sFormula
, xContext
,xInspectorWindow
,xRowSet
) )
1436 _rData
<<= sFormula
;
1437 eResult
= inspection::InteractiveSelectionResult_ObtainedValue
;
1441 else if (PropertyName
== PROPERTY_AREA
)
1443 ::osl::ClearableMutexGuard
aGuard( m_aMutex
);
1445 inspection::InteractiveSelectionResult eResult
= inspection::InteractiveSelectionResult_Cancelled
;
1446 const uno::Reference
< awt::XWindow
> xInspectorWindow(m_xContext
->getValueByName("DialogParentWindow") ,uno::UNO_QUERY
);
1447 const uno::Reference
< report::XShape
> xShape(m_xReportComponent
,uno::UNO_QUERY
);
1450 if ( rptui::openAreaDialog( xShape
, xInspectorWindow
) )
1452 eResult
= inspection::InteractiveSelectionResult_ObtainedValue
;
1453 beans::PropertyChangeEvent aScopeEvent
;
1454 aScopeEvent
.PropertyName
= PROPERTY_FILLCOLOR
;
1455 aScopeEvent
.NewValue
<<= xShape
->getPropertyValue(PROPERTY_FILLCOLOR
);
1456 m_aPropertyListeners
.notify( aScopeEvent
, &beans::XPropertyChangeListener::propertyChange
);
1462 return m_xFormComponentHandler
->onInteractivePropertySelection(PropertyName
, Primary
, _rData
, _rxInspectorUI
);
1465 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
) throw (uno::RuntimeException
, lang::NullPointerException
, std::exception
)
1467 if ( !_rxInspectorUI
.is() )
1468 throw lang::NullPointerException();
1470 ::osl::MutexGuard
aGuard( m_aMutex
);
1471 const sal_Int32 nId
= OPropertyInfoService::getPropertyId(ActuatingPropertyName
);
1474 case PROPERTY_ID_TYPE
:
1476 sal_uInt32 nNewVal
= 0;
1477 NewValue
>>= nNewVal
;
1480 case DATA_OR_FORMULA
:
1481 _rxInspectorUI
->rebuildPropertyUI(PROPERTY_DATAFIELD
);
1482 _rxInspectorUI
->enablePropertyUI(PROPERTY_DATAFIELD
,sal_True
);
1483 _rxInspectorUI
->enablePropertyUI(PROPERTY_FORMULALIST
,sal_False
);
1484 _rxInspectorUI
->enablePropertyUI(PROPERTY_SCOPE
,sal_False
);
1485 OSL_ENSURE(m_sDefaultFunction
.isEmpty(),"Why is the m_sDefaultFunction set?");
1486 OSL_ENSURE(m_sScope
.isEmpty(),"Why is the m_sScope set?");
1489 _rxInspectorUI
->rebuildPropertyUI(PROPERTY_DATAFIELD
);
1490 _rxInspectorUI
->rebuildPropertyUI(PROPERTY_FORMULALIST
);
1491 _rxInspectorUI
->enablePropertyUI(PROPERTY_DATAFIELD
,sal_True
);
1492 _rxInspectorUI
->enablePropertyUI(PROPERTY_FORMULALIST
,!m_sDefaultFunction
.isEmpty());
1493 _rxInspectorUI
->enablePropertyUI(PROPERTY_SCOPE
,!m_sScope
.isEmpty());
1495 case USER_DEF_FUNCTION
:
1496 _rxInspectorUI
->enablePropertyUI(PROPERTY_DATAFIELD
,sal_False
);
1497 _rxInspectorUI
->enablePropertyUI(PROPERTY_FORMULALIST
,sal_True
);
1498 _rxInspectorUI
->rebuildPropertyUI(PROPERTY_FORMULALIST
);
1499 _rxInspectorUI
->enablePropertyUI(PROPERTY_SCOPE
,sal_False
);
1502 _rxInspectorUI
->enablePropertyUI(PROPERTY_DATAFIELD
,sal_False
);
1503 _rxInspectorUI
->enablePropertyUI(PROPERTY_FORMULALIST
,sal_False
);
1504 _rxInspectorUI
->enablePropertyUI(PROPERTY_SCOPE
,sal_True
);
1509 case PROPERTY_ID_DATAFIELD
:
1511 bool bEnable
= (m_nDataFieldType
!= DATA_OR_FORMULA
&& m_nDataFieldType
!= COUNTER
);
1515 m_xReportComponent
->getPropertyValue( PROPERTY_DATAFIELD
) >>= sValue
;
1516 bEnable
= !sValue
.isEmpty();
1518 _rxInspectorUI
->enablePropertyUI(PROPERTY_FORMULALIST
,bEnable
);
1521 _rxInspectorUI
->rebuildPropertyUI(PROPERTY_DATAFIELD
);
1522 _rxInspectorUI
->rebuildPropertyUI(PROPERTY_FORMULALIST
);
1524 m_xFormComponentHandler
->actuatingPropertyChanged(ActuatingPropertyName
, NewValue
, OldValue
, _rxInspectorUI
, _bFirstTimeInit
);
1527 case PROPERTY_ID_FORMULALIST
:
1529 _rxInspectorUI
->enablePropertyUI(PROPERTY_SCOPE
,m_nDataFieldType
== FUNCTION
|| m_nDataFieldType
== COUNTER
);
1532 case PROPERTY_ID_BACKTRANSPARENT
:
1533 case PROPERTY_ID_CONTROLBACKGROUNDTRANSPARENT
:
1535 bool bValue
= false;
1536 NewValue
>>= bValue
;
1538 _rxInspectorUI
->enablePropertyUI(PROPERTY_BACKCOLOR
,bValue
);
1539 _rxInspectorUI
->enablePropertyUI(PROPERTY_CONTROLBACKGROUND
,bValue
);
1543 m_xFormComponentHandler
->actuatingPropertyChanged(ActuatingPropertyName
, NewValue
, OldValue
, _rxInspectorUI
, _bFirstTimeInit
);
1548 sal_Bool SAL_CALL
GeometryHandler::suspend(sal_Bool Suspend
) throw (uno::RuntimeException
, std::exception
)
1550 return m_xFormComponentHandler
->suspend(Suspend
);
1553 bool GeometryHandler::impl_dialogFilter_nothrow( OUString
& _out_rSelectedClause
, ::osl::ClearableMutexGuard
& _rClearBeforeDialog
) const
1555 _out_rSelectedClause
.clear();
1556 bool bSuccess
= false;
1557 ::dbtools::SQLExceptionInfo aErrorInfo
;
1558 uno::Reference
< awt::XWindow
> xInspectorWindow
;
1559 uno::Reference
< lang::XMultiComponentFactory
> xFactory
;
1562 xFactory
= m_xContext
->getServiceManager();
1563 xInspectorWindow
.set(m_xContext
->getValueByName("DialogParentWindow") ,uno::UNO_QUERY
);
1564 uno::Reference
<sdbc::XConnection
> xCon(m_xContext
->getValueByName("ActiveConnection") ,uno::UNO_QUERY
);
1568 uno::Reference
< beans::XPropertySet
> xRowSetProp(m_xRowSet
,uno::UNO_QUERY
);
1569 if ( !m_xRowSet
.is() )
1571 m_xRowSet
.set(xFactory
->createInstanceWithContext("com.sun.star.sdb.RowSet",m_xContext
),uno::UNO_QUERY
);
1572 xRowSetProp
.set(m_xRowSet
,uno::UNO_QUERY
);
1573 xRowSetProp
->setPropertyValue(PROPERTY_ACTIVECONNECTION
,uno::makeAny(xCon
));
1574 ::comphelper::copyProperties(m_xReportComponent
,xRowSetProp
);
1577 // get a composer for the statement which the form is currently based on
1578 uno::Reference
< sdb::XSingleSelectQueryComposer
> xComposer( ::dbtools::getCurrentSettingsComposer( xRowSetProp
, m_xContext
) );
1579 OSL_ENSURE( xComposer
.is(), "GeometryHandler::impl_dialogFilter_nothrow: could not obtain a composer!" );
1580 if ( !xComposer
.is() )
1583 // create the dialog
1584 uno::Reference
< ui::dialogs::XExecutableDialog
> xDialog
= sdb::FilterDialog::createWithQuery(m_xContext
, xComposer
, m_xRowSet
, xInspectorWindow
);
1586 const OUString
sPropertyUIName(OUString(ModuleRes(RID_STR_FILTER
)));
1587 // initialize the dialog
1588 xDialog
->setTitle( sPropertyUIName
);
1590 _rClearBeforeDialog
.clear();
1591 bSuccess
= ( xDialog
->execute() != 0 );
1593 _out_rSelectedClause
= xComposer
->getFilter();
1595 catch (const sdb::SQLContext
& e
) { aErrorInfo
= e
; }
1596 catch (const sdbc::SQLWarning
& e
) { aErrorInfo
= e
; }
1597 catch (const sdbc::SQLException
& e
) { aErrorInfo
= e
; }
1598 catch( const uno::Exception
& )
1600 OSL_FAIL( "GeometryHandler::impl_dialogFilter_nothrow: caught an exception!" );
1603 if ( aErrorInfo
.isValid() )
1604 ::dbtools::showError( aErrorInfo
, xInspectorWindow
, m_xContext
);
1609 void GeometryHandler::checkPosAndSize( const awt::Point
& _aNewPos
,
1610 const awt::Size
& _aSize
)
1612 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY
);
1613 const uno::Reference
< report::XSection
> xSection(xSourceReportComponent
->getParent(),uno::UNO_QUERY
);
1614 if ( !xSection
.is() || uno::Reference
< report::XShape
>(xSourceReportComponent
,uno::UNO_QUERY
).is() ) // shapes can overlap.
1617 ::Point
aPos(VCLPoint(_aNewPos
));
1618 if ( aPos
.X() < 0 || aPos
.Y() < 0 ) // TODO: have to check size with pos aka || (aPos.X() + aAwtSize.Width) > m_xSection->getReportDefinition()->
1619 throw beans::PropertyVetoException(OUString(ModuleRes(RID_STR_ILLEGAL_POSITION
)),xSourceReportComponent
);
1621 ::Rectangle
aSourceRect(aPos
,VCLSize(_aSize
));
1623 const sal_Int32 nCount
= xSection
->getCount();
1624 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
1626 const uno::Reference
< report::XReportComponent
> xReportComponent(xSection
->getByIndex(i
),uno::UNO_QUERY
);
1627 if ( xReportComponent
.is() && xReportComponent
!= xSourceReportComponent
)
1629 const ::Rectangle
aBoundRect(VCLPoint(xReportComponent
->getPosition()),VCLSize(xReportComponent
->getSize()));
1630 const ::Rectangle aRect
= aSourceRect
.GetIntersection(aBoundRect
);
1631 if ( !aRect
.IsEmpty() && (aRect
.Left() != aRect
.Right() && aRect
.Top() != aRect
.Bottom() ) )
1632 throw beans::PropertyVetoException(OUString(ModuleRes( RID_STR_OVERLAP_OTHER_CONTROL
)),xSourceReportComponent
);
1637 void GeometryHandler::impl_fillFormulaList_nothrow(::std::vector
< OUString
>& _out_rList
) const
1639 if ( m_nDataFieldType
== FUNCTION
)
1640 ::std::transform(m_aDefaultFunctions
.begin(),m_aDefaultFunctions
.end(),::std::back_inserter(_out_rList
),::boost::bind( &DefaultFunction::getName
, _1
));
1641 else if ( m_nDataFieldType
== USER_DEF_FUNCTION
)
1642 ::std::transform(m_aFunctionNames
.begin(),m_aFunctionNames
.end(),::std::back_inserter(_out_rList
),::o3tl::select1st
<TFunctions::value_type
>());
1645 OUString
GeometryHandler::impl_ConvertUIToMimeType_nothrow(const OUString
& _sUIName
) const
1647 ::std::vector
< OUString
> aList
;
1648 impl_fillMimeTypes_nothrow(aList
);
1650 ::std::vector
< OUString
>::const_iterator aFind
= ::std::find(aList
.begin(),aList
.end(),_sUIName
);
1651 if ( aFind
!= aList
.end() )
1653 const sal_Size nPos
= aFind
- aList
.begin();
1654 const uno::Reference
< report::XReportDefinition
> xReportDefinition(m_xReportComponent
,uno::UNO_QUERY
);
1655 if ( xReportDefinition
.is() )
1657 const uno::Sequence
< OUString
> aMimeTypes( xReportDefinition
->getAvailableMimeTypes() );
1658 sRet
= aMimeTypes
[nPos
];
1664 OUString
GeometryHandler::impl_ConvertMimeTypeToUI_nothrow(const OUString
& _sMimetype
) const
1666 ::comphelper::MimeConfigurationHelper
aMimeHelper(m_xContext
);
1668 const SfxFilter
* pFilter
= SfxFilter::GetDefaultFilter( aMimeHelper
.GetDocServiceNameFromMediaType(_sMimetype
) );
1670 sRet
= pFilter
->GetUIName();
1671 if ( sRet
.isEmpty() )
1676 void GeometryHandler::impl_fillMimeTypes_nothrow(::std::vector
< OUString
>& _out_rList
) const
1680 const uno::Reference
< report::XReportDefinition
> xReportDefinition(m_xReportComponent
,uno::UNO_QUERY
);
1681 if ( xReportDefinition
.is() )
1683 uno::Sequence
< OUString
> aMimeTypes( xReportDefinition
->getAvailableMimeTypes() );
1684 const OUString
* pIter
= aMimeTypes
.getConstArray();
1685 const OUString
* pEnd
= pIter
+ aMimeTypes
.getLength();
1686 for(;pIter
!= pEnd
; ++pIter
)
1688 const OUString
sDocName( impl_ConvertMimeTypeToUI_nothrow(*pIter
) );
1689 if ( !sDocName
.isEmpty() )
1690 _out_rList
.push_back(sDocName
);
1694 catch(uno::Exception
&)
1696 OSL_FAIL("Exception caught!");
1700 void GeometryHandler::impl_fillScopeList_nothrow(::std::vector
< OUString
>& _out_rList
) const
1704 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY_THROW
);
1705 const uno::Reference
< report::XSection
> xSection(xSourceReportComponent
->getParent(),uno::UNO_QUERY_THROW
);
1707 const uno::Reference
< report::XReportDefinition
> xReportDefinition
= xSection
->getReportDefinition();
1708 const uno::Reference
< report::XGroups
> xGroups
= xReportDefinition
->getGroups();
1709 sal_Int32 nPos
= -1;
1710 uno::Reference
< report::XGroup
> xGroup
= xSection
->getGroup();
1712 nPos
= getPositionInIndexAccess(xGroups
.get(),xGroup
);
1713 else if ( xSection
== xReportDefinition
->getDetail() )
1714 nPos
= xGroups
->getCount()-1;
1716 const OUString sGroup
= ModuleRes(RID_STR_SCOPE_GROUP
).toString();
1717 for (sal_Int32 i
= 0 ; i
<= nPos
; ++i
)
1719 xGroup
.set(xGroups
->getByIndex(i
),uno::UNO_QUERY_THROW
);
1720 OUString sGroupName
= sGroup
.replaceFirst("%1",xGroup
->getExpression());
1721 _out_rList
.push_back(sGroupName
);
1723 _out_rList
.push_back(xReportDefinition
->getName());
1725 catch(uno::Exception
&)
1727 OSL_FAIL("Exception caught!");
1731 uno::Reference
< report::XFunctionsSupplier
> GeometryHandler::fillScope_throw(OUString
& _rsNamePostfix
)
1733 uno::Reference
< report::XFunctionsSupplier
> xReturn
;
1735 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY_THROW
);
1736 const uno::Reference
< report::XSection
> xSection(xSourceReportComponent
->getParent(),uno::UNO_QUERY_THROW
);
1737 const uno::Reference
< report::XReportDefinition
> xReportDefinition
= xSection
->getReportDefinition();
1738 if ( m_sScope
.isEmpty() )
1740 const uno::Reference
< report::XGroup
> xGroup(xSection
->getGroup(),uno::UNO_QUERY
);
1743 OUString sGroupName
= ModuleRes(RID_STR_SCOPE_GROUP
).toString();
1744 _rsNamePostfix
= xGroup
->getExpression();
1745 m_sScope
= sGroupName
.replaceFirst("%1",_rsNamePostfix
);
1746 xReturn
= xGroup
.get();
1748 else if ( xSection
== xReportDefinition
->getDetail() )
1750 const uno::Reference
< report::XGroups
> xGroups
= xReportDefinition
->getGroups();
1751 const sal_Int32 nCount
= xGroups
->getCount();
1754 const uno::Reference
< report::XGroup
> xGroup2(xGroups
->getByIndex(nCount
- 1),uno::UNO_QUERY_THROW
);
1755 OUString sGroupName
= ModuleRes(RID_STR_SCOPE_GROUP
);
1756 _rsNamePostfix
= xGroup2
->getExpression();
1757 m_sScope
= sGroupName
.replaceFirst("%1",_rsNamePostfix
);
1758 xReturn
= xGroup2
.get();
1761 if ( m_sScope
.isEmpty() )
1763 xReturn
= xReportDefinition
.get();
1764 _rsNamePostfix
= m_sScope
= xReportDefinition
->getName();
1767 else if ( m_sScope
== xReportDefinition
->getName() )
1769 xReturn
= xReportDefinition
.get();
1770 _rsNamePostfix
= m_sScope
;
1774 uno::Reference
< report::XGroups
> xGroups
= xReportDefinition
->getGroups();
1775 const sal_Int32 nCount
= xGroups
->getCount();
1777 for (sal_Int32 i
= 0 ; i
< nCount
; ++i
)
1779 const uno::Reference
< report::XGroup
> xGroup(xGroups
->getByIndex(i
),uno::UNO_QUERY_THROW
);
1780 OUString sGroupName
= ModuleRes(RID_STR_SCOPE_GROUP
);
1781 if ( m_sScope
== sGroupName
.replaceFirst("%1",xGroup
->getExpression()) )
1783 _rsNamePostfix
= xGroup
->getExpression();
1784 xReturn
= xGroup
.get();
1790 OSL_ENSURE(xReturn
.is(),"Why don't we have a functionssupplier here!");
1795 bool GeometryHandler::isDefaultFunction( const OUString
& _sQuotedFunction
1796 ,OUString
& _rDataField
1797 ,const uno::Reference
< report::XFunctionsSupplier
>& _xFunctionsSupplier
1800 bool bDefaultFunction
= false;
1803 const uno::Reference
< report::XReportComponent
> xSourceReportComponent(m_xReportComponent
,uno::UNO_QUERY_THROW
);
1804 const uno::Reference
< report::XSection
> xSection(xSourceReportComponent
->getParent(),uno::UNO_QUERY_THROW
);
1805 const uno::Reference
< report::XReportDefinition
> xReportDefinition
= xSection
->getReportDefinition();
1807 ::std::pair
<TFunctions::const_iterator
,TFunctions::const_iterator
> aFind
= m_aFunctionNames
.equal_range(_sQuotedFunction
);
1808 while ( aFind
.first
!= aFind
.second
)
1810 if ( !_xFunctionsSupplier
.is() || _xFunctionsSupplier
== aFind
.first
->second
.second
)
1812 const beans::Optional
< OUString
> aInitalFormula
= aFind
.first
->second
.first
->getInitialFormula();
1813 if ( aInitalFormula
.IsPresent
)
1815 OUString sDefaultFunctionName
;
1816 bDefaultFunction
= impl_isDefaultFunction_nothrow(aFind
.first
->second
.first
,_rDataField
,sDefaultFunctionName
);
1817 if ( bDefaultFunction
)
1819 m_xFunction
= aFind
.first
->second
.first
;
1822 m_sDefaultFunction
= sDefaultFunctionName
;
1823 uno::Reference
< report::XGroup
> xGroup(aFind
.first
->second
.second
,uno::UNO_QUERY
);
1826 OUString sGroupName
= ModuleRes(RID_STR_SCOPE_GROUP
);
1827 m_sScope
= sGroupName
.replaceFirst("%1",xGroup
->getExpression());
1830 m_sScope
= xReportDefinition
->getName();
1839 catch(uno::Exception
&)
1841 OSL_FAIL("Exception caught!");
1843 return bDefaultFunction
;
1846 bool GeometryHandler::impl_isDefaultFunction_nothrow( const uno::Reference
< report::XFunction
>& _xFunction
1847 ,OUString
& _rDataField
1848 ,OUString
& _rsDefaultFunctionName
) const
1850 bool bDefaultFunction
= false;
1853 const OUString
sFormula( _xFunction
->getFormula() );
1854 util::SearchOptions aSearchOptions
;
1855 aSearchOptions
.algorithmType
= util::SearchAlgorithms_REGEXP
;
1856 aSearchOptions
.searchFlag
= 0x00000100;
1857 ::std::vector
< DefaultFunction
>::const_iterator aIter
= m_aDefaultFunctions
.begin();
1858 ::std::vector
< DefaultFunction
>::const_iterator aDeEnd
= m_aDefaultFunctions
.end();
1859 for (; aIter
!= aDeEnd
; ++aIter
)
1861 aSearchOptions
.searchString
= aIter
->m_sSearchString
;
1862 utl::TextSearch
aTextSearch(aSearchOptions
);
1863 sal_Int32 start
= 0;
1864 sal_Int32 end
= sFormula
.getLength();
1865 if ( aTextSearch
.SearchForward(sFormula
,&start
,&end
) && start
== 0 && end
== sFormula
.getLength()) // default function found
1867 aSearchOptions
.searchString
= "\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]";
1868 utl::TextSearch
aDataSearch(aSearchOptions
);
1869 aDataSearch
.SearchForward(sFormula
,&start
,&end
);
1871 _rDataField
= sFormula
.copy(start
,end
-start
-1);
1872 _rsDefaultFunctionName
= aIter
->m_sName
;
1877 bDefaultFunction
= aIter
!= aDeEnd
;
1879 catch(uno::Exception
&)
1881 OSL_FAIL("Exception caught!");
1883 return bDefaultFunction
;
1886 void GeometryHandler::loadDefaultFunctions()
1888 if ( m_aDefaultFunctions
.empty() )
1890 m_aCounterFunction
.m_bPreEvaluated
= false;
1891 m_aCounterFunction
.m_bDeepTraversing
= false;
1892 m_aCounterFunction
.m_sName
= ModuleRes(RID_STR_F_COUNTER
);
1893 m_aCounterFunction
.m_sFormula
= "rpt:[%FunctionName] + 1";
1894 m_aCounterFunction
.m_sSearchString
= "rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*[:digit:]*";
1895 m_aCounterFunction
.m_sInitialFormula
.IsPresent
= sal_True
;
1896 m_aCounterFunction
.m_sInitialFormula
.Value
= "rpt:1";
1898 DefaultFunction aDefault
;
1899 aDefault
.m_bDeepTraversing
= false;
1901 aDefault
.m_bPreEvaluated
= true;
1903 aDefault
.m_sName
= ModuleRes(RID_STR_F_ACCUMULATION
);
1904 aDefault
.m_sFormula
= "rpt:[%Column] + [%FunctionName]";
1905 aDefault
.m_sSearchString
= "rpt:\\[[:alpha:]+([:space:]*[:alnum:]*)*\\][:space:]*\\+[:space:]*\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]";
1906 aDefault
.m_sInitialFormula
.IsPresent
= sal_True
;
1907 aDefault
.m_sInitialFormula
.Value
= "rpt:[%Column]";
1908 m_aDefaultFunctions
.push_back(aDefault
);
1910 aDefault
.m_sName
= ModuleRes(RID_STR_F_MINIMUM
);
1911 aDefault
.m_sFormula
= "rpt:IF([%Column] < [%FunctionName];[%Column];[%FunctionName])";
1912 aDefault
.m_sSearchString
= "rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*<[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)";
1913 aDefault
.m_sInitialFormula
.IsPresent
= sal_True
;
1914 aDefault
.m_sInitialFormula
.Value
= "rpt:[%Column]";
1915 m_aDefaultFunctions
.push_back(aDefault
);
1917 aDefault
.m_sName
= ModuleRes(RID_STR_F_MAXIMUM
);
1918 aDefault
.m_sFormula
= "rpt:IF([%Column] > [%FunctionName];[%Column];[%FunctionName])";
1919 aDefault
.m_sSearchString
= "rpt:IF\\((\\[[:alpha:]+([:space:]*[:alnum:]*)*\\])[:space:]*>[:space:]*(\\[[:alpha:]+([:space:]*[:alnum:]*)*\\]);[:space:]*\\1[:space:]*;[:space:]*\\3[:space:]*\\)";
1920 aDefault
.m_sInitialFormula
.IsPresent
= sal_True
;
1921 aDefault
.m_sInitialFormula
.Value
= "rpt:[%Column]";
1922 m_aDefaultFunctions
.push_back(aDefault
);
1926 void GeometryHandler::createDefaultFunction(::osl::ResettableMutexGuard
& _aGuard
,const OUString
& _sFunction
,const OUString
& _sDataField
)
1930 OUString sNamePostfix
;
1931 const uno::Reference
< report::XFunctionsSupplier
> xFunctionsSupplier
= fillScope_throw(sNamePostfix
);
1933 ::std::vector
< DefaultFunction
>::const_iterator aIter
= m_aDefaultFunctions
.begin();
1934 ::std::vector
< DefaultFunction
>::const_iterator aDeEnd
= m_aDefaultFunctions
.end();
1935 for (; aIter
!= aDeEnd
; ++aIter
)
1937 if ( aIter
->m_sName
== _sFunction
)
1939 const OUString
sFunctionName( _sFunction
+ _sDataField
+ sNamePostfix
);
1940 const OUString
sQuotedFunctionName(lcl_getQuotedFunctionName(sFunctionName
));
1942 beans::PropertyChangeEvent aEvent
;
1943 aEvent
.PropertyName
= PROPERTY_SCOPE
;
1944 aEvent
.OldValue
<<= m_sScope
;
1946 ::std::pair
<TFunctions::const_iterator
,TFunctions::const_iterator
> aFind
= m_aFunctionNames
.equal_range(sQuotedFunctionName
);
1947 while ( aFind
.first
!= aFind
.second
)
1949 if ( xFunctionsSupplier
== aFind
.first
->second
.second
)
1951 m_xFunction
= aFind
.first
->second
.first
;
1953 isDefaultFunction(sQuotedFunctionName
,sTemp
,uno::Reference
< report::XFunctionsSupplier
>(),true); // implicitly sets the m_sScope
1958 if ( aFind
.first
== aFind
.second
)
1959 impl_createFunction(sFunctionName
,_sDataField
,*aIter
);
1961 OBlocker
aBlocker(m_bIn
);
1962 m_xReportComponent
->setPropertyValue(PROPERTY_DATAFIELD
,uno::makeAny( impl_convertToFormula( uno::makeAny(sQuotedFunctionName
) )));
1963 aEvent
.NewValue
<<= m_sScope
;
1965 m_aPropertyListeners
.notify( aEvent
, &beans::XPropertyChangeListener::propertyChange
);
1970 catch(uno::Exception
&)
1972 OSL_FAIL("Exception caught!");
1976 void GeometryHandler::removeFunction()
1978 if ( m_xFunction
.is() )
1980 const OUString
sQuotedFunctionName(lcl_getQuotedFunctionName(m_xFunction
));
1981 ::std::pair
<TFunctions::iterator
,TFunctions::iterator
> aFind
= m_aFunctionNames
.equal_range(sQuotedFunctionName
);
1982 while ( aFind
.first
!= aFind
.second
)
1984 if ( aFind
.first
->second
.first
== m_xFunction
)
1986 uno::Reference
< report::XFunctions
> xFunctions
= aFind
.first
->second
.second
->getFunctions();
1987 xFunctions
->removeByIndex(xFunctions
->getCount() - 1 ); /// TODO: insert new method in XFunctions: removeFunction(xfunction)
1988 m_aFunctionNames
.erase(aFind
.first
);
1989 m_bNewFunction
= false;
1997 void GeometryHandler::resetOwnProperties(::osl::ResettableMutexGuard
& _aGuard
,const OUString
& _sOldFunctionName
,const OUString
& _sOldScope
,const sal_uInt32 _nOldDataFieldType
)
1999 const OUString sNewFunction
= m_sDefaultFunction
;
2000 const OUString sNewScope
= m_sScope
;
2001 const sal_uInt32 nNewDataFieldType
= m_nDataFieldType
;
2003 if ( _nOldDataFieldType
!= nNewDataFieldType
)
2005 beans::PropertyChangeEvent aScopeEvent
;
2006 aScopeEvent
.PropertyName
= PROPERTY_TYPE
;
2007 aScopeEvent
.OldValue
<<= _nOldDataFieldType
;
2008 aScopeEvent
.NewValue
<<= nNewDataFieldType
;
2009 m_aPropertyListeners
.notify( aScopeEvent
, &beans::XPropertyChangeListener::propertyChange
);
2011 if ( _sOldFunctionName
!= sNewFunction
)
2013 beans::PropertyChangeEvent aFormulaEvent
;
2014 aFormulaEvent
.PropertyName
= PROPERTY_FORMULALIST
;
2015 aFormulaEvent
.OldValue
<<= _sOldFunctionName
;
2016 aFormulaEvent
.NewValue
<<= sNewFunction
;
2018 m_aPropertyListeners
.notify( aFormulaEvent
, &beans::XPropertyChangeListener::propertyChange
);
2020 if ( _sOldScope
!= sNewScope
)
2022 beans::PropertyChangeEvent aScopeEvent
;
2023 aScopeEvent
.PropertyName
= PROPERTY_SCOPE
;
2024 aScopeEvent
.OldValue
<<= _sOldScope
;
2025 aScopeEvent
.NewValue
<<= sNewScope
;
2026 m_aPropertyListeners
.notify( aScopeEvent
, &beans::XPropertyChangeListener::propertyChange
);
2032 void GeometryHandler::impl_initFieldList_nothrow( uno::Sequence
< OUString
>& _rFieldNames
) const
2034 _rFieldNames
.realloc(0);
2037 uno::Reference
< awt::XWindow
> xInspectorWindow(m_xContext
->getValueByName("DialogParentWindow") ,uno::UNO_QUERY
);
2038 vcl::Window
* pInspectorWindow
= VCLUnoHelper::GetWindow( xInspectorWindow
);
2039 WaitObject
aWaitCursor( pInspectorWindow
);
2041 uno::Reference
< sdbc::XPreparedStatement
> xStatement
;
2043 // get the form of the control we're inspecting
2044 uno::Reference
< beans::XPropertySet
> xFormSet( m_xRowSet
, uno::UNO_QUERY
);
2045 if ( !xFormSet
.is() )
2048 OUString sObjectName
;
2049 OSL_VERIFY( xFormSet
->getPropertyValue( PROPERTY_COMMAND
) >>= sObjectName
);
2050 // when there is no command we don't need to ask for columns
2051 uno::Reference
<sdbc::XConnection
> xCon(m_xContext
->getValueByName("ActiveConnection") ,uno::UNO_QUERY
);
2052 if ( !sObjectName
.isEmpty() && xCon
.is() )
2054 sal_Int32 nObjectType
= sdb::CommandType::COMMAND
;
2055 OSL_VERIFY( xFormSet
->getPropertyValue( PROPERTY_COMMANDTYPE
) >>= nObjectType
);
2057 _rFieldNames
= ::dbtools::getFieldNamesByCommandDescriptor( xCon
, nObjectType
, sObjectName
);
2060 catch (uno::Exception
&)
2062 OSL_FAIL( "GeometryHandler::impl_initFieldList_nothrow: caught an exception!" );
2066 bool GeometryHandler::impl_isCounterFunction_throw(const OUString
& _sQuotedFunctionName
,OUString
& _Out_sScope
) const
2068 ::std::pair
<TFunctions::const_iterator
,TFunctions::const_iterator
> aFind
= m_aFunctionNames
.equal_range(_sQuotedFunctionName
);
2069 while ( aFind
.first
!= aFind
.second
)
2071 const beans::Optional
< OUString
> aInitalFormula
= aFind
.first
->second
.first
->getInitialFormula();
2072 if ( aInitalFormula
.IsPresent
)
2074 const OUString
sFormula( aFind
.first
->second
.first
->getFormula() );
2075 util::SearchOptions aSearchOptions
;
2076 aSearchOptions
.algorithmType
= util::SearchAlgorithms_REGEXP
;
2077 aSearchOptions
.searchFlag
= 0x00000100;
2078 aSearchOptions
.searchString
= m_aCounterFunction
.m_sSearchString
;
2079 utl::TextSearch
aTextSearch(aSearchOptions
);
2080 sal_Int32 start
= 0;
2081 sal_Int32 end
= sFormula
.getLength();
2082 if ( aTextSearch
.SearchForward(sFormula
,&start
,&end
) && start
== 0 && end
== sFormula
.getLength()) // counter function found
2084 const uno::Reference
< report::XGroup
> xGroup(aFind
.first
->second
.second
,uno::UNO_QUERY
);
2087 OUString sGroupName
= ModuleRes(RID_STR_SCOPE_GROUP
);
2088 _Out_sScope
= sGroupName
.replaceFirst("%1",xGroup
->getExpression());
2091 _Out_sScope
= uno::Reference
< report::XReportDefinition
>(aFind
.first
->second
.second
,uno::UNO_QUERY_THROW
)->getName();
2097 return aFind
.first
!= aFind
.second
;
2100 void GeometryHandler::impl_createFunction(const OUString
& _sFunctionName
,const OUString
& _sDataField
,const DefaultFunction
& _aFunction
)
2102 if ( m_bNewFunction
)
2105 const OUString
sQuotedFunctionName(lcl_getQuotedFunctionName(_sFunctionName
));
2106 m_xFunction
.set(report::Function::create(m_xContext
));
2107 m_xFunction
->setName( _sFunctionName
);
2109 const OUString
sPlaceHolder1("%Column");
2110 const OUString
sPlaceHolder2("%FunctionName");
2111 OUString
sFormula(_aFunction
.m_sFormula
);
2112 sFormula
= sFormula
.replaceAll(sPlaceHolder1
,_sDataField
);
2113 sFormula
= sFormula
.replaceAll(sPlaceHolder2
,_sFunctionName
);
2115 m_xFunction
->setFormula(sFormula
);
2116 m_xFunction
->setPreEvaluated(_aFunction
.m_bPreEvaluated
);
2117 m_xFunction
->setDeepTraversing(_aFunction
.m_bDeepTraversing
);
2118 if ( _aFunction
.m_sInitialFormula
.IsPresent
)
2120 beans::Optional
< OUString
> aInitialFormula
= _aFunction
.m_sInitialFormula
;
2121 OUString sInitialFormula
= aInitialFormula
.Value
;
2122 sInitialFormula
= sInitialFormula
.replaceAll(sPlaceHolder1
,_sDataField
);
2123 sInitialFormula
= sInitialFormula
.replaceAll(sPlaceHolder2
,_sFunctionName
);
2124 aInitialFormula
.Value
= sInitialFormula
;
2125 m_xFunction
->setInitialFormula( aInitialFormula
);
2127 OUString sNamePostfix
;
2128 const uno::Reference
< report::XFunctionsSupplier
> xFunctionsSupplier
= fillScope_throw(sNamePostfix
);
2129 const uno::Reference
< container::XIndexContainer
> xFunctions(xFunctionsSupplier
->getFunctions(),uno::UNO_QUERY_THROW
);
2130 xFunctions
->insertByIndex(xFunctions
->getCount(),uno::makeAny(m_xFunction
));
2131 m_aFunctionNames
.insert(TFunctions::value_type(sQuotedFunctionName
,TFunctionPair(m_xFunction
,xFunctionsSupplier
)));
2132 m_bNewFunction
= true;
2135 void GeometryHandler::impl_setCounterFunction_throw()
2137 OUString sNamePostfix
;
2138 fillScope_throw(sNamePostfix
);
2139 OUString sFunctionName
= m_aCounterFunction
.m_sName
;
2140 sFunctionName
+= sNamePostfix
;
2141 const OUString sQuotedFunctionName
= lcl_getQuotedFunctionName(sFunctionName
);
2143 if ( !(!sFunctionName
.isEmpty() && m_aFunctionNames
.find(sQuotedFunctionName
) != m_aFunctionNames
.end() && impl_isCounterFunction_throw(sQuotedFunctionName
,sScope
)) )
2144 impl_createFunction(sFunctionName
,OUString(),m_aCounterFunction
);
2146 OBlocker
aBlocker(m_bIn
);
2147 m_xReportComponent
->setPropertyValue(PROPERTY_DATAFIELD
,uno::makeAny(impl_convertToFormula( uno::makeAny(sQuotedFunctionName
))));
2150 sal_uInt32
GeometryHandler::impl_getDataFieldType_throw(const OUString
& _sDataField
) const
2152 sal_uInt32 nDataFieldType
= UNDEF_DATA
;
2153 OUString sDataField
;
2154 if ( !_sDataField
.isEmpty() )
2155 sDataField
= _sDataField
;
2158 uno::Any
aDataField( m_xReportComponent
->getPropertyValue( PROPERTY_DATAFIELD
) );
2159 lcl_convertFormulaTo(aDataField
,aDataField
);
2160 aDataField
>>= sDataField
;
2163 if ( !sDataField
.isEmpty() )
2165 if ( impl_isDataField(sDataField
) )
2166 nDataFieldType
= DATA_OR_FORMULA
;
2167 else if ( isDefaultFunction(sDataField
,sDataField
) )
2168 nDataFieldType
= FUNCTION
;
2169 else if ( m_aFunctionNames
.find(sDataField
) != m_aFunctionNames
.end() )
2171 nDataFieldType
= USER_DEF_FUNCTION
;
2173 if ( impl_isCounterFunction_throw(sDataField
,sScope
) )
2174 nDataFieldType
= COUNTER
;
2177 nDataFieldType
= DATA_OR_FORMULA
;
2179 return nDataFieldType
;
2183 void SAL_CALL
GeometryHandler::disposing(const lang::EventObject
& ) throw( uno::RuntimeException
, std::exception
)
2186 // XPropertyChangeListener
2187 void SAL_CALL
GeometryHandler::propertyChange(const beans::PropertyChangeEvent
& /*evt*/) throw(uno::RuntimeException
, std::exception
)
2189 ::osl::ResettableMutexGuard
aGuard( m_aMutex
);
2192 const sal_uInt32 nOldDataFieldType
= m_nDataFieldType
;
2193 const OUString sOldFunctionName
= m_sDefaultFunction
;
2194 const OUString sOldScope
= m_sScope
;
2195 m_sDefaultFunction
.clear();
2197 m_nDataFieldType
= impl_getDataFieldType_throw();
2198 if ( UNDEF_DATA
== m_nDataFieldType
)
2199 m_nDataFieldType
= nOldDataFieldType
;
2200 uno::Any aDataField
= m_xReportComponent
->getPropertyValue( PROPERTY_DATAFIELD
);
2201 lcl_convertFormulaTo(aDataField
,aDataField
);
2202 OUString sDataField
;
2203 aDataField
>>= sDataField
;
2204 switch(m_nDataFieldType
)
2207 isDefaultFunction(sDataField
,sDataField
,uno::Reference
< report::XFunctionsSupplier
>(),true);
2210 impl_isCounterFunction_throw(sDataField
,m_sScope
);
2216 resetOwnProperties(aGuard
,sOldFunctionName
,sOldScope
,nOldDataFieldType
);
2220 } // namespace rptui
2223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */