From 7ac120f629403ac38ed209986dd4c256a52ef890 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 28 Mar 2010 22:17:31 +0200 Subject: Allow Inkscape to run from Unicode directories on Windows Fixed bugs: - https://launchpad.net/bugs/505107 (bzr r9248) --- src/extension/implementation/script.cpp | 251 +++++++++++--------------------- src/extension/implementation/script.h | 24 +-- 2 files changed, 92 insertions(+), 183 deletions(-) (limited to 'src/extension') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 60623191f..256996663 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -21,6 +21,8 @@ #include #include +#include +#include #include #include "ui/view/view.h" @@ -101,14 +103,12 @@ Script::interpreter_t const Script::interpreterTab[] = { \param interpNameArg The name of the interpreter that we're looking for, should be an entry in interpreterTab */ -Glib::ustring Script::resolveInterpreterExecutable(const Glib::ustring &interpNameArg) +std::string Script::resolveInterpreterExecutable(const Glib::ustring &interpNameArg) { - Glib::ustring interpName = interpNameArg; - interpreter_t const *interp = 0; bool foundInterp = false; for (interp = interpreterTab ; interp->identity ; interp++ ){ - if (interpName == interp->identity) { + if (interpNameArg == interp->identity) { foundInterp = true; break; } @@ -118,55 +118,26 @@ Glib::ustring Script::resolveInterpreterExecutable(const Glib::ustring &interpNa if (!foundInterp) { return ""; } - interpName = interp->defaultval; + std::string interpreter_path = Glib::filename_from_utf8(interp->defaultval); - // 1. Check preferences + // 1. Check preferences for an override. + // Note: this must be an absolute path. Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring prefInterp = prefs->getString("/extensions/" + Glib::ustring(interp->prefstring)); if (!prefInterp.empty()) { - interpName = prefInterp; - return interpName; - } - -#ifdef WIN32 - - // 2. Windows. Try looking relative to inkscape.exe - RegistryTool rt; - Glib::ustring fullPath; - Glib::ustring path; - Glib::ustring exeName; - if (rt.getExeInfo(fullPath, path, exeName)) { -// TODO replace with proper glib/glibmm path building routines: - Glib::ustring interpPath = path; - interpPath.append("\\"); - interpPath.append(interpNameArg); - interpPath.append("\\"); - interpPath.append(interpName); - interpPath.append(".exe"); - struct stat finfo; - if (stat(interpPath .c_str(), &finfo) == 0) { - g_message("Found local interpreter, '%s', Size: %d", - interpPath .c_str(), - (int)finfo.st_size); - return interpPath; - } + interpreter_path = Glib::filename_from_utf8(prefInterp); } - // 3. Try searching the path - char szExePath[MAX_PATH] = {0}; - char szCurrentDir[MAX_PATH] = {0}; - GetCurrentDirectory(sizeof(szCurrentDir), szCurrentDir); - HINSTANCE ret = FindExecutable(interpName.c_str(), szCurrentDir, szExePath); - if (ret > reinterpret_cast(32)) { - interpName = szExePath; - return interpName; + // 2. Search the path. + // Do this on all systems, for consistency. + // PATH is set up to contain the Python and Perl binary directories + // on Windows, so no extra code is necessary. + if (!Glib::path_is_absolute(interpreter_path)) { + interpreter_path = Glib::find_program_in_path(interpreter_path); } - -#endif // win32 - - - return interpName; + printf("Interpreter name: %s\n", interpreter_path.data()); + return interpreter_path; } /** \brief This function creates a script object and sets up the @@ -206,38 +177,33 @@ Script::~Script() string. This means that the caller of this function can always free what they are given (and should do it too!). */ -Glib::ustring +std::string Script::solve_reldir(Inkscape::XML::Node *reprin) { gchar const *s = reprin->attribute("reldir"); - if (!s) { + // right now the only recognized relative directory is "extensions" + if (!s || Glib::ustring(s) != "extensions") { Glib::ustring str = sp_repr_children(reprin)->content(); return str; } Glib::ustring reldir = s; - if (reldir == "extensions") { - - for (unsigned int i=0; - i < Inkscape::Extension::Extension::search_path.size(); - i++) { + for (unsigned int i=0; + i < Inkscape::Extension::Extension::search_path.size(); + i++) { - gchar * fname = g_build_filename( - Inkscape::Extension::Extension::search_path[i], - sp_repr_children(reprin)->content(), - NULL); - Glib::ustring filename = fname; - g_free(fname); + gchar * fname = g_build_filename( + Inkscape::Extension::Extension::search_path[i], + sp_repr_children(reprin)->content(), + NULL); + Glib::ustring filename = fname; + g_free(fname); - if ( Inkscape::IO::file_test(filename.c_str(), G_FILE_TEST_EXISTS) ) { - return filename; - } + if ( Inkscape::IO::file_test(filename.c_str(), G_FILE_TEST_EXISTS) ) { + return Glib::filename_from_utf8(filename); } - } else { - Glib::ustring str = sp_repr_children(reprin)->content(); - return str; } return ""; @@ -261,29 +227,25 @@ Script::solve_reldir(Inkscape::XML::Node *reprin) { then a TRUE is returned. If we get all the way through the path then a FALSE is returned, the command could not be found. */ -bool Script::check_existance(const Glib::ustring &command) +bool Script::check_existence(const std::string &command) { // Check the simple case first - if (command.size() == 0) { + if (command.empty()) { return false; } - //Don't search when it contains a slash. */ - if (command.find(G_DIR_SEPARATOR) != command.npos) { - if (Inkscape::IO::file_test(command.c_str(), G_FILE_TEST_EXISTS)) { + //Don't search when it is an absolute path. */ + if (!Glib::path_is_absolute(command)) { + if (Glib::file_test(command, Glib::FILE_TEST_EXISTS)) { return true; } else { return false; } } - - Glib::ustring path; - gchar *s = (gchar *) g_getenv("PATH"); - if (s) { - path = s; - } else { + std::string path = Glib::getenv("PATH"); + if (path.empty()) { /* There is no `PATH' in the environment. The default search path is the current directory */ path = G_SEARCHPATH_SEPARATOR_S; @@ -293,7 +255,7 @@ bool Script::check_existance(const Glib::ustring &command) std::string::size_type pos2 = 0; while ( pos < path.size() ) { - Glib::ustring localPath; + std::string localPath; pos2 = path.find(G_SEARCHPATH_SEPARATOR, pos); if (pos2 == path.npos) { @@ -305,11 +267,11 @@ bool Script::check_existance(const Glib::ustring &command) } //printf("### %s\n", localPath.c_str()); - Glib::ustring candidatePath = + std::string candidatePath = Glib::build_filename(localPath, command); - if (Inkscape::IO::file_test(candidatePath .c_str(), - G_FILE_TEST_EXISTS)) { + if (Glib::file_test(candidatePath, + Glib::FILE_TEST_EXISTS)) { return true; } @@ -357,16 +319,10 @@ bool Script::load(Inkscape::Extension::Extension *module) if (!strcmp(child_repr->name(), INKSCAPE_EXTENSION_NS "command")) { const gchar *interpretstr = child_repr->attribute("interpreter"); if (interpretstr != NULL) { - Glib::ustring interpString = - resolveInterpreterExecutable(interpretstr); - //g_message("Found: %s and %s",interpString.c_str(),interpretstr); - command.insert(command.end(), interpretstr); + std::string interpString = resolveInterpreterExecutable(interpretstr); + command.insert(command.end(), interpString); } - Glib::ustring tmp = "\""; - tmp += solve_reldir(child_repr); - tmp += "\""; - - command.insert(command.end(), tmp); + command.insert(command.end(), solve_reldir(child_repr)); } if (!strcmp(child_repr->name(), INKSCAPE_EXTENSION_NS "helper_extension")) { helper_extension = sp_repr_children(child_repr)->content(); @@ -419,10 +375,10 @@ Script::check(Inkscape::Extension::Extension *module) child_repr = sp_repr_children(child_repr); while (child_repr != NULL) { if (!strcmp(child_repr->name(), INKSCAPE_EXTENSION_NS "check")) { - Glib::ustring command_text = solve_reldir(child_repr); - if (command_text.size() > 0) { + std::string command_text = solve_reldir(child_repr); + if (!command_text.empty()) { /* I've got the command */ - bool existance = check_existance(command_text); + bool existance = check_existence(command_text); if (!existance) return false; } @@ -763,8 +719,7 @@ void Script::effect(Inkscape::Extension::Effect *module, // make sure we don't leak file descriptors from g_file_open_tmp close(tempfd_out); - // FIXME: convert to utf8 (from "filename encoding") and unlink_utf8name - unlink(tempfilename_out.c_str()); + g_unlink(tempfilename_out.c_str()); /* Do something with mydoc.... */ if (mydoc) { @@ -937,89 +892,61 @@ int Script::execute (const std::list &in_command, const Glib::ustring &filein, file_listener &fileout) { - g_return_val_if_fail(in_command.size() > 0, 0); + g_return_val_if_fail(!in_command.empty(), 0); // printf("Executing\n"); - std::vector argv; - -/* - for (std::list::const_iterator i = in_command.begin(); - i != in_command.end(); i++) { - argv.push_back(*i); - } -*/ - // according to http://www.gtk.org/api/2.6/glib/glib-Spawning-Processes.html spawn quotes parameter containing spaces - // we tokenize so that spwan does not need to quote over all params - for (std::list::const_iterator i = in_command.begin(); - i != in_command.end(); i++) { - std::string param_str = *i; - do { - //g_message("param: %s", param_str.c_str()); - size_t first_space = param_str.find_first_of(' '); - size_t first_quote = param_str.find_first_of('"'); - //std::cout << "first space " << first_space << std::endl; - //std::cout << "first quote " << first_quote << std::endl; - - if ((first_quote != std::string::npos) && (first_quote == 0)) { - size_t next_quote = param_str.find_first_of('"', first_quote + 1); - //std::cout << "next quote " << next_quote << std::endl; - - if (next_quote != std::string::npos) { - //std::cout << "now split " << next_quote << std::endl; - //std::cout << "now split " << param_str.substr(1, next_quote - 1) << std::endl; - //std::cout << "now split " << param_str.substr(next_quote + 1) << std::endl; - std::string part_str = param_str.substr(1, next_quote - 1); - if (part_str.size() > 0) - argv.push_back(part_str); - param_str = param_str.substr(next_quote + 1); - - } else { - if (param_str.size() > 0) - argv.push_back(param_str); - param_str = ""; - } - - } else if (first_space != std::string::npos) { - //std::cout << "now split " << first_space << std::endl; - //std::cout << "now split " << param_str.substr(0, first_space) << std::endl; - //std::cout << "now split " << param_str.substr(first_space + 1) << std::endl; - std::string part_str = param_str.substr(0, first_space); - if (part_str.size() > 0) { - argv.push_back(part_str); - } - param_str = param_str.substr(first_space + 1); - } else { - if (param_str.size() > 0) { - argv.push_back(param_str); - } - param_str = ""; - } - } while (param_str.size() > 0); - } - - for (std::list::const_iterator i = in_params.begin(); - i != in_params.end(); i++) { - //g_message("Script parameter: %s",(*i)g.c_str()); - argv.push_back(*i); - } - - if (!(filein.empty())) { + std::vector argv; + + bool interpreted = (in_command.size() == 2); + std::string program = in_command.front(); + std::string script = interpreted ? in_command.back() : ""; + std::string working_directory = ""; + + // Use Glib::find_program_in_path instead of the equivalent + // Glib::spawn_* functionality, because _wspawnp is broken on Windows: + // it doesn't work when PATH contains Unicode directories + if (!Glib::path_is_absolute(program)) { + program = Glib::find_program_in_path(program); + } + argv.push_back(program); + + if (interpreted) { + // On Windows, Python garbles Unicode command line parameters + // in an useless way. This means extensions fail when Inkscape + // is run from an Unicode directory. + // As a workaround, we set the working directory to the one + // containing the script. + working_directory = Glib::path_get_dirname(script); + script = Glib::path_get_basename(script); + #ifdef G_OS_WIN32 + // ANNOYING: glibmm does not wrap g_win32_locale_filename_from_utf8 + gchar *workdir_s = g_win32_locale_filename_from_utf8(working_directory.data()); + working_directory = workdir_s; + g_free(workdir_s); + #endif + + argv.push_back(script); + } + + // assemble the rest of argv + std::copy(in_params.begin(), in_params.end(), std::back_inserter(argv)); + if (!filein.empty()) { argv.push_back(filein); } int stdout_pipe, stderr_pipe; try { - Inkscape::IO::spawn_async_with_pipes(Glib::get_current_dir(), // working directory + Glib::spawn_async_with_pipes(working_directory, // working directory argv, // arg v - Glib::SPAWN_SEARCH_PATH /*| Glib::SPAWN_DO_NOT_REAP_CHILD*/, + static_cast(0), // no flags sigc::slot(), &_pid, // Pid NULL, // STDIN &stdout_pipe, // STDOUT &stderr_pipe); // STDERR - } catch (Glib::SpawnError e) { - printf("Can't Spawn!!! spawn returns: %d\n", e.code()); + } catch (Glib::Error e) { + printf("Can't Spawn!!! spawn returns: %s\n", e.what().data()); return 0; } diff --git a/src/extension/implementation/script.h b/src/extension/implementation/script.h index e0b6701bf..f37f27966 100644 --- a/src/extension/implementation/script.h +++ b/src/extension/implementation/script.h @@ -115,31 +115,14 @@ private: */ Glib::ustring helper_extension; - /** - * Just a quick function to find and resolve relative paths for - * the incoming scripts - */ - Glib::ustring solve_reldir (Inkscape::XML::Node *reprin); - - /** - * - */ - bool check_existance (const Glib::ustring &command); - - /** - * - */ + std::string solve_reldir (Inkscape::XML::Node *reprin); + bool check_existence (const std::string &command); void copy_doc (Inkscape::XML::Node * olddoc, Inkscape::XML::Node * newdoc); - - /** - * - */ void checkStderr (const Glib::ustring &filename, Gtk::MessageType type, const Glib::ustring &message); - class file_listener { Glib::ustring _string; sigc::connection _conn; @@ -184,7 +167,6 @@ private: return true; }; - // Note, doing a copy here, on purpose Glib::ustring string (void) { return _string; }; bool toFile (const Glib::ustring &name) { @@ -215,7 +197,7 @@ private: }; static interpreter_t const interpreterTab[]; - Glib::ustring resolveInterpreterExecutable(const Glib::ustring &interpNameArg); + std::string resolveInterpreterExecutable(const Glib::ustring &interpNameArg); }; // class Script -- cgit v1.2.3 From 45b0106614f265c2b5c8e2d0925f4047837583d2 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 28 Mar 2010 22:22:11 +0200 Subject: Remove leftover debug output (bzr r9249) --- src/extension/implementation/script.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/extension') diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 256996663..53a666e25 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -136,7 +136,6 @@ std::string Script::resolveInterpreterExecutable(const Glib::ustring &interpName if (!Glib::path_is_absolute(interpreter_path)) { interpreter_path = Glib::find_program_in_path(interpreter_path); } - printf("Interpreter name: %s\n", interpreter_path.data()); return interpreter_path; } -- cgit v1.2.3 From dbac090dfa98747f78504a20113df43fa9a78fc2 Mon Sep 17 00:00:00 2001 From: Josh Andler Date: Thu, 1 Apr 2010 01:14:55 -0700 Subject: Patch by Daniel_J for 522327 (bzr r9267) --- src/extension/internal/filter/filter-file.cpp | 2 +- src/extension/internal/filter/filter.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp index 7cb671f51..89afca133 100644 --- a/src/extension/internal/filter/filter-file.cpp +++ b/src/extension/internal/filter/filter-file.cpp @@ -161,7 +161,7 @@ Filter::filters_load_node (Inkscape::XML::Node * node, gchar * menuname) mywriter writer; sp_repr_write_stream(node, writer, 0, FALSE, g_quark_from_static_string("svg"), 0, 0); - Inkscape::Extension::build_from_mem(xml_str, new Filter::Filter(g_strdup(writer.c_str()))); + Inkscape::Extension::build_from_mem(xml_str, new Filter(g_strdup(writer.c_str()))); g_free(xml_str); return; } diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index 30e622507..c2d80b28b 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -219,7 +219,7 @@ Filter::filter_init (gchar const * id, gchar const * name, gchar const * submenu "%s\n" "\n" "\n", name, id, submenu, tip); - Inkscape::Extension::build_from_mem(xml_str, new Filter::Filter(filter)); + Inkscape::Extension::build_from_mem(xml_str, new Filter(filter)); g_free(xml_str); return; } -- cgit v1.2.3 From d037400fcf3fba455e092ed6c1e34163eb6c7b7f Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 3 Apr 2010 18:50:12 +0200 Subject: Fix grid extension (bzr r9281.1.10) --- src/extension/internal/grid.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index d4b35b261..deef367a4 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -46,13 +46,12 @@ Grid::load (Inkscape::Extension::Extension */*module*/) namespace { -Glib::ustring build_lines(int axis, Geom::Rect bounding_area, - float offset, float spacing) +void build_lines(int axis, Geom::Rect bounding_area, float offset, + float spacing, SVG::PathString &path_data) { Geom::Point point_offset(0.0, 0.0); point_offset[axis] = offset; - SVG::PathString path_data; for (Geom::Point start_point = bounding_area.min(); start_point[axis] + offset <= (bounding_area.max())[axis]; start_point[axis] += spacing) { @@ -62,8 +61,6 @@ Glib::ustring build_lines(int axis, Geom::Rect bounding_area, path_data.moveTo(start_point + point_offset) .lineTo(end_point + point_offset); } - - return path_data; } } @@ -89,10 +86,8 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc if (bounds) { bounding_area = *bounds; } - - gdouble doc_height = sp_document_height(document->doc()); - Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]), - Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y])); + Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], bounding_area.min()[Geom::Y]), + Geom::Point(bounding_area.max()[Geom::X], bounding_area.max()[Geom::Y])); bounding_area = temprec; } @@ -103,10 +98,9 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc float offsets[2] = { module->get_param_float("xoffset"), module->get_param_float("yoffset") }; - Glib::ustring path_data(""); + SVG::PathString path_data; for ( int axis = 0 ; axis < 2 ; ++axis ) { - path_data += build_lines(axis, bounding_area, - offsets[axis], spacings[axis]); + build_lines(axis, bounding_area, offsets[axis], spacings[axis], path_data); } Inkscape::XML::Document * xml_doc = sp_document_repr_doc(document->doc()); -- cgit v1.2.3 From 62342e4e8ab205fed32748197f926595071743cc Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 4 Apr 2010 00:00:17 +0200 Subject: remove debug text from cairo-render-context.cpp (bzr r9289) --- src/extension/internal/cairo-render-context.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 877bdb952..cf3c72432 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -80,7 +80,8 @@ #include //#define TRACE(_args) g_printf _args -#define TRACE(_args) g_message _args +//#define TRACE(_args) g_message _args +#define TRACE(_args) //#define TEST(_args) _args #define TEST(_args) @@ -819,7 +820,6 @@ CairoRenderContext::setSurfaceTarget(cairo_surface_t *surface, bool is_vector, c bool CairoRenderContext::_finishSurfaceSetup(cairo_surface_t *surface, cairo_matrix_t *ctm) { -g_message("enter"); if(surface == NULL) { return false; } @@ -846,7 +846,7 @@ g_message("enter"); } _is_valid = TRUE; -g_message("leave"); + return true; } -- cgit v1.2.3 From 2b115a6b3457a06498167e978a2fdf47f5f2655c Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 4 Apr 2010 00:19:13 +0200 Subject: Fix --export-page-drawing option in PDF, PS and LaTeX export. (bzr r9290) --- src/extension/internal/cairo-renderer.cpp | 6 +----- src/extension/internal/latex-text-renderer.cpp | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 6e4bb3b7e..52f070591 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -631,12 +631,8 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page if (ret && !pageBoundingBox) { - double high = sp_document_height(doc); - if (ctx->_vector_based_target) - high *= PT_PER_PX; - Geom::Matrix tp(Geom::Translate(-d.x0 * (ctx->_vector_based_target ? PX_PER_PT : 1.0), - (d.y1 - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0))); + -d.y0 * (ctx->_vector_based_target ? PX_PER_PT : 1.0))); ctx->transform(&tp); } diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 28bba1beb..1fdf1d7fd 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -501,7 +501,8 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * if (!pageBoundingBox) { - push_transform( Geom::Translate( - d->min() ) ); + Geom::Translate t(-d->min()[Geom::X], d->max()[Geom::Y] - sp_document_height(doc)); + push_transform( t ); } // flip y-axis -- cgit v1.2.3 From 95a0c8412e84f5e0cc1d9a63fce2be75f9fa517e Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 6 Apr 2010 16:11:54 +0200 Subject: Revert the inverted coordinate system fix. 3D Boxes and guides require an XML-level backwards compatibility mechanism to fix properly, and it's too late in the 0.48 cycle to introduce it. (bzr r9298) --- src/extension/internal/cairo-renderer.cpp | 6 +++++- src/extension/internal/grid.cpp | 18 ++++++++++++------ src/extension/internal/latex-text-renderer.cpp | 3 +-- 3 files changed, 18 insertions(+), 9 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 52f070591..6e4bb3b7e 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -631,8 +631,12 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page if (ret && !pageBoundingBox) { + double high = sp_document_height(doc); + if (ctx->_vector_based_target) + high *= PT_PER_PX; + Geom::Matrix tp(Geom::Translate(-d.x0 * (ctx->_vector_based_target ? PX_PER_PT : 1.0), - -d.y0 * (ctx->_vector_based_target ? PX_PER_PT : 1.0))); + (d.y1 - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0))); ctx->transform(&tp); } diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index deef367a4..d4b35b261 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -46,12 +46,13 @@ Grid::load (Inkscape::Extension::Extension */*module*/) namespace { -void build_lines(int axis, Geom::Rect bounding_area, float offset, - float spacing, SVG::PathString &path_data) +Glib::ustring build_lines(int axis, Geom::Rect bounding_area, + float offset, float spacing) { Geom::Point point_offset(0.0, 0.0); point_offset[axis] = offset; + SVG::PathString path_data; for (Geom::Point start_point = bounding_area.min(); start_point[axis] + offset <= (bounding_area.max())[axis]; start_point[axis] += spacing) { @@ -61,6 +62,8 @@ void build_lines(int axis, Geom::Rect bounding_area, float offset, path_data.moveTo(start_point + point_offset) .lineTo(end_point + point_offset); } + + return path_data; } } @@ -86,8 +89,10 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc if (bounds) { bounding_area = *bounds; } - Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], bounding_area.min()[Geom::Y]), - Geom::Point(bounding_area.max()[Geom::X], bounding_area.max()[Geom::Y])); + + gdouble doc_height = sp_document_height(document->doc()); + Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]), + Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y])); bounding_area = temprec; } @@ -98,9 +103,10 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc float offsets[2] = { module->get_param_float("xoffset"), module->get_param_float("yoffset") }; - SVG::PathString path_data; + Glib::ustring path_data(""); for ( int axis = 0 ; axis < 2 ; ++axis ) { - build_lines(axis, bounding_area, offsets[axis], spacings[axis], path_data); + path_data += build_lines(axis, bounding_area, + offsets[axis], spacings[axis]); } Inkscape::XML::Document * xml_doc = sp_document_repr_doc(document->doc()); diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 1fdf1d7fd..28bba1beb 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -501,8 +501,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * if (!pageBoundingBox) { - Geom::Translate t(-d->min()[Geom::X], d->max()[Geom::Y] - sp_document_height(doc)); - push_transform( t ); + push_transform( Geom::Translate( - d->min() ) ); } // flip y-axis -- cgit v1.2.3 From 7557c867cfcd841cf46935e7bf7fbee53709c150 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 8 Apr 2010 23:05:52 +0200 Subject: PDF+LaTeX: fix bug 555488, and fix bug with missing space after setting justification Fixed bugs: - https://launchpad.net/bugs/555488 (bzr r9301) --- src/extension/internal/latex-text-renderer.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 28bba1beb..c6c597b7a 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -350,13 +350,13 @@ Flowing in rectangle is possible, not in arb shape. g_free(strtext); g_strfreev(splitstr); - if (!flowtext->has_internal_frame()) { - // has_internal_frame includes a check that frame is a SPRect + 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."); return; // don't know how to handle non-rect frames yet. is quite uncommon for latex users i think } - SPRect *frame = SP_RECT(flowtext->get_frame(NULL)); + SPRect *frame = SP_RECT(frame_item); Geom::Rect framebox = sp_rect_get_rect(frame) * transform(); // get position and alignment @@ -365,13 +365,13 @@ Flowing in rectangle is possible, not in arb shape. gchar const *justification = ""; switch (flowtext->layout.paragraphAlignment(flowtext->layout.begin())) { case Inkscape::Text::Layout::LEFT: - justification = "\\raggedright"; + justification = "\\raggedright "; break; case Inkscape::Text::Layout::RIGHT: - justification = "\\raggedleft"; + justification = "\\raggedleft "; break; case Inkscape::Text::Layout::CENTER: - justification = "\\centering"; + justification = "\\centering "; case Inkscape::Text::Layout::FULL: default: // no need to add LaTeX code for standard justified output :) -- cgit v1.2.3 From 98c1f52afb5011477a9ad164ede006414e0e32af Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 10 Apr 2010 14:51:38 +0200 Subject: fix bug 168275 by removing a ceil on document height and width in pdf/eps/ps exporter. Fixed bugs: - https://launchpad.net/bugs/168275 (bzr r9306) --- src/extension/internal/cairo-renderer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 6e4bb3b7e..ebdb82a69 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -608,8 +608,8 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page NRRect d; if (pageBoundingBox) { d.x0 = d.y0 = 0; - d.x1 = ceil(sp_document_width(doc)); - d.y1 = ceil(sp_document_height(doc)); + d.x1 = sp_document_width(doc); + d.y1 = sp_document_height(doc); } else { sp_item_invoke_bbox(base, &d, sp_item_i2d_affine(base), TRUE, SPItem::RENDERING_BBOX); } -- cgit v1.2.3 From e2fe2f42f1e688936eec062e45785cc0c8fc035f Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 14 Apr 2010 19:30:26 +0200 Subject: Fix for ImageMagick solarize extension. Fixed bugs: - https://launchpad.net/bugs/362271 (bzr r9329) --- src/extension/internal/bitmap/solarize.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/extension') diff --git a/src/extension/internal/bitmap/solarize.cpp b/src/extension/internal/bitmap/solarize.cpp index 147c4f0b5..ea9ec42f3 100644 --- a/src/extension/internal/bitmap/solarize.cpp +++ b/src/extension/internal/bitmap/solarize.cpp @@ -18,7 +18,9 @@ namespace Bitmap { void Solarize::applyEffect(Magick::Image* image) { - image->solarize(_factor); + // Image Magick Quantum depth = 16 + // 655.35 = (2^16 - 1) / 100 + image->solarize(_factor * 655.35); } void -- cgit v1.2.3 From d48d6579e86f42fbd376dfe94ef36adae19d1154 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 19 Apr 2010 21:37:04 +0200 Subject: Extensions. JavaFX output fix by ycswyw. Fixed bugs: - https://launchpad.net/bugs/439270 (bzr r9355) --- src/extension/internal/javafx-out.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/extension') diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index ca061a63a..a4d348940 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -791,7 +791,8 @@ bool JavaFXOutput::doBody(SPDocument *doc, SPObject *obj) SPShape *shape = SP_SHAPE(item); SPCurve *curve = shape->curve; if (!curve->is_empty()) { - out(" %s(),\n", id.c_str()); + String jfxid = sanatize(id); + out(" %s(),\n", jfxid.c_str()); } } } -- cgit v1.2.3 From 74bd4815d7af73ed1595e3daf5c6fd40ea20336c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 21 Apr 2010 23:40:54 +0200 Subject: Extensions. Fix Render>Grid extension (Bug #401567). Fixed bugs: - https://launchpad.net/bugs/401567 (bzr r9361) --- src/extension/internal/grid.cpp | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'src/extension') diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index d4b35b261..39bca52d8 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -46,25 +46,29 @@ Grid::load (Inkscape::Extension::Extension */*module*/) namespace { -Glib::ustring build_lines(int axis, Geom::Rect bounding_area, - float offset, float spacing) +Glib::ustring build_lines(Geom::Rect bounding_area, + float offset[], float spacing[]) { Geom::Point point_offset(0.0, 0.0); - point_offset[axis] = offset; SVG::PathString path_data; - for (Geom::Point start_point = bounding_area.min(); - start_point[axis] + offset <= (bounding_area.max())[axis]; - start_point[axis] += spacing) { - Geom::Point end_point = start_point; - end_point[1-axis] = (bounding_area.max())[1-axis]; - - path_data.moveTo(start_point + point_offset) - .lineTo(end_point + point_offset); - } - return path_data; -} + for ( int axis = 0 ; axis < 2 ; ++axis ) { + point_offset[axis] = offset[axis]; + + for (Geom::Point start_point = bounding_area.min(); + start_point[axis] + offset[axis] <= (bounding_area.max())[axis]; + start_point[axis] += spacing[axis]) { + Geom::Point end_point = start_point; + end_point[1-axis] = (bounding_area.max())[1-axis]; + + path_data.moveTo(start_point + point_offset) + .lineTo(end_point + point_offset); + } + } + // std::cout << "Path data:" << path_data.c_str() << std::endl; + return path_data; + } } @@ -104,11 +108,9 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc module->get_param_float("yoffset") }; Glib::ustring path_data(""); - for ( int axis = 0 ; axis < 2 ; ++axis ) { - path_data += build_lines(axis, bounding_area, - offsets[axis], spacings[axis]); - } + path_data = build_lines(bounding_area, + offsets, spacings); Inkscape::XML::Document * xml_doc = sp_document_repr_doc(document->doc()); Inkscape::XML::Node * current_layer = static_cast(document)->currentLayer()->repr; Inkscape::XML::Node * path = xml_doc->createElement("svg:path"); -- cgit v1.2.3