summaryrefslogtreecommitdiff
path: root/sw/source/uibase/config
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-05-21 17:44:32 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-05-21 21:09:57 +0200
commit2634bc59092b24217d984a5845365d703bdb08d2 (patch)
treea3b7324d54aefb57d5f012c7aeb1b80d07fce75b /sw/source/uibase/config
parentc912c4b02b2dc4cd5aa62d77e92e1731c6cbde65 (diff)
sw: replace most static_cast<sal_uInt16>() calls with o3tl::narrowing()
o3tl::narrowing() is a better way to handle this, as that way the integer conversion is still implicit, which allows detecting integer truncation at runtime (with suitable compiler flags). Change-Id: I499abda3be6943e8c111c56df390e72939586221 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115948 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/uibase/config')
-rw-r--r--sw/source/uibase/config/modcfg.cxx8
-rw-r--r--sw/source/uibase/config/usrpref.cxx2
-rw-r--r--sw/source/uibase/config/viewopt.cxx2
3 files changed, 6 insertions, 6 deletions
diff --git a/sw/source/uibase/config/modcfg.cxx b/sw/source/uibase/config/modcfg.cxx
index ef51d6e6ba95..4733727e7043 100644
--- a/sw/source/uibase/config/modcfg.cxx
+++ b/sw/source/uibase/config/modcfg.cxx
@@ -1139,10 +1139,10 @@ void SwTableConfig::Load()
sal_Int32 nTemp = 0;
switch (nProp)
{
- case 0 : pValues[nProp] >>= nTemp; m_nTableHMove = static_cast<sal_uInt16>(convertMm100ToTwip(nTemp)); break; //"Shift/Row",
- case 1 : pValues[nProp] >>= nTemp; m_nTableVMove = static_cast<sal_uInt16>(convertMm100ToTwip(nTemp)); break; //"Shift/Column",
- case 2 : pValues[nProp] >>= nTemp; m_nTableHInsert = static_cast<sal_uInt16>(convertMm100ToTwip(nTemp)); break; //"Insert/Row",
- case 3 : pValues[nProp] >>= nTemp; m_nTableVInsert = static_cast<sal_uInt16>(convertMm100ToTwip(nTemp)); break; //"Insert/Column",
+ case 0 : pValues[nProp] >>= nTemp; m_nTableHMove = o3tl::narrowing<sal_uInt16>(convertMm100ToTwip(nTemp)); break; //"Shift/Row",
+ case 1 : pValues[nProp] >>= nTemp; m_nTableVMove = o3tl::narrowing<sal_uInt16>(convertMm100ToTwip(nTemp)); break; //"Shift/Column",
+ case 2 : pValues[nProp] >>= nTemp; m_nTableHInsert = o3tl::narrowing<sal_uInt16>(convertMm100ToTwip(nTemp)); break; //"Insert/Row",
+ case 3 : pValues[nProp] >>= nTemp; m_nTableVInsert = o3tl::narrowing<sal_uInt16>(convertMm100ToTwip(nTemp)); break; //"Insert/Column",
case 4 : pValues[nProp] >>= nTemp; m_eTableChgMode = static_cast<TableChgMode>(nTemp); break; //"Change/Effect",
case 5 : m_bInsTableFormatNum = *o3tl::doAccess<bool>(pValues[nProp]); break; //"Input/NumberRecognition",
case 6 : m_bInsTableChangeNumFormat = *o3tl::doAccess<bool>(pValues[nProp]); break; //"Input/NumberFormatRecognition",
diff --git a/sw/source/uibase/config/usrpref.cxx b/sw/source/uibase/config/usrpref.cxx
index 2dbc4b74d966..7f85d5a78940 100644
--- a/sw/source/uibase/config/usrpref.cxx
+++ b/sw/source/uibase/config/usrpref.cxx
@@ -384,7 +384,7 @@ void SwLayoutViewConfig::Load()
case 12: m_rParent.SetMetric(static_cast<FieldUnit>(nInt32Val), true); break;// "Other/MeasureUnit",
case 13: m_rParent.SetDefTabInMm100(nInt32Val, true); break;// "Other/TabStop",
case 14: m_rParent.SetVRulerRight(bSet); break;// "Window/IsVerticalRulerRight",
- case 15: m_rParent.SetViewLayoutColumns( static_cast<sal_uInt16>(nInt32Val) ); break;// "ViewLayout/Columns",
+ case 15: m_rParent.SetViewLayoutColumns( o3tl::narrowing<sal_uInt16>(nInt32Val) ); break;// "ViewLayout/Columns",
case 16: m_rParent.SetViewLayoutBookMode(bSet); break;// "ViewLayout/BookMode",
case 17: m_rParent.SetDefaultPageMode(bSet,true); break;// "Other/IsSquaredPageMode",
case 18: m_rParent.SetApplyCharUnit(bSet, true); break;// "Other/ApplyUserChar"
diff --git a/sw/source/uibase/config/viewopt.cxx b/sw/source/uibase/config/viewopt.cxx
index 77e65e1f6604..f36530c355ad 100644
--- a/sw/source/uibase/config/viewopt.cxx
+++ b/sw/source/uibase/config/viewopt.cxx
@@ -326,7 +326,7 @@ void SwViewOption::Init(const OutputDevice* pWin)
{
if( !s_nPixelTwips && pWin )
{
- s_nPixelTwips = static_cast<sal_uInt16>(pWin->PixelToLogic( Size(1,1) ).Height());
+ s_nPixelTwips = o3tl::narrowing<sal_uInt16>(pWin->PixelToLogic( Size(1,1) ).Height());
}
}