Created attachment 131403 [details] Sample, save as DOCX and reopen 1. Insert an image in an empty document. 2. Set a caption via right click on image, Insert Caption... (just add a caption and click OK) 3. Save file as DOCX. 4. Reopen in Writer. An ODT with steps 1-2 is attached. => The frame around the image is incorrectly sized, and can't contain the image or caption anymore. (there's no numbering, either, that will be reported separately) Reproduced with 5.3.0.3 / Windows 7, looks fine in 5.2.0.4. => regression Interestingly, since 4.4.0.3 the frame also turns into a text box, which, if created manually, can't hold images. Since it's a basic function, setting importance to high/major.
Bibisected using repo bibisect-win32-5.3. 5ef53ff20dccfce6d58e31ec1d7802357d8140b3 is the first bad commit commit 5ef53ff20dccfce6d58e31ec1d7802357d8140b3 Author: Norbert Thiebaud <nthiebaud@gmail.com> Date: Tue Oct 25 05:35:00 2016 -0700 source c761df1e42fd11acc5fc05b0baacd803c3788ca6 # bad: [166286094e583fb471c9500fdbddee4e83ef478c] source 70b3dd697cb248fb56830db691269fe9e78c57fb # good: [defb73f1c6e2a66dbd21ba89e684f57427e8bc4b] source 5b168b3fa568e48e795234dc5fa454bf24c9805e git bisect start '166286094e583fb471c9500fdbddee4e83ef478c' 'oldest' # good: [f8c311fc5523da9c3e971202ac1389be92d196b7] source 9cd59f774621b99174af2cd698466d5c0d9a68e2 git bisect good f8c311fc5523da9c3e971202ac1389be92d196b7 # good: [287cd1a6e31c62e092de162b8a5499fe72858ccd] source 7403c95540ba96a304eaebcb4845e910746133bb git bisect good 287cd1a6e31c62e092de162b8a5499fe72858ccd # bad: [6ce9e10e7d03e295648b1f8018e605b32387e2cc] source 01ff03e15449a618a4a8623a29eb9ea5917e6c22 git bisect bad 6ce9e10e7d03e295648b1f8018e605b32387e2cc # bad: [d942a1e38f5704d412d2c663e437457a1a5a07ba] source 23ca39a7c2cd5b33ac6361282432c6f34c458366 git bisect bad d942a1e38f5704d412d2c663e437457a1a5a07ba # good: [000a4fc35af4d0c25c3730e4531597aeba340052] source 06916c839b16866b47235306d2db50850df0ad7c git bisect good 000a4fc35af4d0c25c3730e4531597aeba340052 # good: [045aad312e2314270c22a467d8599d8d449a3a2b] source b43888e73c761436f102b61e21d00825b6813a18 git bisect good 045aad312e2314270c22a467d8599d8d449a3a2b # bad: [ebaca41f0b9ca71da0779f7daafddc581b5acabd] source 48304cb5b4d8df71463837e2e48aa7c4d9594df9 git bisect bad ebaca41f0b9ca71da0779f7daafddc581b5acabd # bad: [872fabb1ea5566e72d1ba5a357b6f9ed3ba3a313] source 799a3a7915e6285c8072f92c63ba7149223ac443 git bisect bad 872fabb1ea5566e72d1ba5a357b6f9ed3ba3a313 # bad: [76228e22605068b4f07a715107f2602e5f47704d] source 56c71eb5bc674938fc9934a56770f6ee19c98204 git bisect bad 76228e22605068b4f07a715107f2602e5f47704d # bad: [27a003cf107e6356b55a3f42057b44aca9fa05d1] source 30a458d7e1dcd8c7b35cd74b10ce41d2a89e8552 git bisect bad 27a003cf107e6356b55a3f42057b44aca9fa05d1 # good: [2e3a65b324acf135f382cda2efb3cbd0550a4a9e] source fab262f115e5c0e6d43b65e376241152ddff82b3 git bisect good 2e3a65b324acf135f382cda2efb3cbd0550a4a9e # bad: [4ddfd43b5587f5a819d210d04e07a632065f7a78] source b45fe99f16762c5d79ce67f6a04ee58fc7c14456 git bisect bad 4ddfd43b5587f5a819d210d04e07a632065f7a78 # bad: [5ef53ff20dccfce6d58e31ec1d7802357d8140b3] source c761df1e42fd11acc5fc05b0baacd803c3788ca6 git bisect bad 5ef53ff20dccfce6d58e31ec1d7802357d8140b3 # first bad commit: [5ef53ff20dccfce6d58e31ec1d7802357d8140b3] source c761df1e42fd11acc5fc05b0baacd803c3788ca6
The commit is also causing bug 103990, but it's hard to determine whether the two issues are the exact same, and also the repro steps/document are very simple here. Adding Cc: to Miklos Vajna, please take a look. https://cgit.freedesktop.org/libreoffice/core/commit/?id=c761df1e42fd11acc5fc05b0baacd803c3788ca6 author Miklos Vajna <vmiklos@collabora.co.uk> 2016-10-25 07:05:47 (GMT) committer Miklos Vajna <vmiklos@collabora.co.uk> 2016-10-25 09:32:01 (GMT) "tdf#84678 DOCX import: fix handling of textbox margins"
Confirmed in Version: 5.4.0.0.alpha0+ Build ID: 880033edde516fc30225005245253293a6a58ba4 CPU Threads: 4; OS Version: Linux 4.8; UI Render: default; VCL: gtk2; Locale: ca-ES (ca_ES.UTF-8); Calc: group I guess both bugs are related. Anyway, let's keep both open and see if fixing one fixes the other...
I have experienced a similar problem with version 5.2.6.2 with a file I am editing. I have created a test document based on it. Steps to reproduce: - Save the attached .odt file as .docx - Open the .docx Result: the first of the 3 images is incorrectly sized in the .docx, and can't contain the image or caption anymore. Surprisingly, if I save as .docx the document attached by Aron using 5.2.6.2, it shows the correct size when opened again. However, the numbering is lost.
Created attachment 132901 [details] Save as .docx and reopen to reproduce the bug
Created attachment 132902 [details] Sample of the resulting .docx file
Created attachment 134236 [details] DOCX-independent reproducer (ODT) I think the root cause here is somewhere in Writer, not in the docx filter. Reverting the bisected commit doesn't help here. Here is what I tried: if I save the old import result in ODT, then that ODT is loaded fine in the parent of the bisected commit (i.e. something between 5.2 and 5.3), but loading the same ODT on master is broken. I *think* this is the root cause. Bibisecting this breakage gives the 8f2dd1df1d6cc94ebbc1149de72bc6d6dffa6533..a6ce5d391476e4b6a2cb2d92ff45548c1d75684b range, from which 5d9d0f3c979732ade57b9c4c4960dd030ffdc9f9 looks related. It's not clear to me what is the problem, though. There was a follow-up fix of that commit as 1427817a944f3cf1020b2f06a2ca934847b56ba8. Reverting both of these commits locally build, but the bug does not go away.
Justin, any idea what is going on? I guess the root cause here is somewhere around this nice new sw feature that you can have margins without borders, but I'm not sure. Thanks.
(Yes, in the meantime I bisected with bibisect-linux-64-53.git and git bisect points out exactly the commit I suspected. So no more guessing the commit from the range.)
(In reply to Miklos Vajna from comment #9) > (Yes, in the meantime I bisected with bibisect-linux-64-53.git and git > bisect points out exactly the commit I suspected. "there is a function for that: CalcLineSpace(xx, bEvenIfNoLine)" was a VERY unfortunately commit because it prematurely causes the regressions that tdf#41542 (globally allow borderless padding) would have made the following day.
My guess is that some default spacing values for frames/textboxes are not being reset to zero during the conversion. Before, unnecessary values would have been ignored, but as soon as AllowSpacingWithoutBorders exists (which set frmtool.cxx::m_bBorderDist = true), then the entire frame shifted down. Thus, both Miklos and my commits are basically unmasking the same error. Spacing numbers are 142 for right/left and 71 for top/bottom. If that matches defaults, that would validate my suspicions.
(In reply to Justin L from comment #11) > My guess is that some default spacing values for frames/textboxes are not > being reset to zero during the conversion. void Shape::setDefaults(bool bHeight) { maDefaultShapeProperties.setProperty(PROP_TextLeftDistance, static_cast< sal_Int32 >( 250 )); maDefaultShapeProperties.setProperty(PROP_TextUpperDistance, static_cast< sal_Int32 >( 125 )); maDefaultShapeProperties.setProperty(PROP_TextRightDistance, static_cast< sal_Int32 >( 250 )); maDefaultShapeProperties.setProperty(PROP_TextLowerDistance, static_cast< sal_Int32 >( 125 )); } Potential fix for the .docx documents (except that it isn't focused on this particular bug and likely would cause lots of regressions) is: +++ b/oox/source/drawingml/shape.cxx @@ -899,6 +899,12 @@ Reference< XShape > const & Shape::createAndInsert( else if (mbTextBox) { aShapeProps.setProperty(PROP_TextBox, true); +//clear default border spacing values +aShapeProps.setProperty(PROP_TextLeftDistance, static_cast< sal_Int32 >( 0 )); +aShapeProps.setProperty(PROP_TextUpperDistance, static_cast< sal_Int32 >( 0 )); +aShapeProps.setProperty(PROP_TextRightDistance, static_cast< sal_Int32 >( 0 )); +aShapeProps.setProperty(PROP_TextLowerDistance, static_cast< sal_Int32 >( 0 )); }
(In reply to Cesar Martinez Izquierdo from comment #4) Your bug is unrelated - it started in LO5.0. I created a separate report as bug 108932.
*** Bug 103990 has been marked as a duplicate of this bug. ***
Miklos: Can you take over on this one? My hack can be more closely targeted with a if( getWps() ) clause, but you have the big picture scope needed for this.
Justin: I think the root cause is in sw/, not in the import filter. Some context if that helps: Shapes from DOCX are imported as "shape with textbox", which means that we create a draw shapes (which can have rounded corners, etc) and then there is "textbox" attached to it, which is a Writer textframe (so can contain tables, etc). The UI and UNO API hides direct access to this Writer textframe. Now OOXML shapes can have zero margin for their text (even if they don't have a border), and in the textbox use-case the Writer textframes never have a border, that's how your sw feature was super-useful for me, now I can have zero margin and no borders at the same time, needed by the "zero margin in OOXML shape with text" case. The getWps() info is available only in oox. See the above ODT document I attached, I think this doesn't have much to do with OOXML. > Miklos: Can you take over on this one? Ah, so regarding the above ODT file, you think there is no bug in general, but only when it comes to textboxes? I rather hoped you would take this over, but sure, if zero-margin without borders work in general and this is specific to textboxes, then I can try to take a look. :-)
(In reply to Miklos Vajna from comment #16) > Ah, so regarding the above ODT file, you think there is no bug in general, > but only when it comes to textboxes? Correct. I think the .ODT is just "honoring" the hidden textbox border padding settings that were created as part of the .docx import (since the file originated as .docx). So, I'm pretty sure it is just the "conversion to shape with textframe containing non-zero padding defaults" that is the problem here. However, the shape code is so generic that I have no idea what all I would be affecting if I made changes there. from-docx-old.odt contains ...style:style style:name="gr1" ... fo:padding-top="0.125cm" fo:padding-bottom="0.125cm" fo:padding-left="0.25cm" fo:padding-right="0.25cm"... Any re-saved .docx -> odt files since LO4.4 (2014-06-18 09:57:31) d379d18666aa42031359ca8eb34b0021960347ae will probably be "unfixable" since they will have the default border padding hard-coded inside.
OK, I'm taking this.
Justing, thanks a lot for suggesting this is a filter / textbox bug, not an sw layout problem, you were right. :-)
Miklos Vajna committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=6f9f9491bdef676f969898bd653db9905d14f5e8 tdf#106132 DOCX import: fix handling of nested textbox margins It will be available in 6.0.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.
Miklos Vajna committed a patch related to this issue. It has been pushed to "libreoffice-5-4": http://cgit.freedesktop.org/libreoffice/core/commit/?id=2cd91d79b90316f6a21db64bd944cb828b345a78&h=libreoffice-5-4 tdf#106132 DOCX import: fix handling of nested textbox margins It will be available in 5.4.1. 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.