From 88a083f8be05449630c9e2af30474281fd0d8af2 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Fri, 29 Jun 2012 20:00:16 +0200 Subject: fdo#42558 consolidated duplicated code * Moved almost identical code of SvxNumOptionsTabPage::SvxNumOptionsTabPage() and SvxPageDescPage::SvxPageDescPage() into static SvxNumOptionsTabPage::GetI18nNumbering() * Removed now unnecessary includes and using namespace directives Change-Id: I7babe68f2bb8af4fd227cbe558c34c7f85104a15 --- cui/source/inc/numpages.hxx | 13 +++++ cui/source/tabpages/numpages.cxx | 113 +++++++++++++++++++++------------------ cui/source/tabpages/page.cxx | 63 ++-------------------- 3 files changed, 76 insertions(+), 113 deletions(-) (limited to 'cui') diff --git a/cui/source/inc/numpages.hxx b/cui/source/inc/numpages.hxx index 5be85fbd70b4..cc89339482b1 100644 --- a/cui/source/inc/numpages.hxx +++ b/cui/source/inc/numpages.hxx @@ -346,6 +346,19 @@ class SvxNumOptionsTabPage : public SfxTabPage ListBox& GetCharFmtListBox() {return aCharFmtLB;} void SetModified(sal_Bool bRepaint = sal_True); virtual void PageCreated(SfxAllItemSet aSet); + + /** Get the numberings provided by the i18n framework (CTL, Asian, ...) and + add them to the listbox. Extended numbering schemes present in the + resource and already in the listbox but not offered by the i18n + framework per configuration are removed. + + @param nDoNotRemove + A value that shall not be removed, i.e. the ugly 0x88 + (SVX_NUM_BITMAP|0x80) + Pass ::std::numeric_limits::max() if there is no such + restriction. + */ + static void GetI18nNumbering( ListBox& rFmtLB, sal_uInt16 nDoNotRemove ); }; //------------------------------------------------ diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index 8936ebc2c55a..e909c1706886 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -1023,6 +1023,64 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, LinkBmpHdl_Impl) return 0; } +// static +void SvxNumOptionsTabPage::GetI18nNumbering( ListBox& rFmtLB, sal_uInt16 nDoNotRemove ) +{ + + Reference xDefNum = lcl_GetNumberingProvider(); + Reference xInfo(xDefNum, UNO_QUERY); + + // Extended numbering schemes present in the resource but not offered by + // the i18n framework per configuration must be removed from the listbox. + // Do not remove a special entry matching nDoNotRemove. + const sal_uInt16 nDontRemove = 0xffff; + ::std::vector< sal_uInt16> aRemove( rFmtLB.GetEntryCount(), nDontRemove); + for (size_t i=0; i(i)); + if (nEntryData > NumberingType::CHARS_LOWER_LETTER_N && nEntryData != nDoNotRemove) + aRemove[i] = nEntryData; + } + if(xInfo.is()) + { + Sequence aTypes = xInfo->getSupportedNumberingTypes( ); + const sal_Int16* pTypes = aTypes.getConstArray(); + for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++) + { + sal_Int16 nCurrent = pTypes[nType]; + if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N) + { + sal_Bool bInsert = sal_True; + for(sal_uInt16 nEntry = 0; nEntry < rFmtLB.GetEntryCount(); nEntry++) + { + sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)rFmtLB.GetEntryData(nEntry); + if(nEntryData == (sal_uInt16) nCurrent) + { + bInsert = sal_False; + aRemove[nEntry] = nDontRemove; + break; + } + } + if(bInsert) + { + OUString aIdent = xInfo->getNumberingIdentifier( nCurrent ); + sal_uInt16 nPos = rFmtLB.InsertEntry(aIdent); + rFmtLB.SetEntryData(nPos,(void*)(sal_uLong)nCurrent); + } + } + } + } + for (size_t i=0; i xDefNum = lcl_GetNumberingProvider(); - Reference xInfo(xDefNum, UNO_QUERY); - - // Extended numbering schemes present in the resource but not offered by - // the i18n framework per configuration must be removed from the listbox. + // Get advanced numbering types from the component. // Watch out for the ugly 0x88/*SVX_NUM_BITMAP|0x80*/ to not remove that. - const sal_uInt16 nDontRemove = 0xffff; - ::std::vector< sal_uInt16> aRemove( aFmtLB.GetEntryCount(), nDontRemove); - for (size_t i=0; i(i)); - if (nEntryData > NumberingType::CHARS_LOWER_LETTER_N && - nEntryData != (SVX_NUM_BITMAP | 0x80)) - aRemove[i] = nEntryData; - } - if(xInfo.is()) - { - Sequence aTypes = xInfo->getSupportedNumberingTypes( ); - const sal_Int16* pTypes = aTypes.getConstArray(); - for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++) - { - sal_Int16 nCurrent = pTypes[nType]; - if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N) - { - sal_Bool bInsert = sal_True; - for(sal_uInt16 nEntry = 0; nEntry < aFmtLB.GetEntryCount(); nEntry++) - { - sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)aFmtLB.GetEntryData(nEntry); - if(nEntryData == (sal_uInt16) nCurrent) - { - bInsert = sal_False; - aRemove[nEntry] = nDontRemove; - break; - } - } - if(bInsert) - { - OUString aIdent = xInfo->getNumberingIdentifier( nCurrent ); - sal_uInt16 nPos = aFmtLB.InsertEntry(aIdent); - aFmtLB.SetEntryData(nPos,(void*)(sal_uLong)nCurrent); - } - } - } - } - for (size_t i=0; i -#include -#include -//------------------------------------------------------ #include #include #include @@ -73,11 +69,7 @@ #include #include -//Namespaces-------------------------------------------------------------- -using namespace com::sun::star::uno; -using namespace com::sun::star::text; -using namespace com::sun::star::style; -using rtl::OUString; +#include // for GetI18nNumbering() // static ---------------------------------------------------------------- @@ -371,57 +363,8 @@ SvxPageDescPage::SvxPageDescPage( Window* pParent, const SfxItemSet& rAttr ) : aPortraitBtn.SetAccessibleRelationMemberOf(&aOrientationFT); aLandscapeBtn.SetAccessibleRelationMemberOf(&aOrientationFT); -// Get the CTL/Asian Language Numbering and added to list box - Reference lcl_GetNumberingProvider(); - Reference xDefNum = lcl_GetNumberingProvider(); - Reference xInfo(xDefNum, UNO_QUERY); - sal_Int16 nPos; - const sal_uInt16 nDontRemove = 0xffff; - std::vector< sal_uInt16> aRemove( aNumberFormatBox.GetEntryCount(), nDontRemove); - for (size_t i=0; i(i)); - if (nEntryData > NumberingType::CHARS_LOWER_LETTER_N) - aRemove[i] = nEntryData; - } - if(xInfo.is()) - { - Sequence aTypes = xInfo->getSupportedNumberingTypes( ); - const sal_Int16* pTypes = aTypes.getConstArray(); - for(sal_Int32 nType = 0; nType < aTypes.getLength(); nType++) - { - sal_Int16 nCurrent = pTypes[nType]; - if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N) - { - sal_Bool bInsert = sal_True; - for(sal_uInt16 nEntry = 0; nEntry < aNumberFormatBox.GetEntryCount(); nEntry++) - { - sal_uInt16 nEntryData = (sal_uInt16)(sal_uLong)aNumberFormatBox.GetEntryData(nEntry); - if(nEntryData == (sal_uInt16) nCurrent) - { - bInsert = sal_False; - aRemove[nEntry] = nDontRemove; - break; - } - } - if(bInsert) - { - OUString aIdent = xInfo->getNumberingIdentifier( nCurrent ); - nPos = aNumberFormatBox.InsertEntry(aIdent); - aNumberFormatBox.SetEntryData(nPos,(void*)(sal_uLong)nCurrent); - } - } - } - } - for (size_t i=0; i::max()); } // ----------------------------------------------------------------------- -- cgit