From dcae3824261b392170481dd1888f4246a245ab06 Mon Sep 17 00:00:00 2001 From: tavmjong-free Date: Sat, 5 Jun 2010 16:09:41 +0200 Subject: [PATCH] Adding a character to a superscript or subscript no longer resets baseline-shift. --- src/style.cpp | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/style.cpp b/src/style.cpp index f26862871..9c82b1b7a 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -3950,35 +3950,25 @@ sp_style_write_ifontsize(gchar *p, gint const len, gchar const *key, } -/** - * +/* + * baseline-shift is relative to parent. The only time it should + * not be written out is if it is zero (or not set). */ static bool -sp_baseline_shift_differ(SPIBaselineShift const *const a, SPIBaselineShift const *const b) +sp_baseline_shift_notzero(SPIBaselineShift const *const a ) { - if (a->type != b->type) - return true; - if (a->type == SP_BASELINE_SHIFT_LITERAL ) { - if (a->literal != b->literal) - return true; - } - if (a->type == SP_BASELINE_SHIFT_LENGTH) { - if (a->unit == SP_CSS_UNIT_EM || a->unit == SP_CSS_UNIT_EX ) { - if( a->value != b->value ) - return true; - } else { - if (a->computed != b->computed) - return true; + if( a->type == SP_BASELINE_SHIFT_LITERAL ) { + if( a->literal == SP_CSS_BASELINE_SHIFT_BASELINE ) { + return false; + } + } else { + if( a->value == 0.0 ) { + return false; } } - if (a->type == SP_BASELINE_SHIFT_PERCENTAGE) { - if (a->value != b->value) - return true; - } - return false; + return true; } - /** * Write SPIBaselineShift object into string. */ @@ -3990,13 +3980,13 @@ sp_style_write_ibaselineshift(gchar *p, gint const len, gchar const *key, if ((flags & SP_STYLE_FLAG_ALWAYS) || ((flags & SP_STYLE_FLAG_IFSET) && val->set) || ((flags & SP_STYLE_FLAG_IFDIFF) && val->set - && (!base->set || sp_baseline_shift_differ(val, base)))) + && (!base->set || sp_baseline_shift_notzero(val) ))) { if (val->inherit) { return g_snprintf(p, len, "%s:inherit;", key); } else if (val->type == SP_BASELINE_SHIFT_LITERAL) { for (unsigned i = 0; enum_baseline_shift[i].key; i++) { - if (enum_baseline_shift[i].value == static_cast< gint > (val->value) ) { + if (enum_baseline_shift[i].value == static_cast< gint > (val->literal) ) { return g_snprintf(p, len, "%s:%s;", key, enum_baseline_shift[i].key); } } -- 2.30.2