13#include <com/sun/star/awt/Point.hpp>
14#include <com/sun/star/awt/Size.hpp>
15#include <com/sun/star/beans/XPropertySet.hpp>
16#include <com/sun/star/sheet/ValidationType.hpp>
17#include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
18#include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
19#include <com/sun/star/uno/Any.hxx>
20#include <com/sun/star/uno/Reference.hxx>
21#include <com/sun/star/uno/Sequence.hxx>
24#include <cppunit/TestAssert.h>
33 uno::Reference<beans::XPropertySet> xSheetCellRange(
init(), UNO_QUERY_THROW);
37 propName =
"Position";
38 awt::Point aPositionGet;
39 CPPUNIT_ASSERT_MESSAGE(
"Unable to get PropertyValue Position",
40 xSheetCellRange->getPropertyValue(propName) >>= aPositionGet);
42 awt::Point aPositionSet(42, 42);
43 aNewValue <<= aPositionSet;
44 xSheetCellRange->setPropertyValue(propName, aNewValue);
45 CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aPositionSet);
46 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Able to set PropertyValue Position", aPositionGet, aPositionGet);
50 CPPUNIT_ASSERT_MESSAGE(
"Unable to get PropertyValue Size",
51 xSheetCellRange->getPropertyValue(propName) >>= aSizeGet);
53 awt::Size aSizeSet(42, 42);
54 aNewValue <<= aSizeGet;
55 xSheetCellRange->setPropertyValue(propName, aNewValue);
56 CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aSizeSet);
57 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Able to set PropertyValue Size", aSizeGet, aSizeSet);
60 "StyleName", OUString(
"Result2")) };
62 propName =
"ConditionalFormat";
63 uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatGet;
64 uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatSet;
66 CPPUNIT_ASSERT_MESSAGE(
"Unable to get PropertyValue ConditionalFormat",
67 xSheetCellRange->getPropertyValue(propName) >>= aConditionalFormatGet);
69 uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatNew(aConditionalFormatGet,
71 aConditionalFormatNew->addNew(aPropValue);
73 aNewValue <<= aConditionalFormatNew;
74 xSheetCellRange->setPropertyValue(propName, aNewValue);
75 CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aConditionalFormatSet);
76 for (
auto i = 0;
i < aConditionalFormatSet->getCount();
i++)
78 uno::Reference<sheet::XSheetConditionalEntry> xSCENew(aConditionalFormatNew->getByIndex(
i),
80 uno::Reference<sheet::XSheetConditionalEntry> xSCESet(aConditionalFormatSet->getByIndex(
i),
83 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to set PropertyValue ConditionalFormat["
84 + std::to_string(
i) +
"]",
85 xSCENew->getStyleName(), xSCESet->getStyleName());
88 propName =
"ConditionalFormatLocal";
89 uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalGet;
90 uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalSet;
92 CPPUNIT_ASSERT_MESSAGE(
"Unable to get PropertyValue ConditionalFormatLocal",
93 xSheetCellRange->getPropertyValue(propName)
94 >>= aConditionalFormatLocalGet);
96 uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalNew(
97 aConditionalFormatLocalGet, UNO_SET_THROW);
98 aConditionalFormatLocalNew->addNew(aPropValue);
100 aNewValue <<= aConditionalFormatLocalNew;
101 xSheetCellRange->setPropertyValue(propName, aNewValue);
102 CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aConditionalFormatLocalSet);
103 for (
auto i = 0;
i < aConditionalFormatLocalSet->getCount();
i++)
105 uno::Reference<sheet::XSheetConditionalEntry> xSCENew(
106 aConditionalFormatLocalNew->getByIndex(
i), UNO_QUERY_THROW);
107 uno::Reference<sheet::XSheetConditionalEntry> xSCESet(
108 aConditionalFormatLocalSet->getByIndex(
i), UNO_QUERY_THROW);
110 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to set PropertyValue ConditionalFormatLocal["
111 + std::to_string(
i) +
"]",
112 xSCENew->getStyleName(), xSCESet->getStyleName());
115 propName =
"Validation";
116 uno::Reference<beans::XPropertySet> aValidationGet;
117 uno::Reference<beans::XPropertySet> aValidationSet;
119 CPPUNIT_ASSERT_MESSAGE(
"Unable to get PropertyValue Validation",
120 xSheetCellRange->getPropertyValue(propName) >>= aValidationGet);
122 uno::Reference<beans::XPropertySet> aValidationNew(aValidationGet, UNO_SET_THROW);
124 aValidationType <<= sheet::ValidationType_WHOLE;
125 aValidationNew->setPropertyValue(
"Type", aValidationType);
127 aNewValue <<= aValidationNew;
128 xSheetCellRange->setPropertyValue(propName, aNewValue);
129 CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aValidationSet);
130 sheet::ValidationType aType;
131 aValidationSet->getPropertyValue(
"Type") >>= aType;
132 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to set PropertyValue Validation",
133 sheet::ValidationType_WHOLE, aType);
135 propName =
"ValidationLocal";
136 uno::Reference<beans::XPropertySet> aValidationLocalGet;
137 uno::Reference<beans::XPropertySet> aValidationLocalSet;
139 CPPUNIT_ASSERT_MESSAGE(
"Unable to get PropertyValue ValidationLocal",
140 xSheetCellRange->getPropertyValue(propName) >>= aValidationLocalGet);
142 uno::Reference<beans::XPropertySet> aValidationLocalNew(aValidationLocalGet, UNO_SET_THROW);
143 aValidationType <<= sheet::ValidationType_WHOLE;
144 aValidationLocalNew->setPropertyValue(
"Type", aValidationType);
146 aNewValue <<= aValidationLocalNew;
147 xSheetCellRange->setPropertyValue(propName, aNewValue);
148 CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aValidationLocalSet);
149 aValidationLocalSet->getPropertyValue(
"Type") >>= aType;
150 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to set PropertyValue ValidationLocal",
151 sheet::ValidationType_WHOLE, aType);
153 propName =
"AbsoluteName";
154 OUString aAbsoluteNameGet =
"";
155 CPPUNIT_ASSERT_MESSAGE(
"Unable to get PropertyValue AbsoluteName",
156 xSheetCellRange->getPropertyValue(propName) >>= aAbsoluteNameGet);
158 OUString aAbsoluteNameSet =
"$Sheet1.$C$3";
159 aNewValue <<= aAbsoluteNameSet;
160 xSheetCellRange->setPropertyValue(propName, aNewValue);
161 CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aAbsoluteNameSet);
162 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Able to set PropertyValue AbsoluteName", aAbsoluteNameGet,
void testSheetCellRangeProperties()
virtual css::uno::Reference< css::uno::XInterface > init()=0
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)