[Libreoffice-commits] core.git: sc/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 22 16:14:40 UTC 2019


 sc/source/ui/inc/gridwin.hxx   |    2 -
 sc/source/ui/view/gridwin.cxx  |   72 +++++++++++++++++++++--------------------
 sc/source/ui/view/gridwin2.cxx |   14 +++----
 sc/source/ui/view/gridwin4.cxx |   44 ++++++++++++-------------
 4 files changed, 68 insertions(+), 64 deletions(-)

New commits:
commit bef71336399f1dc678eee16b5d6d7bf26a17f491
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Oct 22 14:05:06 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Oct 22 18:13:32 2019 +0200

    sc: rowcol: tdf#50916 convert gridwin
    
    Change-Id: Ifaaddbf17430cf7f2b64785f80afd3cfaa80cdd8
    Reviewed-on: https://gerrit.libreoffice.org/81325
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index dfbfdaef2793..bd4ca07159c5 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -123,7 +123,7 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHel
         SCROW mnRow1;
         SCROW mnRow2;
 
-        VisibleRange();
+        VisibleRange(const ScDocument*);
 
         bool isInside(SCCOL nCol, SCROW nRow) const;
         bool set(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 18c83970a895..777a9ed220f1 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -157,11 +157,11 @@ struct ScGridWindow::MouseEventState
 
 #define SC_FILTERLISTBOX_LINES  12
 
-ScGridWindow::VisibleRange::VisibleRange()
+ScGridWindow::VisibleRange::VisibleRange(const ScDocument* pDoc)
     : mnCol1(0)
-    , mnCol2(MAXCOL)
+    , mnCol2(pDoc->MaxCol())
     , mnRow1(0)
-    , mnRow2(MAXROW)
+    , mnRow2(pDoc->MaxRow())
 {
 }
 
@@ -407,6 +407,7 @@ ScGridWindow::ScGridWindow( vcl::Window* pParent, ScViewData* pData, ScSplitPos
             mpOODragRect(),
             mpOOHeader(),
             mpOOShrink(),
+            maVisibleRange(pData->GetDocument()),
             pViewData( pData ),
             eWhich( eWhichPos ),
             mpNoteMarker(),
@@ -921,6 +922,7 @@ void ScGridWindow::LaunchDPFieldMenu( SCCOL nCol, SCROW nRow )
 
 void ScGridWindow::DoScenarioMenu( const ScRange& rScenRange )
 {
+    ScDocument* pDoc = pViewData->GetDocument();
     mpFilterBox.disposeAndClear();
     mpFilterFloat.disposeAndClear();
 
@@ -929,11 +931,10 @@ void ScGridWindow::DoScenarioMenu( const ScRange& rScenRange )
     if (nRow == 0)
     {
         nRow = rScenRange.aEnd.Row() + 1;   // Range at very the top -> Button below
-        if (nRow>MAXROW) nRow = MAXROW;
+        if (nRow>pDoc->MaxRow()) nRow = pDoc->MaxRow();
         //! Add text height (if it is stored in the View...)
     }
 
-    ScDocument* pDoc = pViewData->GetDocument();
     SCTAB nTab = pViewData->GetTabNo();
     bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
 
@@ -3330,6 +3331,7 @@ void ScGridWindow::UpdateInputContext()
 
 void ScGridWindow::DropScroll( const Point& rMousePos )
 {
+    ScDocument* pDoc = pViewData->GetDocument();
     SCCOL nDx = 0;
     SCROW nDy = 0;
     Size aSize = GetOutputSizePixel();
@@ -3339,7 +3341,7 @@ void ScGridWindow::DropScroll( const Point& rMousePos )
         if ( rMousePos.X() < SCROLL_SENSITIVE && pViewData->GetPosX(WhichH(eWhich)) > 0 )
             nDx = -1;
         if ( rMousePos.X() >= aSize.Width() - SCROLL_SENSITIVE
-                && pViewData->GetPosX(WhichH(eWhich)) < MAXCOL )
+                && pViewData->GetPosX(WhichH(eWhich)) < pDoc->MaxCol() )
             nDx = 1;
     }
     if (aSize.Height() > SCROLL_SENSITIVE * 3)
@@ -3347,7 +3349,7 @@ void ScGridWindow::DropScroll( const Point& rMousePos )
         if ( rMousePos.Y() < SCROLL_SENSITIVE && pViewData->GetPosY(WhichV(eWhich)) > 0 )
             nDy = -1;
         if ( rMousePos.Y() >= aSize.Height() - SCROLL_SENSITIVE
-                && pViewData->GetPosY(WhichV(eWhich)) < MAXROW )
+                && pViewData->GetPosY(WhichV(eWhich)) < pDoc->MaxRow() )
             nDy = 1;
     }
 
