Bug 84678 - FILEOPEN: .DOCX textbox margins incorrectly set in 4.4.x
Summary: FILEOPEN: .DOCX textbox margins incorrectly set in 4.4.x
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.4.0.0.alpha0+ Master
Hardware: Other All
: highest major
Assignee: Miklos Vajna
URL:
Whiteboard: target:5.3.0
Keywords: bibisected, bisected, filter:docx, regression
: 98830 100921 (view as bug list)
Depends on:
Blocks: DOCX-Textbox
  Show dependency treegraph
 
Reported: 2014-10-05 03:06 UTC by Luke
Modified: 2018-11-24 15:11 UTC (History)
14 users (show)

See Also:
Crash report or crash signature:


Attachments
Comparison Textboxs in 4.4 vs 4.3 (176.77 KB, image/png)
2014-10-05 03:06 UTC, Luke
Details
Simple DOCX file showing issue with reduced margins (15.34 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2014-10-05 03:11 UTC, Luke
Details
Text Box ignores margins, Frames keeps them (15.43 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2015-10-01 21:18 UTC, Luke
Details
Second example showing LO 4.3 correctly importing margins (160.68 KB, image/png)
2015-11-29 07:45 UTC, Luke
Details
Example of MSO document with text box not correctly shown by LO (358.03 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2016-08-02 19:21 UTC, Michael
Details
debug84678_patch.diff: to help a developer get started (14.15 KB, patch)
2016-08-11 15:47 UTC, Justin L
Details
zip with various word PDFs of Comment 11's August.docx (836.16 KB, application/zip)
2016-08-12 11:50 UTC, Justin L
Details
Patch to re-enable Text Frames (4.75 KB, patch)
2016-08-13 06:52 UTC, Luke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luke 2014-10-05 03:06:13 UTC
Created attachment 107341 [details]
Comparison Textboxs in 4.4 vs 4.3

The margins of imported DOCX textboxes have been reduced and moved in 4.4. When a textbox is up against the margin, it's so bad that the text is outside of the box's border line. This issue occurs on the screen and when printed.

Step to reproduce:
1) Create a new doc with a textbox in Word2007+
2) Snap the textbox to the left margin
3) Save
4) Open in Write 4.4

This is a regression in 4.4. Libreoffice 4.3 sets the margins of imported textboxs correctly, so the imported textbox looks like Word's.
Comment 1 Luke 2014-10-05 03:11:24 UTC
Created attachment 107342 [details]
Simple DOCX file showing issue with reduced margins
Comment 2 tommy27 2014-10-05 07:28:21 UTC
confirmed under Win7x64 using 4.4.0.0.alpha0+
Build ID: 268b9c10c9ff27c74678ace99762f28d58d33012
TinderBox: Win-x86@42, Branch:master, Time: 2014-10-02_23:35:24

status NEW.works fine with 4.3.2.2 hence regression.

issue is limited to .DOCX format, .DOC and .ODT are unaffected.

@Luke
please define the O/S where you reproduced the bug.
moreover when you report bugs against master is always a good thing to copy and paste Build ID info from the "Help/About LibO dev" textbox
Comment 3 Terrence Enger 2014-10-05 22:57:42 UTC
Within the daily dbgutil bibisect repo, from `git bisect good`:

    49ffb467231cc09d9e351aa2d37f2c0d99c3eb3d is the first bad commit
    commit 49ffb467231cc09d9e351aa2d37f2c0d99c3eb3d
    Author: Miklos Vajna <vmiklos@collabora.co.uk>
    Date:   Thu Jun 19 08:24:47 2014 +0200

        2014-06-19

    :100644 100644 426040151e25ab34608c1a48dcc8ce13f56cd591 7c0067294d629d902d426a1017494a199b13ddbe M	build-info.txt
    :040000 040000 48d4cbc2d07d98d0855650a07a3591184041f373 a0503b6bedcbb741ca300660091d132f8cf56bf6 M	opt

and from `git bisect log`:

    # bad: [3bd90766c05c07c4a39e36cb1d3106b0016983d4] 2014-10-05
    # good: [b3130c846de5cf1b4be48b48dfc780bb369549fa] 2014-05-21
    git bisect start 'origin/master' 'oldest'
    # bad: [5ed7df78a02df9f716188ab12cc6f641f479b6d1] 2014-07-29
    git bisect bad 5ed7df78a02df9f716188ab12cc6f641f479b6d1
    # bad: [402ad27d59e542f8ff5fc88c4ffa74613a3cadfc] 2014-06-24
    git bisect bad 402ad27d59e542f8ff5fc88c4ffa74613a3cadfc
    # good: [5507b65dd2f68bdc720e23686e57269d46c16411] 2014-06-07
    git bisect good 5507b65dd2f68bdc720e23686e57269d46c16411
    # good: [8415e4b7f11bc7defc143883e5daf89e90643de7] 2014-06-15
    git bisect good 8415e4b7f11bc7defc143883e5daf89e90643de7
    # bad: [49ffb467231cc09d9e351aa2d37f2c0d99c3eb3d] 2014-06-19
    git bisect bad 49ffb467231cc09d9e351aa2d37f2c0d99c3eb3d
    # good: [35c0f684cef2fdbe270ff9d3b37169731ef61033] 2014-06-17
    git bisect good 35c0f684cef2fdbe270ff9d3b37169731ef61033
    # good: [2d5ec4b381617f69c8daf3f149f71425af0ce9e9] 2014-06-18
    git bisect good 2d5ec4b381617f69c8daf3f149f71425af0ce9e9
    # first bad commit: [49ffb467231cc09d9e351aa2d37f2c0d99c3eb3d] 2014-06-19
