Arbitrary file from within a UNO package

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Arbitrary file from within a UNO package

Manuel Odesser
Hello,

I am building an extension to OOo, using OOBasic and Java. I actually
have two problems.

1) How to open in Java a file bundled in the UNO package ? I followed
instruction from
http://codesnippets.services.openoffice.org/Office/Office.ArbitraryDeploy.snip 
(and others). I cannot retrieve a path from a .xcu file for opening. I
have the following code :

private init() throws IOException,Exception {
        XComponentContext xContext;
        XMultiComponentFactory xServiceManager;
        XMultiServiceFactory xProvider;
        try {
            xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
        } catch (BootstrapException e1) {
            e1.printStackTrace();
            return false;
        }
        xServiceManager = xContext.getServiceManager();
        Object mxConfigurationProvider =
xServiceManager.createInstanceWithContext(
                "com.sun.star.configuration.ConfigurationProvider",
                xContext);
        try {
            xProvider = (XMultiServiceFactory)
           
UnoRuntime.queryInterface(XMultiServiceFactory.class,mxConfigurationProvider);
            PropertyValue properties[] = new PropertyValue[1];
            PropertyValue property = new PropertyValue();
            property.Name = "nodepath";
            property.Value = "my.package";
            properties[0] = property;

            // create the view
            Object xViewRoot =
xProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess",properties);
            dataPath = (String)xViewRoot.getByName("myvar");
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

        // get data file
        // cut the "vnd.sun.star.expand:" protocol from the macrofied
Url retrieved from the registry
        dataPath = dataPath.replace("vnd.sun.star.expand:","");
        Object theExpander;
        theExpander =
xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander");
        XMacroExpander oMacroExpander = (XMacroExpander)theExpander;
        dataPath = oMacroExpander.expandMacros(dataPath);
        BufferedReader buffer = new BufferedReader(new
FileReader(dataPath));
....
}

* problem 1 : xViewRoot is viewed as an Object, and therefore has no
getByName() method. And I can't cast to
com.sun.star.configuration.ConfigurationAccess because Eclipse couldn't
locate the appropriate file.
* problem 2 : An exception is throw at runtime during the cast of
variable theExpander.
* problem 3 : what is the typical .xcu file that could contain
"%origin%/mypath/myfile.dat ?

2) I have a addons.xcu that begins with :

<oor:component-data
    xmlns:oor="http://solstage2.sfo.collab.net/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="AddonMenu">
            <node
                oor:name="mypackage.myaddon"
                oor:op="replace">


Is "mypackage.myaddon" a suitable/valid name ? Should it begin with
"org.openoffice...." or something else ?


Sorry for this long email, and thank very much in advance for your answers !

--
Manuel

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Arbitrary file from within a UNO package

Juergen Schmidt-3
Hi Manuel,

first of all, we have already detected this as a missing functionality
and we will provide a simple API for detecting the package root in the
future. But i can't say when it will be available ...

See my comments inline ...

Manuel Odesser wrote:

> Hello,
>
> I am building an extension to OOo, using OOBasic and Java. I actually
> have two problems.
>
> 1) How to open in Java a file bundled in the UNO package ? I followed
> instruction from
> http://codesnippets.services.openoffice.org/Office/Office.ArbitraryDeploy.snip 
> (and others). I cannot retrieve a path from a .xcu file for opening. I
> have the following code :
>
> private init() throws IOException,Exception {
>        XComponentContext xContext;
>        XMultiComponentFactory xServiceManager;
>        XMultiServiceFactory xProvider;
>        try {
>            xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
>        } catch (BootstrapException e1) {
>            e1.printStackTrace();
>            return false;
>        }
>        xServiceManager = xContext.getServiceManager();
>        Object mxConfigurationProvider =
> xServiceManager.createInstanceWithContext(
>                "com.sun.star.configuration.ConfigurationProvider",
>                xContext);
>        try {
>            xProvider = (XMultiServiceFactory)
>            
> UnoRuntime.queryInterface(XMultiServiceFactory.class,mxConfigurationProvider);
>
>            PropertyValue properties[] = new PropertyValue[1];
>            PropertyValue property = new PropertyValue();
>            property.Name = "nodepath";
>            property.Value = "my.package";
>            properties[0] = property;
>
>            // create the view
>            Object xViewRoot =
> xProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess",properties);
>
you have to query the new created object to the interface you want to
use, somehting like

XNameAccess xNA =
(XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xViewRoot );

>            dataPath = (String)xViewRoot.getByName("myvar");
>        } catch (Exception e) {
>            e.printStackTrace();
>            return false;
>        }
>
>        // get data file
>        // cut the "vnd.sun.star.expand:" protocol from the macrofied Url
> retrieved from the registry
>        dataPath = dataPath.replace("vnd.sun.star.expand:","");
>        Object theExpander;
>        theExpander =
> xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander");
>        XMacroExpander oMacroExpander = (XMacroExpander)theExpander;
you can't simply cast this object. "getValueByName" returns an "Any"
which of course is mapped in Java to Object. You have either to use the
"AnyConverter" or if you need a specific interface use again
2queryInterface" which allows "Any" object directly.

>        dataPath = oMacroExpander.expandMacros(dataPath);
>        BufferedReader buffer = new BufferedReader(new
> FileReader(dataPath));
> ....
> }
>
> * problem 1 : xViewRoot is viewed as an Object, and therefore has no
> getByName() method. And I can't cast to
> com.sun.star.configuration.ConfigurationAccess because Eclipse couldn't
> locate the appropriate file.
> * problem 2 : An exception is throw at runtime during the cast of
> variable theExpander.
> * problem 3 : what is the typical .xcu file that could contain
> "%origin%/mypath/myfile.dat ?

