[Libreoffice-commits] core.git: 2 commits - filter/source include/filter sd/qa sd/source svtools/source

Caolán McNamara caolanm at redhat.com
Thu Aug 27 01:16:47 PDT 2015


 filter/source/msfilter/svdfppt.cxx     |   45 +++++++++++++++------------------
 include/filter/msfilter/dffpropset.hxx |    1 
 sd/qa/unit/data/ppt/pass/hang-3.ppt    |binary
 sd/source/core/TransitionPreset.cxx    |    4 ++
 sd/source/filter/ppt/pptin.cxx         |   35 +++++++++++++++----------
 svtools/source/graphic/grfmgr.cxx      |    3 ++
 6 files changed, 50 insertions(+), 38 deletions(-)

New commits:
commit c249f93d96ec87b0acbd25ffe087543d6fe9fb14
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Aug 27 09:13:42 2015 +0100

    extend seek, loop ending tests to ppt specific code
    
    Change-Id: Id4419b6b902b742117e248870b6a663c9c58955f

diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 2d65f8e..26cf78c 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -708,19 +708,16 @@ void SdrEscherImport::RecolorGraphic( SvStream& rSt, sal_uInt32 nRecLen, Graphic
     }
 }
 
-namespace
+sal_uLong DffPropSet::SanitizeEndPos(SvStream &rIn, sal_uLong nEndRecPos)
 {
-    sal_uLong SanitizeEndPos(SvStream &rIn, sal_uLong nEndRecPos)
+    auto nStreamLen = rIn.Tell() + rIn.remainingSize();
+    if (nEndRecPos > nStreamLen)
     {
-        auto nStreamLen = rIn.Tell() + rIn.remainingSize();
-        if (nEndRecPos > nStreamLen)
-        {
-            SAL_WARN("filter.ms", "Parsing error: " << nStreamLen <<
-                     " max end pos, but " << nEndRecPos << " claimed, truncating");
-            nEndRecPos = nStreamLen;
-        }
-        return nEndRecPos;
+        SAL_WARN("filter.ms", "Parsing error: " << nStreamLen <<
+                 " max end pos, but " << nEndRecPos << " claimed, truncating");
+        nEndRecPos = nStreamLen;
     }
+    return nEndRecPos;
 }
 
 /* ProcessObject is called from ImplSdPPTImport::ProcessObj to handle all application specific things,
@@ -2662,7 +2659,7 @@ void ImportComment10( SvxMSDffManager& rMan, SvStream& rStCtrl, SdrPage* pPage,
     sal_Int32       nPosY = 0;
 
 
-    auto nEndRecPos = SanitizeEndPos(rStCtrl, rComment10Hd.GetRecEndFilePos());
+    auto nEndRecPos = DffPropSet::SanitizeEndPos(rStCtrl, rComment10Hd.GetRecEndFilePos());
     while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < nEndRecPos ) )
     {
         DffRecordHeader aCommentHd;
@@ -3185,7 +3182,7 @@ PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const
         pListHd->SeekToContent( rSt );
     if ( pListHd && SdrPowerPointImport::SeekToContentOfProgTag( 9, rSt, *pListHd, aContentDataHd ) )
     {
-        auto nEndRecPos = SanitizeEndPos(rSt, aContentDataHd.GetRecEndFilePos());
+        auto nEndRecPos = DffPropSet::SanitizeEndPos(rSt, aContentDataHd.GetRecEndFilePos());
         while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < nEndRecPos ) )
         {
             ReadDffRecordHeader( rSt, aHd );
@@ -3193,7 +3190,7 @@ PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const
             {
                 case PPT_PST_ExtendedBuGraContainer :
                 {
-                    auto nHdEndRecPos = SanitizeEndPos(rSt, aHd.GetRecEndFilePos());
+                    auto nHdEndRecPos = DffPropSet::SanitizeEndPos(rSt, aHd.GetRecEndFilePos());
                     while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < nHdEndRecPos ) )
                     {
                         sal_uInt16 nType;
@@ -3265,7 +3262,7 @@ PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const
 
     if ( pHd && SdrPowerPointImport::SeekToContentOfProgTag( 9, rSt, *pHd, aContentDataHd ) )
     {   // get the extended paragraph styles on mainmaster ( graphical bullets, num ruling ... )
-        auto nEndRecPos = SanitizeEndPos(rSt, aContentDataHd.GetRecEndFilePos());
+        auto nEndRecPos = DffPropSet::SanitizeEndPos(rSt, aContentDataHd.GetRecEndFilePos());
         while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < nEndRecPos ) )
         {
             ReadDffRecordHeader( rSt, aHd );
@@ -3279,7 +3276,7 @@ PPTExtParaProv::PPTExtParaProv( SdrPowerPointImport& rMan, SvStream& rSt, const
                         rSt.ReadUInt16( nDepth );
                         if ( i <= 5 )
                         {
-                            auto nHdEndRecPos = SanitizeEndPos(rSt, aHd.GetRecEndFilePos());
+                            auto nHdEndRecPos = DffPropSet::SanitizeEndPos(rSt, aHd.GetRecEndFilePos());
                             while ( ( rSt.GetError() == 0 ) && ( rSt.Tell() < nHdEndRecPos ) && ( i < nDepth ) )
                             {
                                 bStyles = true;
@@ -4041,7 +4038,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
     {
         pEnvHeader->SeekToContent( rIn );
         DffRecordHeader aTxMasterStyleHd;
-        auto nEndRecPos = SanitizeEndPos(rIn, pEnvHeader->GetRecEndFilePos());
+        auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, pEnvHeader->GetRecEndFilePos());
         while (rIn.Tell() < nEndRecPos)
         {
             ReadDffRecordHeader( rIn, aTxMasterStyleHd );
@@ -4053,7 +4050,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
                 sal_uInt16 nLev = 0;
                 bool bFirst = true;
                 bFoundTxMasterStyleAtom04 = true;
-                auto nTxEndRecPos = SanitizeEndPos(rIn, aTxMasterStyleHd.GetRecEndFilePos());
+                auto nTxEndRecPos = DffPropSet::SanitizeEndPos(rIn, aTxMasterStyleHd.GetRecEndFilePos());
                 while (rIn.GetError() == 0 && rIn.Tell() < nTxEndRecPos && nLev < nLevelAnz && nLev < nMaxPPTLevels)
                 {
                     if ( nLev )
@@ -4092,7 +4089,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
     rSlideHd.SeekToContent( rIn );
 
     DffRecordHeader aTxMasterStyleHd;
-    auto nEndRecPos = SanitizeEndPos(rIn, rSlideHd.GetRecEndFilePos());
+    auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, rSlideHd.GetRecEndFilePos());
     while (rIn.Tell() < nEndRecPos)
     {
         ReadDffRecordHeader( rIn, aTxMasterStyleHd );
@@ -4151,7 +4148,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
             sal_uInt16  nLev = 0;
             bool    bFirst = true;
 
-            auto nTxEndRecPos = SanitizeEndPos(rIn, aTxMasterStyleHd.GetRecEndFilePos());
+            auto nTxEndRecPos = DffPropSet::SanitizeEndPos(rIn, aTxMasterStyleHd.GetRecEndFilePos());
             while ( rIn.GetError() == 0 && rIn.Tell() < nTxEndRecPos && nLev < nLevelAnz )
             {
                 if ( nLev && ( nInstance < 5 ) )
@@ -4231,7 +4228,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
         {
             pEnvHeader2->SeekToContent( rIn );
             DffRecordHeader aTxMasterStyleHd2;
-            auto nEnvEndRecPos = SanitizeEndPos(rIn, pEnvHeader2->GetRecEndFilePos());
+            auto nEnvEndRecPos = DffPropSet::SanitizeEndPos(rIn, pEnvHeader2->GetRecEndFilePos());
             while (rIn.Tell() < nEnvEndRecPos)
             {
                 ReadDffRecordHeader( rIn, aTxMasterStyleHd2 );
@@ -4242,7 +4239,7 @@ PPTStyleSheet::PPTStyleSheet( const DffRecordHeader& rSlideHd, SvStream& rIn, Sd
 
                     sal_uInt16 nLev = 0;
                     bool bFirst = true;
-                    auto nTxEndRecPos = SanitizeEndPos(rIn, aTxMasterStyleHd2.GetRecEndFilePos());
+                    auto nTxEndRecPos = DffPropSet::SanitizeEndPos(rIn, aTxMasterStyleHd2.GetRecEndFilePos());
                     while ( rIn.GetError() == 0 && rIn.Tell() < nTxEndRecPos && nLev < nLevelAnz )
                     {
                         if ( nLev )
@@ -4748,7 +4745,7 @@ bool PPTTextSpecInfoAtomInterpreter::Read( SvStream& rIn, const DffRecordHeader&
     sal_uInt32  nCharIdx = 0;
     rRecHd.SeekToContent( rIn );
 
-    auto nEndRecPos = SanitizeEndPos(rIn, rRecHd.GetRecEndFilePos());
+    auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, rRecHd.GetRecEndFilePos());
     while (rIn.Tell() < nEndRecPos && rIn.good())
     {
         if ( nRecordType == PPT_PST_TextSpecInfoAtom )
@@ -5096,7 +5093,7 @@ void PPTStyleTextPropReader::Init( SvStream& rIn, const DffRecordHeader& rTextHe
     {
         rIn.Seek( rExtParaHd.nFilePos + 8 );
 
-        auto nEndRecPos = SanitizeEndPos(rIn, rExtParaHd.GetRecEndFilePos());
+        auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, rExtParaHd.GetRecEndFilePos());
         while( ( rIn.GetError() == 0 ) && ( rIn.Tell() < nEndRecPos ) )
         {
             aStyleTextProp9.resize( aStyleTextProp9.size() + 1 );
@@ -6622,7 +6619,7 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
                             // or ParaTabStops and append them on this textobj
                             rIn.Seek( nFilePos );
                             ::std::vector< PPTFieldEntry* > FieldList;
-                            auto nEndRecPos = SanitizeEndPos(rIn, aClientTextBoxHd.GetRecEndFilePos());
+                            auto nEndRecPos = DffPropSet::SanitizeEndPos(rIn, aClientTextBoxHd.GetRecEndFilePos());
                             while (rIn.Tell() < nEndRecPos)
                             {
                                 ReadDffRecordHeader( rIn, aTextHd );
diff --git a/include/filter/msfilter/dffpropset.hxx b/include/filter/msfilter/dffpropset.hxx
index e04c295..7e64a17 100644
--- a/include/filter/msfilter/dffpropset.hxx
+++ b/include/filter/msfilter/dffpropset.hxx
@@ -60,6 +60,7 @@ class MSFILTER_DLLPUBLIC DffPropSet
         OUString    GetPropertyString( sal_uInt32 nId, SvStream& rStrm ) const;
         bool        SeekToContent( sal_uInt32 nRecType, SvStream& rSt ) const;
         void        InitializePropSet( sal_uInt16 nPropSetType ) const;
+        static sal_uLong SanitizeEndPos(SvStream &rIn, sal_uLong nEndRecPos);
 
         friend SvStream& ReadDffPropSet( SvStream& rIn, DffPropSet& rPropSet );
         friend SvStream& operator|=( SvStream& rIn, DffPropSet& rPropSet );
diff --git a/sd/qa/unit/data/ppt/pass/hang-3.ppt b/sd/qa/unit/data/ppt/pass/hang-3.ppt
new file mode 100644
index 0000000..156a9d0
Binary files /dev/null and b/sd/qa/unit/data/ppt/pass/hang-3.ppt differ
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 5f92ae8..abc8fc3 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -749,7 +749,8 @@ bool ImplSdPPTImport::Import()
                 DffRecordHeader aPageHd;
                 if ( SeekToAktPage( &aPageHd ) )
                 {
-                    while( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPageHd.GetRecEndFilePos() ) )
+                    auto nEndRecPos = SanitizeEndPos(rStCtrl, aPageHd.GetRecEndFilePos());
+                    while( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < nEndRecPos ) )
                     {
                         DffRecordHeader aHd;
                         ReadDffRecordHeader( rStCtrl, aHd );
@@ -770,7 +771,8 @@ bool ImplSdPPTImport::Import()
                                         if ( SeekToRec( rStCtrl, DFF_msofbtSpgrContainer, nEscherF002End, &aEscherObjListHd ) )
                                         {
                                             sal_uInt32 nObjCount = 0;
-                                            while( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aEscherObjListHd.GetRecEndFilePos() ) )
+                                            auto nListEndRecPos = SanitizeEndPos(rStCtrl, aEscherObjListHd.GetRecEndFilePos());
+                                            while( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < nListEndRecPos ) )
                                             {
                                                 DffRecordHeader aHd2;
                                                 ReadDffRecordHeader( rStCtrl, aHd2 );
@@ -801,7 +803,8 @@ bool ImplSdPPTImport::Import()
                                 DffRecordHeader aProgTagHd;
                                 if ( SeekToContentOfProgTag( 10, rStCtrl, aPageHd, aProgTagHd ) )
                                 {
-                                    while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aProgTagHd.GetRecEndFilePos() ) )
+                                    auto nTagEndRecPos = SanitizeEndPos(rStCtrl, aProgTagHd.GetRecEndFilePos());
+                                    while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < nTagEndRecPos ) )
                                     {
                                         DffRecordHeader aProgTagContentHd;
                                         ReadDffRecordHeader( rStCtrl, aProgTagContentHd );
@@ -909,7 +912,8 @@ bool ImplSdPPTImport::Import()
                     bool bNewAnimationsUsed = false;
 
                     aPageHd.SeekToContent( rStCtrl );
-                    while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aPageHd.GetRecEndFilePos() ) )
+                    auto nEndRecPos = SanitizeEndPos(rStCtrl, aPageHd.GetRecEndFilePos());
+                    while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < nEndRecPos ) )
                     {
                         DffRecordHeader aHd;
                         ReadDffRecordHeader( rStCtrl, aHd );
@@ -920,7 +924,8 @@ bool ImplSdPPTImport::Import()
                                 DffRecordHeader aProgTagHd;
                                 if ( SeekToContentOfProgTag( 10, rStCtrl, aPageHd, aProgTagHd ) )
                                 {
-                                    while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < aProgTagHd.GetRecEndFilePos() ) )
+                                    auto nHdEndRecPos = SanitizeEndPos(rStCtrl, aProgTagHd.GetRecEndFilePos());
+                                    while ( ( rStCtrl.GetError() == 0 ) && ( rStCtrl.Tell() < nHdEndRecPos ) )
                                     {
                                         DffRecordHeader aProgTagContentHd;
                                         ReadDffRecordHeader( rStCtrl, aProgTagContentHd );
@@ -1494,7 +1499,7 @@ void ImplSdPPTImport::ImportPageEffect( SdPage* pPage, const bool bNewAnimations
         DffRecordHeader aPageRecHd;
         if ( SeekToAktPage( &aPageRecHd ) )
         {
-            sal_uLong nPageRecEnd = aPageRecHd.GetRecEndFilePos();
+            sal_uLong nPageRecEnd = SanitizeEndPos(rStCtrl, aPageRecHd.GetRecEndFilePos());
 
             bool bTryTwice = ( eAktPageKind == PPT_SLIDEPAGE );
             bool bSSSlideInfoAtom = false;
@@ -1787,12 +1792,12 @@ void ImplSdPPTImport::ImportPageEffect( SdPage* pPage, const bool bNewAnimations
                             assert( !pPageList->is_null( nMasterNum ) );
                             const PptSlidePersistEntry& rE = (*pPageList)[ nMasterNum ];
                             sal_uInt32 nOfs = rE.aPersistAtom.nReserved;
-                                if ( nOfs )
-                                {
-                                    rStCtrl.Seek( nOfs );
-                                    nPageRecEnd = nOfs + 16;
-                                    continue;
-                                }
+                            if ( nOfs )
+                            {
+                                rStCtrl.Seek( nOfs );
+                                nPageRecEnd = nOfs + 16;
+                                continue;
+                            }
                         }
 
                     }
@@ -1951,7 +1956,8 @@ OUString ImplSdPPTImport::ReadMedia( sal_uInt32 nMediaRef ) const
     if ( pHd )
     {
         pHd->SeekToContent( rStCtrl );
-        while ( ( rStCtrl.Tell() < pHd->GetRecEndFilePos() ) && aRetVal.isEmpty() )
+        auto nEndRecPos = SanitizeEndPos(rStCtrl, pHd->GetRecEndFilePos());
+        while ( ( rStCtrl.Tell() < nEndRecPos ) && aRetVal.isEmpty() )
         {
             DffRecordHeader aHdMovie;
             ReadDffRecordHeader( rStCtrl, aHdMovie );
@@ -1971,7 +1977,8 @@ OUString ImplSdPPTImport::ReadMedia( sal_uInt32 nMediaRef ) const
                             if ( nRef == nMediaRef )
                             {
                                 aExVideoHd.SeekToContent( rStCtrl );
-                                while( rStCtrl.Tell() < aExVideoHd.GetRecEndFilePos() )
+                                auto nHdEndRecPos = SanitizeEndPos(rStCtrl, aExVideoHd.GetRecEndFilePos());
+                                while (rStCtrl.Tell() < nHdEndRecPos)
                                 {
                                     DffRecordHeader aHd;
                                     ReadDffRecordHeader( rStCtrl, aHd );
commit 496ee4fcbe697552622901dfb72775d07496bdb0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Aug 27 08:33:13 2015 +0100

    config-less fallback value
    
    Change-Id: Id2ee43ff95b6d28252f58e4930b81faf8b3b4b7f

diff --git a/sd/source/core/TransitionPreset.cxx b/sd/source/core/TransitionPreset.cxx
index d7bc31e..e19e664 100644
--- a/sd/source/core/TransitionPreset.cxx
+++ b/sd/source/core/TransitionPreset.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/animations/AnimationNodeType.hpp>
 #include <vcl/svapp.hxx>
 #include <osl/mutex.hxx>
+#include <unotools/configmgr.hxx>
 #include <unotools/streamwrap.hxx>
 #include <comphelper/getexpandeduri.hxx>
 #include <comphelper/processfactory.hxx>
@@ -134,6 +135,9 @@ bool TransitionPreset::importTransitionsFile( TransitionPresetList& rList,
 
 bool TransitionPreset::importTransitionPresetList( TransitionPresetList& rList )
 {
+    if (utl::ConfigManager::IsAvoidConfig())
+        return false;
+
     bool bRet = false;
 
     try
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index bac2be7..54e54f5 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -436,6 +436,9 @@ void GraphicObject::SetSwapStreamHdl()
 
 static sal_uInt32 GetCacheTimeInMs()
 {
+    if (utl::ConfigManager::IsAvoidConfig())
+        return 20000;
+
     const sal_uInt32 nSeconds =
         officecfg::Office::Common::Cache::GraphicManager::ObjectReleaseTime::get(
             comphelper::getProcessComponentContext());


More information about the Libreoffice-commits mailing list