LCOV - code coverage report
Current view: top level - vcl/source/gdi - rendergraphic.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 78 0.0 %
Date: 2012-08-25 Functions: 0 16 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 116 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                 :            : #include <vcl/rendergraphic.hxx>
      30                 :            : #include <vcl/rendergraphicrasterizer.hxx>
      31                 :            : #include <vcl/mapmod.hxx>
      32                 :            : #include <tools/stream.hxx>
      33                 :            : #include <tools/vcompat.hxx>
      34                 :            : 
      35                 :            : #include <cstring>
      36                 :            : #include <cstdio>
      37                 :            : 
      38                 :            : namespace vcl
      39                 :            : {
      40                 :            : 
      41                 :            : // -----------------
      42                 :            : // - RenderGraphic -
      43                 :            : // -----------------
      44                 :          0 : RenderGraphic::RenderGraphic( ) :
      45                 :          0 :     mnGraphicDataLength( 0 )
      46                 :            : {
      47                 :          0 : }
      48                 :            : 
      49                 :            : // -------------------------------------------------------------------------
      50                 :            : 
      51                 :          0 : RenderGraphic::RenderGraphic( const RenderGraphic& rRenderGraphic ) :
      52                 :            :     maGraphicData( rRenderGraphic.maGraphicData ),
      53                 :            :     mnGraphicDataLength( rRenderGraphic.mnGraphicDataLength ),
      54                 :            :     maGraphicDataMimeType( rRenderGraphic.maGraphicDataMimeType ),
      55         [ #  # ]:          0 :     mapPrefMapMode( rRenderGraphic.mapPrefMapMode.get() ? new MapMode( *rRenderGraphic.mapPrefMapMode ) : NULL ),
      56 [ #  # ][ #  # ]:          0 :     mapPrefSize( rRenderGraphic.mapPrefSize.get() ? new Size( *rRenderGraphic.mapPrefSize ) : NULL )
         [ #  # ][ #  # ]
      57                 :            : {
      58                 :          0 : }
      59                 :            : 
      60                 :            : // -------------------------------------------------------------------------
      61                 :            : 
      62                 :          0 : RenderGraphic::RenderGraphic( const rtl::OUString& rGraphicDataMimeType,
      63                 :            :                               sal_uInt32 nGraphicDataLength,
      64                 :            :                               const sal_uInt8* pGraphicData ) :
      65                 :            :     maGraphicData(),
      66                 :            :     mnGraphicDataLength( nGraphicDataLength ),
      67                 :          0 :     maGraphicDataMimeType( rGraphicDataMimeType )
      68                 :            : {
      69 [ #  # ][ #  # ]:          0 :     if( !rGraphicDataMimeType.isEmpty( ) && nGraphicDataLength )
                 [ #  # ]
      70                 :            :     {
      71 [ #  # ][ #  # ]:          0 :         maGraphicData.reset( new sal_uInt8[ nGraphicDataLength ] );
      72                 :            : 
      73         [ #  # ]:          0 :         if( pGraphicData )
      74                 :            :         {
      75                 :          0 :             memcpy( maGraphicData.get(), pGraphicData, nGraphicDataLength );
      76                 :            :         }
      77                 :            :     }
      78                 :            :     else
      79                 :            :     {
      80         [ #  # ]:          0 :         ImplCheckData( );
      81                 :            :     }
      82                 :          0 : }
      83                 :            : 
      84                 :            : // -------------------------------------------------------------------------
      85                 :            : 
      86         [ #  # ]:          0 : RenderGraphic::~RenderGraphic( )
      87                 :            : {
      88         [ #  # ]:          0 : }
      89                 :            : 
      90                 :            : // -------------------------------------------------------------------------
      91                 :            : 
      92                 :          0 : RenderGraphic& RenderGraphic::operator=(const RenderGraphic& rRenderGraphic )
      93                 :            : {
      94                 :          0 :     maGraphicData = rRenderGraphic.maGraphicData;
      95                 :          0 :     mnGraphicDataLength = rRenderGraphic.mnGraphicDataLength;
      96                 :          0 :     maGraphicDataMimeType = rRenderGraphic.maGraphicDataMimeType;
      97 [ #  # ][ #  # ]:          0 :     mapPrefMapMode.reset( rRenderGraphic.mapPrefMapMode.get() ? new MapMode( *rRenderGraphic.mapPrefMapMode ) : NULL );
      98         [ #  # ]:          0 :     mapPrefSize.reset( rRenderGraphic.mapPrefSize.get() ? new Size( *rRenderGraphic.mapPrefSize ) : NULL );
      99                 :            : 
     100                 :          0 :     return( *this );
     101                 :            : }
     102                 :            : 
     103                 :            : // -------------------------------------------------------------------------
     104                 :            : 
     105                 :          0 : bool RenderGraphic::operator==(const RenderGraphic& rRenderGraphic ) const
     106                 :            : {
     107                 :            :     return( ( rRenderGraphic.mnGraphicDataLength == mnGraphicDataLength ) &&
     108                 :          0 :             ( rRenderGraphic.maGraphicData == maGraphicData ) &&
     109   [ #  #  #  # ]:          0 :             ( rRenderGraphic.maGraphicDataMimeType.equalsIgnoreAsciiCase( maGraphicDataMimeType ) ) );
                 [ #  # ]
     110                 :            : }
     111                 :            : 
     112                 :            : // -------------------------------------------------------------------------
     113                 :            : 
     114                 :          0 : bool RenderGraphic::operator!() const
     115                 :            : {
     116                 :          0 :     return( ( maGraphicDataMimeType.isEmpty( ) ) ||
     117                 :            :             ( 0 == mnGraphicDataLength ) ||
     118 [ #  # ][ #  # ]:          0 :             !maGraphicData.get( ) );
                 [ #  # ]
     119                 :            : }
     120                 :            : 
     121                 :            : // -------------------------------------------------------------------------
     122                 :            : 
     123                 :          0 : bool RenderGraphic::IsEqual( const RenderGraphic& rRenderGraphic ) const
     124                 :            : {
     125                 :            :     bool bRet = ( rRenderGraphic.mnGraphicDataLength == mnGraphicDataLength ) &&
     126 [ #  # ][ #  # ]:          0 :                 ( rRenderGraphic.maGraphicDataMimeType.equalsIgnoreAsciiCase( maGraphicDataMimeType ) );
     127                 :            : 
     128 [ #  # ][ #  # ]:          0 :     if( bRet && mnGraphicDataLength && ( rRenderGraphic.maGraphicData != maGraphicData ) )
         [ #  # ][ #  # ]
     129                 :            :     {
     130                 :          0 :         bRet = ( 0 == memcmp( rRenderGraphic.maGraphicData.get( ),
     131                 :          0 :                               maGraphicData.get( ),
     132                 :          0 :                               mnGraphicDataLength ) );
     133                 :            :     }
     134                 :            : 
     135                 :          0 :     return( bRet );
     136                 :            : }
     137                 :            : 
     138                 :            : // -------------------------------------------------------------------------
     139                 :            : 
     140                 :          0 : const MapMode& RenderGraphic::GetPrefMapMode() const
     141                 :            : {
     142                 :          0 :     ImplGetDefaults();
     143                 :          0 :     return( *mapPrefMapMode );
     144                 :            : }
     145                 :            : 
     146                 :            : // -------------------------------------------------------------------------
     147                 :            : 
     148                 :          0 : const Size& RenderGraphic::GetPrefSize() const
     149                 :            : {
     150                 :          0 :     ImplGetDefaults();
     151                 :          0 :     return( *mapPrefSize );
     152                 :            : }
     153                 :            : 
     154                 :            : // -------------------------------------------------------------------------
     155                 :            : 
     156                 :          0 : BitmapEx RenderGraphic::GetReplacement() const
     157                 :            : {
     158         [ #  # ]:          0 :     const RenderGraphicRasterizer aRasterizer( *this );
     159                 :            : 
     160 [ #  # ][ #  # ]:          0 :     return( aRasterizer.GetReplacement() );
     161                 :            : }
     162                 :            : 
     163                 :            : // -------------------------------------------------------------------------
     164                 :            : 
     165                 :          0 : void RenderGraphic::ImplCheckData( )
     166                 :            : {
     167         [ #  # ]:          0 :     if( !( *this ) )
     168                 :            :     {
     169                 :          0 :         maGraphicData.reset( );
     170                 :          0 :         mnGraphicDataLength = 0;
     171                 :          0 :         maGraphicDataMimeType = ::rtl::OUString();
     172                 :          0 :         mapPrefMapMode.reset();
     173                 :          0 :         mapPrefSize.reset();
     174                 :            :     }
     175                 :          0 : }
     176                 :            : 
     177                 :            : // -------------------------------------------------------------------------
     178                 :            : 
     179                 :          0 : void RenderGraphic::ImplGetDefaults() const
     180                 :            : {
     181 [ #  # ][ #  # ]:          0 :     if( !mapPrefMapMode.get() || !mapPrefSize.get() )
                 [ #  # ]
     182                 :            :     {
     183         [ #  # ]:          0 :         const RenderGraphicRasterizer aRasterizer( *this );
     184                 :            : 
     185 [ #  # ][ #  # ]:          0 :         mapPrefMapMode.reset( new MapMode( aRasterizer.GetPrefMapMode() ) );
     186 [ #  # ][ #  # ]:          0 :         mapPrefSize.reset( new Size( aRasterizer.GetPrefSize() ) );
                 [ #  # ]
     187                 :            :     }
     188                 :          0 : }
     189                 :            : 
     190                 :            : // -------------------------------------------------------------------------
     191                 :            : 
     192                 :          0 : ::SvStream& operator>>( ::SvStream& rIStm, RenderGraphic& rRenderGraphic )
     193                 :            : {
     194         [ #  # ]:          0 :     ::VersionCompat aVCompat( rIStm, STREAM_READ );
     195                 :          0 :     sal_uInt32      nGraphicDataLength = 0;
     196                 :            : 
     197         [ #  # ]:          0 :     rtl::OUString aGraphicDataMimeType = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIStm, RTL_TEXTENCODING_ASCII_US);
     198         [ #  # ]:          0 :     rIStm >> nGraphicDataLength;
     199                 :            : 
     200 [ #  # ][ #  # ]:          0 :     rRenderGraphic = RenderGraphic( aGraphicDataMimeType, nGraphicDataLength );
                 [ #  # ]
     201                 :            : 
     202 [ #  # ][ #  # ]:          0 :     if( !rRenderGraphic.IsEmpty() )
     203                 :            :     {
     204         [ #  # ]:          0 :         rIStm.Read( rRenderGraphic.GetGraphicData().get(), nGraphicDataLength );
     205                 :            :     }
     206                 :            : 
     207         [ #  # ]:          0 :     return rIStm;
     208                 :            : }
     209                 :            : 
     210                 :            : // ------------------------------------------------------------------
     211                 :            : 
     212                 :          0 : ::SvStream& operator<<( ::SvStream& rOStm, const RenderGraphic& rRenderGraphic )
     213                 :            : {
     214         [ #  # ]:          0 :     ::VersionCompat     aVCompat( rOStm, STREAM_WRITE, 1 );
     215                 :          0 :     const sal_uInt32    nGraphicDataLength = rRenderGraphic.GetGraphicDataLength();
     216                 :            : 
     217                 :          0 :     write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOStm, rRenderGraphic.GetGraphicDataMimeType(),
     218         [ #  # ]:          0 :         RTL_TEXTENCODING_ASCII_US);
     219         [ #  # ]:          0 :     rOStm << nGraphicDataLength;
     220                 :            : 
     221         [ #  # ]:          0 :     if( nGraphicDataLength )
     222                 :            :     {
     223         [ #  # ]:          0 :         rOStm.Write( rRenderGraphic.GetGraphicData().get(), nGraphicDataLength );
     224                 :            :     }
     225                 :            : 
     226         [ #  # ]:          0 :     return rOStm;
     227                 :            : }
     228                 :            : 
     229                 :            : } // VCL
     230                 :            : 
     231                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10