filters

FilterDevice.h

00001 /*
00002  * Copyright (c) 2002 Nicolas HADACEK (hadacek@kde.org)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #ifndef FILTERDEVICE_H
00021 #define FILTERDEVICE_H
00022 
00023 #include <qimage.h>
00024 
00025 class Object;
00026 class Stream;
00027 
00028 #include "gtypes.h"
00029 #include "OutputDev.h"
00030 
00031 #include "misc.h"
00032 
00033 
00034 namespace PDFImport
00035 {
00036 class Page;
00037 class Data;
00038 
00039 class Device : public OutputDev
00040 {
00041 public:
00042     Device(Data &data);
00043     ~Device();
00044 
00045     void init();
00046     void dumpPage(uint i);
00047 
00048     //-----
00049     virtual GBool upsideDown() { return gTrue; }
00050     virtual GBool useDrawChar() { return gTrue; }
00051     virtual GBool interpretType3Chars() { return gFalse; }
00052     virtual GBool needNonText() { return gFalse; }
00053 
00054     //----- initialization
00055     virtual void startPage(int pageNum, GfxState *state);
00056     virtual void endPage();
00057 
00058     //----- update graphics state
00059     virtual void updateAll(GfxState *state);
00060 //    virtual void updateLineDash(GfxState *state);
00061 //    virtual void updateFlatness(GfxState *state);
00062 //    virtual void updateLineJoin(GfxState *state);
00063 //    virtual void updateLineCap(GfxState *state);
00064 //    virtual void updateMiterLimit(GfxState *state);
00065 //    virtual void updateLineWidth(GfxState *state);
00066     virtual void updateFillColor(GfxState *state);
00067     virtual void updateStrokeColor(GfxState *state);
00068 
00069     //----- update text state
00070     virtual void updateFont(GfxState *state);
00071 
00072     //----- text drawing
00073     virtual void beginString(GfxState *state, GString *s);
00074     virtual void endString(GfxState *state);
00075     virtual void drawChar(GfxState *state, double x, double y,
00076                           double dx, double dy,
00077                           double originX, double originY,
00078                           CharCode c, Unicode *u, int uLen);
00079 
00080     //----- link borders
00081     virtual void drawLink(::Link* link, Catalog *cat);
00082 
00083     //----- image drawing
00084     virtual void drawImageMask(GfxState *, Object *ref, Stream *,
00085                                int width, int height, GBool invert,
00086                                GBool inlineImg);
00087     virtual void drawImage(GfxState *, Object *ref, Stream *,
00088                            int width, int height, GfxImageColorMap *colorMap,
00089                            int *maskColors, GBool inlineImg);
00090 
00091     //----- path painting
00092     virtual void stroke(GfxState *state);
00093     virtual void fill(GfxState *state);
00094     virtual void eoFill(GfxState *state);
00095 
00096 private:
00097     class Image;
00098     static void computeGeometry(GfxState *, Image &);
00099     uint initImage(GfxState *, int width, int height, bool mask);
00100     void addImage();
00101     void clear();
00102     static DPathVector convertPath(GfxState *);
00103     void doFill(const DPathVector &);
00104     Page *current() const { return _pages.getLast(); }
00105 
00106 private:
00107     Data &_data;
00108     QPtrList<Page> _pages;
00109     QColor _fillColor, _strokeColor;
00110 
00111     class Image {
00112     public:
00113         QImage image;
00114         DRect  rect;
00115         bool   mask;
00116     };
00117     Image _currentImage;
00118     typedef QValueList<Image> ImageList;
00119     ImageList _images;
00120 };
00121 
00122 } // namespace
00123 
00124 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys