PackageInformationProvider::get() and subsequent Reference<XPackageInformationProvider>::getPackageLocation()

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

PackageInformationProvider::get() and subsequent Reference<XPackageInformationProvider>::getPackageLocation()

Keith Alcock
 OpenOffice API experts,

I've inherited code for an OpenOffice extension in C++ that
purportedly ran with a previous version of OpenOffice who knows how
long ago.  The code is throwing an exception.  It is presently being
built with Visual C++ 2008 and running under Windows 7, although I
doubt that either of those is the problem.  By the time the exception
is caught, it is of type com::sun::star::uno::Exception & with the
message "[context="user"] caught unexpected exception!".  However,
previous to that the debugger sees a
com::sun::star::ucb::InteractiveAugmentedIOException, an 'anonymous
namespace'::NoDescriptionException, a few
com::sun::star::ucb::InteractiveAugmentedIOException's, and a
com::sun::star::lang::WrappedTargetRuntimeException.

The code is below.   I believe that it is preparing to load a graphic
from the extension's installation directory.  Perhaps there is an
alternate way to do that now.  Any and all help would be appreciated.
Thanks.

OUString getPathToExtensionRoot(const char* name) {
    OUString ouName = OUString::createFromAscii(name);
    // localContext seems to be good.  It can be used for other things.
    Reference<XComponentContext> localContext =
        defaultBootstrap_InitialComponentContext();
    Reference<XPackageInformationProvider> xPackageInformationProvider =
        PackageInformationProvider::get(localContext);
    // The following line crashes as does any other call using ->
    // xPackageInfoProvider.is() reports 1
    try {
        OUString path = xPackageInformationProvider->getPackageLocation(ouName);
        return path;
    }
    catch (Exception &ex) {
    }
    return ouName; // just to return something
}

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

Reply | Threaded
Open this post in threaded view
|

Re: PackageInformationProvider::get() and subsequent Reference<XPackageInformationProvider>::getPackageLocation()

Oliver Brinzing
Hi,

I remember i changed my source code last year to catch the exception:

                try {
                        return PackageInformationProvider.get(xComponentContext)
                                        .getPackageLocation(identifier);
                } catch (final java.lang.Exception e) {
                        Log.error(e);
                }

cause catching uno exceptions didn't work

found: Package Information Provider may deliver wrong urls
           https://issues.apache.org/ooo/show_bug.cgi?id=113752 ?

regards
Oliver

Am 24.02.2014 07:36 schrieb Keith Alcock:

>  OpenOffice API experts,
>
> I've inherited code for an OpenOffice extension in C++ that
> purportedly ran with a previous version of OpenOffice who knows how
> long ago.  The code is throwing an exception.  It is presently being
> built with Visual C++ 2008 and running under Windows 7, although I
> doubt that either of those is the problem.  By the time the exception
> is caught, it is of type com::sun::star::uno::Exception & with the
> message "[context="user"] caught unexpected exception!".  However,
> previous to that the debugger sees a
> com::sun::star::ucb::InteractiveAugmentedIOException, an 'anonymous
> namespace'::NoDescriptionException, a few
> com::sun::star::ucb::InteractiveAugmentedIOException's, and a
> com::sun::star::lang::WrappedTargetRuntimeException.
>
> The code is below.   I believe that it is preparing to load a graphic
> from the extension's installation directory.  Perhaps there is an
> alternate way to do that now.  Any and all help would be appreciated.
> Thanks.
>
> OUString getPathToExtensionRoot(const char* name) {
>     OUString ouName = OUString::createFromAscii(name);
>     // localContext seems to be good.  It can be used for other things.
>     Reference<XComponentContext> localContext =
>         defaultBootstrap_InitialComponentContext();
>     Reference<XPackageInformationProvider> xPackageInformationProvider =
>         PackageInformationProvider::get(localContext);
>     // The following line crashes as does any other call using ->
>     // xPackageInfoProvider.is() reports 1
>     try {
>         OUString path = xPackageInformationProvider->getPackageLocation(ouName);
>         return path;
>     }
>     catch (Exception &ex) {
>     }
>     return ouName; // just to return something
> }
>
> ---------------------------------------------------------------------
> 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: PackageInformationProvider::get() and subsequent Reference<XPackageInformationProvider>::getPackageLocation()

Ariel Constenla-Haile-2
In reply to this post by Keith Alcock
Hi Keith,

On Sun, Feb 23, 2014 at 11:36:41PM -0700, Keith Alcock wrote:

