openoffice-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From J├╝rgen Schmidt <jogischm...@gmail.com>
Subject Re: OpenCommandArgument2 Data Sink
Date Thu, 20 Jun 2013 08:57:44 GMT
On 6/20/13 10:26 AM, Rajath Shashidhara wrote:
> Can I use this?
> http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/IOUtils.html

in principal yes, just try if it fulfill your needs.

Juergen

> 
> 
> On Thu, Jun 20, 2013 at 12:48 PM, Rajath Shashidhara <
> rajaths.rajaths@gmail.com> wrote:
> 
>> Hello Ariel,
>>
>> in you code:
>> copyStream() is to be implemented by me or is it there in any library?
>>
>>
>> On Thu, Jun 20, 2013 at 9:25 AM, Rajath Shashidhara <
>> rajaths.rajaths@gmail.com> wrote:
>>
>>> Thanks ariel.
>>> I have finished major part of this code. I only had doubt in that
>>> queryInterface part.
>>>
>>>
>>> On Thu, Jun 20, 2013 at 1:08 AM, Ariel Constenla-Haile <
>>> arielch@apache.org> wrote:
>>>
>>>> Hi Rajath,
>>>>
>>>> On Wed, Jun 19, 2013 at 09:55:21PM +0530, Rajath Shashidhara wrote:
>>>>> Hello,
>>>>>
>>>>> I'm working on the XActiveDataSink.
>>>>> I'm slightly confused about how to handle OpenCommandArgument2.Sink .
>>>>> The object is the one which is filled with the XActiveDataSink object
>>>> for
>>>>> which I have to set the InputStream by calling setInputStream() and
>>>> pass
>>>>> the XInputStream implementation.
>>>>> This is what I have understood. But, the confusing thing is why  is the
>>>>> datatype for Sink - Object? Shoudnt it be XActiveDataSink? I'm not
>>>>> understanding how to handle this Sink.
>>>>
>>>> The OpenCommandArgument2.Sink can be of different kinds, that's why its
>>>> type is defined in a generic way as css.uno.XInterface; this interface
>>>> is the base interface of all other interfaces:
>>>>
>>>> http://www.openoffice.org/api/docs/common/ref/com/sun/star/ucb/OpenCommandArgument.html#Sink
>>>>
>>>> css.uno.XInterface, in this case, is mapped in the Jave bridge to
>>>> java.lang.Object:
>>>>
>>>> http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Java/Mapping_of_Interface_Types
>>>>
>>>> You have to find out if the sink is
>>>>
>>>> a) com.sun.star.io.XOutputStream
>>>> b) com.sun.star.io.XActiveDataSink
>>>> c) com.sun.star.io.XActiveDataStreamer
>>>>
>>>> simply query the sink for each interface. Something like this:
>>>>
>>>>
>>>> private Object open(
>>>>         com.sun.star.ucb.OpenCommandArgument2 aOpenCommand,
>>>>         com.sun.star.ucb.XCommandEnvironment xEnvironment)
>>>>         throws com.sun.star.uno.Exception {
>>>>     Object oRet = com.sun.star.uno.Any.VOID;
>>>>
>>>>     int nOpenMode = aOpenCommand.Mode;
>>>>     if (nOpenMode == com.sun.star.ucb.OpenMode.ALL
>>>>             || nOpenMode == com.sun.star.ucb.OpenMode.DOCUMENTS
>>>>             || nOpenMode == com.sun.star.ucb.OpenMode.FOLDERS) {
>>>>         if (!isFolder(xEnvironment)) {
>>>>             throw new com.sun.star.lang.IllegalArgumentException(
>>>>                     "The content is not a folder!");
>>>>         }
>>>>         com.sun.star.ucb.XDynamicResultSet xResultSet = new
>>>> DynamicResultSet(
>>>>                 m_xContext, this, aOpenCommand, xEnvironment);
>>>>         oRet = xResultSet;
>>>>     } else if (nOpenMode == com.sun.star.ucb.OpenMode.DOCUMENT) {
>>>>         Object aSink = aOpenCommand.Sink;
>>>>         if (aSink == null) {
>>>>             throw new com.sun.star.lang.IllegalArgumentException(
>>>>                     "open command without sink!");
>>>>         }
>>>>         // the Sink can be
>>>>         // a) com.sun.star.io.XOutputStream
>>>>         // b) com.sun.star.io.XActiveDataSink
>>>>         // c) com.sun.star.io.XActiveDataStreamer
>>>>         com.sun.star.io.XActiveDataStreamer xActiveDataStreamer =
>>>> UnoRuntime.queryInterface(
>>>>                 com.sun.star.io.XActiveDataStreamer.class, aSink);
>>>>         if (xActiveDataStreamer != null) {
>>>>             com.sun.star.io.XStream xStream =
>>>> getContentStream(xEnvironment);
>>>>             xActiveDataStreamer.setStream(xStream);
>>>>         } else {
>>>>             com.sun.star.io.XOutputStream xOutputStream =
>>>> UnoRuntime.queryInterface(
>>>>                     com.sun.star.io.XOutputStream.class, aSink);
>>>>             if (xOutputStream != null) {
>>>>                 com.sun.star.io.XInputStream xInputStream =
>>>> getContentInputStream(xEnvironment);
>>>>                 copyStream(xInputStream, xOutputStream);
>>>>             } else {
>>>>                 com.sun.star.io.XActiveDataSink xActiveDataSink =
>>>> UnoRuntime.queryInterface(
>>>>                         com.sun.star.io.XActiveDataSink.class, aSink);
>>>>                 if (xActiveDataSink == null) {
>>>>                     throw new com.sun.star.lang.IllegalArgumentException(
>>>>                             "open command's sink is neither
>>>> XActiveDataStreamer, XOutputStream nor XActiveDataSink!");
>>>>                 }
>>>>                 com.sun.star.io.XInputStream xInputStream =
>>>> getContentInputStream(xEnvironment);
>>>>                 xActiveDataSink.setInputStream(xInputStream);
>>>>             }
>>>>         }
>>>>     } else if (nOpenMode ==
>>>> com.sun.star.ucb.OpenMode.DOCUMENT_SHARE_DENY_NONE ||
>>>>             nOpenMode ==
>>>> com.sun.star.ucb.OpenMode.DOCUMENT_SHARE_DENY_WRITE){
>>>>         throw new UnsupportedCommandException();
>>>>     }
>>>>     return oRet;
>>>> }
>>>>
>>>>
>>>>
>>>> Regards
>>>> --
>>>> Ariel Constenla-Haile
>>>> La Plata, Argentina
>>>>
>>>
>>>
>>>
>>> --
>>> Rajath S,
>>> M.Sc(Hons.) Physics,
>>> Birla Institute of Technology and Science - Pilani,
>>> Pilani
>>>
>>
>>
>>
>> --
>> Rajath S,
>> M.Sc(Hons.) Physics,
>> Birla Institute of Technology and Science - Pilani,
>> Pilani
>>
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@openoffice.apache.org
For additional commands, e-mail: dev-help@openoffice.apache.org


Mime
View raw message