12#include <com/sun/star/beans/XPropertySet.hpp>
13#include <com/sun/star/drawing/XDrawPage.hpp>
14#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
15#include <com/sun/star/sheet/XSheetAuditing.hpp>
16#include <com/sun/star/sheet/XSpreadsheet.hpp>
17#include <com/sun/star/sheet/ValidationType.hpp>
18#include <com/sun/star/table/CellAddress.hpp>
19#include <com/sun/star/table/XCell.hpp>
20#include <com/sun/star/text/XText.hpp>
21#include <com/sun/star/uno/Any.hxx>
22#include <com/sun/star/uno/Reference.hxx>
24#include <cppunit/TestAssert.h>
27using namespace css::uno;
33 uno::Reference<sheet::XSheetAuditing> xAuditing(
init(), UNO_QUERY_THROW);
35 uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
36 uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
37 const sal_Int32
nElements = xDrawPage->getCount();
39 xAuditing->showDependents(table::CellAddress(0, 8, 6));
40 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to showDependents()",
nElements + 1,
41 xDrawPage->getCount());
43 xAuditing->hideDependents(table::CellAddress(0, 8, 6));
44 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to hideDependents()",
nElements, xDrawPage->getCount());
49 uno::Reference<sheet::XSheetAuditing> xAuditing(
init(), UNO_QUERY_THROW);
51 uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
52 uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
53 const sal_Int32
nElements = xDrawPage->getCount();
55 xAuditing->showPrecedents(table::CellAddress(0, 8, 6));
56 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to showPrecedents()",
nElements + 2,
57 xDrawPage->getCount());
59 xAuditing->hidePrecedents(table::CellAddress(0, 8, 6));
60 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to showPrecedents()",
nElements, xDrawPage->getCount());
65 uno::Reference<sheet::XSheetAuditing> xAuditing(
init(), UNO_QUERY_THROW);
67 uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
68 uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
69 const sal_Int32
nElements = xDrawPage->getCount();
71 xAuditing->showPrecedents(table::CellAddress(0, 8, 6));
72 xAuditing->showDependents(table::CellAddress(0, 8, 6));
73 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to set arrows",
nElements + 3, xDrawPage->getCount());
75 xAuditing->clearArrows();
76 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to clear arrows",
nElements, xDrawPage->getCount());
81 uno::Reference<sheet::XSheetAuditing> xAuditing(
init(), UNO_QUERY_THROW);
83 uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
84 uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
85 const sal_Int32
nElements = xDrawPage->getCount();
87 uno::Reference<sheet::XSpreadsheet> xSheet(xAuditing, UNO_QUERY_THROW);
88 uno::Reference<table::XCell> xCell = xSheet->getCellByPosition(7, 6);
90 xCell->setFormula(
"=SQRT(" + OUStringChar(
static_cast<char>(
'A' + 7)) + OUString::number(7)
93 uno::Reference<text::XText> xText(xCell, UNO_QUERY_THROW);
94 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"No error code", OUString(
"Err:522"), xText->getString());
96 xAuditing->showErrors(table::CellAddress(0, 7, 6));
97 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to show errors",
nElements + 1, xDrawPage->getCount());
102 uno::Reference<sheet::XSheetAuditing> xAuditing(
init(), UNO_QUERY_THROW);
104 uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
105 uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
106 const sal_Int32
nElements = xDrawPage->getCount();
108 uno::Reference<sheet::XSpreadsheet> xSheet(xAuditing, UNO_QUERY_THROW);
109 uno::Reference<table::XCell> xCell = xSheet->getCellByPosition(7, 6);
110 xCell->setValue(2.5);
112 uno::Reference<beans::XPropertySet> xPropSet(xCell, UNO_QUERY_THROW);
113 uno::Any aValidation = xPropSet->getPropertyValue(
"Validation");
114 uno::Reference<beans::XPropertySet> xValidation(aValidation, UNO_QUERY_THROW);
117 aAny <<= sheet::ValidationType_WHOLE;
118 xValidation->setPropertyValue(
"Type", aAny);
119 aAny <<= xValidation;
120 xPropSet->setPropertyValue(
"Validation", aAny);
121 xAuditing->showInvalid();
122 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to show invalid (WHOLE)",
nElements + 1,
123 xDrawPage->getCount());
125 xAuditing->clearArrows();
127 aAny <<= sheet::ValidationType_ANY;
128 xValidation->setPropertyValue(
"Type", aAny);
129 aAny <<= xValidation;
130 xPropSet->setPropertyValue(
"Validation", aAny);
132 xAuditing->showInvalid();
133 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Unable to show invalid (ANY)",
nElements, xDrawPage->getCount());
virtual css::uno::Reference< css::uno::XInterface > init()=0
void testShowHidePrecedents()
void testShowHideDependents()