diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2019-04-19 22:16:59 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marcjeanmougin@free.fr> | 2019-04-24 13:16:46 +0000 |
| commit | 1633a91c3a1fd6eb4d981d9117c7a4ba96d1f562 (patch) | |
| tree | ace2405514c65b1d40e7395e8e1e37c5399d1066 /src | |
| parent | Keep Document Grid spacing on change and save (diff) | |
| download | inkscape-1633a91c3a1fd6eb4d981d9117c7a4ba96d1f562.tar.gz inkscape-1633a91c3a1fd6eb4d981d9117c7a4ba96d1f562.zip | |
Removes style on empty lines
Diffstat (limited to 'src')
| -rw-r--r-- | src/document.cpp | 5 | ||||
| -rw-r--r-- | src/file-update.cpp | 20 | ||||
| -rw-r--r-- | src/file.h | 1 |
3 files changed, 26 insertions, 0 deletions
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<SPObject *> cl = o->childList(false); + for (std::vector<SPObject *>::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; |
