Bug 76683 - FILEOPEN: DOCX with 2 column spacing empty opens without content due to wrongly read Columns in Text Section
Summary: FILEOPEN: DOCX with 2 column spacing empty opens without content due to wrong...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: low normal
Assignee: Justin L
URL:
Whiteboard: BSA interoperability target:6.2.0
Keywords: filter:docx
Depends on:
Blocks: DOCX
  Show dependency treegraph
 
Reported: 2014-03-27 12:11 UTC by Toni
Modified: 2018-10-04 06:31 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
MS Word Document (.docx) and MS Word screenshot (740.82 KB, application/zip)
2014-03-27 12:11 UTC, Toni
Details
Problem DOCX - original with 2 columns and empy spacing (687.04 KB, application/vnd.ms-word.document.12)
2017-03-17 17:45 UTC, Timur
Details
Problem DOCX - original screenshot (62.98 KB, image/png)
2017-03-17 17:45 UTC, Timur
Details
Problem DOCX - resaved with 2 columns and some spacing (687.02 KB, application/vnd.ms-word.document.12)
2017-03-17 17:46 UTC, Timur
Details
Not sure working (2.10 MB, video/mp4)
2018-09-15 14:17 UTC, BogdanB
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Toni 2014-03-27 12:11:47 UTC
Created attachment 96454 [details]
MS Word Document (.docx) and MS Word screenshot

Problem description: 
The attached MSO document opens in Writer without content (looks empty).

Steps to reproduce:
Open attached document in Writer.

Current behavior:
Document looks empty.

Expected behavior:
Document looks like it does in MS Word (reference screenshot attached).
Operating System: Windows 7
Version: 4.2.3.1 rc
Comment 1 Urmas 2014-03-27 12:14:46 UTC
Confirmed in master.
Comment 2 Toni 2015-02-26 18:27:17 UTC Comment hidden (obsolete)
Comment 3 Toni 2015-10-01 11:23:50 UTC
Issue still existing in 5.5.0.2 release.
Comment 4 Xisco Faulí 2017-03-15 10:20:15 UTC
Still reproducible in

Version: 5.4.0.0.alpha0+
Build ID: d3b5bd4a07a619db6bee1c39c32280ac3c620532
CPU threads: 4; OS: Linux 4.8; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group

and

LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4
Comment 5 Timur 2017-03-17 17:42:08 UTC
DOCX has 2 columns, but not properly created: 1st column has width 16,59 cm and spacing is empty. 
LO reads TextSection with 1 column, where 1st has width 0,01 cm and spacing 16,00 cm (or 56,00 cm)

Workaround 1: If TextSection is removed, content is there. 
Workaround 2: save DOCX in MSO with some spacing.
Comment 6 Timur 2017-03-17 17:45:23 UTC
Created attachment 131963 [details]
Problem DOCX - original with 2 columns and empy spacing

XML validation shows 2 errors: 
main:space  - attribute invalid, value -1 not valid
main:w - attribute invalid, value -1 not valid
Comment 7 Timur 2017-03-17 17:45:59 UTC
Created attachment 131964 [details]
Problem DOCX - original screenshot
Comment 8 Timur 2017-03-17 17:46:33 UTC
Created attachment 131965 [details]
Problem DOCX - resaved with 2 columns and some spacing
Comment 9 QA Administrators 2018-03-18 03:35:29 UTC Comment hidden (obsolete)
Comment 10 Timur 2018-03-19 07:54:49 UTC Comment hidden (me-too)
Comment 11 Timur 2018-03-19 07:55:16 UTC Comment hidden (obsolete)
Comment 12 Justin L 2018-08-21 08:43:30 UTC
Columns width and space: The possible values for this attribute are defined by the ST_TwipsMeasure simple type (§2.17.104). This simple type specifies that its contents will contain a positive whole number, whose contents consist of a
measurement in twentieths of a point (equivalent to 1/1440th of an inch).

However
<w:cols w:num="2" w:space="794" w:equalWidth="0">
  <w:col w:w="9406" w:space="-1"/>
  <w:col w:w="-1"/>
</w:cols>
Comment 13 Justin L 2018-08-22 04:20:18 UTC
Hmm, more than that. Also appears that the function calculating column width is wrong since inception at https://cgit.freedesktop.org/libreoffice/core/commit/?id=d462a3470c7fc61fcb53fde82fd8fe5489376483 particularly with these lines

pColumn[nCol].Width = sal_Int32((double( m_aColWidth[nCol] + pColumn[nCol].RightMargin + pColumn[nCol].LeftMargin ) + 0.5 ) * fRel );

     if( nColSum != nRefValue )
         pColumn[m_nColumnCount].Width -= ( nColSum - nRefValue );

https://gerrit.libreoffice.org/59400 tdf#76683 writerfilter: TwipMeasure must be positive
https://gerrit.libreoffice.org/59401 related tdf#76683 writerfilter: hanging implemented as SignedTwips
Comment 14 Justin L 2018-08-22 06:17:48 UTC
The following unit tests had instances where a TwipsMeasure was found with a negative value.

ooxmlexport2: fdo66781.docx - numbering.xml hanging indent -1080 ONLY ON A ROUND TRIP - so we are exporting incorrectly in numbering - should be "firstLine" instead of "hanging" for negative numbers.
    -also ooxmlexport4 tdf86926_A3.docx
    -also ooxmlexport9 tdf112169.odt
    -also ooxmlexport10 tdf89702.docx
proposed fix at https://gerrit.libreoffice.org/59423 related tdf#76683 docx export: use firstLine, not hanging

ooxmlexport11: tdf118521_marginsLR.docx - document.xml hanging indent -500. Error in hand-crafted document. Interestingly MS Word ACCEPTS AND USES THE NEGATIVE VALUE despite their documentation.
Comment 15 Commit Notification 2018-08-23 04:24:35 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

related tdf#76683 docx export: use firstLine, not hanging

It will be available in 6.2.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 16 BogdanB 2018-09-15 14:17:47 UTC
Created attachment 144894 [details]
Not sure working

I tested 2 files with 6.2 on linux: I am not sure it is working, please see the video I made. On this video I open first the file from comment 6, the one with errors, and the file is open blank. After that, in video I open the file from comment 8 and it is working as aspected. 

Version: 6.2.0.0.alpha0+
Build ID: 9a9b81c7212fa6a6762246593acf3f1950677a22
CPU threads: 4; OS: Linux 4.15; UI render: GL; VCL: gtk2; 
TinderBox: Linux-rpm_deb-x86_64@86-TDF, Branch:master, Time: 2018-09-08_00:00:43
Locale: ro-RO (ro_RO.UTF-8); Calc: threaded
Comment 17 Justin L 2018-09-17 05:25:30 UTC
Oops. Yes, the patches to fix it are still pending. Comment 15 was just a related patch. The proposals in Comment 13 are still pending review.  Not fixed yet.
Comment 18 Commit Notification 2018-10-03 05:54:46 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#76683 writerfilter: TwipMeasure must be positive

It will be available in 6.2.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 Justin L 2018-10-03 06:03:38 UTC
Really fixed now.  Tomorrow's related patch will build on and take advantage of the TwipsMeasure changes made to fix this bug, but not related to the column bug itself.
Comment 20 Commit Notification 2018-10-04 06:31:12 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

related tdf#76683 writerfilter: hanging implemented as Signed

It will be available in 6.2.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.