LCOV - code coverage report
Current view: top level - svtools/source/urlobj - inetimg.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 56 0.0 %
Date: 2014-04-14 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             : 
      20             : #include <osl/thread.h>
      21             : #include <sot/formats.hxx>
      22             : #include <tools/stream.hxx>
      23             : 
      24             : #include <svtools/inetimg.hxx>
      25             : 
      26             : static const sal_Unicode TOKEN_SEPARATOR = '\001';
      27             : 
      28           0 : bool INetImage::Write( SvStream& rOStm, sal_uLong nFormat ) const
      29             : {
      30           0 :     bool bRet = false;
      31           0 :     switch( nFormat )
      32             :     {
      33             :     case SOT_FORMATSTR_ID_INET_IMAGE:
      34             :         {
      35           0 :             OUString sString;
      36           0 :             (sString += aImageURL ) += OUString(TOKEN_SEPARATOR);
      37           0 :             (sString += aTargetURL ) += OUString(TOKEN_SEPARATOR);
      38           0 :             (sString += aTargetFrame ) += OUString(TOKEN_SEPARATOR);
      39           0 :             (sString += aAlternateText ) += OUString(TOKEN_SEPARATOR);
      40           0 :             sString += OUString::number( aSizePixel.Width() );
      41           0 :             sString += OUString(TOKEN_SEPARATOR);
      42           0 :             sString += OUString::number( aSizePixel.Height() );
      43             : 
      44             :             OString sOut(OUStringToOString(sString,
      45           0 :                 RTL_TEXTENCODING_UTF8));
      46             : 
      47           0 :             rOStm.Write(sOut.getStr(), sOut.getLength());
      48             :             static const sal_Char aEndChar[2] = { 0 };
      49           0 :             rOStm.Write( aEndChar, sizeof( aEndChar ));
      50           0 :             bRet = 0 == rOStm.GetError();
      51             :         }
      52           0 :         break;
      53             : 
      54             :     case SOT_FORMATSTR_ID_NETSCAPE_IMAGE:
      55           0 :         break;
      56             :     }
      57           0 :     return bRet;
      58             : }
      59             : 
      60           0 : bool INetImage::Read( SvStream& rIStm, sal_uLong nFormat )
      61             : {
      62           0 :     bool bRet = false;
      63           0 :     switch( nFormat )
      64             :     {
      65             :     case SOT_FORMATSTR_ID_INET_IMAGE:
      66             :         {
      67           0 :             OUString sINetImg = read_zeroTerminated_uInt8s_ToOUString(rIStm, RTL_TEXTENCODING_UTF8);
      68           0 :             sal_Int32 nStart = 0;
      69           0 :             aImageURL = sINetImg.getToken( 0, TOKEN_SEPARATOR, nStart );
      70           0 :             aTargetURL = sINetImg.getToken( 0, TOKEN_SEPARATOR, nStart );
      71           0 :             aTargetFrame = sINetImg.getToken( 0, TOKEN_SEPARATOR, nStart );
      72           0 :             aAlternateText = sINetImg.getToken( 0, TOKEN_SEPARATOR, nStart );
      73           0 :             aSizePixel.Width() = sINetImg.getToken( 0, TOKEN_SEPARATOR,
      74           0 :                                                     nStart ).toInt32();
      75           0 :             aSizePixel.Height() = sINetImg.getToken( 0, TOKEN_SEPARATOR,
      76           0 :                                                     nStart ).toInt32();
      77           0 :             bRet = !sINetImg.isEmpty();
      78             :         }
      79           0 :         break;
      80             : 
      81             :     case SOT_FORMATSTR_ID_NETSCAPE_IMAGE:
      82             :         {
      83             : /*
      84             :     --> structure size  MUST - alignment of 4!
      85             :     int     iSize;              // size of all data, including variable length strings
      86             :     sal_Bool    bIsMap;             // For server side maps
      87             :     sal_Int32   iWidth;             // Fixed size data correspond to fields in LO_ImageDataStruct
      88             :     sal_Int32   iHeight;            //   and EDT_ImageData
      89             :     sal_Int32   iHSpace;
      90             :     sal_Int32   iVSpace;
      91             :     sal_Int32   iBorder;
      92             :     int     iLowResOffset;      // Offsets into string_data. If 0, string is NULL (not used)
      93             :     int     iAltOffset;         // (alternate text?)
      94             :     int     iAnchorOffset;      // HREF in image
      95             :     int     iExtraHTML_Offset;  // Extra HTML (stored in CImageElement)
      96             :     sal_Char pImageURL[1];      // Append all variable-length strings starting here
      97             : */
      98           0 :             rtl_TextEncoding eSysCSet = osl_getThreadTextEncoding();
      99             :             sal_Int32 nVal, nAnchorOffset, nAltOffset, nFilePos;
     100             : 
     101           0 :             nFilePos = rIStm.Tell();
     102             :             // skip over iSize (int), bIsMao ( sal_Bool ) alignment of 4 !!!!
     103           0 :             rIStm.SeekRel( 8 );
     104           0 :             rIStm.ReadInt32( nVal );  aSizePixel.Width() = nVal;
     105           0 :             rIStm.ReadInt32( nVal );  aSizePixel.Height() = nVal;
     106             :             // skip over iHSpace, iVSpace, iBorder, iLowResOffset
     107           0 :             rIStm.SeekRel( 3 * sizeof( sal_Int32 ) + sizeof( int ) );
     108           0 :             rIStm.ReadInt32( nAltOffset );
     109           0 :             rIStm.ReadInt32( nAnchorOffset );
     110             :             // skip over iExtraHTML_Offset
     111           0 :             rIStm.SeekRel( sizeof( int ) );
     112             : 
     113           0 :             aImageURL = read_zeroTerminated_uInt8s_ToOUString(rIStm, eSysCSet);
     114           0 :             if( nAltOffset )
     115             :             {
     116           0 :                 rIStm.Seek( nFilePos + nAltOffset );
     117           0 :                 aAlternateText = read_zeroTerminated_uInt8s_ToOUString(rIStm, eSysCSet);
     118             :             }
     119           0 :             else if( !aAlternateText.isEmpty() )
     120           0 :                 aAlternateText = "";
     121             : 
     122           0 :             if( nAnchorOffset )
     123             :             {
     124           0 :                 rIStm.Seek( nFilePos + nAnchorOffset );
     125           0 :                 aTargetURL = read_zeroTerminated_uInt8s_ToOUString(rIStm, eSysCSet);
     126             :             }
     127           0 :             else if( !aTargetURL.isEmpty() )
     128           0 :                 aTargetURL = "";
     129             : 
     130           0 :             bRet = 0 == rIStm.GetError();
     131             :         }
     132           0 :         break;
     133             :     }
     134           0 :     return bRet;
     135             : }
     136             : 
     137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10