From 5d3b6e482e72451bd508b3a4db9f182ab4da388d Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 22 Oct 2019 14:21:05 +0200 Subject: sc: rowcol: tdf#50916 convert cellsh Change-Id: If0a44e8bfd3195f2631c2fbcb7c5aa036aae7a40 Reviewed-on: https://gerrit.libreoffice.org/81331 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sc/source/ui/vba/vbarange.cxx | 8 +++++--- sc/source/ui/view/cellsh.cxx | 10 +++++----- sc/source/ui/view/cellsh1.cxx | 15 ++++++++------- sc/source/ui/view/cellsh2.cxx | 4 ++-- sc/source/ui/view/colrowba.cxx | 22 ++++++++++++---------- sc/source/ui/view/dbfunc3.cxx | 29 +++++++++++++++-------------- 6 files changed, 47 insertions(+), 41 deletions(-) diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 311cb9c1fc22..4dc452bb4844 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -2853,6 +2853,7 @@ ScVbaRange::getEntireColumnOrRow( bool bColumn ) ScCellRangesBase* pUnoRangesBase = getCellRangesBase(); // copy the range list ScRangeList aCellRanges = pUnoRangesBase->GetRangeList(); + ScDocument& rDoc = getScDocument(); for ( size_t i = 0, nRanges = aCellRanges.size(); i < nRanges; ++i ) { @@ -2860,12 +2861,12 @@ ScVbaRange::getEntireColumnOrRow( bool bColumn ) if ( bColumn ) { rRange.aStart.SetRow( 0 ); - rRange.aEnd.SetRow( MAXROW ); + rRange.aEnd.SetRow( rDoc.MaxRow() ); } else { rRange.aStart.SetCol( 0 ); - rRange.aEnd.SetCol( MAXCOL ); + rRange.aEnd.SetCol( rDoc.MaxCol() ); } } if ( aCellRanges.size() > 1 ) // Multi-Area @@ -3640,7 +3641,8 @@ ScVbaRange::Delete( const uno::Any& Shift ) } else { - bool bFullRow = ( thisAddress.StartColumn == 0 && thisAddress.EndColumn == MAXCOL ); + ScDocument& rDoc = getScDocument(); + bool bFullRow = ( thisAddress.StartColumn == 0 && thisAddress.EndColumn == rDoc.MaxCol() ); sal_Int32 nCols = thisAddress.EndColumn - thisAddress.StartColumn; sal_Int32 nRows = thisAddress.EndRow - thisAddress.StartRow; if ( mbIsRows || bFullRow || ( nCols >= nRows ) ) diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx index 949c81e47a3d..67908ba1ba68 100644 --- a/sc/source/ui/view/cellsh.cxx +++ b/sc/source/ui/view/cellsh.cxx @@ -137,7 +137,7 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet ) break; case FID_FILL_TO_TOP: { - bDisable = (!bSimpleArea) || (nRow1 == MAXROW && nRow2 == MAXROW); + bDisable = (!bSimpleArea) || (nRow1 == pDoc->MaxRow() && nRow2 == pDoc->MaxRow()); if (!bDisable && GetViewData()->SelectionForbidsCellFill()) bDisable = true; if ( !bDisable && bEditable ) @@ -161,7 +161,7 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet ) break; case FID_FILL_TO_LEFT: { - bDisable = (!bSimpleArea) || (nCol1 == MAXCOL && nCol2 == MAXCOL); + bDisable = (!bSimpleArea) || (nCol1 == pDoc->MaxCol() && nCol2 == pDoc->MaxCol()); if (!bDisable && GetViewData()->SelectionForbidsCellFill()) bDisable = true; if ( !bDisable && bEditable ) @@ -235,7 +235,7 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet ) eAction = sc::ColRowEditAction::InsertRowsAfter; bDisable = (!bSimpleArea) || GetViewData()->SimpleColMarked(); - if (!bEditable && nCol1 == 0 && nCol2 == MAXCOL) + if (!bEditable && nCol1 == 0 && nCol2 == pDoc->MaxCol()) { // See if row insertions are allowed. bEditable = pDoc->IsEditActionAllowed(eAction, rMark, nRow1, nRow2); @@ -255,7 +255,7 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet ) eAction = sc::ColRowEditAction::InsertColumnsAfter; bDisable = (!bSimpleArea) || GetViewData()->SimpleRowMarked(); - if (!bEditable && nRow1 == 0 && nRow2 == MAXROW) + if (!bEditable && nRow1 == 0 && nRow2 == pDoc->MaxRow()) { // See if row insertions are allowed. bEditable = pDoc->IsEditActionAllowed(eAction, rMark, nCol1, nCol2); @@ -1108,7 +1108,7 @@ void ScCellShell::GetState(SfxItemSet &rSet) if (pDoc->HasTabNotes( rTab )) { bHasNotes = true; - aRanges.push_back(ScRange(0,0,rTab,MAXCOL,MAXROW,rTab)); + aRanges.push_back(ScRange(0,0,rTab,pDoc->MaxCol(),pDoc->MaxRow(),rTab)); } } diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx index 382d32236b67..b572bbe601a0 100644 --- a/sc/source/ui/view/cellsh1.cxx +++ b/sc/source/ui/view/cellsh1.cxx @@ -1410,14 +1410,14 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) //check if horizontal shift will fit if ( !pData->GetDocument()->IsBlockEmpty( nStartTab, - MAXCOL - nRangeSizeX, nStartY, - MAXCOL, nStartY + nRangeSizeY ) ) + pDoc->MaxCol() - nRangeSizeX, nStartY, + pDoc->MaxCol(), nStartY + nRangeSizeY ) ) nDisableShiftX = CellShiftDisabledFlags::Right; //check if vertical shift will fit if ( !pData->GetDocument()->IsBlockEmpty( nStartTab, - nStartX, MAXROW - nRangeSizeY, - nStartX + nRangeSizeX, MAXROW ) ) + nStartX, pDoc->MaxRow() - nRangeSizeY, + nStartX + nRangeSizeX, pDoc->MaxRow() ) ) nDisableShiftY = CellShiftDisabledFlags::Down; if ( nDisableShiftX != CellShiftDisabledFlags::NONE || nDisableShiftY != CellShiftDisabledFlags::NONE) @@ -2352,7 +2352,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) std::vector aNotes; for (auto const& rTab : rMark.GetSelectedTabs()) - aRanges.push_back(ScRange(0,0,rTab,MAXCOL,MAXROW,rTab)); + aRanges.push_back(ScRange(0,0,rTab,pDoc->MaxCol(),pDoc->MaxRow(),rTab)); CommentCaptionState eState = pDoc->GetAllNoteCaptionsState( aRanges ); pDoc->GetNotesInRange(aRanges, aNotes); @@ -2400,12 +2400,13 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq ) { ScViewData* pData = GetViewData(); ScMarkData& rMark = pData->GetMarkData(); + ScDocument* pDoc = pData->GetDocument(); ScMarkData aNewMark; ScRangeList aRangeList; for (auto const& rTab : rMark.GetSelectedTabs()) { - aRangeList.push_back(ScRange(0,0,rTab,MAXCOL,MAXROW,rTab)); + aRangeList.push_back(ScRange(0,0,rTab,pDoc->MaxCol(),pDoc->MaxRow(),rTab)); } aNewMark.MarkFromRangeList( aRangeList, true ); @@ -2924,7 +2925,7 @@ void ScCellShell::ExecuteDataPilotDialog() } // output below source data - if ( aRange.aEnd.Row()+2 <= MAXROW - 4 ) + if ( aRange.aEnd.Row()+2 <= pDoc->MaxRow() - 4 ) aDestPos = ScAddress( aRange.aStart.Col(), aRange.aEnd.Row()+2, aRange.aStart.Tab() ); diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 1a886fa3e3c0..8be53409fb9b 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -142,14 +142,14 @@ static bool lcl_GetSortParam( const ScViewData* pData, const ScSortParam& rSortP if( rSortParam.nRow1 != rSortParam.nRow2 ) eFillDir = DIR_TOP; - if( rSortParam.nRow2 == MAXROW ) + if( rSortParam.nRow2 == pDoc->MaxRow() ) { // Assume that user selected entire column(s), but cater for the // possibility that the start row is not the first row. SCSIZE nCount = pDoc->GetEmptyLinesInBlock( rSortParam.nCol1, rSortParam.nRow1, nTab, rSortParam.nCol2, rSortParam.nRow2, nTab, eFillDir ); aExternalRange = ScRange( rSortParam.nCol1, - ::std::min( rSortParam.nRow1 + sal::static_int_cast( nCount ), MAXROW), nTab, + ::std::min( rSortParam.nRow1 + sal::static_int_cast( nCount ), pDoc->MaxRow()), nTab, rSortParam.nCol2, rSortParam.nRow2, nTab); aExternalRange.PutInOrder(); } diff --git a/sc/source/ui/view/colrowba.cxx b/sc/source/ui/view/colrowba.cxx index 80ae03c1c1f5..444db6ac4eef 100644 --- a/sc/source/ui/view/colrowba.cxx +++ b/sc/source/ui/view/colrowba.cxx @@ -51,7 +51,7 @@ static OUString lcl_MetricString( long nTwips, const OUString& rText ) ScColBar::ScColBar( vcl::Window* pParent, ScHSplitPos eWhich, ScHeaderFunctionSet* pFuncSet, ScHeaderSelectionEngine* pEng, ScTabView* pTab ) : - ScHeaderControl( pParent, pEng, MAXCOL+1, false, pTab ), + ScHeaderControl( pParent, pEng, pTab->GetViewData().GetDocument()->MaxCol()+1, false, pTab ), meWhich( eWhich ), mpFuncSet( pFuncSet ) { @@ -105,15 +105,16 @@ void ScColBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize ) std::vector aRanges; if ( rMark.IsColumnMarked( static_cast(nPos) ) ) { + ScDocument* pDoc = rViewData.GetDocument(); SCCOL nStart = 0; - while (nStart<=MAXCOL) + while (nStart<=pDoc->MaxCol()) { - while (nStartMaxCol() && !rMark.IsColumnMarked(nStart)) ++nStart; if (rMark.IsColumnMarked(nStart)) { SCCOL nEnd = nStart; - while (nEndMaxCol() && rMark.IsColumnMarked(nEnd)) ++nEnd; if (!rMark.IsColumnMarked(nEnd)) --nEnd; @@ -121,7 +122,7 @@ void ScColBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize ) nStart = nEnd+1; } else - nStart = MAXCOL+1; + nStart = pDoc->MaxCol()+1; } } else @@ -210,7 +211,7 @@ bool ScColBar::IsLayoutRTL() const // override only for columns ScRowBar::ScRowBar( vcl::Window* pParent, ScVSplitPos eWhich, ScHeaderFunctionSet* pFuncSet, ScHeaderSelectionEngine* pEng, ScTabView* pTab ) : - ScHeaderControl( pParent, pEng, MAXROW+1, true, pTab ), + ScHeaderControl( pParent, pEng, pTab->GetViewData().GetDocument()->MaxRow()+1, true, pTab ), meWhich( eWhich ), mpFuncSet( pFuncSet ) { @@ -264,15 +265,16 @@ void ScRowBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize ) std::vector aRanges; if ( rMark.IsRowMarked( nPos ) ) { + ScDocument* pDoc = rViewData.GetDocument(); SCROW nStart = 0; - while (nStart<=MAXROW) + while (nStart<=pDoc->MaxRow()) { - while (nStartMaxRow() && !rMark.IsRowMarked(nStart)) ++nStart; if (rMark.IsRowMarked(nStart)) { SCROW nEnd = nStart; - while (nEndMaxRow() && rMark.IsRowMarked(nEnd)) ++nEnd; if (!rMark.IsRowMarked(nEnd)) --nEnd; @@ -280,7 +282,7 @@ void ScRowBar::SetEntrySize( SCCOLROW nPos, sal_uInt16 nNewSize ) nStart = nEnd+1; } else - nStart = MAXROW+1; + nStart = pDoc->MaxRow()+1; } } else diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index 751313c201eb..32875638d6cb 100644 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -136,8 +136,8 @@ void ScDBFunc::TestRemoveOutline( bool& rCol, bool& rRow ) ScOutlineEntry* pEntry; SCCOLROW nStart; SCCOLROW nEnd; - bool bColMarked = ( nStartRow == 0 && nEndRow == MAXROW ); - bool bRowMarked = ( nStartCol == 0 && nEndCol == MAXCOL ); + bool bColMarked = ( nStartRow == 0 && nEndRow == pDoc->MaxRow() ); + bool bRowMarked = ( nStartCol == 0 && nEndCol == pDoc->MaxCol() ); // columns @@ -193,8 +193,9 @@ void ScDBFunc::RemoveAllOutlines( bool bRecord ) void ScDBFunc::AutoOutline( ) { + ScDocument* pDoc = GetViewData().GetDocument(); SCTAB nTab = GetViewData().GetTabNo(); - ScRange aRange( 0,0,nTab, MAXCOL,MAXROW,nTab ); // the complete sheet, if nothing is marked + ScRange aRange( 0,0,nTab, pDoc->MaxCol(),pDoc->MaxRow(),nTab ); // the complete sheet, if nothing is marked ScMarkData& rMark = GetViewData().GetMarkData(); if ( rMark.IsMarked() || rMark.IsMultiMarked() ) { @@ -392,7 +393,7 @@ void ScDBFunc::DoSubTotals( const ScSubTotalParam& rParam, bool bRecord, return; } - ScEditableTester aTester( &rDoc, nTab, 0,rParam.nRow1+1, MAXCOL,MAXROW ); + ScEditableTester aTester( &rDoc, nTab, 0,rParam.nRow1+1, rDoc.MaxCol(),rDoc.MaxRow() ); if (!aTester.IsEditable()) { ErrorMessage(aTester.GetMessageId()); @@ -449,18 +450,18 @@ void ScDBFunc::DoSubTotals( const ScSubTotalParam& rParam, bool bRecord, pTable->GetRowArray().GetRange( nOutStartRow, nOutEndRow ); pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true ); - rDoc.CopyToDocument( static_cast(nOutStartCol), 0, nTab, static_cast(nOutEndCol), MAXROW, nTab, InsertDeleteFlags::NONE, false, *pUndoDoc ); - rDoc.CopyToDocument( 0, nOutStartRow, nTab, MAXCOL, nOutEndRow, nTab, InsertDeleteFlags::NONE, false, *pUndoDoc ); + rDoc.CopyToDocument( static_cast(nOutStartCol), 0, nTab, static_cast(nOutEndCol), rDoc.MaxRow(), nTab, InsertDeleteFlags::NONE, false, *pUndoDoc ); + rDoc.CopyToDocument( 0, nOutStartRow, nTab, rDoc.MaxCol(), nOutEndRow, nTab, InsertDeleteFlags::NONE, false, *pUndoDoc ); } else pUndoDoc->InitUndo( &rDoc, nTab, nTab, false, bOldFilter ); // record data range - including filter results - rDoc.CopyToDocument( 0,rParam.nRow1+1,nTab, MAXCOL,rParam.nRow2,nTab, + rDoc.CopyToDocument( 0,rParam.nRow1+1,nTab, rDoc.MaxCol(),rParam.nRow2,nTab, InsertDeleteFlags::ALL, false, *pUndoDoc ); // all formulas for reference - rDoc.CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1, + rDoc.CopyToDocument( 0,0,0, rDoc.MaxCol(),rDoc.MaxRow(),nTabCount-1, InsertDeleteFlags::FORMULA, false, *pUndoDoc ); // database and other ranges @@ -536,7 +537,7 @@ void ScDBFunc::DoSubTotals( const ScSubTotalParam& rParam, bool bRecord, aNewParam.nCol2,aNewParam.nRow2,nTab ) ); MarkDataChanged(); - pDocSh->PostPaint(ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab), + pDocSh->PostPaint(ScRange(0, 0, nTab, rDoc.MaxCol(), rDoc.MaxRow(), nTab), PaintPartFlags::Grid | PaintPartFlags::Left | PaintPartFlags::Top | PaintPartFlags::Size); aModificator.SetDocumentModified(); @@ -2122,17 +2123,17 @@ void ScDBFunc::RepeatDB( bool bRecord ) pTable->GetRowArray().GetRange( nOutStartRow, nOutEndRow ); pUndoDoc->InitUndo( pDoc, nTab, nTab, true, true ); - pDoc->CopyToDocument( static_cast(nOutStartCol), 0, nTab, static_cast(nOutEndCol), MAXROW, nTab, InsertDeleteFlags::NONE, false, *pUndoDoc ); - pDoc->CopyToDocument( 0, nOutStartRow, nTab, MAXCOL, nOutEndRow, nTab, InsertDeleteFlags::NONE, false, *pUndoDoc ); + pDoc->CopyToDocument( static_cast(nOutStartCol), 0, nTab, static_cast(nOutEndCol), pDoc->MaxRow(), nTab, InsertDeleteFlags::NONE, false, *pUndoDoc ); + pDoc->CopyToDocument( 0, nOutStartRow, nTab, pDoc->MaxCol(), nOutEndRow, nTab, InsertDeleteFlags::NONE, false, *pUndoDoc ); } else pUndoDoc->InitUndo( pDoc, nTab, nTab, false, true ); // Record data range - including filter results - pDoc->CopyToDocument( 0,nStartRow,nTab, MAXCOL,nEndRow,nTab, InsertDeleteFlags::ALL, false, *pUndoDoc ); + pDoc->CopyToDocument( 0,nStartRow,nTab, pDoc->MaxCol(),nEndRow,nTab, InsertDeleteFlags::ALL, false, *pUndoDoc ); // all formulas for reference - pDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1, InsertDeleteFlags::FORMULA, false, *pUndoDoc ); + pDoc->CopyToDocument( 0,0,0, pDoc->MaxCol(),pDoc->MaxRow(),nTabCount-1, InsertDeleteFlags::FORMULA, false, *pUndoDoc ); // data base and other ranges ScRangeName* pDocRange = pDoc->GetRangeName(); @@ -2211,7 +2212,7 @@ void ScDBFunc::RepeatDB( bool bRecord ) } GetViewData().GetDocShell()->PostPaint( - ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab), + ScRange(0, 0, nTab, pDoc->MaxCol(), pDoc->MaxRow(), nTab), PaintPartFlags::Grid | PaintPartFlags::Left | PaintPartFlags::Top | PaintPartFlags::Size); } else // "no not execute any operations" -- cgit