diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2022-04-04 17:19:51 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-04-06 14:00:15 +0200 |
commit | 02c16d731b90a9df96bf68bdf8a6210356aac260 (patch) | |
tree | 9d1e88ca231827e9267948238c7549d3c3fe05a2 /xmloff/source | |
parent | e7016cc51d3efafb7d25c71d6ba53cf089e0b2ef (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>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132530
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'xmloff/source')
-rw-r--r-- | xmloff/source/text/XMLTextShapeImportHelper.cxx | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/xmloff/source/text/XMLTextShapeImportHelper.cxx b/xmloff/source/text/XMLTextShapeImportHelper.cxx index 89b7de528c95..f4a62f4ad9b7 100644 --- a/xmloff/source/text/XMLTextShapeImportHelper.cxx +++ b/xmloff/source/text/XMLTextShapeImportHelper.cxx @@ -119,11 +119,7 @@ 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. + // page number must be set before the frame is inserted switch( eAnchorType ) { case TextContentAnchorType_AT_PAGE: @@ -133,6 +129,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; |