Kaydet (Commit) 452ae1ad authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

reduce scope with template specialization

Change-Id: I7bfbaa3898f34e1ed931f5865b493aae66e28c0f
üst 78b28312
......@@ -320,14 +320,13 @@ static bool lcl_GetHeaderFooterItem(
return SfxItemState::SET == eState;
}
static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc,
SfxStyleFamily eFamily, OUString *pString, sal_Int32 nIndex = SAL_MAX_INT32)
template<enum SfxStyleFamily>
static sal_Int32 lcl_GetCountOrName2(const SwDoc &rDoc, OUString *pString, sal_Int32 nIndex);
template<>
sal_Int32 lcl_GetCountOrName2<SFX_STYLE_FAMILY_CHAR>(const SwDoc &rDoc, OUString *pString, sal_Int32 nIndex)
{
sal_Int32 nCount = 0;
switch( eFamily )
{
case SFX_STYLE_FAMILY_CHAR:
{
const sal_Int32 nBaseCount =
RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN +
RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN;
......@@ -354,10 +353,13 @@ static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc,
}
}
nCount += nBaseCount;
}
break;
case SFX_STYLE_FAMILY_PARA:
{
return nCount;
}
template<>
sal_Int32 lcl_GetCountOrName2<SFX_STYLE_FAMILY_PARA>(const SwDoc &rDoc, OUString *pString, sal_Int32 nIndex)
{
sal_Int32 nCount = 0;
const sal_Int32 nBaseCount =
RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN +
RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
......@@ -383,10 +385,13 @@ static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc,
}
}
nCount += nBaseCount;
}
break;
case SFX_STYLE_FAMILY_FRAME:
{
return nCount;
}
template<>
sal_Int32 lcl_GetCountOrName2<SFX_STYLE_FAMILY_FRAME>(const SwDoc &rDoc, OUString *pString, sal_Int32 nIndex)
{
sal_Int32 nCount = 0;
const sal_Int32 nBaseCount = RES_POOLFRM_END - RES_POOLFRM_BEGIN;
nIndex = nIndex - nBaseCount;
const size_t nArrLen = rDoc.GetFrameFormats()->size();
......@@ -406,10 +411,13 @@ static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc,
}
}
nCount += nBaseCount;
}
break;
case SFX_STYLE_FAMILY_PAGE:
{
return nCount;
}
template<>
sal_Int32 lcl_GetCountOrName2<SFX_STYLE_FAMILY_PAGE>(const SwDoc &rDoc, OUString *pString, sal_Int32 nIndex)
{
sal_Int32 nCount = 0;
const sal_Int32 nBaseCount = RES_POOLPAGE_END - RES_POOLPAGE_BEGIN;
nIndex = nIndex - nBaseCount;
const size_t nArrLen = rDoc.GetPageDescCnt();
......@@ -428,10 +436,13 @@ static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc,
}
}
nCount += nBaseCount;
}
break;
case SFX_STYLE_FAMILY_PSEUDO:
{
return nCount;
}
template<>
sal_Int32 lcl_GetCountOrName2<SFX_STYLE_FAMILY_PSEUDO>(const SwDoc &rDoc, OUString *pString, sal_Int32 nIndex)
{
sal_Int32 nCount = 0;
const sal_Int32 nBaseCount = RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN;
nIndex = nIndex - nBaseCount;
const SwNumRuleTable& rNumTable = rDoc.GetNumRuleTable();
......@@ -451,13 +462,43 @@ static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc,
}
}
nCount += nBaseCount;
return nCount;
}
static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc,
SfxStyleFamily eFamily, OUString *pString, sal_Int32 nIndex = SAL_MAX_INT32)
{
switch( eFamily )
{
case SFX_STYLE_FAMILY_CHAR:
{
return lcl_GetCountOrName2<SFX_STYLE_FAMILY_CHAR>(rDoc, pString, nIndex);
}
break;
case SFX_STYLE_FAMILY_PARA:
{
return lcl_GetCountOrName2<SFX_STYLE_FAMILY_PARA>(rDoc, pString, nIndex);
}
break;
case SFX_STYLE_FAMILY_FRAME:
{
return lcl_GetCountOrName2<SFX_STYLE_FAMILY_FRAME>(rDoc, pString, nIndex);
}
break;
case SFX_STYLE_FAMILY_PAGE:
{
return lcl_GetCountOrName2<SFX_STYLE_FAMILY_PAGE>(rDoc, pString, nIndex);
}
break;
case SFX_STYLE_FAMILY_PSEUDO:
{
return lcl_GetCountOrName2<SFX_STYLE_FAMILY_PSEUDO>(rDoc, pString, nIndex);
}
break;
default:
;
return 0;
}
return nCount;
}
sal_Int32 SwXStyleFamily::getCount() throw( uno::RuntimeException, std::exception )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment