[Libreoffice-commits] core.git: sw/inc sw/source
Noel Grandin
noel.grandin at collabora.co.uk
Wed Apr 12 13:02:04 UTC 2017
sw/inc/tblsel.hxx | 32 +++++++++++++++++---------------
sw/source/core/crsr/trvltbl.cxx | 4 ++--
sw/source/core/docnode/ndtbl.cxx | 12 ++++++------
sw/source/core/docnode/ndtbl1.cxx | 2 +-
sw/source/core/frmedt/fetab.cxx | 10 +++++-----
sw/source/core/frmedt/tblsel.cxx | 34 +++++++++++++++++-----------------
sw/source/uibase/shells/tabsh.cxx | 4 ++--
7 files changed, 50 insertions(+), 48 deletions(-)
New commits:
commit b79d297f4be32aa15c599ad6c1cd77580856cccc
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Apr 12 12:35:05 2017 +0200
convert SwTableSearchType to o3tl::typed_flags
Change-Id: I4fbe114d96ac34540d0774fedbe1fed210efa906
Reviewed-on: https://gerrit.libreoffice.org/36459
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/tblsel.hxx b/sw/inc/tblsel.hxx
index c06770e0be9d..295cd2da21c1 100644
--- a/sw/inc/tblsel.hxx
+++ b/sw/inc/tblsel.hxx
@@ -58,28 +58,30 @@ class SwSelBoxes : public o3tl::sorted_vector<SwTableBox*, CompareSwSelBoxes> {}
// Selection gets extended in given direction according to enum-parameter.
// Boxes are collected via the Layout; works correctly if tables are split.
// (Cf. MakeSelUnions().)
-typedef sal_uInt16 SwTableSearchType;
-namespace nsSwTableSearchType
+enum class SwTableSearchType : sal_uInt16
{
- const SwTableSearchType TBLSEARCH_NONE = 0x1; // No extension.
- const SwTableSearchType TBLSEARCH_ROW = 0x2; // Extend to rows.
- const SwTableSearchType TBLSEARCH_COL = 0x3; // Extend to columns.
+ NONE = 0x01, // No extension.
+ Row = 0x02, // Extend to rows.
+ Col = 0x03, // Extend to columns.
- // As flag to the other values!
- const SwTableSearchType TBLSEARCH_PROTECT = 0x8; // Collect protected boxes too.
- const SwTableSearchType TBLSEARCH_NO_UNION_CORRECT = 0x10; // Do not correct collected Union.
+ // As flags to the other values!
+ Protect = 0x08, // Collect protected boxes too.
+ NoUnionCorrect = 0x10, // Do not correct collected Union.
+};
+namespace o3tl {
+ template<> struct typed_flags<SwTableSearchType> : is_typed_flags<SwTableSearchType, 0x1f> {};
}
SW_DLLPUBLIC void GetTableSel( const SwCursorShell& rShell, SwSelBoxes& rBoxes,
- const SwTableSearchType = nsSwTableSearchType::TBLSEARCH_NONE );
+ const SwTableSearchType = SwTableSearchType::NONE );
void GetTableSel( const SwCursor& rCursor, SwSelBoxes& rBoxes,
- const SwTableSearchType = nsSwTableSearchType::TBLSEARCH_NONE );
+ const SwTableSearchType = SwTableSearchType::NONE );
// As before, but don't start from selection but from Start- EndFrames.
void GetTableSel( const SwLayoutFrame* pStart, const SwLayoutFrame* pEnd,
SwSelBoxes& rBoxes, SwCellFrames* pCells,
- const SwTableSearchType = nsSwTableSearchType::TBLSEARCH_NONE );
+ const SwTableSearchType = SwTableSearchType::NONE );
// As before but directly via PaMs.
void GetTableSelCrs( const SwCursorShell& rShell, SwSelBoxes& rBoxes );
@@ -114,9 +116,9 @@ bool IsEmptyBox( const SwTableBox& rBox, SwPaM& rPam );
// Check if Split or InsertCol lead to a box becoming smaller than MINLAY.
bool CheckSplitCells( const SwCursorShell& rShell, sal_uInt16 nDiv,
- const SwTableSearchType = nsSwTableSearchType::TBLSEARCH_NONE );
+ const SwTableSearchType = SwTableSearchType::NONE );
bool CheckSplitCells( const SwCursor& rCursor, sal_uInt16 nDiv,
- const SwTableSearchType = nsSwTableSearchType::TBLSEARCH_NONE );
+ const SwTableSearchType = SwTableSearchType::NONE );
// For working on tab selection also for split tables.
class SwSelUnion
@@ -140,11 +142,11 @@ typedef std::vector<SwSelUnion> SwSelUnions;
// Gets the tables involved in a table selection and the union-rectangles of the selections
// - also for split tables.
-// If a parameter is passed that != nsSwTableSearchType::TBLSEARCH_NONE
+// If a parameter is passed that != SwTableSearchType::NONE
// the selection is extended in the given direction.
void MakeSelUnions( SwSelUnions&, const SwLayoutFrame *pStart,
const SwLayoutFrame *pEnd,
- const SwTableSearchType = nsSwTableSearchType::TBLSEARCH_NONE );
+ const SwTableSearchType = SwTableSearchType::NONE );
// These classes copy the current table selections (rBoxes) into a
// separate structure while keeping the table structure.
diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx
index 472c2766a782..70b4000c46e8 100644
--- a/sw/source/core/crsr/trvltbl.cxx
+++ b/sw/source/core/crsr/trvltbl.cxx
@@ -146,11 +146,11 @@ bool SwCursorShell::SelTableRowOrCol( bool bRow, bool bRowSimple )
// search box based on layout
SwSelBoxes aBoxes;
- SwTableSearchType eType = bRow ? nsSwTableSearchType::TBLSEARCH_ROW : nsSwTableSearchType::TBLSEARCH_COL;
+ SwTableSearchType eType = bRow ? SwTableSearchType::Row : SwTableSearchType::Col;
const bool bCheckProtected = !IsReadOnlyAvailable();
if( bCheckProtected )
- eType = (SwTableSearchType)(eType | nsSwTableSearchType::TBLSEARCH_PROTECT);
+ eType = (SwTableSearchType)(eType | SwTableSearchType::Protect);
if ( !bRowSimple )
{
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 7fb80ffbb457..99b8a6acf53b 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1706,12 +1706,12 @@ bool SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh,
*/
bool SwDoc::InsertCol( const SwCursor& rCursor, sal_uInt16 nCnt, bool bBehind )
{
- if( !::CheckSplitCells( rCursor, nCnt + 1, nsSwTableSearchType::TBLSEARCH_COL ) )
+ if( !::CheckSplitCells( rCursor, nCnt + 1, SwTableSearchType::Col ) )
return false;
// Find the Boxes via the Layout
SwSelBoxes aBoxes;
- ::GetTableSel( rCursor, aBoxes, nsSwTableSearchType::TBLSEARCH_COL );
+ ::GetTableSel( rCursor, aBoxes, SwTableSearchType::Col );
bool bRet = false;
if( !aBoxes.empty() )
@@ -1773,7 +1773,7 @@ bool SwDoc::InsertRow( const SwCursor& rCursor, sal_uInt16 nCnt, bool bBehind )
{
// Find the Boxes via the Layout
SwSelBoxes aBoxes;
- GetTableSel( rCursor, aBoxes, nsSwTableSearchType::TBLSEARCH_ROW );
+ GetTableSel( rCursor, aBoxes, SwTableSearchType::Row );
bool bRet = false;
if( !aBoxes.empty() )
@@ -1839,7 +1839,7 @@ bool SwDoc::DeleteRow( const SwCursor& rCursor )
{
// Find the Boxes via the Layout
SwSelBoxes aBoxes;
- GetTableSel( rCursor, aBoxes, nsSwTableSearchType::TBLSEARCH_ROW );
+ GetTableSel( rCursor, aBoxes, SwTableSearchType::Row );
if( ::HasProtectedCells( aBoxes ))
return false;
@@ -1941,7 +1941,7 @@ bool SwDoc::DeleteCol( const SwCursor& rCursor )
{
// Find the Boxes via the Layout
SwSelBoxes aBoxes;
- GetTableSel( rCursor, aBoxes, nsSwTableSearchType::TBLSEARCH_COL );
+ GetTableSel( rCursor, aBoxes, SwTableSearchType::Col );
if( ::HasProtectedCells( aBoxes ))
return false;
@@ -2605,7 +2605,7 @@ void SwDoc::GetTabRows( SwTabCols &rFill, const SwCursor* ,
{
const SwPosition aPos( *static_cast<const SwTextFrame*>(pContent)->GetTextNode() );
const SwCursor aTmpCursor( aPos, nullptr );
- ::GetTableSel( aTmpCursor, aBoxes, nsSwTableSearchType::TBLSEARCH_COL );
+ ::GetTableSel( aTmpCursor, aBoxes, SwTableSearchType::Col );
}
// Make code robust:
diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx
index 9224bbbbc42c..44b9d0844a86 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -1376,7 +1376,7 @@ static void lcl_CalcColValues( std::vector<sal_uInt16> &rToFill, const SwTabCols
{
SwSelUnions aUnions;
::MakeSelUnions( aUnions, pStart, pEnd,
- bWishValues ? nsSwTableSearchType::TBLSEARCH_NONE : nsSwTableSearchType::TBLSEARCH_COL );
+ bWishValues ? SwTableSearchType::NONE : SwTableSearchType::Col );
for ( auto &rU : aUnions )
{
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index f96d1f194e12..5ac0941053e5 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -208,7 +208,7 @@ bool SwFEShell::InsertRow( sal_uInt16 nCnt, bool bBehind )
pPaM->End()->nNode = pNode->GetIndex() - 2;
pPaM->End()->nContent.Assign(pPaM->End()->nNode.GetNode().GetContentNode(), 0);
}
- GetTableSel( *this, aBoxes, nsSwTableSearchType::TBLSEARCH_ROW );
+ GetTableSel( *this, aBoxes, SwTableSearchType::Row );
TableWait aWait( nCnt, pFrame, *GetDoc()->GetDocShell(), aBoxes.size() );
@@ -236,7 +236,7 @@ bool SwFEShell::InsertCol( sal_uInt16 nCnt, bool bBehind )
SET_CURR_SHELL( this );
- if( !CheckSplitCells( *this, nCnt + 1, nsSwTableSearchType::TBLSEARCH_COL ) )
+ if( !CheckSplitCells( *this, nCnt + 1, SwTableSearchType::Col ) )
{
ErrorHandler::HandleError( ERR_TBLINSCOL_ERROR,
ErrorHandlerFlags::MessageInfo | ErrorHandlerFlags::ButtonDefaultsOk );
@@ -246,7 +246,7 @@ bool SwFEShell::InsertCol( sal_uInt16 nCnt, bool bBehind )
StartAllAction();
// search boxes via the layout
SwSelBoxes aBoxes;
- GetTableSel( *this, aBoxes, nsSwTableSearchType::TBLSEARCH_COL );
+ GetTableSel( *this, aBoxes, SwTableSearchType::Col );
TableWait aWait( nCnt, pFrame, *GetDoc()->GetDocShell(), aBoxes.size() );
@@ -295,7 +295,7 @@ bool SwFEShell::DeleteCol()
// search boxes via the layout
bool bRet;
SwSelBoxes aBoxes;
- GetTableSel( *this, aBoxes, nsSwTableSearchType::TBLSEARCH_COL );
+ GetTableSel( *this, aBoxes, SwTableSearchType::Col );
if ( !aBoxes.empty() )
{
TableWait aWait( aBoxes.size(), pFrame, *GetDoc()->GetDocShell() );
@@ -346,7 +346,7 @@ bool SwFEShell::DeleteRow(bool bCompleteTable)
// search for boxes via the layout
bool bRet;
SwSelBoxes aBoxes;
- GetTableSel( *this, aBoxes, nsSwTableSearchType::TBLSEARCH_ROW );
+ GetTableSel( *this, aBoxes, SwTableSearchType::Row );
if( !aBoxes.empty() )
{
diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx
index 2e04df508cc4..45d48751ca4e 100644
--- a/sw/source/core/frmedt/tblsel.cxx
+++ b/sw/source/core/frmedt/tblsel.cxx
@@ -166,17 +166,17 @@ void GetTableSel( const SwCursor& rCursor, SwSelBoxes& rBoxes,
if( pTableNd && pTableNd->GetTable().IsNewModel() )
{
SwTable::SearchType eSearch;
- switch( nsSwTableSearchType::TBLSEARCH_COL & eSearchType )
+ switch( SwTableSearchType::Col & eSearchType )
{
- case nsSwTableSearchType::TBLSEARCH_ROW: eSearch = SwTable::SEARCH_ROW; break;
- case nsSwTableSearchType::TBLSEARCH_COL: eSearch = SwTable::SEARCH_COL; break;
+ case SwTableSearchType::Row: eSearch = SwTable::SEARCH_ROW; break;
+ case SwTableSearchType::Col: eSearch = SwTable::SEARCH_COL; break;
default: eSearch = SwTable::SEARCH_NONE; break;
}
- const bool bChkP = 0 != ( nsSwTableSearchType::TBLSEARCH_PROTECT & eSearchType );
+ const bool bChkP( SwTableSearchType::Protect & eSearchType );
pTableNd->GetTable().CreateSelection( rCursor, rBoxes, eSearch, bChkP );
return;
}
- if( nsSwTableSearchType::TBLSEARCH_ROW == ((~nsSwTableSearchType::TBLSEARCH_PROTECT ) & eSearchType ) &&
+ if( SwTableSearchType::Row == ((~SwTableSearchType::Protect ) & eSearchType ) &&
pTableNd && !pTableNd->GetTable().IsTableComplex() )
{
const SwTable& rTable = pTableNd->GetTable();
@@ -202,7 +202,7 @@ void GetTableSel( const SwCursor& rCursor, SwSelBoxes& rBoxes,
sal_uInt16 nTmp = nSttPos; nSttPos = nEndPos; nEndPos = nTmp;
}
- int bChkProtected = nsSwTableSearchType::TBLSEARCH_PROTECT & eSearchType;
+ bool bChkProtected( SwTableSearchType::Protect & eSearchType );
for( ; nSttPos <= nEndPos; ++nSttPos )
{
pLine = rLines[ nSttPos ];
@@ -248,7 +248,7 @@ void GetTableSel( const SwLayoutFrame* pStart, const SwLayoutFrame* pEnd,
return;
}
- int bChkProtected = nsSwTableSearchType::TBLSEARCH_PROTECT & eSearchType;
+ bool bChkProtected( SwTableSearchType::Protect & eSearchType );
// #i55421# Reduced value 10
int nLoopMax = 10;
@@ -462,7 +462,7 @@ bool ChkChartSel( const SwNode& rSttNd, const SwNode& rEndNd )
// First, compute tables and rectangles
SwSelUnions aUnions;
- ::MakeSelUnions( aUnions, pStart, pEnd, nsSwTableSearchType::TBLSEARCH_NO_UNION_CORRECT );
+ ::MakeSelUnions( aUnions, pStart, pEnd, SwTableSearchType::NoUnionCorrect );
// find boxes for each entry and emit
for( auto & rSelUnion : aUnions )
@@ -687,7 +687,7 @@ bool GetAutoSumSel( const SwCursorShell& rShell, SwCellFrames& rBoxes )
SwSelUnions aUnions;
// by default, first test above and then to the left
- ::MakeSelUnions( aUnions, pStart, pEnd, nsSwTableSearchType::TBLSEARCH_COL );
+ ::MakeSelUnions( aUnions, pStart, pEnd, SwTableSearchType::Col );
bool bTstRow = true, bFound = false;
@@ -759,7 +759,7 @@ bool GetAutoSumSel( const SwCursorShell& rShell, SwCellFrames& rBoxes )
rBoxes.clear();
aUnions.clear();
- ::MakeSelUnions( aUnions, pStart, pEnd, nsSwTableSearchType::TBLSEARCH_ROW );
+ ::MakeSelUnions( aUnions, pStart, pEnd, SwTableSearchType::Row );
for( SwSelUnions::size_type i = 0; i < aUnions.size(); ++i )
{
@@ -1512,7 +1512,7 @@ static SwTwips lcl_CalcWish( const SwLayoutFrame *pCell, long nWish,
static void lcl_FindStartEndRow( const SwLayoutFrame *&rpStart,
const SwLayoutFrame *&rpEnd,
- const int bChkProtected )
+ const bool bChkProtected )
{
// Put Start at beginning of a row.
// Put End at the end of its row.
@@ -1581,7 +1581,7 @@ static void lcl_FindStartEndRow( const SwLayoutFrame *&rpStart,
static void lcl_FindStartEndCol( const SwLayoutFrame *&rpStart,
const SwLayoutFrame *&rpEnd,
- const int bChkProtected )
+ const bool bChkProtected )
{
// Beginning and end vertical till the border of the table;
// Consider the whole table, including master and follows.
@@ -1788,10 +1788,10 @@ void MakeSelUnions( SwSelUnions& rUnions, const SwLayoutFrame *pStart,
// Beginning and end now nicely sorted, if required we
// should move them
- if( nsSwTableSearchType::TBLSEARCH_ROW == ((~nsSwTableSearchType::TBLSEARCH_PROTECT ) & eSearchType ) )
- ::lcl_FindStartEndRow( pStart, pEnd, nsSwTableSearchType::TBLSEARCH_PROTECT & eSearchType );
- else if( nsSwTableSearchType::TBLSEARCH_COL == ((~nsSwTableSearchType::TBLSEARCH_PROTECT ) & eSearchType ) )
- ::lcl_FindStartEndCol( pStart, pEnd, nsSwTableSearchType::TBLSEARCH_PROTECT & eSearchType );
+ if( SwTableSearchType::Row == ((~SwTableSearchType::Protect ) & eSearchType ) )
+ ::lcl_FindStartEndRow( pStart, pEnd, bool(SwTableSearchType::Protect & eSearchType) );
+ else if( SwTableSearchType::Col == ((~SwTableSearchType::Protect ) & eSearchType ) )
+ ::lcl_FindStartEndCol( pStart, pEnd, bool(SwTableSearchType::Protect & eSearchType) );
if ( !pEnd || !pStart ) return; // Made code robust.
@@ -1853,7 +1853,7 @@ void MakeSelUnions( SwSelUnions& rUnions, const SwLayoutFrame *pStart,
SwRect aUnion( aSt, Size( aDiff.X(), aDiff.Y() ) );
aUnion.Justify();
- if( !(nsSwTableSearchType::TBLSEARCH_NO_UNION_CORRECT & eSearchType ))
+ if( !(SwTableSearchType::NoUnionCorrect & eSearchType ))
{
// Unfortunately the union contains rounding errors now, therefore
// erroneous results could occur during split/merge.
diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx
index 8dc2bf08638e..5cd874fe3832 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -1345,7 +1345,7 @@ void SwTableShell::GetState(SfxItemSet &rSet)
case FN_TABLE_DELETE_ROW:
{
SwSelBoxes aBoxes;
- ::GetTableSel( rSh, aBoxes, nsSwTableSearchType::TBLSEARCH_ROW );
+ ::GetTableSel( rSh, aBoxes, SwTableSearchType::Row );
if( ::HasProtectedCells( aBoxes ))
rSet.DisableItem( nSlot );
}
@@ -1353,7 +1353,7 @@ void SwTableShell::GetState(SfxItemSet &rSet)
case FN_TABLE_DELETE_COL:
{
SwSelBoxes aBoxes;
- ::GetTableSel( rSh, aBoxes, nsSwTableSearchType::TBLSEARCH_COL );
+ ::GetTableSel( rSh, aBoxes, SwTableSearchType::Col );
if( ::HasProtectedCells( aBoxes ))
rSet.DisableItem( nSlot );
}
More information about the Libreoffice-commits
mailing list