diff options
author | Kevin Suo <suokunlong@126.com> | 2021-10-04 23:11:30 +0800 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-10-08 08:01:01 +0200 |
commit | 6b93ee72df1aa42d1a3482ffc396bd0c23134f8b (patch) | |
tree | 006354fcf77732190deedd754b4e8022f9b613dc /codemaker/test | |
parent | 2ad7e095078e09bc27608d5b1fedb8809656abbe (diff) |
tdf#130104 - FILESAVE XLSX: cell indent increased on each save
In OOXML, 1 indent = 3 space char width.
-----
The Old Method:
-----
XLSX Import:
As per the line:
sal_Int32 nIndent = getUnitConverter().scaleToMm100( 3.0 * maModel.mnIndent, Unit::Space );
assume the width of space char is 88, then:
If the OOXML indent is 1, then nIndent would be 264.5, and casted to 264.
If the OOXML indent is 2, then nIndent would be 528.5, and casted to 528.
If the OOXML indent is 3, then nIndent would be 792.5, and casted to 792.
...
Also, as Mike Kaganski has pointed out, we use twips in sc indent internally, thus it is wrong to convert to Mm100 unit here.
XLSX Export:
As per the line:
nTmpIndent = (nTmpIndent + 100) / 200;
Assume we did not edit the document upon open, and simply save it. Now:
If our indent is 264, then the calculated OOXML indent would be 1.82, and then casted to 1, while the expected value is 1.
If our indent is 528, then the calculated OOXML indent would be 3.14, and then casted to 3, while the expected value is 2.
If our indent is 792, then the calculated OOXML indent would be 4.46, and then casted to 4, while the expected value is 3.
...
Then if you reopen the saved xlsx file with Calc, the increament of indent continues on each save which causes serious
format loss.
Most importantly, if you change the indent of cells using the Calc toolbar indent icon, one-click would be 10pt = 200 twips,
see defined macro SC_INDENT_STEP. This causes a mess when you change the indent in an xlsx document.
-----
The New Method
-----
In this patch, I have changed the XLSX import to convert the excel indent unit to 3-spaces-width *in twips*.
Then, per code advice from Mike Kaganski, as a mirror operation, I have changed the XLSX export logic to detect the width
of the space char (which *should* be the same as the one detected at the time of xlsx import), and use this width to convert
the indent in twips unit to excel unit. This way, the indent will remain the same on xlsx export.
-----
TODO:
-----
1. On xlsx import of the file tdf130104_indent.xlsx, the default font (i.e. font for the "Normal" style) is "Times New Roman".
However, when the UI locale is set to Simplified Chinese and "Asian" option is enabled in Tools->Options->Language Settigns->
Languages->"Default Languages for Documents", upon resave as xlsx, the default font for the document is changed to "Noto Sans CJK SC"
on my system, which causes the space-width detected to be different from the width detected on xlsx import. This seems to be another
bug, see tdf#131349. (Luckily the unit test in this patch passes, this is because the change of space width resulted from the change
in default font is very small thus the conversion is not impacted.)
2. The UI part need to be improved, so that after xlsx import, if the user hit the "Increase Indent" or "Decrease Indent" toolar
icon to change the indent, Calc should be able to detect that we are operating in an xlsx file, thus the "increment" should
be 3 * width of space char, rather than the current SC_INDENT_STEP. Also, the if the user changes the default font of the xlsx
document, the Calc should recalculate the indent for each cell to reflect the possible change in width of space char.
Change-Id: I5f7a4ecbcd93079d1c19db3b0b641dda949f6fbf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123111
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'codemaker/test')
0 files changed, 0 insertions, 0 deletions