summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-04-04 17:19:51 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2022-04-04 20:23:15 +0200
commit8fbe27a53c038cd32c45bad1f0b417e79d483185 (patch)
tree95cfc5261a7f1b9f005d1c72bffeacc2377c45a5 /xmloff
parent1ad58c77352e418124387b804b18da2aeea22c8b (diff)
forcepoint#101 sw: fix inserting at-page shapes to not set anchor pos
The problem is that for an at-page anchor SwXDrawPage::add() sets an anchor position, but then a fieldmark is inserted and the node with the anchor position is deleted. The code that sets the surprising anchor position for at-page shape was added in commit cf345e026fc0378c4436173c8064717c7db4d538 "Fix #91289#: Draw objects anchored at page but without page number" and is similar to the code for fly-frames added in commit 2e6d999cf8ceacabb94b11feee6ee0808c2a75bc "If no page number is given for page bound frames, calculate it using cursor" except that it is missing a check for GetPageNum() == 0, for no obvious reason. The matching code to replace the anchor position with a page number is in SwFlyFrameFormat::MakeFrames() and was added in commit 572a48cd16f6ce3a68ffead44a975698954dfe11 "Fix #85019#: Insertion of flyframes without correct pagenumber"; it's not clear if this is only needed for shapes inserted via the above 2 UNO APIs or also for shapes inserted via UI. Then there is the issue that the page number is set in XMLTextShapeImportHelper::addShape() only after the shape is inserted, which was added and commented in commit b5fc47fe5c2892dd712e2bda922656eacbd932f1, earlier than all the above commits; testing shows that if the page number is set before inserting the shape, the shape ends up on the expected page anyway. Let's change this: 1. the page number is set before inserting the shape 2. at-page anchor with page number is left as is 3. at-page anchor without page number gets anchor position and is changed to at-char Change-Id: I2f874bec8424de5eee94cf022e3b49382eaa55f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132479 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/text/XMLTextShapeImportHelper.cxx12
1 files changed, 9 insertions, 3 deletions
diff --git a/xmloff/source/text/XMLTextShapeImportHelper.cxx b/xmloff/source/text/XMLTextShapeImportHelper.cxx
index 89b7de528c95..1c567b689632 100644
--- a/xmloff/source/text/XMLTextShapeImportHelper.cxx
+++ b/xmloff/source/text/XMLTextShapeImportHelper.cxx
@@ -119,9 +119,6 @@ void XMLTextShapeImportHelper::addShape(
// anchor type
xPropSet->setPropertyValue( gsAnchorType, Any(eAnchorType) );
- Reference < XTextContent > xTxtCntnt( rShape, UNO_QUERY );
- xTxtImport->InsertTextContent( xTxtCntnt );
-
// page number (must be set after the frame is inserted, because it
// will be overwritten then inserting the frame.
switch( eAnchorType )
@@ -133,6 +130,15 @@ void XMLTextShapeImportHelper::addShape(
xPropSet->setPropertyValue( gsAnchorPageNo, Any(nPage) );
}
break;
+ default:
+ break;
+ }
+
+ Reference < XTextContent > xTxtCntnt( rShape, UNO_QUERY );
+ xTxtImport->InsertTextContent( xTxtCntnt );
+
+ switch( eAnchorType )
+ {
case TextContentAnchorType_AS_CHARACTER:
xPropSet->setPropertyValue( gsVertOrientPosition, Any(nY) );
break;