LCOV - code coverage report
Current view: top level - sdext/source/pdfimport/xpdfwrapper - pdfioutdev_gpl.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 17 0.0 %
Date: 2014-04-14 Functions: 0 7 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_SDEXT_SOURCE_PDFIMPORT_XPDFWRAPPER_PDFIOUTDEV_GPL_HXX
      21             : #define INCLUDED_SDEXT_SOURCE_PDFIMPORT_XPDFWRAPPER_PDFIOUTDEV_GPL_HXX
      22             : 
      23             : #include <sal/types.h>
      24             : 
      25             : #if defined __GNUC__
      26             : #if HAVE_GCC_PRAGMA_DIAGNOSTIC_SCOPE
      27             : # pragma GCC diagnostic push
      28             : # pragma GCC diagnostic ignored "-Wunused-parameter"
      29             : #endif
      30             : #elif defined _MSC_VER
      31             : #pragma warning(push, 1)
      32             : #endif
      33             : 
      34             : #include "GfxState.h"
      35             : #include "GfxFont.h"
      36             : #include "UnicodeMap.h"
      37             : #include "Link.h"
      38             : #include "Object.h"
      39             : #include "OutputDev.h"
      40             : #include "GlobalParams.h"
      41             : #include "PDFDoc.h"
      42             : 
      43             : #if defined __GNUC__
      44             : #if HAVE_GCC_PRAGMA_DIAGNOSTIC_SCOPE
      45             : # pragma GCC diagnostic pop
      46             : #endif
      47             : #elif defined _MSC_VER
      48             : #pragma warning(pop)
      49             : #endif
      50             : 
      51             : #include <boost/unordered_map.hpp>
      52             : #include <vector>
      53             : 
      54             : class GfxPath;
      55             : class GfxFont;
      56             : class PDFDoc;
      57             : #include <cpp/poppler-version.h>
      58             : #define POPPLER_CHECK_VERSION(major,minor,micro) \
      59             :   (POPPLER_VERSION_MAJOR > (major) || \
      60             :    (POPPLER_VERSION_MAJOR == (major) && POPPLER_VERSION_MINOR > (minor)) || \
      61             :    (POPPLER_VERSION_MAJOR == (major) && POPPLER_VERSION_MINOR == (minor) && POPPLER_VERSION_MICRO >= (micro)))
      62             : 
      63             : namespace pdfi
      64             : {
      65           0 :     struct FontAttributes
      66             :     {
      67             :         FontAttributes( const GooString& familyName_,
      68             :                         bool           isEmbedded_,
      69             :                         bool           isBold_,
      70             :                         bool           isItalic_,
      71             :                         bool           isUnderline_,
      72             :                         double         size_ ) :
      73             :             familyName(),
      74             :             isEmbedded(isEmbedded_),
      75             :             isBold(isBold_),
      76             :             isItalic(isItalic_),
      77             :             isUnderline(isUnderline_),
      78             :             size(size_)
      79             :         {
      80             :             familyName.append(const_cast<GooString*>(&familyName_));
      81             :         }
      82             : 
      83           0 :         FontAttributes() :
      84             :             familyName(),
      85             :             isEmbedded(false),
      86             :             isBold(false),
      87             :             isItalic(false),
      88             :             isUnderline(false),
      89           0 :             size(0.0)
      90           0 :         {}
      91             : 
      92             :         // xdpf goo stuff is so totally borked...
      93             :         // ...need to hand-code assignment
      94             :         FontAttributes( const FontAttributes& rSrc ) :
      95             :             familyName(),
      96             :             isEmbedded(rSrc.isEmbedded),
      97             :             isBold(rSrc.isBold),
      98             :             isItalic(rSrc.isItalic),
      99             :             isUnderline(rSrc.isUnderline),
     100             :             size(rSrc.size)
     101             :         {
     102             :             familyName.append(const_cast<GooString*>(&rSrc.familyName));
     103             :         }
     104             : 
     105           0 :         FontAttributes& operator=( const FontAttributes& rSrc )
     106             :         {
     107           0 :             familyName.clear();
     108           0 :             familyName.append(const_cast<GooString*>(&rSrc.familyName));
     109             : 
     110           0 :             isEmbedded  = rSrc.isEmbedded;
     111           0 :             isBold      = rSrc.isBold;
     112           0 :             isItalic    = rSrc.isItalic;
     113           0 :             isUnderline = rSrc.isUnderline;
     114           0 :             size        = rSrc.size;
     115             : 
     116           0 :             return *this;
     117             :         }
     118             : 
     119             :         bool operator==(const FontAttributes& rFont) const
     120             :         {
     121             :             return const_cast<GooString*>(&familyName)->cmp(
     122             :                 const_cast<GooString*>(&rFont.familyName))==0 &&
     123             :                 isEmbedded == rFont.isEmbedded &&
     124             :                 isBold == rFont.isBold &&
     125             :                 isItalic == rFont.isItalic &&
     126             :                 isUnderline == rFont.isUnderline &&
     127             :                 size == rFont.size;
     128             :         }
     129             : 
     130             :         GooString     familyName;
     131             :         bool        isEmbedded;
     132             :         bool        isBold;
     133             :         bool        isItalic;
     134             :         bool        isUnderline;
     135             :         double      size;
     136             :     };
     137             : 
     138             :     class PDFOutDev : public OutputDev
     139             :     {
     140             :         // not owned by this class
     141             :         PDFDoc*                                 m_pDoc;
     142             :         mutable boost::unordered_map< long long,
     143             :                                FontAttributes > m_aFontMap;
     144             :         UnicodeMap*                             m_pUtf8Map;
     145             : 
     146             :         int  parseFont( long long nNewId, GfxFont* pFont, GfxState* state ) const;
     147             :         void writeFontFile( GfxFont* gfxFont ) const;
     148             :         void printPath( GfxPath* pPath ) const;
     149             : 
     150             :     public:
     151             :         explicit PDFOutDev( PDFDoc* pDoc );
     152             :         virtual ~PDFOutDev();
     153             : 
     154             :         //----- get info about output device
     155             : 
     156             :         // Does this device use upside-down coordinates?
     157             :         // (Upside-down means (0,0) is the top left corner of the page.)
     158           0 :         virtual GBool upsideDown() SAL_OVERRIDE { return gTrue; }
     159             : 
     160             :         // Does this device use drawChar() or drawString()?
     161           0 :         virtual GBool useDrawChar() SAL_OVERRIDE { return gTrue; }
     162             : 
     163             :         // Does this device use beginType3Char/endType3Char?  Otherwise,
     164             :         // text in Type 3 fonts will be drawn with drawChar/drawString.
     165           0 :         virtual GBool interpretType3Chars() SAL_OVERRIDE { return gFalse; }
     166             : 
     167             :         // Does this device need non-text content?
     168           0 :         virtual GBool needNonText() SAL_OVERRIDE { return gTrue; }
     169             : 
     170             :         //----- initialization and control
     171             : 
     172             :         // Set default transform matrix.
     173             :         virtual void setDefaultCTM(double *ctm) SAL_OVERRIDE;
     174             : 
     175             :         // Start a page.
     176             :         virtual void startPage(int pageNum, GfxState *state
     177             : #if POPPLER_CHECK_VERSION(0, 23, 0) || POPPLER_CHECK_VERSION(0, 24, 0)
     178             :                                , XRef *xref
     179             : #endif
     180             :         ) SAL_OVERRIDE;
     181             : 
     182             :         // End a page.
     183             :         virtual void endPage() SAL_OVERRIDE;
     184             : 
     185             :         //----- link borders
     186             :         #if POPPLER_CHECK_VERSION(0, 19, 0)
     187             :         virtual void processLink(AnnotLink *link) SAL_OVERRIDE;
     188             :     #elif POPPLER_CHECK_VERSION(0, 17, 0)
     189             :         virtual void processLink(AnnotLink *link, Catalog *catalog) SAL_OVERRIDE;
     190             :     #else
     191             :         virtual void processLink(Link *link, Catalog *catalog) SAL_OVERRIDE;
     192             :     #endif
     193             : 
     194             :         //----- save/restore graphics state
     195             :         virtual void saveState(GfxState *state) SAL_OVERRIDE;
     196             :         virtual void restoreState(GfxState *state) SAL_OVERRIDE;
     197             : 
     198             :         //----- update graphics state
     199             :         virtual void updateCTM(GfxState *state, double m11, double m12,
     200             :                                double m21, double m22, double m31, double m32) SAL_OVERRIDE;
     201             :         virtual void updateLineDash(GfxState *state) SAL_OVERRIDE;
     202             :         virtual void updateFlatness(GfxState *state) SAL_OVERRIDE;
     203             :         virtual void updateLineJoin(GfxState *state) SAL_OVERRIDE;
     204             :         virtual void updateLineCap(GfxState *state) SAL_OVERRIDE;
     205             :         virtual void updateMiterLimit(GfxState *state) SAL_OVERRIDE;
     206             :         virtual void updateLineWidth(GfxState *state) SAL_OVERRIDE;
     207             :         virtual void updateFillColor(GfxState *state) SAL_OVERRIDE;
     208             :         virtual void updateStrokeColor(GfxState *state) SAL_OVERRIDE;
     209             :         virtual void updateFillOpacity(GfxState *state) SAL_OVERRIDE;
     210             :         virtual void updateStrokeOpacity(GfxState *state) SAL_OVERRIDE;
     211             :         virtual void updateBlendMode(GfxState *state) SAL_OVERRIDE;
     212             : 
     213             :         //----- update text state
     214             :         virtual void updateFont(GfxState *state) SAL_OVERRIDE;
     215             :         virtual void updateRender(GfxState *state) SAL_OVERRIDE;
     216             : 
     217             :         //----- path painting
     218             :         virtual void stroke(GfxState *state) SAL_OVERRIDE;
     219             :         virtual void fill(GfxState *state) SAL_OVERRIDE;
     220             :         virtual void eoFill(GfxState *state) SAL_OVERRIDE;
     221             : 
     222             :         //----- path clipping
     223             :         virtual void clip(GfxState *state) SAL_OVERRIDE;
     224             :         virtual void eoClip(GfxState *state) SAL_OVERRIDE;
     225             : 
     226             :         //----- text drawing
     227             :         virtual void drawChar(GfxState *state, double x, double y,
     228             :                               double dx, double dy,
     229             :                               double originX, double originY,
     230             :                               CharCode code, int nBytes, Unicode *u, int uLen) SAL_OVERRIDE;
     231             :         virtual void drawString(GfxState *state, GooString *s) SAL_OVERRIDE;
     232             :         virtual void endTextObject(GfxState *state) SAL_OVERRIDE;
     233             : 
     234             :         //----- image drawing
     235             :         virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
     236             :                                    int width, int height, GBool invert,
     237             : #if POPPLER_CHECK_VERSION(0, 12, 0)
     238             :                                    GBool interpolate,
     239             : #endif
     240             :                                    GBool inlineImg) SAL_OVERRIDE;
     241             :         virtual void drawImage(GfxState *state, Object *ref, Stream *str,
     242             :                                int width, int height, GfxImageColorMap *colorMap,
     243             : #if POPPLER_CHECK_VERSION(0, 12, 0)
     244             :                                GBool interpolate,
     245             : #endif
     246             :                                int *maskColors, GBool inlineImg) SAL_OVERRIDE;
     247             :         virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
     248             :                                      int width, int height,
     249             :                                      GfxImageColorMap *colorMap,
     250             : #if POPPLER_CHECK_VERSION(0, 12, 0)
     251             :                                      GBool interpolate,
     252             : #endif
     253             :                                      Stream *maskStr, int maskWidth, int maskHeight,
     254             :                                      GBool maskInvert
     255             : #if POPPLER_CHECK_VERSION(0, 12, 0)
     256             :                                      , GBool maskInterpolate
     257             : #endif
     258             :                                     ) SAL_OVERRIDE;
     259             :         virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
     260             :                                          int width, int height,
     261             :                                          GfxImageColorMap *colorMap,
     262             : #if POPPLER_CHECK_VERSION(0, 12, 0)
     263             :                                          GBool interpolate,
     264             : #endif
     265             :                                          Stream *maskStr,
     266             :                                          int maskWidth, int maskHeight,
     267             :                                          GfxImageColorMap *maskColorMap
     268             : #if POPPLER_CHECK_VERSION(0, 12, 0)
     269             :                                          , GBool maskInterpolate
     270             : #endif
     271             :                                         ) SAL_OVERRIDE;
     272             : 
     273             :         void setPageNum( int nNumPages );
     274             :     };
     275             : }
     276             : 
     277             : extern FILE* g_binary_out;
     278             : 
     279             : // note: if you ever hcange Output_t, please keep in mind that the current code
     280             : // relies on it being of 8 bit size
     281             : typedef Guchar Output_t;
     282             : typedef std::vector< Output_t > OutputBuffer;
     283             : 
     284             : #endif // INCLUDED_SDEXT_SOURCE_PDFIMPORT_XPDFWRAPPER_PDFIOUTDEV_GPL_HXX
     285             : 
     286             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10