Currently you have to define your own package specific configuration
schema and you have to provide an appropriate xcu file depending on this
schema together with all other files in your package. In a second step
you can use the configuration API to work with your own configuration
and the MacroExpander to get a valid Url.

Sorry that it is so complicate but we are working on improvements.

Juergen

>
> 2) I have a addons.xcu that begins with :
>
> <oor:component-data
>    xmlns:oor="http://solstage2.sfo.collab.net/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="AddonMenu">
>            <node
>                oor:name="mypackage.myaddon"
>                oor:op="replace">
>
>
> Is "mypackage.myaddon" a suitable/valid name ? Should it begin with
> "org.openoffice...." or something else ?
>
>
> Sorry for this long email, and thank very much in advance for your
> answers !
>
> --
> Manuel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Arbitrary file from within a UNO package

Daniel Boelzle
In reply to this post by Manuel Odesser
Hello,

IMO (for now until there is no convenient way), you can also go the way
that I have proposed here

http://api.openoffice.org/servlets/ReadMsg?listName=dev&msgNo=14040

Assuring a unique jar resource is IMO as hard as assuring a unique
configuration key...

HTH,
-Daniel


Jürgen Schmidt wrote:

> Hi Manuel,
>
> first of all, we have already detected this as a missing functionality
> and we will provide a simple API for detecting the package root in the
> future. But i can't say when it will be available ...
>
> See my comments inline ...
>
> Manuel Odesser wrote:
>> Hello,
>>
>> I am building an extension to OOo, using OOBasic and Java. I actually
>> have two problems.
>>
>> 1) How to open in Java a file bundled in the UNO package ? I followed
>> instruction from
>> http://codesnippets.services.openoffice.org/Office/Office.ArbitraryDeploy.snip 
>> (and others). I cannot retrieve a path from a .xcu file for opening. I
>> have the following code :
>>
>> private init() throws IOException,Exception {
>>        XComponentContext xContext;
>>        XMultiComponentFactory xServiceManager;
>>        XMultiServiceFactory xProvider;
>>        try {
>>            xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
>>        } catch (BootstrapException e1) {
>>            e1.printStackTrace();
>>            return false;
>>        }
>>        xServiceManager = xContext.getServiceManager();
>>        Object mxConfigurationProvider =
>> xServiceManager.createInstanceWithContext(
>>                "com.sun.star.configuration.ConfigurationProvider",
>>                xContext);
>>        try {
>>            xProvider = (XMultiServiceFactory)
>>            
>> UnoRuntime.queryInterface(XMultiServiceFactory.class,mxConfigurationProvider);
>>
>>            PropertyValue properties[] = new PropertyValue[1];
>>            PropertyValue property = new PropertyValue();
>>            property.Name = "nodepath";
>>            property.Value = "my.package";
>>            properties[0] = property;
>>
>>            // create the view
>>            Object xViewRoot =
>> xProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess",properties);
>>
> you have to query the new created object to the interface you want to
> use, somehting like
>
> XNameAccess xNA =
> (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xViewRoot );
>
>>            dataPath = (String)xViewRoot.getByName("myvar");
>>        } catch (Exception e) {
>>            e.printStackTrace();
>>            return false;
>>        }
>>
>>        // get data file
>>        // cut the "vnd.sun.star.expand:" protocol from the macrofied Url
>> retrieved from the registry
>>        dataPath = dataPath.replace("vnd.sun.star.expand:","");
>>        Object theExpander;
>>        theExpander =
>> xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander");
>>        XMacroExpander oMacroExpander = (XMacroExpander)theExpander;
> you can't simply cast this object. "getValueByName" returns an "Any"
> which of course is mapped in Java to Object. You have either to use the
> "AnyConverter" or if you need a specific interface use again
> 2queryInterface" which allows "Any" object directly.
>
>>        dataPath = oMacroExpander.expandMacros(dataPath);
>>        BufferedReader buffer = new BufferedReader(new
>> FileReader(dataPath));
>> ....
>> }
>>
>> * problem 1 : xViewRoot is viewed as an Object, and therefore has no
>> getByName() method. And I can't cast to
>> com.sun.star.configuration.ConfigurationAccess because Eclipse couldn't
>> locate the appropriate file.
>> * problem 2 : An exception is throw at runtime during the cast of
>> variable theExpander.
>> * problem 3 : what is the typical .xcu file that could contain
>> "%origin%/mypath/myfile.dat ?
>
> Currently you have to define your own package specific configuration
> schema and you have to provide an appropriate xcu file depending on this
> schema together with all other files in your package. In a second step
> you can use the configuration API to work with your own configuration
> and the MacroExpander to get a valid Url.
>
> Sorry that it is so complicate but we are working on improvements.
>
> Juergen
>
>> 2) I have a addons.xcu that begins with :
>>
>> <oor:component-data
>>    xmlns:oor="http://solstage2.sfo.collab.net/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="AddonMenu">
>>            <node
>>                oor:name="mypackage.myaddon"
>>                oor:op="replace">
>>
>>
>> Is "mypackage.myaddon" a suitable/valid name ? Should it begin with
>> "org.openoffice...." or something else ?
>>
>>
>> Sorry for this long email, and thank very much in advance for your
>> answers !
>>
>> --
>> Manuel
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Arbitrary file from within a UNO package

