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. Ihope you don't mind me replying you directly, > dun wanna spam the dev boardbecause i'm really confused how the > interactionhandlerworks. In any case, it seems thatto usethe handler, > i'll have to code the class, much like theQuietInteraction example, > create anthe object and pass it in as a property value in > loadcomponentfromurl. It seemsthat if this is the case, i'll lose all > the default implementationof 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. > > Mysituation is that i'm trying to do some automation, and the password > dialogbox would popout 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 tocapture 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: [email protected] > > To: [email protected] > > 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: [email protected] > > >> To: [email protected] > > >> 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: [email protected] > > >> For additional commands, e-mail: [email protected] > > >> > > > > > > _________________________________________________________________ > > > New Windows 7: Find the right PC for you. Learn more. > > > http://windows.microsoft.com/shop > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e! -mail: [email protected] > > > > ------------------------------------------------------------------------ > 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:[email protected] Sitz der Gesellschaft: Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten Amtsgericht München: HRB 161028 Gescha"ftsführer: Thomas Schro"der, Wolfgang Engels, Wolf Frenkel Vorsitzender des Aufsichtsrates: Martin Ha"ring
