[Libreoffice-commits] core.git: sw/qa writerfilter/source

Vitaliy Anderson vanderson at smartru.com
Thu Mar 30 08:14:03 UTC 2017


 sw/qa/extras/ooxmlimport/data/tdf106606.docx     |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx         |   25 +++++++++++++++++++++++
 writerfilter/source/dmapper/NumberingManager.cxx |    4 ---
 3 files changed, 25 insertions(+), 4 deletions(-)

New commits:
commit 2f2296d2c328fa8bf3671f8d3591d3a2bdf2752f
Author: Vitaliy Anderson <vanderson at smartru.com>
Date:   Tue Mar 21 14:46:48 2017 +0300

    tdf#106606: Don't dispose NumPicBullet in sprm handler.
    
    An image saved in cache once when NS_ooxml::LN_CT_NumPicBullet_pict
    is processed, may then be used multiple times (for each NumRule that
    requires it) when NS_ooxml::LN_CT_Lvl_lvlPicBulletId is processed
    for each of them.
    
    If the image was released here for first processing, subsequent rules
    couldn't find the image in cache and failed to create NumberingType::BITMAP
    style for the rule.
    
    The image is ultimately released in ListsManager::~ListsManager()
    after it is no more needed.
    
    Change-Id: Ib4c351437ba94d5a9d3e2927ccf459ec01f1b15f
    Reviewed-on: https://gerrit.libreoffice.org/35591
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/ooxmlimport/data/tdf106606.docx b/sw/qa/extras/ooxmlimport/data/tdf106606.docx
new file mode 100644
index 000000000000..cb085d260aba
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf106606.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 87c71b8afb6b..c4b5fe5dd706 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1235,6 +1235,31 @@ DECLARE_OOXMLIMPORT_TEST(testTdf101626, "tdf101626.docx")
     }
 }
 
+DECLARE_OOXMLIMPORT_TEST( testTdf106606, "tdf106606.docx" )
+{
+    auto FindGraphicBitmapPropertyInNumStyle = [&]( OUString rStyleName )
+    {
+        uno::Reference<beans::XPropertySet>     xPropertySet( getStyles( "NumberingStyles" )->getByName( rStyleName ), uno::UNO_QUERY );
+        uno::Reference<container::XIndexAccess> xLevels( xPropertySet->getPropertyValue( "NumberingRules" ), uno::UNO_QUERY );
+        uno::Sequence<beans::PropertyValue>     aProps;
+        xLevels->getByIndex( 0 ) >>= aProps; // 1st level
+
+        for ( int i = 0; i < aProps.getLength(); ++i )
+        {
+            const beans::PropertyValue& rProp = aProps[i];
+
+            // If the image was prematurely removed from cache when processed for previous numbering list, then the sequence hasn't the property.
+            if ( rProp.Name == "GraphicBitmap" )
+                return true;
+        }
+        return false;
+    };
+
+    // The document has two numbering lists with a picture
+    CPPUNIT_ASSERT( FindGraphicBitmapPropertyInNumStyle("WWNum1") );
+    CPPUNIT_ASSERT( FindGraphicBitmapPropertyInNumStyle("WWNum2") );
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index a27af1d4c23c..87c30c5bd336 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -911,10 +911,6 @@ void ListsManager::lcl_sprm( Sprm& rSprm )
                         m_pCurrentDefinition->GetCurrentLevel()->SetGraphicBitmap( gr );
                     } catch(const beans::UnknownPropertyException&)
                     {}
-
-                    // Now that we saved the URL of the graphic, remove it from the document.
-                    uno::Reference<lang::XComponent> xShapeComponent(xShape, uno::UNO_QUERY);
-                    xShapeComponent->dispose();
                 }
             }
             break;


More information about the Libreoffice-commits mailing list