Mathias Bauer
In reply to this post by Manuel Odesser
Manuel Odesser wrote:

> 2) I have a addons.xcu that begins with :
>
> <oor:component-data
>     xmlns:oor="http://solstage2.sfo.collab.net/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="AddonMenu">
>             <node
>                 oor:name="mypackage.myaddon"
>                 oor:op="replace">
>
>
> Is "mypackage.myaddon" a suitable/valid name ? Should it begin with
> "org.openoffice...." or something else ?

You should create your own namespace, otherwise there is a risk that
your node name will clash of the gazillions ;-) of future Add-Ons we
will get for OOo.

My recommendation is that for Add-Ons created from a company/vendor you
take

vnd.$COMPANYNAME.$PROJECTNAME.$ADDONNAME

Best regards,
Mathias

--
Mathias Bauer - OpenOffice.org Application Framework Project Lead
Please reply to the list only, [hidden email] is a spam sink.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Arbitrary file from within a UNO package

Manuel Odesser
In reply to this post by Juergen Schmidt-3
Hi all,

I'd like to thank everyone I had answer from ! A problem remains : I
cannot find a practical sample to create a simple .xsd and its .xcu
counterpart. Here are my guess, could someone tell me if I cannot access
my values because of the xml or the java code ?

myaddon.xsd :
<?xml version="1.0" encoding="UTF-8"?>
<oor:component-schema
    oor:name="Settings"
    oor:package="org.mycomp.mypackage"
    xsi:schemaLocation="http://openoffice.org/2001/registry 
component-schema.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:oor="http://openoffice.org/2001/registry"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xml:lang='en-US'>
    <import oor:component="org.openoffice.Office.Common"/>
    <templates>
        <group oor:name="URLs">
            <prop oor:name="dataPath" oor:type="xs:string"/>
        </group>
    </templates>
    <oor:component>
        <group oor:name="URLs">
            <prop oor:name="dataPath" oor:type="oor:string">
                <value>%config%/data/terminologie_fr_FR.dat</value>
            </prop>
        </group>
    </oor:component>
</oor:component-schema>

myaddon.xcu :
<?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="Settings"
    oor:package="org.mycomp.mypackage">
    <node oor:name="URLs">
        <prop oor:name="dataPath" oor:type="xs:string">
            <value>%config%/data/terminologie_fr_FR.dat</value>
        </prop>
    </node>
</oor:component-data>

the code :
            PropertyValue properties[] = new PropertyValue[1];
            PropertyValue property = new PropertyValue();
            property.Name = "nodepath";
            property.Value = "/org.mycomp.mypackage/Settings";
            properties[0] = property;
            XInterface xViewRoot =
(XInterface)xConfigProvider.createInstanceWithArguments(
                "com.sun.star.configuration.ConfigurationAccess",
                properties);
            XPropertySet xPropertySet =
(XPropertySet)UnoRuntime.queryInterface(
                    XPropertySet.class, xViewRoot );
            dataPath = (String)xPropertySet.getPropertyValue("dataPath");

Thank you again,
--
Manuel Odesser

Jürgen Schmidt a écrit :

> Hi Manuel,
>
> first of all, we have already detected this as a missing functionality
> and we will provide a simple API for detecting the package root in the
> future. But i can't say when it will be available ...
>
> See my comments inline ...
>
> Manuel Odesser wrote:
>> Hello,
>>
>> I am building an extension to OOo, using OOBasic and Java. I actually
>> have two problems.
>>
>> 1) How to open in Java a file bundled in the UNO package ? I followed
>> instruction from
>> http://codesnippets.services.openoffice.org/Office/Office.ArbitraryDeploy.snip 
>> (and others). I cannot retrieve a path from a .xcu file for opening.
>> I have the following code :
>>
>> private init() throws IOException,Exception {
>>        XComponentContext xContext;
>>        XMultiComponentFactory xServiceManager;
>>        XMultiServiceFactory xProvider;
>>        try {
>>            xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
>>        } catch (BootstrapException e1) {
>>            e1.printStackTrace();
>>            return false;
>>        }
>>        xServiceManager = xContext.getServiceManager();
>>        Object mxConfigurationProvider =
>> xServiceManager.createInstanceWithContext(
>>                "com.sun.star.configuration.ConfigurationProvider",
>>                xContext);
>>        try {
>>            xProvider = (XMultiServiceFactory)
>>            
>> UnoRuntime.queryInterface(XMultiServiceFactory.class,mxConfigurationProvider);
>>
>>            PropertyValue properties[] = new PropertyValue[1];
>>            PropertyValue property = new PropertyValue();
>>            property.Name = "nodepath";
>>            property.Value = "my.package";
>>            properties[0] = property;
>>
>>            // create the view
>>            Object xViewRoot =
>> xProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess",properties);
>>
> you have to query the new created object to the interface you want to
> use, somehting like
>
> XNameAccess xNA =
> (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xViewRoot );
>
>>            dataPath = (String)xViewRoot.getByName("myvar");
>>        } catch (Exception e) {
>>            e.printStackTrace();
>>            return false;
>>        }
>>
>>        // get data file
>>        // cut the "vnd.sun.star.expand:" protocol from the macrofied
>> Url retrieved from the registry
>>        dataPath = dataPath.replace("vnd.sun.star.expand:","");
>>        Object theExpander;
>>        theExpander =
>> xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander");
>>
>>        XMacroExpander oMacroExpander = (XMacroExpander)theExpander;
> you can't simply cast this object. "getValueByName" returns an "Any"
> which of course is mapped in Java to Object. You have either to use
> the "AnyConverter" or if you need a specific interface use again
> 2queryInterface" which allows "Any" object directly.
>
>>        dataPath = oMacroExpander.expandMacros(dataPath);
>>        BufferedReader buffer = new BufferedReader(new
>> FileReader(dataPath));
>> ....
>> }
>>
>> * problem 1 : xViewRoot is viewed as an Object, and therefore has no
>> getByName() method. And I can't cast to
>> com.sun.star.configuration.ConfigurationAccess because Eclipse
>> couldn't locate the appropriate file.
>> * problem 2 : An exception is throw at runtime during the cast of
>> variable theExpander.
>> * problem 3 : what is the typical .xcu file that could contain
>> "%origin%/mypath/myfile.dat ?
>
> Currently you have to define your own package specific configuration
> schema and you have to provide an appropriate xcu file depending on
> this schema together with all other files in your package. In a second
> step you can use the configuration API to work with your own
> configuration and the MacroExpander to get a valid Url.
>
> Sorry that it is so complicate but we are working on improvements.
>
> Juergen
>
>>
>> 2) I have a addons.xcu that begins with :
>>
>> <oor:component-data
>>    xmlns:oor="http://solstage2.sfo.collab.net/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="AddonMenu">
>>            <node
>>                oor:name="mypackage.myaddon"
>>                oor:op="replace">
>>
>>
>> Is "mypackage.myaddon" a suitable/valid name ? Should it begin with
>> "org.openoffice...." or something else ?
>>
>>
>> Sorry for this long email, and thank very much in advance for your
>> answers !
>>
>> --
>> Manuel

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Arbitrary file from within a UNO package

