summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/source/core/doc/notxtfrm.cxx57
-rw-r--r--sw/source/core/inc/frmtool.hxx4
-rw-r--r--sw/source/core/layout/paintfrm.cxx2
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
{