Bug 145987 - Writer typesets identically defined automatic and custom graphic-styles differently
Summary: Writer typesets identically defined automatic and custom graphic-styles diffe...
Status: NEEDINFO
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.2.2.2 release
Hardware: All Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Writer-Styles-Frame
  Show dependency treegraph
 
Reported: 2021-12-01 11:43 UTC by Jambunathan K
Modified: 2024-04-14 12:26 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Test file. Contains detailed descrption of the problem (13.13 KB, application/vnd.oasis.opendocument.text)
2021-12-01 11:43 UTC, Jambunathan K
Details
grouped.png: Screenshot of the "problematic" shapes (117.22 KB, image/png)
2021-12-01 11:44 UTC, Jambunathan K
Details
grouped.pdf: `grouped.odt' exported to PDF by LibreOffice (128.70 KB, application/pdf)
2021-12-01 11:46 UTC, Jambunathan K
Details
grouped-after-save.odt: `grouped.odt' after doing File -> Save (19.69 KB, application/vnd.oasis.opendocument.text)
2021-12-01 11:52 UTC, Jambunathan K
Details
This zip file contains all artifacts creating during the reproduction of this bug. (183.85 KB, application/zip)
2022-06-17 07:36 UTC, Jambunathan K
Details
bug145987-README.odt: Steps to repoduce the bug, in odt format (32.78 KB, application/vnd.oasis.opendocument.text)
2022-06-17 07:38 UTC, Jambunathan K
Details
bug145987-3.png: Quick overview of what the bug is about (43.62 KB, image/png)
2022-06-17 07:39 UTC, Jambunathan K
Details
bug145987-June26.zip: Zip file where the `odg` shape is selectable in Draw (25.84 KB, application/zip)
2022-06-26 02:16 UTC, Jambunathan K
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jambunathan K 2021-12-01 11:43:01 UTC
Created attachment 176618 [details]
Test file.  Contains detailed descrption of the problem

LibreOffice typesets /identically defined/ automatic and custom
`grahic'-styles differently

Please `unzip' this file, and examine `styles.xml' and `content.xml'
therein.

`OrgShape'
      A custom style defined in `styles.xml'
`OrgShape1'
      An automatic style defined in `content.xml'

Note that both the `OrgShape' and `OrgShape1' have /*the exact same
specification*/.

The shape below uses the custom style `OrgShape'

Laborum officia ullamco labore esse cupidatat non tempor irure magna
sint adipiscing ex qui ad ut.  Adipiscing id labore cillum sunt anim
dolor ad aliqua adipiscing sit esse tempor reprehenderit minim pariatur.

The shape below uses the automatic style `OrgShape1'

Laborum officia ullamco labore esse cupidatat non tempor irure magna
sint adipiscing ex qui ad ut.  Adipiscing id labore cillum sunt anim
dolor ad aliqua adipiscing sit esse tempor reprehenderit minim pariatur.

*Problems Obverved*

1. The `style:wrap="none"' is /*not*/ honored in the first shape.
2. The first shape is /*not*/ centered vertically and horizontally
   within it's parent paragraph, while the second shape is centered
   within it's parent paragraph.
3. The text within the first shape in /*not*/ padded, but that within
   the second shape is padded.

*Expected Behaviour*

The first shape should be typeset /*exactly same*/ as the second
shape. i.e., *Why does LibreOffice typeset styles that are /defined
identically/ but /defined in different places/ very /differently/?  I
expect a /consistent/ behaviour!*

*Desired Behaviour*

When I save the file, LibreOffice removes the
`style:horizontal-pos="center"', `style:horizontal-rel="paragraph"',
`style:vertical-pos="top"' and `style:vertical-rel="paragraph"' and
replaces it with absolute positions `svg:x="xxcm"' and `svg:y="yycm"'.
I would prefer that it retains and honors the parapraph-relative
positions.

*Context*

