diff options
author | Armin Le Grand <alg@apache.org> | 2014-07-03 13:58:29 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-07-15 16:15:18 +0100 |
commit | 8930030323f269a9b3c6bd6a09fc723e09211caa (patch) | |
tree | a959fb95e25ac5dc9627dd5f65baf27ca14bb0a4 | |
parent | 60de576a295682002c59b90b1429da25bcd854ea (diff) |
Resolves: #i125171# support lossless embedding of linked jpegs...
in writer for PDF export
(cherry picked from commit 131669af7168020750b726e4e6d1568975f73886)
Conflicts:
sw/source/core/doc/notxtfrm.cxx
Add missing includes to fix build break
(cherry picked from commit 662b23eb1f1b7c178a7a5507864c647a390fae34)
Conflicts:
sw/source/core/doc/notxtfrm.cxx
1e2c208ac91c8e666e4f3f6f89cd917736cdc44d
Change-Id: Ie560fa05964b79240fbd97825be74b0543c97aba
-rw-r--r-- | sw/source/core/doc/notxtfrm.cxx | 57 | ||||
-rw-r--r-- | sw/source/core/inc/frmtool.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 2 |
3 files changed, 54 insertions, 9 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 diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 1372efb67b97..1fdaee5a32aa 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -40,7 +40,7 @@ class XFillGradientItem; class SdrMarkList; class SwNodeIndex; class OutputDevice; -class Graphic; +class GraphicObject; class GraphicAttr; class SwPageDesc; class SwFrmFmts; @@ -72,7 +72,7 @@ bool DrawFillAttributes( void paintGraphicUsingPrimitivesHelper( OutputDevice & rOutputDevice, - Graphic const& rGraphic, GraphicAttr const& rGraphicAttr, + GraphicObject const& rGraphicObj, GraphicAttr const& rGraphicAttr, SwRect const& rAlignedGrfArea); // method to align rectangle. diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 162c7a9a4489..f3aad5f69774 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -1817,7 +1817,7 @@ static void lcl_DrawGraphic( const SvxBrushItem& rBrush, OutputDevice *pOut, if (pGrf->GetGraphic().getSvgData().get()) { // fdo#68927 - SVGs are rasterized badly by DrawWithPDFHandling paintGraphicUsingPrimitivesHelper(*pOut, - pGrf->GetGraphic(), pGrf->GetAttr(), aAlignedGrfRect); + *pGrf, pGrf->GetAttr(), aAlignedGrfRect); } else { |