Kaydet (Commit) 469430a7 authored tarafından Caolán McNamara's avatar Caolán McNamara

rtf: null-deref

Change-Id: I9c4510cb91e2572a3ab2b62497dc4dd9fd1119c8
Reviewed-on: https://gerrit.libreoffice.org/49319Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst e5012e53
...@@ -863,6 +863,7 @@ void ListsManager::lcl_sprm( Sprm& rSprm ) ...@@ -863,6 +863,7 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
} }
break; break;
case NS_ooxml::LN_CT_Lvl_lvlPicBulletId: case NS_ooxml::LN_CT_Lvl_lvlPicBulletId:
if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel())
{ {
uno::Reference<drawing::XShape> xShape; uno::Reference<drawing::XShape> xShape;
for (std::vector<NumPicBullet::Pointer>::iterator it = m_aNumPicBullets.begin(); it != m_aNumPicBullets.end(); ++it) for (std::vector<NumPicBullet::Pointer>::iterator it = m_aNumPicBullets.begin(); it != m_aNumPicBullets.end(); ++it)
...@@ -879,15 +880,15 @@ void ListsManager::lcl_sprm( Sprm& rSprm ) ...@@ -879,15 +880,15 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
try try
{ {
uno::Any aAny = xPropertySet->getPropertyValue("GraphicURL"); uno::Any aAny = xPropertySet->getPropertyValue("GraphicURL");
if (aAny.has<OUString>()) if (aAny.has<OUString>() && pCurrentLevel)
m_pCurrentDefinition->GetCurrentLevel()->SetGraphicURL(aAny.get<OUString>()); pCurrentLevel->SetGraphicURL(aAny.get<OUString>());
} catch(const beans::UnknownPropertyException&) } catch(const beans::UnknownPropertyException&)
{} {}
try try
{ {
uno::Reference< graphic::XGraphic > gr; uno::Reference< graphic::XGraphic > gr;
xPropertySet->getPropertyValue("Bitmap") >>= gr; xPropertySet->getPropertyValue("Bitmap") >>= gr;
m_pCurrentDefinition->GetCurrentLevel()->SetGraphicBitmap( gr ); pCurrentLevel->SetGraphicBitmap( gr );
} catch(const beans::UnknownPropertyException&) } catch(const beans::UnknownPropertyException&)
{} {}
...@@ -902,12 +903,12 @@ void ListsManager::lcl_sprm( Sprm& rSprm ) ...@@ -902,12 +903,12 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
int nWidth = (nHeight * aPrefSize.Width) / aPrefSize.Height; int nWidth = (nHeight * aPrefSize.Width) / aPrefSize.Height;
awt::Size aSize( convertMm100ToTwip(nWidth), convertMm100ToTwip(nHeight) ); awt::Size aSize( convertMm100ToTwip(nWidth), convertMm100ToTwip(nHeight) );
m_pCurrentDefinition->GetCurrentLevel()->SetGraphicSize( aSize ); pCurrentLevel->SetGraphicSize( aSize );
} }
else else
{ {
awt::Size aSize( convertMm100ToTwip(aPrefSize.Width), convertMm100ToTwip(aPrefSize.Height) ); awt::Size aSize( convertMm100ToTwip(aPrefSize.Width), convertMm100ToTwip(aPrefSize.Height) );
m_pCurrentDefinition->GetCurrentLevel()->SetGraphicSize( aSize ); pCurrentLevel->SetGraphicSize( aSize );
} }
} }
} }
...@@ -938,26 +939,26 @@ void ListsManager::lcl_sprm( Sprm& rSprm ) ...@@ -938,26 +939,26 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
} }
break; break;
case NS_ooxml::LN_CT_Lvl_start: case NS_ooxml::LN_CT_Lvl_start:
if (m_pCurrentDefinition->GetCurrentLevel().get()) if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel())
m_pCurrentDefinition->GetCurrentLevel( )->SetValue( nSprmId, nIntValue ); pCurrentLevel->SetValue( nSprmId, nIntValue );
bIsStartVisited = true; bIsStartVisited = true;
break; break;
case NS_ooxml::LN_CT_Lvl_numFmt: case NS_ooxml::LN_CT_Lvl_numFmt:
case NS_ooxml::LN_CT_Lvl_isLgl: case NS_ooxml::LN_CT_Lvl_isLgl:
case NS_ooxml::LN_CT_Lvl_legacy: case NS_ooxml::LN_CT_Lvl_legacy:
if (m_pCurrentDefinition->GetCurrentLevel().get()) if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel())
{ {
m_pCurrentDefinition->GetCurrentLevel( )->SetValue( nSprmId, nIntValue ); pCurrentLevel->SetValue( nSprmId, nIntValue );
if( !bIsStartVisited ) if( !bIsStartVisited )
{ {
m_pCurrentDefinition->GetCurrentLevel( )->SetValue( NS_ooxml::LN_CT_Lvl_start, 0 ); pCurrentLevel->SetValue( NS_ooxml::LN_CT_Lvl_start, 0 );
bIsStartVisited = true; bIsStartVisited = true;
} }
} }
break; break;
case NS_ooxml::LN_CT_Lvl_suff: case NS_ooxml::LN_CT_Lvl_suff:
{ {
if (m_pCurrentDefinition->GetCurrentLevel().get()) if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel())
{ {
SvxNumberFormat::LabelFollowedBy value = SvxNumberFormat::LISTTAB; SvxNumberFormat::LabelFollowedBy value = SvxNumberFormat::LISTTAB;
if( rSprm.getValue()->getString() == "tab" ) if( rSprm.getValue()->getString() == "tab" )
...@@ -969,7 +970,7 @@ void ListsManager::lcl_sprm( Sprm& rSprm ) ...@@ -969,7 +970,7 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
else else
SAL_WARN( "writerfilter", "Unknown ST_LevelSuffix value " SAL_WARN( "writerfilter", "Unknown ST_LevelSuffix value "
<< rSprm.getValue()->getString()); << rSprm.getValue()->getString());
m_pCurrentDefinition->GetCurrentLevel()->SetValue( nSprmId, value ); pCurrentLevel->SetValue( nSprmId, value );
} }
} }
break; break;
...@@ -1006,13 +1007,17 @@ void ListsManager::lcl_sprm( Sprm& rSprm ) ...@@ -1006,13 +1007,17 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
nValue = text::HoriOrientation::RIGHT; nValue = text::HoriOrientation::RIGHT;
break; break;
} }
if (nValue != text::HoriOrientation::NONE) if (nValue != text::HoriOrientation::NONE)
{ {
m_pCurrentDefinition->GetCurrentLevel( )->Insert( if (ListLevel::Pointer pLevel = m_pCurrentDefinition->GetCurrentLevel())
{
pLevel->Insert(
PROP_ADJUST, uno::makeAny( nValue ) ); PROP_ADJUST, uno::makeAny( nValue ) );
writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
} }
} }
}
break; break;
case NS_ooxml::LN_CT_Lvl_pPr: case NS_ooxml::LN_CT_Lvl_pPr:
case NS_ooxml::LN_CT_PPrBase_ind: case NS_ooxml::LN_CT_PPrBase_ind:
...@@ -1034,11 +1039,13 @@ void ListsManager::lcl_sprm( Sprm& rSprm ) ...@@ -1034,11 +1039,13 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
case NS_ooxml::LN_CT_Lvl_pStyle: case NS_ooxml::LN_CT_Lvl_pStyle:
{ {
OUString sStyleName = rSprm.getValue( )->getString( ); OUString sStyleName = rSprm.getValue( )->getString( );
ListLevel::Pointer pLevel = m_pCurrentDefinition->GetCurrentLevel( ); if (ListLevel::Pointer pLevel = m_pCurrentDefinition->GetCurrentLevel())
{
StyleSheetTablePtr pStylesTable = m_rDMapper.GetStyleSheetTable( ); StyleSheetTablePtr pStylesTable = m_rDMapper.GetStyleSheetTable( );
const StyleSheetEntryPtr pStyle = pStylesTable->FindStyleSheetByISTD( sStyleName ); const StyleSheetEntryPtr pStyle = pStylesTable->FindStyleSheetByISTD( sStyleName );
pLevel->SetParaStyle( pStyle ); pLevel->SetParaStyle( pStyle );
} }
}
break; break;
case NS_ooxml::LN_CT_Num_lvlOverride: case NS_ooxml::LN_CT_Num_lvlOverride:
{ {
...@@ -1052,11 +1059,13 @@ void ListsManager::lcl_sprm( Sprm& rSprm ) ...@@ -1052,11 +1059,13 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
if(m_pCurrentDefinition) if(m_pCurrentDefinition)
{ {
if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel()) if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel())
{
// <w:num> -> <w:lvlOverride> -> <w:startOverride> is the non-abstract equivalent of // <w:num> -> <w:lvlOverride> -> <w:startOverride> is the non-abstract equivalent of
// <w:abstractNum> -> <w:lvl> -> <w:start> // <w:abstractNum> -> <w:lvl> -> <w:start>
pCurrentLevel->SetValue(NS_ooxml::LN_CT_Lvl_start, nIntValue); pCurrentLevel->SetValue(NS_ooxml::LN_CT_Lvl_start, nIntValue);
} }
} }
}
break; break;
case NS_ooxml::LN_CT_AbstractNum_numStyleLink: case NS_ooxml::LN_CT_AbstractNum_numStyleLink:
{ {
...@@ -1072,9 +1081,9 @@ void ListsManager::lcl_sprm( Sprm& rSprm ) ...@@ -1072,9 +1081,9 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
case NS_ooxml::LN_EG_RPrBase_eastAsianLayout: case NS_ooxml::LN_EG_RPrBase_eastAsianLayout:
//no break! //no break!
default: default:
if( m_pCurrentDefinition->GetCurrentLevel( ).get()) if (ListLevel::Pointer pCurrentLevel = m_pCurrentDefinition->GetCurrentLevel())
{ {
m_rDMapper.PushListProperties( m_pCurrentDefinition->GetCurrentLevel( ) ); m_rDMapper.PushListProperties(pCurrentLevel);
m_rDMapper.sprm( rSprm ); m_rDMapper.sprm( rSprm );
m_rDMapper.PopListProperties(); m_rDMapper.PopListProperties();
} }
......
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