Bug 139273 - FILEOPEN: DOC/DOCX/RTF. Endnote page style page-size different from Default Page Size
Summary: FILEOPEN: DOC/DOCX/RTF. Endnote page style page-size different from Default P...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: low minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:docx
Depends on:
Blocks: DOCX-Page
  Show dependency treegraph
 
Reported: 2020-12-28 10:52 UTC by Telesto
Modified: 2024-05-29 14:05 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file (20.79 KB, application/vnd.oasis.opendocument.text)
2020-12-28 10:54 UTC, Telesto
Details
endnoteA4size.docx: minimal with <w:numFmt w:val="decimal"/> (7.78 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-12-30 05:21 UTC, Justin L
Details
endnoteMatchingSize.docx: identical minimal except <w:numFmt w:val="lowerRoman"/> (7.78 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-12-30 05:24 UTC, Justin L
Details
endnotePage.docx: LO needs lots of work to handle endnotes like MS Word (17.81 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-05-16 18:22 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Telesto 2020-12-28 10:52:42 UTC
Description:
FILEOPEN: DOC/DOCX/RTF. Wrong last page style (also present at copy/paste of the document)

Steps to Reproduce:
1. Open the attached file
2. CTRL+A
3. CTRL+C
4. CTRL+N
5. CTRL+V (notice first and last page)
6. Back to initial file: Save as DOCX (or DOC)
7. File reload
8. Compare with Word.. does work

Actual Results:
Last page being A4 format

Expected Results:
User defined size


Reproducible: Always


User Profile Reset: No



Additional Info:
Found in
Version: 7.2.0.0.alpha0+ (x64)
Build ID: 315c7570c4a72f4c834086082825533b1e50d1bf
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: Skia/Raster; VCL: win
Locale: nl-NL (nl_NL); UI: en-US
Calc: CL

LibreOffice 3.5.7.2 
Build ID: 3215f89-f603614-ab984f2-7348103-1225a5b
Comment 1 Telesto 2020-12-28 10:54:32 UTC
@Justin
Adding you because you did some work on page styles in the past.. (it related to endnote style in this specific doc)
Comment 2 Telesto 2020-12-28 10:54:52 UTC
Created attachment 168525 [details]
Example file
Comment 3 mulla.tasanim 2020-12-28 17:31:55 UTC
Thank you for reporting the bug.

I can confirm that the bug is present in

Version: 7.0.3.1 (x64)
Build ID: d7547858d014d4cf69878db179d326fc3483e082
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL

Version: 7.2.0.0.alpha0+ (x64)
Build ID: 761a672d62df1891b9f4f367a499b220ab2b33fa
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL
Comment 4 Justin L 2020-12-29 12:28:38 UTC
I found this bug report very hard to follow.  There are so many different things happening here.

1.) If you round-trip the file to DOCX format, then the endnote page doesn't match the smaller size of the other pages on import. (However, Word 2003 imports it with the smaller page dimensions - so file import issue.) Also true for RTF.

2.) DOC format puts the endnotes at the end of the chapter, except that there is still a bit of text from the chapter on the following page - likely just a layout error. (Word opens this file (with errors) and also shows the endnotes at the chapter end.) See Bug 102835 for a request for per-chapter endnotes for Writer. [I'm not sure how DOC format does this. Reviewing the settings of Tools - Footnotes and Endnotes and hitting OK causes the endnotes to jump to the end of the document (with the same caveat as before).

3.) Copy and pasting - doesn't copy the attributes of the default page style (no header, larger A4 page size) or the endnote page style into the new document. (That's not surprising since there is no paragraph containing properties that specify the default page style or the endnote page style.)
Comment 5 Justin L 2020-12-29 13:44:16 UTC
> 1.) If you round-trip the file to DOCX format...
So, the end-note page is not a real page anyway. It is some automatic thing, and so there is no specification in the DOCX attributes about this "page style", since page styles don't exist in Word.

I wasn't able to recreate this problem in a brand new document, so generally it seems to take the size (but not orientation) from the default page style as expected.

I spot checked in 7.1, 6.1, 5.2, 5.0, and 3.5 and all acted the same way in regards to the endnote page being A4 sized.
Comment 6 Telesto 2020-12-29 14:04:57 UTC
FWIW: source file https://bugs.documentfoundation.org/attachment.cgi?id=163710
Comment 7 Justin L 2020-12-29 14:48:31 UTC
Believe it or not, in word/document.xml, replacing all instances of
<w:numFmt w:val="decimal"/>
with
<w:numFmt w:val="lowerRoman"/>
"fixes" the problem of the large endnote page size.
Comment 8 Justin L 2020-12-29 18:55:51 UTC
The big difference is in sw/source/core/doc/docftn.cxx's SetEndNoteInfo when
   if( GetEndNoteInfo() == rInfo )
       return;
when nNumType = SVX_NUM_ROMAN_LOWER, so there is nothing to do since it already matches the default. Otherwise it lcl_PutStdPageSizeIntoItemSet into the Endnote page style - based off of the default page style.

The problem is that this is happening too early - before the default page style has been updated with the DOCX parameters. So obviously the fix is to delay ::LN_CT_NumFmt_val, but how... And where is def page style getting updated? (Well, the updating would happen in the first CloseSectionGroup.)
Comment 9 Justin L 2020-12-29 19:02:34 UTC
Well, this is very low priority I would say, and I have given LOTS of code pointers, so lets make this an easyHack.

It all starts from writerfilter/source/dmapper/DomainMapper.cxx's
    case NS_ooxml::LN_CT_NumFmt_val:
and
    case NS_ooxml::LN_EG_FtnEdnNumProps_numStart:
    case NS_ooxml::LN_EG_FtnEdnNumProps_numRestart:
Comment 10 Justin L 2020-12-29 19:07:46 UTC
P.S. The way to trigger this bug (or workaround to "fix" it) is
Tools -> Footnotes and Endnotes - > Endnotes - Numbering = something that DOCX supports like 123 or ABC, or even I,II,III - anything other than i, ii, iii.
Comment 11 Justin L 2020-12-30 05:21:24 UTC
Created attachment 168567 [details]
endnoteA4size.docx: minimal with <w:numFmt w:val="decimal"/>
Comment 12 Justin L 2020-12-30 05:24:33 UTC
Created attachment 168568 [details]
endnoteMatchingSize.docx: identical minimal except <w:numFmt w:val="lowerRoman"/>
Comment 13 Telesto 2020-12-31 09:21:16 UTC
@Justin
Before I forget. Thank you for looking into it and the depth investigation! 
And figuring out the flaw. 

I really unaware/missed of all the other things I (incidentally) included with my report (comment 4). The page dimensions was the most prominent/obvious
Comment 14 Justin L 2023-05-16 18:22:31 UTC
Created attachment 187338 [details]
endnotePage.docx: LO needs lots of work to handle endnotes like MS Word

The endnote page ought to copy the last page, not the first page.
Comment 15 Justin L 2023-06-15 17:58:43 UTC
Although this patch https://gerrit.libreoffice.org/c/core/+/153151
is probably not correct I'll post it here anyway to document my attempt.

This is not an easyhack.
Comment 16 Justin L 2024-05-29 14:05:02 UTC
repro 24.8+