summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2020-05-23 10:25:11 +0530
committerDennis Francis <dennis.francis@collabora.com>2020-05-25 00:39:57 +0530
commit9947021efa2481dcda99f987013ea8a0de786536 (patch)
tree6bd6fe0842b9363ed7aecb755bac6265f189c148
parent3268f8e16c6b92ee10905cc326956d4d06a33455 (diff)
lokit: move helper classes/functions to anonymous namespace
and drop static keyword from the local functions. No functional changes involved, just a pure refactor to aid an upcoming cleanup of getRowColumnHeaders() method. Change-Id: I7daafdc8f644f73d10d594cb7e0f5b25e6464ca5
-rw-r--r--sc/source/ui/view/tabview.cxx322
1 files changed, 161 insertions, 161 deletions
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index c051547b08c0..f0d272ca7895 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2432,6 +2432,167 @@ void lcl_createGroupsData(
}
}
+class ScRangeProvider
+{
+public:
+ ScRangeProvider(const tools::Rectangle& rArea, bool bInPixels,
+ ScViewData& rViewData, SCCOLROW nEnlargeX = 0,
+ SCCOLROW nEnlargeY = 0):
+ mrViewData(rViewData),
+ mnEnlargeX(nEnlargeX),
+ mnEnlargeY(nEnlargeY)
+ {
+ tools::Rectangle aAreaPx = bInPixels ? rArea :
+ tools::Rectangle(rArea.Left() * mrViewData.GetPPTX(),
+ rArea.Top() * mrViewData.GetPPTY(),
+ rArea.Right() * mrViewData.GetPPTX(),
+ rArea.Bottom() * mrViewData.GetPPTY());
+ calculateBounds(aAreaPx);
+ }
+
+ const ScRange& getCellRange() const
+ {
+ return maRange;
+ }
+
+ void getColPositions(long& rStartColPos, long& rEndColPos) const
+ {
+ rStartColPos = maBoundPositions.Left();
+ rEndColPos = maBoundPositions.Right();
+ }
+
+ void getRowPositions(long& rStartRowPos, long& rEndRowPos) const
+ {
+ rStartRowPos = maBoundPositions.Top();
+ rEndRowPos = maBoundPositions.Bottom();
+ }
+
+private:
+ void calculateBounds(const tools::Rectangle& rAreaPx)
+ {
+ long nLeftPx = 0, nRightPx = 0;
+ SCCOLROW nStartCol = -1, nEndCol = -1;
+ calculateDimensionBounds(rAreaPx.Left(), rAreaPx.Right(), true,
+ nStartCol, nEndCol, nLeftPx, nRightPx,
+ mnEnlargeX, mrViewData);
+ long nTopPx = 0, nBottomPx = 0;
+ SCCOLROW nStartRow = -1, nEndRow = -1;
+ calculateDimensionBounds(rAreaPx.Top(), rAreaPx.Bottom(), false,
+ nStartRow, nEndRow, nTopPx, nBottomPx,
+ mnEnlargeY, mrViewData);
+
+ maRange.aStart.Set(nStartCol, nStartRow, mrViewData.GetTabNo());
+ maRange.aEnd.Set(nEndCol, nEndRow, mrViewData.GetTabNo());
+
+ maBoundPositions.SetLeft(nLeftPx);
+ maBoundPositions.SetRight(nRightPx);
+ maBoundPositions.SetTop(nTopPx);
+ maBoundPositions.SetBottom(nBottomPx);
+ }
+
+ // All positions are in pixels.
+ static void calculateDimensionBounds(const long nStartPos, const long nEndPos,
+ bool bColumns, SCCOLROW& rStartIndex,
+ SCCOLROW& rEndIndex, long& rBoundStart,
+ long& rBoundEnd, SCCOLROW nEnlarge,
+ ScViewData& rViewData)
+ {
+ ScPositionHelper& rPosHelper = bColumns ? rViewData.GetLOKWidthHelper() :
+ rViewData.GetLOKHeightHelper();
+ const auto& rStartNearest = rPosHelper.getNearestByPosition(nStartPos);
+ const auto& rEndNearest = rPosHelper.getNearestByPosition(nEndPos);
+
+ ScBoundsProvider aBoundsProvider(rViewData, rViewData.GetTabNo(), bColumns);
+ aBoundsProvider.Compute(rStartNearest, rEndNearest, nStartPos, nEndPos);
+ aBoundsProvider.EnlargeBy(nEnlarge);
+ if (bColumns)
+ {
+ SCCOL nStartCol = -1, nEndCol = -1;
+ aBoundsProvider.GetStartIndexAndPosition(nStartCol, rBoundStart);
+ aBoundsProvider.GetEndIndexAndPosition(nEndCol, rBoundEnd);
+ rStartIndex = nStartCol;
+ rEndIndex = nEndCol;
+ }
+ else
+ {
+ SCROW nStartRow = -1, nEndRow = -1;
+ aBoundsProvider.GetStartIndexAndPosition(nStartRow, rBoundStart);
+ aBoundsProvider.GetEndIndexAndPosition(nEndRow, rBoundEnd);
+ rStartIndex = nStartRow;
+ rEndIndex = nEndRow;
+ }
+ }
+
+private:
+
+ ScRange maRange;
+ tools::Rectangle maBoundPositions;
+ ScViewData& mrViewData;
+ SCCOLROW mnEnlargeX;
+ SCCOLROW mnEnlargeY;
+};
+
+void lcl_ExtendTiledDimension(bool bColumn, const SCCOLROW nEnd, const SCCOLROW nExtra,
+ ScTabView& rTabView, ScViewData& rViewData)
+{
+ ScDocument* pDoc = rViewData.GetDocument();
+ // If we are approaching current max tiled row/col, signal a size changed event
+ // and invalidate the involved area
+ SCCOLROW nMaxTiledIndex = bColumn ? rViewData.GetMaxTiledCol() : rViewData.GetMaxTiledRow();
+ SCCOLROW nHardLimit = !bColumn ? MAXTILEDROW : pDoc ? pDoc->MaxCol() : MAXCOL;
+
+ if (nMaxTiledIndex >= nHardLimit)
+ return;
+
+ if (nEnd <= nMaxTiledIndex - nExtra) // No need to extend.
+ return;
+
+ ScDocShell* pDocSh = rViewData.GetDocShell();
+ ScModelObj* pModelObj = pDocSh ?
+ comphelper::getUnoTunnelImplementation<ScModelObj>( pDocSh->GetModel() ) : nullptr;
+ Size aOldSize(0, 0);
+ if (pModelObj)
+ aOldSize = pModelObj->getDocumentSize();
+
+ SCCOLROW nNewMaxTiledIndex = std::min(std::max(nEnd, nMaxTiledIndex) + nExtra, nHardLimit);
+
+ if (bColumn)
+ rViewData.SetMaxTiledCol(nNewMaxTiledIndex);
+ else
+ rViewData.SetMaxTiledRow(nNewMaxTiledIndex);
+
+ Size aNewSize(0, 0);
+ if (pModelObj)
+ aNewSize = pModelObj->getDocumentSize();
+
+ if (aOldSize == aNewSize)
+ return;
+
+ if (!pDocSh)
+ return;
+
+ // New area extended to the right/bottom of the sheet after last col/row
+ // excluding overlapping area with aNewArea
+ tools::Rectangle aNewArea = bColumn ?
+ tools::Rectangle(aOldSize.getWidth(), 0, aNewSize.getWidth(), aNewSize.getHeight()):
+ tools::Rectangle(0, aOldSize.getHeight(), aNewSize.getWidth(), aNewSize.getHeight());
+
+ // Only invalidate if spreadsheet has extended to the right or bottom
+ if ((bColumn && aNewArea.getWidth()) || (!bColumn && aNewArea.getHeight()))
+ {
+ rTabView.UpdateSelectionOverlay();
+ SfxLokHelper::notifyInvalidation(rViewData.GetViewShell(), aNewArea.toString());
+ }
+
+ // Provide size in the payload, so clients don't have to query for that.
+ std::stringstream ss;
+ ss << aNewSize.Width() << ", " << aNewSize.Height();
+ OString sSize = ss.str().c_str();
+ ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(
+ rViewData.GetViewShell()->GetCurrentDocument());
+ SfxLokHelper::notifyDocumentSizeChanged(rViewData.GetViewShell(), sSize, pModel, false);
+}
+
} // anonymous namespace
OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle)
@@ -2836,167 +2997,6 @@ OString ScTabView::getSheetGeometryData(bool bColumns, bool bRows, bool bSizes,
return getJSONString(aTree).c_str();
}
-class ScRangeProvider
-{
-public:
- ScRangeProvider(const tools::Rectangle& rArea, bool bInPixels,
- ScViewData& rViewData, SCCOLROW nEnlargeX = 0,
- SCCOLROW nEnlargeY = 0):
- mrViewData(rViewData),
- mnEnlargeX(nEnlargeX),
- mnEnlargeY(nEnlargeY)
- {
- tools::Rectangle aAreaPx = bInPixels ? rArea :
- tools::Rectangle(rArea.Left() * mrViewData.GetPPTX(),
- rArea.Top() * mrViewData.GetPPTY(),
- rArea.Right() * mrViewData.GetPPTX(),
- rArea.Bottom() * mrViewData.GetPPTY());
- calculateBounds(aAreaPx);
- }
-
- const ScRange& getCellRange() const
- {
- return maRange;
- }
-
- void getColPositions(long& rStartColPos, long& rEndColPos) const
- {
- rStartColPos = maBoundPositions.Left();
- rEndColPos = maBoundPositions.Right();
- }
-
- void getRowPositions(long& rStartRowPos, long& rEndRowPos) const
- {
- rStartRowPos = maBoundPositions.Top();
- rEndRowPos = maBoundPositions.Bottom();
- }
-
-private:
- void calculateBounds(const tools::Rectangle& rAreaPx)
- {
- long nLeftPx = 0, nRightPx = 0;
- SCCOLROW nStartCol = -1, nEndCol = -1;
- calculateDimensionBounds(rAreaPx.Left(), rAreaPx.Right(), true,
- nStartCol, nEndCol, nLeftPx, nRightPx,
- mnEnlargeX, mrViewData);
- long nTopPx = 0, nBottomPx = 0;
- SCCOLROW nStartRow = -1, nEndRow = -1;
- calculateDimensionBounds(rAreaPx.Top(), rAreaPx.Bottom(), false,
- nStartRow, nEndRow, nTopPx, nBottomPx,
- mnEnlargeY, mrViewData);
-
- maRange.aStart.Set(nStartCol, nStartRow, mrViewData.GetTabNo());
- maRange.aEnd.Set(nEndCol, nEndRow, mrViewData.GetTabNo());
-
- maBoundPositions.SetLeft(nLeftPx);
- maBoundPositions.SetRight(nRightPx);
- maBoundPositions.SetTop(nTopPx);
- maBoundPositions.SetBottom(nBottomPx);
- }
-
- // All positions are in pixels.
- static void calculateDimensionBounds(const long nStartPos, const long nEndPos,
- bool bColumns, SCCOLROW& rStartIndex,
- SCCOLROW& rEndIndex, long& rBoundStart,
- long& rBoundEnd, SCCOLROW nEnlarge,
- ScViewData& rViewData)
- {
- ScPositionHelper& rPosHelper = bColumns ? rViewData.GetLOKWidthHelper() :
- rViewData.GetLOKHeightHelper();
- const auto& rStartNearest = rPosHelper.getNearestByPosition(nStartPos);
- const auto& rEndNearest = rPosHelper.getNearestByPosition(nEndPos);
-
- ScBoundsProvider aBoundsProvider(rViewData, rViewData.GetTabNo(), bColumns);
- aBoundsProvider.Compute(rStartNearest, rEndNearest, nStartPos, nEndPos);
- aBoundsProvider.EnlargeBy(nEnlarge);
- if (bColumns)
- {
- SCCOL nStartCol = -1, nEndCol = -1;
- aBoundsProvider.GetStartIndexAndPosition(nStartCol, rBoundStart);
- aBoundsProvider.GetEndIndexAndPosition(nEndCol, rBoundEnd);
- rStartIndex = nStartCol;
- rEndIndex = nEndCol;
- }
- else
- {
- SCROW nStartRow = -1, nEndRow = -1;
- aBoundsProvider.GetStartIndexAndPosition(nStartRow, rBoundStart);
- aBoundsProvider.GetEndIndexAndPosition(nEndRow, rBoundEnd);
- rStartIndex = nStartRow;
- rEndIndex = nEndRow;
- }
- }
-
-private:
-
- ScRange maRange;
- tools::Rectangle maBoundPositions;
- ScViewData& mrViewData;
- SCCOLROW mnEnlargeX;
- SCCOLROW mnEnlargeY;
-};
-
-static void lcl_ExtendTiledDimension(bool bColumn, const SCCOLROW nEnd, const SCCOLROW nExtra,
- ScTabView& rTabView, ScViewData& rViewData)
-{
- ScDocument* pDoc = rViewData.GetDocument();
- // If we are approaching current max tiled row/col, signal a size changed event
- // and invalidate the involved area
- SCCOLROW nMaxTiledIndex = bColumn ? rViewData.GetMaxTiledCol() : rViewData.GetMaxTiledRow();
- SCCOLROW nHardLimit = !bColumn ? MAXTILEDROW : pDoc ? pDoc->MaxCol() : MAXCOL;
-
- if (nMaxTiledIndex >= nHardLimit)
- return;
-
- if (nEnd <= nMaxTiledIndex - nExtra) // No need to extend.
- return;
-
- ScDocShell* pDocSh = rViewData.GetDocShell();
- ScModelObj* pModelObj = pDocSh ?
- comphelper::getUnoTunnelImplementation<ScModelObj>( pDocSh->GetModel() ) : nullptr;
- Size aOldSize(0, 0);
- if (pModelObj)
- aOldSize = pModelObj->getDocumentSize();
-
- SCCOLROW nNewMaxTiledIndex = std::min(std::max(nEnd, nMaxTiledIndex) + nExtra, nHardLimit);
-
- if (bColumn)
- rViewData.SetMaxTiledCol(nNewMaxTiledIndex);
- else
- rViewData.SetMaxTiledRow(nNewMaxTiledIndex);
-
- Size aNewSize(0, 0);
- if (pModelObj)
- aNewSize = pModelObj->getDocumentSize();
-
- if (aOldSize == aNewSize)
- return;
-
- if (!pDocSh)
- return;
-
- // New area extended to the right/bottom of the sheet after last col/row
- // excluding overlapping area with aNewArea
- tools::Rectangle aNewArea = bColumn ?
- tools::Rectangle(aOldSize.getWidth(), 0, aNewSize.getWidth(), aNewSize.getHeight()):
- tools::Rectangle(0, aOldSize.getHeight(), aNewSize.getWidth(), aNewSize.getHeight());
-
- // Only invalidate if spreadsheet has extended to the right or bottom
- if ((bColumn && aNewArea.getWidth()) || (!bColumn && aNewArea.getHeight()))
- {
- rTabView.UpdateSelectionOverlay();
- SfxLokHelper::notifyInvalidation(rViewData.GetViewShell(), aNewArea.toString());
- }
-
- // Provide size in the payload, so clients don't have to query for that.
- std::stringstream ss;
- ss << aNewSize.Width() << ", " << aNewSize.Height();
- OString sSize = ss.str().c_str();
- ScModelObj* pModel = comphelper::getUnoTunnelImplementation<ScModelObj>(
- rViewData.GetViewShell()->GetCurrentDocument());
- SfxLokHelper::notifyDocumentSizeChanged(rViewData.GetViewShell(), sSize, pModel, false);
-}
-
void ScTabView::extendTiledAreaIfNeeded()
{
SAL_INFO("sc.lok.header",