|
17 | 17 | #include <document.hxx>
|
18 | 18 | #include <scitems.hxx>
|
19 | 19 |
|
| 20 | +#include <com/sun/star/sheet/XCellRangeAddressable.hpp> |
| 21 | +#include <com/sun/star/sheet/XCellRangeMovement.hpp> |
20 | 22 | #include <com/sun/star/sheet/XFunctionAccess.hpp>
|
21 | 23 | #include <com/sun/star/sheet/XSpreadsheet.hpp>
|
| 24 | +#include <com/sun/star/table/XColumnRowRange.hpp> |
22 | 25 |
|
23 | 26 | #include <com/sun/star/script/XLibraryContainerPassword.hpp>
|
24 | 27 | #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
|
@@ -919,6 +922,60 @@ CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf159412)
|
919 | 922 | CPPUNIT_ASSERT_EQUAL(u"1 Long/2 Double"_ustr, aReturnValue);
|
920 | 923 | }
|
921 | 924 |
|
| 925 | +CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf47479) |
| 926 | +{ |
| 927 | + createScDoc(); |
| 928 | + uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW); |
| 929 | + auto xSheets = xDoc->getSheets().queryThrow<container::XIndexAccess>(); |
| 930 | + auto xSheet = xSheets->getByIndex(0).queryThrow<sheet::XCellRangeMovement>(); |
| 931 | + auto xSheetAddressable = xSheet.queryThrow<sheet::XCellRangeAddressable>(); |
| 932 | + auto xColRowRange = xSheet.queryThrow<table::XColumnRowRange>(); |
| 933 | + auto xColAddressable |
| 934 | + = xColRowRange->getColumns()->getByIndex(1).queryThrow<sheet::XCellRangeAddressable>(); |
| 935 | + auto xRowAddressable |
| 936 | + = xColRowRange->getRows()->getByIndex(1).queryThrow<sheet::XCellRangeAddressable>(); |
| 937 | + css::table::CellRangeAddress origSheetRange = xSheetAddressable->getRangeAddress(); |
| 938 | + css::table::CellRangeAddress origColRange = xColAddressable->getRangeAddress(); |
| 939 | + css::table::CellRangeAddress origRowRange = xRowAddressable->getRangeAddress(); |
| 940 | + css::table::CellRangeAddress addressToRemove(origSheetRange.Sheet, 1, 1, 1, 1); |
| 941 | + |
| 942 | + xSheet->removeRange(addressToRemove, css::sheet::CellDeleteMode_UP); |
| 943 | + |
| 944 | + auto currentRange = xSheetAddressable->getRangeAddress(); |
| 945 | + CPPUNIT_ASSERT_EQUAL(origSheetRange.Sheet, currentRange.Sheet); |
| 946 | + CPPUNIT_ASSERT_EQUAL(origSheetRange.StartColumn, currentRange.StartColumn); |
| 947 | + CPPUNIT_ASSERT_EQUAL(origSheetRange.StartRow, currentRange.StartRow); |
| 948 | + CPPUNIT_ASSERT_EQUAL(origSheetRange.EndColumn, currentRange.EndColumn); |
| 949 | + // Without the fix, this would fail with |
| 950 | + // - Expected: 1048575 |
| 951 | + // - Actual : 0 |
| 952 | + CPPUNIT_ASSERT_EQUAL(origSheetRange.EndRow, currentRange.EndRow); |
| 953 | + |
| 954 | + xSheet->removeRange(addressToRemove, css::sheet::CellDeleteMode_LEFT); |
| 955 | + |
| 956 | + currentRange = xColAddressable->getRangeAddress(); |
| 957 | + CPPUNIT_ASSERT_EQUAL(origColRange.Sheet, currentRange.Sheet); |
| 958 | + CPPUNIT_ASSERT_EQUAL(origColRange.StartColumn, currentRange.StartColumn); |
| 959 | + // Without the fix, this would fail with |
| 960 | + // - Expected: 0 |
| 961 | + // - Actual : 2 |
| 962 | + CPPUNIT_ASSERT_EQUAL(origColRange.StartRow, currentRange.StartRow); |
| 963 | + CPPUNIT_ASSERT_EQUAL(origColRange.EndColumn, currentRange.EndColumn); |
| 964 | + CPPUNIT_ASSERT_EQUAL(origColRange.EndRow, currentRange.EndRow); |
| 965 | + |
| 966 | + xSheet->removeRange(origColRange, css::sheet::CellDeleteMode_UP); |
| 967 | + |
| 968 | + currentRange = xRowAddressable->getRangeAddress(); |
| 969 | + CPPUNIT_ASSERT_EQUAL(origRowRange.Sheet, currentRange.Sheet); |
| 970 | + // Without the fix, this would fail with |
| 971 | + // - Expected: 0 |
| 972 | + // - Actual : 2 |
| 973 | + CPPUNIT_ASSERT_EQUAL(origRowRange.StartColumn, currentRange.StartColumn); |
| 974 | + CPPUNIT_ASSERT_EQUAL(origRowRange.StartRow, currentRange.StartRow); |
| 975 | + CPPUNIT_ASSERT_EQUAL(origRowRange.EndColumn, currentRange.EndColumn); |
| 976 | + CPPUNIT_ASSERT_EQUAL(origRowRange.EndRow, currentRange.EndRow); |
| 977 | +} |
| 978 | + |
922 | 979 | ScMacrosTest::ScMacrosTest()
|
923 | 980 | : ScModelTestBase(u"/sc/qa/extras/testdocuments"_ustr)
|
924 | 981 | {
|
|
0 commit comments