summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-11-28 18:01:02 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-11-29 10:38:35 +0100
commit7cb3a2c35e29207008bac44d7ace10ca9e866d99 (patch)
treeab97874f868e495e04cab84bb4f9ac57a82b4141 /sw/source
parent939657e7c8beca46f0b84faf7a89cda8b789e2f5 (diff)
use a range template for the frame,page,pseudo translations
Change-Id: I50698023c006025bad4ae5d9a632c20b8f897006
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/unocore/unostyle.cxx34
1 files changed, 9 insertions, 25 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 6d5c4dbc5fa9..734f075ec621 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -551,27 +551,11 @@ sal_uInt16 lcl_TranslateIndex<SFX_STYLE_FAMILY_PARA>(const sal_uInt16 nIndex)
throw lang::IndexOutOfBoundsException();
}
-template<>
-sal_uInt16 lcl_TranslateIndex<SFX_STYLE_FAMILY_FRAME>(const sal_uInt16 nIndex)
-{
- if(nIndex < nPoolFrameRange)
- return nIndex + RES_POOLFRM_BEGIN;
- throw lang::IndexOutOfBoundsException();
-}
-
-template<>
-sal_uInt16 lcl_TranslateIndex<SFX_STYLE_FAMILY_PAGE>(const sal_uInt16 nIndex)
-{
- if(nIndex < nPoolPageRange)
- return nIndex + RES_POOLPAGE_BEGIN;
- throw lang::IndexOutOfBoundsException();
-}
-
-template<>
-sal_uInt16 lcl_TranslateIndex<SFX_STYLE_FAMILY_PSEUDO>(const sal_uInt16 nIndex)
+template<sal_uInt16 nRangeBegin, sal_uInt16 nRangeSize>
+static sal_uInt16 lcl_TranslateIndexRange(const sal_uInt16 nIndex)
{
- if(nIndex < nPoolNumRange)
- return nIndex + RES_POOLNUMRULE_BEGIN;
+ if(nIndex < nRangeSize)
+ return nIndex + nRangeBegin;
throw lang::IndexOutOfBoundsException();
}
@@ -758,11 +742,11 @@ static const std::vector<StyleFamilyEntry>* lcl_GetStyleFamilyEntries()
if(!our_pStyleFamilyEntries)
{
our_pStyleFamilyEntries = new std::vector<StyleFamilyEntry>{
- { SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER, &lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR>, &lcl_CreateStyle<SFX_STYLE_FAMILY_CHAR>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_CHAR> },
- { SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PARA>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PARA>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_PARA> },
- { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PAGE>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PAGE>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_PAGE> },
- { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME, &lcl_GetCountOrName<SFX_STYLE_FAMILY_FRAME>, &lcl_CreateStyle<SFX_STYLE_FAMILY_FRAME>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_FRAME> },
- { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PSEUDO>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_PSEUDO> }
+ { SFX_STYLE_FAMILY_CHAR, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, "CharacterStyles", STR_STYLE_FAMILY_CHARACTER, &lcl_GetCountOrName<SFX_STYLE_FAMILY_CHAR>, &lcl_CreateStyle<SFX_STYLE_FAMILY_CHAR>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_CHAR> },
+ { SFX_STYLE_FAMILY_PARA, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, "ParagraphStyles", STR_STYLE_FAMILY_PARAGRAPH, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PARA>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PARA>, &lcl_TranslateIndex<SFX_STYLE_FAMILY_PARA> },
+ { SFX_STYLE_FAMILY_PAGE, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, "PageStyles", STR_STYLE_FAMILY_PAGE, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PAGE>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PAGE>, &lcl_TranslateIndexRange<RES_POOLPAGE_BEGIN, nPoolPageRange> },
+ { SFX_STYLE_FAMILY_FRAME, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, "FrameStyles", STR_STYLE_FAMILY_FRAME, &lcl_GetCountOrName<SFX_STYLE_FAMILY_FRAME>, &lcl_CreateStyle<SFX_STYLE_FAMILY_FRAME>, &lcl_TranslateIndexRange<RES_POOLFRM_BEGIN, nPoolFrameRange> },
+ { SFX_STYLE_FAMILY_PSEUDO, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE, "NumberingStyles", STR_STYLE_FAMILY_NUMBERING, &lcl_GetCountOrName<SFX_STYLE_FAMILY_PSEUDO>, &lcl_CreateStyle<SFX_STYLE_FAMILY_PSEUDO>, &lcl_TranslateIndexRange<RES_POOLNUMRULE_BEGIN, nPoolNumRange> }
};
}
return our_pStyleFamilyEntries;