summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-07-14 12:13:21 +0100
committerDavid Tardon <dtardon@redhat.com>2014-07-15 10:16:40 +0000
commitcd6f03d6f9ceea88e486788b09606c1efcaa4f1f (patch)
tree91ee12dfd3d7b57aaa6a02c87569966cb16346e8 /oox/source
parent36ff78d83b6a012d2a2c8ef2c6d8f0db62ecffc9 (diff)
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 (cherry picked from commit 6e580f3f53ae2de086a08c8ba1958b67874eb9c5) Reviewed-on: https://gerrit.libreoffice.org/10299 Reviewed-by: David Tardon <dtardon@redhat.com> Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/export/drawingml.cxx34
1 files changed, 26 insertions, 8 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 05faa6d696bc..fe55aa8dea2b 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -775,14 +775,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 || aType == 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