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

Generated by: LCOV version 1.11