From 1fa38d29030ae9d9751a1fbec30d8ba3263e681d Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Fri, 6 Nov 2015 17:56:19 +1000 Subject: tdf#91979: ScViewData::GetScrPos(): remove coordinates limit of 32767 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This removes the restriction for returned coodrinates from ScViewData::GetScrPos(). The reasoning is the following: 1. In the existing implementation, the limit enforcement is flawed. The routine is capable to return negative coordinates, but only positives are checked. Also, the routine code itself uses value greater than 32767 (specifically, 65535 in case of col/row exceed MAXCOL/MAXROW), that later gets truncated. 2. In case of tiled rendering, it's already possible to see the numbers greater than 32767. 3. Given that the code works for long time and produces big negatives, as well as big positives in case of tiled rendering, it's highly probable that existing code is prepared for large returned values. Another option could be additionally check for !bAllowNeg before emposing the limit Change-Id: Ie78cfe5907253e6648fed27dfac78b292922f5b4 Reviewed-on: https://gerrit.libreoffice.org/19816 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sc/qa/unit/bugfix-test.cxx | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'sc/qa/unit/bugfix-test.cxx') diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx index 0c2d43b57862..209776d2a6b0 100644 --- a/sc/qa/unit/bugfix-test.cxx +++ b/sc/qa/unit/bugfix-test.cxx @@ -47,6 +47,7 @@ #include "cellvalue.hxx" #include "attrib.hxx" #include "dpshttab.hxx" +#include "tabvwsh.hxx" #include #include #include @@ -62,6 +63,7 @@ #include #include #include +#include #include "helper/qahelper.hxx" #include "helper/shared_test_impl.hxx" @@ -82,6 +84,7 @@ public: void testTdf36933(); void testTdf43700(); void testTdf43534(); + void testTdf91979(); // void testTdf40110(); CPPUNIT_TEST_SUITE(ScFiltersTest); @@ -89,6 +92,7 @@ public: CPPUNIT_TEST(testTdf36933); CPPUNIT_TEST(testTdf43700); CPPUNIT_TEST(testTdf43534); + CPPUNIT_TEST(testTdf91979); // CPPUNIT_TEST(testTdf40110); CPPUNIT_TEST_SUITE_END(); private: @@ -167,6 +171,45 @@ void ScFiltersTest::testTdf43534() xDocSh->DoClose(); } +void ScFiltersTest::testTdf91979() +{ + uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(::comphelper::getProcessComponentContext()); + CPPUNIT_ASSERT(xDesktop.is()); + + Sequence < beans::PropertyValue > args(1); + args[0].Name = "Hidden"; + args[0].Value <<= sal_True; + + uno::Reference< lang::XComponent > xComponent = xDesktop->loadComponentFromURL( + "private:factory/scalc", + "_blank", + 0, + args); + CPPUNIT_ASSERT(xComponent.is()); + + // Get the document model + SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent); + CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); + + ScDocShellRef xDocSh = dynamic_cast(pFoundShell); + CPPUNIT_ASSERT(xDocSh != NULL); + + // Get the document controller + ScTabViewShell* pViewShell = xDocSh->GetBestViewShell(false); + CPPUNIT_ASSERT(pViewShell != NULL); + auto& aViewData = pViewShell->GetViewData(); + auto* pDoc = aViewData.GetDocument(); + + // Check coordinates of a distant cell + Point aPos = aViewData.GetScrPos(MAXCOL - 1, 10000, SC_SPLIT_TOPLEFT, true); + int nColWidth = aViewData.ToPixel(pDoc->GetColWidth(0, 0), aViewData.GetPPTX()); + int nRowHeight = aViewData.ToPixel(pDoc->GetRowHeight(0, 0), aViewData.GetPPTY()); + CPPUNIT_ASSERT(aPos.getX() == (MAXCOL - 1) * nColWidth); + CPPUNIT_ASSERT(aPos.getY() == 10000 * nRowHeight); + + xDocSh->DoClose(); +} + /* void ScFiltersTest::testTdf40110() { -- cgit