LCOV - code coverage report
Current view: top level - libreoffice/hwpfilter/source - htags.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 50 0.0 %
Date: 2012-12-27 Functions: 0 7 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             : 
      20             : #include "precompile.h"
      21             : 
      22             : #include <string.h>
      23             : 
      24             : #include "hwplib.h"
      25             : #include "hwpfile.h"
      26             : #include "htags.h"
      27             : 
      28           0 : bool HyperText::Read(HWPFile & hwpf)
      29             : {
      30           0 :     hwpf.Read1b(filename, 256);
      31           0 :     hwpf.Read2b(bookmark, 16);
      32           0 :     hwpf.Read1b(macro, 325);
      33           0 :     hwpf.Read1b(&type, 1);
      34           0 :     hwpf.Read1b(reserve, 3);
      35           0 :     if( type == 2 )
      36             :     {
      37           0 :         for( int i = 1; i < 256; i++)
      38             :         {
      39           0 :             filename[i-1] = filename[i];
      40           0 :             if( filename[i] == 0 )
      41           0 :                 break;
      42             :         }
      43             :     }
      44           0 :     return true;
      45             : }
      46             : 
      47             : 
      48           0 : EmPicture::EmPicture(size_t tsize)
      49           0 :     : size(tsize >= 32 ? tsize - 32 : 0)
      50             : {
      51           0 :     if (size == 0)
      52           0 :         data = 0;
      53             :     else
      54           0 :         data = new uchar[size];
      55           0 : }
      56             : #ifdef WIN32
      57             : #define unlink _unlink
      58             : #endif
      59           0 : EmPicture::~EmPicture(void)
      60             : {
      61           0 :     if (data)
      62           0 :         delete[]data;
      63           0 : };
      64             : 
      65           0 : bool EmPicture::Read(HWPFile & hwpf)
      66             : {
      67           0 :     if (size == 0)
      68           0 :         return false;
      69           0 :     hwpf.Read1b(name, 16);
      70           0 :     hwpf.Read1b(type, 16);
      71           0 :     name[0] = 'H';
      72           0 :     name[1] = 'W';
      73           0 :     name[2] = 'P';
      74           0 :     if (hwpf.ReadBlock(data, size) == 0)
      75           0 :         return false;
      76           0 :     return true;
      77             : }
      78             : 
      79             : 
      80           0 : OlePicture::OlePicture(int tsize)
      81             : {
      82           0 :     size = tsize - 4;
      83           0 :     if (size <= 0)
      84           0 :         return;
      85             : #ifdef WIN32
      86             :      pis = 0L;
      87             : #else
      88           0 :      pis = new char[size];
      89             : #endif
      90             : };
      91             : 
      92           0 : OlePicture::~OlePicture(void)
      93             : {
      94             : #ifdef WIN32
      95             :      if( pis )
      96             :           pis->Release();
      97             : #else
      98           0 :      delete[] pis;
      99             : #endif
     100           0 : };
     101             : 
     102             : #define FILESTG_SIGNATURE_NORMAL 0xF8995568
     103             : 
     104           0 : bool OlePicture::Read(HWPFile & hwpf)
     105             : {
     106           0 :     if (size <= 0)
     107           0 :         return false;
     108             : 
     109             : // We process only FILESTG_SIGNATURE_NORMAL.
     110           0 :     hwpf.Read4b(&signature, 1);
     111           0 :     if (signature != FILESTG_SIGNATURE_NORMAL)
     112           0 :         return false;
     113             : #ifdef WIN32
     114             :     char *data = new char[size];
     115             :     if( data == 0 || hwpf.ReadBlock(data,size) == 0 )
     116             :     {
     117             :           delete [] data;
     118             :           return false;
     119             :     }
     120             :     FILE *fp;
     121             :     char tname[200];
     122             :     wchar_t wtname[200];
     123             :     tmpnam(tname);
     124             :     if (0 == (fp = fopen(tname, "wb")))
     125             :     {
     126             :          delete [] data;
     127             :          return false;
     128             :     }
     129             :     fwrite(data, size, 1, fp);
     130             :     delete [] data;
     131             :     fclose(fp);
     132             :     MultiByteToWideChar(CP_ACP, 0, tname, -1, wtname, 200);
     133             :     if( StgOpenStorage(wtname, NULL,
     134             :                     STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED,
     135             :                     NULL, 0, &pis) != S_OK ) {
     136             :          pis = 0;
     137             :          unlink(tname);
     138             :          return false;
     139             :     }
     140             :     unlink(tname);
     141             : #else
     142           0 :     if (pis == 0 || hwpf.ReadBlock(pis, size) == 0)
     143           0 :         return false;
     144             : #endif
     145             : 
     146           0 :     return true;
     147             : }
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10