https://bugs.documentfoundation.org/show_bug.cgi?id=148178

            Bug ID: 148178
           Summary: SVG Export from macro in old version of SVG
           Product: LibreOffice
           Version: 7.2.5.2 release
          Hardware: x86-64 (AMD64)
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: Draw
          Assignee: libreoffice-bugs@lists.freedesktop.org
          Reporter: andygp...@gmail.com

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to