12#include <com/sun/star/beans/XPropertySet.hpp>
13#include <com/sun/star/sheet/ValidationType.hpp>
14#include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
15#include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
16#include <com/sun/star/uno/Any.hxx>
17#include <com/sun/star/uno/Reference.hxx>
18#include <com/sun/star/uno/Sequence.hxx>
21#include <cppunit/TestAssert.h>
30 uno::Reference<beans::XPropertySet> xSheetCellRanges(
init(), UNO_QUERY_THROW);
35 "StyleName", OUString(
"Result2")) };
37 propName =
"ConditionalFormat";
38 uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatGet;
39 uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatSet;
41 CPPUNIT_ASSERT_MESSAGE(
"Unable to get PropertyValue ConditionalFormat",
42 xSheetCellRanges->getPropertyValue(propName) >>= aConditionalFormatGet);
44 uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatNew(aConditionalFormatGet,
46 aConditionalFormatNew->addNew(aPropValue);
48 aNewValue <<= aConditionalFormatNew;
49 xSheetCellRanges->setPropertyValue(propName, aNewValue);
50 CPPUNIT_ASSERT(xSheetCellRanges->getPropertyValue(propName) >>= aConditionalFormatSet);
51 for (
auto i = 0;
i < aConditionalFormatSet->getCount();
i++)
53 uno::Reference<sheet::XSheetConditionalEntry> xSCENew(aConditionalFormatNew->getByIndex(
i),
55 uno::Reference<sheet::XSheetConditionalEntry> xSCESet(aConditionalFormatSet->getByIndex(
i),
58 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to set PropertyValue ConditionalFormat["
59 + std::to_string(
i) +
"]",
60 xSCENew->getStyleName(), xSCESet->getStyleName());
63 propName =
"ConditionalFormatLocal";
64 uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalGet;
65 uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalSet;
67 CPPUNIT_ASSERT_MESSAGE(
"Unable to get PropertyValue ConditionalFormatLocal",
68 xSheetCellRanges->getPropertyValue(propName)
69 >>= aConditionalFormatLocalGet);
71 uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalNew(
72 aConditionalFormatLocalGet, UNO_SET_THROW);
73 aConditionalFormatLocalNew->addNew(aPropValue);
75 aNewValue <<= aConditionalFormatLocalNew;
76 xSheetCellRanges->setPropertyValue(propName, aNewValue);
77 CPPUNIT_ASSERT(xSheetCellRanges->getPropertyValue(propName) >>= aConditionalFormatLocalSet);
78 for (
auto i = 0;
i < aConditionalFormatLocalSet->getCount();
i++)
80 uno::Reference<sheet::XSheetConditionalEntry> xSCENew(
81 aConditionalFormatLocalNew->getByIndex(
i), UNO_QUERY_THROW);
82 uno::Reference<sheet::XSheetConditionalEntry> xSCESet(
83 aConditionalFormatLocalSet->getByIndex(
i), UNO_QUERY_THROW);
85 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to set PropertyValue ConditionalFormatLocal["
86 + std::to_string(
i) +
"]",
87 xSCENew->getStyleName(), xSCESet->getStyleName());
90 propName =
"Validation";
91 uno::Reference<beans::XPropertySet> aValidationGet;
92 uno::Reference<beans::XPropertySet> aValidationSet;
94 CPPUNIT_ASSERT_MESSAGE(
"Unable to get PropertyValue Validation",
95 xSheetCellRanges->getPropertyValue(propName) >>= aValidationGet);
97 uno::Reference<beans::XPropertySet> aValidationNew(aValidationGet, UNO_SET_THROW);
99 aValidationType <<= sheet::ValidationType_WHOLE;
100 aValidationNew->setPropertyValue(
"Type", aValidationType);
102 aNewValue <<= aValidationNew;
103 xSheetCellRanges->setPropertyValue(propName, aNewValue);
104 CPPUNIT_ASSERT(xSheetCellRanges->getPropertyValue(propName) >>= aValidationSet);
105 sheet::ValidationType aType;
106 aValidationSet->getPropertyValue(
"Type") >>= aType;
107 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to set PropertyValue Validation",
108 sheet::ValidationType_WHOLE, aType);
110 propName =
"ValidationLocal";
111 uno::Reference<beans::XPropertySet> aValidationLocalGet;
112 uno::Reference<beans::XPropertySet> aValidationLocalSet;
114 CPPUNIT_ASSERT_MESSAGE(
"Unable to get PropertyValue ValidationLocal",
115 xSheetCellRanges->getPropertyValue(propName) >>= aValidationLocalGet);
117 uno::Reference<beans::XPropertySet> aValidationLocalNew(aValidationLocalGet, UNO_SET_THROW);
118 aValidationType <<= sheet::ValidationType_WHOLE;
119 aValidationLocalNew->setPropertyValue(
"Type", aValidationType);
121 aNewValue <<= aValidationLocalNew;
122 xSheetCellRanges->setPropertyValue(propName, aNewValue);
123 CPPUNIT_ASSERT(xSheetCellRanges->getPropertyValue(propName) >>= aValidationLocalSet);
124 aValidationLocalSet->getPropertyValue(
"Type") >>= aType;
125 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to set PropertyValue ValidationLocal",
126 sheet::ValidationType_WHOLE, aType);
128 propName =
"AbsoluteName";
129 OUString aAbsoluteNameGet =
"";
130 CPPUNIT_ASSERT_MESSAGE(
"Unable to get PropertyValue AbsoluteName",
131 xSheetCellRanges->getPropertyValue(propName) >>= aAbsoluteNameGet);
133 OUString aAbsoluteNameSet =
"$Sheet1.$C$3";
134 aNewValue <<= aAbsoluteNameSet;
135 xSheetCellRanges->setPropertyValue(propName, aNewValue);
136 CPPUNIT_ASSERT(xSheetCellRanges->getPropertyValue(propName) >>= aAbsoluteNameSet);
137 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Able to set PropertyValue AbsoluteName", aAbsoluteNameGet,
void testSheetCellRangesProperties()
virtual css::uno::Reference< css::uno::XInterface > init()=0
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)