summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Jung <phil.jung@free.fr>2015-06-02 17:43:19 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2015-06-10 16:57:57 +0000
commit677b373427d3db8d751600b8c540a6afe07f142e (patch)
tree1e4793d332e64c96754585e5096ead657b0efced
parent81950f6a41d7f4512cb29c04c0151aec59e80e98 (diff)
tdf#91228 Fix Writer crash
Start Writer, Insert Image, Anchor as character, Go after image, press enter, writer crash This is because m_pAnchoredFly is not updated. JoinPrev, JoinNext and SplitContentNode all rely on CutText with calls InsertHint. InsertHint calls SetAnchor. SetAnchor calls Modify callback except if "LockModify"ed. This patch ensures that, whatever the value of LockModify, the references are kept correct. Reviewed-on: https://gerrit.libreoffice.org/16041 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 9f01951b858453684f2622541af0eb85d4544fc6) Signed-off-by: Michael Stahl <mstahl@redhat.com> Conflicts: sw/source/core/txtnode/thints.cxx Change-Id: Id7254784c6954db4b542b2c4228b388fb924bbc2 (cherry picked from commit 7ea3a2b5747f148cbdc9a065728cefff1a660bd7) Reviewed-on: https://gerrit.libreoffice.org/16050 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r--sw/source/core/txtnode/thints.cxx40
1 files changed, 35 insertions, 5 deletions
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index a03b391a7440..37b0c261aa9b 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1277,19 +1277,44 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode )
{
SwTxtFlyCnt *pFly = (SwTxtFlyCnt *)pAttr;
SwFrmFmt* pFmt = pAttr->GetFlyCnt().GetFrmFmt();
+
+ // In order to maintain data coherency, if the hint is a fly
+ // moved from a text node to another, we have to remove it from
+ // the first textnode then to add it to the new (this) textnode
+ const SwFmtAnchor* pAnchor = 0;
+ pFmt->GetItemState( RES_ANCHOR, false,
+ reinterpret_cast<const SfxPoolItem**>(&pAnchor) );
+
+ SwIndex aIdx( this, pAttr->GetStart() );
+
+ bool bChangeFlyParentNode( false );
+ if (pAnchor &&
+ pAnchor->GetAnchorId() == FLY_AS_CHAR &&
+ pAnchor->GetCntntAnchor() &&
+ pAnchor->GetCntntAnchor()->nNode != *this)
+ {
+ assert(pAnchor->GetCntntAnchor()->nNode.GetNode().IsTxtNode());
+ SwTxtNode* textNode = pAnchor->GetCntntAnchor()->nNode.GetNode().GetTxtNode();
+
+ if ( textNode->IsModifyLocked() )
+ {
+ // Fly parent has changed but the FlyFormat is locked, so it will
+ // not be updated by SetAnchor (that calls Modify that updates
+ // relationships)
+ textNode->RemoveAnchoredFly( pFmt );
+ bChangeFlyParentNode = true;
+ }
+ }
+
if( !(nsSetAttrMode::SETATTR_NOTXTATRCHR & nInsMode) )
{
+
// Wir muessen zuerst einfuegen, da in SetAnchor()
// dem FlyFrm GetStart() uebermittelt wird.
//JP 11.05.98: falls das Anker-Attribut schon richtig
// gesetzt ist, dann korrigiere dieses nach dem Einfuegen
// des Zeichens. Sonst muesste das immer ausserhalb
// erfolgen (Fehleranfaellig !)
- const SwFmtAnchor* pAnchor = 0;
- pFmt->GetItemState( RES_ANCHOR, false,
- (const SfxPoolItem**)&pAnchor );
-
- SwIndex aIdx( this, pAttr->GetStart() );
const OUString c(GetCharOfTxtAttr(*pAttr));
OUString const ins( InsertText(c, aIdx, nInsertFlags) );
if (ins.isEmpty())
@@ -1353,6 +1378,11 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode )
return false;
}
}
+
+ // Finish relationships update now that SetAnchor has fixed part of it.
+ if (bChangeFlyParentNode)
+ AddAnchoredFly( pFmt );
+
break;
}