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

Kohei Yoshida kohei.yoshida at collabora.com
Tue Aug 12 11:17:19 PDT 2014


 filter/source/msfilter/msdffimp.cxx |  180 ++++++++++++++++--------------------
 1 file changed, 82 insertions(+), 98 deletions(-)

New commits:
commit 95f0811c093680e6258f3bc973a3f7a3731a28f4
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Aug 12 14:00:03 2014 -0400

    Revert "Resolves: #i125187# more precision where the BLIP graphic is located"
    
    This reverts commit 3ea17073114cae99d7c323f051a4a2ba074f043c.
    
    That change from AOO single-handedly broke all image import from xls
    binary files.
    
    Change-Id: I384ae8f286ccc9d39e64de9da5ef6458af0a0972

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index d3ba8ca..2bf8a09 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -5823,46 +5823,25 @@ void SvxMSDffManager::GetDrawingGroupContainerData( SvStream& rSt, sal_uLong nLe
             nLenFBSE = nLength;
             // is FBSE big enough for our data
             bool bOk = ( nSkipBLIPLen + 4 + nSkipBLIPPos + 4 <= nLenFBSE );
-            bool bBLIPIsDirectlyEmbedded(false);
 
-            if(bOk)
+            if( bOk )
             {
-                rSt.SeekRel(nSkipBLIPLen);
+                rSt.SeekRel( nSkipBLIPLen );
                 rSt.ReadUInt32( nBLIPLen );
-
-                // #i125187# do not simply skip these four bytes, but read them. This value
-                // is zero when the BLIP is embedded to the FBSE directly following in the
-                // stream, else 1. Use this as hint to be more reliable (see below)
-                rSt.ReadUInt32( nBLIPPos );
-
-                if (0 == nBLIPPos)
-                {
-                    bBLIPIsDirectlyEmbedded = true;
-                }
-
+                rSt.SeekRel( nSkipBLIPPos );
                 rSt.ReadUInt32( nBLIPPos );
                 bOk = rSt.GetError() == 0;
 
-                nLength -= nSkipBLIPLen + 4 + nSkipBLIPPos + 4;
+                nLength -= nSkipBLIPLen+ 4 + nSkipBLIPPos + 4;
             }
 
             if( bOk )
             {
-                // #i125187# the original check to test if the BLIP is following embeded in the FBSE was
-                // was (!nBLIPPos && nBLIPLen < nLenFBSE), but there are ppt documents
-                // where this is not sufficient (what means that for BLIPs in the picture
-                // stream the same conditions can be true sometimes). I experimented with various
-                // ppt files and detected that the four bytes before reading the nBLIPPos
-                // contain a flag which describes that embedding more reliable, thus I will
-                // use it here now in the form of the bBLIPIsDirectlyEmbedded variable (see above).
-                // This modification works with all ppt files I found which use directly embedded
-                // BLIPs and with the file which showed the error. More work may be needed when
-                // exceptions to this more strict schema may show up, though.
-                if (0 == nBLIPPos && nBLIPLen < nLenFBSE && bBLIPIsDirectlyEmbedded)
-                {
-                    // get BLIP file position as directly following embedded
+                // specialty:
+                // If nBLIPLen is less than nLenFBSE AND nBLIPPos is NULL,
+                // then we assume, that the image is in FBSE!
+                if( (!nBLIPPos) && (nBLIPLen < nLenFBSE) )
                     nBLIPPos = rSt.Tell() + 4;
-                }
 
                 // That worked great!
                 // We store, that we do have one FBSE more in the pointer array.
commit 5fe1a59cb7408e9f6ce0e554f01c89fc44ab3041
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Aug 12 13:33:42 2014 -0400

    Scope reduction in GetBLIP() & remove non-ASCII character (degree symbol).
    
    Change-Id: I306a22b087aceed5dbb6cb2e8b67e2501589ee61

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 867c8e2..d3ba8ca 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -4288,8 +4288,9 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r
                         if ( IsHardAttribute( DFF_Prop_gtextFBold ) )
                             aSet.Put( SvxWeightItem( ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x0020 ) != 0 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT ) );
 
-                        // SJ TODO: Vertical Writing is not correct, instead this should be
-                        // replaced through "CharacterRotation" by 90°, therefore a new Item has to be
+                        // SJ TODO: Vertical Writing is not correct, instead
+                        // this should be replaced through "CharacterRotation"
+                        // by 90 degrees, therefore a new Item has to be
                         // supported by svx core, api and xml file format
                         ((SdrObjCustomShape*)pRet)->SetVerticalWriting( ( GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ) & 0x2000 ) != 0 );
 
