LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/filter/wmf - wmfwr.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 3 100.0 %
Date: 2012-12-27 Functions: 4 4 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 _WMFWR_HXX
      21             : #define _WMFWR_HXX
      22             : 
      23             : #include <vcl/metaact.hxx>
      24             : #include <vcl/graph.hxx>
      25             : #include <vcl/gdimtf.hxx>
      26             : #include <vcl/virdev.hxx>
      27             : #include <svtools/fltcall.hxx>
      28             : 
      29             : // -----------------------------------------------------------------------------
      30             : 
      31             : #define MAXOBJECTHANDLES 16
      32             : 
      33             : // -----------------------------------------------------------------------------
      34             : 
      35         758 : struct WMFWriterAttrStackMember
      36             : {
      37             :     struct WMFWriterAttrStackMember * pSucc;
      38             :     Color aLineColor;
      39             :     Color aFillColor;
      40             :     Color aTextColor;
      41             :     LineInfo aLineInfo;
      42             :     TextAlign eTextAlign;
      43             :     RasterOp eRasterOp;
      44             :     Font aFont;
      45             :     MapMode aMapMode;
      46             :     Region aClipRegion;
      47             :     sal_uInt16 nFlags;
      48             : };
      49             : 
      50             : // -------------
      51             : // - WMFWriter -
      52             : // -------------
      53             : 
      54             : class StarSymbolToMSMultiFont;
      55             : class LineInfo;
      56             : namespace basegfx { class B2DPolygon; }
      57             : 
      58          29 : class WMFWriter
      59             : {
      60             : private:
      61             : 
      62             :     sal_Bool            bStatus;
      63             : 
      64             :     sal_uLong                   nLastPercent; // Mit welcher Zahl pCallback zuletzt aufgerufen wurde.
      65             :     FilterConfigItem*       pFilterConfigItem;
      66             : 
      67             :     com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
      68             : 
      69             :     SvStream*               pWMF;
      70             :     VirtualDevice*          pVirDev;
      71             :     StarSymbolToMSMultiFont *pConvert;
      72             :     MapMode                 aTargetMapMode;
      73             :     Size                    aTargetSize;
      74             :     sal_uInt16                  nTargetDivisor;
      75             : 
      76             :     sal_uLong nMetafileHeaderPos;
      77             :     sal_uInt32 nMaxRecordSize; // in Worten
      78             :     sal_uLong nActRecordPos;
      79             : 
      80             :     // Aktuelle Attribute im Quell-Metafile:
      81             :     Color     aSrcLineColor;
      82             :     Color     aSrcFillColor;
      83             :     Color     aSrcTextColor;
      84             :     LineInfo  aSrcLineInfo;
      85             :     RasterOp  eSrcRasterOp;
      86             :     FontAlign eSrcTextAlign;
      87             :     Font      aSrcFont;
      88             :     MapMode   aSrcMapMode;
      89             :     sal_Bool      bSrcIsClipping;
      90             :     Region    aSrcClipRegion;
      91             :     WMFWriterAttrStackMember * pAttrStack;
      92             : 
      93             :     sal_uInt32    eSrcHorTextAlign;
      94             : 
      95             :     // Aktuelle Attribute im Ziel-Metafile:
      96             :     Color     aDstLineColor;
      97             :     Color     aDstFillColor;
      98             :     Color     aDstTextColor;
      99             :     LineInfo  aDstLineInfo;
     100             :     RasterOp  eDstROP2;
     101             :     FontAlign eDstTextAlign;
     102             :     Font      aDstFont;
     103             : 
     104             :     sal_uInt32    eDstHorTextAlign;
     105             : 
     106             :     sal_Bool      bDstIsClipping; // ???: derzeit unberuecksichtigt
     107             :     Region    aDstClipRegion; // ???: derzeit unberuecksichtigt
     108             :     sal_Bool bHandleAllocated[MAXOBJECTHANDLES];             // Welche Handles vergeben sind
     109             :     sal_uInt16 nDstPenHandle,nDstFontHandle,nDstBrushHandle; // Welche Handles die jeweiligen
     110             :                                                          // Selected-Objects besitzen
     111             :                                                          // 0xffff = keines:
     112             : 
     113             :     // Damit nicht bei jeder Operation alle Attribute verglichen werden muessen:
     114             : 
     115             :     sal_uLong nNumberOfActions; // Anzahl der Actions im GDIMetafile
     116             :     sal_uLong nNumberOfBitmaps; // Anzahl der Bitmaps
     117             :     sal_uLong nWrittenActions;  // Anzahl der bereits verarbeiteten Actions beim Schreiben der Orders
     118             :     sal_uLong nWrittenBitmaps;  // Anzahl der bereits geschriebenen Bitmaps
     119             :     sal_uLong nActBitmapPercent; // Wieviel Prozent die naechste Bitmap schon geschrieben ist.
     120             : 
     121             :     sal_Bool bEmbedEMF; // optionally embedd EMF data into WMF
     122             : 
     123             :     void MayCallback();
     124             :         // Berechnet anhand der obigen 5 Parameter eine Prozentzahl
     125             :         // und macht dann ggf. einen Callback. Setzt bStatus auf FALSE wenn User abbrechen
     126             :         // moechte.
     127             : 
     128             :     void CountActionsAndBitmaps(const GDIMetaFile & rMTF);
     129             :         // Zaehlt die Bitmaps und Actions (nNumberOfActions und nNumberOfBitmaps muessen
     130             :         // zu Anfang auf 0 gesetzt werden, weil diese Methode rekursiv ist)
     131             : 
     132             :     void WritePointXY(const Point & rPoint);
     133             :     void WritePointYX(const Point & rPoint);
     134             :     sal_Int32 ScaleWidth( sal_Int32 nDX );
     135             :     void WriteSize(const Size & rSize);
     136             :     void WriteHeightWidth(const Size & rSize);
     137             :     void WriteRectangle(const Rectangle & rRect);
     138             :     void WriteColor(const Color & rColor);
     139             : 
     140             :     void WriteRecordHeader(sal_uInt32 nSizeWords, sal_uInt16 nType);
     141             :         // nSizeWords ist die Groesse des gesammten Records in Anzahl Worte.
     142             :         // Wenn nSizeWords unbekannt ist, dann 0 einsetzen (siehe UpdateRecordHeader()).
     143             : 
     144             :     void UpdateRecordHeader();
     145             :         // berichtig die Groesse des Records nach dem Schreiben der Parameter, wenn
     146             :         // nSizeWords bei Aufruf von WriteRecordHeader(..) unbekannt war.
     147             :         // fuegt ggf. noch ein BYTE 0 ein damit Anzahl Bytes immer gerade.
     148             : 
     149             :     void WMFRecord_Arc(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt);
     150             :     void WMFRecord_Chord(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt);
     151             :     void WMFRecord_CreateBrushIndirect(const Color& rColor);
     152             :     void WMFRecord_CreateFontIndirect(const Font & rFont);
     153             :     void WMFRecord_CreatePenIndirect(const Color& rColor, const LineInfo& rLineInfo );
     154             :     void WMFRecord_DeleteObject(sal_uInt16 nObjectHandle);
     155             :     void WMFRecord_Ellipse(const Rectangle & rRect);
     156             :     void WMFRecord_Escape( sal_uInt32 nEsc, sal_uInt32 nLen, const sal_Int8* pData );
     157             :     sal_Bool WMFRecord_Escape_Unicode( const Point& rPoint, const String& rStr, const sal_Int32 * pDXAry );
     158             :     void WMFRecord_ExtTextOut(const Point & rPoint, const String & rString, const sal_Int32 * pDXAry);
     159             : 
     160             :     void TrueExtTextOut(const Point & rPoint, const String & rString,
     161             :         const rtl::OString& rByteString, const sal_Int32 * pDXAry);
     162             :     void TrueTextOut(const Point & rPoint, const rtl::OString& rString);
     163             :     void WMFRecord_LineTo(const Point & rPoint);
     164             :     void WMFRecord_MoveTo(const Point & rPoint);
     165             :     void WMFRecord_Pie(const Rectangle & rRect, const Point & rStartPt, const Point & rEndPt);
     166             :     void WMFRecord_Polygon(const Polygon & rPoly);
     167             :     void WMFRecord_PolyLine(const Polygon & rPoly);
     168             :     void WMFRecord_PolyPolygon(const PolyPolygon & rPolyPoly);
     169             :     void WMFRecord_Rectangle(const Rectangle & rRect);
     170             :     void WMFRecord_RestoreDC();
     171             :     void WMFRecord_RoundRect(const Rectangle & rRect, long nHorzRound, long nVertRound);
     172             :     void WMFRecord_SaveDC();
     173             :     void WMFRecord_SelectObject(sal_uInt16 nObjectHandle);
     174             :     void WMFRecord_SetBkMode(sal_Bool bTransparent);
     175             :     void WMFRecord_SetStretchBltMode();
     176             :     void WMFRecord_SetPixel(const Point & rPoint, const Color & rColor);
     177             :     void WMFRecord_SetROP2(RasterOp eROP);
     178             :     void WMFRecord_SetTextAlign(FontAlign eFontAlign, sal_uInt32 eHorTextAlign);
     179             :     void WMFRecord_SetTextColor(const Color & rColor);
     180             :     void WMFRecord_SetWindowExt(const Size & rSize);
     181             :     void WMFRecord_SetWindowOrg(const Point & rPoint);
     182             :     void WMFRecord_StretchDIB(const Point & rPoint, const Size & rSize, const Bitmap & rBitmap, sal_uInt32 nROP = 0UL );
     183             :     void WMFRecord_TextOut(const Point & rPoint, const String & rString);
     184             :     void WMFRecord_EndOfFile();
     185             :     void WMFRecord_IntersectClipRect( const Rectangle& rRect);
     186             : 
     187             :     sal_uInt16 AllocHandle();
     188             :     void FreeHandle(sal_uInt16 nObjectHandle);
     189             :     void CreateSelectDeletePen( const Color& rColor, const LineInfo& rLineInfo );
     190             :     void CreateSelectDeleteFont(const Font & rFont);
     191             :     void CreateSelectDeleteBrush(const Color& rColor);
     192             : 
     193             :     void SetLineAndFillAttr();
     194             :     void SetAllAttr();
     195             : 
     196             :     void HandleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon);
     197             :     void WriteRecords(const GDIMetaFile & rMTF);
     198             : 
     199             :     void WriteHeader(const GDIMetaFile & rMTF, sal_Bool bPlaceable);
     200             :     void UpdateHeader();
     201             : 
     202             :     void WriteEmbeddedEMF( const GDIMetaFile& rMTF );
     203             :     void WriteEMFRecord( SvMemoryStream& rStream, sal_uInt32 nCurSize,
     204             :                             sal_uInt32 nRemainingSize,
     205             :                             sal_uInt32 nTotalSize,
     206             :                             sal_uInt32 nRecCounts,
     207             :                             sal_uInt16 nCheckSum );
     208             : 
     209             :     sal_uInt16 CalcSaveTargetMapMode(MapMode& rMapMode, const Size& rPrefSize);
     210             : 
     211             : public:
     212             : 
     213          29 :     WMFWriter() {}
     214             : 
     215             :     sal_Bool WriteWMF(const GDIMetaFile & rMTF, SvStream & rTargetStream, FilterConfigItem* pFilterConfigItem, sal_Bool bPlaceable=sal_True);
     216             : };
     217             : 
     218             : #endif
     219             : 
     220             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10