Bug 90508 - FILEOPEN: Different First Page broken with Page Number "Start at 0"
Summary: FILEOPEN: Different First Page broken with Page Number "Start at 0"
Status: RESOLVED DUPLICATE of bug 94882
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.2.0.4 release
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, filter:doc, regression
Depends on:
Blocks: Fields-Page-Number
  Show dependency treegraph
 
Reported: 2015-04-07 23:31 UTC by Luke
Modified: 2018-08-07 15:48 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments
Stripped down test case that's not working (44.00 KB, application/msword)
2015-04-07 23:31 UTC, Luke
Details
Comparision MS Word vs AOO 4.2 vs LO 4.5 (181.24 KB, image/png)
2015-04-07 23:41 UTC, Luke
Details
patch that isn't good enough: can't find where FirstLeft is being overwritten (1.66 KB, patch)
2017-01-18 12:08 UTC, Justin L
Details
Stripped down test modified to work (40.00 KB, application/msword)
2017-03-02 07:59 UTC, Luke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luke 2015-04-07 23:31:19 UTC
Created attachment 114681 [details]
Stripped down test case that's not working

The .DOC importer now sometimes ignores the Different First Page Headers and Footers flag. I've noticed this in several documents and have made a very simple test case.

Steps to reproduce:
1. Open DifferentFirstPageChecked-good.doc in OpenOffice or MS Word
2. Open DifferentFirstPageChecked-good.doc in LibreOffice Writer
3. Compare

Page 1 should be 0, while Page 2 should be 1.
Comment 1 Luke 2015-04-07 23:41:52 UTC
Created attachment 114682 [details]
Comparision MS Word vs AOO 4.2 vs LO 4.5
Comment 2 A (Andy) 2015-04-08 19:29:43 UTC
Reproducible with LO 4.4.1.2, Win 8.1

But I was wondering what does this number in the header makes?  How did you insert it?
Comment 3 Luke 2015-04-08 22:40:14 UTC
Andy,
It doesn't mean anything. It's just a "zero" and a "one" that I entered with the keyboard. I could have typed anything. 

The issue is that when the "Different First Page" flag is set, the general header is supposed to be replaced with the title page header. OpenOffice's importer seems to always honor the flag, while Libreoffice's seems to have problems with complex documents.
Comment 4 Buovjaga 2015-04-16 11:00:24 UTC
Works ok in 3.6, already broken in 4.2.

Ubuntu 14.10 64-bit
Version 3.6.7.2 (Build ID: e183d5b)

Version: 4.2.0.4
Build ID: 05dceb5d363845f2cf968344d7adab8dcfb2ba71
Comment 5 Matthew Francis 2015-04-21 01:41:54 UTC
Somehow this has ended up the opposite of bug 77111, which traces back to the same commit.

Adding Cc: to rattles2013@gmail.com; Could you possibly take a look at this one? Thanks


commit c2ccd20c0fd92bddfff76447754541705e3eb8f3
Author: Adam Co <rattles2013@gmail.com>
Date:   Thu Aug 29 17:16:44 2013 +0300

    fdo#44689: fix for specific case of page restart-value 0
    
    This bug fix is for roundtripping a DOCX that has
    a specific 'start value' for the page numbers.
    In most cases LO imports it ok.
    However - until now - Word allowed you to start page number
    from 0, while LO only allowed starting page numbers from 1.
    This was because the 'start value' was stored in an 'unsigned int',
    and the value '0' was used to mark 'there is no start value'.
    This patch changes the way the 'start value' is stored
    from 'unsigned int' to 'optional unsigned int'.
    This way - if there is no value applied - the variable will hold NULL.
    However - if a value is set - it can be 0 or more.
    This meant also tweaking all the places that used to get this value,
    so that now they handle an 'optional uint', instead of a 'uint'.
Comment 6 Xisco Faulí 2015-09-08 15:21:40 UTC
This issue is still present in

Version: 5.0.1.2
Build ID: 81898c9f5c0d43f3473ba111d7b351050be20261
Locale: es-ES (es_ES)

on Windows 7 (64-bit)
Comment 7 Robinson Tryon (qubit) 2015-12-10 01:18:40 UTC Comment hidden (obsolete)
Comment 8 Jean-Baptiste Faure 2016-04-19 19:27:29 UTC
Confirmed in 4.2.0, worked in 3.6.7. Set version number accordingly.

Best regards. JBF
Comment 9 Xisco Faulí 2016-09-24 14:51:31 UTC

*** This bug has been marked as a duplicate of bug 77111 ***
Comment 10 Justin L 2017-01-17 15:47:47 UTC
Not a duplicate.  This header value (which happens to have 0 in it) is not related to the page number (which however IS zero). That's just coincidence.

The problem is that the very first page header is always stored in the ODD page format, but page 0 is an even page. Either store the EVEN header if the page number is already known (haven't checked into that yet), or else bOdd = bOdd || bFirst (known to work for this document).
Comment 11 Justin L 2017-01-18 12:08:54 UTC
Created attachment 130521 [details]
patch that isn't good enough: can't find where FirstLeft is being overwritten

This patch shows that upon initial load, everything is fine, but as soon as you do anything, the first/even header is reset. I haven't located what is causing that reset.
Comment 12 Luke 2017-03-02 07:59:39 UTC
Created attachment 131570 [details]
Stripped down test modified to work

I found the exact setting that breaks our importer.

In Word if I go to 
Design->Page Number->Format Page Number->Page Numbering

And I change the value 
from "Start at 0" 
to "Continue from Previous" OR  "Start at 1" 

Writer successfully imports the file. 

Michael,
The source of the regression that caused Bug 77111 is the same commit that caused this bug. Do you need to make similar changes to the .doc importer to fix this issue too?
Comment 13 Xisco Faulí 2017-11-07 23:50:22 UTC
Bug no longer reproducible in

Version: 6.0.0.0.alpha1+
Build ID: 38a8157d9447134913d88c6c373d99a7aa472857
CPU threads: 4; OS: Linux 4.10; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group

Closing as RESOLVED WORKSFORME

[Improvement found by office-interoperability-tools]
Comment 14 Justin L 2017-11-08 08:38:01 UTC
fixed and backported to 5.4 with bug 94882 by Luke Deller on 2017-08-22 15:07:23 UTC
http://cgit.freedesktop.org/libreoffice/core/commit/?id=232885c66422ab8f05d86cfeac9b377a97462ae4

*** This bug has been marked as a duplicate of bug 94882 ***