LCOV - code coverage report
Current view: top level - vcl/source/filter - sgvmain.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 17 27 63.0 %
Date: 2014-11-03 Functions: 15 35 42.9 %
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_SOURCE_FILTER_SGVMAIN_HXX
      21             : #define INCLUDED_VCL_SOURCE_FILTER_SGVMAIN_HXX
      22             : 
      23             : #include <vcl/font.hxx>
      24             : #include <vcl/outdev.hxx>
      25             : #include <vcl/virdev.hxx>
      26             : 
      27             : #define UCHAR unsigned char
      28             : 
      29             : struct PointType {
      30             :     sal_Int16 x;
      31             :     sal_Int16 y;
      32         250 :     PointType()
      33             :         : x(0)
      34         250 :         , y(0)
      35             :     {
      36         250 :     }
      37             : };
      38             : 
      39             : #define SgfDpmm 40
      40             : 
      41             : #define DtHdSize 256
      42             : class DtHdType {
      43             : public:
      44             :     sal_uInt8  Reserved[256];
      45             :     friend SvStream& ReadDtHdType(SvStream& rIStream, DtHdType& rDtHd);
      46             :     friend void DtHdOverSeek(SvStream& rInp);
      47             : };
      48             : 
      49           4 : struct Seitenformat {
      50             :     PointType        Size;        // 0.00mm...819.175mm (papersize)
      51             :     sal_Int16        RandL;       // left     border on
      52             :     sal_Int16        RandR;       // right    paper
      53             :     sal_Int16        RandO;       // upper    border on
      54             :     sal_Int16        RandU;       // lower    paper
      55             :     sal_uInt8        PColor;      // future use
      56             :     sal_uInt8        PIntens;     // future use
      57             : };
      58             : 
      59             : #define PageSize 146
      60             : class PageType {
      61             : public:
      62             :     sal_uInt32       Next;        // next page
      63             :     sal_uInt32       nList;       // objectdata, first record
      64             :     sal_uInt32       ListEnd;     // objectdata, last record
      65             :     Seitenformat     Paper;       // data of paper
      66             :     bool         BorderClip;  // clip objects at border (cheat due to alignment in NT)
      67             :     sal_uInt8        StdPg;       // insert which standardpage ?
      68             :     PointType        U;           // origin
      69             :     sal_Int16        HlpLnH[20];  // guides
      70             :     sal_Int16        HlpLnV[20];
      71             :     sal_uInt8        LnAnzH;
      72             :     sal_uInt8        LnAnzV;
      73             :     UCHAR            PgName[32];  // page name
      74             :     friend SvStream& ReadPageType(SvStream& rIStream, PageType& rPage);
      75             :     PageType();
      76             : };
      77             : 
      78             : enum ObjArtType {ObjStrk,ObjRect,ObjPoly,ObjCirc,ObjSpln,
      79             :                  ObjText,ObjGrup,ObjBmap,ObjVirt,ObjTxtX,ObjMaxi};
      80             : 
      81             : struct ObjLineType {
      82             :     sal_uInt8   LFarbe;    //  [Index]
      83             :     sal_uInt8   LBFarbe;   //  [Index]
      84             :     sal_uInt8   LIntens;   //  [%]
      85             :     sal_uInt8   LMuster;   //  [Index] including transparency
      86             :     sal_Int16   LMSize;    //  [coefficient/100]
      87             :     sal_Int16   LDicke;    //  line thickness
      88             : };
      89             : 
      90             : struct ObjAreaType {
      91             :     sal_uInt8   FFarbe;    //  [Index]
      92             :     sal_uInt8   FBFarbe;   //  [Index]
      93             :     sal_uInt8   FIntens;   //  [%]
      94             :     // Despite the "Dummy" in the name, and not being used anywhere in
      95             :     // the code, these two fields are *essential*. These structs are
      96             :     // 1:1 mappings of actual on-disk/wire file format structures...
      97             :     // So don't clean the "unused dummy" fields away. (Actually it
      98             :     // might well be that many other fields around here are never used
      99             :     // in our code either.)
     100             :     sal_uInt8   FDummy1;
     101             :     sal_Int16   FDummy2;
     102             :     sal_uInt16  FMuster;   //  [Index] incl. Invers, transparency
     103             : 
     104          14 :     ObjAreaType()
     105             :         : FFarbe(0)
     106             :         , FBFarbe(0)
     107             :         , FIntens(0)
     108             :         , FDummy1(0)
     109             :         , FDummy2(0)
     110          14 :         , FMuster(0)
     111             :     {
     112          14 :     }
     113             : };
     114             : 
     115             : #define ObjTextTypeSize 64
     116           0 : class ObjTextType {
     117             : public:
     118             :     ObjLineType  L;             // text outline (future)
     119             :     ObjAreaType  F;             // inner text
     120             :     sal_uInt16   FontLo,FontHi; // e.g. 92500 (CG Times), split due to DWordAllign in TextType.
     121             :     sal_uInt16   Grad;          // 0.5..32767.5 pt - we should stop at 1000 pt
     122             :     sal_uInt16   Breite;        // 1..65535%  please not more as 500%
     123             :     sal_uInt8    Justify;       // 2 bit vertical (Hi), 3 bit horizontal (Lo)
     124             :     sal_uInt8    Kapit;         // 1..255%
     125             :     sal_uInt16   Schnitt;       // 8 flags
     126             :     sal_uInt16   LnFeed;        // 1..32767% of max font size of the line
     127             :     sal_uInt16   Slant;         // slant angle 0.00..89.99deg default 15.00deg viewed double width)
     128             :     sal_uInt8    ZAbst;         // character spacing 0..255% (0=on the line; 100=normal; 200=Zeichen wird als
     129             :     signed char  ChrVPos;       // vertical position of char. Default 0=on baseline, 10=5Pt below (-64..63")
     130             :     ObjLineType  ShdL;          // shadow outline (new 2.0)
     131             :     ObjAreaType  ShdF;          // shadow inside  (new 2.0)
     132             :     PointType    ShdVers;       // shadow offset max. 300.00%
     133             :     bool     ShdAbs;        // True-> shadow offset is absolute instead of relative to font size
     134             :     bool     NoSpc;         // True-> no space (for background area)
     135             :     ObjAreaType  BackF;         // background area
     136             :     sal_uInt32 GetFont();
     137             :     void   SetFont(sal_uInt32 FontID);
     138             : };
     139             : 
     140          20 : class Obj0Type {                // SuperClass for Apple-VMT
     141             : public:
     142             :     virtual void Draw(OutputDevice& rOut);
     143          20 :     virtual ~Obj0Type() {}
     144             : };
     145             : 
     146             : #define ObjkSize 20                /* should be 21. due to allignment we shifted the flag */
     147          20 : class ObjkType: public Obj0Type {  // basic componenents of all Stardraw objects
     148             : public:
     149             :     sal_uInt32     Last;
     150             :     sal_uInt32     Next;
     151             :     sal_uInt16     MemSize;    // in bytes
     152             :     PointType      ObjMin;     // XY minimum of the object
     153             :     PointType      ObjMax;     // XY maximum of the object
     154             :     sal_uInt8      Art;
     155             :     sal_uInt8      Layer;
     156          20 :     ObjkType()
     157             :         : Last(0)
     158             :         , Next(0)
     159             :         , MemSize(0)
     160             :         , Art(0)
     161          20 :         , Layer(0)
     162             :     {
     163          20 :     }
     164             :     friend SvStream& ReadObjkType(SvStream& rIStream, ObjkType& rObjk);
     165             :     friend bool ObjOverSeek(SvStream& rInp, ObjkType& rObjk);
     166             :     virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
     167             : };
     168             : 
     169             : #define StrkSize 38
     170           0 : class StrkType: public ObjkType {
     171             : public:
     172             :     sal_uInt8       Flags;     // (cheat due to alignment in NT)
     173             :     sal_uInt8       LEnden;    // line ends
     174             :     ObjLineType     L;
     175             :     PointType       Pos1;      // start point
     176             :     PointType       Pos2;      // end point
     177             :     friend SvStream& ReadStrkType(SvStream& rIStream, StrkType& rStrk);
     178             :     virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
     179             : };
     180             : 
     181             : #define RectSize 52
     182           0 : class RectType: public ObjkType {
     183             : public:
     184             :     sal_uInt8       Flags;     // (cheat due to alignment in NT)
     185             :     sal_uInt8       Reserve;
     186             :     ObjLineType     L;
     187             :     ObjAreaType     F;
     188             :     PointType       Pos1;      // lower left corner = reference point
     189             :     PointType       Pos2;      // right corner
     190             :     sal_Int16       Radius;    // radius of corner
     191             :     sal_uInt16      DrehWink;  //  315...<45
     192             :     sal_uInt16      Slant;     // >270...<90
     193             :     friend SvStream& ReadRectType(SvStream& rIStream, RectType& rRect);
     194             :     virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
     195             : };
     196             : 
     197             : #define PolySize 44
     198          12 : class PolyType: public ObjkType { // identical to spline !
     199             : public:
     200             :     sal_uInt8        Flags;   // (cheat due to alignment in NT)
     201             :     sal_uInt8        LEnden;  // only for polyline
     202             :     ObjLineType      L;
     203             :     ObjAreaType      F;       // not for polyline
     204             :     sal_uInt8        nPoints;
     205             :     sal_uInt8        Reserve;
     206             :     sal_uInt32       SD_EckP; // pointer to corner point (StarDraw)
     207             :     PointType*       EckP;    // pointer to corner points (StarView (is not read from disk!))
     208             :     friend SvStream& ReadPolyType(SvStream& rIStream, PolyType& rPoly);
     209             :     virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
     210             : };
     211             : #define  PolyClosBit 0x01     // kinds of Poly:   0: polyLine  1: polygon
     212             : 
     213             : #define SplnSize 44
     214          12 : class SplnType: public ObjkType { // identical to Poly !
     215             : public:
     216             :     sal_uInt8        Flags;   // (cheat due to alignment in NT)
     217             :     sal_uInt8        LEnden;  // only for nSpline
     218             :     ObjLineType L;
     219             :     ObjAreaType F;            // not for nSpline
     220             :     sal_uInt8        nPoints;
     221             :     sal_uInt8        Reserve;
     222             :     sal_uInt32       SD_EckP; // pointer to corner points (StarDraw)
     223             :     PointType*       EckP;    // pointer to corner points (StarView (is not read from disk!))
     224             :     friend SvStream& ReadSplnType(SvStream& rIStream, SplnType& rSpln);
     225             :     virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
     226             : };
     227             : // kinds of Spline: see Poly
     228             : 
     229             : #define CircSize 52
     230           4 : class CircType: public ObjkType {
     231             : public:
     232             :     sal_uInt8       Flags;     // (cheat due to alignment in NT)
     233             :     sal_uInt8       LEnden;    // only arcs (circle & ellips)
     234             :     ObjLineType     L;
     235             :     ObjAreaType     F;         // not for arcs (circly & ellips)
     236             :     PointType       Center;    // center
     237             :     PointType       Radius;    // radius
     238             :     sal_uInt16      DrehWink;  // only ellipses
     239             :     sal_uInt16      StartWink; // and not for full circles
     240             :     sal_uInt16      RelWink;   // and full ellipses
     241             :     friend SvStream& ReadCircType(SvStream& rIStream, CircType& rCirc);
     242             :     virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
     243             : };
     244             : #define CircFull 0x00  /* kinds of circle: 0: full circle    */
     245             : #define CircSect 0x01  /*                  1: circle sector  */
     246             : #define CircAbsn 0x02  /*                  2: circle segment */
     247             : #define CircArc  0x03  /*                  3: circle arc     */
     248             : 
     249             : #define TextSize 116
     250           0 : class TextType: public ObjkType {
     251             : public:
     252             :     sal_uInt8   Flags;       // (cheat due to alignment in NT)
     253             :     sal_uInt8   Reserve;     // for Word Allign
     254             :     ObjTextType T;           // 64 bytes  << DWord-Allign needed for FontID
     255             :     PointType   Pos1;        // reference point (upper left)
     256             :     PointType   Pos2;        //                 (lower right)
     257             :     sal_Int16   TopOfs;      // from upper side to start of text (future for vJustify)
     258             :     sal_uInt16  DrehWink;    //    0...<360
     259             :     sal_uInt16  BoxSlant;    // >270...<90 (only Box)
     260             :     sal_uInt16  BufSize;     // size of buffer for Load, Save, Copy etc.
     261             :     sal_uInt16  BufLo,BufHi; // (UCHAR*) pointer to Textbuffer << ShortArr, otherwise DWord-Allign needed
     262             :     sal_uInt16  ExtLo,ExtHi; // (Ptr)  text over more frames << ShortArr, otherwise DWord-Allign needed
     263             :     PointType   FitSize;     // size of origin for Fit2Size
     264             :     sal_Int16   FitBreit;    // width to format for Fit2Size
     265             :     UCHAR*      Buffer;      // this variable is not set by reading from disk, but explicit!
     266             :     friend SvStream& ReadTextType(SvStream& rIStream, TextType& rText);
     267             :     virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
     268             : };
     269             : #define TextOutlBit 0x01     /*       1=Sourcecode for outliner (ignored byDrawObjekt()) */
     270             : #define TextFitSBit 0x02     /* Bit1: 1=Text-Fit2Size, also outliner  (2.0)              */
     271             : #define TextDrftBit 0x04     /* Bit2: 1=DraftDraw                     (2.0)              */
     272             : #define TextFitZBit 0x08     /* Bit3: 1=Fit2Size line by line         (2.0)              */
     273             : #define TextFitBits (TextFitSBit | TextFitZBit)
     274             : 
     275             : enum GrafStat {NoGraf,Pic,Pcx,Hpgl,Img,Msp,Tiff,Dxf,Lot,Usr,Sgf};
     276             : 
     277             : #define BmapSize 132
     278           0 : class BmapType: public ObjkType {
     279             : public:
     280             :     sal_uInt8   Flags;        // (cheat due to alignment in NT)
     281             :     sal_uInt8   Reserve;
     282             :     ObjAreaType F;            // colour and pattern of first plane bitmap
     283             :     PointType   Pos1;
     284             :     PointType   Pos2;
     285             :     sal_uInt16  DrehWink;     //  315...<45   (future)
     286             :     sal_uInt16  Slant;        // >270...<90   (future)
     287             :     UCHAR       Filename[80]; // path
     288             :     PointType   PixSize;      // size in Pixel (0 for vector)
     289             :     GrafStat    Format;       // see: GpmDef.Pas
     290             :     sal_uInt8   nPlanes;      // number of bitplanes (0 for vector)
     291             :     bool    RawOut;       // output as raw  ?
     292             :     bool    InvOut;       // output inverted ?
     293             :     bool    LightOut;     // brighten? (SD20)
     294             :     sal_uInt8   GrfFlg;       // (SD20) 0=nSGF 1=Pcx 2=HPGL 4=Raw $FF=Undef (to fix DrawBmp)
     295             :     INetURLObject aFltPath;   // for GraphicFilter
     296             : 
     297           0 :     BmapType()
     298             :         : Flags(0)
     299             :         , Reserve(0)
     300             :         , DrehWink(0)
     301             :         , Slant(0)
     302             :         , Format(NoGraf)
     303             :         , nPlanes(0)
     304             :         , RawOut(false)
     305             :         , InvOut(false)
     306             :         , LightOut(false)
     307           0 :         , GrfFlg(0)
     308             :     {
     309           0 :         memset(Filename, 0, sizeof(Filename));
     310           0 :     }
     311             : 
     312             :     friend SvStream& ReadBmapType(SvStream& rIStream, BmapType& rBmap);
     313             :     virtual void Draw(OutputDevice& rOut) SAL_OVERRIDE;
     314             :     void SetPaths( const INetURLObject& rFltPath );
     315             : };
     316             : 
     317             : #define GrupSize 48
     318           4 : class GrupType: public ObjkType {
     319             : public:
     320             :     sal_uInt8   Flags;         // (cheat due to alignment in NT)
     321             :     UCHAR       Name[13];      // name of group
     322             :     sal_uInt16  SbLo,SbHi;     // (Ptr) group list << ShortArr, as otherwise DWord alignment needed
     323             :     sal_uInt16  UpLo,UpHi;     // (Ptr) parent list << ShortArr, as otherwise DWord alignment needed
     324             :     sal_uInt16  ChartSize;     // required amount of memory for structure of diagram structure
     325             :     sal_uInt32  ChartPtr;      // diagram structure
     326             :     sal_uInt32  GetSubPtr();   // only to check if Sublist is empty
     327             :     friend SvStream& ReadGrupType(SvStream& rIStream, GrupType& rGrup);
     328             : };
     329             : 
     330             : void SetLine(ObjLineType& rLine, OutputDevice& rOut);
     331             : void SetArea(ObjAreaType& rArea, OutputDevice& rOut);
     332             : Color Sgv2SvFarbe(sal_uInt8 nFrb1, sal_uInt8 nFrb2, sal_uInt8 nInts);
     333             : void RotatePoint(PointType& P, sal_Int16 cx, sal_Int16 cy, double sn, double cs);
     334             : void RotatePoint(Point& P, sal_Int16 cx, sal_Int16 cy, double sn, double cs);
     335             : sal_Int16 iMulDiv(sal_Int16 a, sal_Int16 Mul, sal_Int16 Div);
     336             : sal_uInt16 MulDiv(sal_uInt16 a, sal_uInt16 Mul, sal_uInt16 Div);
     337             : 
     338           0 : class SgfFontOne {
     339             : public:
     340             :     SgfFontOne*      Next;        // pointer to list
     341             :     sal_uInt32       IFID;
     342             :     bool         Bold;
     343             :     bool         Ital;
     344             :     bool         Sans;
     345             :     bool         Serf;
     346             :     bool         Fixd;
     347             :     FontFamily       SVFamil;
     348             :     rtl_TextEncoding SVChSet;
     349             :     OUString         SVFName;    // e.g. "Times New Roman" = 15 chars
     350             :     sal_uInt16       SVWidth;    // average character width in %
     351             :     SgfFontOne();
     352             :     void ReadOne(const OString& rID, OString& rDsc);
     353             : };
     354             : 
     355             : class SgfFontLst {
     356             : public:
     357             :     OUString    FNam;   // complete filename of the Ini-file
     358             :     SgfFontOne* pList;  // start of list
     359             :     SgfFontOne* Last;   // end of list
     360             :     sal_uInt32  LastID; // for faster access during repeats
     361             :     SgfFontOne* LastLn; // for faster access during repeats
     362             :     bool        Tried;
     363             :                 SgfFontLst();
     364             :                 ~SgfFontLst();
     365             :     void AssignFN(const OUString& rFName);
     366             :     void ReadList();
     367             :     void RausList();
     368             :     SgfFontOne* GetFontDesc(sal_uInt32 ID);
     369             : };
     370             : 
     371             : #endif // INCLUDED_VCL_SOURCE_FILTER_SGVMAIN_HXX
     372             : 
     373             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10