Commits

Anonymous committed b10cb57

sw34bf04: #i117331#: fix SwXText::convertToTextFrame:
SwXText::convertToTextFrame: only delete paragraph if it is empty.
SwXFrame::attachToRange, SwXText::convertToTextFrame:
prevent PaMs on the stack from being registered at nodes that may be deleted
preventing assertions from ~SwIndexReg on the bugdoc of #o11831122#.

  • Participants
  • Parent commits e3305ae

Comments (0)

Files changed (2)

File sw/source/core/unocore/unoframe.cxx

                     aFrmSet.Put( SwFmtAnchor( FLY_AT_PAGE, 1 ));
                 }
 
+                aPam.DeleteMark(); // mark position node will be deleted!
+                aIntPam.DeleteMark(); // mark position node will be deleted!
                 pFmt = pDoc->MakeFlyAndMove( *m_pCopySource, aFrmSet,
                                0,
                                pParentFrmFmt );

File sw/source/core/unocore/unotext.cxx

             // DelFullPara is called
             const uno::Reference< text::XTextRange> xInsertTextRange =
                 new SwXTextRange(aStartPam, this);
+            aStartPam.DeleteMark(); // mark position node may be deleted!
             pNewFrame->attach( xInsertTextRange );
             pNewFrame->setName(m_pImpl->m_pDoc->GetUniqueFrameName());
         }
 
-        if (!aStartPam.GetTxt().Len())
+        SwTxtNode *const pTxtNode(aStartPam.GetNode()->GetTxtNode());
+        OSL_ASSERT(pTxtNode);
+        if (!pTxtNode || !pTxtNode->Len()) // don't remove if it contains text!
         {
-            bool bMoved = false;
             {   // has to be in a block to remove the SwIndexes before
                 // DelFullPara is called
                 SwPaM aMovePam( *aStartPam.GetNode() );
                     m_pImpl->m_pDoc->SetAttr(
                         aNewAnchor, *pNewFrame->GetFrmFmt() );
                 }
-                bMoved = true;
             }
-            if (bMoved)
-            {
-                aStartPam.DeleteMark();
-//                    SwPaM aDelPam( *aStartPam.GetNode() );
-                m_pImpl->m_pDoc->DelFullPara(aStartPam/*aDelPam*/);
-            }
+            m_pImpl->m_pDoc->DelFullPara(aStartPam);
         }
     }
     catch (lang::IllegalArgumentException& rIllegal)