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

Generated by: LCOV version 1.10