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

Generated by: LCOV version 1.10