Hi Wei Min,

On 11/16/09 08:01, Wei Min Teo wrote:

Hi,
Thanks for your reply. I hope you don't mind me replying you directly, dun wanna spam the dev board because i'm really confused how the interactionhandler works. In any case, it seems that to use the handler, i'll have to code the class, much like the QuietInteraction example, create an the object and pass it in as a property value in loadcomponentfromurl. It seems that if this is the case, i'll lose all the default implementation of the default interaction handler.

As I understood, you are using loadComponentFromURL() without providing InteractionHandler currently. That means that the implementation uses QuietInteraction per default. So if you provid an own implementation based on the QuietInteraction you will not lose any functionality at all.

I see. This means that QuietInteraction is the same as the default implementation?

In this scenario yes.
And even if it changes in future, the implementation does exactly what you need as I understood. You can submit a new enhancement issue to me ( m...@openoffice.org ) to let QuietInteraction be available as a service. This would allow to implement an easy wrapper around it, and all the changes for the handler that might be done in future would be used by your implementation as well. But that can be done only for OOo3.3 release unfortunately. For now you have to copy the source code.

    It is also really complicated for me to implement as i'm not that
    experienced a programmer.


I must confess, that I do not see an easier solution in this case than to implement own interaction handler based on the example. All you need is to copy the implementation ( probably translate it to your programming language ), and add the check for the DocumentPasswordRequest. And the best way to learn is to try.

I still have yet to try the implementation, will give it a go. I still hope that it's possible to detect the password event without such an implementation.

As I have mentioned there are other possibilities to do it, but they are more complex from my point of view.
For example you could do the following:
- do the TypeDetection yourself
- create the related to the detected type model object
- load the contents to the model using XLoadable::load() method

The mentioned method returns the exception with the error-code. Unfortunately the error-codes are not specified as the part of the UNO-API, although they are stable enough from my point of view. So, in addition to complexity, it is not a completely clean way.

My situation is that i'm trying to do some automation, and the
    password dialogbox would pop out if i open a document with
    password. Thus, I pass an arbitrary password to prevent the
dialogbox from poping out.

I must confess, that I am confused to hear that you get the password dialog while calling loadComponentFromURL() without InteractionHandler. If it is happens, it is a bug. Can you reproduce it? You are right. The password dialog is not displayed. However, if I pass in the Hidden flag for mediadescriptor, there is a dialog that pops out momentarily and disappears. This does not happen when an arbituary password is passed. I guess this isn't really crucial.

Any dialog in hidden mode is a bug. But since the dialog disappears itself it is not so problematic, because the main idea of hidden mode is to avoid necessity of user input. Anyway, if you can reproduce it please submit a new issue for this, you can send it to me ( m...@openoffice.org ).


    However, I would like to capture when this happens. I am fine with
    default interactionhandler's exception handling. I just want to
    know which files are password protected. Any way i can detect such
    an event without implementing the handler?


The way you are doing it currently ( with wrong password ) is not quite correct. The problem is that it is not defined, what should happen in case a password is provided to a non-encrypted document. It could happen that the behavior changes in future ( the loading process could fail in future if non-encrypted document would be loaded with password ), then the implementation would have problems. Passing a random password does not seem to affect non-encrypted documents.
I did not write that the random password affects non-encrypted documents. I mean that it does not affect the documents by luck, it is an implementation detail that can be changed any time.

Best regards,
Mikhail.

Cheers, Wei Min
------------------------------------------------------------------------
Date: Mon, 9 Nov 2009 09:06:21 +0100
From: mikhail.voyte...@sun.com
Subject: Re: [api-dev] password protected files
To: shaun...@hotmail.com; dev@framework.openoffice.org

Hi Wei Min,

it is always better to discuss questions on the mailing lists, since the discussion might be interesting for other developers. Moreover, since more developers would see your questions on the list, the probability to get better answer is also much bigger.

