summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2016-03-13 01:33:28 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2016-03-17 23:54:43 +0100
commitd9dd018705a7ae2bac2afd2b6db7e0aaaac530c7 (patch)
tree3bde7692841c02970cf595804b67d01d1d9dbaf0 /sw
parent2fea23f13fbc285b749cf0645ed418aa68d34e39 (diff)
refactor out to limit scope: FN_UNO_PARA_STYLE_CONDITIONS
Change-Id: Id9c0347f11837482d8d9a2cb2c6e97c2c6eb87e4
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/unocore/unostyle.cxx60
1 files changed, 31 insertions, 29 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index b244470222b5..544bc4f45436 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -2069,12 +2069,40 @@ uno::Any SwXStyle::GetStyleProperty<FN_UNO_DISPLAY_NAME>(const SfxItemPropertySi
{
return uno::makeAny(rBase.getNewBase()->GetDisplayName());
}
-
+template<>
+uno::Any SwXStyle::GetStyleProperty<FN_UNO_PARA_STYLE_CONDITIONS>(const SfxItemPropertySimpleEntry&, const SfxItemPropertySet&, SwStyleBase_Impl&)
+ throw(uno::RuntimeException, std::exception)
+{
+ static_assert(COND_COMMAND_COUNT == 28, "invalid size of command count?");
+ uno::Sequence<beans::NamedValue> aSeq(COND_COMMAND_COUNT);
+ sal_uInt16 nIndex = 0;
+ for(auto& rNV : aSeq)
+ {
+ rNV.Name = GetCommandContextByIndex(nIndex++);
+ rNV.Value = uno::makeAny(OUString());
+ }
+ SwFormat* pFormat = static_cast<SwDocStyleSheet*>(GetStyleSheetBase())->GetCollection();
+ if(pFormat && RES_CONDTXTFMTCOLL == pFormat->Which())
+ {
+ const CommandStruct* pCmds = SwCondCollItem::GetCmds();
+ beans::NamedValue* pSeq = aSeq.getArray();
+ for(sal_uInt16 n = 0; n < COND_COMMAND_COUNT; ++n)
+ {
+ const SwCollCondition* pCond = static_cast<SwConditionTextFormatColl*>(pFormat)->HasCondition(SwCollCondition(nullptr, pCmds[n].nCnd, pCmds[n].nSubCond));
+ if(!pCond || !pCond->GetTextFormatColl())
+ continue;
+ // get programmatic style name from UI style name
+ OUString aStyleName = pCond->GetTextFormatColl()->GetName();
+ SwStyleNameMapper::FillProgName(aStyleName, aStyleName, lcl_GetSwEnumFromSfxEnum(GetFamily()), true);
+ pSeq[n].Value = uno::makeAny(aStyleName);
+ }
+ }
+ return uno::makeAny(aSeq);
+}
uno::Any SwXStyle::lcl_GetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase)
throw(uno::RuntimeException, std::exception)
{
SwDoc* pDoc = GetDoc();
- SfxStyleFamily eFamily = GetFamily();
SfxStyleSheetBase* pBase(GetStyleSheetBase());
uno::Any aRet;
@@ -2139,33 +2167,7 @@ uno::Any SwXStyle::lcl_GetStyleProperty(const SfxItemPropertySimpleEntry& rEntry
}
case FN_UNO_PARA_STYLE_CONDITIONS:
{
- OSL_ENSURE(COND_COMMAND_COUNT == 28,
- "invalid size of command count?");
- uno::Sequence< beans::NamedValue > aSeq(COND_COMMAND_COUNT);
- beans::NamedValue *pSeq = aSeq.getArray();
-
- SwFormat *pFormat = static_cast<SwDocStyleSheet*>(pBase)->GetCollection();
- const CommandStruct *pCmds = SwCondCollItem::GetCmds();
- for (sal_uInt16 n = 0; n < COND_COMMAND_COUNT; ++n)
- {
- OUString aStyleName;
-
- const SwCollCondition* pCond = nullptr;
- if( pFormat && RES_CONDTXTFMTCOLL == pFormat->Which() &&
- nullptr != ( pCond = static_cast<SwConditionTextFormatColl*>(pFormat)->
- HasCondition( SwCollCondition( nullptr, pCmds[n].nCnd, pCmds[n].nSubCond ) ) )
- && pCond->GetTextFormatColl() )
- {
- // get programmatic style name from UI style name
- aStyleName = pCond->GetTextFormatColl()->GetName();
- SwStyleNameMapper::FillProgName(aStyleName, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
- }
-
- pSeq[n].Name = GetCommandContextByIndex(n);
- pSeq[n].Value <<= aStyleName;
- }
- aRet <<= aSeq;
- break;
+ return GetStyleProperty<FN_UNO_PARA_STYLE_CONDITIONS>(rEntry, rPropSet, rBase);
}
case FN_UNO_CATEGORY:
{