[Libreoffice-commits] core.git: 2 commits - editeng/source include/editeng
Stephan Bergmann
sbergman at redhat.com
Wed Nov 12 00:01:17 PST 2014
editeng/source/items/textitem.cxx | 12 ++++++++++--
include/editeng/fhgtitem.hxx | 3 +--
2 files changed, 11 insertions(+), 4 deletions(-)
New commits:
commit 1eb31467a5af90fe41dc646dd716bdb7d3e5db45
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Nov 12 08:58:57 2014 +0100
Guard against wrap-around in SvxFontHeightItem
...though the whole design there looks broken
Change-Id: I6c3a53d606ea835d34729fcfb661fad0f1897716
diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx
index 4a2bbd8..c471b45 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -884,7 +884,13 @@ bool SvxFontHeightItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
return true;
}
-// Calculate the relative deviation from the expected height.
+// Try to reconstruct the original height input value from the modified height
+// and the prop data; this seems somewhat futile given the various ways how the
+// modified height is calculated (with and without conversion between twips and
+// 100th mm; with an additional eCoreMetric input in one of the SetHeight
+// overloads), and indeed known to occassionally produce nRet values that would
+// be negative, so just guard against negative results here and throw the hands
+// up in despair:
static sal_uInt32 lcl_GetRealHeight_Impl(sal_uInt32 nHeight, sal_uInt16 nProp, SfxMapUnit eProp, bool bCoreInTwip)
{
sal_uInt32 nRet = nHeight;
@@ -913,7 +919,9 @@ static sal_uInt32 lcl_GetRealHeight_Impl(sal_uInt32 nHeight, sal_uInt16 nProp, S
break;
default: ;//prevent warning
}
- nRet -= nDiff;
+ nRet = (nDiff < 0 || nRet >= static_cast<unsigned short>(nDiff))
+ ? nRet - nDiff : 0;
+ //TODO: overflow in case nDiff < 0 and nRet - nDiff > SAL_MAX_UINT32
return nRet;
}
commit 485ac5e159c315b3edf1d892da8e95ce901daa23
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Nov 11 19:57:17 2014 +0100
Clean up SvxFontHeightItem::SetProp
Change-Id: I6cc58745aaf7093e54f92b50201bf2a39fcc5619
diff --git a/include/editeng/fhgtitem.hxx b/include/editeng/fhgtitem.hxx
index 2ea466f..e069f1b 100644
--- a/include/editeng/fhgtitem.hxx
+++ b/include/editeng/fhgtitem.hxx
@@ -81,8 +81,7 @@ public:
sal_uInt32 GetHeight() const { return nHeight; }
- void SetProp( const sal_uInt16 nNewProp,
- SfxMapUnit eUnit = SFX_MAPUNIT_RELATIVE )
+ void SetProp( sal_uInt16 nNewProp, SfxMapUnit eUnit )
{
DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" );
nProp = nNewProp;
More information about the Libreoffice-commits
mailing list