@@ -3388,21 +3390,21 @@ static bool lcl_TestScenarioRedliningDrop( const ScDocument* pDoc, const ScRange
     return bReturn;
 }
 
-static ScRange lcl_MakeDropRange( SCCOL nPosX, SCROW nPosY, SCTAB nTab, const ScRange& rSource )
+static ScRange lcl_MakeDropRange( const ScDocument* pDoc, SCCOL nPosX, SCROW nPosY, SCTAB nTab, const ScRange& rSource )
 {
     SCCOL nCol1 = nPosX;
     SCCOL nCol2 = nCol1 + ( rSource.aEnd.Col() - rSource.aStart.Col() );
-    if ( nCol2 > MAXCOL )
+    if ( nCol2 > pDoc->MaxCol() )
     {
-        nCol1 -= nCol2 - MAXCOL;
-        nCol2 = MAXCOL;
+        nCol1 -= nCol2 - pDoc->MaxCol();
+        nCol2 = pDoc->MaxCol();
     }
     SCROW nRow1 = nPosY;
     SCROW nRow2 = nRow1 + ( rSource.aEnd.Row() - rSource.aStart.Row() );
-    if ( nRow2 > MAXROW )
+    if ( nRow2 > pDoc->MaxRow() )
     {
-        nRow1 -= nRow2 - MAXROW;
-        nRow2 = MAXROW;
+        nRow1 -= nRow2 - pDoc->MaxRow();
+        nRow2 = pDoc->MaxRow();
     }
 
     return ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
@@ -3476,16 +3478,16 @@ sal_Int8 ScGridWindow::AcceptPrivateDrop( const AcceptDropEvent& rEvt )
 
         SCCOL nNewDragX = nPosX - rData.pCellTransfer->GetDragHandleX();
         if (nNewDragX<0) nNewDragX=0;
-        if (nNewDragX+(nSizeX-1) > MAXCOL)
-            nNewDragX = MAXCOL-(nSizeX-1);
+        if (nNewDragX+(nSizeX-1) > pThisDoc->MaxCol())
+            nNewDragX = pThisDoc->MaxCol()-(nSizeX-1);
         SCROW nNewDragY = nPosY - rData.pCellTransfer->GetDragHandleY();
         if (nNewDragY<0) nNewDragY=0;
-        if (nNewDragY+(nSizeY-1) > MAXROW)
-            nNewDragY = MAXROW-(nSizeY-1);
+        if (nNewDragY+(nSizeY-1) > pThisDoc->MaxRow())
+            nNewDragY = pThisDoc->MaxRow()-(nSizeY-1);
 
         //  don't break scenario ranges, don't drop on filtered
         SCTAB nTab = pViewData->GetTabNo();
-        ScRange aDropRange = lcl_MakeDropRange( nNewDragX, nNewDragY, nTab, aSourceRange );
+        ScRange aDropRange = lcl_MakeDropRange( pThisDoc, nNewDragX, nNewDragY, nTab, aSourceRange );
         if ( lcl_TestScenarioRedliningDrop( pThisDoc, aDropRange ) ||
              lcl_TestScenarioRedliningDrop( pSourceDoc, aSourceRange ) ||
              ScViewUtil::HasFiltered( aDropRange, pThisDoc) )
@@ -3638,13 +3640,14 @@ sal_Int8 ScGridWindow::AcceptDrop( const AcceptDropEvent& rEvt )
     if ( pViewData->GetDocShell()->IsReadOnly() )
         return DND_ACTION_NONE;
 
+    ScDocument* pThisDoc = pViewData->GetDocument();
     sal_Int8 nRet = DND_ACTION_NONE;
 
     if (rData.pCellTransfer)
     {
         ScRange aSource = rData.pCellTransfer->GetRange();
-        if ( aSource.aStart.Col() != 0 || aSource.aEnd.Col() != MAXCOL ||
-             aSource.aStart.Row() != 0 || aSource.aEnd.Row() != MAXROW )
+        if ( aSource.aStart.Col() != 0 || aSource.aEnd.Col() != pThisDoc->MaxCol() ||
+             aSource.aStart.Row() != 0 || aSource.aEnd.Row() != pThisDoc->MaxRow() )
             DropScroll( rEvt.maPosPixel );
 
         nRet = AcceptPrivateDrop( rEvt );
@@ -3685,7 +3688,6 @@ sal_Int8 ScGridWindow::AcceptDrop( const AcceptDropEvent& rEvt )
                 if ( rEvt.mbDefault && nMyAction == DND_ACTION_MOVE )
                     nMyAction = DND_ACTION_COPY;
 
-            ScDocument* pThisDoc = pViewData->GetDocument();
             SdrObject* pHitObj = pThisDoc->GetObjectAtPoint(
                         pViewData->GetTabNo(), PixelToLogic(rEvt.maPosPixel) );
             if ( pHitObj && nMyAction == DND_ACTION_LINK )
@@ -4562,8 +4564,10 @@ void ScGridWindow::UpdateFormulas(SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2)
     if (nX2 < nX1) nX2 = nX1;
     if (nY2 < nY1) nY2 = nY1;
 
-    if (nX2 > MAXCOL) nX2 = MAXCOL;
-    if (nY2 > MAXROW) nY2 = MAXROW;
+    ScDocument& rDoc = *pViewData->GetDocument();
+
+    if (nX2 > rDoc.MaxCol()) nX2 = rDoc.MaxCol();
+    if (nY2 > rDoc.MaxRow()) nY2 = rDoc.MaxRow();
 
     // Draw( nX1, nY1, nX2, nY2, SC_UPDATE_CHANGED );
 
@@ -4571,7 +4575,6 @@ void ScGridWindow::UpdateFormulas(SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2)
 
     SCROW nPosY = nY1;
 
-    ScDocument& rDoc = *pViewData->GetDocument();
     SCTAB nTab = pViewData->GetTabNo();
 
     if ( !comphelper::LibreOfficeKit::isActive() )
@@ -4843,7 +4846,7 @@ static void lcl_PaintOneRange( ScDocShell* pDocSh, const ScRange& rRange, sal_uI
         --nCol1;
         bHiddenEdge = true;
     }
-    while ( nCol2 < MAXCOL && rDoc.ColHidden(nCol2, nTab1) )
+    while ( nCol2 < rDoc.MaxCol() && rDoc.ColHidden(nCol2, nTab1) )
     {
         ++nCol2;
         bHiddenEdge = true;
@@ -4856,9 +4859,9 @@ static void lcl_PaintOneRange( ScDocShell* pDocSh, const ScRange& rRange, sal_uI
         nRow1 = nTmp;
         bHiddenEdge = true;
     }
-    nTmp = rDoc.FirstVisibleRow(nRow2, MAXROW, nTab1);
+    nTmp = rDoc.FirstVisibleRow(nRow2, rDoc.MaxRow(), nTab1);
     if (!ValidRow(nTmp))
-        nTmp = MAXROW;
+        nTmp = rDoc.MaxRow();
     if (nTmp > nRow2)
     {
         nRow2 = nTmp;
@@ -5050,21 +5053,22 @@ void ScGridWindow::RFMouseMove( const MouseEvent& rMEvt, bool bUp )
     }
     else
     {
+        ScDocument* pDoc = pViewData->GetDocument();
         long nStartX = nPosX - nRFAddX;
         if ( nStartX < 0 ) nStartX = 0;
         long nStartY = nPosY - nRFAddY;
         if ( nStartY < 0 ) nStartY = 0;
         long nEndX = nStartX + aOld.aEnd.Col() - aOld.aStart.Col();
-        if ( nEndX > MAXCOL )
+        if ( nEndX > pDoc->MaxCol() )
         {
-            nStartX -= ( nEndX - MAXROW );
-            nEndX = MAXCOL;
+            nStartX -= ( nEndX - pDoc->MaxRow() );
+            nEndX = pDoc->MaxCol();
         }
         long nEndY = nStartY + aOld.aEnd.Row() - aOld.aStart.Row();
-        if ( nEndY > MAXROW )
+        if ( nEndY > pDoc->MaxRow() )
         {
-            nStartY -= ( nEndY - MAXROW );
-            nEndY = MAXROW;
+            nStartY -= ( nEndY - pDoc->MaxRow() );
+            nEndY = pDoc->MaxRow();
         }
 
         aNew.aStart.SetCol(static_cast<SCCOL>(nStartX));
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 1a73d80d37a7..4a3364593b85 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -598,16 +598,16 @@ void ScGridWindow::UpdateDPFromFieldPopupMenu()
 
 bool ScGridWindow::UpdateVisibleRange()
 {
+    ScDocument const& rDoc = *pViewData->GetDocument();
     SCCOL nPosX = 0;
     SCROW nPosY = 0;
-    SCCOL nXRight = MAXCOL;
-    SCROW nYBottom = MAXROW;
+    SCCOL nXRight = rDoc.MaxCol();
+    SCROW nYBottom = rDoc.MaxRow();
 
     if (comphelper::LibreOfficeKit::isActive())
     {
         // entire table in the tiled rendering case
         SCTAB nTab = pViewData->GetTabNo();
-        ScDocument const& rDoc = *pViewData->GetDocument();
         SCCOL nEndCol = 0;
         SCROW nEndRow = 0;
 
@@ -622,11 +622,11 @@ bool ScGridWindow::UpdateVisibleRange()
         nPosX = pViewData->GetPosX(eHWhich);
         nPosY = pViewData->GetPosY(eVWhich);
         nXRight = nPosX + pViewData->VisibleCellsX(eHWhich);
-        if (nXRight > MAXCOL)
-            nXRight = MAXCOL;
+        if (nXRight > rDoc.MaxCol())
+            nXRight = rDoc.MaxCol();
         nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich);
-        if (nYBottom > MAXROW)
-            nYBottom = MAXROW;
+        if (nYBottom > rDoc.MaxRow())
+            nYBottom = rDoc.MaxRow();
     }
 
     // Store the current visible range.
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 61664d813b54..aed7f1447d39 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -191,9 +191,9 @@ static void lcl_DrawScenarioFrames( OutputDevice* pDev, ScViewData* pViewData, S
         if ( nX1 > 0 ) --nX1;
         if ( nY1>=2 ) nY1 -= 2;             // Hack: Header row affects two cells
         else if ( nY1 > 0 ) --nY1;
-        if ( nX2 < MAXCOL ) ++nX2;
-        if ( nY2 < MAXROW-1 ) nY2 += 2;     // Hack: Header row affects two cells
-        else if ( nY2 < MAXROW ) ++nY2;
+        if ( nX2 < pDoc->MaxCol() ) ++nX2;
+        if ( nY2 < pDoc->MaxRow()-1 ) nY2 += 2;     // Hack: Header row affects two cells
+        else if ( nY2 < pDoc->MaxRow() ) ++nY2;
         ScRange aViewRange( nX1,nY1,nTab, nX2,nY2,nTab );
 
         //! cache the ranges in table!!!!
@@ -352,25 +352,25 @@ void ScGridWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const tools::R
     }
 
     long nScrX = ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );
-    while ( nScrX <= aMirroredPixel.Left() && nX1 < MAXCOL )
+    while ( nScrX <= aMirroredPixel.Left() && nX1 < pDoc->MaxCol() )
     {
         ++nX1;
         nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );
     }
     SCCOL nX2 = nX1;
-    while ( nScrX <= aMirroredPixel.Right() && nX2 < MAXCOL )
+    while ( nScrX <= aMirroredPixel.Right() && nX2 < pDoc->MaxCol() )
     {
         ++nX2;
         nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX2, nTab ), nPPTX );
     }
 
     long nScrY = 0;
