latex-pstricks.cpp revision bb4a96c096eda596fa1701dceff81c06a4255c99
#define __SP_LATEX_C__
/*
* LaTeX Printing
*
* Author:
* Michael Forbes <miforbes@mbhs.edu>
*
* Copyright (C) 2004 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <signal.h>
#include <errno.h>
#include "libnr/n-art-bpath.h"
#include "sp-item.h"
#include "style.h"
#include "latex-pstricks.h"
#include <unit-constants.h>
namespace Inkscape {
namespace Extension {
namespace Internal {
{
}
PrintLatex::~PrintLatex (void)
{
/* restore default signal handling for SIGPIPE */
#endif
return;
}
unsigned int
{
return TRUE;
}
unsigned int
{
int res;
gsize bytesWritten = 0;
/* TODO: Replace the below fprintf's with something that does the right thing whether in
* gui or batch mode (e.g. --print=blah). Consider throwing an exception: currently one of
* the callers (sp_print_document_to_file, "ret = mod->begin(doc)") wrongly ignores the
* return code.
*/
if (!osf) {
return 0;
}
}
if (_stream) {
/* fixme: this is kinda icky */
#endif
}
/* flush this to test output stream as early as possible */
/*g_print("caught error in sp_module_print_plain_begin\n");*/
g_strerror(errno));
}
g_print("Printing failed\n");
/* fixme: should use pclose() for pipes */
return 0;
}
// width and height in pt
NRRect d;
bool pageLandscape;
// printf("Page Bounding Box: %s\n", pageBoundingBox ? "TRUE" : "FALSE");
/* if (pageBoundingBox) {
d.x0 = d.y0 = 0;
d.x1 = ceil(_width);
d.y1 = ceil(_height);
} else */{ // no bounding boxes for now
// convert from px to pt
}
if (res >= 0) {
os << "%%Please note this file requires PSTricks extensions\n";
// 2004 Dec 10, BFC:
// The point of the following code is (1) to do the thing that's expected by users
// who have done File>New>A4_landscape or ...letter_landscape (i.e., rotate
// the output), while (2) not messing up users who simply want their output wider
// than it is tall (e.g., small figures for inclusion in LaTeX).
// The original patch by WQ only had the w>h condition.
{
pageLandscape = (
(w > 0. && h > 0.) // empty documents fail this sanity check, have w<0, h<0
&& (w > h) // implies, but does not prove, the user wanted landscape
&& (w > 600) // approximate maximum printable width of an A4
)
? true : false;
}
if (pageLandscape) {
os << "\\rotate{90}\n";
}
os << "\\psset{xunit=.5pt,yunit=.5pt,runit=.5pt}\n";
// from now on we can output px, but they will be treated as pt
}
}
unsigned int
{
int res;
if (!_stream) return 0;
/* Flush stream to be sure. */
return 0;
}
const char * comment)
{
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
}
unsigned int
{
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
float rgb[3];
os << "\\pscustom[linestyle=none,fillstyle=solid,fillcolor=curcolor]\n{\n";
os << "}\n}\n";
}
return 0;
}
unsigned int
PrintLatex::stroke (Inkscape::Extension::Print *mod, const NRBPath *bpath, const NRMatrix *transform, const SPStyle *style,
{
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
float rgb[3];
if (style->stroke_dasharray_set &&
int i;
os << ",linestyle=dashed,dash=";
if ((i)) {
os << " ";
}
}
}
os <<"]\n{\n";
os << "}\n}\n";
}
return 0;
}
void
{
unsigned int closed;
os << "\\newpath\n";
using NR::X;
using NR::Y;
case NR_MOVETO:
if (closed) {
os << "\\closepath\n";
}
break;
case NR_MOVETO_OPEN:
if (closed) {
os << "\\closepath\n";
}
break;
case NR_LINETO:
break;
case NR_CURVETO:
break;
default:
break;
}
bp += 1;
}
if (closed) {
os << "\\closepath\n";
}
}
bool
{
}
#include "clear-n_.h"
void
PrintLatex::init (void)
{
/* SVG in */
"<inkscape-extension>\n"
"<param name=\"destination\" type=\"string\"></param>\n"
"<param name=\"textToPath\" type=\"boolean\">TRUE</param>\n"
"<print/>\n"
"</inkscape-extension>", new PrintLatex());
return;
}
} /* namespace Internal */
} /* namespace Extension */
} /* namespace Inkscape */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :