sw/source/core/doc/doclay.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
New commits: commit 838a3ae5e7e2efedfbd07734aedb85c7ec8f2356 Author: Michael Stahl <mst...@redhat.com> Date: Thu Feb 14 23:02:35 2013 +0100 sw: do not crash when it's not possible to insert fly Change-Id: Idfcf54013107ba6b7ce3de0d0bddbef306698f33 (cherry picked from commit 5a80c24b145c8efe0dd384ef88e7d31173522fb8) Reviewed-on: https://gerrit.libreoffice.org/2176 Reviewed-by: Miklos Vajna <vmik...@suse.cz> Tested-by: Miklos Vajna <vmik...@suse.cz> diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index f31c998..3bac734 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -654,7 +654,11 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, if (pTxtNode != NULL) { SwFmtFlyCnt aFmt( pFmt ); - pTxtNode->InsertItem( aFmt, nStt, nStt ); + bool const bSuccess( pTxtNode->InsertItem(aFmt, nStt, nStt) ); + if (!bSuccess) // may fail if there's no space left or header/ftr + { // pFmt is dead now + return 0; + } } } @@ -740,7 +744,9 @@ SwFlyFrmFmt* SwDoc::MakeFlySection( RndStdIds eAnchorType, if (bCalledFromShell && !lcl_IsItemSet(*pNewTxtNd, RES_PARATR_ADJUST) && SFX_ITEM_SET == pAnchorNode->GetSwAttrSet(). GetItemState(RES_PARATR_ADJUST, sal_True, &pItem)) + { static_cast<SwCntntNode *>(pNewTxtNd)->SetAttr(*pItem); + } pFmt = _MakeFlySection( *pAnchorPos, *pNewTxtNd, eAnchorType, pFlySet, pFrmFmt ); @@ -941,8 +947,13 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, { xub_StrLen nStt = rRg.GetPoint()->nContent.GetIndex(); SwFmtFlyCnt aFmt( pFmt ); - rRg.GetPoint()->nNode.GetNode().GetTxtNode()->InsertItem( - aFmt, nStt, nStt ); + bool const bSuccess( // may fail if there's no space left + rRg.GetPoint()->nNode.GetNode().GetTxtNode()->InsertItem( + aFmt, nStt, nStt)); + if (!bSuccess) + { // pFmt is dead now + return 0; + } } SwDrawContact* pContact = new SwDrawContact( pFmt, &rDrawObj ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits