Bug 148178 - SVG Export from macro in old version of SVG
Summary: SVG Export from macro in old version of SVG
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
7.2.5.2 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-25 11:04 UTC by AndyG
Modified: 2023-12-07 08:31 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 AndyG 2022-03-25 11:04:16 UTC
Description:
SVG export in LibreOffice Draw uses an older module for export from a macro than for manual export (SVG 1.1 versus 1.2). The older module does not adequately describe shapes made in Draw and exports only the formal draw area rather than the whole page. This behavior is seen both in Windows (11) and Linux (openSUSE) versions.
Why it matters:
Although LibreOffice has an import filter for Visio files, there is no export filter. Transfer to Visio currently relies on SVG 1v.2 files. But manual export of many pages takes much time. A LibreOffice macro can speed it up significantly.
For those who are interested in importing SVG in Visio, I can make SVG import macros available.

Steps to Reproduce:
(A) Start from a LibreOffice Draw page with various drawing objects. Manually export the file to an SVG from the menu: 
File > Export…
In the Export dialog, select SVG and enter a first file name. Press Save.
Open the first saved file in a text editor. Its first three elements will be something like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.2" width="297mm" height="210mm" viewBox="0 0 29700 21000" preserveAspectRatio="xMidYMid" fill-rule="evenodd" stroke-width="28.222" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg" xmlns:ooo="http://xml.openoffice.org/svg/export" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:presentation="http://sun.com/xmlns/staroffice/presentation" xmlns:smil="http://www.w3.org/2001/SMIL20/" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xml:space="preserve">
The <svg> elements has attribute version="1.2"  

(B) Save the same page from a macro.
Open this second saved file in a text editor. Its first three elements will be something like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="280mm" height="175mm" viewBox="0 0 28000 17500" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" stroke-width="28.222" stroke-linejoin="round" xml:space="preserve">

The macro I used for export:

Sub ExportSVGPage
	dim oDoc, oPage, oFilter, i as integer
	dim args(1) as new com.sun.star.beans.PropertyValue
	dim msg as string, filename as string, path as string, c as string

	oDoc = ThisComponent	
	
	path = oDoc.location
	path = replace(path, "%20", " ")
	path = replace(path, "\", "/")
	for i = len(path) to 1 step -1
		c = mid(path, i, 1)
		if c = "/" then
			path = left(path, i)
			exit for
		end if
	next i
	filename = inputbox("Please enter the filename:", "SVG Automated Export", path & "LO examples B.svg")
	if filename = "" then exit sub
	filename = replace(filename, "\", "/")
	
	oPage = oDoc.getcurrentcontroller.getcurrentpage

	oFilter=CreateUnoService("com.sun.star.drawing.GraphicExportFilter")
	oFilter.setSourceDocument(opage)
	args(0).Name = "URL"
	args(0).Value = filename
	args(1).Name = "MediaType"
	args(1).Value = "image/svg+xml"
	oFilter.filter(args())
	
	msg = "Exported " & filename
	msgbox msg
End Sub


Actual Results:
SVG 1.2 when manually exported, SVG1.1 when exported by a macro

Expected Results:
Required behavior:	
Because the way that SVG export in LibreOffice has evolved between versions 1.1 and 1.2, it should always be in SVG version 1.2. Thus, the Uno service com.sun.star.drawing.GraphicExportFilter should use the current module, not the older one.
Why it matters:
Although LibreOffice has an import filter for Visio files, there is no export filter. Transfer to Visio currently relies on SVG 1v.2 files. But manual export of many pages takes much time. A LibreOffice macro can speed it up significantly.
For those who are interested in importing SVG in Visio, I can make SVG import macros available.


Reproducible: Always


User Profile Reset: No


OpenGL enabled: Yes

Additional Info:
If having both SVG1.1 and SVG1.2 export is seen as a feature rather than a bug, a user should be able to choose, both for manual export and for macro export. 

But I suggest focusing on SVG1.2 only and removing the older export filter.
Comment 1 Regina Henschel 2022-09-09 22:52:59 UTC
Are you sure about the used version? The bug 105636.
Comment 2 Buovjaga 2023-02-01 15:11:40 UTC
(In reply to Regina Henschel from comment #1)
> Are you sure about the used version? The bug 105636.

Waiting for comment from Andy.
Comment 3 AndyG 2023-02-02 01:29:57 UTC
I'm using LibreOffice 7.4.4.2 (x64) on Windows 11 (and sometimes on OpenSUSE Leap 15.4).

It is indeed the old version (1.1 instead of 1.2) of SVG when exported from a macro:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="196mm" height="259mm" viewBox="0 0 19600 25900" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" stroke-width="28.222" stroke-linejoin="round" xml:space="preserve">

The rest of the file is also quite different than when exported manually.
Comment 4 QA Administrators 2023-02-02 03:20:25 UTC Comment hidden (obsolete)
Comment 5 Buovjaga 2023-02-02 08:01:11 UTC
Andy: Regina was referring to the manual export, which reports a DOCTYPE of 1.1 and falsely has 1.2 for the <svg> element.

I tested your macro, I gave it a path to the file to export (on Linux), but the file does not appear in the path.