summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2019-10-04 12:02:53 +0300
committerMiklos Vajna <vmiklos@collabora.com>2019-10-31 08:53:19 +0100
commit7eeb484e7d1faf87fbb8774a8bda4328d047dde3 (patch)
tree2308940cf737bf2d42ff2220a2c91d621ceca560 /sw/source
parentaaa242a33b01e87c41f19fca871cafa857fe71dd (diff)
related tdf#99602 docxoutput: fix incorrect rounding on subscripts
Adding .5 is a poor mans version of rounding which works fine with unsigned numbers, but not with negative numbers. Perhaps use the exotic round() function instead? In addition, the font size isn't necessarily an integer, so that should have been a float. The result of bad rounding was losing a percentage of the subscript every round-trip. Change-Id: I83e05d8367f059f3266d12a7e134e268fef758bb Reviewed-on: https://gerrit.libreoffice.org/80217 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 1d01e7978504..872b693a1431 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6847,8 +6847,10 @@ void DocxAttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement )
else if ( DFLT_ESC_SUPER == nEsc || DFLT_ESC_AUTO_SUPER == nEsc )
sIss = OString( "superscript" );
}
+ // FIXME: these need a better formula. See rtfAttributeOutput
else if ( DFLT_ESC_AUTO_SUPER == nEsc )
nEsc = DFLT_ESC_SUPER;
+ // FIXME: this actually needs to know font information (descending, bottom line) for a proper formula
else if ( DFLT_ESC_AUTO_SUB == nEsc )
nEsc = DFLT_ESC_SUB;
@@ -6858,13 +6860,13 @@ void DocxAttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement )
const SvxFontHeightItem& rItem = m_rExport.GetItem(RES_CHRATR_FONTSIZE);
if (sIss.isEmpty() || sIss.match("baseline"))
{
- long nHeight = rItem.GetHeight();
- OString sPos = OString::number( ( nHeight * nEsc + 500 ) / 1000 );
+ float fHeight = rItem.GetHeight();
+ OString sPos = OString::number( round(( fHeight * nEsc ) / 1000) );
m_pSerializer->singleElementNS(XML_w, XML_position, FSNS(XML_w, XML_val), sPos);
if( ( 100 != nProp || sIss.match( "baseline" ) ) && !m_rExport.m_bFontSizeWritten )
{
- OString sSize = OString::number( ( nHeight * nProp + 500 ) / 1000 );
+ OString sSize = OString::number( round(( fHeight * nProp ) / 1000) );
m_pSerializer->singleElementNS(XML_w, XML_sz, FSNS(XML_w, XML_val), sSize);
}
}