diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2016-07-21 15:05:01 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-07-22 07:04:48 +0000 |
commit | c6c8c2a8b132b1555be3efb7181bac9a074bc208 (patch) | |
tree | 2bf92c878f61c1b4970fc966e381eebf5f82ddd2 /sc/source | |
parent | f045d14791a84f478c40fbd6b0590f527b36cbff (diff) |
sc: convert MatrixEdge... to typed_flags
remove some unhelpful or obvious comments
replace numeric values in last loop of ScTable::HasBlockMatrixFragment
Change-Id: If7115b504689ce31b5caadbcae8ce2f5466e5b2a
Reviewed-on: https://gerrit.libreoffice.org/27378
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/data/column.cxx | 40 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 34 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 43 |
3 files changed, 51 insertions, 66 deletions
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 00664c63bf43..3bc430ada2c0 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -115,12 +115,12 @@ SCsROW ScColumn::GetNextUnprotected( SCROW nRow, bool bUp ) const return pAttrArray->GetNextUnprotected(nRow, bUp); } -sal_uInt16 ScColumn::GetBlockMatrixEdges( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const +sc::MatrixEdge ScColumn::GetBlockMatrixEdges( SCROW nRow1, SCROW nRow2, sc::MatrixEdge nMask ) const { using namespace sc; if (!ValidRow(nRow1) || !ValidRow(nRow2) || nRow1 > nRow2) - return 0; + return MatrixEdge::Nothing; ScAddress aOrigin(ScAddress::INITIALIZE_INVALID); @@ -128,17 +128,17 @@ sal_uInt16 ScColumn::GetBlockMatrixEdges( SCROW nRow1, SCROW nRow2, sal_uInt16 n { std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nRow1); if (aPos.first->type != sc::element_type_formula) - return 0; + return MatrixEdge::Nothing; const ScFormulaCell* pCell = sc::formula_block::at(*aPos.first->data, aPos.second); if (!pCell->GetMatrixFlag()) - return 0; + return MatrixEdge::Nothing; return pCell->GetMatrixEdge(aOrigin); } bool bOpen = false; - sal_uInt16 nEdges = 0; + MatrixEdge nEdges = MatrixEdge::Nothing; std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nRow1); sc::CellStoreType::const_iterator it = aPos.first; @@ -165,29 +165,27 @@ sal_uInt16 ScColumn::GetBlockMatrixEdges( SCROW nRow1, SCROW nRow2, sal_uInt16 n continue; nEdges = pCell->GetMatrixEdge(aOrigin); - if (!nEdges) + if (nEdges == MatrixEdge::Nothing) continue; - if (nEdges & MatrixEdgeTop) + if (nEdges & MatrixEdge::Top) bOpen = true; // top edge opens, keep on looking else if (!bOpen) - return nEdges | MatrixEdgeOpen; // there's something that wasn't opened - else if (nEdges & MatrixEdgeInside) + return nEdges | MatrixEdge::Open; // there's something that wasn't opened + else if (nEdges & MatrixEdge::Inside) return nEdges; // inside - // (nMask & 16 and (4 and not 16)) or - // (nMask & 4 and (16 and not 4)) - if (((nMask & MatrixEdgeRight) && (nEdges & MatrixEdgeLeft) && !(nEdges & MatrixEdgeRight)) || - ((nMask & MatrixEdgeLeft) && (nEdges & MatrixEdgeRight) && !(nEdges & MatrixEdgeLeft))) + if (((nMask & MatrixEdge::Right) && (nEdges & MatrixEdge::Left) && !(nEdges & MatrixEdge::Right)) || + ((nMask & MatrixEdge::Left) && (nEdges & MatrixEdge::Right) && !(nEdges & MatrixEdge::Left))) return nEdges; // only left/right edge - if (nEdges & MatrixEdgeBottom) + if (nEdges & MatrixEdge::Bottom) bOpen = false; // bottom edge closes } nRow += nEnd; } if (bOpen) - nEdges |= MatrixEdgeOpen; // not closed, matrix continues + nEdges |= MatrixEdge::Open; // not closed, matrix continues return nEdges; } @@ -241,24 +239,24 @@ bool ScColumn::HasSelectionMatrixFragment(const ScMarkData& rMark) const // cell is not a part of a matrix. continue; - sal_uInt16 nEdges = pCell->GetMatrixEdge(aOrigin); - if (!nEdges) + MatrixEdge nEdges = pCell->GetMatrixEdge(aOrigin); + if (nEdges == MatrixEdge::Nothing) continue; bool bFound = false; - if (nEdges & MatrixEdgeTop) + if (nEdges & MatrixEdge::Top) bOpen = true; // top edge opens, keep on looking else if (!bOpen) return true; // there's something that wasn't opened - else if (nEdges & MatrixEdgeInside) + else if (nEdges & MatrixEdge::Inside) bFound = true; // inside, all selected? - if ((((nEdges & MatrixEdgeLeft) | MatrixEdgeRight) ^ ((nEdges & MatrixEdgeRight) | MatrixEdgeLeft))) + if ((((nEdges & MatrixEdge::Left) | MatrixEdge::Right) ^ ((nEdges & MatrixEdge::Right) | MatrixEdge::Left))) // either left or right, but not both. bFound = true; // only left/right edge, all selected? - if (nEdges & MatrixEdgeBottom) + if (nEdges & MatrixEdge::Bottom) bOpen = false; // bottom edge closes if (bFound) diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 4d3936b64cb8..407cd47003b7 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2664,19 +2664,7 @@ bool ScFormulaCell::GetMatrixOrigin( ScAddress& rPos ) const return false; } -/* - Edge-Values: - - 8 - 4 16 - 2 - - inside: 1 - outside: 0 - (reserved: open: 32) - */ - -sal_uInt16 ScFormulaCell::GetMatrixEdge( ScAddress& rOrgPos ) const +sc::MatrixEdge ScFormulaCell::GetMatrixEdge( ScAddress& rOrgPos ) const { switch ( cMatrixFlag ) { @@ -2687,7 +2675,7 @@ sal_uInt16 ScFormulaCell::GetMatrixEdge( ScAddress& rOrgPos ) const static SCROW nR; ScAddress aOrg; if ( !GetMatrixOrigin( aOrg ) ) - return 0; // bad luck.. + return sc::MatrixEdge::Nothing; if ( aOrg != rOrgPos ) { // First time or a different matrix than last time. rOrgPos = aOrg; @@ -2752,25 +2740,25 @@ sal_uInt16 ScFormulaCell::GetMatrixEdge( ScAddress& rOrgPos ) const aMsg.append(OUStringToOString(aTmp, RTL_TEXTENCODING_ASCII_US)); OSL_FAIL(aMsg.getStr()); #endif - return 0; // bad luck ... + return sc::MatrixEdge::Nothing; } } // here we are, healthy and clean, somewhere in between SCsCOL dC = aPos.Col() - aOrg.Col(); SCsROW dR = aPos.Row() - aOrg.Row(); - sal_uInt16 nEdges = 0; + sc::MatrixEdge nEdges = sc::MatrixEdge::Nothing; if ( dC >= 0 && dR >= 0 && dC < nC && dR < nR ) { if ( dC == 0 ) - nEdges |= sc::MatrixEdgeLeft; // left edge + nEdges |= sc::MatrixEdge::Left; if ( dC+1 == nC ) - nEdges |= sc::MatrixEdgeRight; // right edge + nEdges |= sc::MatrixEdge::Right; if ( dR == 0 ) - nEdges |= sc::MatrixEdgeTop; // top edge + nEdges |= sc::MatrixEdge::Top; if ( dR+1 == nR ) - nEdges |= sc::MatrixEdgeBottom; // bottom edge - if ( !nEdges ) - nEdges = sc::MatrixEdgeInside; // inside + nEdges |= sc::MatrixEdge::Bottom; + if ( nEdges == sc::MatrixEdge::Nothing ) + nEdges = sc::MatrixEdge::Inside; } #if OSL_DEBUG_LEVEL > 0 else @@ -2795,7 +2783,7 @@ sal_uInt16 ScFormulaCell::GetMatrixEdge( ScAddress& rOrgPos ) const return nEdges; } default: - return 0; + return sc::MatrixEdge::Nothing; } } diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 682ce083805b..788ce139eb48 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -2113,78 +2113,77 @@ bool ScTable::HasBlockMatrixFragment( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCR { using namespace sc; - sal_uInt16 nEdges = 0; + MatrixEdge nEdges = MatrixEdge::Nothing; if ( nCol1 == nCol2 ) { // left and right column - const sal_uInt16 n = MatrixEdgeLeft | MatrixEdgeRight; + const MatrixEdge n = MatrixEdge::Left | MatrixEdge::Right; nEdges = aCol[nCol1].GetBlockMatrixEdges( nRow1, nRow2, n ); - // not (4 and 16) or 1 or 32 - if (nEdges && (((nEdges & n) != n) || (nEdges & (MatrixEdgeInside|MatrixEdgeOpen)))) + if ((nEdges != MatrixEdge::Nothing) && (((nEdges & n)!=n) || (nEdges & (MatrixEdge::Inside|MatrixEdge::Open)))) return true; // left or right edge is missing or open } else { // left column - nEdges = aCol[nCol1].GetBlockMatrixEdges(nRow1, nRow2, MatrixEdgeLeft); - // not 4 or 1 or 32 - if (nEdges && (((nEdges & MatrixEdgeLeft) != MatrixEdgeLeft) || (nEdges & (MatrixEdgeInside|MatrixEdgeOpen)))) + nEdges = aCol[nCol1].GetBlockMatrixEdges(nRow1, nRow2, MatrixEdge::Left); + if ((nEdges != MatrixEdge::Nothing) && ((!(nEdges & MatrixEdge::Left)) || (nEdges & (MatrixEdge::Inside|MatrixEdge::Open)))) return true; // left edge missing or open // right column - nEdges = aCol[nCol2].GetBlockMatrixEdges(nRow1, nRow2, MatrixEdgeRight); - // not 16 or 1 or 32 - if (nEdges && (((nEdges & MatrixEdgeRight) != MatrixEdgeRight) || (nEdges & (MatrixEdgeInside|MatrixEdgeOpen)))) + nEdges = aCol[nCol2].GetBlockMatrixEdges(nRow1, nRow2, MatrixEdge::Right); + if ((nEdges != MatrixEdge::Nothing) && ((!(nEdges & MatrixEdge::Right)) || (nEdges & (MatrixEdge::Inside|MatrixEdge::Open)))) return true; // right edge is missing or open } if ( nRow1 == nRow2 ) { // Row on top and on bottom bool bOpen = false; - const sal_uInt16 n = MatrixEdgeBottom | MatrixEdgeTop; + const MatrixEdge n = MatrixEdge::Bottom | MatrixEdge::Top; for ( SCCOL i=nCol1; i<=nCol2; i++) { nEdges = aCol[i].GetBlockMatrixEdges( nRow1, nRow1, n ); - if ( nEdges ) + if (nEdges != MatrixEdge::Nothing) { if ( (nEdges & n) != n ) return true; // Top or bottom edge missing - if (nEdges & MatrixEdgeLeft) + if (nEdges & MatrixEdge::Left) bOpen = true; // left edge open, continue else if ( !bOpen ) return true; // Something exist that has not been opened - if (nEdges & MatrixEdgeRight) + if (nEdges & MatrixEdge::Right) bOpen = false; // Close right edge } } if ( bOpen ) - return true; // continue + return true; } else { - sal_uInt16 j, n; + int j; + MatrixEdge n; SCROW nR; - // first rop row, then bottom row - for ( j=0, nR=nRow1, n=8; j<2; j++, nR=nRow2, n=2 ) + // first top row, then bottom row + for ( j=0, n = MatrixEdge::Top, nR=nRow1; j<2; + j++, n = MatrixEdge::Bottom, nR=nRow2) { bool bOpen = false; for ( SCCOL i=nCol1; i<=nCol2; i++) { nEdges = aCol[i].GetBlockMatrixEdges( nR, nR, n ); - if ( nEdges ) + if ( nEdges != MatrixEdge::Nothing) { // in top row no top edge respectively // in bottom row no bottom edge if ( (nEdges & n) != n ) return true; - if (nEdges & MatrixEdgeLeft) + if (nEdges & MatrixEdge::Left) bOpen = true; // open left edge, continue else if ( !bOpen ) return true; // Something exist that has not been opened - if (nEdges & MatrixEdgeRight) + if (nEdges & MatrixEdge::Right) bOpen = false; // Close right edge } } if ( bOpen ) - return true; // continue + return true; } } return false; |