@@ -6184,81 +6185,85 @@ bool SvxMSDffManager::GetShape(sal_uLong nId, SdrObject*&         rpShape,
 ******************************************************************************/
 bool SvxMSDffManager::GetBLIP( sal_uLong nIdx_, Graphic& rData, Rectangle* pVisArea )
 {
+    if (!pStData)
+        return false;
+
     bool bOk = false;       // initialize result variable
-    if ( pStData )
+
+    // check if a graphic for this blipId is already imported
+    if ( nIdx_)
     {
-        // check if a graphic for this blipId is already imported
-        if ( nIdx_)
-        {
-            std::map<sal_uInt32,OString>::iterator iter = aEscherBlipCache.find(nIdx_);
+        std::map<sal_uInt32,OString>::iterator iter = aEscherBlipCache.find(nIdx_);
 
-            if (iter != aEscherBlipCache.end())
-            {
-                /* if this entry is available, then it should be possible
-                to get the Graphic via GraphicObject */
-                GraphicObject aGraphicObject( iter->second );
-                rData = aGraphicObject.GetGraphic();
-                if ( rData.GetType() != GRAPHIC_NONE )
-                    bOk = true;
-                else
-                    aEscherBlipCache.erase(iter);
-            }
+        if (iter != aEscherBlipCache.end())
+        {
+            /* if this entry is available, then it should be possible
+            to get the Graphic via GraphicObject */
+            GraphicObject aGraphicObject( iter->second );
+            rData = aGraphicObject.GetGraphic();
+            if ( rData.GetType() != GRAPHIC_NONE )
+                bOk = true;
+            else
+                aEscherBlipCache.erase(iter);
         }
-        if ( !bOk )
-        {
-            sal_uInt16 nIdx = sal_uInt16( nIdx_ );
-            if( !nIdx || (pBLIPInfos->size() < nIdx) ) return false;
-
-            // possibly delete old error flag(s)
-            if( rStCtrl.GetError() )
-                rStCtrl.ResetError();
-            if(    ( &rStCtrl != pStData )
-                && pStData->GetError() )
-                pStData->ResetError();
-
-            // remember FilePos of the stream(s)
-            sal_uLong nOldPosCtrl = rStCtrl.Tell();
-            sal_uLong nOldPosData = pStData ? pStData->Tell() : nOldPosCtrl;
-
-            // fetch matching info struct out of the pointer array
-            SvxMSDffBLIPInfo& rInfo = (*pBLIPInfos)[ nIdx-1 ];
-            // jump to the BLIP atom in the data stream
-            pStData->Seek( rInfo.nFilePos );
-            // possibly reset error status
-            if( pStData->GetError() )
-                pStData->ResetError();
+    }
+
+    if ( !bOk )
+    {
+        sal_uInt16 nIdx = sal_uInt16( nIdx_ );
+        if( !nIdx || (pBLIPInfos->size() < nIdx) )
+            return false;
+
+        // possibly delete old error flag(s)
+        if( rStCtrl.GetError() )
+            rStCtrl.ResetError();
+        if(    ( &rStCtrl != pStData )
+            && pStData->GetError() )
+            pStData->ResetError();
+
+        // remember FilePos of the stream(s)
+        sal_uLong nOldPosCtrl = rStCtrl.Tell();
+        sal_uLong nOldPosData = pStData ? pStData->Tell() : nOldPosCtrl;
+
+        // fetch matching info struct out of the pointer array
+        SvxMSDffBLIPInfo& rInfo = (*pBLIPInfos)[ nIdx-1 ];
+        // jump to the BLIP atom in the data stream
+        pStData->Seek( rInfo.nFilePos );
+        // possibly reset error status
+        if( pStData->GetError() )
+            pStData->ResetError();
+        else
+            bOk = GetBLIPDirect( *pStData, rData, pVisArea );
+        if( pStData2 && !bOk )
+        {
+            // Error, but the is a second chance: There is a second
+            //         data stream in which the graphic could be stored!
+            if( pStData2->GetError() )
+                pStData2->ResetError();
+            sal_uLong nOldPosData2 = pStData2->Tell();
+            // jump to the BLIP atom in the second data stream
+            pStData2->Seek( rInfo.nFilePos );
+            // reset error status if necessary
+            if( pStData2->GetError() )
+                pStData2->ResetError();
             else
-                bOk = GetBLIPDirect( *pStData, rData, pVisArea );
-            if( pStData2 && !bOk )
-            {
-                // Error, but the is a second chance: There is a second
-                //         data stream in which the graphic could be stored!
-                if( pStData2->GetError() )
-                    pStData2->ResetError();
-                sal_uLong nOldPosData2 = pStData2->Tell();
-                // jump to the BLIP atom in the second data stream
-                pStData2->Seek( rInfo.nFilePos );
-                // reset error status if necessary
-                if( pStData2->GetError() )
-                    pStData2->ResetError();
-                else
-                    bOk = GetBLIPDirect( *pStData2, rData, pVisArea );
-                // restore olf FilePos of the second data stream
-                pStData2->Seek( nOldPosData2 );
-            }
-            // restore old FilePos of the stream(s)
-            rStCtrl.Seek( nOldPosCtrl );
-            if( &rStCtrl != pStData )
-              pStData->Seek( nOldPosData );
+                bOk = GetBLIPDirect( *pStData2, rData, pVisArea );
+            // restore olf FilePos of the second data stream
+            pStData2->Seek( nOldPosData2 );
+        }
+        // restore old FilePos of the stream(s)
+        rStCtrl.Seek( nOldPosCtrl );
+        if( &rStCtrl != pStData )
+          pStData->Seek( nOldPosData );
 
-            if ( bOk )
-            {
-                // create new BlipCacheEntry for this graphic
-                GraphicObject aGraphicObject( rData );
-                aEscherBlipCache.insert(std::make_pair(nIdx_,aGraphicObject.GetUniqueID()));
-            }
+        if ( bOk )
+        {
+            // create new BlipCacheEntry for this graphic
+            GraphicObject aGraphicObject( rData );
+            aEscherBlipCache.insert(std::make_pair(nIdx_,aGraphicObject.GetUniqueID()));
         }
     }
+
     return bOk;
 }
 


More information about the Libreoffice-commits mailing list