LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/vcl - gdimtf.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 8 8 100.0 %
Date: 2013-07-09 Functions: 8 8 100.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_GDIMTF_HXX
      21             : #define _SV_GDIMTF_HXX
      22             : 
      23             : #include <vcl/dllapi.h>
      24             : #include <tools/gen.hxx>
      25             : #include <tools/link.hxx>
      26             : #include <vcl/mapmod.hxx>
      27             : #include <vector>
      28             : 
      29             : class OutputDevice;
      30             : class MetaAction;
      31             : class MetaCommentAction;
      32             : class SvStream;
      33             : class Color;
      34             : class BitmapEx;
      35             : class Polygon;
      36             : class PolyPolygon;
      37             : class Gradient;
      38             : 
      39             : // ---------------------
      40             : // - GDIMetaFile-Types -
      41             : // ---------------------
      42             : 
      43             : #define GDI_METAFILE_END                ((size_t)0xFFFFFFFF)
      44             : #define GDI_METAFILE_LABEL_NOTFOUND     ((size_t)0xFFFFFFFF)
      45             : 
      46             : #ifndef METAFILE_END
      47             : #define METAFILE_END                    GDI_METAFILE_END
      48             : #endif
      49             : 
      50             : #ifndef METAFILE_LABEL_NOTFOUND
      51             : #define METAFILE_LABEL_NOTFOUND         GDI_METAFILE_LABEL_NOTFOUND
      52             : #endif
      53             : 
      54             : #define MTF_MIRROR_NONE             0x00000000UL
      55             : #define MTF_MIRROR_HORZ             0x00000001UL
      56             : #define MTF_MIRROR_VERT             0x00000002UL
      57             : 
      58             : enum MtfConversion
      59             : {
      60             :     MTF_CONVERSION_NONE = 0,
      61             :     MTF_CONVERSION_1BIT_THRESHOLD = 1,
      62             :     MTF_CONVERSION_8BIT_GREYS = 2
      63             : };
      64             : 
      65             : // -----------------------------
      66             : // - Color conversion routines -
      67             : // -----------------------------
      68             : 
      69             : typedef Color (*ColorExchangeFnc)( const Color& rColor, const void* pColParam );
      70             : typedef BitmapEx (*BmpExchangeFnc)( const BitmapEx& rBmpEx, const void* pBmpParam );
      71             : 
      72             : class VCL_DLLPUBLIC GDIMetaFile
      73             : {
      74             : private:
      75             :     ::std::vector< MetaAction* > aList;
      76             :     size_t          nCurrentActionElement;
      77             : 
      78             :     MapMode         aPrefMapMode;
      79             :     Size            aPrefSize;
      80             :     Link            aHookHdlLink;
      81             :     GDIMetaFile*    pPrev;
      82             :     GDIMetaFile*    pNext;
      83             :     OutputDevice*   pOutDev;
      84             :     sal_Bool            bPause;
      85             :     sal_Bool            bRecord;
      86             :     sal_Bool            bUseCanvas;
      87             : 
      88             : 
      89             :     SAL_DLLPRIVATE static Color    ImplColAdjustFnc( const Color& rColor, const void* pColParam );
      90             :     SAL_DLLPRIVATE static BitmapEx ImplBmpAdjustFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
      91             : 
      92             :     SAL_DLLPRIVATE static Color    ImplColConvertFnc( const Color& rColor, const void* pColParam );
      93             :     SAL_DLLPRIVATE static BitmapEx ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
      94             : 
      95             :     SAL_DLLPRIVATE static Color    ImplColMonoFnc( const Color& rColor, const void* pColParam );
      96             :     SAL_DLLPRIVATE static BitmapEx ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
      97             : 
      98             :     SAL_DLLPRIVATE static Color    ImplColReplaceFnc( const Color& rColor, const void* pColParam );
      99             :     SAL_DLLPRIVATE static BitmapEx ImplBmpReplaceFnc( const BitmapEx& rBmpEx, const void* pBmpParam );
     100             : 
     101             :     SAL_DLLPRIVATE void            ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pColParam,
     102             :                                                        BmpExchangeFnc pFncBmp, const void* pBmpParam );
     103             : 
     104             :     SAL_DLLPRIVATE Point           ImplGetRotatedPoint( const Point& rPt, const Point& rRotatePt,
     105             :                                                         const Size& rOffset, double fSin, double fCos );
     106             :     SAL_DLLPRIVATE Polygon         ImplGetRotatedPolygon( const Polygon& rPoly, const Point& rRotatePt,
     107             :                                                           const Size& rOffset, double fSin, double fCos );
     108             :     SAL_DLLPRIVATE PolyPolygon     ImplGetRotatedPolyPolygon( const PolyPolygon& rPoly, const Point& rRotatePt,
     109             :                                                               const Size& rOffset, double fSin, double fCos );
     110             :     SAL_DLLPRIVATE void            ImplAddGradientEx( GDIMetaFile&          rMtf,
     111             :                                                       const OutputDevice&   rMapDev,
     112             :                                                       const PolyPolygon&    rPolyPoly,
     113             :                                                       const Gradient&       rGrad       );
     114             :     SAL_DLLPRIVATE bool          ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, Size rLogicDestSize );
     115             :     SAL_DLLPRIVATE void          ImplDelegate2PluggableRenderer( const MetaCommentAction* pAct, OutputDevice* pOut );
     116             : 
     117             : 
     118             : protected:
     119             : 
     120             :     virtual void    Linker( OutputDevice* pOut, sal_Bool bLink );
     121             :     virtual long    Hook();
     122             : 
     123             : public:
     124             :                     GDIMetaFile();
     125             :                     GDIMetaFile( const GDIMetaFile& rMtf );
     126             :     virtual         ~GDIMetaFile();
     127             : 
     128             :     GDIMetaFile&    operator=( const GDIMetaFile& rMtf );
     129             :     sal_Bool        operator==( const GDIMetaFile& rMtf ) const;
     130             :     sal_Bool        operator!=( const GDIMetaFile& rMtf ) const { return !( *this == rMtf ); }
     131             : 
     132             :     void            Clear();
     133             :     sal_Bool        Mirror( sal_uLong nMirrorFlags );
     134             :     void            Move( long nX, long nY );
     135             :     // additional Move method getting specifics how to handle MapMode( MAP_PIXEL )
     136             :     void            Move( long nX, long nY, long nDPIX, long nDPIY );
     137             :     void            Scale( double fScaleX, double fScaleY );
     138             :     void            Scale( const Fraction& rScaleX, const Fraction& rScaleY );
     139             :     void            Rotate( long nAngle10 );
     140             :     void            Clip( const Rectangle& );
     141             :     /* get the bound rect of the contained actions
     142             :      * caveats:
     143             :      * - clip actions will limit the contained actions,
     144             :      *   but the current clipregion of the passed OutputDevice will not
     145             :      * - coordinates of actions will be transformed to preferred mapmode
     146             :      * - the returned rectangle is relative to the preferred mapmode of the metafile
     147             :     */
     148             :     Rectangle       GetBoundRect( OutputDevice& i_rReference, Rectangle* pHairline = 0 ) const;
     149             : 
     150             :     void            Adjust( short nLuminancePercent = 0, short nContrastPercent = 0,
     151             :                             short nChannelRPercent = 0,  short nChannelGPercent = 0,
     152             :                             short nChannelBPercent = 0,  double fGamma = 1.0,
     153             :                             sal_Bool bInvert = sal_False
     154             :                     );
     155             : 
     156             :     void            Convert( MtfConversion eConversion );
     157             :     void            ReplaceColors( const Color* pSearchColors, const Color* rReplaceColors,
     158             :                                    sal_uLong nColorCount, sal_uLong* pTols = NULL );
     159             : 
     160             :     GDIMetaFile     GetMonochromeMtf( const Color& rCol ) const;
     161             : 
     162             :     void            Record( OutputDevice* pOutDev );
     163        2857 :     sal_Bool        IsRecord() const { return bRecord; }
     164             : 
     165             :     void            Play( GDIMetaFile& rMtf, size_t nPos = GDI_METAFILE_END );
     166             :     void            Play( OutputDevice* pOutDev, size_t nPos = GDI_METAFILE_END );
     167             :     void            Play( OutputDevice* pOutDev, const Point& rPos,
     168             :                           const Size& rSize, size_t nPos = GDI_METAFILE_END );
     169             : 
     170             :     void            Pause( sal_Bool bPause );
     171         163 :     sal_Bool        IsPause() const { return bPause; }
     172             : 
     173             :     void            Stop();
     174             : 
     175             :     void            WindStart();
     176             :     void            WindPrev();
     177             : 
     178             :     size_t          GetActionSize() const;
     179             : 
     180             :     void            AddAction( MetaAction* pAction );
     181             :     void            AddAction( MetaAction* pAction, size_t nPos );
     182             :     void            RemoveAction( size_t nPos );
     183             :     void            push_back( MetaAction* pAction );
     184             : 
     185             :     MetaAction*     FirstAction();
     186             :     MetaAction*     NextAction();
     187             :     MetaAction*     GetAction( size_t nAction ) const;
     188        5366 :     MetaAction*     GetCurAction() const { return GetAction( nCurrentActionElement ); }
     189             :     /**
     190             :      * @param pAction takes ownership
     191             :      */
     192             :     MetaAction*     ReplaceAction( MetaAction* pAction, size_t nAction );
     193             : 
     194        1050 :     const Size&     GetPrefSize() const { return aPrefSize; }
     195        2876 :     void            SetPrefSize( const Size& rSize ) { aPrefSize = rSize; }
     196             : 
     197         793 :     const MapMode&  GetPrefMapMode() const { return aPrefMapMode; }
     198        2876 :     void            SetPrefMapMode( const MapMode& rMapMode ) { aPrefMapMode = rMapMode; }
     199             : 
     200             :     void            SetHookHdl( const Link& rLink ) { aHookHdlLink = rLink; }
     201             :     const Link&     GetHookHdl() const { return aHookHdlLink; }
     202             : 
     203             :     sal_uLong       GetChecksum() const;
     204             :     sal_uLong       GetSizeBytes() const;
     205             : 
     206             :     // Methods for reading and writing the new formats;
     207             :     // the Read method also reads the old format
     208             :     SvStream&       Read( SvStream& rIStm );
     209             :     SvStream&       Write( SvStream& rOStm );
     210             : 
     211             :     // Stream-operators write (still) the old format
     212             :     // and read both the old and the new format
     213             :     friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, GDIMetaFile& rGDIMetaFile );
     214             :     friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const GDIMetaFile& rGDIMetaFile );
     215             : 
     216             :     sal_Bool        CreateThumbnail( sal_uInt32 nMaximumExtent, BitmapEx& rBmpEx, const BitmapEx* pOverlay = NULL, const Rectangle* pOverlayRect = NULL ) const;
     217             : 
     218             :     void            UseCanvas( sal_Bool _bUseCanvas );
     219           5 :     sal_Bool        GetUseCanvas() const { return bUseCanvas; }
     220             : };
     221             : 
     222             : /** Create a special metaaction that delegates rendering to specified
     223             :     service.
     224             : 
     225             :     This factory function creates a MetaCommentAction that delegates
     226             :     rendering to the specified services, once played back in the
     227             :     metafile.
     228             : 
     229             :     @param rRendererServiceName
     230             :     Renderer service. Gets an awt::XGraphic on instantiation
     231             : 
     232             :     @param rGraphicServiceName
     233             :     Graphic service. Gets the raw data on instantiation
     234             : 
     235             :     @param pData
     236             :     Raw data. Gets copied
     237             : 
     238             :     @param nDataSize
     239             :     Length, in byte, of raw data
     240             :  */
     241             : MetaCommentAction* makePluggableRendererAction( const OUString& rRendererServiceName,
     242             :                                                 const OUString& rGraphicServiceName,
     243             :                                                 const void* pData,
     244             :                                                 sal_uInt32 nDataSize );
     245             : 
     246             : #endif // _SV_GDIMTF_HXX
     247             : 
     248             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10