Jörg Barfurth
In reply to this post by Manuel Odesser
Hi,

Manuel Odesser wrote:
> Hi all,
>
> I'd like to thank everyone I had answer from ! A problem remains : I
> cannot find a practical sample to create a simple .xsd and its .xcu
> counterpart. Here are my guess, could someone tell me if I cannot access
> my values because of the xml or the java code ?
>

The code. But I have some comments on your XML as well. See inline
comments for more:

> myaddon.xsd :
> <?xml version="1.0" encoding="UTF-8"?>
> <oor:component-schema
>    oor:name="Settings"
>    oor:package="org.mycomp.mypackage"
>    xsi:schemaLocation="http://openoffice.org/2001/registry 
> component-schema.xsd"
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    xmlns:oor="http://openoffice.org/2001/registry"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
> xml:lang='en-US'>
>    <import oor:component="org.openoffice.Office.Common"/>

You don't need that <import>. You don't use any templates from that
component.

>    <templates>
>        <group oor:name="URLs">
>            <prop oor:name="dataPath" oor:type="xs:string"/>
>        </group>
>    </templates>

You also don't need the entire <templates> part, as you don't use that
feature in your data below.

>    <oor:component>
>        <group oor:name="URLs">
>            <prop oor:name="dataPath" oor:type="oor:string">
>                <value>%config%/data/terminologie_fr_FR.dat</value>

Is that really a fundamental, never-to-be-changed, default for this
item? Otherwise you should omit the <value> here.

Please note that the 'origin' substitution offered by unopkg doesn't
work with values in a schema.

>            </prop>
>        </group>
>    </oor:component>
> </oor:component-schema>
>
> myaddon.xcu :
> <?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="Settings"
>    oor:package="org.mycomp.mypackage">
>    <node oor:name="URLs">
>        <prop oor:name="dataPath" oor:type="xs:string">
>            <value>%config%/data/terminologie_fr_FR.dat</value>

If your value here is identical to the default in the schema - in case
you didn't follow my advice above and if you don't need 'origin'
substitution -, then you don't need this <prop> (actually you don't need
the xcu at all in that case).

As a side note: the type="xs:string" isn't needed here, as that is known
from the schema.


>        </prop>
>    </node>
> </oor:component-data>
>

Now to the code

> the code :
>            PropertyValue properties[] = new PropertyValue[1];
>            PropertyValue property = new PropertyValue();
>            property.Name = "nodepath";
>            property.Value = "/org.mycomp.mypackage/Settings";

Should be "/org.mycomp.mypackage.Settings/URLs".

The full component name is composed as <package>.<component-name>. And
you forgot the extra 'URLs' level you introduce in your schema.

>            properties[0] = property;
>            XInterface xViewRoot =
> (XInterface)xConfigProvider.createInstanceWithArguments(
>                "com.sun.star.configuration.ConfigurationAccess",
>                properties);
>            XPropertySet xPropertySet =
> (XPropertySet)UnoRuntime.queryInterface(
>                    XPropertySet.class, xViewRoot );
>            dataPath = (String)xPropertySet.getPropertyValue("dataPath");
>

HTH

- Joerg

--
Joerg Barfurth              Sun Microsystems - Desktop - Hamburg
 >>>>>>>>>>>>>>>>>> using std::disclaimer <<<<<<<<<<<<<<<<<<<<<<<
Software Engineer                         [hidden email]
Thin Client Software

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Arbitrary file from within a UNO package

Manuel Odesser
Hi,

Yes, that was very good help ! But, as usual, everything did not work as
expected :'(   This code :

XInterface xViewRoot =
(XInterface)xConfigProvider.createInstanceWithArguments(
                "com.sun.star.configuration.ConfigurationAccess",
                properties);

throws a WrappedTargetException with the following error code :

com.sun.star.lang.WrappedTargetException:
/org.mycomp.mypackage.Settings/URLs (and for locale fr) could not be
created. Unable to retrieve the node from the configuration server.
The backend returned the following error:
Layer merging: No data to merge with

My .xsd and .xcu files are now like this :

<oor:component-schema
    oor:name="Settings"
    oor:package="org.mycomp.mypackage"
    xsi:schemaLocation="http://openoffice.org/2001/registry 
