diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 7178c0dca3a2..b9b55515ccd5 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1532,8 +1532,8 @@ public: sal_uInt16 GetBoxAlign( const SwCursor& rCursor ) const; void AdjustCellWidth( const SwCursor& rCursor, bool bBalance = false ); - int Chainable( const SwFrmFmt &rSource, const SwFrmFmt &rDest ); - int Chain( SwFrmFmt &rSource, const SwFrmFmt &rDest ); + SwChainRet Chainable( const SwFrmFmt &rSource, const SwFrmFmt &rDest ); + SwChainRet Chain( SwFrmFmt &rSource, const SwFrmFmt &rDest ); void Unchain( SwFrmFmt &rFmt ); // For Copy/Move from FrmShell. diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx index 55ef44beb866..dc8edfd3153c 100644 --- a/sw/inc/fesh.hxx +++ b/sw/inc/fesh.hxx @@ -447,9 +447,9 @@ public: /** For Chain always connect Fly specified by format with that hit by point. rRect contains rect of Fly (for its highlight). */ - int Chainable( SwRect &rRect, const SwFrmFmt &rSource, const Point &rPt ) const; - int Chain( SwFrmFmt &rSource, const Point &rPt ); - int Chain( SwFrmFmt &rSource, const SwFrmFmt &rDest ); + SwChainRet Chainable( SwRect &rRect, const SwFrmFmt &rSource, const Point &rPt ) const; + SwChainRet Chain( SwFrmFmt &rSource, const Point &rPt ); + SwChainRet Chain( SwFrmFmt &rSource, const SwFrmFmt &rDest ); void Unchain( SwFrmFmt &rFmt ); void HideChainMarker(); void SetChainMarker(); diff --git a/sw/inc/flyenum.hxx b/sw/inc/flyenum.hxx index 743adc2bd00f..469bb13ea6c0 100644 --- a/sw/inc/flyenum.hxx +++ b/sw/inc/flyenum.hxx @@ -30,14 +30,17 @@ enum FlyCntType }; // Return values for chainable and chain. -#define SW_CHAIN_OK 0 -#define SW_CHAIN_NOT_EMPTY 1 ///< Only empty frames may be connected. -#define SW_CHAIN_IS_IN_CHAIN 2 ///< Destination already in chain. -#define SW_CHAIN_WRONG_AREA 3 /**< Destination in section where it shouldn't be - (header, footer). */ -#define SW_CHAIN_NOT_FOUND 4 ///< Destination and/or source not found. -#define SW_CHAIN_SOURCE_CHAINED 5 ///< Source already has a follow. -#define SW_CHAIN_SELF 6 ///< Self-chaining is not allowed. +enum class SwChainRet +{ + OK = 0, + NOT_EMPTY = 1, ///< Only empty frames may be connected. + IS_IN_CHAIN = 2, ///< Destination already in chain. + WRONG_AREA = 3, /**< Destination in section where it shouldn't be + (header, footer). */ + NOT_FOUND = 4, ///< Destination and/or source not found. + SOURCE_CHAINED = 5, ///< Source already has a follow. + SELF = 6 ///< Self-chaining is not allowed. +}; #endif diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index 0e39cfb64537..701dea332412 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -929,45 +929,45 @@ bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, return bUnmark; } -int SwDoc::Chainable( const SwFrmFmt &rSource, const SwFrmFmt &rDest ) +SwChainRet SwDoc::Chainable( const SwFrmFmt &rSource, const SwFrmFmt &rDest ) { // The Source must not yet have a Follow. const SwFmtChain &rOldChain = rSource.GetChain(); if ( rOldChain.GetNext() ) - return SW_CHAIN_SOURCE_CHAINED; + return SwChainRet::SOURCE_CHAINED; // Target must not be equal to Source and we also must not have a closed chain. const SwFrmFmt *pFmt = &rDest; do { if( pFmt == &rSource ) - return SW_CHAIN_SELF; + return SwChainRet::SELF; pFmt = pFmt->GetChain().GetNext(); } while ( pFmt ); // There must not be a chaining from outside to inside or the other way around. if( rDest.IsLowerOf( rSource ) || rSource .IsLowerOf( rDest ) ) - return SW_CHAIN_SELF; + return SwChainRet::SELF; // The Target must not yet have a Master. const SwFmtChain &rChain = rDest.GetChain(); if( rChain.GetPrev() ) - return SW_CHAIN_IS_IN_CHAIN; + return SwChainRet::IS_IN_CHAIN; // Target must be empty. const SwNodeIndex* pCntIdx = rDest.GetCntnt().GetCntntIdx(); if( !pCntIdx ) - return SW_CHAIN_NOT_FOUND; + return SwChainRet::NOT_FOUND; SwNodeIndex aNxtIdx( *pCntIdx, 1 ); const SwTxtNode* pTxtNd = aNxtIdx.GetNode().GetTxtNode(); if( !pTxtNd ) - return SW_CHAIN_NOT_FOUND; + return SwChainRet::NOT_FOUND; const sal_uLong nFlySttNd = pCntIdx->GetIndex(); if( 2 != ( pCntIdx->GetNode().EndOfSectionIndex() - nFlySttNd ) || pTxtNd->GetTxt().getLength() ) { - return SW_CHAIN_NOT_EMPTY; + return SwChainRet::NOT_EMPTY; } for( auto pSpzFrmFm : *GetSpzFrmFmts() ) @@ -982,7 +982,7 @@ int SwDoc::Chainable( const SwFrmFmt &rSource, const SwFrmFmt &rDest ) rAnchor.GetCntntAnchor()->nNode.GetIndex() ) && nTstSttNd < nFlySttNd + 2 ) { - return SW_CHAIN_NOT_EMPTY; + return SwChainRet::NOT_EMPTY; } } @@ -1023,13 +1023,13 @@ int SwDoc::Chainable( const SwFrmFmt &rSource, const SwFrmFmt &rDest ) bAllowed = true; } - return bAllowed ? SW_CHAIN_OK : SW_CHAIN_WRONG_AREA; + return bAllowed ? SwChainRet::OK : SwChainRet::WRONG_AREA; } -int SwDoc::Chain( SwFrmFmt &rSource, const SwFrmFmt &rDest ) +SwChainRet SwDoc::Chain( SwFrmFmt &rSource, const SwFrmFmt &rDest ) { - int nErr = Chainable( rSource, rDest ); - if ( !nErr ) + SwChainRet nErr = Chainable( rSource, rDest ); + if ( nErr == SwChainRet::OK ) { GetIDocumentUndoRedo().StartUndo( UNDO_CHAINE, NULL ); diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index ab8f8fd9f4e7..4e34bb0da377 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -1857,14 +1857,14 @@ void SwFEShell::GetConnectableFrmFmts(SwFrmFmt & rFmt, after pFmt. */ - int nChainState; + SwChainRet nChainState; if (bSuccessors) nChainState = mpDoc->Chainable(rFmt, rFmt1); else nChainState = mpDoc->Chainable(rFmt1, rFmt); - if (nChainState == SW_CHAIN_OK) + if (nChainState == SwChainRet::OK) { aTmpSpzArray.push_back(&rFmt1); diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index f092a6c289e5..501d52e53da4 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -2496,7 +2496,7 @@ void SwFEShell::SetCalcFieldValueHdl(Outliner* pOutliner) GetDoc()->SetCalcFieldValueHdl(pOutliner); } -int SwFEShell::Chainable( SwRect &rRect, const SwFrmFmt &rSource, +SwChainRet SwFEShell::Chainable( SwRect &rRect, const SwFrmFmt &rSource, const Point &rPt ) const { rRect.Clear(); @@ -2504,9 +2504,9 @@ int SwFEShell::Chainable( SwRect &rRect, const SwFrmFmt &rSource, // The source is not allowed to have a follow. const SwFmtChain &rChain = rSource.GetChain(); if ( rChain.GetNext() ) - return SW_CHAIN_SOURCE_CHAINED; + return SwChainRet::SOURCE_CHAINED; - int nRet = SW_CHAIN_NOT_FOUND; + SwChainRet nRet = SwChainRet::NOT_FOUND; if( Imp()->HasDrawView() ) { SdrObject* pObj; @@ -2530,16 +2530,16 @@ int SwFEShell::Chainable( SwRect &rRect, const SwFrmFmt &rSource, return nRet; } -int SwFEShell::Chain( SwFrmFmt &rSource, const SwFrmFmt &rDest ) +SwChainRet SwFEShell::Chain( SwFrmFmt &rSource, const SwFrmFmt &rDest ) { return GetDoc()->Chain(rSource, rDest); } -int SwFEShell::Chain( SwFrmFmt &rSource, const Point &rPt ) +SwChainRet SwFEShell::Chain( SwFrmFmt &rSource, const Point &rPt ) { SwRect aDummy; - int nErr = Chainable( aDummy, rSource, rPt ); - if ( !nErr ) + SwChainRet nErr = Chainable( aDummy, rSource, rPt ); + if ( nErr == SwChainRet::OK ) { StartAllAction(); SdrObject* pObj; diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index abb3cfc1b599..c9cda8ab0227 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -385,10 +385,10 @@ void SwEditWin::UpdatePointer(const Point &rLPt, sal_uInt16 nModifier ) if ( IsChainMode() ) { SwRect aRect; - int nChainable = rSh.Chainable( aRect, *rSh.GetFlyFrmFmt(), rLPt ); - PointerStyle eStyle = nChainable + SwChainRet nChainable = rSh.Chainable( aRect, *rSh.GetFlyFrmFmt(), rLPt ); + PointerStyle eStyle = nChainable != SwChainRet::OK ? POINTER_CHAIN_NOTALLOWED : POINTER_CHAIN; - if ( !nChainable ) + if ( nChainable == SwChainRet::OK ) { Rectangle aTmp( aRect.SVRect() ); @@ -2957,7 +2957,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) SetChainMode( false ); SwRect aDummy; SwFlyFrmFmt *pFmt = static_cast(rSh.GetFlyFrmFmt()); - if ( !rSh.Chainable( aDummy, *pFmt, aDocPos ) ) + if ( rSh.Chainable( aDummy, *pFmt, aDocPos ) == SwChainRet::OK ) rSh.Chain( *pFmt, aDocPos ); UpdatePointer( aDocPos, rMEvt.GetModifier() ); return;