Kaydet (Commit) 6e580f3f authored tarafından Caolán McNamara's avatar Caolán McNamara

Related: fdo#52226 ensure graphics are swapped in on DrawingML::WriteImage

I imagine it would be best that the Graphics were delivered pre-swapped in by
higher levels in case there are second level caches or more complex caching
systemed wrapped around it, so warn about it in debug mode but give it a
last-ditch shot anyway. i.e. while the .docx problem should be fixed there
is a report of a very similar .xlsx problem

Change-Id: Ie40ee10fe5cba8ff9c321f47b83e33ee2c1425fd
üst f3d7734a
......@@ -809,14 +809,32 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia )
break;
default: {
GraphicType aType = rGraphic.GetType();
if ( aType == GRAPHIC_BITMAP ) {
GraphicConverter::Export( aStream, rGraphic, CVT_PNG );
sMediaType = "image/png";
pExtension = ".png";
} else if ( aType == GRAPHIC_GDIMETAFILE ) {
GraphicConverter::Export( aStream, rGraphic, CVT_EMF );
sMediaType = "image/x-emf";
pExtension = ".emf";
if ( aType == GRAPHIC_BITMAP && GRAPHIC_GDIMETAFILE) {
bool bSwapped = rGraphic.IsSwapOut();
//Warn rather than just happily swap in because of the comments
//in the sw export filters about needing to go through the
//hairy SwGrfNode::SwapIn which we would subvert by swapping in
//without it knowing about it, so while those ones are fixed we
//probably have to assume that we should ideally be presented
//here with already swapped in graphics.
SAL_WARN_IF(bSwapped, "oox", "attempted to output swapped out graphic");
if (bSwapped)
const_cast<Graphic&>(rGraphic).SwapIn();
if ( aType == GRAPHIC_BITMAP ) {
GraphicConverter::Export( aStream, rGraphic, CVT_PNG );
sMediaType = "image/png";
pExtension = ".png";
} else {
GraphicConverter::Export( aStream, rGraphic, CVT_EMF );
sMediaType = "image/x-emf";
pExtension = ".emf";
}
if (bSwapped)
const_cast<Graphic&>(rGraphic).SwapOut();
} else {
OSL_TRACE( "unhandled graphic type" );
/*Earlier, even in case of unhandled graphic types we were
......
......@@ -56,6 +56,8 @@ sal_uLong GraphicConverter::Import( SvStream& rIStm, Graphic& rGraphic, sal_uLon
sal_uLong GraphicConverter::Export( SvStream& rOStm, const Graphic& rGraphic, sal_uLong nFormat )
{
SAL_WARN_IF(rGraphic.IsSwapOut(), "vcl.filter", "exporting a swapped out graphic!");
GraphicConverter* pCvt = ImplGetSVData()->maGDIData.mpGrfConverter;
sal_uLong nRet = ERRCODE_IO_GENERAL;
......
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