LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/vcl - gfxlink.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 10 14 71.4 %
Date: 2013-07-09 Functions: 9 10 90.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             : #ifndef _SV_GFXLINK_HXX
      21             : #define _SV_GFXLINK_HXX
      22             : 
      23             : #include <vcl/dllapi.h>
      24             : #include <tools/solar.h>
      25             : #include <vcl/mapmod.hxx>
      26             : #include <tools/string.hxx>
      27             : #include <tools/stream.hxx>
      28             : 
      29             : // -------------
      30             : // - ImpBuffer -
      31             : // -------------
      32             : 
      33             : struct ImpBuffer
      34             : {
      35             :     sal_uLong       mnRefCount;
      36             :     sal_uInt8*      mpBuffer;
      37             : 
      38           0 :                 ImpBuffer( sal_uLong nSize )
      39             :                 {
      40           0 :                     mnRefCount = 1UL;
      41           0 :                     mpBuffer = nSize ? new sal_uInt8[ nSize ] : NULL;
      42           0 :                 }
      43             : 
      44         927 :                 ImpBuffer( sal_uInt8* pBuf ) { mnRefCount = 1UL; mpBuffer = pBuf; }
      45             : 
      46         927 :                 ~ImpBuffer() { delete[] mpBuffer; }
      47             : };
      48             : 
      49             : // -----------
      50             : // - ImpSwap -
      51             : // -----------
      52             : 
      53             : struct ImpSwap
      54             : {
      55             :     OUString   maURL;
      56             :     sal_uLong           mnDataSize;
      57             :     sal_uLong           mnRefCount;
      58             : 
      59             :                     ImpSwap( sal_uInt8* pData, sal_uLong nDataSize );
      60             :                     ~ImpSwap();
      61             : 
      62             :     sal_uInt8*          GetData() const;
      63             : 
      64        1866 :     sal_Bool            IsSwapped() const { return maURL.getLength() > 0; }
      65             : 
      66             :     void            WriteTo( SvStream& rOStm ) const;
      67             : };
      68             : 
      69             : // --------------
      70             : // - ImpGfxLink -
      71             : // --------------
      72             : 
      73       15769 : struct ImpGfxLink
      74             : {
      75             :     MapMode         maPrefMapMode;
      76             :     Size            maPrefSize;
      77             :     bool            mbPrefMapModeValid;
      78             :     bool            mbPrefSizeValid;
      79             : 
      80       10090 :     ImpGfxLink() :
      81             :         maPrefMapMode(),
      82             :         maPrefSize(),
      83             :         mbPrefMapModeValid( false ),
      84       10090 :         mbPrefSizeValid( false )
      85       10090 :     {}
      86             : };
      87             : 
      88             : //#endif // __PRIVATE
      89             : 
      90             : // ---------------
      91             : // - GfxLinkType -
      92             : // ---------------
      93             : 
      94             : enum GfxLinkType
      95             : {
      96             :     GFX_LINK_TYPE_NONE          = 0,
      97             :     GFX_LINK_TYPE_EPS_BUFFER    = 1,
      98             :     GFX_LINK_TYPE_NATIVE_GIF    = 2,    // Don't forget to update the following defines
      99             :     GFX_LINK_TYPE_NATIVE_JPG    = 3,    // Don't forget to update the following defines
     100             :     GFX_LINK_TYPE_NATIVE_PNG    = 4,    // Don't forget to update the following defines
     101             :     GFX_LINK_TYPE_NATIVE_TIF    = 5,    // Don't forget to update the following defines
     102             :     GFX_LINK_TYPE_NATIVE_WMF    = 6,    // Don't forget to update the following defines
     103             :     GFX_LINK_TYPE_NATIVE_MET    = 7,    // Don't forget to update the following defines
     104             :     GFX_LINK_TYPE_NATIVE_PCT    = 8,    // Don't forget to update the following defines
     105             :     GFX_LINK_TYPE_NATIVE_SVG    = 9,    // Don't forget to update the following defines
     106             :     GFX_LINK_TYPE_USER          = 0xffff
     107             : };
     108             : 
     109             : #define GFX_LINK_FIRST_NATIVE_ID    GFX_LINK_TYPE_NATIVE_GIF
     110             : #define GFX_LINK_LAST_NATIVE_ID     GFX_LINK_TYPE_NATIVE_SVG
     111             : 
     112             : // -----------
     113             : // - GfxLink -
     114             : // -----------
     115             : 
     116             : struct ImpBuffer;
     117             : struct ImpSwap;
     118             : struct ImpGfxLink;
     119             : class Graphic;
     120             : 
     121             : class VCL_DLLPUBLIC GfxLink
     122             : {
     123             : private:
     124             : 
     125             :     GfxLinkType         meType;
     126             :     ImpBuffer*          mpBuf;
     127             :     ImpSwap*            mpSwap;
     128             :     sal_uInt32          mnBufSize;
     129             :     sal_uInt32          mnUserId;
     130             :     ImpGfxLink*         mpImpData;
     131             :     sal_uLong               mnExtra2;
     132             : 
     133             :     SAL_DLLPRIVATE void ImplCopy( const GfxLink& rGfxLink );
     134             : 
     135             : public:
     136             :                         GfxLink();
     137             :                         GfxLink( const GfxLink& );
     138             :                         GfxLink( const String& rPath, GfxLinkType nType );
     139             :                         GfxLink( sal_uInt8* pBuf, sal_uInt32 nBufSize, GfxLinkType nType, sal_Bool bOwns );
     140             :                         ~GfxLink();
     141             : 
     142             :     GfxLink&            operator=( const GfxLink& );
     143             :     sal_Bool            IsEqual( const GfxLink& ) const;
     144             : 
     145             :     GfxLinkType         GetType() const;
     146             : 
     147           6 :     void                SetUserId( sal_uInt32 nUserId ) { mnUserId = nUserId; }
     148          11 :     sal_uInt32          GetUserId() const { return mnUserId; }
     149             : 
     150             :     sal_uInt32          GetDataSize() const;
     151             :     void                SetData( sal_uInt8* pBuf, sal_uInt32 nSize, GfxLinkType nType, sal_Bool bOwns );
     152             :     const sal_uInt8*            GetData() const;
     153             : 
     154             :     const Size&         GetPrefSize() const;
     155             :     void                SetPrefSize( const Size& rPrefSize );
     156             :     bool                IsPrefSizeValid();
     157             : 
     158             :     const MapMode&      GetPrefMapMode() const;
     159             :     void                SetPrefMapMode( const MapMode& rPrefMapMode );
     160             :     bool                IsPrefMapModeValid();
     161             : 
     162             :     sal_Bool                IsNative() const;
     163             :     sal_Bool                IsUser() const { return( GFX_LINK_TYPE_USER == meType ); }
     164             : 
     165             :     sal_Bool                LoadNative( Graphic& rGraphic );
     166             : 
     167             :     sal_Bool                ExportNative( SvStream& rOStream ) const;
     168             : 
     169             :     void                SwapOut();
     170             :     void                SwapIn();
     171        1644 :     sal_Bool                IsSwappedOut() const { return( mpSwap != NULL ); }
     172             : 
     173             : public:
     174             : 
     175             :     friend VCL_DLLPUBLIC SvStream&  operator<<( SvStream& rOStream, const GfxLink& rGfxLink );
     176             :     friend VCL_DLLPUBLIC SvStream&  operator>>( SvStream& rIStream, GfxLink& rGfxLink );
     177             : };
     178             : 
     179             : #endif
     180             : 
     181             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10