12#include <com/sun/star/beans/XPropertySet.hpp>
13#include <com/sun/star/sheet/ValidationAlertStyle.hpp>
14#include <com/sun/star/sheet/ValidationType.hpp>
15#include <com/sun/star/uno/Any.hxx>
16#include <com/sun/star/uno/Reference.hxx>
18#include <cppunit/TestAssert.h>
27 uno::Reference<beans::XPropertySet> xTableValidation(
init(), UNO_QUERY_THROW);
32 uno::Any aValue = xTableValidation->getPropertyValue(propName);
33 sheet::ValidationType aValidationType;
34 aValue >>= aValidationType;
35 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to get property value Type", sheet::ValidationType_ANY,
38 aNewValue <<= sheet::ValidationType_WHOLE;
39 xTableValidation->setPropertyValue(propName, aNewValue);
40 aValue = xTableValidation->getPropertyValue(propName);
41 aValue >>= aValidationType;
42 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to set property value Type", sheet::ValidationType_WHOLE,
45 propName =
"ShowInputMessage";
46 bool aShowInputMessage =
true;
47 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowInputMessage);
48 CPPUNIT_ASSERT_MESSAGE(
"Unable to get property value ShowInputMessage", !aShowInputMessage);
51 xTableValidation->setPropertyValue(propName, aNewValue);
52 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowInputMessage);
53 CPPUNIT_ASSERT_MESSAGE(
"Unable to set property value ShowInputMessage", aShowInputMessage);
56 propName =
"InputMessage";
57 OUString aInputMessage;
58 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aInputMessage);
59 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to get property value InputMessage", OUString(
""),
62 aNewValue <<= OUString(
"UnitTest InputMessage");
63 xTableValidation->setPropertyValue(propName, aNewValue);
64 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aInputMessage);
65 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to get property value InputMessage",
66 OUString(
"UnitTest InputMessage"), aInputMessage);
69 propName =
"InputTitle";
71 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aInputTitle);
72 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to get property value InputTitle", OUString(
""),
75 aNewValue <<= OUString(
"UnitTest InputTitle");
76 xTableValidation->setPropertyValue(propName, aNewValue);
77 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aInputTitle);
78 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to get property value InputTitle",
79 OUString(
"UnitTest InputTitle"), aInputTitle);
81 propName =
"ShowErrorMessage";
82 bool aShowErrorMessage =
true;
83 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowErrorMessage);
84 CPPUNIT_ASSERT_MESSAGE(
"Unable to get property value ShowErrorMessage", !aShowErrorMessage);
87 xTableValidation->setPropertyValue(propName, aNewValue);
88 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowErrorMessage);
89 CPPUNIT_ASSERT_MESSAGE(
"Unable to set property value ShowErrorMessage", aShowErrorMessage);
92 propName =
"ErrorMessage";
93 OUString aErrorMessage;
94 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aErrorMessage);
95 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to get property value ErrorMessage", OUString(
""),
98 aNewValue <<= OUString(
"UnitTest ErrorMessage");
99 xTableValidation->setPropertyValue(propName, aNewValue);
100 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aErrorMessage);
101 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to get property value ErrorMessage",
102 OUString(
"UnitTest ErrorMessage"), aErrorMessage);
105 propName =
"ErrorTitle";
106 OUString aErrorTitle;
107 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aErrorTitle);
108 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to get property value ErrorTitle", OUString(
""),
111 aNewValue <<= OUString(
"UnitTest ErrorTitle");
112 xTableValidation->setPropertyValue(propName, aNewValue);
113 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aErrorTitle);
114 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to get property value ErrorTitle",
115 OUString(
"UnitTest ErrorTitle"), aErrorTitle);
117 propName =
"IgnoreBlankCells";
118 bool aIgnoreBlankCells =
false;
119 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aIgnoreBlankCells);
120 CPPUNIT_ASSERT_MESSAGE(
"Unable to get property value IgnoreBlankCells", aIgnoreBlankCells);
123 xTableValidation->setPropertyValue(propName, aNewValue);
124 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aIgnoreBlankCells);
125 CPPUNIT_ASSERT_MESSAGE(
"Unable to set property value IgnoreBlankCells", !aIgnoreBlankCells);
127 propName =
"ErrorAlertStyle";
128 aValue = xTableValidation->getPropertyValue(propName);
129 sheet::ValidationAlertStyle aValidationAlertStyle;
130 aValue >>= aValidationAlertStyle;
131 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to get property value ValidationAlertStyle",
132 sheet::ValidationAlertStyle_STOP, aValidationAlertStyle);
134 aNewValue <<= sheet::ValidationAlertStyle_WARNING;
135 xTableValidation->setPropertyValue(propName, aNewValue);
136 aValue = xTableValidation->getPropertyValue(propName);
137 aValue >>= aValidationAlertStyle;
138 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to set property value ValidationAlertStyle",
139 sheet::ValidationAlertStyle_WARNING, aValidationAlertStyle);
141 propName =
"ShowList";
142 sal_Int16 aShowList = 0;
143 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowList);
144 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to get property value ShowList", sal_Int16(1), aShowList);
146 aNewValue <<= sal_Int16(42);
147 xTableValidation->setPropertyValue(propName, aNewValue);
148 CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowList);
149 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to set property value ShowList", sal_Int16(42), aShowList);
virtual css::uno::Reference< css::uno::XInterface > init()=0
void testTableValidationProperties()