On 11/09/09 07:52, Wei Min Teo wrote:

    Hi Mikhail,
Thanks for your reply. I hope you don't mind me replying you
    directly, dun wanna spam the dev board because i'm really confused
    how the interactionhandler works. In any case, it seems that to
    use the handler, i'll have to code the class, much like
    the QuietInteraction example, create an the object and pass it in
    as a property value in loadcomponentfromurl. It seems that if this
    is the case, i'll lose all the default implementation of the
    default interaction handler.


As I understood, you are using loadComponentFromURL() without providing InteractionHandler currently. That means that the implementation uses QuietInteraction per default. So if you provid an own implementation based on the QuietInteraction you will not lose any functionality at all.

    It is also really complicated for me to implement as i'm not that
    experienced a programmer.


I must confess, that I do not see an easier solution in this case than to implement own interaction handler based on the example. All you need is to copy the implementation ( probably translate it to your programming language ), and add the check for the DocumentPasswordRequest. And the best way to learn is to try.

My situation is that i'm trying to do some automation, and the
    password dialogbox would pop out if i open a document with
    password. Thus, I pass an arbitrary password to prevent the
dialogbox from poping out.

I must confess, that I am confused to hear that you get the password dialog while calling loadComponentFromURL() without InteractionHandler. If it is happens, it is a bug. Can you reproduce it?

    However, I would like to capture when this happens. I am fine with
    default interactionhandler's exception handling. I just want to
    know which files are password protected. Any way i can detect such
    an event without implementing the handler?


The way you are doing it currently ( with wrong password ) is not quite correct. The problem is that it is not defined, what should happen in case a password is provided to a non-encrypted document. It could happen that the behavior changes in future ( the loading process could fail in future if non-encrypted document would be loaded with password ), then the implementation would have problems.

Best regards,
Mikhail.

Sorry for the lengthy explanation. Once again, Thanks for your help. Cheers, Wei Min > Date: Thu, 5 Nov 2009 10:56:44 +0100
    > From: mikhail.voyte...@sun.com <mailto:mikhail.voyte...@sun.com>
    > To: d...@api.openoffice.org <mailto:d...@api.openoffice.org>
    > Subject: Re: [api-dev] password protected files
    >
    > Hi Wei Min,
    >
    > On 11/05/09 03:22, Wei Min Teo wrote:
    > > Hi Mikhail,
    > >
    > >
    > >
    > > Thanks for the reply. You're right, i'm using
    loadComponentFromURL().
    > >
    > >
    > >
    > > How can i code a simple interactionhandler to detect the
    password event?
    >
    > The InteractionHandler argument is mentioned in the following
    article:
    >
    
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/Handling_Documents
    >
    > As it is mentioned there you should just implement the
    > com.sun.star.task.InteractionHandler service.
    >
    
http://api.openoffice.org/docs/common/ref/com/sun/star/task/InteractionHandler.html
    >
    >
    >! >
    > > If this is the only case i implement the interactionhandler to
    handle, will all other cases run through the default
    interactionhandler to throw the default exceptions?
    > >
    >
    > Please see the following sourcecode as an example of a simple
    > InteractionHandler that does not show any UI.
    >
    