This bug is identified while trying to produce a `Google
Documents'-compatible ODT file using LibreOffice.  See [A simple
document with a captioned image (produced in LibreOffice by hand) isn't
displayed properly when uploaded to Google Docs] for a detailed report.

*LibreOffice Used*

┌────
│ $ uname -a
│ Linux debian 5.14.0-4-amd64 #1 SMP Debian 5.14.16-1 (2021-11-03) x86_64 GNU/Linux
└────

┌────
│ $ dpkg -l | grep writer
│ ii  libreoffice-writer 1:7.2.2-1 amd64 office productivity suite -- word processor
└────

┌────
│ Version: 7.2.2.2 / LibreOffice Community
│ Build ID: 20(Build:2)
│ CPU threads: 4; OS: Linux 5.14; UI render: default; VCL: x11
│ Locale: en-IN (en_IN.UTF-8); UI: en-US
│ Debian package version: 1:7.2.2-1
│ Calc: threaded
└────


[A simple document with a captioned image (produced in LibreOffice by
hand) isn't displayed properly when uploaded to Google Docs]
<https://github.com/kjambunathan/org-mode-ox-odt/issues/136>
Comment 1 Jambunathan K 2021-12-01 11:44:04 UTC
Created attachment 176619 [details]
grouped.png: Screenshot of the "problematic" shapes
Comment 2 Jambunathan K 2021-12-01 11:46:42 UTC
Created attachment 176620 [details]
grouped.pdf: `grouped.odt' exported to PDF by LibreOffice
Comment 3 Jambunathan K 2021-12-01 11:52:35 UTC
Created attachment 176621 [details]
grouped-after-save.odt: `grouped.odt' after doing File -> Save

Note that `paragraph'-relative shape positions gets replaced with equivalent absolute positions.

I want LibreOffice to preserve and honor the relative positions.

