LCOV - code coverage report
Current view: top level - sw/source/core/docnode - retrieveinputstream.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 25 96.0 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25 56 44.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #include <retrieveinputstream.hxx>
      29                 :            : #include <comphelper/mediadescriptor.hxx>
      30                 :            : #include <com/sun/star/io/XStream.hpp>
      31                 :            : 
      32                 :            : /** class for a thread to retrieve an input stream given by an URL
      33                 :            : 
      34                 :            :     #i73788#
      35                 :            : 
      36                 :            :     @author OD
      37                 :            : */
      38                 :          8 : ::rtl::Reference< ObservableThread > SwAsyncRetrieveInputStreamThread::createThread(
      39                 :            :                         const SwRetrievedInputStreamDataManager::tDataKey nDataKey,
      40                 :            :                         const String& rLinkedURL )
      41                 :            : {
      42                 :            :     SwAsyncRetrieveInputStreamThread* pNewThread =
      43         [ +  - ]:          8 :             new SwAsyncRetrieveInputStreamThread( nDataKey, rLinkedURL );
      44                 :          8 :     return pNewThread;
      45                 :            : }
      46                 :            : 
      47                 :          8 : SwAsyncRetrieveInputStreamThread::SwAsyncRetrieveInputStreamThread(
      48                 :            :                             const SwRetrievedInputStreamDataManager::tDataKey nDataKey,
      49                 :            :                             const String& rLinkedURL )
      50                 :            :     : ObservableThread(),
      51                 :            :       mnDataKey( nDataKey ),
      52         [ +  - ]:          8 :       mrLinkedURL( rLinkedURL )
      53                 :            : {
      54                 :          8 : }
      55                 :            : 
      56         [ +  - ]:          8 : SwAsyncRetrieveInputStreamThread::~SwAsyncRetrieveInputStreamThread()
      57                 :            : {
      58         [ -  + ]:         16 : }
      59                 :            : 
      60                 :          8 : void SwAsyncRetrieveInputStreamThread::threadFunction()
      61                 :            : {
      62         [ +  - ]:          8 :     com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > xProps( 1 );
      63 [ +  - ][ +  - ]:          8 :     xProps[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"));
      64 [ +  - ][ +  - ]:          8 :     xProps[0].Value <<= ::rtl::OUString( mrLinkedURL );
                 [ +  - ]
      65         [ +  - ]:          8 :     comphelper::MediaDescriptor aMedium( xProps );
      66                 :            : 
      67         [ +  - ]:          8 :     aMedium.addInputStream();
      68                 :            : 
      69                 :          8 :     com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream;
      70 [ +  - ][ +  - ]:          8 :     aMedium[comphelper::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream;
                 [ +  - ]
      71         [ +  - ]:          8 :     if ( !xInputStream.is() )
      72                 :            :     {
      73                 :          8 :         com::sun::star::uno::Reference<com::sun::star::io::XStream> xStream;
      74 [ +  - ][ +  - ]:          8 :         aMedium[comphelper::MediaDescriptor::PROP_STREAM()] >>= xStream;
                 [ +  - ]
      75         [ -  + ]:          8 :         if ( xStream.is() )
      76                 :            :         {
      77 [ #  # ][ #  # ]:          0 :             xInputStream = xStream->getInputStream();
                 [ #  # ]
      78                 :          8 :         }
      79                 :            :     }
      80                 :            : 
      81         [ +  - ]:          8 :     SwRetrievedInputStreamDataManager::GetManager().PushData( mnDataKey,
      82                 :            :                                                               xInputStream,
      83 [ +  - ][ +  - ]:         16 :                                                               aMedium.isStreamReadOnly() );
         [ +  - ][ +  - ]
      84                 :          8 : }
      85                 :            : 
      86                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10