Bug 148182

Summary: Page number and page count mess up in exported SVG
Product: LibreOffice Reporter: AndyG <andygp999>
Component: DrawAssignee: Not Assigned <libreoffice-bugs>
Status: NEW ---    
Severity: normal CC: aron.budea, ilmari.lauhakangas, mrcekets
Priority: medium Keywords: bibisected, bisected, regression
Version: 7.2.0.0.alpha0+   
Hardware: All   
OS: All   
Whiteboard:
Crash report or crash signature: Regression By: Marco Cecchetti
Bug Depends on:    
Bug Blocks: 111450    
Attachments: Example file

Description AndyG 2022-03-25 11:32:58 UTC
Description:
The page number and page count fields really screw up export to SVG of a LibreOffice Draw page, especially the page count field. 

Steps to Reproduce:
Create a new LibreOffice Draw document. Do not insert any elements or text fields. Instead, directly insert a page count field (menu: Insert > Field > Page Count). Click somewhere in the page to deselect the inserted item, and insert a page number field (menu: Insert > Page Number). Add a page (menu: Page > New Page). Insert a text box, and in the text box type: "Some words, page ", then insert the page number (menu: Insert > Page Number), then type " of total " and insert the page count (menu: Insert > Field > Page Count). Make sure the text box is wide enough that everything fits on one line. Add a third page. On this page, create two text boxes. In the first, type "Page " and then insert the page number field. In the second text box, type "Page count " and the insert the page count field. Export all three pages to SVG. Open them in a text editor to verify that they're saved as SVG 1.2 (search for '<svg version="1.2"').
All three exported pages list numbers instead of fields. That is OK, of course. The page count field is identified with the attribute class="PageCount" (great). The page number field is not identified so. Instead, it has the attribute class="PlaceholderText" (not helpful). This should be class="PageNumber".
The middle page, though looks horrific. The text that should have been "Some words, page 2 of total 3" now reads "Some words, page 333". Both the page number field and the text " of total " have been replaced by the page count. In the SVG, there are three successive identical entries 
<tspan fill="rgb(0,0,0)" stroke="none" class="PageCount">3</tspan>
It gets worse. In LibreOffice, go to the master page (menu: View > Master Page) and insert a text box. In it, type "Page ", insert the page number field (it will show as <number>), then type " of " and insert the page count field (it will show as <count>). Close the master view. The text shows as it should, for example "Page 2 of 3" on the second page. Now export to SVG. Open the SVG with a text editor and search for class="BackgroundObjects". The exported text box looks like this (skipping TextParagraph and TextPosition):
<tspan fill="rgb(0,0,0)" stroke="none">Page </tspan>
<tspan class="PlaceholderText" fill="rgb(0,0,0)" stroke="none">&lt;number&gt;</tspan>
<tspan fill="rgb(0,0,0)" stroke="none"> of </tspan>
<tspan fill="rgb(0,0,0)" stroke="none" class="PageCount">3</tspan>

Whereas the page count is exported correctly, the page number is exported as "&lt;number&gt"

Actual Results:
The SVG contains numbers that are meaningless, or not representative of the element

Expected Results:
(1) The <tspan> element that holds the page number field should always be exported with the attribute class="PageNumber".
(2) In a text box that has a line with multiple fields, each field should be identified correctly, and they should not be overwritten with the page count. Certainly, parts of text should not be overwritten by the page count.
(3) The page number field, in master view, should not be exported as
<tspan class="PlaceholderText" fill="rgb(0,0,0)" stroke="none">&lt;number&gt;</tspan>
but as
<tspan fill="rgb(0,0,0)" stroke="none" class="PageNumber">0</tspan>

Why it matters:	Correct export will make a document look good in SVG editors, and will also make it possible to re-import in other drawing editors, such as Visio. (I'll make Visio import macros available for interested parties).


Reproducible: Always


User Profile Reset: No


OpenGL enabled: Yes

Additional Info:
xxx
Comment 1 Buovjaga 2023-01-03 11:39:18 UTC
Created attachment 184459 [details]
Example file
Comment 2 Buovjaga 2023-01-03 11:59:03 UTC
(In reply to AndyG from comment #0)
> The middle page, though looks horrific. The text that should have been "Some
> words, page 2 of total 3" now reads "Some words, page 333". Both the page
> number field and the text " of total " have been replaced by the page count.

Bibisected with linux-64-7.2 to https://git.libreoffice.org/core/commit/cc5becc37dc4828e09f4d2f2af48b8482f7efaa3
impress: <count> variable not substituted in presentation on slideshow