LCOV - code coverage report
Current view: top level - libreoffice/package/source/xstor - oseekinstream.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 60 28.3 %
Date: 2012-12-27 Functions: 6 11 54.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/lang/DisposedException.hpp>
      21             : #include <cppuhelper/typeprovider.hxx>
      22             : #include <osl/diagnose.h>
      23             : 
      24             : #include "oseekinstream.hxx"
      25             : #include "owriteablestream.hxx"
      26             : 
      27             : using namespace ::com::sun::star;
      28             : 
      29         449 : OInputSeekStream::OInputSeekStream( OWriteStream_Impl& pImpl,
      30             :                                     uno::Reference < io::XInputStream > xStream,
      31             :                                     const uno::Sequence< beans::PropertyValue >& aProps,
      32             :                                     sal_Int32 nStorageType )
      33         449 : : OInputCompStream( pImpl, xStream, aProps, nStorageType )
      34             : {
      35         449 :     if ( m_xStream.is() )
      36             :     {
      37         449 :         m_xSeekable = uno::Reference< io::XSeekable >( m_xStream, uno::UNO_QUERY );
      38             :         OSL_ENSURE( m_xSeekable.is(), "No seeking support!\n" );
      39             :     }
      40         449 : }
      41             : 
      42           0 : OInputSeekStream::OInputSeekStream( uno::Reference < io::XInputStream > xStream,
      43             :                                     const uno::Sequence< beans::PropertyValue >& aProps,
      44             :                                     sal_Int32 nStorageType )
      45           0 : : OInputCompStream( xStream, aProps, nStorageType )
      46             : {
      47           0 :     if ( m_xStream.is() )
      48             :     {
      49           0 :         m_xSeekable = uno::Reference< io::XSeekable >( m_xStream, uno::UNO_QUERY );
      50             :         OSL_ENSURE( m_xSeekable.is(), "No seeking support!\n" );
      51             :     }
      52           0 : }
      53             : 
      54         898 : OInputSeekStream::~OInputSeekStream()
      55             : {
      56         898 : }
      57             : 
      58           0 : uno::Sequence< uno::Type > SAL_CALL OInputSeekStream::getTypes()
      59             :         throw ( uno::RuntimeException )
      60             : {
      61             :     static ::cppu::OTypeCollection* pTypeCollection = NULL ;
      62             : 
      63           0 :     if ( pTypeCollection == NULL )
      64             :     {
      65           0 :         ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() ) ;
      66             : 
      67           0 :         if ( pTypeCollection == NULL )
      68             :         {
      69             :             static ::cppu::OTypeCollection aTypeCollection(
      70           0 :                     ::getCppuType(( const uno::Reference< io::XSeekable >* )NULL ),
      71           0 :                     OInputCompStream::getTypes() );
      72             : 
      73           0 :             pTypeCollection = &aTypeCollection ;
      74           0 :         }
      75             :     }
      76             : 
      77           0 :     return pTypeCollection->getTypes() ;
      78             : }
      79             : 
      80        5882 : uno::Any SAL_CALL OInputSeekStream::queryInterface( const uno::Type& rType )
      81             :         throw( uno::RuntimeException )
      82             : {
      83             :     // Attention:
      84             :     //  Don't use mutex or guard in this method!!! Is a method of XInterface.
      85             : 
      86             :     uno::Any aReturn( ::cppu::queryInterface( rType,
      87        5882 :                                            static_cast< io::XSeekable* >( this ) ) );
      88             : 
      89        5882 :     if ( aReturn.hasValue() == sal_True )
      90             :     {
      91           0 :         return aReturn ;
      92             :     }
      93             : 
      94        5882 :     return OInputCompStream::queryInterface( rType ) ;
      95             : }
      96             : 
      97       22728 : void SAL_CALL OInputSeekStream::acquire()
      98             :         throw()
      99             : {
     100       22728 :     OInputCompStream::acquire();
     101       22728 : }
     102             : 
     103       22728 : void SAL_CALL OInputSeekStream::release()
     104             :         throw()
     105             : {
     106       22728 :     OInputCompStream::release();
     107       22728 : }
     108             : 
     109             : 
     110           0 : void SAL_CALL OInputSeekStream::seek( sal_Int64 location )
     111             :         throw ( lang::IllegalArgumentException,
     112             :                 io::IOException,
     113             :                 uno::RuntimeException )
     114             : {
     115           0 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
     116           0 :     if ( m_bDisposed )
     117             :     {
     118           0 :         ::package::StaticAddLog( OSL_LOG_PREFIX "Disposed!" );
     119           0 :         throw lang::DisposedException();
     120             :     }
     121             : 
     122           0 :     if ( !m_xSeekable.is() )
     123             :     {
     124           0 :         ::package::StaticAddLog( OSL_LOG_PREFIX "No seekable!" );
     125           0 :         throw uno::RuntimeException();
     126             :     }
     127             : 
     128           0 :     m_xSeekable->seek( location );
     129           0 : }
     130             : 
     131           0 : sal_Int64 SAL_CALL OInputSeekStream::getPosition()
     132             :         throw ( io::IOException,
     133             :                 uno::RuntimeException)
     134             : {
     135           0 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
     136           0 :     if ( m_bDisposed )
     137             :     {
     138           0 :         ::package::StaticAddLog( OSL_LOG_PREFIX "Disposed!" );
     139           0 :         throw lang::DisposedException();
     140             :     }
     141             : 
     142           0 :     if ( !m_xSeekable.is() )
     143             :     {
     144           0 :         ::package::StaticAddLog( OSL_LOG_PREFIX "No seekable!" );
     145           0 :         throw uno::RuntimeException();
     146             :     }
     147             : 
     148           0 :     return m_xSeekable->getPosition();
     149             : }
     150             : 
     151           0 : sal_Int64 SAL_CALL OInputSeekStream::getLength()
     152             :         throw ( io::IOException,
     153             :                 uno::RuntimeException )
     154             : {
     155           0 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
     156           0 :     if ( m_bDisposed )
     157             :     {
     158           0 :         ::package::StaticAddLog( OSL_LOG_PREFIX "Disposed!" );
     159           0 :         throw lang::DisposedException();
     160             :     }
     161             : 
     162           0 :     if ( !m_xSeekable.is() )
     163             :     {
     164           0 :         ::package::StaticAddLog( OSL_LOG_PREFIX "No seekable!" );
     165           0 :         throw uno::RuntimeException();
     166             :     }
     167             : 
     168           0 :     return m_xSeekable->getLength();
     169             : }
     170             : 
     171             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10