summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-02-14 23:02:35 +0100
committerMichael Stahl <mstahl@redhat.com>2013-02-15 22:43:11 +0100
commit5a80c24b145c8efe0dd384ef88e7d31173522fb8 (patch)
tree3e8d9fd26e860f2426134e38d6c9452f17a436e4 /sw
parent549c0f785d4b6d4bc1b39b22827d77d66f48430a (diff)
sw: do not crash when it's not possible to insert fly
Change-Id: Idfcf54013107ba6b7ce3de0d0bddbef306698f33
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 f73cc7265148..b97a2639bc41 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 );