-    ScViewData::AddPixelsWhile( nScrY, aPixRect.Top(), nY1, MAXROW, nPPTY, pDoc, nTab);
+    ScViewData::AddPixelsWhile( nScrY, aPixRect.Top(), nY1, pDoc->MaxRow(), nPPTY, pDoc, nTab);
     SCROW nY2 = nY1;
-    if (nScrY <= aPixRect.Bottom() && nY2 < MAXROW)
+    if (nScrY <= aPixRect.Bottom() && nY2 < pDoc->MaxRow())
     {
         ++nY2;
-        ScViewData::AddPixelsWhile( nScrY, aPixRect.Bottom(), nY2, MAXROW, nPPTY, pDoc, nTab);
+        ScViewData::AddPixelsWhile( nScrY, aPixRect.Bottom(), nY2, pDoc->MaxRow(), nPPTY, pDoc, nTab);
     }
 
     Draw( nX1,nY1,nX2,nY2, ScUpdateMode::Marks ); // don't continue with painting
@@ -623,7 +623,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
         tools::Rectangle aDrawingRectPixel(Point(nScrX, nScrY), Size(aOutputData.GetScrW(), aOutputData.GetScrH()));
 
         // correct for border (left/right)
-        if(MAXCOL == nX2)
+        if(rDoc.MaxCol() == nX2)
         {
             if(bLayoutRTL)
             {
@@ -636,7 +636,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
         }
 
         // correct for border (bottom)
-        if(MAXROW == nY2)
+        if(rDoc.MaxRow() == nY2)
         {
             aDrawingRectPixel.SetBottom( GetOutputSizePixel().getHeight() );
         }
@@ -679,7 +679,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
     }
 
     // edge (area) (Pixel)
