sc/qa/unit/bugfix-test.cxx | 43 +++++++++++++++++++++++++++++++++++++++++ sc/source/ui/view/viewdata.cxx | 12 +---------- 2 files changed, 45 insertions(+), 10 deletions(-)
New commits: commit 1fa38d29030ae9d9751a1fbec30d8ba3263e681d Author: Mike Kaganski <mike.kagan...@collabora.com> Date: Fri Nov 6 17:56:19 2015 +1000 tdf#91979: ScViewData::GetScrPos(): remove coordinates limit of 32767 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 <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx index 0c2d43b..209776d 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 <scopetools.hxx> #include <columnspanset.hxx> #include <tokenstringcontext.hxx> @@ -62,6 +63,7 @@ #include <com/sun/star/text/textfield/Type.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/data/XDataReceiver.hpp> +#include <com/sun/star/frame/Desktop.hpp> #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<ScDocShell*>(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() { diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 6df608e..91272a5 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -1529,7 +1529,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, for (nX = nPosX; nX < nWhereX && (bAllowNeg || bIsTiledRendering || nScrPosX <= aScrSize.Width()); nX++) { if ( nX > MAXCOL ) - nScrPosX = 65535; + nScrPosX = 0x7FFFFFFF; else { nTSize = pDoc->GetColWidth( nX, nTabNo ); @@ -1560,7 +1560,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, for (nY = nPosY; nY < nWhereY && (bAllowNeg || bIsTiledRendering || nScrPosY <= aScrSize.Height()); nY++) { if ( nY > MAXROW ) - nScrPosY = 65535; + nScrPosY = 0x7FFFFFFF; else { nTSize = pDoc->GetRowHeight( nY, nTabNo ); @@ -1598,14 +1598,6 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, nScrPosX = aScrSize.Width() - 1 - nScrPosX; } - if (!bIsTiledRendering) - { - if (nScrPosX > 32767) - nScrPosX = 32767; - if (nScrPosY > 32767) - nScrPosY = 32767; - } - return Point( nScrPosX, nScrPosY ); }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits