diff options
Diffstat (limited to 'sw/source/core/frmedt/fews.cxx')
-rw-r--r-- | sw/source/core/frmedt/fews.cxx | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx index fd1d137b15f4..539f48531353 100644 --- a/sw/source/core/frmedt/fews.cxx +++ b/sw/source/core/frmedt/fews.cxx @@ -18,6 +18,7 @@ */ #include <svx/svdobj.hxx> +#include <osl/diagnose.h> #include <comphelper/lok.hxx> #include <init.hxx> #include <fesh.hxx> @@ -49,6 +50,7 @@ #include <dflyobj.hxx> #include <dcontact.hxx> #include <UndoInsert.hxx> +#include <formatflysplit.hxx> using namespace com::sun::star; @@ -101,7 +103,7 @@ const SwRect& SwFEShell::GetAnyCurRect( CurRectType eType, const Point* pPt, SwPosition aPos( *GetCursor()->GetPoint() ); Point aPt( *pPt ); GetLayout()->GetModelPositionForViewPoint( &aPos, aPt ); - SwContentNode *pNd = aPos.nNode.GetNode().GetContentNode(); + SwContentNode *pNd = aPos.GetNode().GetContentNode(); std::pair<Point, bool> const tmp(*pPt, true); pFrame = pNd->getLayoutFrame(GetLayout(), nullptr, &tmp); } @@ -184,7 +186,7 @@ const SwRect& SwFEShell::GetAnyCurRect( CurRectType eType, const Point* pPt, sal_uInt16 SwFEShell::GetPageNumber( const Point &rPoint ) const { const SwFrame *pPage = GetLayout()->Lower(); - while ( pPage && !pPage->getFrameArea().IsInside( rPoint ) ) + while ( pPage && !pPage->getFrameArea().Contains( rPoint ) ) pPage = pPage->GetNext(); if ( pPage ) return static_cast<const SwPageFrame*>(pPage)->GetPhyPageNum(); @@ -242,7 +244,7 @@ FrameTypeFlags SwFEShell::GetFrameType( const Point *pPt, bool bStopAtFly ) cons SwPosition aPos( *GetCursor()->GetPoint() ); Point aPt( *pPt ); GetLayout()->GetModelPositionForViewPoint( &aPos, aPt ); - SwContentNode *pNd = aPos.nNode.GetNode().GetContentNode(); + SwContentNode *pNd = aPos.GetNode().GetContentNode(); std::pair<Point, bool> const tmp(*pPt, true); pFrame = pNd->getLayoutFrame(GetLayout(), nullptr, &tmp); } @@ -432,7 +434,7 @@ void SwFEShell::InsertLabel( const SwLabelType eType, const OUString &rText, con SwRewriter aRewriter(SwUndoInsertLabel::CreateRewriter(rText)); StartUndo(SwUndoId::INSERTLABEL, &aRewriter); - sal_uLong nIdx = 0; + SwNodeOffset nIdx(0); bool bInnerCntIsFly = false; SwFlyFrameFormat* pFlyFormat = nullptr; switch( eType ) @@ -451,9 +453,24 @@ void SwFEShell::InsertLabel( const SwLabelType eType, const OUString &rText, con if( pCnt->IsInTab() ) { // pass down index to the TableNode for tables - const SwTable& rTable = *pCnt->FindTabFrame()->GetTable(); + SwTabFrame* pTabFrame = pCnt->FindTabFrame(); + const SwTable& rTable = *pTabFrame->GetTable(); nIdx = rTable.GetTabSortBoxes()[ 0 ] ->GetSttNd()->FindTableNode()->GetIndex(); + + SwFlyFrame* pFly = pTabFrame->FindFlyFrame(); + if (pFly && pFly->IsFlySplitAllowed()) + { + // This table is in a split fly, but we will insert a label, which means this is not + // a floating table anymore, disable the "can split" bit, it'll be hidden on the UI + // anyway. + SwFrameFormat* pFormat = pFly->GetFrameFormat(); + SfxItemSetFixed<RES_FLY_SPLIT, RES_FLY_SPLIT> aSet(GetDoc()->GetAttrPool()); + SwFormatFlySplit aSplit(false); + aSet.Put(aSplit); + // SwUndoFormatAttr is created for us. + GetDoc()->SetFlyFrameAttr(*pFormat, aSet); + } } break; case SwLabelType::Draw: @@ -552,29 +569,28 @@ bool SwFEShell::Sort(const SwSortOptions& rOpt) { SwPaM* pPam = &rPaM; - SwPosition* pStart = pPam->Start(); - SwPosition* pEnd = pPam->End(); + auto [pStart, pEnd] = pPam->StartEnd(); // SwPosition* - SwNodeIndex aPrevIdx( pStart->nNode, -1 ); - sal_uLong nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex(); - const sal_Int32 nCntStt = pStart->nContent.GetIndex(); + SwNodeIndex aPrevIdx( pStart->GetNode(), -1 ); + SwNodeOffset nOffset = pEnd->GetNodeIndex() - pStart->GetNodeIndex(); + const sal_Int32 nCntStt = pStart->GetContentIndex(); // Sorting bRet = mxDoc->SortText(*pPam, rOpt); // put selection again pPam->DeleteMark(); - pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); - SwContentNode* pCNd = pPam->GetContentNode(); + pPam->GetPoint()->Assign( aPrevIdx.GetNode(), SwNodeOffset(+1) ); + SwContentNode* pCNd = pPam->GetPointContentNode(); sal_Int32 nLen = pCNd->Len(); if( nLen > nCntStt ) nLen = nCntStt; - pPam->GetPoint()->nContent.Assign(pCNd, nLen ); + pPam->GetPoint()->SetContent(nLen ); pPam->SetMark(); - pPam->GetPoint()->nNode += nOffset; - pCNd = pPam->GetContentNode(); - pPam->GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); + pPam->GetPoint()->Adjust(nOffset); + pCNd = pPam->GetPointContentNode(); + pPam->GetPoint()->SetContent( pCNd->Len() ); } } @@ -691,7 +707,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, const RndStdIds _nAnchorId, const sal_Int16 _eHoriRelOrient, const sal_Int16 _eVertRelOrient, - const SwPosition* _pToCharContentPos, + const SwFormatAnchor* _pToCharContentPos, const bool _bFollowTextFlow, bool _bMirror, Point* _opRef, @@ -709,7 +725,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, } else { - pFly = GetSelectedFlyFrame(); + pFly = GetSelectedOrCurrFlyFrame(); pFrame = pFly ? pFly->GetAnchorFrame() : GetCurrFrame(); } @@ -981,7 +997,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, // <pFrame>, which is the anchor frame or the proposed anchor frame, // doesn't have to be a text frame (e.g. edit a to-page anchored // fly frame). Thus, assure this. - const SwTextFrame* pTextFrame( dynamic_cast<const SwTextFrame*>(pFrame) ); + const SwTextFrame* pTextFrame = pFrame->DynCastTextFrame(); if ( pTextFrame && (_nAnchorId == RndStdIds::FLY_AT_CHAR) && ( _eVertRelOrient == text::RelOrientation::CHAR || @@ -993,7 +1009,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, SwRect aChRect; if ( _pToCharContentPos ) { - pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos ); + pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos->GetContentAnchor() ); } else { @@ -1007,7 +1023,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, { if ( _pToCharContentPos ) { - pTextFrame->GetTopOfLine( nTop, *_pToCharContentPos ); + pTextFrame->GetTopOfLine( nTop, *_pToCharContentPos->GetContentAnchor() ); } else { @@ -1037,7 +1053,7 @@ void SwFEShell::CalcBoundRect( SwRect& _orRect, SwRect aChRect; if ( _pToCharContentPos ) { - pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos ); + pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos->GetContentAnchor() ); } else { @@ -1299,8 +1315,9 @@ bool SwFEShell::IsFrameVertical(const bool bEnvironment, bool& bRTL, bool& bVert return bVert; } - if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr && !bEnvironment ) - pRef = static_cast<const SwVirtFlyDrawObj*>(pObj)->GetFlyFrame(); + if ( !bEnvironment ) + if ( auto pVirtFly = dynamic_cast<const SwVirtFlyDrawObj*>( pObj) ) + pRef = pVirtFly->GetFlyFrame(); bVert = pRef->IsVertical(); bRTL = pRef->IsRightToLeft(); |