Return-Path: X-Original-To: apmail-openoffice-dev-archive@www.apache.org Delivered-To: apmail-openoffice-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D1DC3106C8 for ; Thu, 20 Jun 2013 07:18:54 +0000 (UTC) Received: (qmail 95787 invoked by uid 500); 20 Jun 2013 07:18:53 -0000 Delivered-To: apmail-openoffice-dev-archive@openoffice.apache.org Received: (qmail 95644 invoked by uid 500); 20 Jun 2013 07:18:52 -0000 Mailing-List: contact dev-help@openoffice.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openoffice.apache.org Delivered-To: mailing list dev@openoffice.apache.org Received: (qmail 95622 invoked by uid 99); 20 Jun 2013 07:18:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Jun 2013 07:18:51 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of rajaths.rajaths@gmail.com designates 209.85.219.45 as permitted sender) Received: from [209.85.219.45] (HELO mail-oa0-f45.google.com) (209.85.219.45) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Jun 2013 07:18:43 +0000 Received: by mail-oa0-f45.google.com with SMTP id j1so7623203oag.18 for ; Thu, 20 Jun 2013 00:18:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=j1lDdAiqzBc60pGyFV5LUtOir6U9HaWFOh3OpRAeF2U=; b=J05gjh5hEp28nTf2TaUL+rw9Y7WGpkS8dTbrvkn7XAdn3k7/pzcraXt5zf/1Qhs4Xf l01susCNWFDy5wEl77d2RfD2SgHeh0UL1I3iCM8kWrFZGoCyLLaAhvh+DpK6F2Nj/RL/ O9Y1wVVC/OF+RBgqKdscCBJnCfppouVsR08nTqtxFcNfooXPIOHsKXQt6x1qerW/CmIl EN8m2Y6lPnj+O0DXuiYQj0V4itfBIcCiBaIJXAxe1guwbTgTbGflUYnaDr7KUQ+xEnGN KCPQX7J6lfAVrttQ/aoDJNzHFjpbrK8GSoqZH65r7NlfgPbibgt0JR3S5QFkcOgnau5D Aaxw== MIME-Version: 1.0 X-Received: by 10.60.146.242 with SMTP id tf18mr3635894oeb.115.1371712702603; Thu, 20 Jun 2013 00:18:22 -0700 (PDT) Received: by 10.76.113.228 with HTTP; Thu, 20 Jun 2013 00:18:22 -0700 (PDT) In-Reply-To: References: <20130619193821.GA12750@localhost> Date: Thu, 20 Jun 2013 12:48:22 +0530 Message-ID: Subject: Re: OpenCommandArgument2 Data Sink From: Rajath Shashidhara To: dev Content-Type: multipart/alternative; boundary=047d7b5d34165f69dd04df90c0a8 X-Virus-Checked: Checked by ClamAV on apache.org --047d7b5d34165f69dd04df90c0a8 Content-Type: text/plain; charset=ISO-8859-1 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 > 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 --047d7b5d34165f69dd04df90c0a8--