Bug 134326 - Text Grid should accept floating point font-size for base text and ruby
Summary: Text Grid should accept floating point font-size for base text and ruby
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.1.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.1.0 target:7.0.0.1
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-26 16:14 UTC by himajin100000
Modified: 2020-06-28 20:12 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description himajin100000 2020-06-26 16:14:03 UTC
Description:
see steps to reproduce.

Steps to Reproduce:
Preparation steps:

1. Run LibreOffice
2. Tools->Options
3. Language Settings->Languages
4. Make sure "Asian" checkbox under "Default Languages for Documents " is checked.
I also set the Language to "Japanese", but this may not be necessary.
5. Apply
6. Quit LibreOffice
7. Run Writer
8. Tools->Options
9. LibreOffice Writer->General
10. check "Use square page mode for text grid" under Settings. Also, note that font-size is in points, whatever measurement unit is set.
11. Apply
12. Restart LibreOffice

Main Steps:

1. Run Writer
2. (for comparison) In the "Formatting" toolbar, you will find a FontSizeBox(COMBOBOX, not a spinbutton), and there you will find 10.5 pt.
This font-size is said to be used by Japanese government's official documents.

https://opengrok.libreoffice.org/xref/core/svtools/source/control/ctrltool.cxx?r=d077cd61#45
https://opengrok.libreoffice.org/xref/core/svtools/source/control/ctrlbox.cxx?r=fcce0642#962

3. Format ( in Main menu) -> Page Style
4. you will find "Text Grid" tab
5.  In the "Grid" section,  click "Grid (lines and characters)".  "Grid Layout" section will be enabled.
6. In the "Grid Layout" section,  you will find "Max. base text size." MetricSpinButton.
7. Input 10.5pt to the MetricSpinButton.
8. Leave the control(e.g. with Tab key) so that we can notify the program of completion of our text input to the spinbutton. 

Actual Results:
The spinbutton's value changes to 11pt.
Previews, Max characters per line, Max lines per page are calculated based on this 11pt.

Expected Results:
MetricSpinButtons hold floating point values. In this case, 10.5pt.


Reproducible: Always


User Profile Reset: No



Additional Info:
My guess( but just a guess ):

MetricSpinButton holds a floating point length, for example, 100.405 cm (= 100405 * 10^(-3) cm ), with an integer member variable( = 100405), a member variable for the decimal digits(= 3) , and the measurement unit(= "cm").

When we change its unit from its initial unit through e.g. SetFieldUnit, the decimal digits will be set based on the new unit. 
https://opengrok.libreoffice.org/xref/core/svtools/source/misc/unitconv.cxx?r=ec11b733#25 
Also, please note that MetricSpinButton constructor doesn't seem to call this function.

I guess, the MetricSpinButton's unit hasn't changed since its initial value, 0. (not that sure) 
https://opengrok.libreoffice.org/xref/core/vcl/source/app/salvtables.cxx?r=01e37e3e#5272
https://opengrok.libreoffice.org/xref/core/vcl/source/control/fmtfield.cxx?r=01e37e3e#657
https://opengrok.libreoffice.org/xref/core/svl/source/numbers/zformat.cxx?r=1861363d#221

I have one more concern.

when we call a method to try to get 100.405 in the example case,  the control tries to caluculate 100405 / 10^3.
https://opengrok.libreoffice.org/xref/core/vcl/source/window/builder.cxx?r=7e4a3eee#240
but the return value seems to be of int type, not floating point type like double.

This value is set to  SwTextGridItem::SetBaseHeight(int), yes this also take an integer parameter, and this value seems to be used for layouting I guess.
https://opengrok.libreoffice.org/xref/core/sw/source/ui/misc/pggrid.cxx?r=eaeabd78#229

==================
Version: 7.1.0.0.alpha0+ (x64)
Build ID: 642fc41cd7d080384658e10b30bb9d3b38a2cbd9
CPU threads: 4; OS: Windows 10.0 Build 18363; UI render: default; VCL: win
Locale: ja-JP (ja_JP); UI: en-US
Calc: CL
Comment 1 himajin100000 2020-06-26 18:08:02 UTC
>I have one more concern.

On the second thought, I'm now thinking I don't need to worry about this, because I'm getting the metric value in TWIP unit.
Comment 2 Caolán McNamara 2020-06-27 16:02:24 UTC
There's a lot of text here to begin to parse. Is this a regression from some known state ? Or did it never do what you want it to do ?
Comment 3 himajin100000 2020-06-27 16:11:51 UTC
> There's a lot of text here to begin to parse. Is this a regression from some
> known state ? Or did it never do what you want it to do ?

I HEARD from other Japanese community member that previously at some point,Writer showed the expected behavior and current master doesn't.(so, It's a regression)

I just tested with current master behaving in the unexpected way.but I still haven't tried bibisection to figure out from which version the unexpected behavior started to occur.

I added you to CC list because I noticed you submitted a spin button related patch https://gerrit.libreoffice.org/c/core/+/97217 (not MetricSpinButton related, though)  and I thought you have a good knowledge on this matter.
Comment 4 Caolán McNamara 2020-06-27 18:55:33 UTC
seems to be a regression, possibly since...

    commit 1f622157d10b15c7d9496e3887f493de0f0f94c8
    Date:   Sun Apr 7 18:04:11 2013 -0300
    
        Convert Writer asian text grid page to Widget UI

https://gerrit.libreoffice.org/c/core/+/97327 might be sufficient to solve this
Comment 5 Commit Notification 2020-06-27 19:49:19 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4c26e797aa7ed1c136b63008727d6c97d7bfb9cf

tdf#134326 allow 2 decimal places for asian grid point sizes

It will be available in 7.1.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2020-06-28 19:41:46 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-7-0":

https://git.libreoffice.org/core/commit/e9af6eec4a4e5c715c1792fdb6254cccc919e22e

tdf#134326 allow 2 decimal places for asian grid point sizes

It will be available in 7.0.0.1.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Caolán McNamara 2020-06-28 20:10:02 UTC
I wonder if that is sufficient to consider this solved ?
Comment 8 himajin100000 2020-06-28 20:11:47 UTC
Yes, Thank you Caolan for your good work. (Actually I was waiting for community's input)