LCOV - code coverage report
Current view: top level - include/vcl - gdimtf.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 8 0.0 %
Date: 2014-04-14 Functions: 0 8 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             : #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 <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             :     bool            bPause;
      85             :     bool            bRecord;
      86             :     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, 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             :     bool        operator==( const GDIMetaFile& rMtf ) const;
     130             :     bool        operator!=( const GDIMetaFile& rMtf ) const { return !( *this == rMtf ); }
     131             : 
     132             :     void            Clear();
     133             :     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             :                             bool bInvert = 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           0 :     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( bool bPause );
     171           0 :     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           0 :     MetaAction*     GetCurAction() const { return GetAction( nCurrentActionElement ); }
     189             :     /**
     190             :      * @param pAction takes ownership
     191             :      */
     192             :     MetaAction*     ReplaceAction( MetaAction* pAction, size_t nAction );
     193             : 
     194           0 :     const Size&     GetPrefSize() const { return aPrefSize; }
     195           0 :     void            SetPrefSize( const Size& rSize ) { aPrefSize = rSize; }
     196             : 
     197           0 :     const MapMode&  GetPrefMapMode() const { return aPrefMapMode; }
     198           0 :     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& ReadGDIMetaFile( SvStream& rIStm, GDIMetaFile& rGDIMetaFile );
     214             :     friend VCL_DLLPUBLIC SvStream& WriteGDIMetaFile( SvStream& rOStm, const GDIMetaFile& rGDIMetaFile );
     215             : 
     216             :     /// Creates an antialiased thumbnail, with maximum width or height of nMaximumExtent.
     217             :     bool        CreateThumbnail(BitmapEx& rBmpEx, sal_uInt32 nMaximumSize = 256) const;
     218             : 
     219             :     void            UseCanvas( bool _bUseCanvas );
     220           0 :     bool        GetUseCanvas() const { return bUseCanvas; }
     221             : };
     222             : 
     223             : /** Create a special metaaction that delegates rendering to specified
     224             :     service.
     225             : 
     226             :     This factory function creates a MetaCommentAction that delegates
     227             :     rendering to the specified services, once played back in the
     228             :     metafile.
     229             : 
     230             :     @param rRendererServiceName
     231             :     Renderer service. Gets an awt::XGraphic on instantiation
     232             : 
     233             :     @param rGraphicServiceName
     234             :     Graphic service. Gets the raw data on instantiation
     235             : 
     236             :     @param pData
     237             :     Raw data. Gets copied
     238             : 
     239             :     @param nDataSize
     240             :     Length, in byte, of raw data
     241             :  */
     242             : MetaCommentAction* makePluggableRendererAction( const OUString& rRendererServiceName,
     243             :                                                 const OUString& rGraphicServiceName,
     244             :                                                 const void* pData,
     245             :                                                 sal_uInt32 nDataSize );
     246             : 
     247             : #endif // INCLUDED_VCL_GDIMTF_HXX
     248             : 
     249             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10