summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-02-14 23:02:35 +0100
committerMiklos Vajna <vmiklos@suse.cz>2013-02-18 09:54:51 +0000
commit838a3ae5e7e2efedfbd07734aedb85c7ec8f2356 (patch)
treef49bd4849cf5937a5670299cdf796069ac3f2d90 /sw
parent9b5975072ccd67279f653e982f9a044d5262c4e2 (diff)
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 <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/doclay.cxx17
1 files changed, 14 insertions, 3 deletions
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index f31c998e07ec..3bac7340f34d 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 );