LCOV - code coverage report
Current view: top level - reportdesign/source/ui/inspection - GeometryHandler.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 3 1227 0.2 %
Date: 2014-11-03 Functions: 3 64 4.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10