Comment 4 Miklos Vajna 2014-10-06 14:31:54 UTC
It's obviously a regression from d379d18666aa42031359ca8eb34b0021960347ae, I plan to look into this.
Comment 5 Björn Michaelsen 2014-12-18 10:22:05 UTC Comment hidden (obsolete)
Comment 6 Luke 2015-09-30 00:51:19 UTC
http://cgit.freedesktop.org/libreoffice/core/commit/?id=d379d18666aa42031359ca8eb34b0021960347ae

Changes imported textboxes from text within frames to text within a TextBox shape. The TextBox's outer position and dimensions are correct, but the text inside is shifted up and to the left.
Comment 7 Luke 2015-10-01 21:18:18 UTC
Created attachment 119178 [details]
Text Box ignores margins, Frames keeps them

To see the issue here compare this file in Writer 4.x with Writer 5.x.

Miklos,
I ran into a related issue with docx import, only this time the text was completely out of place. Upon further investigation, I discovered that we're now completely ignoring the margins of text boxes, whereas the old code was respecting them. The attached file clearly illustrates the issue. Should I file a new bug report or track it under this one?
Comment 8 Luke 2015-11-29 07:45:36 UTC
Created attachment 120863 [details]
Second example showing LO 4.3 correctly importing margins

Left textbox should have the text vertically and horizontally centered, while the right textbox has no margins.
Comment 9 Robinson Tryon (qubit) 2015-12-10 01:18:39 UTC Comment hidden (obsolete)
Comment 10 Joey Reid 2016-04-17 15:43:16 UTC
Miklos,
I know you did this to enable shapes, but it seems to break more than it fixes. Do you think you could revert the old behavior in cases where no shapes are involved?
Comment 11 Michael 2016-08-02 19:21:04 UTC Comment hidden (obsolete)
Comment 12 Justin L 2016-08-11 15:47:37 UTC
Created attachment 126761 [details]
debug84678_patch.diff: to help a developer get started

comment 10: I tried to do a simple revert and LO crashes, so it has moved a long way in 2 years and there is simple reversion option.

I think the first place to start is focusing on the FRAME position, not the textbox.  Try moving the frame around - it jumps all over the place and immediately gets out of sync with the textbox.
Comment 13 Justin L 2016-08-12 11:50:53 UTC
Created attachment 126771 [details]
zip with various word PDFs of Comment 11's August.docx

reply to comment 11: this is a different problem than the reported one.  I tried opening it in Word 2007 (xp) and in Word Online (Firefox) and it looks bad even in both of those.
Comment 14 Luke 2016-08-13 06:52:53 UTC
Created attachment 126778 [details]
Patch to re-enable Text Frames

This patch reverts d379d18666aa42031359ca8eb34b0021960347ae. As Justin pointed out it breaks a lot of Unit Tests. If we decide to go down this path, I can try to figure out additional code was added between 4.4 and now that's causing this issue.

I think 4.3's use of Text Frames aligns much better with MSO's Text Boxes. Our Text Frame's "Spacing to Content" maps perfectly to MSO's Text Box margins. Our Text Boxes don't have margins. And when you move them the text doesn't stay in the Text Box, which kind of defeats the whole point of Text Boxes. 

Miklos,
What do you think of going back to Text frames?


Michael,
Please refrain hijacking bug reports with your issues. attachment 126525 [details] renders better in LibreOffice than it does in MSO 2013. The frame is cut off in MSO 2013 and fully displayed in LibreOffice. The CONFIRMATION Text Box renders the same in LibreOffice as it does in Word 2013 and Word Online. Neither of these issue are related to this issue of "textbox margins".
Comment 15 Xisco Faulí 2016-09-19 21:41:56 UTC
*** Bug 98830 has been marked as a duplicate of this bug. ***
Comment 16 Xisco Faulí 2016-09-19 21:43:43 UTC
*** Bug 100921 has been marked as a duplicate of this bug. ***
Comment 17 Xisco Faulí 2016-09-26 09:26:16 UTC
Adding Cc: to Miklos Vajna
Comment 18 Commit Notification 2016-10-25 09:33:31 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=c761df1e42fd11acc5fc05b0baacd803c3788ca6

tdf#84678 DOCX import: fix handling of textbox margins

It will be available in 5.3.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 19 Terrence Enger 2016-10-27 15:49:01 UTC
I see the bad alignment fixed between commit cec94a4 (2016-10-14) and
commit 8175e30 (2016-10-25).

I used local-built LibreOffice, configured ...
    CC=ccache /usr/bin/gcc
    CXX=ccache /usr/bin/g++
    --enable-option-checking=fatal
    --enable-dbgutil
    --enable-debug
    --without-system-postgresql
    --without-myspell-dicts
    --with-extra-buildid
    --without-doxygen
    --with-external-tar=/home/terry/lo_hacking/git/src
built and running on debian-stretch.
Comment 20 Xisco Faulí 2016-10-27 16:01:01 UTC
Set it to VERIFIED FIXED as per comment 19