From 361ff9f55ac6accbeb5016d680db735f0d888a9e Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 24 Apr 2019 13:14:19 +0200 Subject: Fix center alignment errors in flowed text due to white space between elements inside a element. Alternative fix to that proposed by samuel. --- src/xml/repr-io.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index f6552a5f9..7b76a3086 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -983,7 +983,8 @@ void sp_repr_write_stream_element( Node * repr, Writer & out, // If this is a element, suppress formatting whitespace // for its content and children: - if (strcmp(repr->name(),"svg:text") == 0) { + if (strcmp(repr->name(), "svg:text") == 0 || + strcmp(repr->name(), "svg:flowRoot") == 0) { add_whitespace = false; } -- cgit v1.2.3 From e831b034746f8dc3c3c1b88372751f6dcb974831 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Wed, 24 Apr 2019 14:11:26 +0200 Subject: Tentative fix for poppler 0.76 --- src/extension/internal/pdfinput/pdf-parser.cpp | 2 +- src/extension/internal/pdfinput/poppler-transition-api.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp index 8484984bd..4f798e35b 100644 --- a/src/extension/internal/pdfinput/pdf-parser.cpp +++ b/src/extension/internal/pdfinput/pdf-parser.cpp @@ -421,7 +421,7 @@ void PdfParser::parse(Object *obj, GBool topLevel) { error(errInternal, -1, "Weird page contents"); return; } - parser = new Parser(xref, new Lexer(xref, obj), gFalse); + parser = new _POPPLER_NEW_PARSER(xref, obj); go(topLevel); delete parser; parser = nullptr; diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h index 61a15083a..5e8bc4ae9 100644 --- a/src/extension/internal/pdfinput/poppler-transition-api.h +++ b/src/extension/internal/pdfinput/poppler-transition-api.h @@ -14,6 +14,13 @@ #include +#if POPPLER_CHECK_VERSION(0, 76, 0) +#define _POPPLER_NEW_PARSER(xref, obj) Parser(xref, obj, gFalse) +#else +#define _POPPLER_NEW_PARSER(xref, obj) Parser(xref, new Lexer(xref, obj), gFalse) +#endif + + #if POPPLER_CHECK_VERSION(0, 72, 0) #define getCString c_str #endif -- cgit v1.2.3 From 124f550235d24b6313929cc9bbb5cbcca356104c Mon Sep 17 00:00:00 2001 From: Nathan Lee <2431820-nathanal@users.noreply.gitlab.com> Date: Sat, 20 Apr 2019 00:16:51 +1000 Subject: Keep Document Grid spacing on change and save Reverts behaviour back to Feb 2019. setDigits calls on_value_changed(), leading to 0 value being set when wr.isUpdating() is false. The grid widget is re-created on save, if closed. Fix https://gitlab.com/inkscape/inbox/issues/387 --- src/display/canvas-axonomgrid.cpp | 18 +++++++++--------- src/display/canvas-grid.cpp | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 2e4a20d6a..6bfa317b3 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -288,15 +288,6 @@ CanvasAxonomGrid::newSpecificWidget() _rsi = Gtk::manage( new Inkscape::UI::Widget::RegisteredSuffixedInteger( _("_Major grid line every:"), "", _("lines"), "empspacing", _wr, repr, doc ) ); - _rsu_ox->setDigits(5); - _rsu_ox->setIncrements(0.1, 1.0); - - _rsu_oy->setDigits(5); - _rsu_oy->setIncrements(0.1, 1.0); - - _rsu_sy->setDigits(5); - _rsu_sy->setIncrements(0.1, 1.0); - _rumg->set_hexpand(); _rsu_ox->set_hexpand(); _rsu_oy->set_hexpand(); @@ -310,6 +301,15 @@ CanvasAxonomGrid::newSpecificWidget() // set widget values _wr.setUpdating (true); + _rsu_ox->setDigits(5); + _rsu_ox->setIncrements(0.1, 1.0); + + _rsu_oy->setDigits(5); + _rsu_oy->setIncrements(0.1, 1.0); + + _rsu_sy->setDigits(5); + _rsu_sy->setIncrements(0.1, 1.0); + _rumg->setUnit (gridunit->abbr); gdouble val; diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index f4a210fe6..b8569d539 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -680,18 +680,6 @@ CanvasXYGrid::newSpecificWidget() _rsi = Gtk::manage( new Inkscape::UI::Widget::RegisteredSuffixedInteger( _("_Major grid line every:"), "", _("lines"), "empspacing", _wr, repr, doc) ); - _rsu_ox->setDigits(5); - _rsu_ox->setIncrements(0.1, 1.0); - - _rsu_oy->setDigits(5); - _rsu_oy->setIncrements(0.1, 1.0); - - _rsu_sx->setDigits(5); - _rsu_sx->setIncrements(0.1, 1.0); - - _rsu_sy->setDigits(5); - _rsu_sy->setIncrements(0.1, 1.0); - _rumg->set_hexpand(); _rsu_ox->set_hexpand(); _rsu_oy->set_hexpand(); @@ -704,6 +692,18 @@ CanvasXYGrid::newSpecificWidget() // set widget values _wr.setUpdating (true); + _rsu_ox->setDigits(5); + _rsu_ox->setIncrements(0.1, 1.0); + + _rsu_oy->setDigits(5); + _rsu_oy->setIncrements(0.1, 1.0); + + _rsu_sx->setDigits(5); + _rsu_sx->setIncrements(0.1, 1.0); + + _rsu_sy->setDigits(5); + _rsu_sy->setIncrements(0.1, 1.0); + _rumg->setUnit (gridunit->abbr); gdouble val; -- cgit v1.2.3 From 1633a91c3a1fd6eb4d981d9117c7a4ba96d1f562 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sat, 20 Apr 2019 00:16:59 +0200 Subject: Removes style on empty lines --- src/document.cpp | 5 +++++ src/file-update.cpp | 20 ++++++++++++++++++++ src/file.h | 1 + 3 files changed, 26 insertions(+) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 680e98f6a..96dce8d2c 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -450,6 +450,11 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, sp_file_convert_font_name(document); } + /** Fix first line spacing in legacy documents (pre-1.0 files) **/ + if ( sp_version_inside_range( document->root->version.inkscape, 0, 1, 1, 0 ) ) { + sp_file_remove_style_on_empty_lines(document); + } + /** Fix dpi (pre-92 files). With GUI fixed in Inkscape::Application::fix_document. **/ if ( !(INKSCAPE.use_gui()) && sp_version_inside_range( document->root->version.inkscape, 0, 1, 0, 92 ) ) { sp_file_convert_dpi(document); diff --git a/src/file-update.cpp b/src/file-update.cpp index 5489ee499..de2f17ad6 100644 --- a/src/file-update.cpp +++ b/src/file-update.cpp @@ -205,6 +205,26 @@ void sp_file_convert_text_baseline_spacing(SPDocument *doc) sp_file_text_run_recursive(fix_update, doc->getRoot()); } +void _remove_style_on_empty_lines(SPObject *o) +{ + std::vector cl = o->childList(false); + for (std::vector::const_iterator ci = cl.begin(); ci != cl.end(); ++ci) { + if (SP_IS_TSPAN(*ci) and (*ci)->childList(false).empty() and (*ci)->getAttribute("sodipodi:role")=="line" ) { + (*ci)->style->clear(); + } + } +} + + + +void sp_file_remove_style_on_empty_lines(SPDocument *doc) +{ + sp_file_text_run_recursive(_remove_style_on_empty_lines, doc->getRoot()); + sp_file_text_run_recursive(fix_update, doc->getRoot()); +} + + + void sp_file_convert_font_name(SPDocument *doc) { sp_file_text_run_recursive(fix_font_name, doc->getRoot()); diff --git a/src/file.h b/src/file.h index fc0925b78..5feb81a0c 100644 --- a/src/file.h +++ b/src/file.h @@ -196,6 +196,7 @@ void sp_file_vacuum (SPDocument *doc); void sp_file_convert_text_baseline_spacing(SPDocument *doc); void sp_file_convert_font_name(SPDocument *doc); void sp_file_convert_dpi(SPDocument *doc); +void sp_file_remove_style_on_empty_lines(SPDocument *doc); enum File_DPI_Fix { FILE_DPI_UNCHANGED = 0, FILE_DPI_VIEWBOX_SCALED, FILE_DPI_DOCUMENT_SCALED }; extern int sp_file_convert_dpi_method_commandline; -- cgit v1.2.3 From a545384a9246881ba14effeafef924ffc3eca27d Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sat, 20 Apr 2019 01:19:45 +0200 Subject: Fix style and line detection --- src/document.cpp | 2 +- src/file-update.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 96dce8d2c..f923a45d6 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -451,7 +451,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, } /** Fix first line spacing in legacy documents (pre-1.0 files) **/ - if ( sp_version_inside_range( document->root->version.inkscape, 0, 1, 1, 0 ) ) { + if (sp_version_inside_range(document->root->version.inkscape, 0, 1, 1, 0)) { sp_file_remove_style_on_empty_lines(document); } diff --git a/src/file-update.cpp b/src/file-update.cpp index de2f17ad6..84a598f8e 100644 --- a/src/file-update.cpp +++ b/src/file-update.cpp @@ -209,9 +209,10 @@ void _remove_style_on_empty_lines(SPObject *o) { std::vector cl = o->childList(false); for (std::vector::const_iterator ci = cl.begin(); ci != cl.end(); ++ci) { - if (SP_IS_TSPAN(*ci) and (*ci)->childList(false).empty() and (*ci)->getAttribute("sodipodi:role")=="line" ) { - (*ci)->style->clear(); - } + if (SP_IS_TSPAN(*ci) and (*ci)->childList(false).empty() and is_line(*ci)) { + (*ci)->removeAttribute("style"); + (*ci)->updateRepr(); + } } } -- cgit v1.2.3 From 39fb9702333606bc43cb831121b688077831832b Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sun, 21 Apr 2019 17:30:39 +0200 Subject: Add second Tav fix --- src/file-update.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/file-update.cpp b/src/file-update.cpp index 84a598f8e..ff72f9b0e 100644 --- a/src/file-update.cpp +++ b/src/file-update.cpp @@ -208,11 +208,26 @@ void sp_file_convert_text_baseline_spacing(SPDocument *doc) void _remove_style_on_empty_lines(SPObject *o) { std::vector cl = o->childList(false); + bool begin = true; + std::string cur_y = ""; for (std::vector::const_iterator ci = cl.begin(); ci != cl.end(); ++ci) { - if (SP_IS_TSPAN(*ci) and (*ci)->childList(false).empty() and is_line(*ci)) { + if (!SP_IS_TSPAN(*ci)) + continue; + if (!is_line(*ci)) + continue; + if (!(*ci)->childList(false).empty()) { + if (begin) + cur_y = (*ci)->getAttribute("y") ? (*ci)->getAttribute("y") : cur_y; + begin = false; + } else { (*ci)->removeAttribute("style"); (*ci)->updateRepr(); + if (begin) { + (*ci)->deleteObject(); + } } + if (cur_y != "") + o->setAttribute("y", cur_y); } } -- cgit v1.2.3 From 1446f4eeb37a47231dd45db757454db045049ac6 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Wed, 24 Apr 2019 15:16:09 +0200 Subject: Add comment, rename function --- src/document.cpp | 2 +- src/file-update.cpp | 17 ++++++++++++++--- src/file.h | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index f923a45d6..03b285710 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -452,7 +452,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, /** Fix first line spacing in legacy documents (pre-1.0 files) **/ if (sp_version_inside_range(document->root->version.inkscape, 0, 1, 1, 0)) { - sp_file_remove_style_on_empty_lines(document); + sp_file_fix_empty_lines(document); } /** Fix dpi (pre-92 files). With GUI fixed in Inkscape::Application::fix_document. **/ diff --git a/src/file-update.cpp b/src/file-update.cpp index ff72f9b0e..9f1eafd7f 100644 --- a/src/file-update.cpp +++ b/src/file-update.cpp @@ -205,7 +205,18 @@ void sp_file_convert_text_baseline_spacing(SPDocument *doc) sp_file_text_run_recursive(fix_update, doc->getRoot()); } -void _remove_style_on_empty_lines(SPObject *o) + +/** + * Implements a fix for https://gitlab.com/inkscape/inkscape/issues/45 + * Line spacing for empty lines was handled differently before 1.0 + * and in particular with the first empty lines or with how style attributes + * are processed in empty lines (line = tspan with sodipodi:role="line") + * + * This function "fixes" a text element in a old document by removing the + * first empty lines and style attrs on other empty lines. + * + * */ +void _fix_pre_v1_empty_lines(SPObject *o) { std::vector cl = o->childList(false); bool begin = true; @@ -233,9 +244,9 @@ void _remove_style_on_empty_lines(SPObject *o) -void sp_file_remove_style_on_empty_lines(SPDocument *doc) +void sp_file_fix_empty_lines(SPDocument *doc) { - sp_file_text_run_recursive(_remove_style_on_empty_lines, doc->getRoot()); + sp_file_text_run_recursive(_fix_pre_v1_empty_lines, doc->getRoot()); sp_file_text_run_recursive(fix_update, doc->getRoot()); } diff --git a/src/file.h b/src/file.h index 5feb81a0c..c6353ad99 100644 --- a/src/file.h +++ b/src/file.h @@ -196,7 +196,7 @@ void sp_file_vacuum (SPDocument *doc); void sp_file_convert_text_baseline_spacing(SPDocument *doc); void sp_file_convert_font_name(SPDocument *doc); void sp_file_convert_dpi(SPDocument *doc); -void sp_file_remove_style_on_empty_lines(SPDocument *doc); +void sp_file_fix_empty_lines(SPDocument *doc); enum File_DPI_Fix { FILE_DPI_UNCHANGED = 0, FILE_DPI_VIEWBOX_SCALED, FILE_DPI_DOCUMENT_SCALED }; extern int sp_file_convert_dpi_method_commandline; -- cgit v1.2.3 From ce6d9290e0d31aa666d5202a1c5ede1b68c74a7f Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Wed, 24 Apr 2019 19:09:29 +0200 Subject: Fix commandline page selection page selection and allow to select poppler in cmd --- src/extension/internal/pdfinput/pdf-input.cpp | 3 +++ src/inkscape-application.cpp | 17 +++++++++++++++-- src/inkscape-application.h | 2 ++ src/inkscape.h | 8 ++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 5e1a91589..3ff599ebf 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -782,6 +782,9 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { #endif } else { page_num = INKSCAPE.get_pdf_page(); +#ifdef HAVE_POPPLER_CAIRO + is_importvia_poppler = INKSCAPE.get_pdf_poppler(); +#endif } SPDocument *doc = nullptr; diff --git a/src/inkscape-application.cpp b/src/inkscape-application.cpp index 97233f32b..77734ecd4 100644 --- a/src/inkscape-application.cpp +++ b/src/inkscape-application.cpp @@ -66,6 +66,8 @@ InkscapeApplication::InkscapeApplication() , _active_document(nullptr) , _active_selection(nullptr) , _active_view(nullptr) + , _pdf_page(0) + , _pdf_poppler(false) {} // Add document to app. @@ -484,6 +486,7 @@ ConcreteInkscapeApplication::ConcreteInkscapeApplication() // Open/Import this->add_main_option_entry(T::OPTION_TYPE_INT, "pdf-page", '\0', N_("Open: PDF page to import"), N_("PAGE")); + this->add_main_option_entry(T::OPTION_TYPE_BOOL, "pdf-poppler", '\0', N_("Use poppler when importing via commandline"), ""); this->add_main_option_entry(T::OPTION_TYPE_STRING, "convert-dpi-method", '\0', N_("Open: Method used to convert pre-0.92 document dpi, if needed: [none|scale-viewbox|scale-document]."), "[...]"); this->add_main_option_entry(T::OPTION_TYPE_BOOL, "no-convert-text-baseline-spacing", 0, N_("Open: Do not fix pre-0.92 document's text baseline spacing on opening."), ""); @@ -803,6 +806,10 @@ void ConcreteInkscapeApplication::on_open(const Gio::Application::type_vec_files& files, const Glib::ustring& hint) { on_startup2(); + if(_pdf_poppler) + INKSCAPE.set_pdf_poppler(_pdf_poppler); + if(_pdf_page) + INKSCAPE.set_pdf_page(_pdf_page); for (auto file : files) { // Open file @@ -849,6 +856,10 @@ void ConcreteInkscapeApplication::on_open(const Gio::Application::type_vec_files& files, const Glib::ustring& hint) { on_startup2(); + if(_pdf_poppler) + INKSCAPE.set_pdf_poppler(_pdf_poppler); + if(_pdf_page) + INKSCAPE.set_pdf_page(_pdf_page); for (auto file : files) { if (_with_gui) { @@ -1131,11 +1142,13 @@ ConcreteInkscapeApplication::on_handle_local_options(const Glib::RefPtrcontains("pdf-poppler")) { + _pdf_poppler = true; + } if (options->contains("pdf-page")) { // Maybe useful for other file types? int page = 0; options->lookup_value("pdf-page", page); - _command_line_actions.push_back( - std::make_pair("open-page", Glib::Variant::create(page))); + _pdf_page = page; } if (options->contains("convert-dpi-method")) { diff --git a/src/inkscape-application.h b/src/inkscape-application.h index 05fbafb89..d3c909f4a 100644 --- a/src/inkscape-application.h +++ b/src/inkscape-application.h @@ -92,6 +92,8 @@ protected: bool _with_gui; bool _batch_process; // Temp bool _use_shell; + int _pdf_page; + int _pdf_poppler; InkscapeApplication(); // Documents are owned by the application which is responsible for opening/saving/exporting. WIP diff --git a/src/inkscape.h b/src/inkscape.h index fd9a4c38d..840620171 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -193,12 +193,19 @@ public: // may not be reflected by a selection change and thus needs a separate signal sigc::signal signal_external_change; + void set_pdf_poppler(bool p) { + _pdf_poppler = p; + } + bool get_pdf_poppler() { + return _pdf_poppler; + } void set_pdf_page(gint page) { _pdf_page = page; } gint get_pdf_page() { return _pdf_page; } + void add_gtk_css(); void add_icon_theme(); @@ -225,6 +232,7 @@ public: static bool _crashIsHappening; bool _use_gui; gint _pdf_page; + bool _pdf_poppler; }; } // namespace Inkscape -- cgit v1.2.3 From 7e5838231b883a202a039c78bb39e3d383a700cc Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Wed, 24 Apr 2019 10:41:15 +0200 Subject: fix #175 crash with mask in