So far, stroke coordinates are written out absolutely, which means that
simple shifts of strokes show up as large diffs.

Introduce relative stroke coordinates (with an r suffix) which are
relative with respect to the coordinate before.

Signed-off-by: Michael J Gruber <michaeljgru...@users.sourceforge.net>
---
Hi there,

This is just a suggestion which should probably come with a knob to turn
it on but have it off by default: The patched parser happily reads
absolute and relative coordinates, but the unpatched only absolute ones.

But the patch really helps when you track your xoj in git, so that using diff
you can check whether you have shifts only or real rewrites in your file.

Cheers,
Michael

 src/xo-file.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/xo-file.c b/src/xo-file.c
index 082d399..4a49027 100644
--- a/src/xo-file.c
+++ b/src/xo-file.c
@@ -242,8 +242,10 @@ gboolean save_journal(const char *filename)
             for (i=0;i<item->path->num_points-1;i++)
               gzprintf(f, " %.2f", item->widths[i]);
           gzprintf(f, "\">\n");
-          for (i=0;i<2*item->path->num_points;i++)
-            gzprintf(f, "%.2f ", item->path->coords[i]);
+          for (i=0;(i<2*item->path->num_points) && i<2;i++)
+            gzprintf(f, "%.2f ", item->path->coords[0]);
+          for (i=2;i<2*item->path->num_points;i++)
+            gzprintf(f, "%+.2fr ", item->path->coords[i] - 
item->path->coords[i-2]);
           gzprintf(f, "\n</stroke>\n");
         }
         if (item->type == ITEM_TEXT) {
@@ -759,6 +761,10 @@ void xoj_parser_text(GMarkupParseContext *context,
       realloc_cur_path(n/2 + 1);
       ui.cur_path.coords[n] = g_ascii_strtod(text, (char **)(&ptr));
       if (ptr == text) break;
+      if ((n > 1) && (*ptr == 'r')) {
+        ui.cur_path.coords[n] += ui.cur_path.coords[n-2];
+        ptr++;
+      }
       text_len -= (ptr - text);
       text = ptr;
       if (!finite_sized(ui.cur_path.coords[n])) {
-- 
2.2.0.379.ge4a21d5


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Xournal-devel mailing list
Xournal-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xournal-devel

Reply via email to