component-schema.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:oor="http://openoffice.org/2001/registry"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xml:lang='en-US'>
    <oor:component>
        <group oor:name="URLs">
            <prop oor:name="dataPath" oor:type="oor:string">
                <value />
            </prop>
        </group>
    </oor:component>
</oor:component-schema>

<oor:component-data
    xmlns:oor="http://openoffice.org/2001/registry"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    oor:name="Settings"
    oor:package="org.mycomp.mypackage">
    <node oor:name="URLs">
        <prop oor:name="dataPath">
            <value>%config%/data/terminologie_fr_FR.dat</value>
        </prop>
    </node>
</oor:component-data>

I just cannot find a place with information about this. Does it ring
someone's bell ?

Thank you in advance !


Joerg Barfurth a écrit :
> The code. But I have some comments on your XML as well. See inline
> comments for more:
>
> <snip>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Arbitrary file from within a UNO package

Cyrille Moureaux
In reply to this post by Manuel Odesser
Hi Manuel,

>
> Yes, that was very good help ! But, as usual, everything did not work as
> expected :'(   This code :
>
> XInterface xViewRoot =
> (XInterface)xConfigProvider.createInstanceWithArguments(
>                 "com.sun.star.configuration.ConfigurationAccess",
>                 properties);
>
> throws a WrappedTargetException with the following error code :
>
> com.sun.star.lang.WrappedTargetException:
> /org.mycomp.mypackage.Settings/URLs (and for locale fr) could not be
> created. Unable to retrieve the node from the configuration server.
> The backend returned the following error:
> Layer merging: No data to merge with
>
> My .xsd and .xcu files are now like this :
>
> <oor:component-schema
>     oor:name="Settings"
>     oor:package="org.mycomp.mypackage"
>     xsi:schemaLocation="http://openoffice.org/2001/registry 
> component-schema.xsd"
>     xmlns:xs="http://www.w3.org/2001/XMLSchema"
>     xmlns:oor="http://openoffice.org/2001/registry"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"      
> xml:lang='en-US'>
--^^^^^^^^^^^^^^^^
I don't think you need this (but I may be wrong).
>     <oor:component>
>         <group oor:name="URLs">
>             <prop oor:name="dataPath" oor:type="oor:string">
--------------------------------------------------^^^^
The data type here should be xs:string.

Hope this helps,

Cyrille

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Arbitrary file from within a UNO package

Cyrille Moureaux
In reply to this post by Manuel Odesser
Hi again,
>> xml:lang='en-US'>
>
> --^^^^^^^^^^^^^^^^
> I don't think you need this (but I may be wrong).

Forget about that, apparently I am wrong. Sorry about the confusion.

Cyrille

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Arbitrary file from within a UNO package

Jörg Barfurth
In reply to this post by Manuel Odesser
Manuel Odesser wrote:

> Hi,
>
> Yes, that was very good help ! But, as usual, everything did not work as
> expected :'(   This code :
>
> XInterface xViewRoot =
> (XInterface)xConfigProvider.createInstanceWithArguments(
>                "com.sun.star.configuration.ConfigurationAccess",
>                properties);
>
> throws a WrappedTargetException with the following error code :
>
> com.sun.star.lang.WrappedTargetException:
> /org.mycomp.mypackage.Settings/URLs (and for locale fr) could not be
> created. Unable to retrieve the node from the configuration server.
> The backend returned the following error:
> Layer merging: No data to merge with
>

IIRC that means that the OOR schema is not there.

> My .xsd and .xcu files are now like this :
>

The schema file extension should be .xcs (not .xsd). Does that fix the
problem?

> <oor:component-schema
>    oor:name="Settings"
>    oor:package="org.mycomp.mypackage"
>    xsi:schemaLocation="http://openoffice.org/2001/registry 
> component-schema.xsd"

I don't think that actually is a valid schema location. Might drop this.

>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>    xmlns:oor="http://openoffice.org/2001/registry"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
> xml:lang='en-US'>
>    <oor:component>
>        <group oor:name="URLs">
>            <prop oor:name="dataPath" oor:type="oor:string">

As Cyrille pointed out that should be xs:string.

HTH

- Joerg

--
Joerg Barfurth              Sun Microsystems - Desktop - Hamburg
 >>>>>>>>>>>>>>>>>> using std::disclaimer <<<<<<<<<<<<<<<<<<<<<<<
Software Engineer                         [hidden email]
Thin Client Software

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]