Kaydet (Commit) 2f2296d2 authored tarafından Vitaliy Anderson's avatar Vitaliy Anderson Kaydeden (comit) Miklos Vajna

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/35591Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst e1ff3782
......@@ -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();
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment