summaryrefslogtreecommitdiff
path: root/xmloff
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 /xmloff
parent2c7ec52b028ea389c6a1c6ce2ee9b6e83566a4e8 (diff)
xmloff,sw: some stylistic cleanup to conditional styles
Change-Id: I1722a0b3d67a7c8740daa5a131d7800319ee2373
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/style/prstylecond.cxx21
-rw-r--r--xmloff/source/style/styleexp.cxx17
2 files changed, 18 insertions, 20 deletions
diff --git a/xmloff/source/style/prstylecond.cxx b/xmloff/source/style/prstylecond.cxx
index 4568c6bc88b2..63b7e3ace250 100644
--- a/xmloff/source/style/prstylecond.cxx
+++ b/xmloff/source/style/prstylecond.cxx
@@ -23,12 +23,14 @@
using namespace ::xmloff::token;
-static struct ConditionMap
+// note: keep this in sync with the list of conditions in sw/source/uibase/chrdlg/ccoll.cxx
+
+static const struct ConditionMap
{
char const* aInternal;
XMLTokenEnum nExternal;
int aValue;
-} aConditionMap[] =
+} g_ConditionMap[] =
{
{ "TableHeader", XML_TABLE_HEADER, -1 },
{ "Table", XML_TABLE, -1 },
@@ -60,27 +62,24 @@ static struct ConditionMap
{ "NumberingLevel10", XML_LIST_LEVEL, 10 }
};
-#define CONDITION_COUNT (sizeof(aConditionMap) / sizeof(aConditionMap[0]))
-
OUString GetParaStyleCondExternal( OUString const &internal)
{
- unsigned i;
-
- for(i = 0; i < CONDITION_COUNT; ++i)
+ for (size_t i = 0; i < SAL_N_ELEMENTS(g_ConditionMap); ++i)
{
- if(internal.compareToAscii( aConditionMap[i].aInternal ) == 0)
+ if (internal.compareToAscii( g_ConditionMap[i].aInternal ) == 0)
{
- OUString aResult( GetXMLToken( aConditionMap[i].nExternal ) );
+ OUString aResult( GetXMLToken( g_ConditionMap[i].nExternal ) );
aResult += "()";
- if( aConditionMap[i].aValue != -1 )
+ if (g_ConditionMap[i].aValue != -1)
{
aResult += "=";
- aResult += OUString::number( aConditionMap[i].aValue );
+ aResult += OUString::number( g_ConditionMap[i].aValue );
}
return aResult;
}
}
+ assert(!"GetParaStyleCondExternal: model has unknown style condition");
return OUString();
}
diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx
index bd8588a1928a..4795aa32b19f 100644
--- a/xmloff/source/style/styleexp.cxx
+++ b/xmloff/source/style/styleexp.cxx
@@ -80,30 +80,29 @@ void XMLStyleExport::exportStyleAttributes( const Reference< XStyle >& )
void XMLStyleExport::exportStyleContent( const Reference< XStyle >& rStyle )
{
Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
+ assert(xPropSet.is());
try
{
uno::Any aProperty = xPropSet->getPropertyValue( "ParaStyleConditions" );
uno::Sequence< beans::NamedValue > aSeq;
- int i;
aProperty >>= aSeq;
- for(i = 0; i < aSeq.getLength(); ++i)
+ for (sal_Int32 i = 0; i < aSeq.getLength(); ++i)
{
- beans::NamedValue const& aNamedCond = aSeq[i];
+ beans::NamedValue const& rNamedCond = aSeq[i];
OUString aStyleName;
- if ( aNamedCond.Value >>= aStyleName )
+ if (rNamedCond.Value >>= aStyleName)
{
- if ( aStyleName.getLength() > 0 )
+ if (!aStyleName.isEmpty())
{
- OUString aExternal = GetParaStyleCondExternal( aNamedCond.Name );
+ OUString aExternal = GetParaStyleCondExternal(rNamedCond.Name);
- if (aExternal.getLength() > 0)
+ if (!aExternal.isEmpty())
{
- bool bEncoded;
-
+ bool bEncoded;
GetExport().AddAttribute( XML_NAMESPACE_STYLE,
XML_CONDITION,