summaryrefslogtreecommitdiffstats
path: root/src/extension/internal
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2011-06-19 10:00:24 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2011-06-19 10:00:24 +0000
commit06dfaa02d7a80bcdff717d579a48f81643f53f31 (patch)
tree49b8e67ad9051f1507b0959cac986383ab4001e2 /src/extension/internal
parentFix rendering of control points (diff)
parentfix bug 796451: Measure tools should support rotation constraint (diff)
downloadinkscape-06dfaa02d7a80bcdff717d579a48f81643f53f31.tar.gz
inkscape-06dfaa02d7a80bcdff717d579a48f81643f53f31.zip
Merge from trunk
(bzr r9508.1.89)
Diffstat (limited to 'src/extension/internal')
-rw-r--r--src/extension/internal/CMakeLists.txt31
-rw-r--r--src/extension/internal/bitmap/CMakeLists.txt37
-rw-r--r--src/extension/internal/bluredge.cpp8
-rw-r--r--src/extension/internal/cairo-render-context.cpp6
-rw-r--r--src/extension/internal/cairo-renderer.cpp29
-rw-r--r--src/extension/internal/emf-win32-inout.cpp71
-rw-r--r--src/extension/internal/emf-win32-print.cpp7
-rw-r--r--src/extension/internal/filter/CMakeLists.txt8
-rwxr-xr-xsrc/extension/internal/filter/experimental.h2
-rw-r--r--src/extension/internal/filter/filter.cpp2
-rw-r--r--src/extension/internal/javafx-out.cpp6
-rw-r--r--src/extension/internal/latex-text-renderer.cpp128
-rw-r--r--src/extension/internal/latex-text-renderer.h3
-rw-r--r--src/extension/internal/pdf-input-cairo.cpp4
-rw-r--r--src/extension/internal/pdf-input-cairo.h10
-rw-r--r--src/extension/internal/pdfinput/CMakeLists.txt5
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp5
-rw-r--r--src/extension/internal/pdfinput/pdf-input.h10
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp10
-rw-r--r--src/extension/internal/pov-out.cpp3
-rw-r--r--src/extension/internal/svg.cpp1
-rw-r--r--src/extension/internal/wpg-input.cpp22
22 files changed, 214 insertions, 194 deletions
diff --git a/src/extension/internal/CMakeLists.txt b/src/extension/internal/CMakeLists.txt
deleted file mode 100644
index 8b23cb0ac..000000000
--- a/src/extension/internal/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-IF(WIN32)
-SET(EXT_INT_WIN
-win32.cpp
-)
-ENDIF(WIN32)
-
-SET(extension_internal_SRC
-bluredge.cpp
-cairo-png-out.cpp
-cairo-ps-out.cpp
-cairo-render-context.cpp
-cairo-renderer.cpp
-cairo-renderer-pdf-out.cpp
-emf-win32-inout.cpp
-emf-win32-print.cpp
-gdkpixbuf-input.cpp
-gimpgrad.cpp
-grid.cpp
-latex-pstricks.cpp
-latex-pstricks-out.cpp
-odf.cpp
-pdfinput
-latex-text-renderer.cpp
-pdf-input-cairo.cpp
-pov-out.cpp
-javafx-out.cpp
-svg.cpp
-svgz.cpp
-wpg-input.cpp
-${EXT_INT_WIN}
-)
diff --git a/src/extension/internal/bitmap/CMakeLists.txt b/src/extension/internal/bitmap/CMakeLists.txt
deleted file mode 100644
index 8aec17492..000000000
--- a/src/extension/internal/bitmap/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-SET(extension_internal_bitmap_SRC
-adaptiveThreshold.cpp
-addNoise.cpp
-blur.cpp
-channel.cpp
-charcoal.cpp
-colorize.cpp
-contrast.cpp
-cycleColormap.cpp
-despeckle.cpp
-edge.cpp
-emboss.cpp
-enhance.cpp
-equalize.cpp
-gaussianBlur.cpp
-imagemagick.cpp
-implode.cpp
-levelChannel.cpp
-level.cpp
-medianFilter.cpp
-modulate.cpp
-negate.cpp
-normalize.cpp
-oilPaint.cpp
-opacity.cpp
-raise.cpp
-reduceNoise.cpp
-sample.cpp
-shade.cpp
-sharpen.cpp
-solarize.cpp
-spread.cpp
-swirl.cpp
-threshold.cpp
-unsharpmask.cpp
-wave.cpp
-)
diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp
index 8ec09d11e..76582ab05 100644
--- a/src/extension/internal/bluredge.cpp
+++ b/src/extension/internal/bluredge.cpp
@@ -59,7 +59,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
int steps = module->get_param_int("num-steps");
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0);
+ double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px");
using Inkscape::Util::GSListConstIterator;
// TODO need to properly refcount the items, at least
@@ -97,10 +97,10 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
if (offset < 0.0) {
/* Doing an inset here folks */
offset *= -1.0;
- prefs->setDouble("/options/defaultoffsetwidth/value", offset);
+ prefs->setDoubleUnit("/options/defaultoffsetwidth/value", offset, "px");
sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_INSET)->get_action(desktop), NULL);
} else if (offset > 0.0) {
- prefs->setDouble("/options/defaultoffsetwidth/value", offset);
+ prefs->setDoubleUnit("/options/defaultoffsetwidth/value", offset, "px");
sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_OFFSET)->get_action(desktop), NULL);
}
@@ -110,7 +110,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
Inkscape::GC::release(new_group);
}
- prefs->setDouble("/options/defaultoffsetwidth/value", old_offset);
+ prefs->setDoubleUnit("/options/defaultoffsetwidth/value", old_offset, "px");
selection->clear();
selection->add(items.begin(), items.end());
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index 0e2194c17..b9c2a4488 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -1361,7 +1361,7 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
addClipPath(pathv, &style->fill_rule);
} else {
setPathVector(pathv);
- if (style->fill_rule.value == SP_WIND_RULE_EVENODD) {
+ if (style->fill_rule.computed == SP_WIND_RULE_EVENODD) {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_EVEN_ODD);
} else {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_WINDING);
@@ -1391,7 +1391,7 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
_setFillStyle(style, pbox);
setPathVector(pathv);
- if (style->fill_rule.value == SP_WIND_RULE_EVENODD) {
+ if (style->fill_rule.computed == SP_WIND_RULE_EVENODD) {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_EVEN_ODD);
} else {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_WINDING);
@@ -1606,7 +1606,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_ma
if (_render_mode == RENDER_MODE_CLIP) {
if (_clip_mode == CLIP_MODE_MASK) {
- if (style->fill_rule.value == SP_WIND_RULE_EVENODD) {
+ if (style->fill_rule.computed == SP_WIND_RULE_EVENODD) {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_EVEN_ODD);
} else {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_WINDING);
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index dbda82c28..bbafd7e94 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -170,11 +170,13 @@ static void sp_shape_render_invoke_marker_rendering(SPMarker* marker, Geom::Affi
if (render) {
SPItem* marker_item = sp_item_first_item_child(marker);
- tr = (Geom::Affine)marker_item->transform * (Geom::Affine)marker->c2p * tr;
- Geom::Affine old_tr = marker_item->transform;
- marker_item->transform = tr;
- ctx->getRenderer()->renderItem (ctx, marker_item);
- marker_item->transform = old_tr;
+ if (marker_item) {
+ tr = (Geom::Affine)marker_item->transform * (Geom::Affine)marker->c2p * tr;
+ Geom::Affine old_tr = marker_item->transform;
+ marker_item->transform = tr;
+ ctx->getRenderer()->renderItem (ctx, marker_item);
+ marker_item->transform = old_tr;
+ }
}
}
@@ -418,19 +420,18 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx)
ctx->popState();
}
-static void sp_root_render(SPItem *item, CairoRenderContext *ctx)
+static void sp_root_render(SPRoot *root, CairoRenderContext *ctx)
{
- SPRoot *root = SP_ROOT(item);
CairoRenderer *renderer = ctx->getRenderer();
- if (!ctx->getCurrentState()->has_overflow && item->parent)
+ if (!ctx->getCurrentState()->has_overflow && root->parent)
ctx->addClippingRect(root->x.computed, root->y.computed, root->width.computed, root->height.computed);
ctx->pushState();
- renderer->setStateForItem(ctx, item);
+ renderer->setStateForItem(ctx, root);
Geom::Affine tempmat (root->c2p);
ctx->transform(&tempmat);
- sp_group_render(item, ctx);
+ sp_group_render(root, ctx);
ctx->popState();
}
@@ -541,7 +542,10 @@ static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx)
if (SP_IS_ROOT(item)) {
TRACE(("root\n"));
- return sp_root_render(item, ctx);
+ return sp_root_render(SP_ROOT(item), ctx);
+ } else if (SP_IS_SYMBOL(item)) {
+ TRACE(("symbol\n"));
+ return sp_symbol_render(item, ctx);
} else if (SP_IS_GROUP(item)) {
TRACE(("group\n"));
return sp_group_render(item, ctx);
@@ -552,9 +556,6 @@ static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx)
TRACE(("use begin---\n"));
sp_use_render(item, ctx);
TRACE(("---use end\n"));
- } else if (SP_IS_SYMBOL(item)) {
- TRACE(("symbol\n"));
- return sp_symbol_render(item, ctx);
} else if (SP_IS_TEXT(item)) {
TRACE(("text\n"));
return sp_text_render(item, ctx);
diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp
index 2716faee2..646b33507 100644
--- a/src/extension/internal/emf-win32-inout.cpp
+++ b/src/extension/internal/emf-win32-inout.cpp
@@ -27,6 +27,8 @@
# include "config.h"
#endif
+//#include "inkscape.h"
+#include "sp-root.h"
#include "sp-path.h"
#include "style.h"
#include "print.h"
@@ -59,6 +61,8 @@ namespace Extension {
namespace Internal {
static float device_scale = DEVICESCALE;
+static RECTL rc_old;
+static bool clipset = false;
EmfWin32::EmfWin32 (void) // The null constructor
{
@@ -101,7 +105,7 @@ emf_print_document_to_file(SPDocument *doc, gchar const *filename)
context.module = mod;
/* fixme: This has to go into module constructor somehow */
/* Create new arena */
- mod->base = SP_ITEM(doc->getRoot());
+ mod->base = doc->getRoot();
mod->arena = NRArena::create();
mod->dkey = SPItem::display_key_new(1);
mod->root = mod->base->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
@@ -182,6 +186,7 @@ typedef struct emf_device_context {
typedef struct emf_callback_data {
Glib::ustring *outsvg;
Glib::ustring *path;
+ Glib::ustring *outdef;
EMF_DEVICE_CONTEXT dc[EMF_MAX_DC+1]; // FIXME: This should be dynamic..
int level;
@@ -288,6 +293,9 @@ output_style(PEMF_CALLBACK_DATA d, int iType)
tmp_style << "stroke-opacity:1;";
}
tmp_style << "\" ";
+ if (clipset)
+ tmp_style << "\n\tclip-path=\"url(#clipEmfPath" << d->id << ")\" ";
+ clipset = false;
*(d->outsvg) += tmp_style.str().c_str();
}
@@ -747,19 +755,20 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
{
dbg_str << "<!-- EMR_HEADER -->\n";
- *(d->outsvg) += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
+ *(d->outdef) += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
if (d->pDesc) {
- *(d->outsvg) += "<!-- ";
- *(d->outsvg) += d->pDesc;
- *(d->outsvg) += " -->\n";
+ *(d->outdef) += "<!-- ";
+ *(d->outdef) += d->pDesc;
+ *(d->outdef) += " -->\n";
}
ENHMETAHEADER *pEmr = (ENHMETAHEADER *) lpEMFR;
- tmp_outsvg << "<svg\n";
- tmp_outsvg << " xmlns:svg=\"http://www.w3.org/2000/svg\"\n";
- tmp_outsvg << " xmlns=\"http://www.w3.org/2000/svg\"\n";
- tmp_outsvg << " version=\"1.0\"\n";
+ SVGOStringStream tmp_outdef;
+ tmp_outdef << "<svg\n";
+ tmp_outdef << " xmlns:svg=\"http://www.w3.org/2000/svg\"\n";
+ tmp_outdef << " xmlns=\"http://www.w3.org/2000/svg\"\n";
+ tmp_outdef << " version=\"1.0\"\n";
d->xDPI = 2540;
d->yDPI = 2540;
@@ -777,15 +786,13 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
if (pEmr->szlMillimeters.cx && pEmr->szlDevice.cx)
device_scale = PX_PER_MM*pEmr->szlMillimeters.cx/pEmr->szlDevice.cx;
- tmp_outsvg <<
+ tmp_outdef <<
" width=\"" << d->MMX << "mm\"\n" <<
" height=\"" << d->MMY << "mm\">\n";
-// tmp_outsvg <<
-// " id=\"" << (d->id++) << "\">\n";
+ *(d->outdef) += tmp_outdef.str().c_str();
+ *(d->outdef) += "<defs>"; // temporary end of header
- tmp_outsvg << "<g>\n";
-// "<g\n" <<
-// " id=\"" << (d->id++) << "\">\n";
+ tmp_outsvg << "\n</defs>\n<g>\n"; // start of main body
if (pEmr->nHandles) {
d->n_obj = pEmr->nHandles;
@@ -1129,6 +1136,7 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
assert_empty_path(d, "EMR_EOF");
tmp_outsvg << "</g>\n";
tmp_outsvg << "</svg>\n";
+ *(d->outsvg) = *(d->outdef) + *(d->outsvg);
break;
}
case EMR_SETPIXELV:
@@ -1211,8 +1219,37 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
dbg_str << "<!-- EMR_EXCLUDECLIPRECT -->\n";
break;
case EMR_INTERSECTCLIPRECT:
+ {
dbg_str << "<!-- EMR_INTERSECTCLIPRECT -->\n";
+
+ PEMRINTERSECTCLIPRECT pEmr = (PEMRINTERSECTCLIPRECT) lpEMFR;
+ RECTL rc = pEmr->rclClip;
+ clipset = true;
+ if ((rc.left == rc_old.left) && (rc.top == rc_old.top) && (rc.right == rc_old.right) && (rc.bottom == rc_old.bottom))
+ break;
+ rc_old = rc;
+
+ double l = pix_to_x_point( d, rc.left, rc.top );
+ double t = pix_to_y_point( d, rc.left, rc.top );
+ double r = pix_to_x_point( d, rc.right, rc.bottom );
+ double b = pix_to_y_point( d, rc.right, rc.bottom );
+
+ SVGOStringStream tmp_rectangle;
+ tmp_rectangle << "\n<clipPath\n\tclipPathUnits=\"userSpaceOnUse\" ";
+ tmp_rectangle << "\n\tid=\"clipEmfPath" << ++(d->id) << "\" >";
+ tmp_rectangle << "\n<rect ";
+ tmp_rectangle << "\n\tx=\"" << l << "\" ";
+ tmp_rectangle << "\n\ty=\"" << t << "\" ";
+ tmp_rectangle << "\n\twidth=\"" << r-l << "\" ";
+ tmp_rectangle << "\n\theight=\"" << b-t << "\" />";
+ tmp_rectangle << "\n</clipPath>";
+
+ assert_empty_path(d, "EMR_RECTANGLE");
+
+ *(d->outdef) += tmp_rectangle.str().c_str();
+ *(d->path) = "";
break;
+ }
case EMR_SCALEVIEWPORTEXTEX:
dbg_str << "<!-- EMR_SCALEVIEWPORTEXTEX -->\n";
break;
@@ -2250,6 +2287,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
d.outsvg = new Glib::ustring("");
d.path = new Glib::ustring("");
+ d.outdef = new Glib::ustring("");
CHAR *ansi_uri = (CHAR *) local_fn;
gunichar2 *unicode_fn = g_utf8_to_utf16( local_fn, -1, NULL, NULL, NULL );
@@ -2368,6 +2406,8 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
delete d.outsvg;
if (d.path)
delete d.path;
+ if (d.outdef)
+ delete d.outdef;
if (local_fn)
g_free(local_fn);
if (unicode_fn)
@@ -2409,6 +2449,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
delete d.outsvg;
delete d.path;
+ delete d.outdef;
if (d.emf_obj) {
int i;
diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp
index eb6abeaca..e5d1b0681 100644
--- a/src/extension/internal/emf-win32-print.cpp
+++ b/src/extension/internal/emf-win32-print.cpp
@@ -42,9 +42,7 @@
#include "sp-item.h"
//#include "glib.h"
-//#include "gtk/gtkdialog.h"
-//#include "gtk/gtkbox.h"
-//#include "gtk/gtkstock.h"
+//#include "gtk/gtk.h"
//#include "glibmm/i18n.h"
//#include "enums.h"
@@ -52,6 +50,7 @@
#include "style.h"
//#include "sp-paint-server.h"
#include "inkscape-version.h"
+#include "sp-root.h"
//#include "libnrtype/FontFactory.h"
//#include "libnrtype/font-instance.h"
@@ -144,7 +143,7 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
d.x1 = _width;
d.y1 = _height;
} else {
- SPItem* doc_item = SP_ITEM(doc->getRoot());
+ SPItem* doc_item = doc->getRoot();
doc_item->invoke_bbox(&d, doc_item->i2d_affine(), TRUE);
}
diff --git a/src/extension/internal/filter/CMakeLists.txt b/src/extension/internal/filter/CMakeLists.txt
deleted file mode 100644
index 80a14ba3a..000000000
--- a/src/extension/internal/filter/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-SET(extension_internal_filter_SRC
-drop-shadow.h
-filter-all.cpp
-filter.cpp
-filter-file.cpp
-filter.h
-snow.h
-)
diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h
index 8d260f62e..f60a6b414 100755
--- a/src/extension/internal/filter/experimental.h
+++ b/src/extension/internal/filter/experimental.h
@@ -335,7 +335,7 @@ public:
"<param name=\"simply\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n"
"<param name=\"clean\" gui-text=\"" N_("Clean-up:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"500\">10</param>\n"
"<param name=\"erase\" gui-text=\"" N_("Erase:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"60\">0</param>\n"
- "<param name=\"transluscent\" gui-text=\"" N_("Transluscent") "\" type=\"boolean\" >false</param>\n"
+ "<param name=\"translucent\" gui-text=\"" N_("Translucent") "\" type=\"boolean\" >false</param>\n"
"<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">Smoothness</_param>\n"
"<param name=\"smooth\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n"
"<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n"
diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp
index 715278051..fb8d4de4b 100644
--- a/src/extension/internal/filter/filter.cpp
+++ b/src/extension/internal/filter/filter.cpp
@@ -133,7 +133,7 @@ Filter::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *d
items.insert<GSListConstIterator<SPItem *> >(items.end(), selection->itemList(), NULL);
Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc();
- Inkscape::XML::Node * defsrepr = SP_DOCUMENT_DEFS(document->doc())->getRepr();
+ Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr();
for(std::list<SPItem *>::iterator item = items.begin();
item != items.end(); item++) {
diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp
index 750849eb1..8399d602f 100644
--- a/src/extension/internal/javafx-out.cpp
+++ b/src/extension/internal/javafx-out.cpp
@@ -38,7 +38,7 @@
#include "helper/geom.h"
#include "helper/geom-curves.h"
#include <io/sys.h>
-
+#include "sp-root.h"
#include <string>
#include <stdio.h>
@@ -758,7 +758,7 @@ bool JavaFXOutput::doTree(SPDocument *doc)
miny = bignum;
maxy = -bignum;
- if (!doTreeRecursive(doc, doc->root)) {
+ if (!doTreeRecursive(doc, doc->getRoot())) {
return false;
}
@@ -875,7 +875,7 @@ bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8)
out(" content: [\n");
idindex = 0;
- doBody(doc, doc->root);
+ doBody(doc, doc->getRoot());
if (!doTail()) {
return false;
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index 1f9bdfef1..5d9fec905 100644
--- a/src/extension/internal/latex-text-renderer.cpp
+++ b/src/extension/internal/latex-text-renderer.cpp
@@ -10,7 +10,7 @@
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
- * Copyright (C) 2006-2010 Authors
+ * Copyright (C) 2006-2011 Authors
*
* Licensed under GNU GPL
*/
@@ -196,22 +196,22 @@ static char const preamble[] =
"%% \n"
"%% For more information, please see info/svg-inkscape on CTAN:\n"
"%% http://tug.ctan.org/tex-archive/info/svg-inkscape\n"
-"\n"
-"\\begingroup\n"
-" \\makeatletter\n"
+"%%\n"
+"\\begingroup%\n"
+" \\makeatletter%\n"
" \\providecommand\\color[2][]{%\n"
-" \\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package \'color.sty\' is not loaded}\n"
+" \\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package \'color.sty\' is not loaded}%\n"
" \\renewcommand\\color[2][]{}%\n"
-" }\n"
+" }%\n"
" \\providecommand\\transparent[1]{%\n"
-" \\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package \'transparent.sty\' is not loaded}\n"
+" \\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package \'transparent.sty\' is not loaded}%\n"
" \\renewcommand\\transparent[1]{}%\n"
-" }\n"
-" \\providecommand\\rotatebox[2]{#2}\n";
+" }%\n"
+" \\providecommand\\rotatebox[2]{#2}%\n";
static char const postamble[] =
" \\end{picture}%\n"
-"\\endgroup\n";
+"\\endgroup%\n";
void
LaTeXTextRenderer::writePreamble()
@@ -266,10 +266,15 @@ LaTeXTextRenderer::sp_text_render(SPItem *item)
SPText *textobj = SP_TEXT (item);
SPStyle *style = item->style;
- gchar *str = sp_te_get_string_multiline(item);
- if (!str) {
+ gchar *strtext = sp_te_get_string_multiline(item);
+ if (!strtext) {
return;
}
+ // replace carriage return with double slash
+ gchar ** splitstr = g_strsplit(strtext, "\n", -1);
+ gchar *str = g_strjoinv("\\\\ ", splitstr);
+ g_free(strtext);
+ g_strfreev(splitstr);
// get position and alignment
// Align vertically on the baseline of the font (retreived from the anchor point)
@@ -340,7 +345,7 @@ LaTeXTextRenderer::sp_text_render(SPItem *item)
li != le; li.nextStartOfSpan())
{
SPStyle const &spanstyle = *(sp_te_style_at_position (item, li));
- bool is_bold = false, is_italic = false;
+ bool is_bold = false, is_italic = false, is_oblique = false;
if (spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_500 ||
spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_600 ||
@@ -351,19 +356,34 @@ LaTeXTextRenderer::sp_text_render(SPItem *item)
spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_BOLDER)
{
is_bold = true;
- os << "{\\bfseries{}";
+ os << "\\textbf{";
}
if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_ITALIC)
{
is_italic = true;
- os << "{\\itshape{}";
+ os << "\\textit{";
+ }
+ if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_OBLIQUE)
+ {
+ is_oblique = true;
+ os << "\\textsl{"; // this is an accurate choice if the LaTeX chosen font matches the font in Inkscape. Gives bad results when it is not so...
}
Inkscape::Text::Layout::iterator ln = li;
ln.nextStartOfSpan();
- Glib::ustring spanstr = sp_te_get_string_multiline (item, li, ln);
- os << spanstr;
-
+ Glib::ustring uspanstr = sp_te_get_string_multiline (item, li, ln);
+ const gchar *spanstr = uspanstr.c_str();
+ if (!spanstr) {
+ continue;
+ }
+ // replace carriage return with double slash
+ gchar ** splitstr = g_strsplit(spanstr, "\n", -1);
+ gchar *spanstr_new = g_strjoinv("\\\\ ", splitstr);
+ os << spanstr_new;
+ g_strfreev(splitstr);
+ g_free(spanstr_new);
+
+ if (is_oblique) { os << "}"; } // oblique end
if (is_italic) { os << "}"; } // italic end
if (is_bold) { os << "}"; } // bold end
}
@@ -389,16 +409,6 @@ Flowing in rectangle is possible, not in arb shape.
SPFlowtext *flowtext = SP_FLOWTEXT(item);
SPStyle *style = item->style;
- gchar *strtext = sp_te_get_string_multiline(item);
- if (!strtext) {
- return;
- }
- // replace carriage return with double slash
- gchar ** splitstr = g_strsplit(strtext, "\n", -1);
- gchar *str = g_strjoinv("\\\\ ", splitstr);
- g_free(strtext);
- g_strfreev(splitstr);
-
SPItem *frame_item = flowtext->get_frame(NULL);
if (!frame_item || !SP_IS_RECT(frame_item)) {
g_warning("LaTeX export: non-rectangular flowed text shapes are not supported, skipping text.");
@@ -479,7 +489,7 @@ Flowing in rectangle is possible, not in arb shape.
li != le; li.nextStartOfSpan())
{
SPStyle const &spanstyle = *(sp_te_style_at_position (item, li));
- bool is_bold = false, is_italic = false;
+ bool is_bold = false, is_italic = false, is_oblique = false;
if (spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_500 ||
spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_600 ||
@@ -490,19 +500,34 @@ Flowing in rectangle is possible, not in arb shape.
spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_BOLDER)
{
is_bold = true;
- os << "{\\bfseries{}";
+ os << "\\textbf{";
}
if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_ITALIC)
{
is_italic = true;
- os << "{\\itshape{}";
+ os << "\\textit{";
+ }
+ if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_OBLIQUE)
+ {
+ is_oblique = true;
+ os << "\\textsl{"; // this is an accurate choice if the LaTeX chosen font matches the font in Inkscape. Gives bad results when it is not so...
}
Inkscape::Text::Layout::iterator ln = li;
ln.nextStartOfSpan();
- Glib::ustring spanstr = sp_te_get_string_multiline (item, li, ln);
- os << spanstr;
-
+ Glib::ustring uspanstr = sp_te_get_string_multiline (item, li, ln);
+ const gchar *spanstr = uspanstr.c_str();
+ if (!spanstr) {
+ continue;
+ }
+ // replace carriage return with double slash
+ gchar ** splitstr = g_strsplit(spanstr, "\n", -1);
+ gchar *spanstr_new = g_strjoinv("\\\\ ", splitstr);
+ os << spanstr_new;
+ g_strfreev(splitstr);
+ g_free(spanstr_new);
+
+ if (is_oblique) { os << "}"; } // oblique end
if (is_italic) { os << "}"; } // italic end
if (is_bold) { os << "}"; } // bold end
}
@@ -517,13 +542,10 @@ Flowing in rectangle is possible, not in arb shape.
fprintf(_stream, "%s", os.str().c_str());
}
-void
-LaTeXTextRenderer::sp_root_render(SPItem *item)
+void LaTeXTextRenderer::sp_root_render(SPRoot *root)
{
- SPRoot *root = SP_ROOT(item);
-
push_transform(root->c2p);
- sp_group_render(item);
+ sp_group_render(root);
pop_transform();
}
@@ -536,7 +558,7 @@ LaTeXTextRenderer::sp_item_invoke_render(SPItem *item)
}
if (SP_IS_ROOT(item)) {
- return sp_root_render(item);
+ return sp_root_render(SP_ROOT(item));
} else if (SP_IS_GROUP(item)) {
return sp_group_render(item);
} else if (SP_IS_USE(item)) {
@@ -598,19 +620,19 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *
// scaling of the image when including it in LaTeX
- os << " \\ifx\\svgwidth\\undefined\n";
- os << " \\setlength{\\unitlength}{" << d->width() * PT_PER_PX << "pt}\n";
- os << " \\ifx\\svgscale\\undefined\n";
- os << " \\relax\n";
- os << " \\else\n";
- os << " \\setlength{\\unitlength}{\\unitlength * \\real{\\svgscale}}\n";
- os << " \\fi\n";
- os << " \\else\n";
- os << " \\setlength{\\unitlength}{\\svgwidth}\n";
- os << " \\fi\n";
- os << " \\global\\let\\svgwidth\\undefined\n";
- os << " \\global\\let\\svgscale\\undefined\n";
- os << " \\makeatother\n";
+ os << " \\ifx\\svgwidth\\undefined%\n";
+ os << " \\setlength{\\unitlength}{" << d->width() * PT_PER_PX << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384
+ os << " \\ifx\\svgscale\\undefined%\n";
+ os << " \\relax%\n";
+ os << " \\else%\n";
+ os << " \\setlength{\\unitlength}{\\unitlength * \\real{\\svgscale}}%\n";
+ os << " \\fi%\n";
+ os << " \\else%\n";
+ os << " \\setlength{\\unitlength}{\\svgwidth}%\n";
+ os << " \\fi%\n";
+ os << " \\global\\let\\svgwidth\\undefined%\n";
+ os << " \\global\\let\\svgscale\\undefined%\n";
+ 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.
diff --git a/src/extension/internal/latex-text-renderer.h b/src/extension/internal/latex-text-renderer.h
index 2259427d6..66055a3bc 100644
--- a/src/extension/internal/latex-text-renderer.h
+++ b/src/extension/internal/latex-text-renderer.h
@@ -22,6 +22,7 @@
#include <stack>
class SPItem;
+struct SPRoot;
namespace Inkscape {
namespace Extension {
@@ -60,7 +61,7 @@ protected:
void writePostamble();
void sp_item_invoke_render(SPItem *item);
- void sp_root_render(SPItem *item);
+ void sp_root_render(SPRoot *item);
void sp_group_render(SPItem *item);
void sp_use_render(SPItem *item);
void sp_text_render(SPItem *item);
diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp
index 048b26bed..daa185268 100644
--- a/src/extension/internal/pdf-input-cairo.cpp
+++ b/src/extension/internal/pdf-input-cairo.cpp
@@ -31,6 +31,8 @@
#include <poppler/glib/poppler-document.h>
#include <poppler/glib/poppler-page.h>
+#include "ui/widget/spinbutton.h"
+
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -67,7 +69,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
// Page number
int num_pages = poppler_document_get_n_pages(_poppler_doc);
Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, num_pages, 1, 10, 0));
- _pageNumberSpin = Gtk::manage(new class Gtk::SpinButton(*_pageNumberSpin_adj, 1, 1));
+ _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
_labelTotalPages = Gtk::manage(new class Gtk::Label());
hbox2 = Gtk::manage(new class Gtk::HBox(false, 0));
// Disable the page selector when there's only one page
diff --git a/src/extension/internal/pdf-input-cairo.h b/src/extension/internal/pdf-input-cairo.h
index ad7c884cb..7581cb0a5 100644
--- a/src/extension/internal/pdf-input-cairo.h
+++ b/src/extension/internal/pdf-input-cairo.h
@@ -20,7 +20,6 @@
#include <gtkmm/button.h>
#include <gtkmm/buttonbox.h>
#include <gtkmm/label.h>
-#include <gtkmm/spinbutton.h>
#include <gtkmm/box.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/comboboxtext.h>
@@ -39,6 +38,13 @@
#include "../implementation/implementation.h"
namespace Inkscape {
+
+namespace UI {
+namespace Widget {
+ class SpinButton;
+}
+}
+
namespace Extension {
namespace Internal {
@@ -64,7 +70,7 @@ private:
class Gtk::Button * cancelbutton;
class Gtk::Button * okbutton;
class Gtk::Label * _labelSelect;
- class Gtk::SpinButton * _pageNumberSpin;
+ class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
class Gtk::Label * _labelTotalPages;
class Gtk::HBox * hbox2;
class Gtk::CheckButton * _cropCheck;
diff --git a/src/extension/internal/pdfinput/CMakeLists.txt b/src/extension/internal/pdfinput/CMakeLists.txt
deleted file mode 100644
index 9a093a065..000000000
--- a/src/extension/internal/pdfinput/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-SET(extension_internal_pdfinput_SRC
-pdf-input.cpp
-pdf-parser.cpp
-svg-builder.cpp
-)
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index ae3e473a5..186f337c4 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -40,7 +40,8 @@
#include "inkscape.h"
#include "dialogs/dialog-events.h"
-#include <gtk/gtkdialog.h>
+#include <gtk/gtk.h>
+#include "ui/widget/spinbutton.h"
namespace Inkscape {
namespace Extension {
@@ -75,7 +76,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar *uri)
// Page number
Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
new class Gtk::Adjustment(1, 1, _pdf_doc->getNumPages(), 1, 10, 0));
- _pageNumberSpin = Gtk::manage(new class Gtk::SpinButton(*_pageNumberSpin_adj, 1, 1));
+ _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
_labelTotalPages = Gtk::manage(new class Gtk::Label());
hbox2 = Gtk::manage(new class Gtk::HBox(false, 0));
// Disable the page selector when there's only one page
diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h
index 6bf0f11a2..c2fd0b6d8 100644
--- a/src/extension/internal/pdfinput/pdf-input.h
+++ b/src/extension/internal/pdfinput/pdf-input.h
@@ -24,7 +24,6 @@
#include <gtkmm/button.h>
#include <gtkmm/buttonbox.h>
#include <gtkmm/label.h>
-#include <gtkmm/spinbutton.h>
#include <gtkmm/box.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/comboboxtext.h>
@@ -41,6 +40,13 @@
#endif
namespace Inkscape {
+
+namespace UI {
+namespace Widget {
+ class SpinButton;
+}
+}
+
namespace Extension {
namespace Internal {
@@ -66,7 +72,7 @@ private:
class Gtk::Button * cancelbutton;
class Gtk::Button * okbutton;
class Gtk::Label * _labelSelect;
- class Gtk::SpinButton * _pageNumberSpin;
+ class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
class Gtk::Label * _labelTotalPages;
class Gtk::HBox * hbox2;
class Gtk::CheckButton * _cropCheck;
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index 94edf826e..dc995b7aa 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -531,7 +531,7 @@ void SvgBuilder::setClipPath(GfxState *state, bool even_odd) {
clip_path->appendChild(path);
Inkscape::GC::release(path);
// Append clipPath to defs and get id
- SP_DOCUMENT_DEFS(_doc)->getRepr()->appendChild(clip_path);
+ _doc->getDefs()->getRepr()->appendChild(clip_path);
gchar *urltext = g_strdup_printf ("url(#%s)", clip_path->attribute("id"));
Inkscape::GC::release(clip_path);
_container->setAttribute("clip-path", urltext);
@@ -678,7 +678,7 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern,
delete pattern_builder;
// Append the pattern to defs
- SP_DOCUMENT_DEFS(_doc)->getRepr()->appendChild(pattern_node);
+ _doc->getDefs()->getRepr()->appendChild(pattern_node);
gchar *id = g_strdup(pattern_node->attribute("id"));
Inkscape::GC::release(pattern_node);
@@ -752,7 +752,7 @@ gchar *SvgBuilder::_createGradient(GfxShading *shading, double *matrix, bool for
return NULL;
}
- Inkscape::XML::Node *defs = SP_DOCUMENT_DEFS(_doc)->getRepr();
+ Inkscape::XML::Node *defs = _doc->getDefs()->getRepr();
defs->appendChild(gradient);
gchar *id = g_strdup(gradient->attribute("id"));
Inkscape::GC::release(gradient);
@@ -1635,9 +1635,9 @@ Inkscape::XML::Node *SvgBuilder::_createMask(double width, double height) {
sp_repr_set_svg_double(mask_node, "height", height);
// Append mask to defs
if (_is_top_level) {
- SP_DOCUMENT_DEFS(_doc)->getRepr()->appendChild(mask_node);
+ _doc->getDefs()->getRepr()->appendChild(mask_node);
Inkscape::GC::release(mask_node);
- return SP_DOCUMENT_DEFS(_doc)->getRepr()->lastChild();
+ return _doc->getDefs()->getRepr()->lastChild();
} else { // Work around for renderer bug when mask isn't defined in pattern
static int mask_count = 0;
Inkscape::XML::Node *defs = _root->firstChild();
diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp
index 1563d04c1..382f8cbfb 100644
--- a/src/extension/internal/pov-out.cpp
+++ b/src/extension/internal/pov-out.cpp
@@ -35,6 +35,7 @@
#include "helper/geom.h"
#include "helper/geom-curves.h"
#include <io/sys.h>
+#include "sp-root.h"
#include <string>
#include <stdio.h>
@@ -485,7 +486,7 @@ bool PovOutput::doTree(SPDocument *doc)
miny = bignum;
maxy = -bignum;
- if (!doTreeRecursive(doc, doc->root))
+ if (!doTreeRecursive(doc, doc->getRoot()))
return false;
//## Let's make a union of all of the Shapes
diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp
index 946ff22fe..afc706e89 100644
--- a/src/extension/internal/svg.cpp
+++ b/src/extension/internal/svg.cpp
@@ -24,6 +24,7 @@
#include "extension/output.h"
#include <vector>
#include "xml/attribute-record.h"
+#include "sp-root.h"
#ifdef WITH_GNOME_VFS
# include <libgnomevfs/gnome-vfs.h>
diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp
index 70fa28967..3cd5044f7 100644
--- a/src/extension/internal/wpg-input.cpp
+++ b/src/extension/internal/wpg-input.cpp
@@ -49,9 +49,17 @@
#include "extension/input.h"
#include "document.h"
+// Take a guess and fallback to 0.1.x if no configure has run
+#if !defined(WITH_LIBWPG01) && !defined(WITH_LIBWPG02)
+#define WITH_LIBWPG01 1
+#endif
+
#include "libwpg/libwpg.h"
+#if WITH_LIBWPG01
#include "libwpg/WPGStreamImplementation.h"
-
+#elif WITH_LIBWPG02
+#include "libwpd-stream/libwpd-stream.h"
+#endif
using namespace libwpg;
@@ -62,9 +70,17 @@ namespace Internal {
SPDocument *
WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) {
+#if WITH_LIBWPG01
WPXInputStream* input = new libwpg::WPGFileStream(uri);
+#elif WITH_LIBWPG02
+ WPXInputStream* input = new WPXFileStream(uri);
+#endif
if (input->isOLEStream()) {
+#if WITH_LIBWPG01
WPXInputStream* olestream = input->getDocumentOLEStream();
+#elif WITH_LIBWPG02
+ WPXInputStream* olestream = input->getDocumentOLEStream("PerfectOffice_MAIN");
+#endif
if (olestream) {
delete input;
input = olestream;
@@ -79,7 +95,11 @@ WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) {
return NULL;
}
+#if WITH_LIBWPG01
libwpg::WPGString output;
+#elif WITH_LIBWPG02
+ WPXString output;
+#endif
if (!libwpg::WPGraphics::generateSVG(input, output)) {
delete input;
return NULL;