diff options
| author | Matthew Petroff <matthew@mpetroff.net> | 2013-09-12 23:14:21 +0000 |
|---|---|---|
| committer | Matthew Petroff <matthew@mpetroff.net> | 2013-09-12 23:14:21 +0000 |
| commit | 51c44884aca2d41b8b38df329835e2a3c2d4e0ef (patch) | |
| tree | 3b7576e868b9edbabc1bc77d5e0320971ddad243 /src/extension/internal/latex-text-renderer.cpp | |
| parent | Finish fixing document unit change undo bug. (diff) | |
| parent | Merge in fix for critical blocker #166371 (diff) | |
| download | inkscape-51c44884aca2d41b8b38df329835e2a3c2d4e0ef.tar.gz inkscape-51c44884aca2d41b8b38df329835e2a3c2d4e0ef.zip | |
Merge from trunk.
(bzr r12475.1.16)
Diffstat (limited to 'src/extension/internal/latex-text-renderer.cpp')
| -rw-r--r-- | src/extension/internal/latex-text-renderer.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index b1c67aa81..1303b82e2 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -98,7 +98,9 @@ latex_render_document_text_to_file( SPDocument *doc, gchar const *filename, LaTeXTextRenderer::LaTeXTextRenderer(bool pdflatex) : _stream(NULL), _filename(NULL), - _pdflatex(pdflatex) + _pdflatex(pdflatex), + _omittext_state(EMPTY), + _omittext_page(1) { push_transform(Geom::identity()); } @@ -262,6 +264,11 @@ LaTeXTextRenderer::sp_use_render(SPItem *item) void LaTeXTextRenderer::sp_text_render(SPItem *item) { + // Only PDFLaTeX supports importing a single page of a graphics file, + // so only PDF backend gets interleaved text/graphics + if (_pdflatex && _omittext_state == GRAPHIC_ON_TOP) + _omittext_state = NEW_PAGE_ON_GRAPHIC; + SPText *textobj = SP_TEXT (item); SPStyle *style = item->style; @@ -395,6 +402,11 @@ Flowtext is possible by using a minipage! :) Flowing in rectangle is possible, not in arb shape. */ + // Only PDFLaTeX supports importing a single page of a graphics file, + // so only PDF backend gets interleaved text/graphics + if (_pdflatex && _omittext_state == GRAPHIC_ON_TOP) + _omittext_state = NEW_PAGE_ON_GRAPHIC; + SPFlowtext *flowtext = SP_FLOWTEXT(item); SPStyle *style = item->style; @@ -556,8 +568,13 @@ LaTeXTextRenderer::sp_item_invoke_render(SPItem *item) return sp_text_render(item); } else if (SP_IS_FLOWTEXT(item)) { return sp_flowtext_render(item); + } else { + // Only PDFLaTeX supports importing a single page of a graphics file, + // so only PDF backend gets interleaved text/graphics + if (_pdflatex && (_omittext_state == EMPTY || _omittext_state == NEW_PAGE_ON_GRAPHIC)) + writeGraphicPage(); + _omittext_state = GRAPHIC_ON_TOP; } - // We are not interested in writing the other SPItem types to LaTeX } void @@ -568,6 +585,20 @@ LaTeXTextRenderer::renderItem(SPItem *item) pop_transform(); } +void +LaTeXTextRenderer::writeGraphicPage(void) { + Inkscape::SVGOStringStream os; + os.setf(std::ios::fixed); // no scientific notation + + // strip pathname, as it is probably desired. Having a specific path in the TeX file is not convenient. + if (_pdflatex) + os << " \\put(0,0){\\includegraphics[width=\\unitlength,page=" << _omittext_page++ << "]{" << _filename << "}}%\n"; + else + os << " \\put(0,0){\\includegraphics[width=\\unitlength]{" << _filename << "}}%\n"; + + fprintf(_stream, "%s", os.str().c_str()); +} + bool LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base) { @@ -625,11 +656,12 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, float bl os << " \\makeatother%\n"; os << " \\begin{picture}(" << _width << "," << _height << ")%\n"; - // strip pathname, as it is probably desired. Having a specific path in the TeX file is not convenient. - os << " \\put(0,0){\\includegraphics[width=\\unitlength]{" << _filename << "}}%\n"; fprintf(_stream, "%s", os.str().c_str()); + if (!_pdflatex) + writeGraphicPage(); + return true; } |
