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

Generated by: LCOV version 1.10