http://svn.services.openoffice.org/opengrok/xref/DEV300_m60/framework/source/interaction/quietinteraction.cxx
    >
    > Your implementation could look similar and additionally it could
    > remember whether com.sun.star.task.DocumentPasswordRequest was done.
    > This request is done in case an encrypted document is loaded to
    get the
    > password.
    >
    > Hope that helps.
    >
    > Best regards,
    > Mikhail.
    >
    > >
    > >
    > > Thanks.
    > >
    > >
    > >
    > > Cheers,
    > >
    > >
    > >
    > > Wei Min
    > >! ;
    > >> Date: Wed, 4 Nov 2009 13:15:14 +0100
    > >& gt; From: mikhail.voyte...@sun.com
    <mailto:mikhail.voyte...@sun.com>
    > >> To: d...@api.openoffice.org <mailto:d...@api.openoffice.org>
    > >> Subject: Re: [api-dev] password protected files
    > >>
    > >> Hi Wei Min,
    > >>
    > >> it depends from the API you are using.
    > >>
    > >> I suspect that you are using loadComponentFromURL(), in this
    case you
    > >> can provide the InteractionHandler in the MediaDescriptor, the
    > >> InteractionHandler would handle the document password request
    in this case.
    > >>
    > >> If the standard InteractionHandler implementation is provided
    to the
    > >> call, the password dialog would be shown to user. You can
    also provide
    > >> an own simple InteractionHandler implementation, that could
    for example
    > >> detect whether document password request was done on loading
    ( that
    > >> means that the document is encrypted one ). In the same way
    other> >> problems during the loading could be handled.
    > >>
    > >> Hope that helps.
    > >>
    > >> Best regards,
    > >> Mikhail.
    > >>
    > >>
    > >> On 11/04/09 11:05, Wei Min Teo wrote:
    > >>> Hi,
    > >>>
    > >>>
    > >>>
    > >>> I was wondering if there's any way to identify password
    protected files before opening it?
    > >>>
    > >>>
    > >>>
    > >>> It doesn't seem to throw an aIOException or
    illegalArgumentException. It just seems to fail XComponent.is().
    The thing is that this could fail due to other reasons.
    > >>>
    > >>>
    > >>>
    > >>>
    > >>>
    > >>>
    > >>>
    > >>>
    > >>>
    > >>> Cheers,
    > >>>
    > >>>> >>>
    > >>> Wei Min
    > >>>< BR>> >>>
    > >>>
    > >>>
    > >>>
    > >>>
    _________________________________________________________________
    > >>> New Windows 7: Find the right PC for you. Learn more.
    > >>> http://windows.microsoft.com/shop
    > >>>
    > >>
    ---------------------------------------------------------------------
    > >> To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
    <mailto:dev-unsubscr...@api.openoffice.org>
    > >> For additional commands, e-mail: dev-h...@api.openoffice.org
    <mailto:dev-h...@api.openoffice.org>
    > >>
    > >
    > > _________________________________________________________________
    > > New Windows 7: Find the right PC for you. Learn more.
    > > http://windows.microsoft.com/shop
    > >
    >
    >
    ---------------------------------------------------------------------
    > To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
    <mailto:dev-unsubscr...@api.openoffice.org>
    > For additional commands, e! -mail: dev-h...@api.openoffice.org
    <mailto:dev-h...@api.openoffice.org>
    >

    ------------------------------------------------------------------------
    Windows 7: Simplify what you do everyday. Find the right PC for
    you. <http://windows.microsoft.com/shop>



--
Sun Microsystems GmbH                Mikhail Voytenko
Nagelsweg 55                         Software Engineer
20097 Hamburg                        Phone: (+49 40)23646 500
Germany                              Fax:   (+49 40)23646 550
http://www.sun.de <http://www.sun.de/>                    
mailto:mikhail.voyte...@sun.com

Sitz der Gesellschaft:
Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten
Amtsgericht München: HRB 161028
Geschäftsführer: Thomas Schröder, Wolfgang Engels, Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin Häring

------------------------------------------------------------------------
New Windows 7: Simplify what you do everyday. Find the right PC for you. <http://windows.microsoft.com/shop>


--
Sun Microsystems GmbH                Mikhail Voytenko
Nagelsweg 55                         Software Engineer
20097 Hamburg                        Phone: (+49 40)23646 500
Germany                              Fax:   (+49 40)23646 550
http://www.sun.de                    mailto:mikhail.voyte...@sun.com

Sitz der Gesellschaft:
Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten
Amtsgericht München: HRB 161028
Geschäftsführer: Thomas Schröder, Wolfgang Engels, Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin Häring


Reply via email to