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