Bug 149269 - For objects anchored "To character", LO uses the character immediately to the left of anchor character when Vertical position is to "Character", but it should use the anchor character
Summary: For objects anchored "To character", LO uses the character immediately to the...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.4.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL: https://docs.oasis-open.org/office/Op...
Whiteboard:
Keywords:
Depends on:
Blocks: Anchor-and-Text-Wrap
  Show dependency treegraph
 
Reported: 2022-05-24 18:00 UTC by Regina Henschel
Modified: 2023-05-13 11:00 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Shapes anchored "to character" vertical positioned "to character" (25.91 KB, application/vnd.oasis.opendocument.text)
2022-05-24 18:00 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2022-05-24 18:00:38 UTC
Created attachment 180349 [details]
Shapes anchored "to character" vertical positioned "to character"

ODF 1.3 defines that the anchor is "The character after the drawing shape element." in section 19.759 text:anchor-type. Thereby not the visual appearance but the position in the file markup is meant.

The attached document "Anchor character is tall before shape.odt" has two rectangles with position "top" and "bottom" respectively. You see, that the vertical position corresponds to the character "|", which has a font size 96pt.

When you open the content.xml of the file in editor, then you see, that the character "|" is before the rectangles.

I think, that the reference area for the vertical position should not be the character before the object but the anchor character, and that has to be the character after the object.

If you drag the anchor one character to the left or right, you see that the reference area for the vertical position changes, which means, that in case of "to character" really a character area is used, in contrast to "to Line of Text" where the entire line area is used as reference area for vertical position.
Comment 1 sdc.blanco 2022-05-25 15:27:10 UTC
(In reply to Regina Henschel from comment #0)
Restating -- to be sure....

Using: 
1. "to character" anchor
2.  with "Vertical" positioning "to" "Character"

I understand that ODF is referring to file contents not appearance, but I think your descriptions here are from the user POV. (not a problem, because the description is clear, just confirming what is being described).

> reference area for the vertical position should not be the
> character before the object
in UI: reference area ... should not be character before the anchor position.

> but the anchor character, and that has to be the character after the object.
but the implementation should use the character immediately after the character where the anchor appears.

For example:  40 40 40 96 96 40 40

(each number indicates a character and its pt. size)

1. Place anchor on first 96.

Actual:  vertical positioning uses 40
Expected: uses 96

2. Place anchor on second 96

Actual: vertical positioning uses 96
Expected:  uses 40

(Example tested using attachment 180349 [details], and adding a 96 pt character)

Version: 7.4.0.0.alpha1+ (x64) / LibreOffice Community
Build ID: 09822cf77cdbe32b03553cd05154100b5f2591d0
CPU threads: 8; OS: Windows 10.0 Build 19043; UI render: default; VCL: win
Locale: da-DK (da_DK); UI: en-US
Calc: threaded


> When you open the content.xml of the file in editor, then you see, that the
> character "|" is before the rectangles.
Confirm. In this case, both draw:rect are after "|"  (which is used as anchor)

According to section 19.759, for text:anchor-type:char

    The drawing shape element shall be located in file text…Just before the character. 


Additional test:  

1. Add a second 96 pt. character next to the one in the attachment.
2. Move the anchor for the lower red rectangle to another character (I used "d" at the start of the line).
3. Put the anchor for the upper red rectangle on the second 96 pt. character
4. Inspect the content.xml

Actual and expected:  The draw:rect is BEFORE the anchor character.

=> NEEDINFO  

1. Can you repro "Additional test"?
2. If so, maybe problem is related to >1 anchor per character?
Comment 2 sdc.blanco 2022-05-25 16:23:25 UTC
Should also have mentioned....

Even though the content.xml of the "Additional test" looks correct according to ODF 1.3, the appearance to the user is still as in the original test: the area of the character before the anchor location is used to position the rectangle.
Comment 3 Regina Henschel 2022-06-13 14:12:08 UTC
(In reply to sdc.blanco from comment #1)
> 1. Add a second 96 pt. character next to the one in the attachment.
> 2. Move the anchor for the lower red rectangle to another character (I used
> "d" at the start of the line).
> 3. Put the anchor for the upper red rectangle on the second 96 pt. character
> 4. Inspect the content.xml
> 
> Actual and expected:  The draw:rect is BEFORE the anchor character.

Yes.

> 
> => NEEDINFO  
> 
> 1. Can you repro "Additional test"?
> 2. If so, maybe problem is related to >1 anchor per character?

I do not understand, what this "Additional test" should show. The problem is, that not the anchor character, but the character left from the anchor character is used for calculating the position.
Comment 4 sdc.blanco 2022-06-14 06:05:29 UTC
(In reply to Regina Henschel from comment #3)
> The problem is, that not the anchor character, but the character left
> from the anchor character is used for calculating the position.
I can confirm this.  Have changed Bug summary to make the issue more salient, but please check that the description is accurate.
Comment 5 sdc.blanco 2022-06-14 06:14:55 UTC
(In reply to Regina Henschel from comment #3)
> I do not understand, what this "Additional test" should show. 
Is there some relation between the contents of contents.xml and the character used for positioning?  If not, then the "Additional test" may not be so relevant.

Fwiw, the issue arose because in comment 0:
> When you open the content.xml of the file in editor, then you see, that the
> character "|" is before the rectangles.
The "Additional test" shows a case where the "|" is after the rectangle.

(but still positions in relation to the character to the "immediate left" of the anchor character.)