LCOV - code coverage report
Current view: top level - package/source/xstor - oseekinstream.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 37 52 71.2 %
Date: 2015-06-13 12:38:46 Functions: 10 11 90.9 %
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 <cppuhelper/queryinterface.hxx>
      23             : #include <osl/diagnose.h>
      24             : 
      25             : #include "oseekinstream.hxx"
      26             : #include "owriteablestream.hxx"
      27             : 
      28             : using namespace ::com::sun::star;
      29             : 
      30       18154 : OInputSeekStream::OInputSeekStream( OWriteStream_Impl& pImpl,
      31             :                                     uno::Reference < io::XInputStream > xStream,
      32             :                                     const uno::Sequence< beans::PropertyValue >& aProps,
      33             :                                     sal_Int32 nStorageType )
      34       18154 : : OInputCompStream( pImpl, xStream, aProps, nStorageType )
      35             : {
      36       18154 :     m_xSeekable = uno::Reference< io::XSeekable >( m_xStream, uno::UNO_QUERY );
      37             :     OSL_ENSURE( m_xSeekable.is(), "No seeking support!\n" );
      38       18154 : }
      39             : 
      40          14 : OInputSeekStream::OInputSeekStream( uno::Reference < io::XInputStream > xStream,
      41             :                                     const uno::Sequence< beans::PropertyValue >& aProps,
      42             :                                     sal_Int32 nStorageType )
      43          14 : : OInputCompStream( xStream, aProps, nStorageType )
      44             : {
      45          14 :     m_xSeekable = uno::Reference< io::XSeekable >( m_xStream, uno::UNO_QUERY );
      46             :     OSL_ENSURE( m_xSeekable.is(), "No seeking support!\n" );
      47          14 : }
      48             : 
      49       36336 : OInputSeekStream::~OInputSeekStream()
      50             : {
      51       36336 : }
      52             : 
      53           0 : uno::Sequence< uno::Type > SAL_CALL OInputSeekStream::getTypes()
      54             :         throw ( uno::RuntimeException, std::exception )
      55             : {
      56             :     static ::cppu::OTypeCollection* pTypeCollection = NULL ;
      57             : 
      58           0 :     if ( pTypeCollection == NULL )
      59             :     {
      60           0 :         ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() ) ;
      61             : 
      62           0 :         if ( pTypeCollection == NULL )
      63             :         {
      64             :             static ::cppu::OTypeCollection aTypeCollection(
      65           0 :                     cppu::UnoType<io::XSeekable>::get(),
      66           0 :                     OInputCompStream::getTypes() );
      67             : 
      68           0 :             pTypeCollection = &aTypeCollection ;
      69           0 :         }
      70             :     }
      71             : 
      72           0 :     return pTypeCollection->getTypes() ;
      73             : }
      74             : 
      75     1455762 : uno::Any SAL_CALL OInputSeekStream::queryInterface( const uno::Type& rType )
      76             :         throw( uno::RuntimeException, std::exception )
      77             : {
      78             :     // Attention:
      79             :     //  Don't use mutex or guard in this method!!! Is a method of XInterface.
      80             : 
      81             :     uno::Any aReturn( ::cppu::queryInterface( rType,
      82     1455762 :                                            static_cast< io::XSeekable* >( this ) ) );
      83             : 
      84     1455762 :     if ( aReturn.hasValue() )
      85             :     {
      86          25 :         return aReturn ;
      87             :     }
      88             : 
      89     1455737 :     return OInputCompStream::queryInterface( rType ) ;
      90             : }
      91             : 
      92     5788119 : void SAL_CALL OInputSeekStream::acquire()
      93             :         throw()
      94             : {
      95     5788119 :     OInputCompStream::acquire();
      96     5788119 : }
      97             : 
      98     5788119 : void SAL_CALL OInputSeekStream::release()
      99             :         throw()
     100             : {
     101     5788119 :     OInputCompStream::release();
     102     5788119 : }
     103             : 
     104         151 : void SAL_CALL OInputSeekStream::seek( sal_Int64 location )
     105             :         throw ( lang::IllegalArgumentException,
     106             :                 io::IOException,
     107             :                 uno::RuntimeException, std::exception )
     108             : {
     109         151 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
     110         151 :     if ( m_bDisposed )
     111             :     {
     112             :         SAL_INFO("package.xstor", "Disposed!");
     113           0 :         throw lang::DisposedException();
     114             :     }
     115             : 
     116         151 :     if ( !m_xSeekable.is() )
     117             :     {
     118             :         SAL_INFO("package.xstor", "No seekable!");
     119           0 :         throw uno::RuntimeException();
     120             :     }
     121             : 
     122         151 :     m_xSeekable->seek( location );
     123         151 : }
     124             : 
     125          84 : sal_Int64 SAL_CALL OInputSeekStream::getPosition()
     126             :         throw ( io::IOException,
     127             :                 uno::RuntimeException, std::exception)
     128             : {
     129          84 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
     130          84 :     if ( m_bDisposed )
     131             :     {
     132             :         SAL_INFO("package.xstor", "Disposed!");
     133           0 :         throw lang::DisposedException();
     134             :     }
     135             : 
     136          84 :     if ( !m_xSeekable.is() )
     137             :     {
     138             :         SAL_INFO("package.xstor", "No seekable!");
     139           0 :         throw uno::RuntimeException();
     140             :     }
     141             : 
     142          84 :     return m_xSeekable->getPosition();
     143             : }
     144             : 
     145         146 : sal_Int64 SAL_CALL OInputSeekStream::getLength()
     146             :         throw ( io::IOException,
     147             :                 uno::RuntimeException, std::exception )
     148             : {
     149         146 :     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
     150         146 :     if ( m_bDisposed )
     151             :     {
     152             :         SAL_INFO("package.xstor", "Disposed!");
     153           0 :         throw lang::DisposedException();
     154             :     }
     155             : 
     156         146 :     if ( !m_xSeekable.is() )
     157             :     {
     158             :         SAL_INFO("package.xstor", "No seekable!");
     159           0 :         throw uno::RuntimeException();
     160             :     }
     161             : 
     162         146 :     return m_xSeekable->getLength();
     163             : }
     164             : 
     165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11