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 "vbavalidation.hxx" 28*cdf0e10cSrcweir #include <com/sun/star/sheet/XSheetCondition.hpp> 29*cdf0e10cSrcweir #include <com/sun/star/sheet/ValidationType.hpp> 30*cdf0e10cSrcweir #include <com/sun/star/sheet/ValidationAlertStyle.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 32*cdf0e10cSrcweir #include <ooo/vba/excel/XlDVType.hpp> 33*cdf0e10cSrcweir #include <ooo/vba/excel/XlFormatConditionOperator.hpp> 34*cdf0e10cSrcweir #include <ooo/vba/excel/XlDVAlertStyle.hpp> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include "unonames.hxx" 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir using namespace ::ooo::vba; 39*cdf0e10cSrcweir using namespace ::com::sun::star; 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir const static rtl::OUString VALIDATION( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_VALIDAT ) ); 42*cdf0e10cSrcweir const static rtl::OUString IGNOREBLANK( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_IGNOREBL ) ); 43*cdf0e10cSrcweir const static rtl::OUString SHOWINPUT( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SHOWINP ) ); 44*cdf0e10cSrcweir const static rtl::OUString SHOWERROR( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SHOWERR ) ); 45*cdf0e10cSrcweir const static rtl::OUString ERRORTITLE( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_ERRTITLE ) ); 46*cdf0e10cSrcweir const static rtl::OUString INPUTTITLE( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_INPTITLE ) ); 47*cdf0e10cSrcweir const static rtl::OUString INPUTMESS( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_INPMESS ) ); 48*cdf0e10cSrcweir const static rtl::OUString ERRORMESS( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_ERRMESS ) ); 49*cdf0e10cSrcweir const static rtl::OUString STYPE( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_TYPE ) ); 50*cdf0e10cSrcweir const static rtl::OUString SHOWLIST( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SHOWLIST ) ); 51*cdf0e10cSrcweir const static rtl::OUString ALERTSTYLE( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_ERRALSTY ) ); 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir void 54*cdf0e10cSrcweir lcl_setValidationProps( const uno::Reference< table::XCellRange >& xRange, const uno::Reference< beans::XPropertySet >& xProps ) 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xRangeProps( xRange, uno::UNO_QUERY_THROW ); 57*cdf0e10cSrcweir xRangeProps->setPropertyValue( VALIDATION , uno::makeAny( xProps ) ); 58*cdf0e10cSrcweir } 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > 61*cdf0e10cSrcweir lcl_getValidationProps( const uno::Reference< table::XCellRange >& xRange ) 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( xRange, uno::UNO_QUERY_THROW ); 64*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xValProps; 65*cdf0e10cSrcweir xValProps.set( xProps->getPropertyValue( VALIDATION ), uno::UNO_QUERY_THROW ); 66*cdf0e10cSrcweir return xValProps; 67*cdf0e10cSrcweir } 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir ::sal_Bool SAL_CALL 70*cdf0e10cSrcweir ScVbaValidation::getIgnoreBlank() throw (uno::RuntimeException) 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) ); 73*cdf0e10cSrcweir sal_Bool bBlank = sal_False; 74*cdf0e10cSrcweir xProps->getPropertyValue( IGNOREBLANK ) >>= bBlank; 75*cdf0e10cSrcweir return bBlank; 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir void SAL_CALL 79*cdf0e10cSrcweir ScVbaValidation::setIgnoreBlank( ::sal_Bool _ignoreblank ) throw (uno::RuntimeException) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) ); 82*cdf0e10cSrcweir xProps->setPropertyValue( IGNOREBLANK, uno::makeAny( _ignoreblank ) ); 83*cdf0e10cSrcweir lcl_setValidationProps( m_xRange, xProps ); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir ::sal_Bool SAL_CALL 87*cdf0e10cSrcweir ScVbaValidation::getInCellDropdown() throw (uno::RuntimeException) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange ); 90*cdf0e10cSrcweir sal_Int32 nShowList = 0; 91*cdf0e10cSrcweir xProps->getPropertyValue( SHOWLIST ) >>= nShowList; 92*cdf0e10cSrcweir return ( nShowList ? sal_True : sal_False ); 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir void SAL_CALL 96*cdf0e10cSrcweir ScVbaValidation::setInCellDropdown( ::sal_Bool _incelldropdown ) throw (uno::RuntimeException) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir sal_Int32 nDropDown = sal_False; 99*cdf0e10cSrcweir if ( _incelldropdown ) 100*cdf0e10cSrcweir nDropDown = 1; 101*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps(m_xRange) ); 102*cdf0e10cSrcweir xProps->setPropertyValue( SHOWLIST, uno::makeAny( nDropDown ) ); 103*cdf0e10cSrcweir lcl_setValidationProps( m_xRange, xProps ); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir ::sal_Bool SAL_CALL 107*cdf0e10cSrcweir ScVbaValidation::getShowInput() throw (uno::RuntimeException) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange ); 110*cdf0e10cSrcweir sal_Bool bShowInput = sal_False; 111*cdf0e10cSrcweir xProps->getPropertyValue( SHOWINPUT ) >>= bShowInput; 112*cdf0e10cSrcweir return bShowInput; 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir void SAL_CALL 116*cdf0e10cSrcweir ScVbaValidation:: setShowInput( ::sal_Bool _showinput ) throw (uno::RuntimeException) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps(m_xRange) ); 119*cdf0e10cSrcweir xProps->setPropertyValue( IGNOREBLANK, uno::makeAny( _showinput ) ); 120*cdf0e10cSrcweir lcl_setValidationProps( m_xRange, xProps ); 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir ::sal_Bool SAL_CALL 124*cdf0e10cSrcweir ScVbaValidation::getShowError() throw (uno::RuntimeException) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange ); 127*cdf0e10cSrcweir sal_Bool bShowError = sal_False; 128*cdf0e10cSrcweir xProps->getPropertyValue( SHOWERROR ) >>= bShowError; 129*cdf0e10cSrcweir return bShowError; 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir void SAL_CALL 133*cdf0e10cSrcweir ScVbaValidation::setShowError( ::sal_Bool _showerror ) throw (uno::RuntimeException) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) ); 136*cdf0e10cSrcweir xProps->setPropertyValue( SHOWERROR, uno::makeAny( _showerror ) ); 137*cdf0e10cSrcweir lcl_setValidationProps( m_xRange, xProps ); 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir ::rtl::OUString SAL_CALL 141*cdf0e10cSrcweir ScVbaValidation::getErrorTitle() throw (uno::RuntimeException) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange ); 144*cdf0e10cSrcweir rtl::OUString sErrorTitle; 145*cdf0e10cSrcweir xProps->getPropertyValue( ERRORTITLE ) >>= sErrorTitle; 146*cdf0e10cSrcweir return sErrorTitle; 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir void 150*cdf0e10cSrcweir ScVbaValidation::setErrorTitle( const rtl::OUString& _errormessage ) throw (uno::RuntimeException) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) ); 153*cdf0e10cSrcweir xProps->setPropertyValue( ERRORTITLE, uno::makeAny( _errormessage ) ); 154*cdf0e10cSrcweir lcl_setValidationProps( m_xRange, xProps ); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir ::rtl::OUString SAL_CALL 158*cdf0e10cSrcweir ScVbaValidation::getInputMessage() throw (uno::RuntimeException) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange ); 161*cdf0e10cSrcweir rtl::OUString sMsg; 162*cdf0e10cSrcweir xProps->getPropertyValue( INPUTMESS ) >>= sMsg; 163*cdf0e10cSrcweir return sMsg; 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir void SAL_CALL 167*cdf0e10cSrcweir ScVbaValidation::setInputMessage( const ::rtl::OUString& _inputmessage ) throw (uno::RuntimeException) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) ); 170*cdf0e10cSrcweir xProps->setPropertyValue( INPUTMESS, uno::makeAny( _inputmessage ) ); 171*cdf0e10cSrcweir lcl_setValidationProps( m_xRange, xProps ); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir ::rtl::OUString SAL_CALL 175*cdf0e10cSrcweir ScVbaValidation::getInputTitle() throw (uno::RuntimeException) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange ); 178*cdf0e10cSrcweir rtl::OUString sString; 179*cdf0e10cSrcweir xProps->getPropertyValue( INPUTTITLE ) >>= sString; 180*cdf0e10cSrcweir return sString; 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir void SAL_CALL 184*cdf0e10cSrcweir ScVbaValidation::setInputTitle( const ::rtl::OUString& _inputtitle ) throw (uno::RuntimeException) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) ); 187*cdf0e10cSrcweir xProps->setPropertyValue( INPUTTITLE, uno::makeAny( _inputtitle ) ); 188*cdf0e10cSrcweir lcl_setValidationProps( m_xRange, xProps ); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir ::rtl::OUString SAL_CALL 192*cdf0e10cSrcweir ScVbaValidation::getErrorMessage() throw (uno::RuntimeException) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange ); 195*cdf0e10cSrcweir rtl::OUString sString; 196*cdf0e10cSrcweir xProps->getPropertyValue( ERRORMESS ) >>= sString; 197*cdf0e10cSrcweir return sString; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir void SAL_CALL 201*cdf0e10cSrcweir ScVbaValidation::setErrorMessage( const ::rtl::OUString& _errormessage ) throw (uno::RuntimeException) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) ); 204*cdf0e10cSrcweir xProps->setPropertyValue( ERRORMESS, uno::makeAny( _errormessage ) ); 205*cdf0e10cSrcweir lcl_setValidationProps( m_xRange, xProps ); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir void SAL_CALL 210*cdf0e10cSrcweir ScVbaValidation::Delete( ) throw (uno::RuntimeException) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir rtl::OUString sBlank; 213*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) ); 214*cdf0e10cSrcweir uno::Reference< sheet::XSheetCondition > xCond( xProps, uno::UNO_QUERY_THROW ); 215*cdf0e10cSrcweir xProps->setPropertyValue( IGNOREBLANK, uno::makeAny( sal_True ) ); 216*cdf0e10cSrcweir xProps->setPropertyValue( SHOWINPUT, uno::makeAny( sal_True ) ); 217*cdf0e10cSrcweir xProps->setPropertyValue( SHOWERROR, uno::makeAny( sal_True ) ); 218*cdf0e10cSrcweir xProps->setPropertyValue( ERRORTITLE, uno::makeAny( sBlank ) ); 219*cdf0e10cSrcweir xProps->setPropertyValue( INPUTMESS, uno::makeAny( sBlank) ); 220*cdf0e10cSrcweir xProps->setPropertyValue( ALERTSTYLE, uno::makeAny( sheet::ValidationAlertStyle_STOP) ); 221*cdf0e10cSrcweir xProps->setPropertyValue( STYPE, uno::makeAny( sheet::ValidationType_ANY ) ); 222*cdf0e10cSrcweir xCond->setFormula1( sBlank ); 223*cdf0e10cSrcweir xCond->setFormula2( sBlank ); 224*cdf0e10cSrcweir xCond->setOperator( sheet::ConditionOperator_NONE ); 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir lcl_setValidationProps( m_xRange, xProps ); 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir void SAL_CALL 229*cdf0e10cSrcweir ScVbaValidation::Add( const uno::Any& Type, const uno::Any& AlertStyle, const uno::Any& /*Operator*/, const uno::Any& Formula1, const uno::Any& Formula2 ) throw (uno::RuntimeException) 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) ); 232*cdf0e10cSrcweir uno::Reference< sheet::XSheetCondition > xCond( xProps, uno::UNO_QUERY_THROW ); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir sheet::ValidationType nValType = sheet::ValidationType_ANY; 235*cdf0e10cSrcweir xProps->getPropertyValue( STYPE ) >>= nValType; 236*cdf0e10cSrcweir if ( nValType != sheet::ValidationType_ANY ) 237*cdf0e10cSrcweir throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "validation object already exists" ) ), uno::Reference< uno::XInterface >() ); 238*cdf0e10cSrcweir sal_Int32 nType = -1; 239*cdf0e10cSrcweir if ( !Type.hasValue() || !( Type >>= nType ) ) 240*cdf0e10cSrcweir throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "missing required param" ) ), uno::Reference< uno::XInterface >() ); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir Delete(); // set up defaults 243*cdf0e10cSrcweir rtl::OUString sFormula1; 244*cdf0e10cSrcweir Formula1 >>= sFormula1; 245*cdf0e10cSrcweir rtl::OUString sFormula2; 246*cdf0e10cSrcweir Formula2 >>= sFormula2; 247*cdf0e10cSrcweir switch ( nType ) 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir case excel::XlDVType::xlValidateList: 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir // for validate list 252*cdf0e10cSrcweir // at least formula1 is required 253*cdf0e10cSrcweir if ( !Formula1.hasValue() ) 254*cdf0e10cSrcweir throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "missing param" ) ), uno::Reference< uno::XInterface >() ); 255*cdf0e10cSrcweir nValType = sheet::ValidationType_LIST; 256*cdf0e10cSrcweir xProps->setPropertyValue( STYPE, uno::makeAny(nValType )); 257*cdf0e10cSrcweir // #TODO validate required params 258*cdf0e10cSrcweir // #TODO need to correct the ';' delimited formula on get/set 259*cdf0e10cSrcweir break; 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir case excel::XlDVType::xlValidateWholeNumber: 262*cdf0e10cSrcweir nValType = sheet::ValidationType_WHOLE; 263*cdf0e10cSrcweir xProps->setPropertyValue( STYPE, uno::makeAny(nValType )); 264*cdf0e10cSrcweir break; 265*cdf0e10cSrcweir default: 266*cdf0e10cSrcweir throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "unsupported operation..." ) ), uno::Reference< uno::XInterface >() ); 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir sheet::ValidationAlertStyle eStyle = sheet::ValidationAlertStyle_STOP; 270*cdf0e10cSrcweir sal_Int32 nVbaAlertStyle = excel::XlDVAlertStyle::xlValidAlertStop; 271*cdf0e10cSrcweir if ( AlertStyle.hasValue() && ( AlertStyle >>= nVbaAlertStyle ) ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir switch( nVbaAlertStyle ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir case excel::XlDVAlertStyle::xlValidAlertStop: 276*cdf0e10cSrcweir // yes I know it's already defaulted but safer to assume 277*cdf0e10cSrcweir // someone propbably could change the code above 278*cdf0e10cSrcweir eStyle = sheet::ValidationAlertStyle_STOP; 279*cdf0e10cSrcweir break; 280*cdf0e10cSrcweir case excel::XlDVAlertStyle::xlValidAlertWarning: 281*cdf0e10cSrcweir eStyle = sheet::ValidationAlertStyle_WARNING; 282*cdf0e10cSrcweir break; 283*cdf0e10cSrcweir case excel::XlDVAlertStyle::xlValidAlertInformation: 284*cdf0e10cSrcweir eStyle = sheet::ValidationAlertStyle_INFO; 285*cdf0e10cSrcweir break; 286*cdf0e10cSrcweir default: 287*cdf0e10cSrcweir throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "bad param..." ) ), uno::Reference< uno::XInterface >() ); 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir xProps->setPropertyValue( ALERTSTYLE, uno::makeAny( eStyle ) ); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir if ( sFormula1.getLength() ) 295*cdf0e10cSrcweir xCond->setFormula1( sFormula1 ); 296*cdf0e10cSrcweir if ( sFormula2.getLength() ) 297*cdf0e10cSrcweir xCond->setFormula2( sFormula2 ); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir lcl_setValidationProps( m_xRange, xProps ); 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir ::rtl::OUString SAL_CALL 303*cdf0e10cSrcweir ScVbaValidation::getFormula1() throw (uno::RuntimeException) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir uno::Reference< sheet::XSheetCondition > xCond( lcl_getValidationProps( m_xRange ), uno::UNO_QUERY_THROW ); 306*cdf0e10cSrcweir return xCond->getFormula1(); 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir ::rtl::OUString SAL_CALL 310*cdf0e10cSrcweir ScVbaValidation::getFormula2() throw (uno::RuntimeException) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir uno::Reference< sheet::XSheetCondition > xCond( lcl_getValidationProps( m_xRange ), uno::UNO_QUERY_THROW ); 313*cdf0e10cSrcweir return xCond->getFormula2(); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir rtl::OUString& 317*cdf0e10cSrcweir ScVbaValidation::getServiceImplName() 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaValidation") ); 320*cdf0e10cSrcweir return sImplName; 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir uno::Sequence< rtl::OUString > 324*cdf0e10cSrcweir ScVbaValidation::getServiceNames() 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir static uno::Sequence< rtl::OUString > aServiceNames; 327*cdf0e10cSrcweir if ( aServiceNames.getLength() == 0 ) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir aServiceNames.realloc( 1 ); 330*cdf0e10cSrcweir aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Validation" ) ); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir return aServiceNames; 333*cdf0e10cSrcweir } 334