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