summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-11-28 01:34:35 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-11-28 12:46:43 +0100
commitec326f42c6390a241a5d0535611b68326885e8dd (patch)
tree4f1041b8baf7a456fc6270f791183c114a4bb1e1
parentremove hugely scoped superficial Any (diff)
downloadcore-ec326f42c6390a241a5d0535611b68326885e8dd.tar.gz
core-ec326f42c6390a241a5d0535611b68326885e8dd.zip
use constexprs and static_assert()
Change-Id: Ia7abeed325d8bc845e35bb9e7667cec6b83ac11f
-rw-r--r--sw/source/core/unocore/unostyle.cxx16
1 files changed, 8 insertions, 8 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index bdc6f822730c..49b4267bfffb 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -482,17 +482,17 @@ uno::Any SwXStyleFamily::getByIndex(sal_Int32 nIndex)
if(!m_pBasePool)
throw uno::RuntimeException();
OUString sStyleName;
- switch( m_eFamily )
+ switch(m_eFamily)
{
case SFX_STYLE_FAMILY_CHAR:
{
- if ( nIndex < ( RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) )
- SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCHR_NORMAL_BEGIN + nIndex), sStyleName );
- else if ( nIndex < ( RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN +
- RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) )
- SwStyleNameMapper::FillUIName ( RES_POOLCHR_HTML_BEGIN
- - RES_POOLCHR_NORMAL_END + RES_POOLCHR_NORMAL_BEGIN
- + nIndex, sStyleName );
+ constexpr sal_Int32 nPoolChrNormalRange = RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN;
+ constexpr sal_Int32 nPoolChrHtmlRange = RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN;
+ static_assert(nPoolChrNormalRange > 0 && nPoolChrHtmlRange > 0, "invalid pool range");
+ if(nIndex < nPoolChrNormalRange)
+ SwStyleNameMapper::FillUIName(static_cast<sal_uInt16>(RES_POOLCHR_NORMAL_BEGIN + nIndex), sStyleName);
+ else if(nIndex < (nPoolChrHtmlRange+nPoolChrNormalRange))
+ SwStyleNameMapper::FillUIName(RES_POOLCHR_HTML_BEGIN + nPoolChrNormalRange + nIndex, sStyleName );
}
break;
case SFX_STYLE_FAMILY_PARA: