[Libreoffice-commits] core.git: 2 commits - desktop/qa sc/source
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Wed Nov 6 00:21:06 UTC 2019
desktop/qa/desktop_lib/test_desktop_lib.cxx | 2 -
sc/source/ui/inc/viewdata.hxx | 4 ++
sc/source/ui/view/gridwin.cxx | 7 +----
sc/source/ui/view/gridwin4.cxx | 3 --
sc/source/ui/view/tabview.cxx | 39 ++++++++++++++--------------
sc/source/ui/view/viewdata.cxx | 24 ++++++++---------
6 files changed, 39 insertions(+), 40 deletions(-)
New commits:
commit 05b72d7dc26080b2e97cbe76d08478926b20947e
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Fri Nov 1 15:40:43 2019 +0000
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed Nov 6 01:19:28 2019 +0100
sc lok: cope with non 100% zoom better.
Do the tile rendering and alignment ourselves. More work required
to get cleaner conversion between view and document twips (view
twips being rounded to produce nice round pixel sizes when
re-converted).
Change-Id: I51edb186cfd2dc434005cc074f4ed8de19c85cb3
Reviewed-on: https://gerrit.libreoffice.org/82092
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 52da7fba5c5b..24dd5e69a275 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -161,13 +161,15 @@ class ScBoundsProvider
const bool bColumnHeader;
const index_type MAX_INDEX;
+ double mfPPTX;
+ double mfPPTY;
index_type nFirstIndex;
index_type nSecondIndex;
long nFirstPositionPx;
long nSecondPositionPx;
public:
- ScBoundsProvider(ScDocument* pD, SCTAB nT, bool bColumnHeader);
+ ScBoundsProvider(const ScViewData &rView, SCTAB nT, bool bColumnHeader);
void GetStartIndexAndPosition(SCCOL& nIndex, long& nPosition) const;
void GetEndIndexAndPosition(SCCOL& nIndex, long& nPosition) const;
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 9f924931b09b..acaa81842a97 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1086,7 +1086,6 @@ namespace
const bool bColumnHeader = std::is_same<IndexType, SCCOL>::value;
SCTAB nTab = pViewData->GetTabNo();
- ScDocument* pDoc = pViewData->GetDocument();
IndexType nStartIndex = -1;
IndexType nEndIndex = -1;
@@ -1098,7 +1097,7 @@ namespace
const auto& rStartNearest = rPositionHelper.getNearestByPosition(nTileStartPosPx);
const auto& rEndNearest = rPositionHelper.getNearestByPosition(nTileEndPosPx);
- ScBoundsProvider aBoundsProvider(pDoc, nTab, bColumnHeader);
+ ScBoundsProvider aBoundsProvider(*pViewData, nTab, bColumnHeader);
aBoundsProvider.Compute(rStartNearest, rEndNearest, nTileStartPosPx, nTileEndPosPx);
aBoundsProvider.GetStartIndexAndPosition(nStartIndex, nStartPosPx); ++nStartIndex;
aBoundsProvider.GetEndIndexAndPosition(nEndIndex, nEndPosPx);
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 807dc27d4993..ff0dc196d82f 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2310,16 +2310,16 @@ void ScTabView::SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<ed
namespace
{
-long lcl_GetRowHeightPx(const ScDocument* pDoc, SCROW nRow, SCTAB nTab)
+long lcl_GetRowHeightPx(const ScViewData &rViewData, SCROW nRow, SCTAB nTab)
{
- const sal_uInt16 nSize = pDoc->GetRowHeight(nRow, nTab);
- return ScViewData::ToPixel(nSize, 1.0 / TWIPS_PER_PIXEL);
+ const sal_uInt16 nSize = rViewData.GetDocument()->GetRowHeight(nRow, nTab);
+ return ScViewData::ToPixel(nSize, rViewData.GetPPTY());
}
-long lcl_GetColWidthPx(const ScDocument* pDoc, SCCOL nCol, SCTAB nTab)
+long lcl_GetColWidthPx(const ScViewData &rViewData, SCCOL nCol, SCTAB nTab)
{
- const sal_uInt16 nSize = pDoc->GetColWidth(nCol, nTab);
- return ScViewData::ToPixel(nSize, 1.0 / TWIPS_PER_PIXEL);
+ const sal_uInt16 nSize = rViewData.GetDocument()->GetColWidth(nCol, nTab);
+ return ScViewData::ToPixel(nSize, rViewData.GetPPTX());
}
void lcl_getGroupIndexes(const ScOutlineArray& rArray, SCCOLROW nStart, SCCOLROW nEnd, std::vector<size_t>& rGroupIndexes)
@@ -2495,13 +2495,13 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
{
SAL_INFO("sc.lok.header", "Row Header: compute start/end rows.");
long nEndHeightPx = 0;
- long nRectTopPx = rRectangle.Top() / TWIPS_PER_PIXEL;
- long nRectBottomPx = rRectangle.Bottom() / TWIPS_PER_PIXEL;
+ long nRectTopPx = rRectangle.Top() * aViewData.GetPPTX();
+ long nRectBottomPx = rRectangle.Bottom() * aViewData.GetPPTY();
const auto& rTopNearest = aViewData.GetLOKHeightHelper().getNearestByPosition(nRectTopPx);
const auto& rBottomNearest = aViewData.GetLOKHeightHelper().getNearestByPosition(nRectBottomPx);
- ScBoundsProvider aBoundingRowsProvider(pDoc, nTab, /*bColumnHeader: */ false);
+ ScBoundsProvider aBoundingRowsProvider(aViewData, nTab, /*bColumnHeader: */ false);
aBoundingRowsProvider.Compute(rTopNearest, rBottomNearest, nRectTopPx, nRectBottomPx);
aBoundingRowsProvider.EnlargeBy(2);
aBoundingRowsProvider.GetStartIndexAndPosition(nStartRow, nStartHeightPx);
@@ -2591,7 +2591,7 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
{
OUString aText = OUString::number(nStartRow + 1);
aBuffer.append("{ \"text\": \"").append(aText).append("\", ");
- aBuffer.append("\"size\": \"").append(OUString::number(nTotalPixels * TWIPS_PER_PIXEL)).append("\", ");
+ aBuffer.append("\"size\": \"").append(OUString::number(nTotalPixels / aViewData.GetPPTX())).append("\", ");
aBuffer.append("\"groupLevels\": \"").append(OUString::number(nRowGroupDepth)).append("\" }");
}
@@ -2601,14 +2601,15 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
for (SCROW nRow = nStartRow + 1; nRow <= nEndRow; ++nRow)
{
// nSize will be 0 for hidden rows.
- const long nSizePx = lcl_GetRowHeightPx(pDoc, nRow, nTab);
+ const long nSizePx = lcl_GetRowHeightPx(aViewData, nRow, nTab);
nTotalPixels += nSizePx;
- const long nTotalTwips = nTotalPixels * TWIPS_PER_PIXEL;
+ const long nTotalTwips = nTotalPixels / aViewData.GetPPTY();
if (bRangeHeaderSupport && nRowGroupDepth > 0)
{
lcl_createGroupsData(nRow, nEndRow, nSizePx, nTotalTwips,
- *pRowArray, aRowGroupIndexes, aRowGroupStartPositions, aRowGroupsBuffer);
+ *pRowArray, aRowGroupIndexes, aRowGroupStartPositions,
+ aRowGroupsBuffer);
}
if (bRangeHeaderSupport && nRow < nEndRow && nSizePx == nPrevSizePx)
@@ -2638,13 +2639,13 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
{
SAL_INFO("sc.lok.header", "Column Header: compute start/end columns.");
long nEndWidthPx = 0;
- long nRectLeftPx = rRectangle.Left() / TWIPS_PER_PIXEL;
- long nRectRightPx = rRectangle.Right() / TWIPS_PER_PIXEL;
+ long nRectLeftPx = rRectangle.Left() * aViewData.GetPPTX();
+ long nRectRightPx = rRectangle.Right() * aViewData.GetPPTY();
const auto& rLeftNearest = aViewData.GetLOKWidthHelper().getNearestByPosition(nRectLeftPx);
const auto& rRightNearest = aViewData.GetLOKWidthHelper().getNearestByPosition(nRectRightPx);
- ScBoundsProvider aBoundingColsProvider(pDoc, nTab, /*bColumnHeader: */ true);
+ ScBoundsProvider aBoundingColsProvider(aViewData, nTab, /*bColumnHeader: */ true);
aBoundingColsProvider.Compute(rLeftNearest, rRightNearest, nRectLeftPx, nRectRightPx);
aBoundingColsProvider.EnlargeBy(2);
aBoundingColsProvider.GetStartIndexAndPosition(nStartCol, nStartWidthPx);
@@ -2734,7 +2735,7 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
{
OUString aText = OUString::number(nStartCol + 1);
aBuffer.append("{ \"text\": \"").append(aText).append("\", ");
- aBuffer.append("\"size\": \"").append(OUString::number(nTotalPixels * TWIPS_PER_PIXEL)).append("\", ");
+ aBuffer.append("\"size\": \"").append(OUString::number(nTotalPixels / aViewData.GetPPTY())).append("\", ");
aBuffer.append("\"groupLevels\": \"").append(OUString::number(nColGroupDepth)).append("\" }");
}
@@ -2744,9 +2745,9 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
for (SCCOL nCol = nStartCol + 1; nCol <= nEndCol; ++nCol)
{
// nSize will be 0 for hidden columns.
- const long nSizePx = lcl_GetColWidthPx(pDoc, nCol, nTab);
+ const long nSizePx = lcl_GetColWidthPx(aViewData, nCol, nTab);
nTotalPixels += nSizePx;
- const long nTotalTwips = nTotalPixels * TWIPS_PER_PIXEL;
+ const long nTotalTwips = nTotalPixels / aViewData.GetPPTY();
if (bRangeHeaderSupport && nColGroupDepth > 0)
{
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 0eb317ff1eca..97dbaacfac2a 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -280,11 +280,13 @@ long ScPositionHelper::computePosition(index_type nIndex, const std::function<lo
return nTotalPixels;
}
-ScBoundsProvider::ScBoundsProvider(ScDocument* pD, SCTAB nT, bool bColHeader)
- : pDoc(pD)
+ScBoundsProvider::ScBoundsProvider(const ScViewData &rView, SCTAB nT, bool bColHeader)
+ : pDoc(rView.GetDocument())
, nTab(nT)
, bColumnHeader(bColHeader)
- , MAX_INDEX(bColHeader ? pD->MaxCol() : MAXTILEDROW)
+ , MAX_INDEX(bColHeader ? pDoc->MaxCol() : MAXTILEDROW)
+ , mfPPTX(rView.GetPPTX())
+ , mfPPTY(rView.GetPPTY())
, nFirstIndex(-1)
, nSecondIndex(-1)
, nFirstPositionPx(-1)
@@ -322,7 +324,7 @@ void ScBoundsProvider::GetEndIndexAndPosition(SCROW& nIndex, long& nPosition) co
long ScBoundsProvider::GetSize(index_type nIndex) const
{
const sal_uInt16 nSize = bColumnHeader ? pDoc->GetColWidth(nIndex, nTab) : pDoc->GetRowHeight(nIndex, nTab);
- return ScViewData::ToPixel(nSize, 1.0 / TWIPS_PER_PIXEL);
+ return ScViewData::ToPixel(nSize, bColumnHeader ? mfPPTX : mfPPTY);
}
void ScBoundsProvider::GetIndexAndPos(index_type nNearestIndex, long nNearestPosition,
@@ -1372,10 +1374,9 @@ void ScViewData::SetMaxTiledCol( SCCOL nNewMaxCol )
nNewMaxCol = pDoc->MaxCol();
const SCTAB nTab = GetTabNo();
- ScDocument* pThisDoc = pDoc;
- auto GetColWidthPx = [pThisDoc, nTab](SCCOL nCol) {
- const sal_uInt16 nSize = pThisDoc->GetColWidth(nCol, nTab);
- const long nSizePx = ScViewData::ToPixel(nSize, 1.0 / TWIPS_PER_PIXEL);
+ auto GetColWidthPx = [this, nTab](SCCOL nCol) {
+ const sal_uInt16 nSize = this->pDoc->GetColWidth(nCol, nTab);
+ const long nSizePx = ScViewData::ToPixel(nSize, nPPTX);
return nSizePx;
};
@@ -1398,10 +1399,9 @@ void ScViewData::SetMaxTiledRow( SCROW nNewMaxRow )
nNewMaxRow = MAXTILEDROW;
const SCTAB nTab = GetTabNo();
- ScDocument* pThisDoc = pDoc;
- auto GetRowHeightPx = [pThisDoc, nTab](SCROW nRow) {
- const sal_uInt16 nSize = pThisDoc->GetRowHeight(nRow, nTab);
- const long nSizePx = ScViewData::ToPixel(nSize, 1.0 / TWIPS_PER_PIXEL);
+ auto GetRowHeightPx = [this, nTab](SCROW nRow) {
+ const sal_uInt16 nSize = this->pDoc->GetRowHeight(nRow, nTab);
+ const long nSizePx = ScViewData::ToPixel(nSize, nPPTY);
return nSizePx;
};
commit 56b11c503cbc4a42b604821a8701408d59a7f744
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon Oct 28 21:39:14 2019 +0000
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed Nov 6 01:19:18 2019 +0100
Revert "lok: sc: make hi-dpi/zoom compatible with retrieving cell cursor"
This reverts commit e3ff84aed5be8e0d2780d80b178fa8fc0e388859.
Change-Id: I174dd54cf7b44f12c90c61882814b6dee9be9b7c
Reviewed-on: https://gerrit.libreoffice.org/82089
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Tested-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 49a26253b388..8200c7e1c859 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -813,7 +813,7 @@ void DesktopLOKTest::testCellCursor()
OString aRectangle(aTree.get<std::string>("commandValues").c_str());
// cell cursor geometry + col + row
- CPPUNIT_ASSERT_EQUAL(OString("0, 0, 1274, 254, 0, 0"), aRectangle);
+ CPPUNIT_ASSERT_EQUAL(OString("0, 0, 1279, 255, 0, 0"), aRectangle);
}
void DesktopLOKTest::testCommandResult()
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 8f5324a7cd00..0f72c2954a1b 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5675,7 +5675,7 @@ OString ScGridWindow::getCellCursor( int nOutputWidth, int nOutputHeight,
return getCellCursor(zoomX, zoomY);
}
-OString ScGridWindow::getCellCursor(const Fraction& /*rZoomX*/, const Fraction& /*rZoomY*/) const
+OString ScGridWindow::getCellCursor(const Fraction& rZoomX, const Fraction& rZoomY) const
{
// GridWindow stores a shown cell cursor in mpOOCursors, hence
// we can use that to determine whether we would want to be showing
@@ -5691,10 +5691,7 @@ OString ScGridWindow::getCellCursor(const Fraction& /*rZoomX*/, const Fraction&
Fraction defaultZoomX = pViewData->GetZoomX();
Fraction defaultZoomY = pViewData->GetZoomY();
- // hardcode to what we mean as 100% (256px tiles meaning 3840 twips)
- Fraction aFracX(long(256 * TWIPS_PER_PIXEL), 3840);
- Fraction aFracY(long(256 * TWIPS_PER_PIXEL), 3840);
- pViewData->SetZoom(aFracX, aFracY, true);
+ pViewData->SetZoom(rZoomX, rZoomY, true);
Point aScrPos = pViewData->GetScrPos( nX, nY, eWhich, true );
long nSizeXPix;
More information about the Libreoffice-commits
mailing list