[Libreoffice-commits] core.git: filter/source

Caolán McNamara caolanm at redhat.com
Fri Apr 7 09:01:04 UTC 2017


 filter/source/msfilter/svdfppt.cxx |   34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

New commits:
commit 6c401a7bdc4e0f5340203b9885e368cb96986aa1
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sat Mar 18 12:47:02 2017 +0000

    ofz#893 limit para depth to max legal ppt level
    
    Change-Id: Ie7c287964b126d143a0eeb14be53addc7c34b87f
    Reviewed-on: https://gerrit.libreoffice.org/35402
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 088b01766a26..dfd8148bf699 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -5824,6 +5824,19 @@ SvxFieldItem* PPTPortionObj::GetTextField()
     return nullptr;
 }
 
+namespace
+{
+    sal_uInt16 sanitizeForMaxPPTLevels(sal_uInt16 nDepth)
+    {
+        if (nDepth >= nMaxPPTLevels)
+        {
+            SAL_WARN("filter.ms", "Para Style Sheet depth " << nDepth << " but " << nMaxPPTLevels - 1 << " is max possible");
+            nDepth = nMaxPPTLevels - 1;
+        }
+        return nDepth;
+    }
+}
+
 PPTParagraphObj::PPTParagraphObj( const PPTStyleSheet& rStyleSheet, TSS_Type nInstance, sal_uInt16 nDepth ) :
     PPTNumberFormatCreator  ( nullptr ),
     mrStyleSheet            ( rStyleSheet ),
@@ -5831,9 +5844,7 @@ PPTParagraphObj::PPTParagraphObj( const PPTStyleSheet& rStyleSheet, TSS_Type nIn
     mbTab                   ( true ),      // style sheets always have to get the right tabulator setting
     mnCurrentObject         ( 0 )
 {
-    if ( nDepth > 4 )
-        nDepth = 4;
-    pParaSet->mnDepth = nDepth;
+    pParaSet->mnDepth = sanitizeForMaxPPTLevels(nDepth);
 }
 
 PPTParagraphObj::PPTParagraphObj( PPTStyleTextPropReader& rPropReader,
@@ -5898,7 +5909,9 @@ void PPTParagraphObj::UpdateBulletRelSize( sal_uInt32& nBulletRelSize ) const
         }
         // if we do not have a hard attributed fontheight, the fontheight is taken from the style
         if ( !nFontHeight )
-            nFontHeight = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[ pParaSet->mnDepth ].mnFontHeight;
+        {
+            nFontHeight = mrStyleSheet.mpCharSheet[ mnInstance ]->maCharLevel[sanitizeForMaxPPTLevels(pParaSet->mnDepth)].mnFontHeight;
+        }
         nBulletRelSize = nFontHeight ? ((-((sal_Int16)nBulletRelSize)) * 100 ) / nFontHeight : 100;
     }
 }
@@ -5916,13 +5929,7 @@ bool PPTParagraphObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& rRetValue, TSS_Ty
 
     bool bIsHardAttribute = ( ( pParaSet->mnAttrSet & nMask ) != 0 );
 
-    sal_uInt16 nDepth = pParaSet->mnDepth;
-
-    if (nDepth >= nMaxPPTLevels)
-    {
-        SAL_WARN("filter.ms", "Para Style Sheet depth " << nDepth << " but " << nMaxPPTLevels - 1 << " is max possible");
-        nDepth = nMaxPPTLevels - 1;
-    }
+    sal_uInt16 nDepth = sanitizeForMaxPPTLevels(pParaSet->mnDepth);
 
     if ( bIsHardAttribute )
     {
@@ -6202,12 +6209,11 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet,  boost::optional< sal_Int16 >&
                 if ( pRule )
                 {
                     pRule->SetLevel( pParaSet->mnDepth, aNumberFormat );
-                    sal_uInt16 i, n;
-                    for ( i = 0; i < pRule->GetLevelCount(); i++ )
+                    for (sal_uInt16 i = 0; i < pRule->GetLevelCount(); ++i)
                     {
                         if ( i != pParaSet->mnDepth )
                         {
-                            n = i > 4 ? 4 : i;
+                            sal_uInt16 n = sanitizeForMaxPPTLevels(i);
 
                             SvxNumberFormat aNumberFormat2( pRule->GetLevel( i ) );
                             const PPTParaLevel& rParaLevel = mrStyleSheet.mpParaSheet[ nInstance ]->maParaLevel[ n ];


More information about the Libreoffice-commits mailing list