[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sc/source
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Wed Nov 6 14:46:57 UTC 2019
sc/source/ui/inc/viewdata.hxx | 4 +++-
sc/source/ui/view/gridwin4.cxx | 3 +--
sc/source/ui/view/tabview.cxx | 39 ++++++++++++++++++++-------------------
sc/source/ui/view/viewdata.cxx | 22 +++++++++++-----------
4 files changed, 35 insertions(+), 33 deletions(-)
New commits:
commit 933ffa881f6180b6b2505b2a49a9f0c8fc0a13d2
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 15:45:53 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/82098
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
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 0e1a275af067..40dad1b62e69 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -159,13 +159,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 75111de74eae..a861daec3177 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1070,7 +1070,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;
@@ -1082,7 +1081,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 24794e50d57a..4904514a7f77 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)
@@ -2496,13 +2496,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);
@@ -2592,7 +2592,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("\" }");
}
@@ -2603,14 +2603,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)
@@ -2640,13 +2641,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);
@@ -2736,7 +2737,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("\" }");
}
@@ -2747,9 +2748,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 a40a70e3e6a8..8ff09126c54d 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -262,11 +262,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 ? MAXCOL : MAXTILEDROW)
+ , mfPPTX(rView.GetPPTX())
+ , mfPPTY(rView.GetPPTY())
, nFirstIndex(-1)
, nSecondIndex(-1)
, nFirstPositionPx(-1)
@@ -304,7 +306,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,
@@ -1338,10 +1340,9 @@ void ScViewData::SetMaxTiledCol( SCCOL nNewMaxCol )
nNewMaxCol = 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 = this->ToPixel(nSize, nPPTX);
return nSizePx;
};
@@ -1364,10 +1365,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 = this->ToPixel(nSize, nPPTY);
return nSizePx;
};
More information about the Libreoffice-commits
mailing list