| View previous topic :: View next topic |
| Author |
Message |
munkejens General User

Joined: 12 Sep 2003 Posts: 19
|
Posted: Wed Jan 12, 2005 7:33 am Post subject: Registrating and accessing UNO components questions |
|
|
Hi
I have some questions about UNO components (implementet in Java) that I can't seem to get an answer in the DeveloperGuide.
1. When building my component in NetBeans 4.0 I get just one jar-archive, naturally.
Is this jar-archive supposed to go into another jar-archive (or zip-archive) which is then the UNO package that should be registered with OOo?
2. Does anybody know how to make the registration (pkgchk) automatic when building the project using Apache Ant (NetBeans 4.0)?
3. Making GUI-buttons/Topmenus to access my UNO component?
I know this is possible using Macros . But how else? I would like to have these topmenus throughout the entire OOo, not just when opening specific templates as I supposed the macro-solution is. I can't seem to find information on how to make this in Java. Is this possible?
Furthermore, is it possible to have these topmenus included in my own Java UNO component?
Thanks in advance.
Daniel Kokott |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
munkejens General User

Joined: 12 Sep 2003 Posts: 19
|
Posted: Mon Jan 17, 2005 1:17 am Post subject: |
|
|
Thank you very much, DannyB, for you answer. It was very helpful. Looking forward to implement it.
As for question 2, I found one answer:
I am using the Ant Exec Task like this in the build.xml:
| Code: |
<exec executable="pkgchk">
<arg value="${unopackage}"/>
</exec>
|
|
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Tue Jan 18, 2005 7:09 am Post subject: |
|
|
For question number 3, I'll elaborate on my answer.
I hope that if you really read and re-read all of this, that it explains the Configuration Data, and how to access/modify it from code, and also how to add top level menus, toolbar icons, or add on menus from an XCU file in your component. If you really pay attention you can even learn to create custom configuration schema within your component so that you can store your own arbitrary configuration data for your component. For instance, if your component has dialog boxes, you may want to "remember" some of the settings by storing it in the configuration manauger data.
Below, under "Configuration Manager", are some past threads that have macros which manipulate the configuration data.
In the macros below, see how Macros manipulate the Configuration data, by using the API?
From the threads below, especially, see this one....
* Brief explanation of how Config API ties to XCU files
http://www.oooforum.org/forum/viewtopic.php?p=24558#24558
That message talks about how the XCU (and XCS schema) files relate to how the macros call the Configuration Manager API to manipulate the nodes in the tree.
In your case, you do NOT need to write code to manipulate the configuration data. But you do need to learn to write an AddOn.xcu file, and include it into your component. See the Developer's Guide which has examples of some AddOn.xcu files I believe.
You can even write you own custom configuration schema! For instance, I wanted to store some custom data into a component (written in Python) once, and I created the following....
XCS schema file
| Code: | <?xml version='1.0' encoding='UTF-8'?>
<oor:component-schema oor:name="DannysConfig" oor:package="name.dannyBrewer" xml:lang="en-US" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<templates>
<group oor:name="DannysSetting">
<prop oor:name="Setting" oor:type="xs:string"/>
<set oor:name="SubSettings" oor:node-type="DannysSetting"/>
</group>
</templates>
<component>
<group oor:name="DannysConfigNode">
<set oor:name="Settings" oor:node-type="DannysSetting"/>
</group>
</component>
</oor:component-schema>
|
What this says, is that there is now a node called name.DannyBrewer.DannysConfig.
Put together the name.DannyBrewer from the package and the name.
oor:package="name.dannyBrewer"
oor:name="DannysConfig"
Thus, the configuration is at name.DannyBrewer.DannysConfig.
Within that, there is a node called DannysConfigNode.
| Code: | | <group oor:name="DannysConfigNode"> |
The Python code that accesses my node looks like this.....
| Code: | oConfigAccess = getConfigAccess( "/name.dannyBrewer.DannysConfig/DannysConfigNode" )
oElement = oConfigAccess.getByName( "Settings" )
oLocation = oElement.getByName( "my.location" )
cLocation = oLocation.Setting
|
(In the macros below, you can find my GetConfigAccess() function.)
See how the function is getting the node name.DannyBrewer.DannysConfig/DannysConfigNode? (Note that all of these names are case sensisitve. I once used name.dannyBrewer, and now use name.DannyBrewer.)
Within a configuration node, you can have eiather a set, or a group. In my case, you see I used a set named Settings.
| Code: | <group oor:name="DannysConfigNode">
<set oor:name="Settings" oor:node-type="DannysSetting"/>
</group>
|
The set is named Settings, and is a set of type DannysSetting. That is, there is a set of things. The things are of type DannysSetting. Each item in the set has a pair of (a name, a DannysSetting).
Under the templates, you can see that any node of type DannysSetting, has a property name Setting, which is a xs:string, and a SubSettings, which in turn is another set of DannysSetting. I figured this schema was flexible enough to let me store just about anything I wanted. Under DannysConfigNode, I could put as many named items into the top level set as I wanted. Each item in that set, in turn has a string, and a sub set. Each item in the subset then recursively can have named items with strings and more subsets.
Now the configuration data. What I chose to store into my configuration node was something like this.
XCU configuration data
| Code: | <?xml version="1.0" encoding="UTF-8"?>
<oor:component-data oor:name="DannysConfig" oor:package="name.dannyBrewer" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<node oor:name="DannysConfigNode">
<node oor:name="Settings">
<node oor:name="my.location" oor:op="replace">
<prop oor:name="Setting" oor:type="xs:string">
<value>%origin%</value>
</prop>
</node>
<node oor:name="my.thing1" oor:op="replace">
<prop oor:name="Setting" oor:type="xs:string">
<value>Thing1</value>
</prop>
</node>
<node oor:name="my.thing2" oor:op="replace">
<prop oor:name="Setting" oor:type="xs:string">
<value>Thing2</value>
</prop>
<node oor:name="SubSettings">
<node oor:name="sub1" oor:op="replace">
<prop oor:name="Setting" oor:type="xs:string">
<value>sub setting 1</value>
</prop>
</node>
<node oor:name="sub2" oor:op="replace">
<prop oor:name="Setting" oor:type="xs:string">
<value>sub setting 2</value>
</prop>
</node>
</node>
</node>
</node>
</node>
</oor:component-data>
|
As you can see, this configuration data specifies a name and package.
oor:package="name.dannyBrewer"
oor:name="DannysConfig"
Then there is a DannysConfigNode.
Inside this node is a Settings, which is a set of named items.
There are three different items in that set.
The frist item is named "my.location".
The second item is named "my.thing1".
The third item is "my.thing2".
Each item in the set, (my.location, my.thing1, and my.thing2) each has a Setting, which is an xs:string.
The third item in the set (my.thing2) has not only a Setting, but also takes advantage of the SubSettings, and has a set of two named items.
The first item in that subset is "sub1"
The second item in that subset is "sub2".
Both items (sub1, and sub2) each have a Setting (which is xs:string).
I could have recursively put sub-sub-sets of items within either sub1 or sub2. I think you see the recursive nature of my schema here.
When you look back at the my.thing1 item, it has a string, whose value is "Thing1".
When you look back at the my.location item, it has a string, whose value is "%origin%". You'll notice that my Python code above was interested in retrieving this string "%origin%" from my configuration data.
Your Java code can read, and write the configuration nodes, to store persistent sticky settings for your component.
Furthermore, configuration nodes under the AddOn, describe add on menus, toolbar icons, top level menu items, etc.
* Example of creating top level menu items
http://www.oooforum.org/forum/viewtopic.php?t=6310
In here, you can find my GetConfigAccess subroutine.
See how this creates a new top level menu? What that message does not explain, is that after running the macro, OOo's configuration data is changed with the following XML.
from OOo/user/registry/data/org/openoffice/Office/Addons.xcu
| Code: | <?xml version="1.0" encoding="UTF-8"?>
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office">
<node oor:name="AddonUI">
<node oor:name="OfficeMenuBar">
<node oor:name="com.Example.TopMenu.01" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value>com.sun.star.drawing.DrawingDocument</value>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">MeowMix</value>
</prop>
<node oor:name="Submenu">
<node oor:name="Itm-1" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Won</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(1)</value>
</prop>
</node>
<node oor:name="Itm-2" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Too</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(2)</value>
</prop>
</node>
<node oor:name="Itm-3" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Free</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(3)</value>
</prop>
</node>
<node oor:name="Itm-4" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Fore</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(4)</value>
</prop>
<node oor:name="Submenu">
<node oor:name="A1" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Apple 1</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(A 1)</value>
</prop>
<node oor:name="Submenu">
<node oor:name="A11" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Apple 1.1</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(A 1 1)</value>
</prop>
</node>
<node oor:name="A12" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Apple 1.2</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(A 1 2)</value>
</prop>
</node>
<node oor:name="A13" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Apple 1.3</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(A 1 3)</value>
</prop>
</node>
<node oor:name="A14" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Apple 1.4</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(A 1 4)</value>
</prop>
</node>
</node>
</node>
<node oor:name="A2" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Apple 2</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(A 2)</value>
</prop>
<node oor:name="Submenu">
<node oor:name="A21" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Apple 2.1</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(A 2 1)</value>
</prop>
</node>
<node oor:name="A22" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Apple 2.2</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(A 2 2)</value>
</prop>
</node>
<node oor:name="A23" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Apple 2.3</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(A 2 3)</value>
</prop>
</node>
<node oor:name="A24" oor:op="replace">
<prop oor:name="Context" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="ImageIdentifier" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Target" oor:type="xs:string">
<value xsi:nil="true"/>
</prop>
<prop oor:name="Title" oor:type="xs:string">
<value xml:lang="en-US">Apple 2.4</value>
</prop>
<prop oor:name="URL" oor:type="xs:string">
<value>macro:///DannysLibrary.Module163.test(A 2 4)</value>
</prop>
</node>
</node>
</node>
</node>
</node>
</node>
</node>
</node>
</node>
</oor:component-data>
|
By running the RemoveDannysTopLevelMenu function from the macro, it removes the top level menu and its submenus.
I did this programmatically from a macro.
But you could just put an Addon.xcu file into your component.
Configuration Manager
=====================
Number of times you can UNDO
http://www.oooforum.org/forum/viewtopic.php?p=45487#45487
Get rid of product registration
http://www.oooforum.org/forum/viewtopic.php?t=2267
* The Configuration Manager chapter of the Developer's Guide.
* My post titled: ENLARGE THE SIZE OF YOUR recent files list
http://www.oooforum.org/forum/viewtopic.php?t=3559
* My post titled: FYI...new macro to make OOo listen for UNO connections
* UnoConnectionListener
http://www.oooforum.org/forum/viewtopic.php?t=3754
* My post titled: Development of a Basic Macro Installer
http://www.oooforum.org/forum/viewtopic.php?t=4255
* Example of creating top level menu items
http://www.oooforum.org/forum/viewtopic.php?t=6310
* Example of creating new toolbar items
http://www.oooforum.org/forum/viewtopic.php?p=29341#29341
* Duplicate Shape installable draw tool
http://www.ooomacros.org/user.php#115800
* Brief explanation of how Config API ties to XCU files
http://www.oooforum.org/forum/viewtopic.php?p=24558#24558
* Explanation of custom XCS and XCU files using pkgchk
http://www.oooforum.org/forum/viewtopic.php?p=27922#27922
* My post titled: Musings about the Configuration Manager
http://www.oooforum.org/forum/viewtopic.php?t=4028
* Add On Tool
http://www.oooforum.org/forum/viewtopic.php?t=4059
Development of a Basic macro installer
http://www.oooforum.org/forum/viewtopic.php?t=4255
How to change default fonts programatically?
http://www.oooforum.org/forum/viewtopic.php?p=16982#16982
Dropdown Menus in Custom Toolbars
http://www.oooforum.org/forum/viewtopic.php?t=4008
TypeDetection.xml
http://www.oooforum.org/forum/viewtopic.php?t=3692
Description of TypeDetection.xcu
http://www.oooforum.org/forum/viewtopic.php?t=10111
Disabling menus items at runtime
http://www.oooforum.org/forum/viewtopic.php?t=3558
Configuring to listen for UNO connections
http://www.oooforum.org/forum/viewtopic.php?p=12370#12370
http://www.oooforum.org/forum/viewtopic.php?t=9768
Unanswered...possible to specify alternate configuration at launch time?
http://www.oooforum.org/forum/viewtopic.php?t=6798
What version of OOo is running?
Installed version of SOffice
http://www.oooforum.org/forum/viewtopic.php?p=37431
get the OpenOffice version
http://www.oooforum.org/forum/viewtopic.php?t=12008
Corrupt configuration fixup
=============================
http://www.oooforum.org/forum/viewtopic.php?t=3938
not yet fixed...
http://www.oooforum.org/forum/viewtopic.php?t=6966
Configuration files & other OOo installation files
==================================================
http://www.oooforum.org/forum/viewtopic.php?t=4432
http://www.openoffice.org/servlets/ReadMsg?list=discuss&msgNo=27486
http://www.oooforum.org/forum/viewtopic.php?t=4190
http://www.oooforum.org/forum/viewtopic.php?t=3369
User configuration backup discussion
http://www.oooforum.org/forum/viewtopic.php?t=3012
OO personal settings
http://www.oooforum.org/forum/viewtopic.php?t=13024
pathnames under Windows and Linux to the user folder
http://www.oooforum.org/forum/viewtopic.php?p=49774#49774
Copy user settings to other PC
http://www.oooforum.org/forum/viewtopic.php?p=11651
http://www.oooforum.org/forum/viewtopic.php?t=3121
http://www.oooforum.org/forum/viewtopic.php?p=11179#11179
http://www.oooforum.org/forum/viewtopic.php?t=6630
http://www.oooforum.org/forum/viewtopic.php?p=11651#11651
http://www.oooforum.org/forum/viewtopic.php?p=10865#10865
http://www.oooforum.org/forum/viewtopic.php?p=11663#11663
User Interface Configuration tied to a specific document instance
http://www.oooforum.org/forum/viewtopic.php?p=14862#14862 _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
|
|
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
|