OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Changing images in dialog interactively

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
hillerd
General User
General User


Joined: 02 Jul 2005
Posts: 22

PostPosted: Sat Feb 24, 2007 1:23 pm    Post subject: Changing images in dialog interactively Reply with quote

I want to interactively change the image of an "ImageControl" of a dialog.
Since the corresponding macro is installed with the extension manager, I cannot use absolute paths in the URL.
So I need to find out, where the images have been placed with the extension manager and manipulate the graphURL value accordingly.
Is there an example somewhere? Programming language is BASIC.

Thanks
Back to top
View user's profile Send private message Visit poster's website
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 7649
Location: Germany

PostPosted: Sat Feb 24, 2007 2:18 pm    Post subject: Reply with quote

Browse the directory <user-dir>/.openoffice.org2/user/uno_packages/cache/uno_packages/
Under Windows something like: Docs and settings\name\Application Data\OOo\user\uno_packages\cache\uno_packages\
_________________
XUbuntu 9.04, OOo 3.1.1(Sun), Sun Java 1.5.0_06
Back to top
View user's profile Send private message
hillerd
General User
General User


Joined: 02 Jul 2005
Posts: 22

PostPosted: Sun Feb 25, 2007 2:36 am    Post subject: Reply with quote

I have found the add-on, but I need to tell in the dialog editor the URL where the image is located. Since I want to install the add-on via the extension manager I cannot use the direct URL but have to take a general term. I found the %origin% but have no idea of how to make use of it.
Do you have any suggestions?
Back to top
View user's profile Send private message Visit poster's website
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 7649
Location: Germany

PostPosted: Sun Feb 25, 2007 3:51 am    Post subject: Reply with quote

If your add-on is registered as "name/your_name/myAddon" and one of your configuration entries in mySetup.xcu looks like
"%origin%/pictures/mypic.png"
the registered add-on will store this info in a file ~/.openoffice.org2/user/uno_packages/cache/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/registry/data/name/your_name/myAddon/mySetup.xcu
The corresponding line reads like:
vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE/uno_packages/SHZUe5_/myAddon.uno.zip/pictures/myPic.png

You have to read that entry from a config-node, instanciate a macro-expander, use it's method expand(str) in order to get a url like:
vnd.sun.star.expand:file:///<real/path/to/your/installed/package>/uno_packages/SHZUe5_/....
Strip "vnd.sun.star.expand:" and you have the url of the picture file.
One example in python, but almost usable as Basic code:
http://www.oooforum.org/forum/viewtopic.phtml?t=14552&highlight=themacroexpander

The first link in my signature provides a working add-on in python.
The relevant stuff is in "registry/Localization.xcu|xcs" and python/SpecialCells.py, class ConfigProvider.
Sorry, I can't find a StarBasic example yet.
_________________
XUbuntu 9.04, OOo 3.1.1(Sun), Sun Java 1.5.0_06
Back to top
View user's profile Send private message
hillerd
General User
General User


Joined: 02 Jul 2005
Posts: 22

PostPosted: Sun Feb 25, 2007 4:06 am    Post subject: Reply with quote

Thanks, that looks very promising. It will take some time to get this done (I am just preparing for a paragliding exam and thus do not have too much time), but be sure that I will let you know.

Dietmar
Back to top
View user's profile Send private message Visit poster's website
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 7649
Location: Germany

PostPosted: Sun Feb 25, 2007 5:45 am    Post subject: Reply with quote

*g* Of course I have a working example in StarBasic.
Install my add-on "SpecialCells" and run this:
Code:

Sub print_SpecialCellsHelpPath
'calls getRootElement, getExpander
Const sNode = "name.AndreasSaeger.SpecialCells.Localization/LocalizedStrings"
Const sEntry = "HelpPath"
Const sPrefix = "vnd.sun.star.expand:"
oRoot = getRootElement(sNode)
sMacroString = oRoot.getbyName("HelpPath")
print "sMacroString: "& sMacroString
expander = getMacroExpander()
sExpandURL = expander.expandMacros(sMacroString)
print "sExpandURL: "& sExpandURL
sFileURL = mid(sExpandURL,len(sPrefix) +1)
print "sFileURL: "& sFileURL
End Sub

