LCOV - code coverage report
Current view: top level - sdext/source/pdfimport/xpdfwrapper - pdfioutdev_gpl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 16 18 88.9 %
Date: 2012-08-25 Functions: 6 9 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 4 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  *  OpenOffice.org - a multi-platform office productivity suite
       5                 :            :  *
       6                 :            :  *  The Contents of this file are made available subject to
       7                 :            :  *  the terms of GNU General Public License Version 2.
       8                 :            :  *
       9                 :            :  *
      10                 :            :  *    GNU General Public License, version 2
      11                 :            :  *    =============================================
      12                 :            :  *    Copyright 2005 by Sun Microsystems, Inc.
      13                 :            :  *    901 San Antonio Road, Palo Alto, CA 94303, USA
      14                 :            :  *
      15                 :            :  *    This program is free software; you can redistribute it and/or
      16                 :            :  *    modify it under the terms of the GNU General Public License as
      17                 :            :  *    published by the Free Software Foundation; either version 2 of
      18                 :            :  *    the License, or (at your option) any later version.
      19                 :            :  *
      20                 :            :  *    This program is distributed in the hope that it will be useful,
      21                 :            :  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
      22                 :            :  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      23                 :            :  *    GNU General Public License for more details.
      24                 :            :  *
      25                 :            :  *    You should have received a copy of the GNU General Public
      26                 :            :  *    License along with this program; if not, write to the Free
      27                 :            :  *    Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
      28                 :            :  *    Boston, MA 02110-1301, USA.
      29                 :            :  *
      30                 :            :  ************************************************************************/
      31                 :            : 
      32                 :            : #ifndef INCLUDED_PDFI_OUTDEV_HXX
      33                 :            : #define INCLUDED_PDFI_OUTDEV_HXX
      34                 :            : 
      35                 :            : #if defined __GNUC__
      36                 :            : #pragma GCC system_header
      37                 :            : #elif defined __SUNPRO_CC
      38                 :            : #pragma disable_warn
      39                 :            : #elif defined _MSC_VER
      40                 :            : #pragma warning(push, 1)
      41                 :            : #endif
      42                 :            : 
      43                 :            : #include "GfxState.h"
      44                 :            : #include "GfxFont.h"
      45                 :            : #include "UnicodeMap.h"
      46                 :            : #include "Link.h"
      47                 :            : #include "Object.h"
      48                 :            : #include "OutputDev.h"
      49                 :            : #ifndef SYSTEM_POPPLER
      50                 :            : #  include "parseargs.h"
      51                 :            : #endif
      52                 :            : #include "GlobalParams.h"
      53                 :            : #include "PDFDoc.h"
      54                 :            : 
      55                 :            : #if defined __SUNPRO_CC
      56                 :            : #pragma enable_warn
      57                 :            : #elif defined _MSC_VER
      58                 :            : #pragma warning(pop)
      59                 :            : #endif
      60                 :            : 
      61                 :            : #include <boost/unordered_map.hpp>
      62                 :            : #include <vector>
      63                 :            : 
      64                 :            : class GfxPath;
      65                 :            : class GfxFont;
      66                 :            : class PDFDoc;
      67                 :            : #ifndef SYSTEM_POPPLER
      68                 :            : #define POPPLER_CHECK_VERSION(major,minor,micro) (0)
      69                 :            : typedef GString GooString;
      70                 :            : #else
      71                 :            : #include <cpp/poppler-version.h>
      72                 :            : #define POPPLER_CHECK_VERSION(major,minor,micro) \
      73                 :            :   (POPPLER_VERSION_MAJOR > (major) || \
      74                 :            :    (POPPLER_VERSION_MAJOR == (major) && POPPLER_VERSION_MINOR > (minor)) || \
      75                 :            :    (POPPLER_VERSION_MAJOR == (major) && POPPLER_VERSION_MINOR == (minor) && POPPLER_VERSION_MICRO >= (micro)))
      76                 :            : #endif
      77                 :            : 
      78                 :            : namespace pdfi
      79                 :            : {
      80                 :        210 :     struct FontAttributes
      81                 :            :     {
      82                 :            :         FontAttributes( const GooString& familyName_,
      83                 :            :                         bool           isEmbedded_,
      84                 :            :                         bool           isBold_,
      85                 :            :                         bool           isItalic_,
      86                 :            :                         bool           isUnderline_,
      87                 :            :                         double         size_ ) :
      88                 :            :             familyName(),
      89                 :            :             isEmbedded(isEmbedded_),
      90                 :            :             isBold(isBold_),
      91                 :            :             isItalic(isItalic_),
      92                 :            :             isUnderline(isUnderline_),
      93                 :            :             size(size_)
      94                 :            :         {
      95                 :            :             familyName.append(const_cast<GooString*>(&familyName_));
      96                 :            :         }
      97                 :            : 
      98                 :        255 :         FontAttributes() :
      99                 :            :             familyName(),
     100                 :            :             isEmbedded(false),
     101                 :            :             isBold(false),
     102                 :            :             isItalic(false),
     103                 :            :             isUnderline(false),
     104                 :        255 :             size(0.0)
     105                 :        255 :         {}
     106                 :            : 
     107                 :            :         // xdpf goo stuff is so totally borked...
     108                 :            :         // ...need to hand-code assignment
     109                 :            :         FontAttributes( const FontAttributes& rSrc ) :
     110                 :            :             familyName(),
     111                 :            :             isEmbedded(rSrc.isEmbedded),
     112                 :            :             isBold(rSrc.isBold),
     113                 :            :             isItalic(rSrc.isItalic),
     114                 :            :             isUnderline(rSrc.isUnderline),
     115                 :            :             size(rSrc.size)
     116                 :            :         {
     117                 :            :             familyName.append(const_cast<GooString*>(&rSrc.familyName));
     118                 :            :         }
     119                 :            : 
     120                 :        210 :         FontAttributes& operator=( const FontAttributes& rSrc )
     121                 :            :         {
     122                 :        210 :             familyName.clear();
     123                 :        210 :             familyName.append(const_cast<GooString*>(&rSrc.familyName));
     124                 :            : 
     125                 :        210 :             isEmbedded  = rSrc.isEmbedded;
     126                 :        210 :             isBold      = rSrc.isBold;
     127                 :        210 :             isItalic    = rSrc.isItalic;
     128                 :        210 :             isUnderline = rSrc.isUnderline;
     129                 :        210 :             size        = rSrc.size;
     130                 :            : 
     131                 :        210 :             return *this;
     132                 :            :         }
     133                 :            : 
     134                 :            :         bool operator==(const FontAttributes& rFont) const
     135                 :            :         {
     136                 :            :             return const_cast<GooString*>(&familyName)->cmp(
     137                 :            :                 const_cast<GooString*>(&rFont.familyName))==0 &&
     138                 :            :                 isEmbedded == rFont.isEmbedded &&
     139                 :            :                 isBold == rFont.isBold &&
     140                 :            :                 isItalic == rFont.isItalic &&
     141                 :            :                 isUnderline == rFont.isUnderline &&
     142                 :            :                 size == rFont.size;
     143                 :            :         }
     144                 :            : 
     145                 :            :         GooString     familyName;
     146                 :            :         bool        isEmbedded;
     147                 :            :         bool        isBold;
     148                 :            :         bool        isItalic;
     149                 :            :         bool        isUnderline;
     150                 :            :         double      size;
     151                 :            :     };
     152                 :            : 
     153 [ #  # ][ #  # ]:          0 :     class PDFOutDev : public OutputDev
     154                 :            :     {
     155                 :            :         // not owned by this class
     156                 :            :         PDFDoc*                                 m_pDoc;
     157                 :            :         mutable boost::unordered_map< long long,
     158                 :            :                                FontAttributes > m_aFontMap;
     159                 :            :         UnicodeMap*                             m_pUtf8Map;
     160                 :            : 
     161                 :            :         int  parseFont( long long nNewId, GfxFont* pFont, GfxState* state ) const;
     162                 :            :         void writeFontFile( GfxFont* gfxFont ) const;
     163                 :            :         void printPath( GfxPath* pPath ) const;
     164                 :            : 
     165                 :            :     public:
     166                 :            :         explicit PDFOutDev( PDFDoc* pDoc );
     167                 :            : 
     168                 :            :         //----- get info about output device
     169                 :            : 
     170                 :            :         // Does this device use upside-down coordinates?
     171                 :            :         // (Upside-down means (0,0) is the top left corner of the page.)
     172                 :         30 :         virtual GBool upsideDown() { return gTrue; }
     173                 :            : 
     174                 :            :         // Does this device use drawChar() or drawString()?
     175                 :       2880 :         virtual GBool useDrawChar() { return gTrue; }
     176                 :            : 
     177                 :            :         // Does this device use beginType3Char/endType3Char?  Otherwise,
     178                 :            :         // text in Type 3 fonts will be drawn with drawChar/drawString.
     179                 :          0 :         virtual GBool interpretType3Chars() { return gFalse; }
     180                 :            : 
     181                 :            :         // Does this device need non-text content?
     182                 :         15 :         virtual GBool needNonText() { return gTrue; }
     183                 :            : 
     184                 :            :         //----- initialization and control
     185                 :            : 
     186                 :            :         // Set default transform matrix.
     187                 :            :         virtual void setDefaultCTM(double *ctm);
     188                 :            : 
     189                 :            :         // Start a page.
     190                 :            :         virtual void startPage(int pageNum, GfxState *state);
     191                 :            : 
     192                 :            :         // End a page.
     193                 :            :         virtual void endPage();
     194                 :            : 
     195                 :            :         // Dump page contents to display.
     196                 :            :         // virtual void dump() {}
     197                 :            : 
     198                 :            :         //----- coordinate conversion
     199                 :            : 
     200                 :            :         // Convert between device and user coordinates.
     201                 :            :         // virtual void cvtDevToUser(double dx, double dy, double *ux, double *uy);
     202                 :            :         // virtual void cvtUserToDev(double ux, double uy, int *dx, int *dy);
     203                 :            : 
     204                 :            :         #if POPPLER_CHECK_VERSION(0, 17, 0)
     205                 :            :         virtual void processLink(AnnotLink *link, Catalog *catalog);
     206                 :            :         #else
     207                 :            :         //----- link borders
     208                 :            :         virtual void processLink(Link *link, Catalog *catalog);
     209                 :            :         #endif
     210                 :            : 
     211                 :            :         //----- save/restore graphics state
     212                 :            :         virtual void saveState(GfxState *state);
     213                 :            :         virtual void restoreState(GfxState *state);
     214                 :            : 
     215                 :            :         //----- update graphics state
     216                 :            :         // virtual void updateAll(GfxState *state);
     217                 :            :         virtual void updateCTM(GfxState *state, double m11, double m12,
     218                 :            :                                double m21, double m22, double m31, double m32);
     219                 :            :         virtual void updateLineDash(GfxState *state);
     220                 :            :         virtual void updateFlatness(GfxState *state);
     221                 :            :         virtual void updateLineJoin(GfxState *state);
     222                 :            :         virtual void updateLineCap(GfxState *state);
     223                 :            :         virtual void updateMiterLimit(GfxState *state);
     224                 :            :         virtual void updateLineWidth(GfxState *state);
     225                 :            :         virtual void updateFillColor(GfxState *state);
     226                 :            :         virtual void updateStrokeColor(GfxState *state);
     227                 :            :         virtual void updateFillOpacity(GfxState *state);
     228                 :            :         virtual void updateStrokeOpacity(GfxState *state);
     229                 :            :         virtual void updateBlendMode(GfxState *state);
     230                 :            : 
     231                 :            :         //----- update text state
     232                 :            :         virtual void updateFont(GfxState *state);
     233                 :            :         // virtual void updateTextMat(GfxState *state);
     234                 :            :         // virtual void updateCharSpace(GfxState *state) {}
     235                 :            :         virtual void updateRender(GfxState *state);
     236                 :            :         // virtual void updateRise(GfxState *state) {}
     237                 :            :         // virtual void updateWordSpace(GfxState *state) {}
     238                 :            :         // virtual void updateHorizScaling(GfxState *state) {}
     239                 :            :         // virtual void updateTextPos(GfxState *state) {}
     240                 :            :         // virtual void updateTextShift(GfxState *state, double shift) {}
     241                 :            : 
     242                 :            :         //----- path painting
     243                 :            :         virtual void stroke(GfxState *state);
     244                 :            :         virtual void fill(GfxState *state);
     245                 :            :         virtual void eoFill(GfxState *state);
     246                 :            : 
     247                 :            :         //----- path clipping
     248                 :            :         virtual void clip(GfxState *state);
     249                 :            :         virtual void eoClip(GfxState *state);
     250                 :            : 
     251                 :            :         //----- text drawing
     252                 :            :         virtual void drawChar(GfxState *state, double x, double y,
     253                 :            :                               double dx, double dy,
     254                 :            :                               double originX, double originY,
     255                 :            :                               CharCode code, int nBytes, Unicode *u, int uLen);
     256                 :            :         virtual void drawString(GfxState *state, GooString *s);
     257                 :            :         virtual void endTextObject(GfxState *state);
     258                 :            : 
     259                 :            :         //----- image drawing
     260                 :            :         virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
     261                 :            :                                    int width, int height, GBool invert,
     262                 :            :                                    GBool inlineImg);
     263                 :            :         virtual void drawImage(GfxState *state, Object *ref, Stream *str,
     264                 :            :                                int width, int height, GfxImageColorMap *colorMap,
     265                 :            :                                int *maskColors, GBool inlineImg);
     266                 :            :         virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
     267                 :            :                                      int width, int height,
     268                 :            :                                      GfxImageColorMap *colorMap,
     269                 :            :                                      Stream *maskStr, int maskWidth, int maskHeight,
     270                 :            :                                      GBool maskInvert);
     271                 :            :         virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
     272                 :            :                                          int width, int height,
     273                 :            :                                          GfxImageColorMap *colorMap,
     274                 :            :                                          Stream *maskStr,
     275                 :            :                                          int maskWidth, int maskHeight,
     276                 :            :                                          GfxImageColorMap *maskColorMap);
     277                 :            : 
     278                 :            :         //----- OPI functions
     279                 :            :         // virtual void opiBegin(GfxState *state, Dict *opiDict);
     280                 :            :         // virtual void opiEnd(GfxState *state, Dict *opiDict);
     281                 :            : 
     282                 :            :         //----- Type 3 font operators
     283                 :            :         // virtual void type3D0(GfxState *state, double wx, double wy) {}
     284                 :            :         // virtual void type3D1(GfxState *state, double wx, double wy,
     285                 :            :         //                      double llx, double lly, double urx, double ury) {}
     286                 :            : 
     287                 :            :         //----- PostScript XObjects
     288                 :            :         // virtual void psXObject(Stream *psStream, Stream *level1Stream) {}
     289                 :            : 
     290                 :            :         void setPageNum( int nNumPages );
     291                 :            :     };
     292                 :            : }
     293                 :            : 
     294                 :            : extern FILE* g_binary_out;
     295                 :            : 
     296                 :            : // note: if you ever hcange Output_t, please keep in mind that the current code
     297                 :            : // relies on it being of 8 bit size
     298                 :            : typedef Guchar Output_t;
     299                 :            : typedef std::vector< Output_t > OutputBuffer;
     300                 :            : 
     301                 :            : #endif /* INCLUDED_PDFI_OUTDEV_HXX */
     302                 :            : 
     303                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10