>  OpenOffice API experts,
>
> I've inherited code for an OpenOffice extension in C++ that
> purportedly ran with a previous version of OpenOffice who knows how
> long ago.  The code is throwing an exception.  It is presently being
> built with Visual C++ 2008 and running under Windows 7, although I
> doubt that either of those is the problem.  By the time the exception
> is caught, it is of type com::sun::star::uno::Exception & with the
> message "[context="user"] caught unexpected exception!".  However,
> previous to that the debugger sees a
> com::sun::star::ucb::InteractiveAugmentedIOException, an 'anonymous
> namespace'::NoDescriptionException, a few
> com::sun::star::ucb::InteractiveAugmentedIOException's, and a
> com::sun::star::lang::WrappedTargetRuntimeException.
>
> The code is below.   I believe that it is preparing to load a graphic
> from the extension's installation directory.  Perhaps there is an
> alternate way to do that now.  Any and all help would be appreciated.
> Thanks.
>
> OUString getPathToExtensionRoot(const char* name) {
>     OUString ouName = OUString::createFromAscii(name);
>     // localContext seems to be good.  It can be used for other things.
>     Reference<XComponentContext> localContext =
>         defaultBootstrap_InitialComponentContext();
>     Reference<XPackageInformationProvider> xPackageInformationProvider =
>         PackageInformationProvider::get(localContext);
>     // The following line crashes as does any other call using ->
>     // xPackageInfoProvider.is() reports 1
>     try {
>         OUString path = xPackageInformationProvider->getPackageLocation(ouName);
>         return path;
>     }
>     catch (Exception &ex) {
>     }
>     return ouName; // just to return something
> }
Is this code from a client application or from a extension?


Regards
--
Ariel Constenla-Haile
La Plata, Argentina

attachment0 (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: PackageInformationProvider::get() and subsequent Reference<XPackageInformationProvider>::getPackageLocation()

Keith Alcock
Ariel,

The code is from the extension itself.  I get the feeling that the
technique is not intended for that situation.

Keith


On Mon, Feb 24, 2014 at 5:21 AM, Ariel Constenla-Haile
<[hidden email]> wrote:

> Hi Keith,
>
> On Sun, Feb 23, 2014 at 11:36:41PM -0700, Keith Alcock wrote:
>>  OpenOffice API experts,
>>
>> I've inherited code for an OpenOffice extension in C++ that
>> purportedly ran with a previous version of OpenOffice who knows how
>> long ago.  The code is throwing an exception.  It is presently being
>> built with Visual C++ 2008 and running under Windows 7, although I
>> doubt that either of those is the problem.  By the time the exception
>> is caught, it is of type com::sun::star::uno::Exception & with the
>> message "[context="user"] caught unexpected exception!".  However,
>> previous to that the debugger sees a
>> com::sun::star::ucb::InteractiveAugmentedIOException, an 'anonymous
>> namespace'::NoDescriptionException, a few
>> com::sun::star::ucb::InteractiveAugmentedIOException's, and a
>> com::sun::star::lang::WrappedTargetRuntimeException.
>>
>> The code is below.   I believe that it is preparing to load a graphic
>> from the extension's installation directory.  Perhaps there is an
>> alternate way to do that now.  Any and all help would be appreciated.
>> Thanks.
>>
>> OUString getPathToExtensionRoot(const char* name) {
>>     OUString ouName = OUString::createFromAscii(name);
>>     // localContext seems to be good.  It can be used for other things.
>>     Reference<XComponentContext> localContext =
>>         defaultBootstrap_InitialComponentContext();
>>     Reference<XPackageInformationProvider> xPackageInformationProvider =
>>         PackageInformationProvider::get(localContext);
>>     // The following line crashes as does any other call using ->
>>     // xPackageInfoProvider.is() reports 1
>>     try {
>>         OUString path = xPackageInformationProvider->getPackageLocation(ouName);
>>         return path;
>>     }
>>     catch (Exception &ex) {
>>     }
>>     return ouName; // just to return something
>> }
>
> Is this code from a client application or from a extension?
>
>
> Regards
> --
> Ariel Constenla-Haile
> La Plata, Argentina

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

Reply | Threaded
Open this post in threaded view
|

Re: PackageInformationProvider::get() and subsequent Reference<XPackageInformationProvider>::getPackageLocation()

Ariel Constenla-Haile-2
Hi Keith,

On Mon, Feb 24, 2014 at 08:34:26AM -0700, Keith Alcock wrote:
> Ariel,
>
> The code is from the extension itself.  I get the feeling that the
> technique is not intended for that situation.

you are right

> >>     Reference<XComponentContext> localContext =
> >>         defaultBootstrap_InitialComponentContext();

your C++ extension has a DLL with one or more components, each component
is instantiated with a component context; do not bootstrap a component
context, just use the one the component is instantiated with.


Regards
--
Ariel Constenla-Haile
La Plata, Argentina

attachment0 (836 bytes) Download Attachment