diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2016-03-13 02:09:35 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2016-03-17 23:54:43 +0100 |
commit | 4482c062a5277bd2a5b1306a61a70e91112ebe08 (patch) | |
tree | 21d81a1fcaefb92d15a6fce353a6bee5ff58824a | |
parent | d9dd018705a7ae2bac2afd2b6db7e0aaaac530c7 (diff) |
refactor out to limit scope: FN_UNO_CATEGORY
Change-Id: I00c4f6269f80e6bc6eb924e02932b1c22b101dfc
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 544bc4f45436..fc52c1bb0666 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2099,6 +2099,30 @@ uno::Any SwXStyle::GetStyleProperty<FN_UNO_PARA_STYLE_CONDITIONS>(const SfxItemP } return uno::makeAny(aSeq); } +template<> +uno::Any SwXStyle::GetStyleProperty<FN_UNO_CATEGORY>(const SfxItemPropertySimpleEntry&, const SfxItemPropertySet&, SwStyleBase_Impl& rBase) + throw(uno::RuntimeException, std::exception) +{ + using paragraphstyle_t = std::remove_const<decltype(style::ParagraphStyleCategory::TEXT)>::type; + using paragraphcorestyle_t = sal_Int16; + static std::unique_ptr<std::map<paragraphstyle_t, paragraphcorestyle_t>> pUnoToCore; + if(!pUnoToCore) + { + pUnoToCore.reset(new std::map<paragraphcorestyle_t, paragraphstyle_t> { + { COLL_TEXT_BITS, style::ParagraphStyleCategory::TEXT }, + { COLL_DOC_BITS, style::ParagraphStyleCategory::CHAPTER }, + { COLL_LISTS_BITS, style::ParagraphStyleCategory::LIST }, + { COLL_REGISTER_BITS, style::ParagraphStyleCategory::INDEX }, + { COLL_EXTRA_BITS, style::ParagraphStyleCategory::EXTRA }, + { COLL_HTML_BITS, style::ParagraphStyleCategory::HTML } + }); + } + const sal_uInt16 nPoolId = rBase.getNewBase()->GetCollection()->GetPoolFormatId(); + const auto pUnoToCoreIt(pUnoToCore->find(COLL_GET_RANGE_BITS & nPoolId)); + if(pUnoToCoreIt == pUnoToCore->end()) + return uno::makeAny<sal_Int16>(-1); + return uno::makeAny(pUnoToCoreIt->second); +} uno::Any SwXStyle::lcl_GetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase) throw(uno::RuntimeException, std::exception) { @@ -2171,33 +2195,7 @@ uno::Any SwXStyle::lcl_GetStyleProperty(const SfxItemPropertySimpleEntry& rEntry } case FN_UNO_CATEGORY: { - const sal_uInt16 nPoolId = rBase.getNewBase()->GetCollection()->GetPoolFormatId(); - short nRet = -1; - - switch ( COLL_GET_RANGE_BITS & nPoolId ) - { - case COLL_TEXT_BITS: - nRet = style::ParagraphStyleCategory::TEXT; - break; - case COLL_DOC_BITS: - nRet = style::ParagraphStyleCategory::CHAPTER; - break; - case COLL_LISTS_BITS: - nRet = style::ParagraphStyleCategory::LIST; - break; - case COLL_REGISTER_BITS: - nRet = style::ParagraphStyleCategory::INDEX; - break; - case COLL_EXTRA_BITS: - nRet = style::ParagraphStyleCategory::EXTRA; - break; - case COLL_HTML_BITS: - nRet = style::ParagraphStyleCategory::HTML; - break; - } - - aRet <<= nRet; - break; + return GetStyleProperty<FN_UNO_CATEGORY>(rEntry, rPropSet, rBase); } case SID_SWREGISTER_COLLECTION: { |