Relative URL in a dialog

Discussions about using 3rd party extension with

Relative URL in a dialog

Postby Lucrecia » Fri Nov 03, 2017 9:52 pm

My dialog has 2 buttons with images and they are saved in the folder "images" of my extension.
In my pc the dialog shows the two images in their respective buttons but when executing the extension in another pc the images are lost.
Please can you tell me how to change the absolute reference of the image so that my extension works well on other PCs.

Code: Select all   Expand viewCollapse view
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dlg:window PUBLIC "-// OfficeDocument 1.0//EN" "dialog.dtd">
<dlg:window xmlns:dlg="" xmlns:script="" dlg:id="Dialog1" dlg:left="159" dlg:top="91" dlg:width="80" dlg:height="53" dlg:help-text="&amp;0.Dialog1.HelpText" dlg:closeable="true" dlg:moveable="true" dlg:title="&amp;1.Dialog1.Title">

     <dlg:button dlg:id="CommandButton1" dlg:tab-index="0" dlg:left="8" dlg:top="3" dlg:width="28" dlg:height="28" dlg:value="&amp;15.Dialog1.CommandButton1.Label" dlg:image-src="file:///C:/Users/Lucrecia/Desktop/plug%20final%20lucre/DropCaps/images/DropCaps.png">
      <script:event script:event-name="on-performaction" script:macro-name=";location=application" script:language="Script"/>

     <dlg:button dlg:id="CommandButton2" dlg:tab-index="1" dlg:left="41" dlg:top="3" dlg:width="28" dlg:height="28" dlg:value="&amp;16.Dialog1.CommandButton2.Label" dlg:image-src="file:///C:/Users/Lucrecia/Desktop/plug%20final%20lucre/DropCaps/images/NoneDropCaps.png">
      <script:event script:event-name="on-performaction" script:macro-name=";location=application" script:language="Script"/>

     <dlg:button dlg:id="CommandButton3" dlg:tab-index="3" dlg:left="15" dlg:top="38" dlg:width="55" dlg:height="14" dlg:help-text="&amp;111.Dialog1.CommandButton3.HelpText" dlg:value="Cancel">
      <script:event script:event-name="on-performaction" script:macro-name=";location=application" script:language="Script"/>

here my full extension
dialogo sin botones.PNG
buttons without images
dialogo sin botones.PNG (1.43 KiB) Viewed 172 times
dialogo con 2 botones.PNG
buttons with images
dialogo con 2 botones.PNG (2.65 KiB) Viewed 172 times
OpenOffice 4.1.2
Windows 10
Posts: 8
Joined: Thu Jun 30, 2016 10:18 am

Re: Relative URL in a dialog

Postby musikai » Sat Nov 04, 2017 9:59 pm

I'm also new to this but after reading some documents here are some thoughts:
Files that are to be used have to be declared in the Manifest.xml (in META-INF-Folder). There the Addons.xcu is also declared.
As your Addons.xcu contains info about images in "image" path they are also copied to the extension install path.
This install path will be unique on every machine. So to use an image from there you have to find out the path.
There is a macro to find out the path of your extension by its name: the extensionidentifier that you can read in description.xml. On your extension it reads "org.broffice.DropCaps"
Here is the macro to find the install path (with your ExtensionIdentifier):
Code: Select all   Expand viewCollapse view
function GetExtensionInstPfad
Dim sService as string, sExtensionIdentifier as string, sPackageLocation as string
dim oPackageInfoProvider as variant
sExtensionIdentifier = "org.broffice.DropCaps"
sService = ""
oPackageInfoProvider = GetDefaultContext.getValueByName("/singletons/" & sService)
sPackageLocation = oPackageInfoProvider.getPackageLocation(sExtensionIdentifier)
GetExtensionInstPfad = sPackageLocation
End function

(To get a path from this function the extension has to be installed.)

For the images in your dialog you can't statically set them via the dialog editor but have to assign them on runtime.
Here you can find some code how to do this:
In that thread there is mentioned another elegant way to create, save and use images directly in the basic code.

I haven't tested all stuff here, but hope it might be useful to you.
Win7 Pro, Lubuntu 15.10, LO 4.4.7, OO 4.1.3
Free Project: LibreOffice Songbook Architect (LOSA)
Posts: 166
Joined: Wed Nov 11, 2015 12:19 am

Return to Extensions

Who is online

Users browsing this forum: No registered users and 4 guests