LCOV - code coverage report
Current view: top level - sc/source/filter/inc - biffcodec.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 5 0.0 %
Date: 2012-08-25 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 16 0.0 %

           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                 :            : 
      29                 :            : #ifndef OOX_XLS_BIFFCODEC_HXX
      30                 :            : #define OOX_XLS_BIFFCODEC_HXX
      31                 :            : 
      32                 :            : #include <vector>
      33                 :            : #include <comphelper/docpasswordhelper.hxx>
      34                 :            : #include "oox/core/binarycodec.hxx"
      35                 :            : #include "workbookhelper.hxx"
      36                 :            : 
      37                 :            : namespace oox {
      38                 :            : namespace xls {
      39                 :            : 
      40                 :            : // ============================================================================
      41                 :            : 
      42                 :            : const sal_Int64 BIFF_RCF_BLOCKSIZE          = 1024;
      43                 :            : 
      44                 :            : // ============================================================================
      45                 :            : 
      46                 :            : /** Base class for BIFF stream decoders. */
      47                 :            : class BiffDecoderBase : public ::comphelper::IDocPasswordVerifier
      48                 :            : {
      49                 :            : public:
      50                 :            :     explicit            BiffDecoderBase();
      51                 :            :     virtual             ~BiffDecoderBase();
      52                 :            : 
      53                 :            :     /** Derived classes return a clone of the decoder for usage in new streams. */
      54                 :          0 :     inline BiffDecoderBase* clone() { return implClone(); }
      55                 :            : 
      56                 :            :     /** Implementation of the ::comphelper::IDocPasswordVerifier interface. */
      57                 :            :     virtual ::comphelper::DocPasswordVerifierResult verifyPassword( const ::rtl::OUString& rPassword, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& o_rEncryptionData );
      58                 :            :     virtual ::comphelper::DocPasswordVerifierResult verifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& o_rEncryptionData );
      59                 :            : 
      60                 :            :     /** Returns true, if the decoder has been initialized correctly. */
      61                 :          0 :     inline bool         isValid() const { return mbValid; }
      62                 :            : 
      63                 :            :     /** Decodes nBytes bytes and writes encrypted data into the buffer pnDestData. */
      64                 :            :     void                decode(
      65                 :            :                             sal_uInt8* pnDestData,
      66                 :            :                             const sal_uInt8* pnSrcData,
      67                 :            :                             sal_Int64 nStreamPos,
      68                 :            :                             sal_uInt16 nBytes );
      69                 :            : 
      70                 :            : private:
      71                 :            :     /** Derived classes return a clone of the decoder for usage in new streams. */
      72                 :            :     virtual BiffDecoderBase* implClone() = 0;
      73                 :            : 
      74                 :            :     /** Derived classes implement password verification and initialization of
      75                 :            :         the decoder. */
      76                 :            :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > implVerifyPassword( const ::rtl::OUString& rPassword ) = 0;
      77                 :            :     virtual bool implVerifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rEncryptionData ) = 0;
      78                 :            : 
      79                 :            :     /** Implementation of decryption of a memory block. */
      80                 :            :     virtual void        implDecode(
      81                 :            :                             sal_uInt8* pnDestData,
      82                 :            :                             const sal_uInt8* pnSrcData,
      83                 :            :                             sal_Int64 nStreamPos,
      84                 :            :                             sal_uInt16 nBytes ) = 0;
      85                 :            : 
      86                 :            : private:
      87                 :            :     bool                mbValid;        /// True = decoder is correctly initialized.
      88                 :            : };
      89                 :            : 
      90                 :            : typedef ::boost::shared_ptr< BiffDecoderBase > BiffDecoderRef;
      91                 :            : 
      92                 :            : // ============================================================================
      93                 :            : 
      94                 :            : /** Decodes BIFF stream contents that are encoded using the old XOR algorithm. */
      95 [ #  # ][ #  # ]:          0 : class BiffDecoder_XOR : public BiffDecoderBase
                 [ #  # ]
      96                 :            : {
      97                 :            : private:
      98                 :            :     /** Copy constructor for cloning. */
      99                 :            :                         BiffDecoder_XOR( const BiffDecoder_XOR& rDecoder );
     100                 :            : 
     101                 :            :     /** Returns a clone of the decoder for usage in new streams. */
     102                 :            :     virtual BiffDecoder_XOR* implClone();
     103                 :            : 
     104                 :            :     /** Implements password verification and initialization of the decoder. */
     105                 :            :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > implVerifyPassword( const ::rtl::OUString& rPassword );
     106                 :            :     virtual bool implVerifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rEncryptionData );
     107                 :            : 
     108                 :            : 
     109                 :            :     /** Implementation of decryption of a memory block. */
     110                 :            :     virtual void        implDecode(
     111                 :            :                             sal_uInt8* pnDestData,
     112                 :            :                             const sal_uInt8* pnSrcData,
     113                 :            :                             sal_Int64 nStreamPos,
     114                 :            :                             sal_uInt16 nBytes );
     115                 :            : 
     116                 :            : private:
     117                 :            :     ::oox::core::BinaryCodec_XOR maCodec;   /// Cipher algorithm implementation.
     118                 :            :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > maEncryptionData;
     119                 :            :     sal_uInt16          mnKey;
     120                 :            :     sal_uInt16          mnHash;
     121                 :            : };
     122                 :            : 
     123                 :            : // ============================================================================
     124                 :            : 
     125                 :            : /** Decodes BIFF stream contents that are encoded using the RC4 algorithm. */
     126 [ #  # ][ #  # ]:          0 : class BiffDecoder_RCF : public BiffDecoderBase
                 [ #  # ]
     127                 :            : {
     128                 :            : private:
     129                 :            :     /** Copy constructor for cloning. */
     130                 :            :                         BiffDecoder_RCF( const BiffDecoder_RCF& rDecoder );
     131                 :            : 
     132                 :            :     /** Returns a clone of the decoder for usage in new streams. */
     133                 :            :     virtual BiffDecoder_RCF* implClone();
     134                 :            : 
     135                 :            :     /** Implements password verification and initialization of the decoder. */
     136                 :            :     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > implVerifyPassword( const ::rtl::OUString& rPassword );
     137                 :            :     virtual bool implVerifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rEncryptionData );
     138                 :            : 
     139                 :            :     /** Implementation of decryption of a memory block. */
     140                 :            :     virtual void        implDecode(
     141                 :            :                             sal_uInt8* pnDestData,
     142                 :            :                             const sal_uInt8* pnSrcData,
     143                 :            :                             sal_Int64 nStreamPos,
     144                 :            :                             sal_uInt16 nBytes );
     145                 :            : 
     146                 :            : private:
     147                 :            :     ::oox::core::BinaryCodec_RCF maCodec;   /// Cipher algorithm implementation.
     148                 :            :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > maEncryptionData;
     149                 :            :     ::std::vector< sal_uInt8 > maSalt;
     150                 :            :     ::std::vector< sal_uInt8 > maVerifier;
     151                 :            :     ::std::vector< sal_uInt8 > maVerifierHash;
     152                 :            : };
     153                 :            : 
     154                 :            : // ============================================================================
     155                 :            : 
     156                 :            : /** Helper for BIFF stream codecs. Holds the used codec object. */
     157 [ #  # ][ #  # ]:          0 : class BiffCodecHelper : public WorkbookHelper
     158                 :            : {
     159                 :            : public:
     160                 :            :     explicit            BiffCodecHelper( const WorkbookHelper& rHelper );
     161                 :            : 
     162                 :            :     /** Clones the contained decoder object if existing and sets it at the passed stream. */
     163                 :            :     void                cloneDecoder( BiffInputStream& rStrm );
     164                 :            : 
     165                 :            : private:
     166                 :            :     BiffDecoderRef      mxDecoder;          /// The decoder for import filter.
     167                 :            : };
     168                 :            : 
     169                 :            : // ============================================================================
     170                 :            : 
     171                 :            : } // namespace xls
     172                 :            : } // namespace oox
     173                 :            : 
     174                 :            : #endif
     175                 :            : 
     176                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10