FWIW, Google Docs creates a captioned image as an image and a custom shape grouped together.  Google Docs doesn't render the LibreOffice produced captioned images correctly.  (Google Docs not rendering the LibreOffice-produced document is *not* a LibreOffice issue).  So, I wanted to create captioned images just the way Google Docs expect it.  When trying to produce such a Google-compatible document, I ran in to this issue. For more details see https://github.com/kjambunathan/org-mode-ox-odt/issues/136.
Comment 4 Jambunathan K 2021-12-01 11:56:30 UTC
(In reply to Jambunathan K from comment #3)
> Created attachment 176621 [details]
> grouped-after-save.odt: `grouped.odt' after doing File -> Save
> 
> Note that `paragraph'-relative shape positions gets replaced with equivalent
> absolute positions.
> 
> I want LibreOffice to preserve and honor the relative positions.
> 
> FWIW, Google Docs creates a captioned image as an image and a custom shape
> grouped together.  Google Docs doesn't render the LibreOffice produced
> captioned images correctly.  (Google Docs not rendering the
> LibreOffice-produced document is *not* a LibreOffice issue).  So, I wanted
> to create captioned images just the way Google Docs expect it.  When trying
> to produce such a Google-compatible document, I ran in to this issue. For
> more details see https://github.com/kjambunathan/org-mode-ox-odt/issues/136.

This is the ultimate goal.  This bug is only a step 1 in reaching the goal.  If this bug gets some traction and gets fixed, then I may (or may not) have a followup bug.

[A Simple Captioned Image as produced by Google Docs.odt](https://github.com/kjambunathan/org-mode-ox-odt/files/7594408/A.Simple.Captioned.Image.as.produced.by.Google.Docs.odt)
Comment 5 Jambunathan K 2021-12-01 12:03:23 UTC
(In reply to Jambunathan K from comment #3)
> Created attachment 176621 [details]

> FWIW, Google Docs creates a captioned image as an image and a custom shape
> grouped together.

FWIW, this is how one produces captioned images in Google Docs  [How to Add Captions to Images in Google Docs](https://www.howtogeek.com/725451/how-to-add-captions-to-images-in-google-docs/)
Comment 6 Dieter 2021-12-17 15:53:08 UTC
I can see the difference but I'm not familiar enough with the topic to assess, what is the expected result. And I also don't understand how to define a certain style for a shape. So how did you create those shapes, that look like frames?
Comment 7 Jambunathan K 2021-12-18 01:24:26 UTC
(In reply to Dieter from comment #6)

> I can see the difference but I'm not familiar enough with the topic to
> assess, what is the expected result. And I also don't understand how to
> define a certain style for a shape. So how did you create those shapes, that
> look like frames?

In LibreOffice Draw, I created the shape.  Then I copy+pasted that to my ODT document.  Then I moved around the XML a bit.  The XML you see in the file are legitimate XML generated by LibreOffice, and edits if any are "minor" or "minimal".  

Btw, you need to copy+paste the drawing from LibreOffice Draw UI, as opposed to inserting the Draw file in to LibreOffice writer.  Copy+pasting with clipboard will only copy over the shape with relevant parameters, but inserting a draw object will also copy over the page size of the draw object.
Comment 8 Dieter 2021-12-18 14:08:07 UTC
(In reply to Jambunathan K from comment #7)
Thnak you for further inforations. After creating the two shapes in Draw, do they work as expected? If "Yes" please add the document from DRAW and some steps to reproduce it in Writer. If "No", this is a problem in Draw and you should describe some steps to reproduce it there.
=> NEEDINFO
Comment 9 QA Administrators 2022-06-17 03:33:47 UTC Comment hidden (obsolete)
Comment 10 Jambunathan K 2022-06-17 07:36:52 UTC
Created attachment 180804 [details]
This zip file contains all artifacts creating during the reproduction of this bug.

This zip file contains all artifacts creating during the reproduction of this bug. 

I am reproducing the bug145987-README.org here and attaching bug145987-README.odt, and bug145987-3.png for convenience.  

#+title: Bug 145987: Writer typesets identically defined automatic and custom graphic-styles differently 

#+odt_prettify_xml: ""

* Create =bug145987-1.odt=

   1. Open =bug145987.odg=
   2. In this step, we copy the above shape to an empty =odt= file,
      and change some shape attributes:

      - In the =odg= file, do =C-a=, =C-c=

      - Open an empty =bug145987-1.odt=, and =C-v= the shape

      - Change the properties of pasted shape as below:
         - =Wrap None=

         - Right Click, =Position and Size= and change horizontal
           positioning to =Horizontal Center to Paragraph Area=

* Create =bug145987-1.odt=

   1. Open a shell and do

      =cp bug145987-1.odt bug145987-2.odt=

   2. In this step we will modify =content.xml= of =bug145987-2.odt= as
      below:

      1. =unzip bug145987-2.odt=.

      2. In =content.xml=, locate =draw:custom-shape=.

         Note that it has following attributes

         - ~draw:style-name="gr1"~

         - ~svg:x="7.001cm" svg:y="0cm"~

         Now,

         - _globally_ string replace ="gr1"= to ="OrgShape2"=.  (We do
           global / file-wise replacement, because we want the
           automatic style named =gr1= to be renamed too.)

         - strip the =svg:x= and =svg:y= attributes.

      3. Save edits to =content.xml=, and =zip= up the =bug145987-2.odt=.

      4. Open the file =bug145987-2.odt= in LibreOffice and make sure
         that it is rendered identical to =bug145987-1.odt=.

         (*_Note_*: /Do NOT save =bug145987-2.odt= from within
         LibreOffice.  We do NOT want LibreOffice to re-write XML./)

* Create =bug145987-3.odt=

   1. Open a bash shell and do

      =cp bug145987-2.odt bug145987-3.odt=

   2.

      #+ATTR_ODT: :style "Text_20_body_20_bold"
      In this step you will replicate the paragraph that holds
      =draw:custom-shape= and also it's associated style.  Note that
      the style is replicated from =content.xml= to =styles.xml= and
      is now /a custom style/ as opposed to /an automatic style/.

      1. =unzip bug145987-3.odt=.

      2. Open =content.xml= and replicate the paragraph holding
         =draw:custom-shape=.

         Change the attributes of the replicated shape as below:

         - Change =draw:name= from ="OrgShape2= to ="OrgShape3"=.

         - Change =draw:style-name= from ="OrgShape2"= to ="OrgShape3"=.

         - Copy the definition of ="OrgShape2"= _automatic style_ from
          =content.xml=, move over to =styles.xml= and append it to
          =office:styles=.  Rename the style to ="OrgShape3"=.

      3. =zip= up =bug145987-3.odt= with above edits.

      4. Open the =bug145987-3.odt=.

         - Expected :: The replicated paragraph / custom shape should
           be rendered identically to the original paragraph / custom
           shape.

         - Observed ::  See the screenshot of =bug145987-3.png=.

           The observed behaviour is not along the expected lines.  It
           seems like a bug (unless there is an explanation for the
           difference)
Comment 11 Jambunathan K 2022-06-17 07:38:05 UTC
Created attachment 180805 [details]
bug145987-README.odt:  Steps to repoduce the bug, in odt format
Comment 12 Jambunathan K 2022-06-17 07:39:00 UTC
Created attachment 180806 [details]
bug145987-3.png: Quick overview of what the bug is about
Comment 13 Jambunathan K 2022-06-17 07:41:48 UTC
(In reply to Dieter from comment #8)
> (In reply to Jambunathan K from comment #7)
> Thnak you for further inforations. After creating the two shapes in Draw, do
> they work as expected? If "Yes" please add the document from DRAW and some
> steps to reproduce it in Writer. If "No", this is a problem in Draw and you
> should describe some steps to reproduce it there.
> => NEEDINFO

I have provided the needed information starting from this comment https://bugs.documentfoundation.org/show_bug.cgi?id=145987#c10. 

My gut feeling is that this is a Writer issue.
Comment 14 Jambunathan K 2022-06-17 07:44:09 UTC
Revised instructions are for 

Version: 7.3.4.1 / LibreOffice Community
Build ID: 30(Build:1)
CPU threads: 4; OS: Linux 5.17; UI render: default; VCL: x11
Locale: en-IN (en_IN); UI: en-US
Debian package version: 1:7.3.4~rc1-1
Calc: threaded
Comment 15 Dieter 2022-06-18 08:43:52 UTC
Thank you for detailed description. But I still think, there might be a problem with that shape from Draw. I don't get a context menu in Writer and also not in Draw (LO immediately deselect shape if I click for context menu). If I open shape properties in sidebar, there is a fill colour and a line, but I can't see them. If I create a shape in Draw (text frame, rectangle or whatever) on my own, I always have access to context menu.
Comment 16 Jambunathan K 2022-06-26 02:16:12 UTC
Created attachment 180966 [details]
bug145987-June26.zip:  Zip file where the `odg` shape is selectable in Draw
Comment 17 Jambunathan K 2022-06-26 02:23:59 UTC
(In reply to Dieter from comment #15)
> Thank you for detailed description. But I still think, there might be a
> problem with that shape from Draw. I don't get a context menu in Writer and
> also not in Draw (LO immediately deselect shape if I click for context
> menu). If I open shape properties in sidebar, there is a fill colour and a
> line, but I can't see them. If I create a shape in Draw (text frame,
> rectangle or whatever) on my own, I always have access to context menu.

I have created a new attachment (https://bugs.documentfoundation.org/attachment.cgi?id=180966) where the shape is selectable in LibreOffice Draw.  That is, you can see the shape properties in the styles area, or right click and manipulate shape properties.  The `odt` file in the attachment is created in the exact same manner as outlined in https://bugs.documentfoundation.org/attachment.cgi?id=180805.  For conciseness, I am not re-attaching the steps.

Even with a selectable `odg` shape, the `odt` file is not along expected lines.
Comment 18 Dieter 2024-04-14 12:26:24 UTC
Jambunathan, ist the problem still present in master or in LO 24.2.2.? If this is the case, I will again try to repriduce it.
=> NEEDINFO