LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/unotools - ucblockbytes.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1 0.0 %
Date: 2012-12-27 Functions: 0 2 0.0 %
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             : #ifndef _UNTOOLS_UCBLOCKBYTES_HXX
      20             : #define _UNTOOLS_UCBLOCKBYTES_HXX
      21             : 
      22             : #include <com/sun/star/uno/Reference.hxx>
      23             : #include <com/sun/star/uno/Sequence.hxx>
      24             : #include <com/sun/star/ucb/XContent.hpp>
      25             : #include <com/sun/star/beans/PropertyValue.hpp>
      26             : #include "unotools/unotoolsdllapi.h"
      27             : 
      28             : #include <osl/thread.hxx>
      29             : #include <osl/conditn.hxx>
      30             : #include <osl/mutex.hxx>
      31             : #include <tools/stream.hxx>
      32             : #include <tools/link.hxx>
      33             : #include <tools/errcode.hxx>
      34             : #include <tools/datetime.hxx>
      35             : 
      36             : namespace com
      37             : {
      38             :     namespace sun
      39             :     {
      40             :         namespace star
      41             :         {
      42             :             namespace task
      43             :             {
      44             :                 class XInteractionHandler;
      45             :             }
      46             :             namespace io
      47             :             {
      48             :                 class XStream;
      49             :                 class XInputStream;
      50             :                 class XOutputStream;
      51             :                 class XSeekable;
      52             :             }
      53             :             namespace ucb
      54             :             {
      55             :                 class XContent;
      56             :             }
      57             :             namespace beans
      58             :             {
      59             :                 struct PropertyValue;
      60             :             }
      61             :         }
      62             :     }
      63             : }
      64             : 
      65             : namespace utl
      66             : {
      67             : SV_DECL_REF( UcbLockBytes )
      68             : 
      69           0 : class UcbLockBytesHandler : public SvRefBase
      70             : {
      71             :     sal_Bool        m_bActive;
      72             : public:
      73             :     enum LoadHandlerItem
      74             :     {
      75             :         DATA_AVAILABLE,
      76             :         DONE,
      77             :         CANCEL
      78             :     };
      79             : 
      80             :                     UcbLockBytesHandler()
      81             :                         : m_bActive( sal_True )
      82             :                     {}
      83             : 
      84             :     virtual void    Handle( LoadHandlerItem nWhich, UcbLockBytesRef xLockBytes ) = 0;
      85             :     void            Activate( sal_Bool bActivate = sal_True ) { m_bActive = bActivate; }
      86             :     sal_Bool        IsActive() const { return m_bActive; }
      87             : };
      88             : 
      89             : SV_DECL_IMPL_REF( UcbLockBytesHandler )
      90             : 
      91             : class UNOTOOLS_DLLPUBLIC UcbLockBytes : public virtual SvLockBytes
      92             : {
      93             :     osl::Condition          m_aInitialized;
      94             :     osl::Condition          m_aTerminated;
      95             :     osl::Mutex              m_aMutex;
      96             : 
      97             :     String                  m_aContentType;
      98             :     String                  m_aRealURL;
      99             :     DateTime                m_aExpireDate;
     100             : 
     101             :     ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >  m_xInputStream;
     102             :     ::com::sun::star::uno::Reference < ::com::sun::star::io::XOutputStream > m_xOutputStream;
     103             :     ::com::sun::star::uno::Reference < ::com::sun::star::io::XSeekable >     m_xSeekable;
     104             :     void*                   m_pCommandThread; // is alive only for compatibility reasons
     105             :     UcbLockBytesHandlerRef  m_xHandler;
     106             : 
     107             :     sal_uInt32              m_nRead;
     108             :     sal_uInt32              m_nSize;
     109             :     ErrCode                 m_nError;
     110             : 
     111             :     sal_Bool                m_bTerminated : 1;
     112             :     sal_Bool                m_bDontClose : 1;
     113             :     sal_Bool                m_bStreamValid : 1;
     114             : 
     115             :     DECL_LINK(              DataAvailHdl, void * );
     116             : 
     117             :                             UcbLockBytes( UcbLockBytesHandler* pHandler=NULL );
     118             : protected:
     119             :     virtual                 ~UcbLockBytes (void);
     120             : 
     121             : public:
     122             :                             // properties: Referer, PostMimeType
     123             :     static UcbLockBytesRef  CreateLockBytes( const ::com::sun::star::uno::Reference < ::com::sun::star::ucb::XContent >& xContent,
     124             :                                             const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rProps,
     125             :                                             StreamMode eMode,
     126             :                                             const ::com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionHandler >& xInter,
     127             :                                             UcbLockBytesHandler* pHandler=0 );
     128             : 
     129             :     static UcbLockBytesRef  CreateInputLockBytes( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >& xContent );
     130             :     static UcbLockBytesRef  CreateLockBytes( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream >& xContent );
     131             : 
     132             :     // SvLockBytes
     133             :     virtual void            SetSynchronMode (sal_Bool bSynchron);
     134             :     virtual ErrCode         ReadAt ( sal_uLong nPos, void *pBuffer, sal_uLong nCount, sal_uLong *pRead) const;
     135             :     virtual ErrCode         WriteAt ( sal_uLong, const void*, sal_uLong, sal_uLong *pWritten);
     136             :     virtual ErrCode         Flush (void) const;
     137             :     virtual ErrCode         SetSize (sal_uLong);
     138             :     virtual ErrCode         Stat ( SvLockBytesStat *pStat, SvLockBytesStatFlag) const;
     139             : 
     140             :     void                    SetError( ErrCode nError )
     141             :                             { m_nError = nError; }
     142             : 
     143             :     ErrCode                 GetError() const
     144             :                             { return m_nError; }
     145             : 
     146             :     // the following properties are available when and after the first DataAvailable callback has been executed
     147             :     String                  GetContentType() const;
     148             :     String                  GetRealURL() const;
     149             :     DateTime                GetExpireDate() const;
     150             : 
     151             :     // calling this method delegates the responsibility to call closeinput to the caller!
     152             :     ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > getInputStream();
     153             : 
     154             :     sal_Bool                setInputStream_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > &rxInputStream,
     155             :                                                  sal_Bool bSetXSeekable = sal_True );
     156             :     sal_Bool                setStream_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream > &rxStream );
     157             :     void                    terminate_Impl (void);
     158             : 
     159             :     ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > getInputStream_Impl() const
     160             :                             {
     161             :                                 osl::MutexGuard aGuard( (const_cast< UcbLockBytes* >(this))->m_aMutex );
     162             :                                 return m_xInputStream;
     163             :                             }
     164             : 
     165             :     ::com::sun::star::uno::Reference < ::com::sun::star::io::XOutputStream > getOutputStream_Impl() const
     166             :                             {
     167             :                                 osl::MutexGuard aGuard( (const_cast< UcbLockBytes* >(this))->m_aMutex );
     168             :                                 return m_xOutputStream;
     169             :                             }
     170             : 
     171             :     ::com::sun::star::uno::Reference < ::com::sun::star::io::XSeekable > getSeekable_Impl() const
     172             :                             {
     173             :                                 osl::MutexGuard aGuard( (const_cast< UcbLockBytes* >(this))->m_aMutex );
     174             :                                 return m_xSeekable;
     175             :                             }
     176             : 
     177             :     sal_Bool                hasInputStream_Impl() const
     178             :                             {
     179             :                                 osl::MutexGuard aGuard( (const_cast< UcbLockBytes* >(this))->m_aMutex );
     180             :                                 return m_xInputStream.is();
     181             :                             }
     182             : 
     183             :     void                    setDontClose_Impl()
     184             :                             { m_bDontClose = sal_True; }
     185             : 
     186             :     void                    SetContentType_Impl( const String& rType ) { m_aContentType = rType; }
     187             :     void                    SetRealURL_Impl( const String& rURL )  { m_aRealURL = rURL; }
     188             :     void                    SetExpireDate_Impl( const DateTime& rDateTime )  { m_aExpireDate = rDateTime; }
     189             :     void                    SetStreamValid_Impl();
     190             : };
     191             : 
     192             : SV_IMPL_REF( UcbLockBytes );
     193             : 
     194             : }
     195             : 
     196             : #endif
     197             : 
     198             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10