From 9932d3f124c047d557a978fb6b035214a09c086a Mon Sep 17 00:00:00 2001 From: johanengelen Date: Thu, 12 Jun 2008 20:38:23 +0000 Subject: [PATCH] add svg_write and read methods for Geom::Matrix --- src/svg/svg-affine.cpp | 28 ++++++++++++++++++++++++++++ src/svg/svg.h | 3 +++ 2 files changed, 31 insertions(+) diff --git a/src/svg/svg-affine.cpp b/src/svg/svg-affine.cpp index d33947447..0ad54accd 100644 --- a/src/svg/svg-affine.cpp +++ b/src/svg/svg-affine.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include "svg.h" #include "prefs-utils.h" @@ -37,6 +38,18 @@ # define M_PI 3.14159265358979323846 #endif +bool +sp_svg_transform_read(gchar const *str, Geom::Matrix *transform) +{ + NR::Matrix mat; + if (sp_svg_transform_read(str, &mat)) { + *transform = to_2geom(mat); + return true; + } else { + return false; + } +} + bool sp_svg_transform_read(gchar const *str, NR::Matrix *transform) { @@ -161,6 +174,21 @@ sp_svg_transform_read(gchar const *str, NR::Matrix *transform) #define EQ(a,b) (fabs ((a) - (b)) < 1e-9) +gchar * +sp_svg_transform_write(Geom::Matrix const &transform) +{ + Geom::Matrix const t(transform); + return sp_svg_transform_write(&t); +} + + +gchar * +sp_svg_transform_write(Geom::Matrix const *transform) +{ + NR::Matrix const t(from_2geom(*transform)); + return sp_svg_transform_write(&t); +} + gchar * sp_svg_transform_write(NR::Matrix const &transform) { diff --git a/src/svg/svg.h b/src/svg/svg.h index 0e5b4d5d5..a273ceddc 100644 --- a/src/svg/svg.h +++ b/src/svg/svg.h @@ -54,8 +54,11 @@ unsigned int sp_svg_length_read_ldd (const gchar *str, SVGLength::Unit *unit, do std::string sp_svg_length_write_with_units(SVGLength const &length); +bool sp_svg_transform_read(gchar const *str, Geom::Matrix *transform); bool sp_svg_transform_read(gchar const *str, NR::Matrix *transform); +gchar *sp_svg_transform_write(Geom::Matrix const &transform); +gchar *sp_svg_transform_write(Geom::Matrix const *transform); gchar *sp_svg_transform_write(NR::Matrix const &transform); gchar *sp_svg_transform_write(NR::Matrix const *transform); -- 2.30.2