~ubuntu-branches/ubuntu/precise/ipe/precise

« back to all changes in this revision

Viewing changes to src/include/ipepdfwriter.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2009-12-11 21:22:35 UTC
  • mfrom: (4.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20091211212235-5iio4nzpra64snab
Tags: 7.0.10-1
* New upstream.  Closes: #551192.
  - New build-depends: libcairo2-dev, liblua5.1-0-dev, gsfonts
  - patches/config.diff: Remove.  Upstream build system replaced.
  - Runtime lib package changed to libipe7.0.10 from libipe1c2a
  - Devel package renamed to libipe-dev (from libipe1-dev)
  - Package ipe depends on lua5.1 due to ipe-update-master.

* rules: Re-write to use dh.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
/*
6
6
 
7
7
    This file is part of the extensible drawing editor Ipe.
8
 
    Copyright (C) 1993-2007  Otfried Cheong
 
8
    Copyright (C) 1993-2009  Otfried Cheong
9
9
 
10
10
    Ipe is free software; you can redistribute it and/or modify it
11
11
    under the terms of the GNU General Public License as published by
12
 
    the Free Software Foundation; either version 2 of the License, or
 
12
    the Free Software Foundation; either version 3 of the License, or
13
13
    (at your option) any later version.
14
14
 
15
15
    As a special exception, you have permission to link Ipe with the
36
36
#include "ipepage.h"
37
37
#include "ipedoc.h"
38
38
#include "ipeimage.h"
39
 
 
40
 
class IpeFontPool;
41
 
 
42
 
// --------------------------------------------------------------------
43
 
 
44
 
class IpePdfPainter : public IpePainter {
45
 
public:
46
 
  IpePdfPainter(const IpeStyleSheet *style, IpeStream &stream);
47
 
  virtual ~IpePdfPainter() { }
48
 
 
49
 
  virtual void Rect(const IpeRect &re);
50
 
 
51
 
protected:
52
 
  virtual void DoPush();
53
 
  virtual void DoPop();
54
 
  virtual void DoNewPath();
55
 
  virtual void DoMoveTo(const IpeVector &v);
56
 
  virtual void DoLineTo(const IpeVector &v);
57
 
  virtual void DoCurveTo(const IpeVector &v1, const IpeVector &v2,
58
 
                         const IpeVector &v3);
59
 
  virtual void DoClosePath();
60
 
  virtual void DoDrawPath();
61
 
  virtual void DoDrawBitmap(IpeBitmap bitmap);
62
 
  virtual void DoDrawText(const IpeText *text);
63
 
 
64
 
protected:
65
 
  void DrawColor(IpeStream &stream, IpeAttribute color,
66
 
                 const char *gray, const char *rgb);
67
 
  void DrawAttributes();
68
 
 
69
 
protected:
70
 
  IpeStream &iStream;
71
 
  // iActiveState records the attribute settings that have been
72
 
  // recorded in the PDF output, to avoid repeating them
73
 
  // over and over again.
74
 
  StateSeq iActiveState;
75
 
};
76
 
 
77
 
// --------------------------------------------------------------------
78
 
 
79
 
class IpePdfWriter {
80
 
public:
81
 
  IpePdfWriter(IpeTellStream &stream, const IpeDocument *doc,
82
 
               bool noShading, bool lastView,
83
 
               int fromPage, int toPage, int compression);
84
 
  ~IpePdfWriter();
85
 
 
86
 
  void EmbedFonts(const IpeFontPool *pool);
87
 
  void CreatePages();
88
 
  void CreateBookmarks();
89
 
  void CreateXmlStream(IpeString xmldata, bool preCompressed);
90
 
  void CreateTrailer(IpeString creator);
91
 
 
92
 
private:
93
 
  void CreatePageView(int page, int view);
94
 
  int StartObject(int objnum = -1);
95
 
  void CreateStream(const char *data, int size, bool preCompressed);
96
 
  void WriteString(IpeString text);
97
 
  void EmbedBitmap(IpeBitmap bitmap);
98
 
  IpeRect PaintView(IpeStream &stream, int pno, int view);
99
 
 
100
 
private:
101
 
  IpeTellStream &iStream;
102
 
  const IpeDocument *iDoc;
103
 
  //! Save only last view of each page?
104
 
  bool iLastView;
105
 
  //! Obj id of XML stream.
106
 
  int iXmlStreamNum;
107
 
  //! Obj id of font resource dictionary.
108
 
  int iResourceNum;
109
 
  //! Obj id of shading dictionary.
110
 
  int iShadingNum;
111
 
  //! Obj id of outline dictionary.
112
 
  int iBookmarks;
113
 
  //! Compression level (0..9).
114
 
  int iCompressLevel;
115
 
  //! Obj id of font for page numbers.
116
 
  int iPageNumberFont;
117
 
  // Export only those pages
118
 
  int iFromPage;
119
 
  int iToPage;
120
 
 
121
 
  std::vector<IpeBitmap> iBitmaps;
122
 
  //! Next unused PDF object number.
123
 
  int iObjNum;
124
 
  //! List of pages, expressed as Pdf object numbers.
125
 
  std::vector<int> iPageObjectNumbers;
126
 
  //! List of file locations, in object number order (starting with 0).
127
 
  std::map<int, long> iXref;
128
 
};
 
39
#include "ipefontpool.h"
 
40
 
 
41
// --------------------------------------------------------------------
 
42
 
 
43
namespace ipe {
 
44
 
 
45
  class PdfPainter : public Painter {
 
46
  public:
 
47
    PdfPainter(const Cascade *style, Stream &stream);
 
48
    virtual ~PdfPainter() { }
 
49
 
 
50
    static void drawColor(Stream &stream, Color color,
 
51
                          const char *gray, const char *rgb);
 
52
 
 
53
  protected:
 
54
    virtual void doPush();
 
55
    virtual void doPop();
 
56
    virtual void doNewPath();
 
57
    virtual void doMoveTo(const Vector &v);
 
58
    virtual void doLineTo(const Vector &v);
 
59
    virtual void doCurveTo(const Vector &v1, const Vector &v2,
 
60
                           const Vector &v3);
 
61
    virtual void doClosePath();
 
62
    virtual void doDrawPath(TPathMode mode);
 
63
    virtual void doDrawBitmap(Bitmap bitmap);
 
64
    virtual void doDrawText(const Text *text);
 
65
    virtual void doAddClipPath();
 
66
    virtual void doDrawSymbol(Attribute symbol);
 
67
 
 
68
  protected:
 
69
    void drawAttributes();
 
70
    void drawOpacity();
 
71
 
 
72
  protected:
 
73
    Stream &iStream;
 
74
    // iActiveState records the attribute settings that have been
 
75
    // recorded in the PDF output, to avoid repeating them
 
76
    // over and over again.
 
77
    std::list<State> iActiveState;
 
78
  };
 
79
 
 
80
  // --------------------------------------------------------------------
 
81
 
 
82
  class PdfWriter {
 
83
  public:
 
84
    PdfWriter(TellStream &stream, const Document *doc,
 
85
              const FontPool *pool,
 
86
              bool lastView, int fromPage, int toPage, int compression);
 
87
    ~PdfWriter();
 
88
 
 
89
    void createPages();
 
90
    void createPageView(int page, int view);
 
91
    void createBookmarks();
 
92
    void createXmlStream(String xmldata, bool preCompressed);
 
93
    void createTrailer();
 
94
 
 
95
  private:
 
96
    int startObject(int objnum = -1);
 
97
    void createStream(const char *data, int size, bool preCompressed);
 
98
    void writeString(String text);
 
99
    void embedBitmap(Bitmap bitmap);
 
100
    void paintView(Stream &stream, int pno, int view);
 
101
    void embedBitmaps(const BitmapFinder &bm);
 
102
    void createResources(const BitmapFinder &bm);
 
103
    void embedFonts(const FontPool *pool);
 
104
 
 
105
  private:
 
106
    TellStream &iStream;
 
107
    const Document *iDoc;
 
108
    //! Show only last view of each page?
 
109
    bool iLastView;
 
110
    //! Obj id of XML stream.
 
111
    int iXmlStreamNum;
 
112
    //! Obj id of font resource dictionary.
 
113
    int iResourceNum;
 
114
    //! Obj id of outline dictionary.
 
115
    int iBookmarks;
 
116
    //! Compression level (0..9).
 
117
    int iCompressLevel;
 
118
    //! Obj id of font for page numbers.
 
119
    int iPageNumberFont;
 
120
    //! Obj id of GState with opacity definitions.
 
121
    int iExtGState;
 
122
    //! Obj id of dictionary with pattern definitions.
 
123
    int iPatternNum;
 
124
    // Export only those pages
 
125
    int iFromPage;
 
126
    int iToPage;
 
127
 
 
128
    std::vector<Bitmap> iBitmaps;
 
129
    //! Next unused PDF object number.
 
130
    int iObjNum;
 
131
 
 
132
    //! Object numbers of gradients, indexed by attribute name
 
133
    std::map<int, int> iGradients;
 
134
    //! Object numbers of symbols, indexed by attribute name
 
135
    std::map<int, int> iSymbols;
 
136
    //! List of pages, expressed as Pdf object numbers.
 
137
    std::vector<int> iPageObjectNumbers;
 
138
    //! List of file locations, in object number order (starting with 0).
 
139
    std::map<int, long> iXref;
 
140
  };
 
141
 
 
142
} // namespace
129
143
 
130
144
// --------------------------------------------------------------------
131
145
#endif