sc/CppunitTest_sc_tiledrendering.mk | 1 sc/qa/unit/tiledrendering/data/rowheight.ods |binary sc/qa/unit/tiledrendering/tiledrendering.cxx | 31 +++++++++++++++++++++++++++ sc/source/ui/docshell/sizedev.cxx | 4 +-- sc/source/ui/inc/sizedev.hxx | 2 - sc/source/ui/inc/viewfunc.hxx | 2 - sc/source/ui/view/viewfunc.cxx | 2 - 7 files changed, 37 insertions(+), 5 deletions(-)
New commits: commit aabca62553513f41c4991998fbdf67de4b7d97a9 Author: Dennis Francis <dennis.fran...@collabora.com> AuthorDate: Mon Jan 22 19:11:25 2024 +0530 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Jan 23 10:26:19 2024 +0100 lok: sc: .uno:SetOptimalRowHeight does not work correctly because it uses ScSizeDeviceProvider uses a printer "device" with its own PPTX, PPTY for computing the optimal height which does not match with the tile rendering parameters. Conflicts: sc/qa/unit/tiledrendering/tiledrendering.cxx Change-Id: I6fb400755f82e36562fedaa74d7ad994c9e8f7a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162400 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/CppunitTest_sc_tiledrendering.mk b/sc/CppunitTest_sc_tiledrendering.mk index 960e5fa67205..604c2da9f802 100644 --- a/sc/CppunitTest_sc_tiledrendering.mk +++ b/sc/CppunitTest_sc_tiledrendering.mk @@ -44,6 +44,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_tiledrendering, \ $(eval $(call gb_CppunitTest_use_externals,sc_tiledrendering,\ boost_headers \ libxml2 \ + mdds_headers \ )) $(eval $(call gb_CppunitTest_set_include,sc_tiledrendering,\ diff --git a/sc/qa/unit/tiledrendering/data/rowheight.ods b/sc/qa/unit/tiledrendering/data/rowheight.ods new file mode 100644 index 000000000000..5f8a5278c724 Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/rowheight.ods differ diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 250caa5d5392..8b092c49c0d2 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -57,6 +57,7 @@ #include <drwlayer.hxx> #include <editutil.hxx> #include <undomanager.hxx> +#include <columnspanset.hxx> using namespace css; @@ -175,6 +176,7 @@ public: void testNoInvalidateOnSave(); void testCellMinimalInvalidations(); void testCellInvalidationDocWithExistingZoom(); + void testOptimalRowHeight(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnHeaders); @@ -252,6 +254,7 @@ public: CPPUNIT_TEST(testNoInvalidateOnSave); CPPUNIT_TEST(testCellMinimalInvalidations); CPPUNIT_TEST(testCellInvalidationDocWithExistingZoom); + CPPUNIT_TEST(testOptimalRowHeight); CPPUNIT_TEST_SUITE_END(); private: @@ -3886,6 +3889,34 @@ void ScTiledRenderingTest::testCellInvalidationDocWithExistingZoom() 50); } +void ScTiledRenderingTest::testOptimalRowHeight() +{ + ScModelObj* pModelObj = createDoc("rowheight.ods"); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current()); + CPPUNIT_ASSERT(pView); + + pModelObj->setClientVisibleArea(tools::Rectangle(0, 82545, 22290, 7380)); + pModelObj->setClientZoom(256, 256, 3072, 3072); + Scheduler::ProcessEventsToIdle(); + + constexpr SCROW nRow = 305; + pView->SetCursor(0, nRow); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Before setOptimalHeight: Row#306 height is invalid!", sal_uInt16(300), pDoc->GetRowHeight(nRow, 0)); + + std::vector<sc::ColRowSpan> aRowArr(1, sc::ColRowSpan(nRow, nRow)); + pView->SetWidthOrHeight(false, aRowArr, SC_SIZE_OPTIMAL, 0); + + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("After setOptimalHeight: Row#306 height is invalid!", sal_uInt16(504), pDoc->GetRowHeight(nRow, 0)); +} + } CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest); diff --git a/sc/source/ui/docshell/sizedev.cxx b/sc/source/ui/docshell/sizedev.cxx index c5b7e416c83c..43c9e15036de 100644 --- a/sc/source/ui/docshell/sizedev.cxx +++ b/sc/source/ui/docshell/sizedev.cxx @@ -25,10 +25,10 @@ #include <scmod.hxx> #include <inputopt.hxx> -ScSizeDeviceProvider::ScSizeDeviceProvider( ScDocShell* pDocSh ) +ScSizeDeviceProvider::ScSizeDeviceProvider( ScDocShell* pDocSh, bool bForceOwnDevice ) { bool bTextWysiwyg = SC_MOD()->GetInputOptions().GetTextWysiwyg(); - if ( bTextWysiwyg ) + if ( bTextWysiwyg && !bForceOwnDevice) { pDevice = pDocSh->GetPrinter(); bOwner = false; diff --git a/sc/source/ui/inc/sizedev.hxx b/sc/source/ui/inc/sizedev.hxx index 8bf98be8ef0e..52f2a9c319ad 100644 --- a/sc/source/ui/inc/sizedev.hxx +++ b/sc/source/ui/inc/sizedev.hxx @@ -34,7 +34,7 @@ class ScSizeDeviceProvider MapMode aOldMapMode; public: - ScSizeDeviceProvider( ScDocShell* pDocSh ); + ScSizeDeviceProvider( ScDocShell* pDocSh, bool bForceOwnDevice = false ); ~ScSizeDeviceProvider(); OutputDevice* GetDevice() const { return pDevice.get(); } diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx index f2a4111c72b1..b5b4ffec6b75 100644 --- a/sc/source/ui/inc/viewfunc.hxx +++ b/sc/source/ui/inc/viewfunc.hxx @@ -208,7 +208,7 @@ public: void DeleteContents( InsertDeleteFlags nFlags ); - void SetWidthOrHeight( + SC_DLLPUBLIC void SetWidthOrHeight( bool bWidth, const std::vector<sc::ColRowSpan>& rRanges, ScSizeMode eMode, sal_uInt16 nSizeTwips, bool bRecord = true, const ScMarkData* pMarkData = nullptr ); diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 86ec365d2a2b..bc27224324a8 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -2321,7 +2321,7 @@ void ScViewFunc::SetWidthOrHeight( Fraction aZoomX = GetViewData().GetZoomX(); Fraction aZoomY = GetViewData().GetZoomY(); - ScSizeDeviceProvider aProv(pDocSh); + ScSizeDeviceProvider aProv(pDocSh, comphelper::LibreOfficeKit::isActive() /* bForceOwnDevice */); if (aProv.IsPrinter()) { nPPTX = aProv.GetPPTX();