Kaydet (Commit) 89300303 authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Caolán McNamara

Resolves: #i125171# support lossless embedding of linked jpegs...

in writer for PDF export

(cherry picked from commit 131669af)

Conflicts:
	sw/source/core/doc/notxtfrm.cxx

Add missing includes to fix build break

(cherry picked from commit 662b23eb)

Conflicts:
	sw/source/core/doc/notxtfrm.cxx

1e2c208ac91c8e666e4f3f6f89cd917736cdc44d

Change-Id: Ie560fa05964b79240fbd97825be74b0543c97aba
üst 60de576a
...@@ -75,6 +75,8 @@ ...@@ -75,6 +75,8 @@
#include <basegfx/matrix/b2dhommatrixtools.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <drawinglayer/processor2d/processor2dtools.hxx> #include <drawinglayer/processor2d/processor2dtools.hxx>
#include <txtfly.hxx> #include <txtfly.hxx>
#include <vcl/graphicfilter.hxx>
#include <vcl/pdfextoutdevdata.hxx>
using namespace com::sun::star; using namespace com::sun::star;
...@@ -754,7 +756,7 @@ bool paintUsingPrimitivesHelper( ...@@ -754,7 +756,7 @@ bool paintUsingPrimitivesHelper(
} }
void paintGraphicUsingPrimitivesHelper(OutputDevice & rOutputDevice, void paintGraphicUsingPrimitivesHelper(OutputDevice & rOutputDevice,
Graphic const& rGraphic, GraphicAttr const& rGraphicAttr, GraphicObject const& rGrfObj, GraphicAttr const& rGraphicAttr,
SwRect const& rAlignedGrfArea) SwRect const& rAlignedGrfArea)
{ {
// unify using GraphicPrimitive2D // unify using GraphicPrimitive2D
...@@ -768,12 +770,55 @@ void paintGraphicUsingPrimitivesHelper(OutputDevice & rOutputDevice, ...@@ -768,12 +770,55 @@ void paintGraphicUsingPrimitivesHelper(OutputDevice & rOutputDevice,
basegfx::tools::createScaleTranslateB2DHomMatrix( basegfx::tools::createScaleTranslateB2DHomMatrix(
aTargetRange.getRange(), aTargetRange.getRange(),
aTargetRange.getMinimum())); aTargetRange.getMinimum()));
drawinglayer::primitive2d::Primitive2DSequence aContent(1); 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());
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( aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D(
aTargetTransform, aTargetTransform,
rGraphic, aTempGraphic,
rGraphicAttr); rGraphicAttr);
bDone = true;
}
}
}
}
if(!bDone)
{
aContent[0] = new drawinglayer::primitive2d::GraphicPrimitive2D(
aTargetTransform,
rGrfObj.GetGraphic(),
rGraphicAttr);
}
paintUsingPrimitivesHelper( paintUsingPrimitivesHelper(
rOutputDevice, rOutputDevice,
...@@ -905,7 +950,7 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons ...@@ -905,7 +950,7 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons
else else
{ {
paintGraphicUsingPrimitivesHelper(*pOut, paintGraphicUsingPrimitivesHelper(*pOut,
rGrfObj.GetGraphic(), aGrfAttr, aAlignedGrfArea); rGrfObj, aGrfAttr, aAlignedGrfArea);
} }
} }
else else
......
...@@ -40,7 +40,7 @@ class XFillGradientItem; ...@@ -40,7 +40,7 @@ class XFillGradientItem;
class SdrMarkList; class SdrMarkList;
class SwNodeIndex; class SwNodeIndex;
class OutputDevice; class OutputDevice;
class Graphic; class GraphicObject;
class GraphicAttr; class GraphicAttr;
class SwPageDesc; class SwPageDesc;
class SwFrmFmts; class SwFrmFmts;
...@@ -72,7 +72,7 @@ bool DrawFillAttributes( ...@@ -72,7 +72,7 @@ bool DrawFillAttributes(
void paintGraphicUsingPrimitivesHelper( void paintGraphicUsingPrimitivesHelper(
OutputDevice & rOutputDevice, OutputDevice & rOutputDevice,
Graphic const& rGraphic, GraphicAttr const& rGraphicAttr, GraphicObject const& rGraphicObj, GraphicAttr const& rGraphicAttr,
SwRect const& rAlignedGrfArea); SwRect const& rAlignedGrfArea);
// method to align rectangle. // method to align rectangle.
......
...@@ -1817,7 +1817,7 @@ static void lcl_DrawGraphic( const SvxBrushItem& rBrush, OutputDevice *pOut, ...@@ -1817,7 +1817,7 @@ static void lcl_DrawGraphic( const SvxBrushItem& rBrush, OutputDevice *pOut,
if (pGrf->GetGraphic().getSvgData().get()) if (pGrf->GetGraphic().getSvgData().get())
{ // fdo#68927 - SVGs are rasterized badly by DrawWithPDFHandling { // fdo#68927 - SVGs are rasterized badly by DrawWithPDFHandling
paintGraphicUsingPrimitivesHelper(*pOut, paintGraphicUsingPrimitivesHelper(*pOut,
pGrf->GetGraphic(), pGrf->GetAttr(), aAlignedGrfRect); *pGrf, pGrf->GetAttr(), aAlignedGrfRect);
} }
else else
{ {
......
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