22#include <com/sun/star/sheet/XSheetCondition.hpp>
23#include <com/sun/star/sheet/ValidationType.hpp>
24#include <com/sun/star/sheet/ValidationAlertStyle.hpp>
25#include <com/sun/star/table/XCellRange.hpp>
26#include <com/sun/star/beans/XPropertySet.hpp>
27#include <ooo/vba/excel/XlDVType.hpp>
28#include <ooo/vba/excel/XlDVAlertStyle.hpp>
30#include <unonames.hxx>
39lcl_setValidationProps(
const uno::Reference< table::XCellRange >& xRange,
const uno::Reference< beans::XPropertySet >& xProps )
41 uno::Reference< beans::XPropertySet > xRangeProps( xRange, uno::UNO_QUERY_THROW );
45static uno::Reference< beans::XPropertySet >
48 uno::Reference< beans::XPropertySet > xProps( xRange, uno::UNO_QUERY_THROW );
49 uno::Reference< beans::XPropertySet > xValProps;
75 sal_Int32 nShowList = 0;
77 return nShowList != 0;
83 sal_Int32 nDropDown = 0;
84 if ( _incelldropdown )
95 bool bShowInput =
false;
112 bool bShowError =
false;
129 OUString sErrorTitle;
198 uno::Reference< sheet::XSheetCondition > xCond( xProps, uno::UNO_QUERY_THROW );
206 xCond->setFormula1( sBlank );
207 xCond->setFormula2( sBlank );
208 xCond->setOperator( sheet::ConditionOperator_NONE );
218 uno::Reference< sheet::XSheetCondition > xCond( xProps, uno::UNO_QUERY_THROW );
220 sheet::ValidationType nValType = sheet::ValidationType_ANY;
222 if ( nValType != sheet::ValidationType_ANY )
223 throw uno::RuntimeException(
"validation object already exists" );
224 sal_Int32
nType = -1;
226 throw uno::RuntimeException(
"missing required param" );
230 Formula1 >>= sFormula1;
232 Formula2 >>= sFormula2;
235 case excel::XlDVType::xlValidateList:
240 throw uno::RuntimeException(
"missing param" );
241 nValType = sheet::ValidationType_LIST;
247 case excel::XlDVType::xlValidateWholeNumber:
248 nValType = sheet::ValidationType_WHOLE;
252 throw uno::RuntimeException(
"unsupported operation..." );
255 sheet::ValidationAlertStyle eStyle = sheet::ValidationAlertStyle_STOP;
256 sal_Int32 nVbaAlertStyle = excel::XlDVAlertStyle::xlValidAlertStop;
257 if ( AlertStyle.
hasValue() && ( AlertStyle >>= nVbaAlertStyle ) )
259 switch( nVbaAlertStyle )
261 case excel::XlDVAlertStyle::xlValidAlertStop:
264 eStyle = sheet::ValidationAlertStyle_STOP;
266 case excel::XlDVAlertStyle::xlValidAlertWarning:
267 eStyle = sheet::ValidationAlertStyle_WARNING;
269 case excel::XlDVAlertStyle::xlValidAlertInformation:
270 eStyle = sheet::ValidationAlertStyle_INFO;
273 throw uno::RuntimeException(
"bad param..." );
285 xCond->setOperator( conOperator );
288 if ( !sFormula1.isEmpty() )
289 xCond->setFormula1( sFormula1 );
290 if ( !sFormula2.isEmpty() )
291 xCond->setFormula2( sFormula2 );
300 OUString sString = xCond->getFormula1();
312 sString =
"=" + sString;
320 return xCond->getFormula2();
327 sheet::ValidationType nValType = sheet::ValidationType_ANY;
329 sal_Int32 nExcelType = excel::XlDVType::xlValidateList;
334 case sheet::ValidationType_LIST:
335 nExcelType = excel::XlDVType::xlValidateList;
337 case sheet::ValidationType_ANY:
338 nExcelType = excel::XlDVType::xlValidateInputOnly;
340 case sheet::ValidationType_CUSTOM:
341 nExcelType = excel::XlDVType::xlValidateCustom;
343 case sheet::ValidationType_WHOLE:
344 nExcelType = excel::XlDVType::xlValidateWholeNumber;
346 case sheet::ValidationType_DECIMAL:
347 nExcelType = excel::XlDVType::xlValidateDecimal;
349 case sheet::ValidationType_DATE:
350 nExcelType = excel::XlDVType::xlValidateDate;
352 case sheet::ValidationType_TIME:
353 nExcelType = excel::XlDVType::xlValidateTime;
355 case sheet::ValidationType_TEXT_LEN:
356 nExcelType = excel::XlDVType::xlValidateTextLength;
358 case sheet::ValidationType::ValidationType_MAKE_FIXED_SIZE:
369 return "ScVbaValidation";
372uno::Sequence< OUString >
377 "ooo.vba.excel.Validation"
static css::sheet::ConditionOperator retrieveAPIOperator(const css::uno::Any &_aOperator)
static bool getCellRangesForAddress(ScRefFlags &rResFlags, std::u16string_view sAddress, ScDocShell *pDocSh, ScRangeList &rCellRanges, formula::FormulaGrammar::AddressConvention eConv, char cDelimiter)
virtual sal_Bool SAL_CALL getShowError() override
virtual sal_Bool SAL_CALL getIgnoreBlank() override
virtual sal_Bool SAL_CALL getInCellDropdown() override
virtual OUString SAL_CALL getErrorMessage() override
virtual void SAL_CALL Add(const css::uno::Any &Type, const css::uno::Any &AlertStyle, const css::uno::Any &Operator, const css::uno::Any &Formula1, const css::uno::Any &Formula2) override
virtual OUString SAL_CALL getInputTitle() override
virtual void SAL_CALL Delete() override
css::uno::Reference< css::table::XCellRange > m_xRange
virtual OUString SAL_CALL getFormula2() override
virtual OUString SAL_CALL getInputMessage() override
virtual OUString getServiceImplName() override
virtual void SAL_CALL setErrorTitle(const OUString &_errortitle) override
virtual void SAL_CALL setInCellDropdown(sal_Bool _incelldropdown) override
virtual OUString SAL_CALL getFormula1() override
virtual void SAL_CALL setIgnoreBlank(sal_Bool _ignoreblank) override
virtual void SAL_CALL setInputTitle(const OUString &_inputtitle) override
virtual void SAL_CALL setShowError(sal_Bool _showerror) override
virtual sal_Int32 SAL_CALL getType() override
virtual void SAL_CALL setErrorMessage(const OUString &_errormessage) override
virtual sal_Bool SAL_CALL getShowInput() override
virtual OUString SAL_CALL getErrorTitle() override
virtual void SAL_CALL setInputMessage(const OUString &_inputmessage) override
virtual void SAL_CALL setShowInput(sal_Bool _showinput) override
virtual css::uno::Sequence< OUString > getServiceNames() override
Sequence< OUString > aServiceNames
ScDocShell * GetDocShellFromRange(const uno::Reference< uno::XInterface > &xRange)
constexpr OUStringLiteral SC_UNONAME_VALIDAT
constexpr OUStringLiteral SC_UNONAME_SHOWINP
constexpr OUStringLiteral SC_UNONAME_SHOWERR
constexpr OUStringLiteral SC_UNONAME_IGNOREBL
constexpr OUStringLiteral SC_UNONAME_ERRALSTY
constexpr OUStringLiteral SC_UNONAME_TYPE
constexpr OUStringLiteral SC_UNONAME_INPMESS
constexpr OUStringLiteral SC_UNONAME_ERRTITLE
constexpr OUStringLiteral SC_UNONAME_ERRMESS
constexpr OUStringLiteral SC_UNONAME_SHOWLIST
constexpr OUStringLiteral SC_UNONAME_INPTITLE
static void lcl_setValidationProps(const uno::Reference< table::XCellRange > &xRange, const uno::Reference< beans::XPropertySet > &xProps)
static uno::Reference< beans::XPropertySet > lcl_getValidationProps(const uno::Reference< table::XCellRange > &xRange)