diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-11-29 11:30:00 +0000 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-29 19:43:55 +0100 |
commit | 20b8522e6c40625e662a2225521881f5c029fd90 (patch) | |
tree | 8e491a5e29e23eef82c3936dc6a9bc1dcca70527 /sd | |
parent | cc56ccc8cd16949e95696f131abb9717e09046c1 (diff) |
tdf#121795 bogus checks on depth limit
nDepth is only set in ParagraphObj::ImplGetParagraphValues
where the limit is checked, so the checks elsewhere are
unnecessary, and aren't comprehensive anyway
Change-Id: I566335da6b0cf13a76dcb247ad45c8b551af4456
Reviewed-on: https://gerrit.libreoffice.org/64223
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/filter/eppt/epptso.cxx | 44 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptx-stylesheet.cxx | 2 |
2 files changed, 17 insertions, 29 deletions
diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx index 5d0c51c6ccec..895c4b16c6b0 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -664,7 +664,6 @@ void PPTWriter::ImplWriteParagraphs( SvStream& rOut, TextObj& rTextObj ) bool bFirstParagraph = true; sal_uInt32 nCharCount; sal_uInt32 nPropertyFlags = 0; - sal_uInt16 nDepth = 0; sal_Int16 nLineSpacing; int nInstance = rTextObj.GetInstance(); @@ -674,10 +673,6 @@ void PPTWriter::ImplWriteParagraphs( SvStream& rOut, TextObj& rTextObj ) const PortionObj& rPortion = pPara->front(); nCharCount = pPara->CharacterCount(); - nDepth = pPara->nDepth; - if ( nDepth > 4) - nDepth = 4; - if ( ( pPara->meTextAdjust == css::beans::PropertyState_DIRECT_VALUE ) || ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, ParaAttr_Adjust, pPara->mnTextAdjust ) ) ) nPropertyFlags |= 0x00000800; @@ -727,7 +722,7 @@ void PPTWriter::ImplWriteParagraphs( SvStream& rOut, TextObj& rTextObj ) ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, ParaAttr_UpperDist, pPara->mbParagraphPunctation ? 1 : 0 ) ) ) nPropertyFlags |= 0x00080000; if ( ( pPara->meBiDi == css::beans::PropertyState_DIRECT_VALUE ) || - ( mpStyleSheet->IsHardAttribute( nInstance, nDepth, ParaAttr_BiDi, pPara->mnBiDi ) ) ) + ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, ParaAttr_BiDi, pPara->mnBiDi ) ) ) nPropertyFlags |= 0x00200000; sal_Int32 nBuRealSize = pPara->nBulletRealSize; @@ -742,16 +737,16 @@ void PPTWriter::ImplWriteParagraphs( SvStream& rOut, TextObj& rTextObj ) } // Write nTextOfs and nBullets - if ( mpStyleSheet->IsHardAttribute( nInstance, nDepth, ParaAttr_TextOfs, pPara->nTextOfs ) ) + if ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, ParaAttr_TextOfs, pPara->nTextOfs ) ) nPropertyFlags |= 0x100; - if ( mpStyleSheet->IsHardAttribute( nInstance, nDepth, ParaAttr_BulletOfs, pPara->nBulletOfs )) + if ( mpStyleSheet->IsHardAttribute( nInstance, pPara->nDepth, ParaAttr_BulletOfs, pPara->nBulletOfs )) nPropertyFlags |= 0x400; FontCollectionEntry aFontDescEntry( pPara->aFontDesc.Name, pPara->aFontDesc.Family, pPara->aFontDesc.Pitch, pPara->aFontDesc.CharSet ); sal_uInt16 nFontId = static_cast<sal_uInt16>(maFontCollection.GetId( aFontDescEntry )); rOut.WriteUInt32( nCharCount ) - .WriteUInt16( nDepth ) // Level + .WriteUInt16( pPara->nDepth ) // Level .WriteUInt32( nPropertyFlags ); // Paragraph Attribut Set if ( nPropertyFlags & 0xf ) @@ -1213,7 +1208,7 @@ void PPTWriter::ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_u { pPara = aTextObj.GetParagraph(0); sal_uInt32 nParaFlags = 0x1f; - sal_Int16 nDepth, nMask, nNumberingRule[ 10 ]; + sal_Int16 nMask, nNumberingRule[ 10 ]; sal_uInt32 nTextOfs = pPara->nTextOfs; sal_uInt32 nTabs = pPara->maTabStop.getLength(); const css::style::TabStop* pTabStop = pPara->maTabStop.getConstArray(); @@ -1223,20 +1218,16 @@ void PPTWriter::ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_u pPara = aTextObj.GetParagraph(i); if ( pPara->bExtendedParameters ) { - nDepth = pPara->nDepth; - if ( nDepth < 5 ) + nMask = 1 << pPara->nDepth; + if ( nParaFlags & nMask ) { - nMask = 1 << nDepth; - if ( nParaFlags & nMask ) + nParaFlags &=~ nMask; + if ( ( rParaSheet.maParaLevel[ pPara->nDepth ].mnTextOfs != pPara->nTextOfs ) || + ( rParaSheet.maParaLevel[ pPara->nDepth ].mnBulletOfs != pPara->nBulletOfs ) ) { - nParaFlags &=~ nMask; - if ( ( rParaSheet.maParaLevel[ nDepth ].mnTextOfs != pPara->nTextOfs ) || - ( rParaSheet.maParaLevel[ nDepth ].mnBulletOfs != pPara->nBulletOfs ) ) - { - nParaFlags |= nMask << 16; - nNumberingRule[ nDepth << 1 ] = pPara->nTextOfs; - nNumberingRule[ ( nDepth << 1 ) + 1 ] = static_cast<sal_Int16>(pPara->nBulletOfs); - } + nParaFlags |= nMask << 16; + nNumberingRule[ pPara->nDepth << 1 ] = pPara->nTextOfs; + nNumberingRule[ ( pPara->nDepth << 1 ) + 1 ] = static_cast<sal_Int16>(pPara->nBulletOfs); } } } @@ -2445,13 +2436,8 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a for ( sal_uInt32 i = 0; i < aTextObj.ParagraphCount() ; ++i ) { ParagraphObj* pPara = aTextObj.GetParagraph(i); - sal_uInt32 nCharCount = pPara->CharacterCount(); - sal_uInt16 nDepth = pPara->nDepth; - if ( nDepth > 4) - nDepth = 4; - - mpStrm->WriteUInt32( nCharCount ) - .WriteUInt16( nDepth ); + mpStrm->WriteUInt32( pPara->CharacterCount() ) + .WriteUInt16( pPara->nDepth ); } mpPptEscherEx->EndAtom( EPP_BaseTextPropAtom ); mpPptEscherEx->AddAtom( 10, EPP_TextSpecInfoAtom ); diff --git a/sd/source/filter/eppt/pptx-stylesheet.cxx b/sd/source/filter/eppt/pptx-stylesheet.cxx index 0fb26bfe74f2..1548a18f2da8 100644 --- a/sd/source/filter/eppt/pptx-stylesheet.cxx +++ b/sd/source/filter/eppt/pptx-stylesheet.cxx @@ -411,6 +411,8 @@ void PPTExStyleSheet::SetStyleSheet( const css::uno::Reference< css::beans::XPro bool PPTExStyleSheet::IsHardAttribute( sal_uInt32 nInstance, sal_uInt32 nLevel, PPTExTextAttr eAttr, sal_uInt32 nValue ) { + assert(nInstance < PPTEX_STYLESHEETENTRYS && nLevel < 5); + const PPTExParaLevel& rPara = mpParaSheet[ nInstance ]->maParaLevel[ nLevel ]; const PPTExCharLevel& rChar = mpCharSheet[ nInstance ]->maCharLevel[ nLevel ]; |