diff options
author | Vitaliy Anderson <vanderson@smartru.com> | 2017-03-21 14:46:48 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-03-30 08:13:39 +0000 |
commit | 2f2296d2c328fa8bf3671f8d3591d3a2bdf2752f (patch) | |
tree | 08f34c9702ef06e75aa90c27c6fa20b0e31c7efb | |
parent | e1ff3782cc0bef951e7e5f0166c2b2395eaee26b (diff) |
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@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/tdf106606.docx | bin | 0 -> 73530 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 25 | ||||
-rw-r--r-- | writerfilter/source/dmapper/NumberingManager.cxx | 4 |
3 files changed, 25 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf106606.docx b/sw/qa/extras/ooxmlimport/data/tdf106606.docx Binary files differnew file mode 100644 index 000000000000..cb085d260aba --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf106606.docx 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; |