diff options
Diffstat (limited to 'sw/source/core/unocore/unotext.cxx')
-rw-r--r-- | sw/source/core/unocore/unotext.cxx | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 3887a11191d7..a4dfe5422af1 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1566,6 +1566,8 @@ SwXText::convertToTextFrame( } bool bParaAfterInserted = false; bool bParaBeforeInserted = false; + ::std::optional<SwPaM> oAnchorCheckPam; + oAnchorCheckPam.emplace(*pStartPam->Start(), *pEndPam->End()); if ( pStartStartNode && pEndStartNode && (pStartStartNode != pEndStartNode || pStartStartNode != GetStartNode()) @@ -1646,6 +1648,7 @@ SwXText::convertToTextFrame( bParaAfterInserted = GetDoc()->getIDocumentContentOperations().AppendTextNode( aEnd ); pEndPam->DeleteMark(); *pEndPam->GetPoint() = aEnd; + *oAnchorCheckPam->End() = aEnd; } pStartPam->SetMark(); *pStartPam->End() = *pEndPam->End(); @@ -1660,10 +1663,17 @@ SwXText::convertToTextFrame( { const SwFrameFormat* pFrameFormat = (*m_pImpl->m_pDoc->GetSpzFrameFormats())[i]; const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor(); - if ( !isGraphicNode(pFrameFormat) && - (RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId() || RndStdIds::FLY_AT_CHAR == rAnchor.GetAnchorId()) && - pStartPam->Start()->nNode.GetIndex() <= rAnchor.GetContentAnchor()->nNode.GetIndex() && - pStartPam->End()->nNode.GetIndex() >= rAnchor.GetContentAnchor()->nNode.GetIndex()) + // note: Word can do at-char anchors in text frames - sometimes! + // see testFlyInFly for why this checks only the edges of the selection, + // and testFloatingTablesAnchor for why it excludes pre/post table + // added nodes + if (!isGraphicNode(pFrameFormat) + && ( (RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId() + && ( oAnchorCheckPam->Start()->nNode.GetIndex() == rAnchor.GetContentAnchor()->nNode.GetIndex() + || oAnchorCheckPam->End()->nNode.GetIndex() == rAnchor.GetContentAnchor()->nNode.GetIndex())) + || (RndStdIds::FLY_AT_CHAR == rAnchor.GetAnchorId() + && ( *oAnchorCheckPam->Start() == *rAnchor.GetContentAnchor() + || *oAnchorCheckPam->End() == *rAnchor.GetContentAnchor())))) { if (pFrameFormat->GetName().isEmpty()) { @@ -1675,6 +1685,7 @@ SwXText::convertToTextFrame( } } } + oAnchorCheckPam.reset(); // clear SwIndex before deleting nodes const uno::Reference<text::XTextFrame> xNewFrame( SwXTextFrame::CreateXTextFrame(*m_pImpl->m_pDoc, nullptr)); @@ -1692,7 +1703,7 @@ SwXText::convertToTextFrame( new SwXTextRange(*pStartPam, this); assert(rNewFrame.IsDescriptor()); rNewFrame.attachToRange(xInsertTextRange, pStartPam.get()); - rNewFrame.setName(m_pImpl->m_pDoc->GetUniqueFrameName()); + assert(!rNewFrame.getName().isEmpty()); } SwTextNode *const pTextNode(pStartPam->GetNode().GetTextNode()); |