12#include <com/sun/star/sheet/XSpreadsheet.hpp>
13#include <com/sun/star/table/CellRangeAddress.hpp>
14#include <com/sun/star/table/XCellRange.hpp>
16#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
17#include <com/sun/star/table/TableOrientation.hpp>
19#include <com/sun/star/sheet/XSheetCellRanges.hpp>
20#include <com/sun/star/sheet/XSheetOutline.hpp>
21#include <com/sun/star/sheet/XCellRangesQuery.hpp>
23#include <cppunit/TestAssert.h>
24#include <rtl/ustring.hxx>
27using namespace css::uno;
31constexpr OUStringLiteral
colLevel1 =
u"OutlineSheet.A1:Z1";
32constexpr OUStringLiteral
colLevel2 =
u"OutlineSheet.C1:W1";
33constexpr OUStringLiteral
colLevel3 =
u"OutlineSheet.E1:U1";
34constexpr OUStringLiteral
colLevel4 =
u"OutlineSheet.G1:S1";
36constexpr OUStringLiteral
rowLevel1 =
u"OutlineSheet.A1:A30";
37constexpr OUStringLiteral
rowLevel2 =
u"OutlineSheet.A3:A27";
40 uno::Reference<sheet::XSpreadsheet>
const& xSheet,
41 const OUString& aLevelRangeString)
44 uno::Reference<table::XCellRange> aSheetRangeAccess(xSheet, UNO_QUERY_THROW);
45 uno::Reference<table::XCellRange> aLevelRange = aSheetRangeAccess->getCellRangeByName(aLevelRangeString);
47 uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(aLevelRange,UNO_QUERY_THROW);
48 uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryVisibleCells();
49 OUString aResult = xRanges->getRangeAddressesAsString();
56 uno::Reference<sheet::XSpreadsheet>
const& xSheet,
57 const OUString& aStringAddress)
60 uno::Reference< table::XCellRange > aSheetRangeAccess(xSheet, UNO_QUERY_THROW);
61 uno::Reference<table::XCellRange> aRange = aSheetRangeAccess->getCellRangeByName(aStringAddress);
63 uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(aRange, UNO_QUERY_THROW);
64 table::CellRangeAddress aLevelRangeAddress = xCellRangeAddressable->getRangeAddress();
66 return aLevelRangeAddress;
73 uno::Reference< sheet::XSpreadsheet > aSheet(
init(), UNO_QUERY_THROW);
74 uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
78 aSheetOutline->hideDetail(aLevelRangeAddress);
80 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Column level 2 not hidden",
85 aSheetOutline->hideDetail(aLevelRangeAddress);
87 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Row level 2 not hidden",
94 uno::Reference< sheet::XSpreadsheet > aSheet(
init(), UNO_QUERY_THROW);
95 uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
102 aSheetOutline->showDetail(aLevelRangeAddress);
104 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Row level 2 still hidden",
109 aSheetOutline->showDetail(aLevelRangeAddress);
111 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Column level 2 still hidden",
119 uno::Reference< sheet::XSpreadsheet > aSheet(
init(), UNO_QUERY_THROW);
120 uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
133 aSheetOutline->hideDetail(aLevel1);
134 aSheetOutline->hideDetail(aLevel2);
135 aSheetOutline->hideDetail(aLevel3);
136 aSheetOutline->hideDetail(aLevel4);
138 aSheetOutline->showLevel(2, table::TableOrientation_COLUMNS);
140 std::cout <<
" verify showLevel col apres" <<
getVisibleAddress(aSheet,
"OutlineSheet.A1:Z30") << std::endl;
145 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"testShowLevel Column", OUString(
"OutlineSheet.A1:D1"),
getVisibleAddress(aSheet,
"OutlineSheet.A1:D1"));
146 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"testShowLevel Column", OUString(
"OutlineSheet.V1:Z1"),
getVisibleAddress(aSheet,
"OutlineSheet.V1:Z1"));
189 uno::Reference< sheet::XSpreadsheet > aSheet(
init(), UNO_QUERY_THROW);
190 uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
193 OUString aNewString =
"OutlineSheet.AB1:AG1";
195 aSheetOutline->group(aLevelRangeAddress, table::TableOrientation_COLUMNS);
197 aSheetOutline->hideDetail(aLevelRangeAddress);
199 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"testGroup Column still visible",
getVisibleAddress(aSheet, aNewString), OUString());
202 aNewString =
"OutlineSheet.A50:A60";
204 aSheetOutline->group(aLevelRangeAddress, table::TableOrientation_ROWS);
206 aSheetOutline->hideDetail(aLevelRangeAddress);
208 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"testGroup Row still visible",
getVisibleAddress(aSheet, aNewString), OUString());
214 uno::Reference< sheet::XSpreadsheet > aSheet(
init(), UNO_QUERY_THROW);
215 uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
218 OUString aNewString =
"OutlineSheet.BB1:BG1";
220 aSheetOutline->group(aLevelRangeAddress, table::TableOrientation_COLUMNS);
221 aSheetOutline->hideDetail(aLevelRangeAddress);
223 aSheetOutline->ungroup(aLevelRangeAddress, table::TableOrientation_COLUMNS);
225 aSheetOutline->showDetail(aLevelRangeAddress);
228 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"testUnGroup Column becomes visible after ungroup",
getVisibleAddress(aSheet, aNewString), OUString());
231 aNewString =
"OutlineSheet.A70:A80";
233 aSheetOutline->group(aLevelRangeAddress, table::TableOrientation_ROWS);
234 aSheetOutline->hideDetail(aLevelRangeAddress);
236 aSheetOutline->ungroup(aLevelRangeAddress, table::TableOrientation_ROWS);
238 aSheetOutline->showDetail(aLevelRangeAddress);
241 CPPUNIT_ASSERT_EQUAL_MESSAGE(
"testUnGroup Row becomes visible after ungroup",
getVisibleAddress(aSheet, aNewString), OUString());
247 uno::Reference< sheet::XSpreadsheet > aSheet(
init(), UNO_QUERY_THROW);
248 uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
250 aSheetOutline->clearOutline();
253 aSheetOutline->hideDetail(aLevelRangeAddress);
255 aSheetOutline->hideDetail(aLevelRangeAddress);
virtual css::uno::Reference< css::uno::XInterface > init()=0
static table::CellRangeAddress getAddressFromRangeString(uno::Reference< sheet::XSpreadsheet > const &xSheet, const OUString &aStringAddress)
static OUString getVisibleAddress(uno::Reference< sheet::XSpreadsheet > const &xSheet, const OUString &aLevelRangeString)
constexpr OUStringLiteral colLevel3
constexpr OUStringLiteral rowLevel1
constexpr OUStringLiteral colLevel4
constexpr OUStringLiteral colLevel2
constexpr OUStringLiteral rowLevel2
constexpr OUStringLiteral colLevel1