Merge lp:~drbild/inkscape/multilayer-pdf-latex-output into lp:~inkscape.dev/inkscape/trunk
- multilayer-pdf-latex-output
- Merge into trunk
Proposed by
Martin Owens
Status: | Merged |
---|---|
Approved by: | Johan Engelen |
Approved revision: | 12489 |
Merged at revision: | 12489 |
Proposed branch: | lp:~drbild/inkscape/multilayer-pdf-latex-output |
Merge into: | lp:~inkscape.dev/inkscape/trunk |
Diff against target: |
366 lines (+114/-18) 8 files modified
src/extension/internal/cairo-ps-out.cpp (+1/-1) src/extension/internal/cairo-render-context.cpp (+47/-2) src/extension/internal/cairo-render-context.h (+17/-0) src/extension/internal/cairo-renderer-pdf-out.cpp (+1/-1) src/extension/internal/cairo-renderer.cpp (+0/-6) src/extension/internal/cairo-renderer.h (+0/-4) src/extension/internal/latex-text-renderer.cpp (+37/-4) src/extension/internal/latex-text-renderer.h (+11/-0) |
To merge this branch: | bzr merge lp:~drbild/inkscape/multilayer-pdf-latex-output |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Johan Engelen | Approve | ||
Review via email: mp+183288@code.launchpad.net |
Commit message
Description of the change
Merge in, signed off by Johan Engelen
To post a comment you must log in.
- 12489. By David R. Bild <email address hidden>
-
use multiple graphic/text layers for pdf+latex output
Revision history for this message
Johan Engelen (johanengelen) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/extension/internal/cairo-ps-out.cpp' | |||
2 | --- src/extension/internal/cairo-ps-out.cpp 2013-08-05 21:07:35 +0000 | |||
3 | +++ src/extension/internal/cairo-ps-out.cpp 2013-08-30 22:23:52 +0000 | |||
4 | @@ -97,7 +97,7 @@ | |||
5 | 97 | ctx->setPSLevel(level); | 97 | ctx->setPSLevel(level); |
6 | 98 | ctx->setEPS(eps); | 98 | ctx->setEPS(eps); |
7 | 99 | ctx->setTextToPath(texttopath); | 99 | ctx->setTextToPath(texttopath); |
9 | 100 | renderer->_omitText = omittext; | 100 | ctx->setOmitText(omittext); |
10 | 101 | ctx->setFilterToBitmap(filtertobitmap); | 101 | ctx->setFilterToBitmap(filtertobitmap); |
11 | 102 | ctx->setBitmapResolution(resolution); | 102 | ctx->setBitmapResolution(resolution); |
12 | 103 | 103 | ||
13 | 104 | 104 | ||
14 | === modified file 'src/extension/internal/cairo-render-context.cpp' | |||
15 | --- src/extension/internal/cairo-render-context.cpp 2013-08-06 18:54:40 +0000 | |||
16 | +++ src/extension/internal/cairo-render-context.cpp 2013-08-30 22:23:52 +0000 | |||
17 | @@ -6,6 +6,7 @@ | |||
18 | 6 | * Miklos Erdelyi <erdelyim@gmail.com> | 6 | * Miklos Erdelyi <erdelyim@gmail.com> |
19 | 7 | * Jon A. Cruz <jon@joncruz.org> | 7 | * Jon A. Cruz <jon@joncruz.org> |
20 | 8 | * Abhishek Sharma | 8 | * Abhishek Sharma |
21 | 9 | * David R. Bild <drbild@umich.edu> | ||
22 | 9 | * | 10 | * |
23 | 10 | * Copyright (C) 2006 Miklos Erdelyi | 11 | * Copyright (C) 2006 Miklos Erdelyi |
24 | 11 | * | 12 | * |
25 | @@ -111,6 +112,7 @@ | |||
26 | 111 | _ps_level(1), | 112 | _ps_level(1), |
27 | 112 | _eps(false), | 113 | _eps(false), |
28 | 113 | _is_texttopath(FALSE), | 114 | _is_texttopath(FALSE), |
29 | 115 | _is_omittext(FALSE), | ||
30 | 114 | _is_filtertobitmap(FALSE), | 116 | _is_filtertobitmap(FALSE), |
31 | 115 | _bitmapresolution(72), | 117 | _bitmapresolution(72), |
32 | 116 | _stream(NULL), | 118 | _stream(NULL), |
33 | @@ -124,7 +126,8 @@ | |||
34 | 124 | _state(NULL), | 126 | _state(NULL), |
35 | 125 | _renderer(parent), | 127 | _renderer(parent), |
36 | 126 | _render_mode(RENDER_MODE_NORMAL), | 128 | _render_mode(RENDER_MODE_NORMAL), |
38 | 127 | _clip_mode(CLIP_MODE_MASK) | 129 | _clip_mode(CLIP_MODE_MASK), |
39 | 130 | _omittext_state(EMPTY) | ||
40 | 128 | { | 131 | { |
41 | 129 | font_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, font_data_free); | 132 | font_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, font_data_free); |
42 | 130 | } | 133 | } |
43 | @@ -426,6 +429,16 @@ | |||
44 | 426 | _is_texttopath = texttopath; | 429 | _is_texttopath = texttopath; |
45 | 427 | } | 430 | } |
46 | 428 | 431 | ||
47 | 432 | void CairoRenderContext::setOmitText(bool omittext) | ||
48 | 433 | { | ||
49 | 434 | _is_omittext = omittext; | ||
50 | 435 | } | ||
51 | 436 | |||
52 | 437 | bool CairoRenderContext::getOmitText(void) | ||
53 | 438 | { | ||
54 | 439 | return _is_omittext; | ||
55 | 440 | } | ||
56 | 441 | |||
57 | 429 | void CairoRenderContext::setFilterToBitmap(bool filtertobitmap) | 442 | void CairoRenderContext::setFilterToBitmap(bool filtertobitmap) |
58 | 430 | { | 443 | { |
59 | 431 | _is_filtertobitmap = filtertobitmap; | 444 | _is_filtertobitmap = filtertobitmap; |
60 | @@ -1331,11 +1344,36 @@ | |||
61 | 1331 | cairo_set_miter_limit(_cr, MAX(1, style->stroke_miterlimit.value)); | 1344 | cairo_set_miter_limit(_cr, MAX(1, style->stroke_miterlimit.value)); |
62 | 1332 | } | 1345 | } |
63 | 1333 | 1346 | ||
64 | 1347 | void | ||
65 | 1348 | CairoRenderContext::_prepareRenderGraphic() | ||
66 | 1349 | { | ||
67 | 1350 | // Only PDFLaTeX supports importing a single page of a graphics file, | ||
68 | 1351 | // so only PDF backend gets interleaved text/graphics | ||
69 | 1352 | if (_is_omittext && _target == CAIRO_SURFACE_TYPE_PDF) { | ||
70 | 1353 | if (_omittext_state == NEW_PAGE_ON_GRAPHIC) | ||
71 | 1354 | cairo_show_page(_cr); | ||
72 | 1355 | _omittext_state = GRAPHIC_ON_TOP; | ||
73 | 1356 | } | ||
74 | 1357 | } | ||
75 | 1358 | |||
76 | 1359 | void | ||
77 | 1360 | CairoRenderContext::_prepareRenderText() | ||
78 | 1361 | { | ||
79 | 1362 | // Only PDFLaTeX supports importing a single page of a graphics file, | ||
80 | 1363 | // so only PDF backend gets interleaved text/graphics | ||
81 | 1364 | if (_is_omittext && _target == CAIRO_SURFACE_TYPE_PDF) { | ||
82 | 1365 | if (_omittext_state == GRAPHIC_ON_TOP) | ||
83 | 1366 | _omittext_state = NEW_PAGE_ON_GRAPHIC; | ||
84 | 1367 | } | ||
85 | 1368 | } | ||
86 | 1369 | |||
87 | 1334 | bool | 1370 | bool |
88 | 1335 | CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, Geom::OptRect const &pbox) | 1371 | CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, Geom::OptRect const &pbox) |
89 | 1336 | { | 1372 | { |
90 | 1337 | g_assert( _is_valid ); | 1373 | g_assert( _is_valid ); |
91 | 1338 | 1374 | ||
92 | 1375 | _prepareRenderGraphic(); | ||
93 | 1376 | |||
94 | 1339 | if (_render_mode == RENDER_MODE_CLIP) { | 1377 | if (_render_mode == RENDER_MODE_CLIP) { |
95 | 1340 | if (_clip_mode == CLIP_MODE_PATH) { | 1378 | if (_clip_mode == CLIP_MODE_PATH) { |
96 | 1341 | addClipPath(pathv, &style->fill_rule); | 1379 | addClipPath(pathv, &style->fill_rule); |
97 | @@ -1408,6 +1446,8 @@ | |||
98 | 1408 | return true; | 1446 | return true; |
99 | 1409 | } | 1447 | } |
100 | 1410 | 1448 | ||
101 | 1449 | _prepareRenderGraphic(); | ||
102 | 1450 | |||
103 | 1411 | int w = gdk_pixbuf_get_width (pb); | 1451 | int w = gdk_pixbuf_get_width (pb); |
104 | 1412 | int h = gdk_pixbuf_get_height (pb); | 1452 | int h = gdk_pixbuf_get_height (pb); |
105 | 1413 | 1453 | ||
106 | @@ -1489,7 +1529,12 @@ | |||
107 | 1489 | bool | 1529 | bool |
108 | 1490 | CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_matrix, | 1530 | CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_matrix, |
109 | 1491 | std::vector<CairoGlyphInfo> const &glyphtext, SPStyle const *style) | 1531 | std::vector<CairoGlyphInfo> const &glyphtext, SPStyle const *style) |
111 | 1492 | { | 1532 | { |
112 | 1533 | |||
113 | 1534 | _prepareRenderText(); | ||
114 | 1535 | if (_is_omittext) | ||
115 | 1536 | return true; | ||
116 | 1537 | |||
117 | 1493 | // create a cairo_font_face from PangoFont | 1538 | // create a cairo_font_face from PangoFont |
118 | 1494 | double size = style->font_size.computed; /// \fixme why is this variable never used? | 1539 | double size = style->font_size.computed; /// \fixme why is this variable never used? |
119 | 1495 | gpointer fonthash = (gpointer)font; | 1540 | gpointer fonthash = (gpointer)font; |
120 | 1496 | 1541 | ||
121 | === modified file 'src/extension/internal/cairo-render-context.h' | |||
122 | --- src/extension/internal/cairo-render-context.h 2013-03-15 00:39:02 +0000 | |||
123 | +++ src/extension/internal/cairo-render-context.h 2013-08-30 22:23:52 +0000 | |||
124 | @@ -94,6 +94,8 @@ | |||
125 | 94 | void setPDFLevel(unsigned int level); | 94 | void setPDFLevel(unsigned int level); |
126 | 95 | void setTextToPath(bool texttopath); | 95 | void setTextToPath(bool texttopath); |
127 | 96 | bool getTextToPath(void); | 96 | bool getTextToPath(void); |
128 | 97 | void setOmitText(bool omittext); | ||
129 | 98 | bool getOmitText(void); | ||
130 | 97 | void setFilterToBitmap(bool filtertobitmap); | 99 | void setFilterToBitmap(bool filtertobitmap); |
131 | 98 | bool getFilterToBitmap(void); | 100 | bool getFilterToBitmap(void); |
132 | 99 | void setBitmapResolution(int resolution); | 101 | void setBitmapResolution(int resolution); |
133 | @@ -109,6 +111,9 @@ | |||
134 | 109 | /** Saves the contents of the context to a PNG file. */ | 111 | /** Saves the contents of the context to a PNG file. */ |
135 | 110 | bool saveAsPng(const char *file_name); | 112 | bool saveAsPng(const char *file_name); |
136 | 111 | 113 | ||
137 | 114 | /** On targets supporting multiple pages, sends subsequent rendering to a new page*/ | ||
138 | 115 | void newPage(void); | ||
139 | 116 | |||
140 | 112 | /* Render/clip mode setting/query */ | 117 | /* Render/clip mode setting/query */ |
141 | 113 | void setRenderMode(CairoRenderMode mode); | 118 | void setRenderMode(CairoRenderMode mode); |
142 | 114 | CairoRenderMode getRenderMode(void) const; | 119 | CairoRenderMode getRenderMode(void) const; |
143 | @@ -150,6 +155,12 @@ | |||
144 | 150 | CairoRenderContext(CairoRenderer *renderer); | 155 | CairoRenderContext(CairoRenderer *renderer); |
145 | 151 | virtual ~CairoRenderContext(void); | 156 | virtual ~CairoRenderContext(void); |
146 | 152 | 157 | ||
147 | 158 | enum CairoOmitTextPageState { | ||
148 | 159 | EMPTY, | ||
149 | 160 | GRAPHIC_ON_TOP, | ||
150 | 161 | NEW_PAGE_ON_GRAPHIC | ||
151 | 162 | }; | ||
152 | 163 | |||
153 | 153 | float _width; | 164 | float _width; |
154 | 154 | float _height; | 165 | float _height; |
155 | 155 | unsigned short _dpi; | 166 | unsigned short _dpi; |
156 | @@ -157,6 +168,7 @@ | |||
157 | 157 | unsigned int _ps_level; | 168 | unsigned int _ps_level; |
158 | 158 | bool _eps; | 169 | bool _eps; |
159 | 159 | bool _is_texttopath; | 170 | bool _is_texttopath; |
160 | 171 | bool _is_omittext; | ||
161 | 160 | bool _is_filtertobitmap; | 172 | bool _is_filtertobitmap; |
162 | 161 | int _bitmapresolution; | 173 | int _bitmapresolution; |
163 | 162 | 174 | ||
164 | @@ -182,6 +194,8 @@ | |||
165 | 182 | CairoRenderMode _render_mode; | 194 | CairoRenderMode _render_mode; |
166 | 183 | CairoClipMode _clip_mode; | 195 | CairoClipMode _clip_mode; |
167 | 184 | 196 | ||
168 | 197 | CairoOmitTextPageState _omittext_state; | ||
169 | 198 | |||
170 | 185 | cairo_pattern_t *_createPatternForPaintServer(SPPaintServer const *const paintserver, | 199 | cairo_pattern_t *_createPatternForPaintServer(SPPaintServer const *const paintserver, |
171 | 186 | Geom::OptRect const &pbox, float alpha); | 200 | Geom::OptRect const &pbox, float alpha); |
172 | 187 | cairo_pattern_t *_createPatternPainter(SPPaintServer const *const paintserver, Geom::OptRect const &pbox); | 201 | cairo_pattern_t *_createPatternPainter(SPPaintServer const *const paintserver, Geom::OptRect const &pbox); |
173 | @@ -196,6 +210,9 @@ | |||
174 | 196 | void _concatTransform(cairo_t *cr, double xx, double yx, double xy, double yy, double x0, double y0); | 210 | void _concatTransform(cairo_t *cr, double xx, double yx, double xy, double yy, double x0, double y0); |
175 | 197 | void _concatTransform(cairo_t *cr, Geom::Affine const &transform); | 211 | void _concatTransform(cairo_t *cr, Geom::Affine const &transform); |
176 | 198 | 212 | ||
177 | 213 | void _prepareRenderGraphic(void); | ||
178 | 214 | void _prepareRenderText(void); | ||
179 | 215 | |||
180 | 199 | GHashTable *font_table; | 216 | GHashTable *font_table; |
181 | 200 | static void font_data_free(gpointer data); | 217 | static void font_data_free(gpointer data); |
182 | 201 | 218 | ||
183 | 202 | 219 | ||
184 | === modified file 'src/extension/internal/cairo-renderer-pdf-out.cpp' | |||
185 | --- src/extension/internal/cairo-renderer-pdf-out.cpp 2013-08-06 18:54:40 +0000 | |||
186 | +++ src/extension/internal/cairo-renderer-pdf-out.cpp 2013-08-30 22:23:52 +0000 | |||
187 | @@ -94,7 +94,7 @@ | |||
188 | 94 | CairoRenderContext *ctx = renderer->createContext(); | 94 | CairoRenderContext *ctx = renderer->createContext(); |
189 | 95 | ctx->setPDFLevel(level); | 95 | ctx->setPDFLevel(level); |
190 | 96 | ctx->setTextToPath(texttopath); | 96 | ctx->setTextToPath(texttopath); |
192 | 97 | renderer->_omitText = omittext; | 97 | ctx->setOmitText(omittext); |
193 | 98 | ctx->setFilterToBitmap(filtertobitmap); | 98 | ctx->setFilterToBitmap(filtertobitmap); |
194 | 99 | ctx->setBitmapResolution(resolution); | 99 | ctx->setBitmapResolution(resolution); |
195 | 100 | 100 | ||
196 | 101 | 101 | ||
197 | === modified file 'src/extension/internal/cairo-renderer.cpp' | |||
198 | --- src/extension/internal/cairo-renderer.cpp 2013-07-31 22:33:03 +0000 | |||
199 | +++ src/extension/internal/cairo-renderer.cpp 2013-08-30 22:23:52 +0000 | |||
200 | @@ -101,7 +101,6 @@ | |||
201 | 101 | namespace Internal { | 101 | namespace Internal { |
202 | 102 | 102 | ||
203 | 103 | CairoRenderer::CairoRenderer(void) | 103 | CairoRenderer::CairoRenderer(void) |
204 | 104 | : _omitText(false) | ||
205 | 105 | {} | 104 | {} |
206 | 106 | 105 | ||
207 | 107 | CairoRenderer::~CairoRenderer(void) | 106 | CairoRenderer::~CairoRenderer(void) |
208 | @@ -578,11 +577,6 @@ | |||
209 | 578 | // TODO change this to accept a const SPItem: | 577 | // TODO change this to accept a const SPItem: |
210 | 579 | void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) | 578 | void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) |
211 | 580 | { | 579 | { |
212 | 581 | if ( _omitText && (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) ) { | ||
213 | 582 | // skip text if _omitText is true | ||
214 | 583 | return; | ||
215 | 584 | } | ||
216 | 585 | |||
217 | 586 | ctx->pushState(); | 580 | ctx->pushState(); |
218 | 587 | setStateForItem(ctx, item); | 581 | setStateForItem(ctx, item); |
219 | 588 | 582 | ||
220 | 589 | 583 | ||
221 | === modified file 'src/extension/internal/cairo-renderer.h' | |||
222 | --- src/extension/internal/cairo-renderer.h 2013-03-15 00:39:02 +0000 | |||
223 | +++ src/extension/internal/cairo-renderer.h 2013-08-30 22:23:52 +0000 | |||
224 | @@ -57,10 +57,6 @@ | |||
225 | 57 | 57 | ||
226 | 58 | /** Traverses the object tree and invokes the render methods. */ | 58 | /** Traverses the object tree and invokes the render methods. */ |
227 | 59 | void renderItem(CairoRenderContext *ctx, SPItem *item); | 59 | void renderItem(CairoRenderContext *ctx, SPItem *item); |
228 | 60 | |||
229 | 61 | /** If _omitText is true, no text will be output to the PDF document. | ||
230 | 62 | The PDF will be exactly the same as if the text was written to it and then erased. */ | ||
231 | 63 | bool _omitText; | ||
232 | 64 | }; | 60 | }; |
233 | 65 | 61 | ||
234 | 66 | // FIXME: this should be a static method of CairoRenderer | 62 | // FIXME: this should be a static method of CairoRenderer |
235 | 67 | 63 | ||
236 | === modified file 'src/extension/internal/latex-text-renderer.cpp' | |||
237 | --- src/extension/internal/latex-text-renderer.cpp 2013-07-31 22:33:03 +0000 | |||
238 | +++ src/extension/internal/latex-text-renderer.cpp 2013-08-30 22:23:52 +0000 | |||
239 | @@ -9,6 +9,7 @@ | |||
240 | 9 | * Miklos Erdelyi <erdelyim@gmail.com> | 9 | * Miklos Erdelyi <erdelyim@gmail.com> |
241 | 10 | * Jon A. Cruz <jon@joncruz.org> | 10 | * Jon A. Cruz <jon@joncruz.org> |
242 | 11 | * Abhishek Sharma | 11 | * Abhishek Sharma |
243 | 12 | * David R. Bild <drbild@umich.edu> | ||
244 | 12 | * | 13 | * |
245 | 13 | * Copyright (C) 2006-2011 Authors | 14 | * Copyright (C) 2006-2011 Authors |
246 | 14 | * | 15 | * |
247 | @@ -98,7 +99,9 @@ | |||
248 | 98 | LaTeXTextRenderer::LaTeXTextRenderer(bool pdflatex) | 99 | LaTeXTextRenderer::LaTeXTextRenderer(bool pdflatex) |
249 | 99 | : _stream(NULL), | 100 | : _stream(NULL), |
250 | 100 | _filename(NULL), | 101 | _filename(NULL), |
252 | 101 | _pdflatex(pdflatex) | 102 | _pdflatex(pdflatex), |
253 | 103 | _omittext_state(EMPTY), | ||
254 | 104 | _omittext_page(1) | ||
255 | 102 | { | 105 | { |
256 | 103 | push_transform(Geom::identity()); | 106 | push_transform(Geom::identity()); |
257 | 104 | } | 107 | } |
258 | @@ -262,6 +265,11 @@ | |||
259 | 262 | void | 265 | void |
260 | 263 | LaTeXTextRenderer::sp_text_render(SPItem *item) | 266 | LaTeXTextRenderer::sp_text_render(SPItem *item) |
261 | 264 | { | 267 | { |
262 | 268 | // Only PDFLaTeX supports importing a single page of a graphics file, | ||
263 | 269 | // so only PDF backend gets interleaved text/graphics | ||
264 | 270 | if (_pdflatex && _omittext_state == GRAPHIC_ON_TOP) | ||
265 | 271 | _omittext_state = NEW_PAGE_ON_GRAPHIC; | ||
266 | 272 | |||
267 | 265 | SPText *textobj = SP_TEXT (item); | 273 | SPText *textobj = SP_TEXT (item); |
268 | 266 | SPStyle *style = item->style; | 274 | SPStyle *style = item->style; |
269 | 267 | 275 | ||
270 | @@ -395,6 +403,11 @@ | |||
271 | 395 | Flowing in rectangle is possible, not in arb shape. | 403 | Flowing in rectangle is possible, not in arb shape. |
272 | 396 | */ | 404 | */ |
273 | 397 | 405 | ||
274 | 406 | // Only PDFLaTeX supports importing a single page of a graphics file, | ||
275 | 407 | // so only PDF backend gets interleaved text/graphics | ||
276 | 408 | if (_pdflatex && _omittext_state == GRAPHIC_ON_TOP) | ||
277 | 409 | _omittext_state = NEW_PAGE_ON_GRAPHIC; | ||
278 | 410 | |||
279 | 398 | SPFlowtext *flowtext = SP_FLOWTEXT(item); | 411 | SPFlowtext *flowtext = SP_FLOWTEXT(item); |
280 | 399 | SPStyle *style = item->style; | 412 | SPStyle *style = item->style; |
281 | 400 | 413 | ||
282 | @@ -556,8 +569,13 @@ | |||
283 | 556 | return sp_text_render(item); | 569 | return sp_text_render(item); |
284 | 557 | } else if (SP_IS_FLOWTEXT(item)) { | 570 | } else if (SP_IS_FLOWTEXT(item)) { |
285 | 558 | return sp_flowtext_render(item); | 571 | return sp_flowtext_render(item); |
286 | 572 | } else { | ||
287 | 573 | // Only PDFLaTeX supports importing a single page of a graphics file, | ||
288 | 574 | // so only PDF backend gets interleaved text/graphics | ||
289 | 575 | if (_pdflatex && (_omittext_state == EMPTY || _omittext_state == NEW_PAGE_ON_GRAPHIC)) | ||
290 | 576 | writeGraphicPage(); | ||
291 | 577 | _omittext_state = GRAPHIC_ON_TOP; | ||
292 | 559 | } | 578 | } |
293 | 560 | // We are not interested in writing the other SPItem types to LaTeX | ||
294 | 561 | } | 579 | } |
295 | 562 | 580 | ||
296 | 563 | void | 581 | void |
297 | @@ -568,6 +586,20 @@ | |||
298 | 568 | pop_transform(); | 586 | pop_transform(); |
299 | 569 | } | 587 | } |
300 | 570 | 588 | ||
301 | 589 | void | ||
302 | 590 | LaTeXTextRenderer::writeGraphicPage(void) { | ||
303 | 591 | Inkscape::SVGOStringStream os; | ||
304 | 592 | os.setf(std::ios::fixed); // no scientific notation | ||
305 | 593 | |||
306 | 594 | // strip pathname, as it is probably desired. Having a specific path in the TeX file is not convenient. | ||
307 | 595 | if (_pdflatex) | ||
308 | 596 | os << " \\put(0,0){\\includegraphics[width=\\unitlength,page=" << _omittext_page++ << "]{" << _filename << "}}%\n"; | ||
309 | 597 | else | ||
310 | 598 | os << " \\put(0,0){\\includegraphics[width=\\unitlength]{" << _filename << "}}%\n"; | ||
311 | 599 | |||
312 | 600 | fprintf(_stream, "%s", os.str().c_str()); | ||
313 | 601 | } | ||
314 | 602 | |||
315 | 571 | bool | 603 | bool |
316 | 572 | LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base) | 604 | LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base) |
317 | 573 | { | 605 | { |
318 | @@ -625,11 +657,12 @@ | |||
319 | 625 | os << " \\makeatother%\n"; | 657 | os << " \\makeatother%\n"; |
320 | 626 | 658 | ||
321 | 627 | os << " \\begin{picture}(" << _width << "," << _height << ")%\n"; | 659 | os << " \\begin{picture}(" << _width << "," << _height << ")%\n"; |
322 | 628 | // strip pathname, as it is probably desired. Having a specific path in the TeX file is not convenient. | ||
323 | 629 | os << " \\put(0,0){\\includegraphics[width=\\unitlength]{" << _filename << "}}%\n"; | ||
324 | 630 | 660 | ||
325 | 631 | fprintf(_stream, "%s", os.str().c_str()); | 661 | fprintf(_stream, "%s", os.str().c_str()); |
326 | 632 | 662 | ||
327 | 663 | if (!_pdflatex) | ||
328 | 664 | writeGraphicPage(); | ||
329 | 665 | |||
330 | 633 | return true; | 666 | return true; |
331 | 634 | } | 667 | } |
332 | 635 | 668 | ||
333 | 636 | 669 | ||
334 | === modified file 'src/extension/internal/latex-text-renderer.h' | |||
335 | --- src/extension/internal/latex-text-renderer.h 2012-10-28 14:10:22 +0000 | |||
336 | +++ src/extension/internal/latex-text-renderer.h 2013-08-30 22:23:52 +0000 | |||
337 | @@ -47,11 +47,20 @@ | |||
338 | 47 | void renderItem(SPItem *item); | 47 | void renderItem(SPItem *item); |
339 | 48 | 48 | ||
340 | 49 | protected: | 49 | protected: |
341 | 50 | enum LaTeXOmitTextPageState { | ||
342 | 51 | EMPTY, | ||
343 | 52 | GRAPHIC_ON_TOP, | ||
344 | 53 | NEW_PAGE_ON_GRAPHIC | ||
345 | 54 | }; | ||
346 | 55 | |||
347 | 50 | FILE * _stream; | 56 | FILE * _stream; |
348 | 51 | gchar * _filename; | 57 | gchar * _filename; |
349 | 52 | 58 | ||
350 | 53 | bool _pdflatex; /** true if ouputting for pdfLaTeX*/ | 59 | bool _pdflatex; /** true if ouputting for pdfLaTeX*/ |
351 | 54 | 60 | ||
352 | 61 | LaTeXOmitTextPageState _omittext_state; | ||
353 | 62 | gulong _omittext_page; | ||
354 | 63 | |||
355 | 55 | void push_transform(Geom::Affine const &transform); | 64 | void push_transform(Geom::Affine const &transform); |
356 | 56 | Geom::Affine const & transform(); | 65 | Geom::Affine const & transform(); |
357 | 57 | void pop_transform(); | 66 | void pop_transform(); |
358 | @@ -60,6 +69,8 @@ | |||
359 | 60 | void writePreamble(); | 69 | void writePreamble(); |
360 | 61 | void writePostamble(); | 70 | void writePostamble(); |
361 | 62 | 71 | ||
362 | 72 | void writeGraphicPage(); | ||
363 | 73 | |||
364 | 63 | void sp_item_invoke_render(SPItem *item); | 74 | void sp_item_invoke_render(SPItem *item); |
365 | 64 | void sp_root_render(SPRoot *item); | 75 | void sp_root_render(SPRoot *item); |
366 | 65 | void sp_group_render(SPItem *item); | 76 | void sp_group_render(SPItem *item); |