[Libreoffice-commits] core.git: Branch 'feature/fixes36' - filter/source include/vcl vcl/source
László Németh
laszlo.nemeth at collabora.com
Wed Oct 26 21:43:47 UTC 2016
filter/source/pdf/pdfexport.cxx | 2
include/vcl/pdfextoutdevdata.hxx | 20 ++-------
vcl/source/gdi/pdfextoutdevdata.cxx | 73 ++----------------------------------
3 files changed, 10 insertions(+), 85 deletions(-)
New commits:
commit ad876cf437e5967d34c43905f3f45a3efc678ee8
Author: László Németh <laszlo.nemeth at collabora.com>
Date: Wed Oct 26 23:04:41 2016 +0200
Revert "tdf#97662 - Try to preserve original compressed JPEGs harder."
This reverts commit 76ec54e8c9f3580450bca85236a4f5af0c328588.
Conflicts:
include/vcl/pdfextoutdevdata.hxx
vcl/source/gdi/pdfextoutdevdata.cxx
Change-Id: I38a3f4882a64dc1618b700ea4f414efbb29ed301
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index 469e20f..db2ddb6 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -821,8 +821,6 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
pPDFExtOutDevData->SetIsExportBookmarks( mbExportBookmarks );
pPDFExtOutDevData->SetIsExportHiddenSlides( mbExportHiddenSlides );
pPDFExtOutDevData->SetIsLosslessCompression( mbUseLosslessCompression );
- pPDFExtOutDevData->SetCompressionQuality( mnQuality );
- pPDFExtOutDevData->SetMaxImageResolution( mnMaxImageResolution );
pPDFExtOutDevData->SetIsReduceImageResolution( mbReduceImageResolution );
pPDFExtOutDevData->SetIsExportNamedDestinations( mbExportBmkToDest );
diff --git a/include/vcl/pdfextoutdevdata.hxx b/include/vcl/pdfextoutdevdata.hxx
index 48fab90..930d56c 100644
--- a/include/vcl/pdfextoutdevdata.hxx
+++ b/include/vcl/pdfextoutdevdata.hxx
@@ -86,8 +86,6 @@ class VCL_DLLPUBLIC PDFExtOutDevData : public ExtOutDevData
bool mbExportNDests; //i56629
sal_Int32 mnFormsFormat;
sal_Int32 mnPage;
- sal_Int32 mnCompressionQuality;
- sal_Int32 mnMaxImageResolution;
css::lang::Locale maDocLocale;
PageSyncData* mpPageSyncData;
@@ -105,6 +103,8 @@ public:
void PlayGlobalActions( PDFWriter& rWriter );
+
+
bool GetIsExportNotes() const { return mbExportNotes;}
void SetIsExportNotes( const bool bExportNotes );
@@ -135,14 +135,10 @@ public:
sal_Int32 GetCurrentPageNumber() const { return mnPage;}
void SetCurrentPageNumber( const sal_Int32 nPage );
- bool GetIsLosslessCompression() const { return mbUseLosslessCompression;}
+ bool GetIsLosslessCompression() const { return mbUseLosslessCompression;}
void SetIsLosslessCompression( const bool bLosslessCompression );
- void SetCompressionQuality( const sal_Int32 nQuality );
-
- void SetMaxImageResolution( const sal_Int32 nQuality );
-
- bool GetIsReduceImageResolution() const { return mbReduceImageResolution;}
+ bool GetIsReduceImageResolution() const { return mbReduceImageResolution;}
void SetIsReduceImageResolution( const bool bReduceImageResolution );
const css::lang::Locale& GetDocumentLocale() const { return maDocLocale;}
@@ -182,15 +178,9 @@ public:
rOutputRect, e.g. for cropped graphics.
*/
void EndGroup( const Graphic& rGraphic,
- sal_uInt8 nTransparency,
+ sal_uInt8 nTransparency,
const Rectangle& rOutputRect,
const Rectangle& rVisibleOutputRect );
-
- /// Detect if stream is compressed enough to avoid de-compress / scale & re-compress
- bool HasAdequateCompression( const Graphic &rGraphic,
- const Rectangle &rOutputRect,
- const Rectangle &rVisibleOutputRect ) const;
-
//--->i56629
/** Create a new named destination to be used in a link to this document from another PDF document
(see PDF spec 1.4, 8.2.1)
diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx
index 34d0c1b..ff33463 100644
--- a/vcl/source/gdi/pdfextoutdevdata.cxx
+++ b/vcl/source/gdi/pdfextoutdevdata.cxx
@@ -309,7 +309,6 @@ struct PageSyncData
void PushAction( const OutputDevice& rOutDev, const PDFExtOutDevDataSync::Action eAct );
bool PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const PDFExtOutDevData& rOutDevData );
};
-
void PageSyncData::PushAction( const OutputDevice& rOutDev, const PDFExtOutDevDataSync::Action eAct )
{
GDIMetaFile* pMtf = rOutDev.GetConnectMetaFile();
@@ -408,21 +407,12 @@ bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAc
}
else if ( aBeg->eAct == PDFExtOutDevDataSync::EndGroupGfxLink )
{
- Graphic& rGraphic = mGraphics.front();
- if ( rGraphic.IsLink() )
+ if ( rOutDevData.GetIsLosslessCompression() && !rOutDevData.GetIsReduceImageResolution() )
{
- GfxLinkType eType = rGraphic.GetLink().GetType();
- if ( eType == GFX_LINK_TYPE_NATIVE_JPG && mParaRects.size() >= 2 )
- {
- mbGroupIgnoreGDIMtfActions =
- rOutDevData.HasAdequateCompression(
- rGraphic, mParaRects[0], mParaRects[1]);
- if ( !mbGroupIgnoreGDIMtfActions )
- mCurrentGraphic = rGraphic;
- }
- else if ( eType == GFX_LINK_TYPE_NATIVE_PNG )
+ Graphic& rGraphic = mGraphics.front();
+ if ( rGraphic.IsLink() && rGraphic.GetLink().GetType() == GFX_LINK_TYPE_NATIVE_JPG )
{
- mCurrentGraphic = rGraphic;
+ mbGroupIgnoreGDIMtfActions = true;
}
}
break;
@@ -528,8 +518,6 @@ PDFExtOutDevData::PDFExtOutDevData( const OutputDevice& rOutDev ) :
mbExportNDests ( false ),
mnFormsFormat ( 0 ),
mnPage ( -1 ),
- mnCompressionQuality ( 90 ),
- mnMaxImageResolution ( 300 ),
mpPageSyncData ( nullptr ),
mpGlobalSyncData ( new GlobalSyncData() )
{
@@ -559,14 +547,6 @@ void PDFExtOutDevData::SetIsLosslessCompression( const bool bUseLosslessCompress
{
mbUseLosslessCompression = bUseLosslessCompression;
}
-void PDFExtOutDevData::SetCompressionQuality( const sal_Int32 nQuality )
-{
- mnCompressionQuality = nQuality;
-}
-void PDFExtOutDevData::SetMaxImageResolution( const sal_Int32 nMaxImageResolution )
-{
- mnMaxImageResolution = nMaxImageResolution;
-}
void PDFExtOutDevData::SetIsReduceImageResolution( const bool bReduceImageResolution )
{
mbReduceImageResolution = bReduceImageResolution;
@@ -787,7 +767,7 @@ void PDFExtOutDevData::BeginGroup()
}
void PDFExtOutDevData::EndGroup( const Graphic& rGraphic,
- sal_uInt8 nTransparency,
+ sal_uInt8 nTransparency,
const Rectangle& rOutputRect,
const Rectangle& rVisibleOutputRect )
{
@@ -798,49 +778,6 @@ void PDFExtOutDevData::EndGroup( const Graphic& rGraphic,
mpPageSyncData->mParaRects.push_back( rVisibleOutputRect );
}
-// Avoids expensive de-compression and re-compression of large images.
-bool PDFExtOutDevData::HasAdequateCompression( const Graphic &rGraphic,
- const Rectangle & /* rOutputRect */,
- const Rectangle & /* rVisibleOutputRect */ ) const
-{
- bool bReduceResolution = false;
-
- assert( rGraphic.IsLink() && rGraphic.GetLink().GetType() == GFX_LINK_TYPE_NATIVE_JPG );
-
- // small items better off as PNG anyway
- if ( rGraphic.GetSizePixel().Width() < 32 &&
- rGraphic.GetSizePixel().Height() < 32 )
- return false;
-
- // FIXME: ideally we'd also pre-empt the DPI related scaling too.
-
- Size aSize = rGraphic.GetSizePixel();
- sal_Int32 nCurrentRatio = (100 * aSize.Width() * aSize.Height() * 4) /
- rGraphic.GetLink().GetDataSize();
-
- if ( GetIsLosslessCompression() )
- return !bReduceResolution && !GetIsReduceImageResolution();
- else
- {
- static const struct {
- sal_Int32 mnQuality;
- sal_Int32 mnRatio;
- } aRatios[] = { // minium tolerable compression ratios
- { 100, 400 }, { 95, 700 }, { 90, 1000 }, { 85, 1200 },
- { 80, 1500 }, { 75, 1700 }
- };
- sal_Int32 nTargetRatio = 10000;
- for (auto & rRatio : aRatios)
- {
- if ( mnCompressionQuality > rRatio.mnQuality )
- break;
- nTargetRatio = rRatio.mnRatio;
- }
-
- return nCurrentRatio > nTargetRatio;
- }
-}
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list