Function getRootElement(sNodePath$)
Dim sProvider$,sAccess$,aSettings
Dim aConfigProvider, aParams2(0) as new com.sun.star.beans.PropertyValue
  sProvider = "com.sun.star.configuration.ConfigurationProvider"
  sAccess   = "com.sun.star.configuration.ConfigurationAccess"
  aConfigProvider = createUnoService(sProvider)
  aParams2(0).Name = "nodepath"
  aParams2(0).Value = sNodePath
  aSettings = aConfigProvider.createInstanceWithArguments(sAccess, aParams2())
   getRootElement = aSettings
End Function

Function getMacroExpander():
Dim PSM, ctx,btx
   PSM = getProcessServiceManager()
   ctx = PSM.DefaultContext
        btx = PSM.createInstanceWithContext("com.sun.star.configuration.bootstrap.BootstrapContext", ctx)
        getMacroExpander= btx.getValueByName("/singletons/com.sun.star.util.theMacroExpander")
End FUnction

If you run a german version the last print shows a path "file:///.../de", otherwise it is "file:///.../en".
_________________
XUbuntu 9.04, OOo 3.1.1(Sun), Sun Java 1.5.0_06
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3208
Location: Troyes France

PostPosted: Sun Feb 25, 2007 9:44 am    Post subject: Reply with quote

See also :
Using charts or other shapes in dialogs http://www.oooforum.org/forum/viewtopic.phtml?t=51038&highlight=
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
hillerd
General User
General User


Joined: 02 Jul 2005
Posts: 22

PostPosted: Mon Feb 26, 2007 10:09 am    Post subject: Reply with quote

Thank you all, I understand the way to go.

While I am working through your documents, another question arose:
Do I actually have to do the same for static images, so images installed with the extention manager that are not controlled from the code? Or is there a trick to tell the dialog editior to look in the %origin% directory?
Back to top
View user's profile Send private message Visit poster's website
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 7649
Location: Germany

PostPosted: Mon Feb 26, 2007 2:28 pm    Post subject: Reply with quote

hillerd wrote:
Thank you all, I understand the way to go.

While I am working through your documents, another question arose:
Do I actually have to do the same for static images, so images installed with the extention manager that are not controlled from the code? Or is there a trick to tell the dialog editior to look in the %origin% directory?

No, I don't think there is such a trick. I created a dialog with an image control.
The image path is absolute.
Code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="Dialog2" dlg:left="10" dlg:top="76" dlg:width="152" dlg:height="122" dlg:closeable="true" dlg:moveable="true">
 <dlg:bulletinboard>
  <dlg:img dlg:id="ImageControl1" dlg:tab-index="0" dlg:left="34" dlg:top="37" dlg:width="82" dlg:height="54" dlg:src="file:///home/andreas/Documents/Bilder/airbag.jpg"/>
 </dlg:bulletinboard>

This changes the picture:
Code:

Sub test_Dialog2
   globalscope.dialoglibraries.loadlibrary("Library1")
   oObj = DialogLibraries.Library1.Dialog2
   oDlg = createUnoDialog(oObj)
   oDlg.Model.getByName("ImageControl1").ImageURL = "file:///home/andreas/Documents/Bilder/Bremse.jpg"
   oDlg.execute()
end sub

_________________
XUbuntu 9.04, OOo 3.1.1(Sun), Sun Java 1.5.0_06
Back to top
View user's profile Send private message
hillerd
General User
General User


Joined: 02 Jul 2005
Posts: 22

PostPosted: Wed Mar 07, 2007 7:43 am    Post subject: Changing images in dialog interactively [closed] Reply with quote

Thank you all.
I created a little application how I realized it in the end: [URL]
http://www.oooforum.org/forum/viewtopic.phtml?p=211564#211564[/URL]
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group