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

Generated by: LCOV version 1.10