Bug 154703 - [META] Export DOCX flies with framePr instead of DrawingDML
Summary: [META] Export DOCX flies with framePr instead of DrawingDML
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: target:7.6.0 target:7.5.4 target:24.8...
Keywords: filter:docx
Depends on: 105035
Blocks: DOCX-Frames
  Show dependency treegraph
 
Reported: 2023-04-07 19:54 UTC by Justin L
Modified: 2024-01-23 18:14 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
n592908-frameC.docx: top frame border spacing copied to paragraph border spacing (15.19 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-04-07 19:54 UTC, Justin L
Details
ooo39250-1-minB.rtf : table in framePr (35.04 KB, application/rtf)
2023-04-14 15:14 UTC, Justin L
Details
wrapExample.odt: captions are a prime candidate for using framePr (71.33 KB, application/vnd.oasis.opendocument.text)
2023-04-14 18:21 UTC, Justin L
Details
wrapExample2.odt: comment 10 round-tripped to DOCX, then RT to ODT (59.82 KB, application/vnd.oasis.opendocument.text)
2023-04-14 18:49 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2023-04-07 19:54:41 UTC
Created attachment 186534 [details]
n592908-frameC.docx: top frame border spacing copied to paragraph border spacing

Currently the only time that framePr is exported is if framePr settings are grabbaged on import. Otherwise (most) frames are exported as a DrawingML shape - which is imported as an editeng drawing object.

An exploration into exporting textboxes and captions using framePr can be found at https://gerrit.libreoffice.org/c/core/+/150114.

FramePr PROs:
    • simple xml
    • imports as SW native – not a synchronized editeng monstrosity, better styles, text area is already MS Word compatible.

FramePr CONs
    • no overlap setting – layout decision to overlap sequential framePRs is somewhat arbitrary.
    • limited wrapping choices. No before/after/through
    • relatively poor export support currently – missing background/shadow/links
    • not allowed in header/footer (at least, that is LO export rule)
    • layout loops might occur: regression danger from making a change.

DrawingML PROs:
    • encourages code improvements to editeng
    • full wrapping support

DrawingML CONs:
    • LO imports as draw frame sync’d to hidden SW frame. Causes layout issues
    • poor anchor import - only TO-CHAR or AS-CHAR – often translates to poor placement emulation

This is a META kind of report. My intention is to add documents that highlight a specific issue so that the CONs (of both types) can be alleviated.

This first attachment shows top/left margins being duplicated on framePr import (I assume). It bibisects to 3.3.1 (3.3.0 was OK). [Note - prior to 4.4, you need to look at the number in the dialog box, not at the layout.]. Duplicate left/right margins tend to be (mostly) absorbed in LO for some reason, but top margins are applied twice.
Comment 1 Justin L 2023-04-08 12:28:35 UTC
attachment 186535 [details]  n592908-frameC_word2010.pdf: how it looks in MS Word

proposed temporary import fix for the extra top/bottom margins at  https://gerrit.libreoffice.org/c/core/+/150157.
But really the export should be fixed first, so that a proper import can be done.
Comment 2 Commit Notification 2023-04-08 18:10:18 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/31ea6305b6a763ee48f639562313d9bd109a2923

tdf#154703 writerfilter framePr: avoid exception with hasValue

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 3 Commit Notification 2023-04-09 01:41:00 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/e4b1be58db73f5a3c483b40b5615c1c764bbe1d3

tdf#154703 writerfilter framePr: don't duplicate top/bot spacing

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Commit Notification 2023-04-13 19:04:17 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/499247966af565071542f1cdfa882d6b8e6c33f0

NFC tdf#154703 docx export framePr: cleanup prep before patch

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Commit Notification 2023-04-13 23:05:42 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/996d264dd4ca37c869e5109296de6ae306f740d9

tdf#154703 docx export framePr: export frame background

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2023-04-14 01:13:53 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/02c902bde09984a87f19ac0eb63942724056c982

tdf#154703 docx export framePr: merge para/frame FormatBox

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2023-04-14 14:55:16 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/a24d461d736de0a29bb8ef2a20b57db4836cda3e

tdf#154703 writerfilter framePr: RTF != INVERT_BORDER_SPACING

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Justin L 2023-04-14 15:14:18 UTC
Created attachment 186668 [details]
ooo39250-1-minB.rtf : table in framePr

RTF can also import as framePr, although the export as RTF loses the framePr status I believe, and exports as a different kind of frame. Lots of things don't export nicely into RTF, so I won't spend much time with that format.

I'm not sure if this attachment is much value. It doesn't import the table nicely, but I assume that is just an RTF import issue, and not a framePR specific issue.

LO has an INVERT_BORDER_SPACING compat setting for DOC/X, but not for RTF. The setting just ignores paragraph border spacing (inside a frame only I assume). I have to assume that it was put in place simply to handle these framePrs - in the strange cases where the frame contains paragraphs with differing border spacings. In that case it probably shouldn't apply to non-framePr frames but I expect that LO doesn't know the difference. In any case, I didn't dare to apply it to RTF as well - too many import/export implications to consider in an already bad starting place.
Comment 9 Justin L 2023-04-14 15:49:06 UTC
ooxmlexport frame-wrap-auto.docx is an example where the frame was centred, but now is "from left".

Bisected to LO 4.4 commit 1c876f5616522ab695de8c0316cdb0c601081815
Author: Rohit Deshmukh on Fri Jun 13 11:39:56 2014 +0530
    fdo#78590: Fix for Corruption of para with framePr & drawing object into para
Comment 10 Justin L 2023-04-14 18:21:08 UTC
Created attachment 186669 [details]
wrapExample.odt: captions are a prime candidate for using framePr

Although this example primarily shows wrap problems, it also demonstrates the problems (probably wrap related) that plague synchronized draw-frames when round-tripped to DOCX format. There are two images on the first page - but the captioned one often seems to be missing in DOCX until you click in the right spot.

The layout problem became evident in 7.2.2 when GraphicImport.cxx marked drawing-objects as AT-CHAR instead of AT-PARA. Obviously the layout is just exposed by the change. commit c0b951024c2ec815f1ef70d59d31860df2434d28
Author: Miklos Vajna on Mon Sep 20 19:56:37 2021 +0200
    tdf#143591 DOCX import: handle anchored objects as at-char
Comment 11 Justin L 2023-04-14 18:49:26 UTC
Created attachment 186670 [details]
wrapExample2.odt: comment 10 round-tripped to DOCX, then RT to ODT

Saving as ODT format lets this be tested prior to 7.2. 

Almost certainly the problem with comment 10's document is that the frame is trying to be on a different page than the anchor. There are lots of bug reports about that kind of behaviour. (In this case, it seems like the character anchor is at the end of the paragraph. There can't be right answer because other documents would be better served as anchored at the end of the paragraph I'm sure.)

However, in this particular document it really shouldn't matter where the character anchor is, because the position is based on the "entire paragraph area". So it is just a layout problem.
Comment 12 Commit Notification 2023-04-15 00:43:13 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/e07d5c089ab2e8fe8a5cfa2a11cef3f1cf3afab3

tdf#154703 docx export framePr: export xAlign/yAlign

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 Commit Notification 2023-04-16 01:51:29 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1d12d12598927ef8a74dd648632112ceb16bdf78

tdf#154703 DOCX {im,ex}port framePr: adjust framesize by para spacing

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 14 Commit Notification 2023-04-16 07:47:57 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/1cebe3ef85b4b1f7c34263a2da38f4e1d269ae4b

tdf#154703 docx export framePr: export xAlign/yAlign

It will be available in 7.5.4.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 15 Justin L 2023-04-19 12:20:50 UTC
(In reply to Justin L from comment #11)
> wrapExample2.odt: comment 10 round-tripped to DOCX, then RT to ODT

https://gerrit.libreoffice.org/c/core/+/150637 is debug statements for this layout issue. Too many pathways for my brain to handle, and to much wrong on a grand scale - not just a minor wrong calculation but fundamental issues here. Fundamental issues on a fragile base is not somewhere I should be.

This topic is covered by bug 135225.
Comment 16 Justin L 2023-04-21 17:25:11 UTC
(In reply to Justin L from comment #0)
> An exploration into exporting textboxes and captions using framePr can be
> found at https://gerrit.libreoffice.org/c/core/+/150114.
Abandoned. Too fragile. Cannot easily target captions or any other specific instance or situation.

Next idea: add bool "ParaFrameProperties" to grabbag at SwView::InsertCaption dialog.
Comment 17 Commit Notification 2023-04-21 20:27:47 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/981c5b5421b5fc728e2b8140d7d52d8c8eb465e7

NFC tdf#154703 docx export: optimize/reorder "if TextBoxIsFramePr"

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 18 Commit Notification 2023-04-21 20:36:50 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/006b35d50024b1932d84380b5d2fec1f7066bccd

tdf#154703 NFC sw framePr: flatten TextBoxIsFramePr and fix typo

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 19 Commit Notification 2023-04-22 00:57:10 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d3a121cecfa8fb3c6f81b05822ba3309d77ab85d

tdf#154703 sw framePr: export knowing import wrap spacing limitations

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 20 Commit Notification 2023-04-23 00:57:07 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/deb1a14adb115710b5e40dd305dc5da4a4e3b065

tdf#97128 tdf#154703 docx export framePr: export frame textDirection

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 21 Justin L 2023-04-24 20:39:24 UTC
(In reply to Justin L from comment #16)
> Next idea: add framePr hint at InsertCaption dialog.
https://gerrit.libreoffice.org/c/core/+/150795

In that code review, Gabor commented:
This is related to bug 131302 (which has an idea how to solve it) and bug 96579 (which collects duplicates) and all the See also ones.
There were several other attempts to fix this over the years, but somehow all were inadequate and reverted.
Also bug 121378 has some ideas how to improve this.
Comment 22 Commit Notification 2024-01-22 18:19:07 UTC Comment hidden (off-topic)
Comment 23 Commit Notification 2024-01-23 09:43:19 UTC Comment hidden (off-topic)
Comment 24 Justin L 2024-01-23 18:14:17 UTC
tdf#154703 writerfilter framePr: avoid unexpected frame borders

This addresses a regression caused by comment 2's patch, fixing bug 159207, and should have used that bug number in the comment...