1*76b6b121SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*76b6b121SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*76b6b121SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*76b6b121SAndrew Rist * distributed with this work for additional information 6*76b6b121SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*76b6b121SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*76b6b121SAndrew Rist * "License"); you may not use this file except in compliance 9*76b6b121SAndrew Rist * with the License. You may obtain a copy of the License at 10*76b6b121SAndrew Rist * 11*76b6b121SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*76b6b121SAndrew Rist * 13*76b6b121SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*76b6b121SAndrew Rist * software distributed under the License is distributed on an 15*76b6b121SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*76b6b121SAndrew Rist * KIND, either express or implied. See the License for the 17*76b6b121SAndrew Rist * specific language governing permissions and limitations 18*76b6b121SAndrew Rist * under the License. 19*76b6b121SAndrew Rist * 20*76b6b121SAndrew Rist *************************************************************/ 21*76b6b121SAndrew Rist 22*76b6b121SAndrew Rist 23cdf0e10cSrcweir package complex.loadAllDocuments; 24cdf0e10cSrcweir 25cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 26cdf0e10cSrcweir import com.sun.star.ucb.XSimpleFileAccess; 27cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 28cdf0e10cSrcweir 29cdf0e10cSrcweir /** 30cdf0e10cSrcweir * Simulates an input and output stream and 31cdf0e10cSrcweir * implements the interfaces XInputStream, XOutputStream. 32cdf0e10cSrcweir * So it can be used for testing loading/saving of documents 33cdf0e10cSrcweir * using streams instead of URLs. 34cdf0e10cSrcweir */ 35cdf0e10cSrcweir public class StreamSimulator implements com.sun.star.io.XInputStream , 36cdf0e10cSrcweir com.sun.star.io.XOutputStream , 37cdf0e10cSrcweir com.sun.star.io.XSeekable 38cdf0e10cSrcweir { 39cdf0e10cSrcweir //_________________________________ 40cdf0e10cSrcweir /** 41cdf0e10cSrcweir * @member m_sFileName name of the corrsponding file on disk 42cdf0e10cSrcweir * @member m_xInStream the internal input stream for reading 43cdf0e10cSrcweir * @member m_xOutStream the internal input stream for writing 44cdf0e10cSrcweir * @member m_xSeek points at runtime to m_xInStream or m_xOutStream and make it seekable 45cdf0e10cSrcweir * 46cdf0e10cSrcweir * @member m_bInWasUsed indicates, that the input stream interface was used 47cdf0e10cSrcweir * @member m_bOutWasUsed indicates, that the output stream interface was used 48cdf0e10cSrcweir */ 49cdf0e10cSrcweir 50cdf0e10cSrcweir private String m_sFileName ; 51cdf0e10cSrcweir private com.sun.star.io.XInputStream m_xInStream ; 52cdf0e10cSrcweir private com.sun.star.io.XOutputStream m_xOutStream ; 53cdf0e10cSrcweir private com.sun.star.io.XSeekable m_xSeek ; 54cdf0e10cSrcweir 55cdf0e10cSrcweir public boolean m_bInWasUsed ; 56cdf0e10cSrcweir public boolean m_bOutWasUsed ; 57cdf0e10cSrcweir 58cdf0e10cSrcweir /** 59cdf0e10cSrcweir * construct a new instance of this class 60cdf0e10cSrcweir * It set the name of the correspojnding file on disk, which 61cdf0e10cSrcweir * should be source or target for the following operations on 62cdf0e10cSrcweir * this object. And it regulate if it should function as 63cdf0e10cSrcweir * input or output stream. 64cdf0e10cSrcweir * 65cdf0e10cSrcweir * @param sFileName 66cdf0e10cSrcweir * name of the file on disk 67cdf0e10cSrcweir * Will be used as source (if param bInput==true) 68cdf0e10cSrcweir * or as target (if param bInput==false). 69cdf0e10cSrcweir * 70cdf0e10cSrcweir * @param bInput 71cdf0e10cSrcweir * it specify, which interface should work at this object. 72cdf0e10cSrcweir * <TRUE/> => we simulate an input stream 73cdf0e10cSrcweir * <FALSE/> => we simulate an output stream 74cdf0e10cSrcweir * 75cdf0e10cSrcweir * @throw com.sun.star.io.NotConnectedException 76cdf0e10cSrcweir * in case the internal streams to the file on disk couldn't 77cdf0e10cSrcweir * be established. 78cdf0e10cSrcweir * They are neccessary. Otherwhise this simulator can't 79cdf0e10cSrcweir * really work. 80cdf0e10cSrcweir */ StreamSimulator(XMultiServiceFactory xMSF, String sFileName, boolean bInput)81cdf0e10cSrcweir public StreamSimulator(XMultiServiceFactory xMSF, 82cdf0e10cSrcweir String sFileName, boolean bInput) 83cdf0e10cSrcweir throws com.sun.star.io.NotConnectedException 84cdf0e10cSrcweir { 85cdf0e10cSrcweir m_sFileName = sFileName ; 86cdf0e10cSrcweir m_bInWasUsed = false ; 87cdf0e10cSrcweir m_bOutWasUsed = false ; 88cdf0e10cSrcweir 89cdf0e10cSrcweir try 90cdf0e10cSrcweir { 91cdf0e10cSrcweir XSimpleFileAccess xHelper = (XSimpleFileAccess) 92cdf0e10cSrcweir UnoRuntime.queryInterface(XSimpleFileAccess.class, 93cdf0e10cSrcweir xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess")); 94cdf0e10cSrcweir 95cdf0e10cSrcweir if (xHelper == null) 96cdf0e10cSrcweir throw new com.sun.star.io.NotConnectedException( 97cdf0e10cSrcweir "ucb helper not available. Can't create streams."); 98cdf0e10cSrcweir 99cdf0e10cSrcweir if (bInput) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir m_xInStream = xHelper.openFileRead(m_sFileName); 102cdf0e10cSrcweir m_xSeek = (com.sun.star.io.XSeekable)UnoRuntime.queryInterface( 103cdf0e10cSrcweir com.sun.star.io.XSeekable.class, 104cdf0e10cSrcweir m_xInStream); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir else 107cdf0e10cSrcweir { 108cdf0e10cSrcweir m_xOutStream = xHelper.openFileWrite(m_sFileName); 109cdf0e10cSrcweir m_xSeek = (com.sun.star.io.XSeekable)UnoRuntime.queryInterface( 110cdf0e10cSrcweir com.sun.star.io.XSeekable.class, 111cdf0e10cSrcweir m_xOutStream); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir } 114cdf0e10cSrcweir catch(com.sun.star.uno.Exception exUno) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir throw new com.sun.star.io.NotConnectedException( 117cdf0e10cSrcweir "Could not open the file."); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir /** 122cdf0e10cSrcweir * following methods simulates the XInputStream. 123cdf0e10cSrcweir * The notice all actions inside the internal protocol 124cdf0e10cSrcweir * and try to map all neccessary functions to the internal 125cdf0e10cSrcweir * open in-stream. 126cdf0e10cSrcweir */ readBytes(byte[][] lData, int nBytesToRead )127cdf0e10cSrcweir public int readBytes(byte[][] lData, int nBytesToRead ) 128cdf0e10cSrcweir throws com.sun.star.io.NotConnectedException, 129cdf0e10cSrcweir com.sun.star.io.BufferSizeExceededException, 130cdf0e10cSrcweir com.sun.star.io.IOException 131cdf0e10cSrcweir { 132cdf0e10cSrcweir m_bInWasUsed = true; 133cdf0e10cSrcweir 134cdf0e10cSrcweir if (m_xInStream == null) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir throw new com.sun.star.io.NotConnectedException("stream not open"); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir int nRead = 0; 140cdf0e10cSrcweir try 141cdf0e10cSrcweir { 142cdf0e10cSrcweir nRead = m_xInStream.readBytes(lData,nBytesToRead); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir catch (com.sun.star.io.NotConnectedException exConnect) { 145cdf0e10cSrcweir } 146cdf0e10cSrcweir catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { 147cdf0e10cSrcweir } 148cdf0e10cSrcweir catch (com.sun.star.io.IOException exIO ) { 149cdf0e10cSrcweir } 150cdf0e10cSrcweir catch (com.sun.star.uno.RuntimeException exRuntime) { 151cdf0e10cSrcweir } 152cdf0e10cSrcweir catch (com.sun.star.uno.Exception exUno ) { 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir 156cdf0e10cSrcweir return nRead; 157cdf0e10cSrcweir } 158cdf0e10cSrcweir readSomeBytes(byte[][] lData, int nMaxBytesToRead)159cdf0e10cSrcweir public int readSomeBytes(byte[][] lData, int nMaxBytesToRead) 160cdf0e10cSrcweir throws com.sun.star.io.NotConnectedException, 161cdf0e10cSrcweir com.sun.star.io.BufferSizeExceededException , 162cdf0e10cSrcweir com.sun.star.io.IOException 163cdf0e10cSrcweir { 164cdf0e10cSrcweir m_bInWasUsed = true; 165cdf0e10cSrcweir 166cdf0e10cSrcweir if (m_xInStream == null) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir throw new com.sun.star.io.NotConnectedException("stream not open"); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir int nRead = 0; 172cdf0e10cSrcweir try 173cdf0e10cSrcweir { 174cdf0e10cSrcweir nRead = m_xInStream.readSomeBytes(lData,nMaxBytesToRead); 175cdf0e10cSrcweir } 176cdf0e10cSrcweir catch (com.sun.star.io.NotConnectedException exConnect) { 177cdf0e10cSrcweir } 178cdf0e10cSrcweir catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { 179cdf0e10cSrcweir } 180cdf0e10cSrcweir catch (com.sun.star.io.IOException exIO ) { 181cdf0e10cSrcweir } 182cdf0e10cSrcweir catch (com.sun.star.uno.RuntimeException exRuntime) { 183cdf0e10cSrcweir } 184cdf0e10cSrcweir catch (com.sun.star.uno.Exception exUno ) { 185cdf0e10cSrcweir } 186cdf0e10cSrcweir 187cdf0e10cSrcweir return nRead; 188cdf0e10cSrcweir } 189cdf0e10cSrcweir 190cdf0e10cSrcweir //_________________________________ 191cdf0e10cSrcweir skipBytes(int nBytesToSkip)192cdf0e10cSrcweir public void skipBytes(int nBytesToSkip) 193cdf0e10cSrcweir throws com.sun.star.io.NotConnectedException, 194cdf0e10cSrcweir com.sun.star.io.BufferSizeExceededException , 195cdf0e10cSrcweir com.sun.star.io.IOException 196cdf0e10cSrcweir { 197cdf0e10cSrcweir m_bInWasUsed = true; 198cdf0e10cSrcweir 199cdf0e10cSrcweir if (m_xInStream == null) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir throw new com.sun.star.io.NotConnectedException("stream not open"); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir try 205cdf0e10cSrcweir { 206cdf0e10cSrcweir m_xInStream.skipBytes(nBytesToSkip); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir catch (com.sun.star.io.NotConnectedException exConnect) { 209cdf0e10cSrcweir } 210cdf0e10cSrcweir catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { 211cdf0e10cSrcweir } 212cdf0e10cSrcweir catch (com.sun.star.io.IOException exIO ) { 213cdf0e10cSrcweir } 214cdf0e10cSrcweir catch (com.sun.star.uno.RuntimeException exRuntime) { 215cdf0e10cSrcweir } 216cdf0e10cSrcweir catch (com.sun.star.uno.Exception exUno ) { 217cdf0e10cSrcweir } 218cdf0e10cSrcweir 219cdf0e10cSrcweir } 220cdf0e10cSrcweir available()221cdf0e10cSrcweir public int available() throws com.sun.star.io.NotConnectedException, 222cdf0e10cSrcweir com.sun.star.io.IOException 223cdf0e10cSrcweir { 224cdf0e10cSrcweir m_bInWasUsed = true; 225cdf0e10cSrcweir 226cdf0e10cSrcweir if (m_xInStream == null) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir throw new com.sun.star.io.NotConnectedException("stream not open"); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir int nAvailable = 0; 232cdf0e10cSrcweir try 233cdf0e10cSrcweir { 234cdf0e10cSrcweir nAvailable = m_xInStream.available(); 235cdf0e10cSrcweir } 236cdf0e10cSrcweir catch (com.sun.star.io.NotConnectedException exConnect) { 237cdf0e10cSrcweir } 238cdf0e10cSrcweir catch (com.sun.star.io.IOException exIO ) { 239cdf0e10cSrcweir } 240cdf0e10cSrcweir catch (com.sun.star.uno.RuntimeException exRuntime) { 241cdf0e10cSrcweir } 242cdf0e10cSrcweir catch (com.sun.star.uno.Exception exUno ) { 243cdf0e10cSrcweir } 244cdf0e10cSrcweir 245cdf0e10cSrcweir return nAvailable; 246cdf0e10cSrcweir } 247cdf0e10cSrcweir 248cdf0e10cSrcweir //_________________________________ 249cdf0e10cSrcweir closeInput()250cdf0e10cSrcweir public void closeInput() throws com.sun.star.io.NotConnectedException, 251cdf0e10cSrcweir com.sun.star.io.IOException 252cdf0e10cSrcweir { 253cdf0e10cSrcweir m_bInWasUsed = true; 254cdf0e10cSrcweir 255cdf0e10cSrcweir if (m_xInStream == null) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir throw new com.sun.star.io.NotConnectedException("stream not open"); 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir try 261cdf0e10cSrcweir { 262cdf0e10cSrcweir m_xInStream.closeInput(); 263cdf0e10cSrcweir } 264cdf0e10cSrcweir catch (com.sun.star.io.NotConnectedException exConnect) { 265cdf0e10cSrcweir } 266cdf0e10cSrcweir catch (com.sun.star.io.IOException exIO ) { 267cdf0e10cSrcweir } 268cdf0e10cSrcweir catch (com.sun.star.uno.RuntimeException exRuntime) { 269cdf0e10cSrcweir } 270cdf0e10cSrcweir catch (com.sun.star.uno.Exception exUno ) { 271cdf0e10cSrcweir } 272cdf0e10cSrcweir 273cdf0e10cSrcweir } 274cdf0e10cSrcweir 275cdf0e10cSrcweir /** 276cdf0e10cSrcweir * following methods simulates the XOutputStream. 277cdf0e10cSrcweir * The notice all actions inside the internal protocol 278cdf0e10cSrcweir * and try to map all neccessary functions to the internal 279cdf0e10cSrcweir * open out-stream. 280cdf0e10cSrcweir */ writeBytes(byte[] lData)281cdf0e10cSrcweir public void writeBytes(byte[] lData) 282cdf0e10cSrcweir throws com.sun.star.io.NotConnectedException, 283cdf0e10cSrcweir com.sun.star.io.BufferSizeExceededException , 284cdf0e10cSrcweir com.sun.star.io.IOException 285cdf0e10cSrcweir { 286cdf0e10cSrcweir m_bOutWasUsed = true; 287cdf0e10cSrcweir 288cdf0e10cSrcweir if (m_xOutStream == null) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir throw new com.sun.star.io.NotConnectedException("stream not open"); 291cdf0e10cSrcweir } 292cdf0e10cSrcweir 293cdf0e10cSrcweir try 294cdf0e10cSrcweir { 295cdf0e10cSrcweir m_xOutStream.writeBytes(lData); 296cdf0e10cSrcweir } 297cdf0e10cSrcweir catch (com.sun.star.io.NotConnectedException exConnect) { 298cdf0e10cSrcweir } 299cdf0e10cSrcweir catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { 300cdf0e10cSrcweir } 301cdf0e10cSrcweir catch (com.sun.star.io.IOException exIO ) { 302cdf0e10cSrcweir } 303cdf0e10cSrcweir catch (com.sun.star.uno.RuntimeException exRuntime) { 304cdf0e10cSrcweir } 305cdf0e10cSrcweir catch (com.sun.star.uno.Exception exUno ) { 306cdf0e10cSrcweir } 307cdf0e10cSrcweir 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310cdf0e10cSrcweir //_________________________________ 311cdf0e10cSrcweir flush()312cdf0e10cSrcweir public void flush() throws com.sun.star.io.NotConnectedException , 313cdf0e10cSrcweir com.sun.star.io.BufferSizeExceededException , 314cdf0e10cSrcweir com.sun.star.io.IOException 315cdf0e10cSrcweir { 316cdf0e10cSrcweir m_bOutWasUsed = true; 317cdf0e10cSrcweir 318cdf0e10cSrcweir if (m_xOutStream == null) 319cdf0e10cSrcweir { 320cdf0e10cSrcweir throw new com.sun.star.io.NotConnectedException("stream not open"); 321cdf0e10cSrcweir } 322cdf0e10cSrcweir 323cdf0e10cSrcweir try 324cdf0e10cSrcweir { 325cdf0e10cSrcweir m_xOutStream.flush(); 326cdf0e10cSrcweir } 327cdf0e10cSrcweir catch (com.sun.star.io.NotConnectedException exConnect) { 328cdf0e10cSrcweir } 329cdf0e10cSrcweir catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { 330cdf0e10cSrcweir } 331cdf0e10cSrcweir catch (com.sun.star.io.IOException exIO ) { 332cdf0e10cSrcweir } 333cdf0e10cSrcweir catch (com.sun.star.uno.RuntimeException exRuntime) { 334cdf0e10cSrcweir } 335cdf0e10cSrcweir catch (com.sun.star.uno.Exception exUno ) { 336cdf0e10cSrcweir } 337cdf0e10cSrcweir } 338cdf0e10cSrcweir 339cdf0e10cSrcweir //_________________________________ 340cdf0e10cSrcweir closeOutput()341cdf0e10cSrcweir public void closeOutput() throws com.sun.star.io.NotConnectedException , 342cdf0e10cSrcweir com.sun.star.io.BufferSizeExceededException, 343cdf0e10cSrcweir com.sun.star.io.IOException 344cdf0e10cSrcweir { 345cdf0e10cSrcweir m_bOutWasUsed = true; 346cdf0e10cSrcweir 347cdf0e10cSrcweir if (m_xOutStream == null) 348cdf0e10cSrcweir { 349cdf0e10cSrcweir throw new com.sun.star.io.NotConnectedException("stream not open"); 350cdf0e10cSrcweir } 351cdf0e10cSrcweir 352cdf0e10cSrcweir try 353cdf0e10cSrcweir { 354cdf0e10cSrcweir m_xOutStream.closeOutput(); 355cdf0e10cSrcweir } 356cdf0e10cSrcweir catch (com.sun.star.io.NotConnectedException exConnect) { 357cdf0e10cSrcweir } 358cdf0e10cSrcweir catch (com.sun.star.io.BufferSizeExceededException exBuffer ) { 359cdf0e10cSrcweir } 360cdf0e10cSrcweir catch (com.sun.star.io.IOException exIO ) { 361cdf0e10cSrcweir } 362cdf0e10cSrcweir catch (com.sun.star.uno.RuntimeException exRuntime) { 363cdf0e10cSrcweir } 364cdf0e10cSrcweir catch (com.sun.star.uno.Exception exUno ) { 365cdf0e10cSrcweir } 366cdf0e10cSrcweir 367cdf0e10cSrcweir } 368cdf0e10cSrcweir 369cdf0e10cSrcweir /** 370cdf0e10cSrcweir * following methods simulates the XSeekable. 371cdf0e10cSrcweir * The notice all actions inside the internal protocol 372cdf0e10cSrcweir * and try to map all neccessary functions to the internal 373cdf0e10cSrcweir * open stream. 374cdf0e10cSrcweir */ seek(long nLocation )375cdf0e10cSrcweir public void seek(long nLocation ) 376cdf0e10cSrcweir throws com.sun.star.lang.IllegalArgumentException, 377cdf0e10cSrcweir com.sun.star.io.IOException 378cdf0e10cSrcweir { 379cdf0e10cSrcweir if (m_xInStream != null) 380cdf0e10cSrcweir m_bInWasUsed = true; 381cdf0e10cSrcweir else 382cdf0e10cSrcweir if (m_xOutStream != null) 383cdf0e10cSrcweir m_bOutWasUsed = true; 384cdf0e10cSrcweir // else 385cdf0e10cSrcweir //m_aProtocol.log("\tno stream open!\n"); 386cdf0e10cSrcweir 387cdf0e10cSrcweir if (m_xSeek == null) 388cdf0e10cSrcweir { 389cdf0e10cSrcweir throw new com.sun.star.io.IOException("stream not seekable"); 390cdf0e10cSrcweir } 391cdf0e10cSrcweir 392cdf0e10cSrcweir try 393cdf0e10cSrcweir { 394cdf0e10cSrcweir m_xSeek.seek(nLocation); 395cdf0e10cSrcweir } 396cdf0e10cSrcweir catch (com.sun.star.lang.IllegalArgumentException exArg ) { 397cdf0e10cSrcweir } 398cdf0e10cSrcweir catch (com.sun.star.io.IOException exIO ) { 399cdf0e10cSrcweir } 400cdf0e10cSrcweir catch (com.sun.star.uno.RuntimeException exRuntime) { 401cdf0e10cSrcweir } 402cdf0e10cSrcweir catch (com.sun.star.uno.Exception exUno ) { 403cdf0e10cSrcweir } 404cdf0e10cSrcweir 405cdf0e10cSrcweir } 406cdf0e10cSrcweir getPosition()407cdf0e10cSrcweir public long getPosition() throws com.sun.star.io.IOException 408cdf0e10cSrcweir { 409cdf0e10cSrcweir 410cdf0e10cSrcweir if (m_xInStream != null) 411cdf0e10cSrcweir m_bInWasUsed = true; 412cdf0e10cSrcweir else 413cdf0e10cSrcweir if (m_xOutStream != null) 414cdf0e10cSrcweir m_bOutWasUsed = true; 415cdf0e10cSrcweir // else 416cdf0e10cSrcweir //m_aProtocol.log("\tno stream open!\n"); 417cdf0e10cSrcweir 418cdf0e10cSrcweir if (m_xSeek == null) 419cdf0e10cSrcweir { 420cdf0e10cSrcweir throw new com.sun.star.io.IOException("stream not seekable"); 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir long nPos = 0; 424cdf0e10cSrcweir try 425cdf0e10cSrcweir { 426cdf0e10cSrcweir nPos = m_xSeek.getPosition(); 427cdf0e10cSrcweir } 428cdf0e10cSrcweir catch (com.sun.star.io.IOException exIO ) { 429cdf0e10cSrcweir } 430cdf0e10cSrcweir catch (com.sun.star.uno.RuntimeException exRuntime) { 431cdf0e10cSrcweir } 432cdf0e10cSrcweir catch (com.sun.star.uno.Exception exUno ) { 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 435cdf0e10cSrcweir return nPos; 436cdf0e10cSrcweir } 437cdf0e10cSrcweir 438cdf0e10cSrcweir //_________________________________ 439cdf0e10cSrcweir getLength()440cdf0e10cSrcweir public long getLength() throws com.sun.star.io.IOException 441cdf0e10cSrcweir { 442cdf0e10cSrcweir 443cdf0e10cSrcweir if (m_xInStream != null) 444cdf0e10cSrcweir m_bInWasUsed = true; 445cdf0e10cSrcweir else 446cdf0e10cSrcweir if (m_xOutStream != null) 447cdf0e10cSrcweir m_bOutWasUsed = true; 448cdf0e10cSrcweir // else 449cdf0e10cSrcweir //m_aProtocol.log("\tno stream open!\n"); 450cdf0e10cSrcweir 451cdf0e10cSrcweir if (m_xSeek == null) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir throw new com.sun.star.io.IOException("stream not seekable"); 454cdf0e10cSrcweir } 455cdf0e10cSrcweir 456cdf0e10cSrcweir long nLen = 0; 457cdf0e10cSrcweir try 458cdf0e10cSrcweir { 459cdf0e10cSrcweir nLen = m_xSeek.getLength(); 460cdf0e10cSrcweir } 461cdf0e10cSrcweir catch (com.sun.star.io.IOException exIO ) { 462cdf0e10cSrcweir } 463cdf0e10cSrcweir catch (com.sun.star.uno.RuntimeException exRuntime) { 464cdf0e10cSrcweir } 465cdf0e10cSrcweir catch (com.sun.star.uno.Exception exUno ) { 466cdf0e10cSrcweir } 467cdf0e10cSrcweir 468cdf0e10cSrcweir return nLen; 469cdf0e10cSrcweir } 470cdf0e10cSrcweir } 471