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

Generated by: LCOV version 1.10