diff options
Diffstat (limited to 'sw/source/core/doc/notxtfrm.cxx')
-rw-r--r-- | sw/source/core/doc/notxtfrm.cxx | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 0f98c9c11493..c6bae4aab45f 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -75,6 +75,8 @@ #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <drawinglayer/processor2d/processor2dtools.hxx> #include <txtfly.hxx> +#include <vcl/graphicfilter.hxx> +#include <vcl/pdfextoutdevdata.hxx> using namespace com::sun::star; @@ -754,7 +756,7 @@ bool paintUsingPrimitivesHelper( } void paintGraphicUsingPrimitivesHelper(OutputDevice & rOutputDevice, - Graphic const& rGraphic, GraphicAttr const& rGraphicAttr, + GraphicObject const& rGrfObj, GraphicAttr const& rGraphicAttr, SwRect const& rAlignedGrfArea) { // unify using GraphicPrimitive2D @@ -768,12 +770,55 @@ void paintGraphicUsingPrimitivesHelper(OutputDevice & rOutputDevice, basegfx::tools::createScaleTranslateB2DHomMatrix( aTargetRange.getRange(), aTargetRange.getMinimum())); + drawinglayer::primitive2d::Primitive2DSequence aContent(1); + bool bDone(false); + + // #i125171# The mechanism to get lossless jpegs into pdf is based on having the original + // file data (not the bitmap data) at the Graphic in the GfxLink (which has *nothing* to + // do with the graphic being linked). This works well for DrawingLayer GraphicObjects (linked + // and unlinked) but fails for linked Writer GraphicObjects. These have the URL in the + // GraphicObject, but no GfxLink with the original file data when it's a linked graphic. + // Since this blows up PDF size by a factor of 10 (the graphics get embedded as pixel maps + // then) it is okay to add this workarund: In the needed case, load the graphic in a way to + // get the GfxLink in the needed form and use that Graphic temporarily. Do this only when + // - we have PDF export + // - the GraphicObject is linked + // - the Graphic has no GfxLink + // - LosslessCompression is activated + // - it's indeed a jpeg graphic (could be checked by the url ending, but is more reliable to check later) + // In all other cases (normal repaint, print, etc...) use the available Graphic with the + // already loaded pixel graphic as before this change. + if (rOutputDevice.GetExtOutDevData() && rGrfObj.HasLink() && !rGrfObj.GetGraphic().IsLink()) + { + const vcl::PDFExtOutDevData* pPDFExt = dynamic_cast< const vcl::PDFExtOutDevData* >(rOutputDevice.GetExtOutDevData()); + + if (pPDFExt && pPDFExt->GetIsLosslessCompression()) + { + Graphic aTempGraphic; + INetURLObject aURL(rGrfObj.GetLink()); - aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D( - aTargetTransform, - rGraphic, - rGraphicAttr); + if (GRFILTER_OK == GraphicFilter::GetGraphicFilter().ImportGraphic(aTempGraphic, aURL)) + { + if(aTempGraphic.IsLink() && GFX_LINK_TYPE_NATIVE_JPG == aTempGraphic.GetLink().GetType()) + { + aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D( + aTargetTransform, + aTempGraphic, + rGraphicAttr); + bDone = true; + } + } + } + } + + if(!bDone) + { + aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D( + aTargetTransform, + rGrfObj.GetGraphic(), + rGraphicAttr); + } paintUsingPrimitivesHelper( rOutputDevice, @@ -905,7 +950,7 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons else { paintGraphicUsingPrimitivesHelper(*pOut, - rGrfObj.GetGraphic(), aGrfAttr, aAlignedGrfArea); + rGrfObj, aGrfAttr, aAlignedGrfArea); } } else |