Kaydet (Commit) b5a1f7cb authored tarafından Noel Grandin's avatar Noel Grandin

convert DelContentType to o3tl::typed_flags

Change-Id: I2c94b28e4c95c22c05ba7aed8e413cc7f6b70874
Reviewed-on: https://gerrit.libreoffice.org/31358Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 3c1b1fb9
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <tools/solar.h> #include <tools/solar.h>
#include <SwRewriter.hxx> #include <SwRewriter.hxx>
#include <swundo.hxx> #include <swundo.hxx>
#include <o3tl/typed_flags_set.hxx>
class SwHistory; class SwHistory;
class SwIndex; class SwIndex;
...@@ -125,21 +126,23 @@ public: ...@@ -125,21 +126,23 @@ public:
static bool HasHiddenRedlines( const SwRedlineSaveDatas& rSData ); static bool HasHiddenRedlines( const SwRedlineSaveDatas& rSData );
}; };
typedef sal_uInt16 DelContentType; enum class DelContentType : sal_uInt16
namespace nsDelContentType
{ {
const DelContentType DELCNT_FTN = 0x01; Ftn = 0x01,
const DelContentType DELCNT_FLY = 0x02; Fly = 0x02,
const DelContentType DELCNT_TOC = 0x04; Toc = 0x04,
const DelContentType DELCNT_BKM = 0x08; Bkm = 0x08,
const DelContentType DELCNT_ALL = 0x0F; AllMask = 0x0F,
const DelContentType DELCNT_CHKNOCNTNT = 0x80; CheckNoCntnt = 0x80,
};
namespace o3tl {
template<> struct typed_flags<DelContentType> : is_typed_flags<DelContentType, 0x8f> {};
} }
/// will DelContentIndex destroy a frame anchored at character at rAnchorPos? /// will DelContentIndex destroy a frame anchored at character at rAnchorPos?
bool IsDestroyFrameAnchoredAtChar(SwPosition const & rAnchorPos, bool IsDestroyFrameAnchoredAtChar(SwPosition const & rAnchorPos,
SwPosition const & rStart, SwPosition const & rEnd, const SwDoc* doc, 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 // This class has to be inherited into an Undo-object if it saves content
// for Redo/Undo... // for Redo/Undo...
...@@ -171,7 +174,7 @@ protected: ...@@ -171,7 +174,7 @@ protected:
// Before moving stuff into UndoNodes-Array care has to be taken that // Before moving stuff into UndoNodes-Array care has to be taken that
// the content-bearing attributes are removed from the nodes-array. // the content-bearing attributes are removed from the nodes-array.
void DelContentIndex( const SwPosition& pMark, const SwPosition& pPoint, void DelContentIndex( const SwPosition& pMark, const SwPosition& pPoint,
DelContentType nDelContentType = nsDelContentType::DELCNT_ALL ); DelContentType nDelContentType = DelContentType::AllMask );
public: public:
SwUndoSaveContent(); SwUndoSaveContent();
......
...@@ -147,7 +147,7 @@ SwUndoDelete::SwUndoDelete( ...@@ -147,7 +147,7 @@ SwUndoDelete::SwUndoDelete(
{ {
OSL_ENSURE( rPam.HasMark(), "PaM ohne Mark" ); OSL_ENSURE( rPam.HasMark(), "PaM ohne Mark" );
DelContentIndex( *rPam.GetMark(), *rPam.GetPoint(), DelContentIndex( *rPam.GetMark(), *rPam.GetPoint(),
DelContentType(nsDelContentType::DELCNT_ALL | nsDelContentType::DELCNT_CHKNOCNTNT) ); DelContentType(DelContentType::AllMask | DelContentType::CheckNoCntnt) );
::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
DelBookmarks(pStt->nNode, pEnd->nNode); DelBookmarks(pStt->nNode, pEnd->nNode);
...@@ -990,7 +990,7 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext) ...@@ -990,7 +990,7 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext)
{ {
OSL_ENSURE( rPam.HasMark(), "PaM without Mark" ); OSL_ENSURE( rPam.HasMark(), "PaM without Mark" );
DelContentIndex( *rPam.GetMark(), *rPam.GetPoint(), DelContentIndex( *rPam.GetMark(), *rPam.GetPoint(),
DelContentType(nsDelContentType::DELCNT_ALL | nsDelContentType::DELCNT_CHKNOCNTNT) ); DelContentType(DelContentType::AllMask | DelContentType::CheckNoCntnt) );
DelBookmarks(rPam.GetMark()->nNode, rPam.GetPoint()->nNode); DelBookmarks(rPam.GetMark()->nNode, rPam.GetPoint()->nNode);
} }
...@@ -1006,7 +1006,7 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext) ...@@ -1006,7 +1006,7 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext)
{ {
OSL_ENSURE( rPam.HasMark(), "PaM without Mark" ); OSL_ENSURE( rPam.HasMark(), "PaM without Mark" );
DelContentIndex( *rPam.GetMark(), *rPam.GetPoint(), DelContentIndex( *rPam.GetMark(), *rPam.GetPoint(),
DelContentType(nsDelContentType::DELCNT_ALL | nsDelContentType::DELCNT_CHKNOCNTNT) ); DelContentType(DelContentType::AllMask | DelContentType::CheckNoCntnt) );
DelBookmarks( rPam.GetMark()->nNode, rPam.GetPoint()->nNode ); DelBookmarks( rPam.GetMark()->nNode, rPam.GetPoint()->nNode );
} }
......
...@@ -471,7 +471,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark, ...@@ -471,7 +471,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
// 1. Footnotes // 1. Footnotes
if( nsDelContentType::DELCNT_FTN & nDelContentType ) if( DelContentType::Ftn & nDelContentType )
{ {
SwFootnoteIdxs& rFootnoteArr = pDoc->GetFootnoteIdxs(); SwFootnoteIdxs& rFootnoteArr = pDoc->GetFootnoteIdxs();
if( !rFootnoteArr.empty() ) if( !rFootnoteArr.empty() )
...@@ -487,7 +487,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark, ...@@ -487,7 +487,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
<= pEnd->nNode.GetIndex() ) <= pEnd->nNode.GetIndex() )
{ {
const sal_Int32 nFootnoteSttIdx = pSrch->GetStart(); const sal_Int32 nFootnoteSttIdx = pSrch->GetStart();
if( (nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType ) if( (DelContentType::CheckNoCntnt & nDelContentType )
? (&pEnd->nNode.GetNode() == pFootnoteNd ) ? (&pEnd->nNode.GetNode() == pFootnoteNd )
: (( &pStt->nNode.GetNode() == pFootnoteNd && : (( &pStt->nNode.GetNode() == pFootnoteNd &&
pStt->nContent.GetIndex() > nFootnoteSttIdx) || pStt->nContent.GetIndex() > nFootnoteSttIdx) ||
...@@ -517,7 +517,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark, ...@@ -517,7 +517,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
GetTextNode())->GetIndex() >= pStt->nNode.GetIndex() ) GetTextNode())->GetIndex() >= pStt->nNode.GetIndex() )
{ {
const sal_Int32 nFootnoteSttIdx = pSrch->GetStart(); const sal_Int32 nFootnoteSttIdx = pSrch->GetStart();
if( !(nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType) && ( if( !(DelContentType::CheckNoCntnt & nDelContentType) && (
( &pStt->nNode.GetNode() == pFootnoteNd && ( &pStt->nNode.GetNode() == pFootnoteNd &&
pStt->nContent.GetIndex() > nFootnoteSttIdx ) || pStt->nContent.GetIndex() > nFootnoteSttIdx ) ||
( &pEnd->nNode.GetNode() == pFootnoteNd && ( &pEnd->nNode.GetNode() == pFootnoteNd &&
...@@ -541,7 +541,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark, ...@@ -541,7 +541,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
} }
// 2. Flys // 2. Flys
if( nsDelContentType::DELCNT_FLY & nDelContentType ) if( DelContentType::Fly & nDelContentType )
{ {
sal_uInt16 nChainInsPos = pHistory ? pHistory->Count() : 0; sal_uInt16 nChainInsPos = pHistory ? pHistory->Count() : 0;
const SwFrameFormats& rSpzArr = *pDoc->GetSpzFrameFormats(); const SwFrameFormats& rSpzArr = *pDoc->GetSpzFrameFormats();
...@@ -561,7 +561,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark, ...@@ -561,7 +561,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
{ {
case FLY_AS_CHAR: case FLY_AS_CHAR:
if( nullptr != (pAPos = pAnchor->GetContentAnchor() ) && if( nullptr != (pAPos = pAnchor->GetContentAnchor() ) &&
(( nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType ) (( DelContentType::CheckNoCntnt & nDelContentType )
? ( pStt->nNode <= pAPos->nNode && ? ( pStt->nNode <= pAPos->nNode &&
pAPos->nNode < pEnd->nNode ) pAPos->nNode < pEnd->nNode )
: ( *pStt <= *pAPos && *pAPos < *pEnd )) ) : ( *pStt <= *pAPos && *pAPos < *pEnd )) )
...@@ -584,7 +584,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark, ...@@ -584,7 +584,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
if( pAPos ) if( pAPos )
{ {
bool bTmp; bool bTmp;
if( nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType ) if( DelContentType::CheckNoCntnt & nDelContentType )
bTmp = pStt->nNode <= pAPos->nNode && pAPos->nNode < pEnd->nNode; bTmp = pStt->nNode <= pAPos->nNode && pAPos->nNode < pEnd->nNode;
else else
{ {
...@@ -602,7 +602,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark, ...@@ -602,7 +602,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
pHistory = new SwHistory; pHistory = new SwHistory;
// Moving the anchor? // Moving the anchor?
if( !( nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType ) && if( !( DelContentType::CheckNoCntnt & nDelContentType ) &&
( rPoint.nNode.GetIndex() == pAPos->nNode.GetIndex() ) ) ( rPoint.nNode.GetIndex() == pAPos->nNode.GetIndex() ) )
{ {
// Do not try to move the anchor to a table! // Do not try to move the anchor to a table!
...@@ -638,7 +638,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark, ...@@ -638,7 +638,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
pHistory->Add( *static_cast<SwFlyFrameFormat *>(pFormat), nChainInsPos ); pHistory->Add( *static_cast<SwFlyFrameFormat *>(pFormat), nChainInsPos );
n = n >= rSpzArr.size() ? rSpzArr.size() : n+1; n = n >= rSpzArr.size() ? rSpzArr.size() : n+1;
} }
else if( !( nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType ) ) else if( !( DelContentType::CheckNoCntnt & nDelContentType ) )
{ {
if( *pStt <= *pAPos && *pAPos < *pEnd ) if( *pStt <= *pAPos && *pAPos < *pEnd )
{ {
...@@ -677,7 +677,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark, ...@@ -677,7 +677,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
} }
// 3. Bookmarks // 3. Bookmarks
if( nsDelContentType::DELCNT_BKM & nDelContentType ) if( DelContentType::Bkm & nDelContentType )
{ {
IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
if( pMarkAccess->getAllMarksCount() ) if( pMarkAccess->getAllMarksCount() )
...@@ -690,7 +690,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark, ...@@ -690,7 +690,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
bool bSaveOtherPos = false; bool bSaveOtherPos = false;
const ::sw::mark::IMark* pBkmk = (pMarkAccess->getAllMarksBegin() + n)->get(); const ::sw::mark::IMark* pBkmk = (pMarkAccess->getAllMarksBegin() + n)->get();
if( nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType ) if( DelContentType::CheckNoCntnt & nDelContentType )
{ {
if ( pStt->nNode <= pBkmk->GetMarkPos().nNode if ( pStt->nNode <= pBkmk->GetMarkPos().nNode
&& pBkmk->GetMarkPos().nNode < pEnd->nNode ) && pBkmk->GetMarkPos().nNode < pEnd->nNode )
...@@ -1155,7 +1155,7 @@ bool IsDestroyFrameAnchoredAtChar(SwPosition const & rAnchorPos, ...@@ -1155,7 +1155,7 @@ bool IsDestroyFrameAnchoredAtChar(SwPosition const & rAnchorPos,
// - anchored in start of the selection with "CheckNoContent" // - anchored in start of the selection with "CheckNoContent"
// - anchored in start of sel. and the selection start at pos 0 // - anchored in start of sel. and the selection start at pos 0
return inSelection return inSelection
&& ( (nsDelContentType::DELCNT_CHKNOCNTNT & nDelContentType) && ( (DelContentType::CheckNoCntnt & nDelContentType)
|| (rStart.nNode < rAnchorPos.nNode) || (rStart.nNode < rAnchorPos.nNode)
|| !rStart.nContent.GetIndex() || !rStart.nContent.GetIndex()
); );
......
...@@ -129,7 +129,7 @@ SwUndoMove::SwUndoMove( SwDoc* pDoc, const SwNodeRange& rRg, ...@@ -129,7 +129,7 @@ SwUndoMove::SwUndoMove( SwDoc* pDoc, const SwNodeRange& rRg,
if( nullptr != ( pCNd = aMkPos.nNode.GetNode().GetContentNode() )) if( nullptr != ( pCNd = aMkPos.nNode.GetNode().GetContentNode() ))
aMkPos.nContent.Assign( pCNd, 0 ); aMkPos.nContent.Assign( pCNd, 0 );
DelContentIndex( aMkPos, aPtPos, nsDelContentType::DELCNT_FTN ); DelContentIndex( aMkPos, aPtPos, DelContentType::Ftn );
if( pHistory && !pHistory->Count() ) if( pHistory && !pHistory->Count() )
DELETEZ( pHistory ); DELETEZ( pHistory );
...@@ -338,7 +338,7 @@ void SwUndoMove::DelFootnote( const SwPaM& rRange ) ...@@ -338,7 +338,7 @@ void SwUndoMove::DelFootnote( const SwPaM& rRange )
{ {
// delete all footnotes since they are undesired there // delete all footnotes since they are undesired there
DelContentIndex( *rRange.GetMark(), *rRange.GetPoint(), DelContentIndex( *rRange.GetMark(), *rRange.GetPoint(),
nsDelContentType::DELCNT_FTN ); DelContentType::Ftn );
if( pHistory && !pHistory->Count() ) if( pHistory && !pHistory->Count() )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment