summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-09-20 14:29:10 +0200
committerMichael Stahl <mstahl@redhat.com>2017-09-20 15:17:53 +0200
commit0ae13c77b6b20c2b58131fd21fea0ffce2a7a825 (patch)
treee3aa8f57d240c4b207107ab8eb39535d00a5f8b5 /sw
parent2c7ec52b028ea389c6a1c6ce2ee9b6e83566a4e8 (diff)
xmloff,sw: some stylistic cleanup to conditional styles
Change-Id: I1722a0b3d67a7c8740daa5a131d7800319ee2373
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/xml/xmlfmt.cxx40
-rw-r--r--sw/source/uibase/chrdlg/ccoll.cxx2
2 files changed, 24 insertions, 18 deletions
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index 8f60091126c1..904a102722b1 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -311,36 +311,40 @@ SwXMLTextStyleContext_Impl::Finish( bool bOverwrite )
if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() && xNewStyle.is() )
{
- CommandStruct const *aCommands = SwCondCollItem::GetCmds();
+ CommandStruct const*const pCommands = SwCondCollItem::GetCmds();
Reference< XPropertySet > xPropSet( xNewStyle, UNO_QUERY );
uno::Sequence< beans::NamedValue > aSeq( pConditions->size() );
- std::vector<rtl::Reference<SwXMLConditionContext_Impl>>::size_type i;
- unsigned j;
-
- for( i = 0; i < pConditions->size(); ++i )
+ for (std::vector<rtl::Reference<SwXMLConditionContext_Impl>>::size_type i = 0;
+ i < pConditions->size(); ++i)
{
- if( (*pConditions)[i]->IsValid() )
- {
- Master_CollCondition nCond = (*pConditions)[i]->getCondition();
- sal_uInt32 nSubCond = (*pConditions)[i]->getSubCondition();
+ assert((*pConditions)[i]->IsValid()); // checked before inserting
+ Master_CollCondition nCond = (*pConditions)[i]->getCondition();
+ sal_uInt32 nSubCond = (*pConditions)[i]->getSubCondition();
- for( j = 0; j < COND_COMMAND_COUNT; ++j )
+ for (size_t j = 0; j < COND_COMMAND_COUNT; ++j)
+ {
+ if (pCommands[j].nCnd == nCond &&
+ pCommands[j].nSubCond == nSubCond)
{
- if( aCommands[j].nCnd == nCond &&
- aCommands[j].nSubCond == nSubCond )
- {
- aSeq[i].Name = GetCommandContextByIndex( j );
- aSeq[i].Value <<= GetImport().GetStyleDisplayName( GetFamily(), (*pConditions)[i]->getApplyStyle() );
- break;
- }
+ aSeq[i].Name = GetCommandContextByIndex( j );
+ aSeq[i].Value <<= GetImport().GetStyleDisplayName(
+ GetFamily(), (*pConditions)[i]->getApplyStyle() );
+ break;
}
}
}
- xPropSet->setPropertyValue( UNO_NAME_PARA_STYLE_CONDITIONS, uno::makeAny( aSeq ) );
+ try
+ {
+ xPropSet->setPropertyValue(UNO_NAME_PARA_STYLE_CONDITIONS, uno::makeAny(aSeq));
+ }
+ catch (uno::Exception const& e)
+ {
+ SAL_WARN("sw.xml", "exception when setting ParaStyleConditions: " << e.Message);
+ }
}
XMLTextStyleContext::Finish( bOverwrite );
}
diff --git a/sw/source/uibase/chrdlg/ccoll.cxx b/sw/source/uibase/chrdlg/ccoll.cxx
index d4b617b12d9b..58f77f5770db 100644
--- a/sw/source/uibase/chrdlg/ccoll.cxx
+++ b/sw/source/uibase/chrdlg/ccoll.cxx
@@ -41,6 +41,8 @@
//!! order of entries has to be the same as in
//!! CommandStruct SwCondCollItem::aCmds[]
+// note: also keep this in sync with the list of conditions in xmloff/source/style/prstylecond.cxx
+
const char * const aCommandContext[COND_COMMAND_COUNT] =
{
"TableHeader",