[Libreoffice-commits] core.git: sw/inc sw/source

Noel Grandin noel.grandin at collabora.co.uk
Wed Nov 30 06:24:26 UTC 2016


 sw/inc/undobj.hxx              |   23 +++++++++++++----------
 sw/source/core/undo/undel.cxx  |    6 +++---
 sw/source/core/undo/undobj.cxx |   22 +++++++++++-----------
 sw/source/core/undo/unmove.cxx |    4 ++--
 4 files changed, 29 insertions(+), 26 deletions(-)

New commits:
commit b5a1f7cbf9c83f7b1cc6ea103047147ce3d63fee
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Nov 29 13:08:34 2016 +0200

    convert DelContentType to o3tl::typed_flags
    
    Change-Id: I2c94b28e4c95c22c05ba7aed8e413cc7f6b70874
    Reviewed-on: https://gerrit.libreoffice.org/31358
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx
index ef154ca..fedc567 100644
--- a/sw/inc/undobj.hxx
+++ b/sw/inc/undobj.hxx
@@ -26,6 +26,7 @@
 #include <tools/solar.h>
 #include <SwRewriter.hxx>
 #include <swundo.hxx>
+#include <o3tl/typed_flags_set.hxx>
 
 class SwHistory;
 class SwIndex;
@@ -125,21 +126,23 @@ public:
     static bool HasHiddenRedlines( const SwRedlineSaveDatas& rSData );
 };
 
-typedef sal_uInt16 DelContentType;
-namespace nsDelContentType
+enum class DelContentType : sal_uInt16
 {
-    const DelContentType DELCNT_FTN = 0x01;
-    const DelContentType DELCNT_FLY = 0x02;
-    const DelContentType DELCNT_TOC = 0x04;
-    const DelContentType DELCNT_BKM = 0x08;
-    const DelContentType DELCNT_ALL = 0x0F;
-    const DelContentType DELCNT_CHKNOCNTNT = 0x80;
+    Ftn          = 0x01,
+    Fly          = 0x02,
+    Toc          = 0x04,
+    Bkm          = 0x08,
+    AllMask      = 0x0F,
+    CheckNoCntnt = 0x80,
+};
+namespace o3tl {
+    template<> struct typed_flags<DelContentType> : is_typed_flags<DelContentType, 0x8f> {};
 }
 
 /// will DelContentIndex destroy a frame anchored at character at rAnchorPos?
 bool IsDestroyFrameAnchoredAtChar(SwPosition const & rAnchorPos,
         SwPosition const & rStart, SwPosition const & rEnd, const SwDoc* doc,
-        DelContentType const nDelContentType = nsDelContentType::DELCNT_ALL);
+        DelContentType const nDelContentType = DelContentType::AllMask);
 
 // This class has to be inherited into an Undo-object if it saves content
 // for Redo/Undo...
@@ -171,7 +174,7 @@ protected:
     // Before moving stuff into UndoNodes-Array care has to be taken that
     // the content-bearing attributes are removed from the nodes-array.
     void DelContentIndex( const SwPosition& pMark, const SwPosition& pPoint,
-                        DelContentType nDelContentType = nsDelContentType::DELCNT_ALL );
+                        DelContentType nDelContentType = DelContentType::AllMask );
 
 public:
     SwUndoSaveContent();
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index 073ed50..2b91ad4 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -147,7 +147,7 @@ SwUndoDelete::SwUndoDelete(
     {
         OSL_ENSURE( rPam.HasMark(), "PaM ohne Mark" );
         DelContentIndex( *rPam.GetMark(), *rPam.GetPoint(),
-                        DelContentType(nsDelContentType::DELCNT_ALL | nsDelContentType::DELCNT_CHKNOCNTNT) );
+                        DelContentType(DelContentType::AllMask | DelContentType::CheckNoCntnt) );
 
         ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
         DelBookmarks(pStt->nNode, pEnd->nNode);
@@ -990,7 +990,7 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext)
         {
             OSL_ENSURE( rPam.HasMark(), "PaM without Mark" );
             DelContentIndex( *rPam.GetMark(), *rPam.GetPoint(),
-                            DelContentType(nsDelContentType::DELCNT_ALL | nsDelContentType::DELCNT_CHKNOCNTNT) );
+                            DelContentType(DelContentType::AllMask | DelContentType::CheckNoCntnt) );
 
             DelBookmarks(rPam.GetMark()->nNode, rPam.GetPoint()->nNode);
         }
@@ -1006,7 +1006,7 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext)
         {
             OSL_ENSURE( rPam.HasMark(), "PaM without Mark" );
             DelContentIndex( *rPam.GetMark(), *rPam.GetPoint(),
-                            DelContentType(nsDelContentType::DELCNT_ALL | nsDelContentType::DELCNT_CHKNOCNTNT) );
+                            DelContentType(DelContentType::AllMask | DelContentType::CheckNoCntnt) );
 
             DelBookmarks( rPam.GetMark()->nNode, rPam.GetPoint()->nNode );
         }
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index e630254..5d0dfb2 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -471,7 +471,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
     ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
 
     // 1. Footnotes
