summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-06-29 21:05:27 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-06-30 09:28:31 +0200
commit682e0488df819c191c13a03758fad0690706e508 (patch)
treec1cc1d39f8317f9b10ee55d0e9936dfa0511c6d5 /sw/source
parentca1df564c3199a569c681d5814e1fddc66c48522 (diff)
tdf#134099 sw: fix textbox anchors on copy-paste and undo
Regression from commit c7307c77254557646f33017af915f6808a861e29 (fdo#82191 sw::DocumentLayoutManager: copy textbox content of draw formats, 2014-08-15), without which this problem gets hidden, as copy breaks the textbox into 2 pieces, so the textbox codepaths are no longer hit. The direct problem is that SwHistorySetFormat::SetInDoc() uses a raw node index into the nodes array, which is past the end of the nodes array. Root cause is that we have this invariant that actions and their undo has to be in sync, otherwise raw node indexes no longer work. In this case, SwUndoSaveContent::DelContentIndex() did not delete a fly frame format, because it was out of range, as it had a wrong anchor. Fix this in SwTextFlyCnt::SetAnchor(), so that whenever the anchor of a draw format is set via that function, we update its textbox as well. Also fix a related problem when fly formats were copied twice. Change-Id: I0d6c9069544c405eb20c5fed65fb40423b0adc84 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97457 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx8
-rw-r--r--sw/source/core/txtnode/atrflyin.cxx10
2 files changed, 18 insertions, 0 deletions
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index ea1aa8b001be..4bb4325134d9 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -3788,6 +3788,14 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
}
}
+ // Ignore TextBoxes, they are already handled in
+ // sw::DocumentLayoutManager::CopyLayoutFormat().
+ if (SwTextBoxHelper::isTextBox(it->GetFormat(), RES_FLYFRMFMT))
+ {
+ it = aSet.erase(it);
+ continue;
+ }
+
// Copy the format and set the new anchor
aVecSwFrameFormat.push_back( pDest->getIDocumentLayoutAccess().CopyLayoutFormat( *(*it).GetFormat(),
aAnchor, false, true ) );
diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx
index 3fc62f51a368..902d3bda3a1e 100644
--- a/sw/source/core/txtnode/atrflyin.cxx
+++ b/sw/source/core/txtnode/atrflyin.cxx
@@ -33,6 +33,7 @@
#include <objectformatter.hxx>
#include <calbck.hxx>
#include <dcontact.hxx>
+#include <textboxhelper.hxx>
SwFormatFlyCnt::SwFormatFlyCnt( SwFrameFormat *pFrameFormat )
: SfxPoolItem( RES_TXTATR_FLYCNT ),
@@ -200,6 +201,15 @@ void SwTextFlyCnt::SetAnchor( const SwTextNode *pNode )
}
}
pFormat->SetFormatAttr( aAnchor ); // only set the anchor
+
+ // If the draw format has a TextBox, then set its anchor as well.
+ if (SwFrameFormat* pTextBox
+ = SwTextBoxHelper::getOtherTextBoxFormat(pFormat, RES_DRAWFRMFMT))
+ {
+ SwFormatAnchor aTextBoxAnchor(pTextBox->GetAnchor());
+ aTextBoxAnchor.SetAnchor(aAnchor.GetContentAnchor());
+ pTextBox->SetFormatAttr(aTextBoxAnchor);
+ }
}
// The node may have several SwTextFrames - for every SwTextFrame a