summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2019-10-04 14:41:19 +0300
committerMiklos Vajna <vmiklos@collabora.com>2019-10-31 08:52:38 +0100
commitaaa242a33b01e87c41f19fca871cafa857fe71dd (patch)
treefe791b7ca28a66945c9efa011ebed14de5c735bc /sw/source
parentef3dabd1f814d1b005efc5d5144978c1d26a8e73 (diff)
related tdf#99602 ww8/rtfoutput: 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: I9093f7bfcd0b87249b42562668e45480dcb59f53 Reviewed-on: https://gerrit.libreoffice.org/80218 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/rtfattributeoutput.cxx8
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx9
2 files changed, 7 insertions, 10 deletions
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 078f9dc94dd6..70ba0dd85115 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -2306,14 +2306,14 @@ void RtfAttributeOutput::CharEscapement(const SvxEscapementItem& rEscapement)
const char* pUpDn;
- SwTwips nH = m_rExport.GetItem(RES_CHRATR_FONTSIZE).GetHeight();
+ double fHeight = m_rExport.GetItem(RES_CHRATR_FONTSIZE).GetHeight();
if (0 < rEscapement.GetEsc())
pUpDn = OOO_STRING_SVTOOLS_RTF_UP;
else if (0 > rEscapement.GetEsc())
{
pUpDn = OOO_STRING_SVTOOLS_RTF_DN;
- nH = -nH;
+ fHeight = -fHeight;
}
else
return;
@@ -2344,9 +2344,7 @@ void RtfAttributeOutput::CharEscapement(const SvxEscapementItem& rEscapement)
* ----------------------- = ------------
* 100% Escapement
*/
-
- m_aStyles.append(static_cast<sal_Int32>((long(nEsc) * nH) + 500) / 1000);
- // 500 to round !!
+ m_aStyles.append(static_cast<sal_Int32>(round(fHeight * nEsc / 1000)));
}
void RtfAttributeOutput::CharFont(const SvxFontItem& rFont)
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 040153b65bdd..17780b0e0efb 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -1396,6 +1396,7 @@ void WW8AttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement )
else if ( DFLT_ESC_SUPER == nEsc || DFLT_ESC_AUTO_SUPER == nEsc )
b = 1;
}
+ // FIXME: these need a better formula. See rtfAttributeOutput
else if ( DFLT_ESC_AUTO_SUPER == nEsc )
nEsc = DFLT_ESC_SUPER;
else if ( DFLT_ESC_AUTO_SUB == nEsc )
@@ -1410,17 +1411,15 @@ void WW8AttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement )
if ( 0 == b || 0xFF == b )
{
- long nHeight = m_rWW8Export.GetItem( RES_CHRATR_FONTSIZE ).GetHeight();
+ double fHeight = m_rWW8Export.GetItem( RES_CHRATR_FONTSIZE ).GetHeight();
m_rWW8Export.InsUInt16( NS_sprm::sprmCHpsPos );
- m_rWW8Export.InsUInt16( static_cast<short>(( nHeight * nEsc + 500 ) / 1000 ));
+ m_rWW8Export.InsUInt16(static_cast<short>( round(fHeight * nEsc / 1000) ));
if( 100 != nProp || !b )
{
m_rWW8Export.InsUInt16( NS_sprm::sprmCHps );
-
- m_rWW8Export.InsUInt16(
- msword_cast<sal_uInt16>((nHeight * nProp + 500 ) / 1000));
+ m_rWW8Export.InsUInt16(msword_cast<sal_uInt16>( round(fHeight * nProp / 1000) ));
}
}
}