-    if( nsDelContentType::DELCNT_FTN & nDelContentType )
+    if( DelContentType::Ftn & nDelContentType )
     {
         SwFootnoteIdxs& rFootnoteArr = pDoc->GetFootnoteIdxs();
         if( !rFootnoteArr.empty() )
@@ -487,7 +487,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
                         <= pEnd->nNode.GetIndex() )
             {
                 const sal_Int32 nFootnoteSttIdx = pSrch->GetStart();
-                if( (nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType )
+                if( (DelContentType::CheckNoCntnt & nDelContentType )
                     ? (&pEnd->nNode.GetNode() == pFootnoteNd )
                     : (( &pStt->nNode.GetNode() == pFootnoteNd &&
                     pStt->nContent.GetIndex() > nFootnoteSttIdx) ||
@@ -517,7 +517,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
                     GetTextNode())->GetIndex() >= pStt->nNode.GetIndex() )
             {
                 const sal_Int32 nFootnoteSttIdx = pSrch->GetStart();
-                if( !(nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType) && (
+                if( !(DelContentType::CheckNoCntnt & nDelContentType) && (
                     ( &pStt->nNode.GetNode() == pFootnoteNd &&
                     pStt->nContent.GetIndex() > nFootnoteSttIdx ) ||
                     ( &pEnd->nNode.GetNode() == pFootnoteNd &&
@@ -541,7 +541,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
     }
 
     // 2. Flys
-    if( nsDelContentType::DELCNT_FLY & nDelContentType )
+    if( DelContentType::Fly & nDelContentType )
     {
         sal_uInt16 nChainInsPos = pHistory ? pHistory->Count() : 0;
         const SwFrameFormats& rSpzArr = *pDoc->GetSpzFrameFormats();
@@ -561,7 +561,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
                 {
                 case FLY_AS_CHAR:
                     if( nullptr != (pAPos = pAnchor->GetContentAnchor() ) &&
-                        (( nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType )
+                        (( DelContentType::CheckNoCntnt & nDelContentType )
                         ? ( pStt->nNode <= pAPos->nNode &&
                             pAPos->nNode < pEnd->nNode )
                         : ( *pStt <= *pAPos && *pAPos < *pEnd )) )
@@ -584,7 +584,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
                         if( pAPos )
                         {
                             bool bTmp;
-                            if( nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType )
+                            if( DelContentType::CheckNoCntnt & nDelContentType )
                                 bTmp = pStt->nNode <= pAPos->nNode && pAPos->nNode < pEnd->nNode;
                             else
                             {
@@ -602,7 +602,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
                                     pHistory = new SwHistory;
 
                                 // Moving the anchor?
-                                if( !( nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType ) &&
+                                if( !( DelContentType::CheckNoCntnt & nDelContentType ) &&
                                     ( rPoint.nNode.GetIndex() == pAPos->nNode.GetIndex() ) )
                                 {
                                     // Do not try to move the anchor to a table!
@@ -638,7 +638,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
                             pHistory->Add( *static_cast<SwFlyFrameFormat *>(pFormat), nChainInsPos );
                             n = n >= rSpzArr.size() ? rSpzArr.size() : n+1;
                         }
-                        else if( !( nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType ) )
+                        else if( !( DelContentType::CheckNoCntnt & nDelContentType ) )
                         {
                             if( *pStt <= *pAPos && *pAPos < *pEnd )
                             {
@@ -677,7 +677,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
     }
 
     // 3. Bookmarks
-    if( nsDelContentType::DELCNT_BKM & nDelContentType )
+    if( DelContentType::Bkm & nDelContentType )
     {
         IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
         if( pMarkAccess->getAllMarksCount() )
@@ -690,7 +690,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
                 bool bSaveOtherPos = false;
                 const ::sw::mark::IMark* pBkmk = (pMarkAccess->getAllMarksBegin() + n)->get();
 
-                if( nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType )
+                if( DelContentType::CheckNoCntnt & nDelContentType )
                 {
                     if ( pStt->nNode <= pBkmk->GetMarkPos().nNode
                          && pBkmk->GetMarkPos().nNode < pEnd->nNode )
@@ -1155,7 +1155,7 @@ bool IsDestroyFrameAnchoredAtChar(SwPosition const & rAnchorPos,
     // - anchored in start of the selection with "CheckNoContent"
     // - anchored in start of sel. and the selection start at pos 0
     return  inSelection
-         && (   (nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType)
+         && (   (DelContentType::CheckNoCntnt & nDelContentType)
             ||  (rStart.nNode < rAnchorPos.nNode)
             ||  !rStart.nContent.GetIndex()
             );
diff --git a/sw/source/core/undo/unmove.cxx b/sw/source/core/undo/unmove.cxx
index c833359..a2c0ffb 100644
--- a/sw/source/core/undo/unmove.cxx
+++ b/sw/source/core/undo/unmove.cxx
@@ -129,7 +129,7 @@ SwUndoMove::SwUndoMove( SwDoc* pDoc, const SwNodeRange& rRg,
         if( nullptr != ( pCNd = aMkPos.nNode.GetNode().GetContentNode() ))
             aMkPos.nContent.Assign( pCNd, 0 );
 
-        DelContentIndex( aMkPos, aPtPos, nsDelContentType::DELCNT_FTN );
+        DelContentIndex( aMkPos, aPtPos, DelContentType::Ftn );
 
         if( pHistory && !pHistory->Count() )
             DELETEZ( pHistory );
@@ -338,7 +338,7 @@ void SwUndoMove::DelFootnote( const SwPaM& rRange )
     {
         // delete all footnotes since they are undesired there
         DelContentIndex( *rRange.GetMark(), *rRange.GetPoint(),
-                            nsDelContentType::DELCNT_FTN );
+                            DelContentType::Ftn );
 
         if( pHistory && !pHistory->Count() )
         {


More information about the Libreoffice-commits mailing list