diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-05-22 16:20:18 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-05-22 19:30:25 +0200 |
commit | 4c2172a3e973bc6351107a3a1b554c77b40b75dd (patch) | |
tree | 23f46863d12dd137b9d8f40190328c517c66c974 /vcl/source | |
parent | 2c1fb32e0b3f0c51edcbb861977d372ae4eaf5e4 (diff) |
tdf#106702 PDF export: fix missing images from Writer headers/footers
Position of an image is determined by the relevant bitmap scale metafile
action when recompressing images.
The same position was determined by PDFExtOutDevData "meta" info when
not recompressing images. This second rectangle was never correct for
images repeated in Writer headers/footers on non-first pages: the
position was relative to the page, while PDF export sets the map mode
(origin) of the output device during export, so such positions are
expected to be absolute ones.
The root of the problem seems to be that header images in Writer are
both repeated (as the user sees it) and unrepeated (as the doc model
sees it), and by the time we want to get its position, we only see the
unrepeated SdrObject.
Fix the problem by using the correct position from the scale action and
not from PDFExtOutDevData if possible.
(Also give up on running CppunitTest_vcl_pdfexport in the non-pdfium
case, most of the tests there do require pdfium anyway, and the growing
ifdef forest in that file just made it hard to read the code.)
Change-Id: I31c14d4bd223b2804859982542ebd6d5f9abd312
Reviewed-on: https://gerrit.libreoffice.org/54674
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/pdfextoutdevdata.cxx | 25 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl2.cxx | 2 |
2 files changed, 22 insertions, 5 deletions
diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx index a36a056ddfd2..05bb37a0c6c3 100644 --- a/vcl/source/gdi/pdfextoutdevdata.cxx +++ b/vcl/source/gdi/pdfextoutdevdata.cxx @@ -22,6 +22,7 @@ #include <vcl/outdev.hxx> #include <vcl/gfxlink.hxx> #include <vcl/dllapi.h> +#include <vcl/metaact.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> @@ -300,7 +301,7 @@ struct PageSyncData { mpGlobalData = pGlobal; } void PushAction( const OutputDevice& rOutDev, const PDFExtOutDevDataSync::Action eAct ); - bool PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const PDFExtOutDevData& rOutDevData ); + bool PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const GDIMetaFile& rMtf, const PDFExtOutDevData& rOutDevData ); }; void PageSyncData::PushAction( const OutputDevice& rOutDev, const PDFExtOutDevDataSync::Action eAct ) @@ -316,7 +317,7 @@ void PageSyncData::PushAction( const OutputDevice& rOutDev, const PDFExtOutDevDa aSync.nIdx = 0x7fffffff; // sync not possible mActions.push_back( aSync ); } -bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const PDFExtOutDevData& rOutDevData ) +bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const GDIMetaFile& rMtf, const PDFExtOutDevData& rOutDevData ) { bool bRet = false; if ( mActions.size() && ( mActions.front().nIdx == rCurGDIMtfAction ) ) @@ -462,6 +463,22 @@ bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAc if( pData && nBytes ) { aTmp.WriteBytes( pData, nBytes ); + + // Look up the output rectangle from the previous + // bitmap scale action if possible. This has the + // correct position for images repeated in + // Writer headers/footers for non-first pages. + if (rCurGDIMtfAction > 0) + { + const MetaAction* pAction = rMtf.GetAction(rCurGDIMtfAction - 1); + if (pAction && pAction->GetType() == MetaActionType::BMPSCALE) + { + const MetaBmpScaleAction* pA + = static_cast<const MetaBmpScaleAction*>(pAction); + aOutputRect.SetPos(pA->GetPoint()); + } + } + rWriter.DrawJPGBitmap( aTmp, aGraphic.GetBitmap().GetBitCount() > 8, aGraphic.GetSizePixel(), aOutputRect, aMask, aGraphic ); } @@ -582,9 +599,9 @@ void PDFExtOutDevData::ResetSyncData() { *mpPageSyncData = PageSyncData( mpGlobalSyncData.get() ); } -bool PDFExtOutDevData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rIdx ) +bool PDFExtOutDevData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rIdx, const GDIMetaFile& rMtf ) { - return mpPageSyncData->PlaySyncPageAct( rWriter, rIdx, *this ); + return mpPageSyncData->PlaySyncPageAct( rWriter, rIdx, rMtf, *this ); } void PDFExtOutDevData::PlayGlobalActions( PDFWriter& rWriter ) { diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index 9028bc75fa77..e2d4c4178f43 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -269,7 +269,7 @@ void PDFWriterImpl::playMetafile( const GDIMetaFile& i_rMtf, vcl::PDFExtOutDevDa for( sal_uInt32 i = 0, nCount = aMtf.GetActionSize(); i < nCount; ) { - if ( !i_pOutDevData || !i_pOutDevData->PlaySyncPageAct( m_rOuterFace, i ) ) + if ( !i_pOutDevData || !i_pOutDevData->PlaySyncPageAct( m_rOuterFace, i, aMtf ) ) { const MetaAction* pAction = aMtf.GetAction( i ); const MetaActionType nType = pAction->GetType(); |