Bug 93644 - FILEOPEN: Header Object Anchored Incorrectly Causing Incorrect Alignment
Summary: FILEOPEN: Header Object Anchored Incorrectly Causing Incorrect Alignment
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected)
Hardware: Other All
: medium normal
Assignee: Not Assigned
Keywords: bibisected, bisected, filter:docx, regression
Depends on:
Blocks: Anchor-and-Text-Wrap DOCX-Limitations FastParser-regressions
  Show dependency treegraph
Reported: 2015-08-25 00:44 UTC by Matthew Holloway
Modified: 2022-09-30 12:29 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:
Regression By:

Source document (283.33 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2015-08-25 00:44 UTC, Matthew Holloway
msword rendering of document showing that the header is to the left (58.74 KB, image/png)
2015-08-25 00:45 UTC, Matthew Holloway
Rendering in LibreOffice showing header is moved to the right (196.52 KB, application/pdf)
2015-08-25 00:45 UTC, Matthew Holloway
Rendering in LibreOffice (429.06 KB, application/pdf)
2015-08-25 03:54 UTC, Matthew Holloway
libreoffice- (16.46 KB, image/png)
2015-08-25 03:56 UTC, Matthew Holloway
simple test case (186.24 KB, application/msword)
2015-12-03 15:39 UTC, raal
simple test case (185.94 KB, application/msword)
2015-12-03 15:57 UTC, raal

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Holloway 2015-08-25 00:44:56 UTC
Created attachment 118157 [details]
Source document

In the attached file the header on the first page is moved over towards the right.
Comment 1 Matthew Holloway 2015-08-25 00:45:28 UTC
Created attachment 118158 [details]
msword rendering of document showing that the header is to the left
Comment 2 Matthew Holloway 2015-08-25 00:45:59 UTC
Created attachment 118159 [details]
Rendering in LibreOffice showing header is moved to the right
Comment 3 Joel Madero 2015-08-25 03:43:25 UTC
It's actually how the header is anchored - it's anchored as a character instead of to the page. Objects anchored as a character cannot be aligned Horizontally (the option is greyed out). 

Ubuntu 15.04 x64

Setting as:
Normal - can prevent high quality work. This could technically be a minor bug because there is the ability to "reset" the object but if someone sends you a document it's very hard to collaborate as objects are not maintained in the correct place;
Medium - default

@Matthew - if possibly it would be great to determine if this is a regression. Our team isn't big enough to test every bug to determine if they are regressions but if it is a regression there are additional things we can do to track down the cause. Older versions can be found here: http://downloadarchive.documentfoundation.org/libreoffice/old/

Note that version is the oldest version confirmed on - so if you confirm it on an older version please update the version field. Thanks!
Comment 4 Matthew Holloway 2015-08-25 03:54:12 UTC
Created attachment 118163 [details]
Rendering in LibreOffice

Hi Joel, thanks I'll do that and try and find the version where the regression occurred.

It seems that earlier versions of LibreOffice handled it more correctly. Here are some examples.
Comment 5 Matthew Holloway 2015-08-25 03:56:21 UTC
Created attachment 118164 [details]

And here's an overlay of MSWord's rendering with LibreOffice (at 50% transparency). As you can see it's very close in the older versions of LibreOffice.

I'll try and find the version of LibreOffice in which this regression occured.
Comment 6 Joel Madero 2015-08-25 04:07:43 UTC
Fantastic work here :) We'd love to have you join the QA team - we could use these talents. If you want to stop by to say hello: http://webchat.freenode.net/?channels=libreoffice-qa

Also - if you find that your bugs are regressions you can add the following:
Keywords: regression;
Whiteboard: bibisectRequest
Comment 7 Matthew Holloway 2015-08-25 05:36:28 UTC
Hi, thanks for the links to the downloadarchive. I've been installing various versions of LO in some VMs to test on and here's what I've found so far (I'll continue this tomorrow).

Bug doesn't occur in

Bug does occur in (and later including and

So I guess that means that it first occurred in,,, or
Comment 8 Matthew Holloway 2015-08-25 10:53:50 UTC
First appears in
Comment 9 Matthew Holloway 2015-08-27 01:04:04 UTC
Notes from a tester,

"I think this is because the margin for the first section is left = 4.5 cm. Ordinarily the text in the header (which is anchored as a character, as identified by the LibreOffice people, and ordinarily can’t be shifted around) would obey the same margins, but it is centred instead. However the conversion has picked up the section margin."

I don't have Microsoft Office so I can't verify this but it makes sense.
Comment 10 raal 2015-11-18 17:24:44 UTC
This seems to have begun at the below commit.
Adding Cc: to Michael Meeks ; Could you possibly take a look at this one?
 2b816c44ec70b743ef29d091031d1f51c73bb9ad is the first bad commit
commit 2b816c44ec70b743ef29d091031d1f51c73bb9ad
Author: Matthew Francis <mjay.francis@gmail.com>
Date:   Sat Mar 14 22:23:33 2015 +0800

    commit 4771c8836a3e4d5e8ac25a7212293a13fb1e73ba
    Author:     Michael Meeks <michael.meeks@collabora.com>
    AuthorDate: Sat Jun 28 22:59:33 2014 +0100
    Commit:     Michael Meeks <michael.meeks@collabora.com>
    CommitDate: Mon Jun 30 15:36:27 2014 +0100
        writerfilter: use XFastAttributes more efficiently.
        Don't duplicate UTF8 as UCS2 before converting to integers.
        Don't double convert every attribute, and allocate it twice.
        Change-Id: Ibb15d703f011865dac8eb72f18408a5d62b60d96
Comment 11 Michael Meeks 2015-12-02 21:35:56 UTC
Most odd - appears to be fixed in master/5.1 - though in 5.1 we get the header on the 2nd page mis-aligned (which is not present in word FWIW) - and that on the title page is aligned as expected; most curious.

More curious is that there has been no significant changes in the files (of mine) that the identified commit mentions =) very curious; cf.

git log -u libreoffice-5-0-branch-point..master -- writerfilter/source/ooxml/OOXMLFactory.cxx writerfilter/source/ooxml/OOXMLFastContextHandler.cxx writerfilter/source/ooxml/OOXMLPropertySetImpl.hxx

So - I'm a bit stumped really.

Is there any chance of making a very small sample file - ideally with a single page, and a single graphical element to investigate here [ that can also become the unit test file ].

Thanks for all the great bisection work !
Comment 12 raal 2015-12-03 15:39:07 UTC
Created attachment 120997 [details]
simple test case

Simple test file. This is fixed part - bad in 5.0.3, good in master. For unit test.
Comment 13 raal 2015-12-03 15:57:13 UTC
Created attachment 120998 [details]
simple test case

Simple test case - 1st page is OK, 2nd page contains header left justified
Comment 14 Robinson Tryon (qubit) 2015-12-14 00:44:41 UTC Comment hidden (obsolete)
Comment 15 Michael Meeks 2016-09-29 16:30:55 UTC
Seems this was fixed in 5.1+ and 5.0 was end-of-lifed at the end of May, so absent any replication in 5.1 and later - I'll not spend more time hunting the cause & just close it.

Thanks for the report !