-    if ( nX2==MAXCOL || nY2==MAXROW )
+    if ( nX2==rDoc.MaxCol() || nY2==rDoc.MaxRow() )
     {
         // save MapMode and set to pixel
         MapMode aCurrentMapMode(pContentDev->GetMapMode());
@@ -688,7 +688,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
         tools::Rectangle aPixRect( Point(), GetOutputSizePixel() );
         pContentDev->SetFillColor( rColorCfg.GetColorValue(svtools::APPBACKGROUND).nColor );
         pContentDev->SetLineColor();
-        if ( nX2==MAXCOL )
+        if ( nX2==rDoc.MaxCol() )
         {
             tools::Rectangle aDrawRect( aPixRect );
             if ( bLayoutRTL )
@@ -698,11 +698,11 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
             if (aDrawRect.Right() >= aDrawRect.Left())
                 pContentDev->DrawRect( aDrawRect );
         }
-        if ( nY2==MAXROW )
+        if ( nY2==rDoc.MaxRow() )
         {
             tools::Rectangle aDrawRect( aPixRect );
             aDrawRect.SetTop( nScrY + aOutputData.GetScrH() );
-            if ( nX2==MAXCOL )
+            if ( nX2==rDoc.MaxCol() )
             {
                 // no double painting of the corner
                 if ( bLayoutRTL )
@@ -1185,8 +1185,8 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     nBottomRightTileCol++;
     nBottomRightTileRow++;
 
-    if (nBottomRightTileCol > MAXCOL)
-        nBottomRightTileCol = MAXCOL;
+    if (nBottomRightTileCol > pDoc->MaxCol())
+        nBottomRightTileCol = pDoc->MaxCol();
 
     if (nBottomRightTileRow > MAXTILEDROW)
         nBottomRightTileRow = MAXTILEDROW;
@@ -1748,9 +1748,9 @@ tools::Rectangle ScGridWindow::GetListValButtonRect( const ScAddress& rButtonPos
     const ScMergeAttr* pMerge = pDoc->GetAttr( nCol,nRow,nTab, ATTR_MERGE );
     if ( pMerge->GetColMerge() > 1 )
         nNextCol = nCol + pMerge->GetColMerge();    // next cell after the merged area
-    while ( nNextCol <= MAXCOL && pDoc->ColHidden(nNextCol, nTab) )
+    while ( nNextCol <= pDoc->MaxCol() && pDoc->ColHidden(nNextCol, nTab) )
         ++nNextCol;
-    bool bNextCell = ( nNextCol <= MAXCOL );
+    bool bNextCell = ( nNextCol <= pDoc->MaxCol() );
     if ( bNextCell )
         nAvailable = ScViewData::ToPixel( pDoc->GetColWidth( nNextCol, nTab ), pViewData->GetPPTX() );
 
@@ -1851,12 +1851,12 @@ void ScGridWindow::GetSelectionRects( ::std::vector< tools::Rectangle >& rPixelR
     {
         // limit the selection to only what is visible on the screen
         SCCOL nXRight = nPosX + pViewData->VisibleCellsX(eHWhich);
-        if (nXRight > MAXCOL)
-            nXRight = MAXCOL;
+        if (nXRight > pDoc->MaxCol())
+            nXRight = pDoc->MaxCol();
 
         SCROW nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich);
-        if (nYBottom > MAXROW)
-            nYBottom = MAXROW;
+        if (nYBottom > pDoc->MaxRow())
+            nYBottom = pDoc->MaxRow();
 
         // is the selection visible at all?
         if (nX1 > nXRight || nY1 > nYBottom)


More information about the Libreoffice-commits mailing list