Kaydet (Commit) c75bddd7 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

reduce nesting in WriteParagraphNumbering

Change-Id: I49a3c3449d8354ce5e2a6e42414fbefdfc489388
üst 1edf2c0f
...@@ -1464,22 +1464,25 @@ inline static const char* GetAutoNumType( sal_Int16 nNumberingType, bool bSDot, ...@@ -1464,22 +1464,25 @@ inline static const char* GetAutoNumType( sal_Int16 nNumberingType, bool bSDot,
void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sal_Int16 nLevel ) void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sal_Int16 nLevel )
{ {
if( nLevel >= 0 && GETA( NumberingRules ) ) if( nLevel < 0 || !GETA( NumberingRules ) )
{ return;
Reference< XIndexAccess > rXIndexAccess; Reference< XIndexAccess > rXIndexAccess;
if ( ( mAny >>= rXIndexAccess ) && nLevel < rXIndexAccess->getCount() ) if (!(mAny >>= rXIndexAccess) || nLevel >= rXIndexAccess->getCount())
{ return;
DBG(fprintf (stderr, "numbering rules\n")); DBG(fprintf (stderr, "numbering rules\n"));
Sequence< PropertyValue > aPropertySequence; Sequence<PropertyValue> aPropertySequence;
rXIndexAccess->getByIndex( nLevel ) >>= aPropertySequence; rXIndexAccess->getByIndex(nLevel) >>= aPropertySequence;
const PropertyValue* pPropValue = aPropertySequence.getArray(); if (!aPropertySequence.hasElements())
return;
sal_Int32 nPropertyCount = aPropertySequence.getLength(); sal_Int32 nPropertyCount = aPropertySequence.getLength();
if ( nPropertyCount ) { const PropertyValue* pPropValue = aPropertySequence.getArray();
sal_Int16 nNumberingType = SVX_NUM_NUMBER_NONE; sal_Int16 nNumberingType = SVX_NUM_NUMBER_NONE;
bool bSDot = false; bool bSDot = false;
...@@ -1491,22 +1494,30 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa ...@@ -1491,22 +1494,30 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
OUString aGraphicURL; OUString aGraphicURL;
sal_Int16 nBulletRelSize = 0; sal_Int16 nBulletRelSize = 0;
for ( sal_Int32 i = 0; i < nPropertyCount; i++ ) { for ( sal_Int32 i = 0; i < nPropertyCount; i++ )
{
const void* pValue = pPropValue[ i ].Value.getValue(); const void* pValue = pPropValue[ i ].Value.getValue();
if ( pValue ) { if ( pValue )
{
OUString aPropName( pPropValue[ i ].Name ); OUString aPropName( pPropValue[ i ].Name );
DBG(fprintf (stderr, "pro name: %s\n", OUStringToOString( aPropName, RTL_TEXTENCODING_UTF8 ).getStr())); DBG(fprintf (stderr, "pro name: %s\n", OUStringToOString( aPropName, RTL_TEXTENCODING_UTF8 ).getStr()));
if ( aPropName == "NumberingType" ) if ( aPropName == "NumberingType" )
{
nNumberingType = *( (sal_Int16*)pValue ); nNumberingType = *( (sal_Int16*)pValue );
else if ( aPropName == "Prefix" ) { }
else if ( aPropName == "Prefix" )
{
if( *(OUString*)pValue == ")") if( *(OUString*)pValue == ")")
bPBoth = true; bPBoth = true;
} else if ( aPropName == "Suffix" ) { }
else if ( aPropName == "Suffix" )
{
if( *(OUString*)pValue == ".") if( *(OUString*)pValue == ".")
bSDot = true; bSDot = true;
else if( *(OUString*)pValue == ")") else if( *(OUString*)pValue == ")")
bPBehind = true; bPBehind = true;
} else if ( aPropName == "BulletChar" ) }
else if ( aPropName == "BulletChar" )
{ {
aBulletChar = OUString ( *( (OUString*)pValue ) )[ 0 ]; aBulletChar = OUString ( *( (OUString*)pValue ) )[ 0 ];
//printf ("bullet char: %d\n", aBulletChar.getStr()); //printf ("bullet char: %d\n", aBulletChar.getStr());
...@@ -1523,12 +1534,17 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa ...@@ -1523,12 +1534,17 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
if ( aFontDesc.Name.equalsIgnoreAsciiCase("StarSymbol") ) if ( aFontDesc.Name.equalsIgnoreAsciiCase("StarSymbol") )
aFontDesc.CharSet = RTL_TEXTENCODING_MS_1252; aFontDesc.CharSet = RTL_TEXTENCODING_MS_1252;
} else if ( aPropName == "BulletRelSize" ) { }
else if ( aPropName == "BulletRelSize" )
{
nBulletRelSize = *( (sal_Int16*)pValue ); nBulletRelSize = *( (sal_Int16*)pValue );
} else if ( aPropName == "GraphicURL" ) { }
else if ( aPropName == "GraphicURL" )
{
aGraphicURL = ( *(OUString*)pValue ); aGraphicURL = ( *(OUString*)pValue );
DBG(fprintf (stderr, "graphic url: %s\n", OUStringToOString( aGraphicURL, RTL_TEXTENCODING_UTF8 ).getStr())); DBG(fprintf (stderr, "graphic url: %s\n", OUStringToOString( aGraphicURL, RTL_TEXTENCODING_UTF8 ).getStr()));
} else if ( aPropName == "GraphicSize" ) }
else if ( aPropName == "GraphicSize" )
{ {
if ( pPropValue[ i ].Value.getValueType() == cppu::UnoType<awt::Size>::get()) if ( pPropValue[ i ].Value.getValueType() == cppu::UnoType<awt::Size>::get())
{ {
...@@ -1545,14 +1561,18 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa ...@@ -1545,14 +1561,18 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
const char* pAutoNumType = GetAutoNumType( nNumberingType, bSDot, bPBehind, bPBoth ); const char* pAutoNumType = GetAutoNumType( nNumberingType, bSDot, bPBehind, bPBoth );
if( nLevel >= 0 ) { if( nLevel >= 0 )
if( !aGraphicURL.isEmpty() ) { {
if( !aGraphicURL.isEmpty() )
{
OUString sRelId = WriteImage( aGraphicURL ); OUString sRelId = WriteImage( aGraphicURL );
mpFS->startElementNS( XML_a, XML_buBlip, FSEND ); mpFS->startElementNS( XML_a, XML_buBlip, FSEND );
mpFS->singleElementNS( XML_a, XML_blip, FSNS( XML_r, XML_embed ), USS( sRelId ), FSEND ); mpFS->singleElementNS( XML_a, XML_blip, FSNS( XML_r, XML_embed ), USS( sRelId ), FSEND );
mpFS->endElementNS( XML_a, XML_buBlip ); mpFS->endElementNS( XML_a, XML_buBlip );
} else { }
else
{
if( nBulletRelSize && nBulletRelSize != 100 ) if( nBulletRelSize && nBulletRelSize != 100 )
mpFS->singleElementNS( XML_a, XML_buSzPct, mpFS->singleElementNS( XML_a, XML_buSzPct,
XML_val, IS( std::max( (sal_Int32)25000, std::min( (sal_Int32)400000, 1000*( (sal_Int32)nBulletRelSize ) ) ) ), FSEND ); XML_val, IS( std::max( (sal_Int32)25000, std::min( (sal_Int32)400000, 1000*( (sal_Int32)nBulletRelSize ) ) ) ), FSEND );
...@@ -1564,15 +1584,13 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa ...@@ -1564,15 +1584,13 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
if( pAutoNumType ) if( pAutoNumType )
mpFS->singleElementNS( XML_a, XML_buAutoNum, XML_type, pAutoNumType, FSEND ); mpFS->singleElementNS( XML_a, XML_buAutoNum, XML_type, pAutoNumType, FSEND );
else { else
{
aBulletChar = SubstituteBullet( aBulletChar, aFontDesc ); aBulletChar = SubstituteBullet( aBulletChar, aFontDesc );
mpFS->singleElementNS( XML_a, XML_buChar, XML_char, USS( OUString( aBulletChar ) ), FSEND ); mpFS->singleElementNS( XML_a, XML_buChar, XML_char, USS( OUString( aBulletChar ) ), FSEND );
} }
} }
} }
}
}
}
} }
const char* DrawingML::GetAlignment( sal_Int32 nAlignment ) const char* DrawingML::GetAlignment( sal_Int32 nAlignment )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment