[Libreoffice-bugs] [Bug 130104] XLSX: cell indent ("stylesheet -> cellXfs -> xf -> alignment: indent") is increased by 3 times upon FILEOPEN, and thus resulted in wrong indent attribute upon FILESAVE (see comment 13)

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Thu Jul 1 08:29:56 UTC 2021


https://bugs.documentfoundation.org/show_bug.cgi?id=130104

--- Comment #17 from Kevin Suo <suokunlong at 126.com> ---
My bad...

It was not FILEOPEN, it is FILESAVE.

On XLSX import the indent is correctly detected (as integer value such as "1"),
and is converted to a value which is 3 times the width of space in 100mm (such
as 528), in
https://opengrok.libreoffice.org/xref/core/sc/source/filter/oox/stylesbuffer.cxx?r=9964531f#1186
> sal_Int32 nIndent = getUnitConverter().scaleToMm100( 3.0 * maModel.mnIndent, Unit::Space );

However, when you now save the document, the width value in 100mm unit is then
converted to the following:
https://opengrok.libreoffice.org/xref/core/sc/source/filter/excel/xestyle.cxx?r=b8cfea65#1461
> nTmpIndent = (nTmpIndent + 100) / 200;
The comment in this line says "1 Excel unit == 10 pt == 200 twips", so this
100mm unit value is treated as pt and converted to twips. The problem is that
in xlsx file the indent value should be an integer number such, of which "1"
means 3 space width, as correctly used in
sc/source/filter/oox/stylesbuffer.cxx:1186.

So the solution would be convert back the 100mm unit value to int value, which
is a reverse operation of the import calculation. I see there is
UnitConverter::scaleFromMm100 function in 
https://opengrok.libreoffice.org/s?refs=scaleFromMm100&project=core
which can do this.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20210701/5834177f/attachment-0001.htm>


More information about the Libreoffice-bugs mailing list