[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 50 commits - download.lst external/pdfium include/svx include/tools include/vcl sdext/CppunitTest_sdext_pdfimport.mk sdext/Executable_pdf2xml.mk sdext/Executable_pdfunzip.mk sdext/Library_pdfimport.mk sdext/source sd/inc sd/Library_sd.mk sd/qa sd/source sfx2/source svtools/qa svtools/source svx/Library_svxcore.mk svx/source sw/source vcl/inc vcl/Library_vcl.mk vcl/source
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Fri Jun 1 07:02:51 UTC 2018
download.lst | 4
external/pdfium/Library_pdfium.mk | 79 +
external/pdfium/UnpackedTarball_pdfium.mk | 10
external/pdfium/build.patch.1 | 124 ++
external/pdfium/configs/build_config.h | 132 +++
external/pdfium/edit.patch.1 | 757 +++++++++++++++++
external/pdfium/freetype.patch.1 | 18
external/pdfium/icu.patch.1 | 13
external/pdfium/ubsan.patch | 38
include/svx/svdograf.hxx | 11
include/svx/xmlgrhlp.hxx | 2
include/tools/gen.hxx | 8
include/vcl/GraphicExternalLink.hxx | 31
include/vcl/GraphicLoader.hxx | 25
include/vcl/dibtools.hxx | 8
include/vcl/graph.hxx | 15
include/vcl/pdfread.hxx | 12
sd/Library_sd.mk | 1
sd/inc/sdpdffilter.hxx | 40
sd/qa/unit/import-tests.cxx | 6
sd/source/filter/pdf/sdpdffilter.cxx | 154 +++
sd/source/ui/docshell/docshel4.cxx | 9
sd/source/ui/view/drviews2.cxx | 4
sdext/CppunitTest_sdext_pdfimport.mk | 2
sdext/Executable_pdf2xml.mk | 2
sdext/Executable_pdfunzip.mk | 2
sdext/Library_pdfimport.mk | 2
sdext/source/pdfimport/wrapper/wrapper.cxx | 19
sfx2/source/doc/objstor.cxx | 8
svtools/qa/unit/GraphicObjectTest.cxx | 4
svtools/source/graphic/grfcache.cxx | 12
svx/Library_svxcore.mk | 2
svx/source/svdraw/svdedtv.cxx | 32
svx/source/svdraw/svdedtv2.cxx | 78 -
svx/source/svdraw/svdograf.cxx | 18
svx/source/svdraw/svdpdf.cxx | 1260 +++++++++++++++++++++++++++++
svx/source/svdraw/svdpdf.hxx | 244 +++++
svx/source/xml/xmlgrhlp.cxx | 16
svx/source/xoutdev/_xoutbmp.cxx | 6
sw/source/core/graphic/ndgrf.cxx | 2
vcl/Library_vcl.mk | 1
vcl/inc/impgraph.hxx | 34
vcl/source/filter/graphicfilter.cxx | 2
vcl/source/filter/ipdf/pdfread.cxx | 129 +-
vcl/source/gdi/dibtools.cxx | 16
vcl/source/gdi/graph.cxx | 46 -
vcl/source/gdi/impgraph.cxx | 89 +-
vcl/source/gdi/pdfwriter_impl.cxx | 10
vcl/source/graphic/GraphicLoader.cxx | 49 +
49 files changed, 3333 insertions(+), 253 deletions(-)
New commits:
commit 1ff67704d513bdf4d614fcadab7e0e7c5c11d21f
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon May 28 08:02:06 2018 -0400
vcl: fix pdf rendering regression
Change-Id: I6c2c48c033facb317b4ca7ed2af07348d6386b98
Reviewed-on: https://gerrit.libreoffice.org/54921
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 9d9a5f1b3cd9..0eb30bf17ae0 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -244,7 +244,9 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic,
{
uno::Sequence<sal_Int8> aPdfData;
Bitmap aBitmap;
- bool bRet = ImportPDF(rStream, aBitmap, 0, aPdfData, fResolutionDPI);
+ bool bRet = ImportPDF(rStream, aBitmap, 0, aPdfData,
+ STREAM_SEEK_TO_BEGIN,
+ STREAM_SEEK_TO_END, fResolutionDPI);
rGraphic = aBitmap;
rGraphic.setPdfData(std::make_shared<css::uno::Sequence<sal_Int8>>(aPdfData));
rGraphic.setPageNumber(0); // We currently import only the first page.
commit 6a1187ef3a74fbd194e8578df97cba65e39d21aa
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Thu May 24 23:01:15 2018 -0400
pdf: preserve the original page dimensions on import
Also allow for rendering PDFs to images at custom
resolution, instead of hard-coded (old hard-coded
value of 96 dpi is now default arguments).
Change-Id: Ia5b52f72d6ce7130a2debc7c6f86504aa041bdc8
Reviewed-on: https://gerrit.libreoffice.org/54786
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/include/vcl/pdfread.hxx b/include/vcl/pdfread.hxx
index 003bc0a76907..d239a087cf91 100644
--- a/include/vcl/pdfread.hxx
+++ b/include/vcl/pdfread.hxx
@@ -21,11 +21,16 @@ VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Bitmap& rBitmap,
size_t nPageIndex,
css::uno::Sequence<sal_Int8>& rPdfData,
sal_uInt64 nPos = STREAM_SEEK_TO_BEGIN,
- sal_uInt64 nSize = STREAM_SEEK_TO_END);
-VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Graphic& rGraphic);
+ sal_uInt64 nSize = STREAM_SEEK_TO_END,
+ const double fResolutionDPI = 96.);
-VCL_DLLPUBLIC size_t ImportPDF(const OUString& rURL, std::vector<Bitmap>& rBitmaps,
- css::uno::Sequence<sal_Int8>& rPdfData);
+VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Graphic& rGraphic,
+ const double fResolutionDPI = 96.);
+
+VCL_DLLPUBLIC size_t ImportPDF(const OUString& rURL,
+ std::vector<Bitmap>& rBitmaps,
+ css::uno::Sequence<sal_Int8>& rPdfData,
+ const double fResolutionDPI = 96.);
}
#endif // INCLUDED_VCL_SOURCE_FILTER_IPDF_PDFREAD_HXX
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index c7aba7d18ca2..26d7c70bdd54 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -99,9 +99,12 @@ bool SdPdfFilter::Import()
const OUString aFileName(
mrMedium.GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::NONE));
+ // Rendering resolution.
+ const double dResolutionDPI = 96.;
+
uno::Sequence<sal_Int8> aPdfData;
std::vector<Bitmap> aBitmaps;
- if (vcl::ImportPDF(aFileName, aBitmaps, aPdfData) == 0)
+ if (vcl::ImportPDF(aFileName, aBitmaps, aPdfData, dResolutionDPI) == 0)
return false;
// Prepare the link with the PDF stream.
@@ -129,8 +132,12 @@ bool SdPdfFilter::Import()
// Create the page and insert the Graphic.
SdPage* pPage = mrDocument.GetSdPage(nPageNumber++, PageKind::Standard);
- const Size aGrfSize(OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(),
- MapMode(MapUnit::Map100thMM)));
+ Size aGrfSize(OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(),
+ MapMode(MapUnit::Map100thMM)));
+
+ // Resize to original size based on 72 dpi to preserve page size.
+ aGrfSize = Size(aGrfSize.Width() * 72. / dResolutionDPI,
+ aGrfSize.Height() * 72. / dResolutionDPI);
// Make the page size match the rendered image.
pPage->SetSize(aGrfSize);
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 72f1ae43a3aa..9d9a5f1b3cd9 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -52,15 +52,16 @@ int CompatibleWriter::WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, const void*
}
/// Convert to inch, then assume 96 DPI.
-double pointToPixel(double fPoint)
+inline double pointToPixel(const double fPoint, const double fResolutionDPI)
{
- return fPoint / 72 * 96;
+ return fPoint * fResolutionDPI / 72.;
}
/// Does PDF to bitmap conversion using pdfium.
size_t generatePreview(SvStream& rStream, std::vector<Bitmap>& rBitmaps,
sal_uInt64 nPos, sal_uInt64 nSize,
- const size_t nFirstPage = 0, int nPages = 1)
+ const size_t nFirstPage = 0, int nPages = 1,
+ const double fResolutionDPI = 96.)
{
FPDF_LIBRARY_CONFIG aConfig;
aConfig.version = 2;
@@ -91,8 +92,8 @@ size_t generatePreview(SvStream& rStream, std::vector<Bitmap>& rBitmaps,
break;
// Returned unit is points, convert that to pixel.
- const size_t nPageWidth = pointToPixel(FPDF_GetPageWidth(pPdfPage));
- const size_t nPageHeight = pointToPixel(FPDF_GetPageHeight(pPdfPage));
+ const size_t nPageWidth = pointToPixel(FPDF_GetPageWidth(pPdfPage), fResolutionDPI);
+ const size_t nPageHeight = pointToPixel(FPDF_GetPageHeight(pPdfPage), fResolutionDPI);
FPDF_BITMAP pPdfBitmap = FPDFBitmap_Create(nPageWidth, nPageHeight, /*alpha=*/1);
if (!pPdfBitmap)
break;
@@ -213,11 +214,12 @@ namespace vcl
bool ImportPDF(SvStream& rStream, Bitmap& rBitmap,
size_t nPageIndex,
css::uno::Sequence<sal_Int8>& rPdfData,
- sal_uInt64 nPos, sal_uInt64 nSize)
+ sal_uInt64 nPos, sal_uInt64 nSize,
+ const double fResolutionDPI)
{
// Get the preview of the first page.
std::vector<Bitmap> aBitmaps;
- if (generatePreview(rStream, aBitmaps, nPos, nSize, nPageIndex, 1) != 1 ||
+ if (generatePreview(rStream, aBitmaps, nPos, nSize, nPageIndex, 1, fResolutionDPI) != 1 ||
aBitmaps.empty())
return false;
@@ -237,11 +239,12 @@ bool ImportPDF(SvStream& rStream, Bitmap& rBitmap,
}
-bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
+bool ImportPDF(SvStream& rStream, Graphic& rGraphic,
+ const double fResolutionDPI)
{
uno::Sequence<sal_Int8> aPdfData;
Bitmap aBitmap;
- bool bRet = ImportPDF(rStream, aBitmap, 0, aPdfData);
+ bool bRet = ImportPDF(rStream, aBitmap, 0, aPdfData, fResolutionDPI);
rGraphic = aBitmap;
rGraphic.setPdfData(std::make_shared<css::uno::Sequence<sal_Int8>>(aPdfData));
rGraphic.setPageNumber(0); // We currently import only the first page.
@@ -249,12 +252,13 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
}
size_t ImportPDF(const OUString& rURL, std::vector<Bitmap>& rBitmaps,
- css::uno::Sequence<sal_Int8>& rPdfData)
+ css::uno::Sequence<sal_Int8>& rPdfData,
+ const double fResolutionDPI)
{
std::unique_ptr<SvStream> xStream(
::utl::UcbStreamHelper::CreateStream(rURL, StreamMode::READ | StreamMode::SHARE_DENYNONE));
- if (generatePreview(*xStream, rBitmaps, STREAM_SEEK_TO_BEGIN, STREAM_SEEK_TO_END, 0, -1) == 0)
+ if (generatePreview(*xStream, rBitmaps, STREAM_SEEK_TO_BEGIN, STREAM_SEEK_TO_END, 0, -1, fResolutionDPI) == 0)
return 0;
// Save the original PDF stream for later use.
commit f303db85f6b1fa06a61b0f709efce97ab9615bf8
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Thu May 24 06:59:39 2018 -0400
sd: make the imported PDF page exactly as original
i.e. no borders or larger page than rendered PDF
Change-Id: I1f356cceeec1d5d9f1728f0e29160fdd9241a221
Reviewed-on: https://gerrit.libreoffice.org/54764
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index 25f0370a81bf..c7aba7d18ca2 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -129,37 +129,12 @@ bool SdPdfFilter::Import()
// Create the page and insert the Graphic.
SdPage* pPage = mrDocument.GetSdPage(nPageNumber++, PageKind::Standard);
- Size aGrfSize(OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(),
- MapMode(MapUnit::Map100thMM)));
-
- Size aPagSize(pPage->GetSize());
- aPagSize.AdjustWidth(-(pPage->GetLftBorder() + pPage->GetRgtBorder()));
- aPagSize.AdjustHeight(-(pPage->GetUppBorder() + pPage->GetLwrBorder()));
-
- // scale to fit page
- if (((aGrfSize.Height() > aPagSize.Height()) || (aGrfSize.Width() > aPagSize.Width()))
- && aGrfSize.Height() && aPagSize.Height())
- {
- const double fGrfWH = static_cast<double>(aGrfSize.Width()) / aGrfSize.Height();
- const double fWinWH = static_cast<double>(aPagSize.Width()) / aPagSize.Height();
-
- // adjust graphic to page size (scales)
- if (fGrfWH < fWinWH)
- {
- aGrfSize.setWidth(static_cast<long>(aPagSize.Height() * fGrfWH));
- aGrfSize.setHeight(aPagSize.Height());
- }
- else if (fGrfWH > 0.F)
- {
- aGrfSize.setWidth(aPagSize.Width());
- aGrfSize.setHeight(static_cast<long>(aPagSize.Width() / fGrfWH));
- }
- }
-
- // Set the output rectangle of the Graphic.
- Point aPos;
- aPos.setX(((aPagSize.Width() - aGrfSize.Width()) >> 1) + pPage->GetLftBorder());
- aPos.setY(((aPagSize.Height() - aGrfSize.Height()) >> 1) + pPage->GetUppBorder());
+ const Size aGrfSize(OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(),
+ MapMode(MapUnit::Map100thMM)));
+
+ // Make the page size match the rendered image.
+ pPage->SetSize(aGrfSize);
+ Point aPos(0, 0);
pPage->InsertObject(new SdrGrafObj(aGraphic, tools::Rectangle(aPos, aGrfSize)));
}
commit 6a104fb42e4d0e5e394c3b4dd78b71cd756304d7
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Thu May 24 01:33:50 2018 -0400
sd: render the correct PDF page on swapping in
Change-Id: I81225e228d9cf2b9849110715dbfdeb59f2805dd
Reviewed-on: https://gerrit.libreoffice.org/54746
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/include/vcl/pdfread.hxx b/include/vcl/pdfread.hxx
index 969667dc17f9..003bc0a76907 100644
--- a/include/vcl/pdfread.hxx
+++ b/include/vcl/pdfread.hxx
@@ -18,6 +18,7 @@ namespace vcl
/// Imports a PDF stream into rGraphic as a GDIMetaFile.
VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Bitmap& rBitmap,
+ size_t nPageIndex,
css::uno::Sequence<sal_Int8>& rPdfData,
sal_uInt64 nPos = STREAM_SEEK_TO_BEGIN,
sal_uInt64 nSize = STREAM_SEEK_TO_END);
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index 1e17d91e5655..25f0370a81bf 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -129,11 +129,8 @@ bool SdPdfFilter::Import()
// Create the page and insert the Graphic.
SdPage* pPage = mrDocument.GetSdPage(nPageNumber++, PageKind::Standard);
-
- SAL_WARN("sd.filter", "Graphic PrefSize: " << aGraphic.GetPrefSize());
Size aGrfSize(OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(),
MapMode(MapUnit::Map100thMM)));
- SAL_WARN("sd.filter", "Graphic Logic Size: " << aGrfSize);
Size aPagSize(pPage->GetSize());
aPagSize.AdjustWidth(-(pPage->GetLftBorder() + pPage->GetRgtBorder()));
@@ -164,8 +161,6 @@ bool SdPdfFilter::Import()
aPos.setX(((aPagSize.Width() - aGrfSize.Width()) >> 1) + pPage->GetLftBorder());
aPos.setY(((aPagSize.Height() - aGrfSize.Height()) >> 1) + pPage->GetUppBorder());
- SAL_WARN("sd.filter", "Graphic Pos: " << aPos);
- SAL_WARN("sd.filter", "Graphic Logic Size: " << aGrfSize);
pPage->InsertObject(new SdrGrafObj(aGraphic, tools::Rectangle(aPos, aGrfSize)));
}
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 173596ba33ec..72f1ae43a3aa 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -211,12 +211,14 @@ namespace vcl
{
bool ImportPDF(SvStream& rStream, Bitmap& rBitmap,
+ size_t nPageIndex,
css::uno::Sequence<sal_Int8>& rPdfData,
sal_uInt64 nPos, sal_uInt64 nSize)
{
// Get the preview of the first page.
std::vector<Bitmap> aBitmaps;
- if (generatePreview(rStream, aBitmaps, nPos, nSize, 0, 1) != 1)
+ if (generatePreview(rStream, aBitmaps, nPos, nSize, nPageIndex, 1) != 1 ||
+ aBitmaps.empty())
return false;
rBitmap = aBitmaps[0];
@@ -239,7 +241,7 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
{
uno::Sequence<sal_Int8> aPdfData;
Bitmap aBitmap;
- bool bRet = ImportPDF(rStream, aBitmap, aPdfData);
+ bool bRet = ImportPDF(rStream, aBitmap, 0, aPdfData);
rGraphic = aBitmap;
rGraphic.setPdfData(std::make_shared<css::uno::Sequence<sal_Int8>>(aPdfData));
rGraphic.setPageNumber(0); // We currently import only the first page.
commit 687a1e593c896af2fbcaaca34f88980998c432be
Author: Jan Holesovsky <kendy at collabora.com>
Date: Tue May 22 10:47:46 2018 +0200
Introduce a LO_IMPORT_USE_PDFIUM envvar to force PDFium for PDF import.
Change-Id: Ibb7734430b955dad4aefec22260ba8694ccb9183
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 79e41343f61f..de065085c217 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -750,7 +750,7 @@ bool SfxObjectShell::DoLoad( SfxMedium *pMed )
{
// Experimental PDF importing using PDFium. This is currently enabled for LOK only and
// we handle it not via XmlFilterAdaptor but a new SdPdfFiler.
- const bool bPdfiumImport = comphelper::LibreOfficeKit::isActive() && pMedium->GetFilter() &&
+ const bool bPdfiumImport = (comphelper::LibreOfficeKit::isActive() || getenv("LO_IMPORT_USE_PDFIUM")) && pMedium->GetFilter() &&
(pMedium->GetFilter()->GetFilterName() == "draw_pdf_import");
pImpl->nLoadedFlags = SfxLoadedFlags::NONE;
pImpl->bModelInitialized = false;
commit 970720a472267b24682475aff8ae7408fa5aa28d
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun May 20 22:31:36 2018 -0400
sd: disable pdf import tests
Change-Id: Iaee679d2ff322c67d081185588103d5685fa970a
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 574447f60a79..95fb428cfd1b 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -133,7 +133,7 @@ public:
void testTableBorderLineStyle();
void testBnc862510_6();
void testBnc862510_7();
-#if ENABLE_PDFIMPORT
+#if ENABLE_PDFIMPORT && defined(IMPORT_PDF_ELEMENTS)
void testPDFImport();
void testPDFImportSkipImages();
#endif
@@ -212,7 +212,7 @@ public:
CPPUNIT_TEST(testTableBorderLineStyle);
CPPUNIT_TEST(testBnc862510_6);
CPPUNIT_TEST(testBnc862510_7);
-#if ENABLE_PDFIMPORT
+#if ENABLE_PDFIMPORT && defined(IMPORT_PDF_ELEMENTS)
CPPUNIT_TEST(testPDFImport);
CPPUNIT_TEST(testPDFImportSkipImages);
#endif
@@ -1186,7 +1186,7 @@ void SdImportTest::testBnc862510_7()
xDocShRef->DoClose();
}
-#if ENABLE_PDFIMPORT
+#if ENABLE_PDFIMPORT && defined(IMPORT_PDF_ELEMENTS)
void SdImportTest::testPDFImport()
{
commit ef332bcfac96ec0f492179f454be6a474c67c212
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun May 20 15:17:16 2018 -0400
svx: set the font name of imported PDF text
Change-Id: I79dde3c8983a70311de2d2a46093fac2722fb372
diff --git a/external/pdfium/edit.patch.1 b/external/pdfium/edit.patch.1
index de57d10e1be6..d0d7cb97060e 100644
--- a/external/pdfium/edit.patch.1
+++ b/external/pdfium/edit.patch.1
@@ -111,7 +111,7 @@ index fed1581..968b84a 100644
FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object,
void* buffer,
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
-index ec29891..a52e1a9 100644
+index ec29891..9daffc0 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -12,12 +12,14 @@
@@ -137,7 +137,7 @@ index ec29891..a52e1a9 100644
#include "fpdfsdk/cpdfsdk_helpers.h"
#include "public/fpdf_formfill.h"
#include "third_party/base/logging.h"
-@@ -624,3 +627,245 @@ FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap) {
+@@ -624,3 +627,268 @@ FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap) {
pPageObj->SetDirty(true);
return true;
}
@@ -162,6 +162,29 @@ index ec29891..a52e1a9 100644
+ return pTxtObj->GetFontSize();
+}
+
++FPDF_EXPORT int FPDF_CALLCONV
++FPDFTextObj_GetFontName(FPDF_PAGEOBJECT text_object, char* result)
++{
++ if (!text_object)
++ return 0;
++
++ CPDF_TextObject* pTxtObj = CPDFTextObjectFromFPDFPageObject(text_object);
++ CPDF_Font* pPdfFont = pTxtObj->GetFont();
++ if (!pPdfFont)
++ return 0;
++
++ CFX_Font* pFont = pPdfFont->GetFont();
++ if (!pFont)
++ return 0;
++
++ ByteString byte_str = pFont->GetFamilyName();
++ const size_t byte_str_len = byte_str.GetLength();
++
++ memcpy(result, byte_str.GetBuffer(byte_str_len).data(), byte_str_len);
++ result[byte_str_len] = '\0';
++ return byte_str_len;
++}
++
+FPDF_EXPORT void FPDF_CALLCONV
+FPDFTextObj_GetMatrix(FPDF_PAGEOBJECT text_object,
+ double* a,
@@ -495,7 +518,7 @@ index a1bbbb4..01b74c9 100644
int index,
double* left,
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
-index c0766a3..4351649 100644
+index c0766a3..75381bb 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
@@ -660,6 +660,15 @@ FPDFPageObj_GetStrokeColor(FPDF_PAGEOBJECT page_object,
@@ -551,7 +574,7 @@ index c0766a3..4351649 100644
// Create a new text object using one of the standard PDF fonts.
//
// document - handle to the document.
-@@ -971,6 +1010,125 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
+@@ -971,6 +1010,135 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
FPDF_FONT font,
float font_size);
@@ -564,7 +587,6 @@ index c0766a3..4351649 100644
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object);
+
-+
+// Get the font size of a text object.
+//
+// text_object - Handle of text object returned by FPDFPageObj_NewTextObj
@@ -575,6 +597,17 @@ index c0766a3..4351649 100644
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text_object);
+
++// Get the font name of a text object.
++//
++// text_object - Handle of text object returned by FPDFPageObj_NewTextObj
++// or FPDFPageObj_NewTextObjEx.
++// result - The result in ascii.
++//
++// Return Value:
++// The number of characters / bytes written in result.
++FPDF_EXPORT int FPDF_CALLCONV
++FPDFTextObj_GetFontName(FPDF_PAGEOBJECT text_object, char* result);
++
+// Get the matrix of a particular text object.
+//
+// text_object - Handle of text object returned by FPDFPageObj_NewTextObj
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 24102a135ece..5a90da06b6eb 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -927,6 +927,20 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
mbFntDirty = true;
}
+ std::unique_ptr<char[]> pFontName(new char[80 + 1]); // + terminating null
+ char* pCharFontName = reinterpret_cast<char*>(pFontName.get());
+ int nFontNameChars = FPDFTextObj_GetFontName(pPageObject, pCharFontName);
+ if (nFontNameChars > 0)
+ {
+ OUString sFontName = OUString::createFromAscii(pFontName.get());
+ if (sFontName != aFnt.GetFamilyName())
+ {
+ aFnt.SetFamilyName(sFontName);
+ mpVD->SetFont(aFnt);
+ mbFntDirty = true;
+ }
+ }
+
Color aTextColor(COL_TRANSPARENT);
unsigned int nR, nG, nB, nA;
if (FPDFTextObj_GetColor(pPageObject, &nR, &nG, &nB, &nA))
@@ -1209,11 +1223,11 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectI
if (!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aPolyPoly)))
{
- SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aPolyPoly);
- pPath->SetModel(mpModel);
- SetAttributes(pPath);
- InsertObj(pPath, false);
-}
+ SdrPathObj *pPath = new SdrPathObj(OBJ_POLY, aPolyPoly);
+ pPath->SetModel(mpModel);
+ SetAttributes(pPath);
+ InsertObj(pPath, false);
+ }
}
Point ImpSdrPdfImport::PointsToLogic(double x, double y) const
commit 02234666caa4af031dde9411193f7994c9e2746c
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sat May 19 21:28:31 2018 -0400
svx: update PDFium patch and code
Change-Id: I07c6a7c65d5631b70da64927a35d7a3b371eff25
diff --git a/external/pdfium/edit.patch.1 b/external/pdfium/edit.patch.1
index 5b23140c2069..de57d10e1be6 100644
--- a/external/pdfium/edit.patch.1
+++ b/external/pdfium/edit.patch.1
@@ -1,61 +1,10 @@
-diff --git a/core/fpdfapi/page/cpdf_colorstate.cpp b/core/fpdfapi/page/cpdf_colorstate.cpp
-index 693fcf1..14e883f 100644
---- a/core/fpdfapi/page/cpdf_colorstate.cpp
-+++ b/core/fpdfapi/page/cpdf_colorstate.cpp
-@@ -124,7 +124,7 @@ void CPDF_ColorState::SetColor(CPDF_Color& color,
- uint32_t& rgb,
- CPDF_ColorSpace* pCS,
- float* pValue,
-- uint32_t nValues) {
-+ uint32_t nValues) const {
- if (pCS)
- color.SetColorSpace(pCS);
- else if (color.IsNull())
-diff --git a/core/fpdfapi/page/cpdf_colorstate.h b/core/fpdfapi/page/cpdf_colorstate.h
-index 9619051..dbe9c47 100644
---- a/core/fpdfapi/page/cpdf_colorstate.h
-+++ b/core/fpdfapi/page/cpdf_colorstate.h
-@@ -64,7 +64,7 @@ class CPDF_ColorState {
- uint32_t& rgb,
- CPDF_ColorSpace* pCS,
- float* pValue,
-- uint32_t nValues);
-+ uint32_t nValues) const;
-
- SharedCopyOnWrite<ColorData> m_Ref;
- };
-diff --git a/core/fpdfapi/page/cpdf_pageobjectlist.cpp b/core/fpdfapi/page/cpdf_pageobjectlist.cpp
-index afd2c98..2c8e061 100644
---- a/core/fpdfapi/page/cpdf_pageobjectlist.cpp
-+++ b/core/fpdfapi/page/cpdf_pageobjectlist.cpp
-@@ -8,6 +8,6 @@
-
- #include "third_party/base/stl_util.h"
-
--CPDF_PageObject* CPDF_PageObjectList::GetPageObjectByIndex(int index) {
-+CPDF_PageObject* CPDF_PageObjectList::GetPageObjectByIndex(int index) const {
- return pdfium::IndexInBounds(*this, index) ? (*this)[index].get() : nullptr;
- }
-diff --git a/core/fpdfapi/page/cpdf_pageobjectlist.h b/core/fpdfapi/page/cpdf_pageobjectlist.h
-index b450537..77c7d81 100644
---- a/core/fpdfapi/page/cpdf_pageobjectlist.h
-+++ b/core/fpdfapi/page/cpdf_pageobjectlist.h
-@@ -15,7 +15,7 @@ class CPDF_PageObject;
- class CPDF_PageObjectList
- : public std::deque<std::unique_ptr<CPDF_PageObject>> {
- public:
-- CPDF_PageObject* GetPageObjectByIndex(int index);
-+ CPDF_PageObject* GetPageObjectByIndex(int index) const;
- };
-
- #endif // CORE_FPDFAPI_PAGE_CPDF_PAGEOBJECTLIST_H_
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
-index e712549..a7973f7 100644
+index 5690698..4d7c48a 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
-@@ -1490,3 +1490,32 @@ bool CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1,
- rect.Intersect(rect2);
- return !rect.IsEmpty();
+@@ -1464,3 +1464,32 @@ Optional<PAGECHAR_INFO> CPDF_TextPage::GenerateCharInfo(wchar_t unicode) {
+ info.m_Origin.x, info.m_Origin.y);
+ return info;
}
+
+WideString CPDF_TextPage::GetTextObjectText(CPDF_TextObject* pTextObj)
@@ -87,10 +36,10 @@ index e712549..a7973f7 100644
+ return strText;
+}
diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h
-index c87ab00..e5a1ba8 100644
+index 43a0312..7d5d5ec 100644
--- a/core/fpdftext/cpdf_textpage.h
+++ b/core/fpdftext/cpdf_textpage.h
-@@ -110,6 +110,8 @@ class CPDF_TextPage {
+@@ -105,6 +105,8 @@ class CPDF_TextPage {
WideString GetPageText(int start, int count) const;
WideString GetAllPageText() const { return GetPageText(0, CountChars()); }
@@ -99,12 +48,43 @@ index c87ab00..e5a1ba8 100644
int CountRects(int start, int nCount);
bool GetRect(int rectIndex, CFX_FloatRect* pRect) const;
-diff --git a/fpdfsdk/fpdfeditimg.cpp b/fpdfsdk/fpdfeditimg.cpp
-index 0d7ba56..37bdf99 100644
---- a/fpdfsdk/fpdfeditimg.cpp
-+++ b/fpdfsdk/fpdfeditimg.cpp
-@@ -167,6 +167,26 @@ FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object) {
- return pBitmap.Leak();
+diff --git a/fpdfsdk/cpdfsdk_helpers.h b/fpdfsdk/cpdfsdk_helpers.h
+index d93ecfc..c700592 100644
+--- a/fpdfsdk/cpdfsdk_helpers.h
++++ b/fpdfsdk/cpdfsdk_helpers.h
+@@ -40,7 +40,8 @@ class CPDF_TextPage;
+ class CPDF_TextPageFind;
+ class IPDFSDK_PauseAdapter;
+ class FX_PATHPOINT;
+-
++class CPDF_TextObject;
++class CPDF_FormObject;
+ #ifdef PDF_ENABLE_XFA
+ class CPDFXFA_Context;
+ class CPDFXFA_Page;
+@@ -204,6 +205,16 @@ inline CPDF_TextPageFind* CPDFTextPageFindFromFPDFSchHandle(
+ return reinterpret_cast<CPDF_TextPageFind*>(handle);
+ }
+
++inline CPDF_TextObject* CPDFTextObjectFromFPDFPageObject(
++ FPDF_PAGEOBJECT page_object) {
++ return reinterpret_cast<CPDF_TextObject*>(page_object);
++}
++
++inline CPDF_FormObject* CPDFFormObjectFromFPDFPageObject(
++ FPDF_PAGEOBJECT page_object) {
++ return reinterpret_cast<CPDF_FormObject*>(page_object);
++}
++
+ ByteString CFXByteStringFromFPDFWideString(FPDF_WIDESTRING wide_string);
+
+ #ifdef PDF_ENABLE_XFA
+diff --git a/fpdfsdk/fpdf_editimg.cpp b/fpdfsdk/fpdf_editimg.cpp
+index fed1581..968b84a 100644
+--- a/fpdfsdk/fpdf_editimg.cpp
++++ b/fpdfsdk/fpdf_editimg.cpp
+@@ -186,6 +186,26 @@ FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object) {
+ return FPDFBitmapFromCFXDIBitmap(pBitmap.Leak());
}
+FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV
@@ -124,18 +104,18 @@ index 0d7ba56..37bdf99 100644
+ RetainPtr<CFX_DIBitmap> pBitmap;
+ pBitmap = pSource->CloneConvert(FXDIB_Argb);
+
-+ return pBitmap.Leak();
++ return FPDFBitmapFromCFXDIBitmap(pBitmap.Leak());
+}
+
FPDF_EXPORT unsigned long FPDF_CALLCONV
FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object,
void* buffer,
-diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
-index ca2cf3f..1eaa232 100644
---- a/fpdfsdk/fpdfeditpage.cpp
-+++ b/fpdfsdk/fpdfeditpage.cpp
-@@ -11,12 +11,14 @@
- #include <utility>
+diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
+index ec29891..a52e1a9 100644
+--- a/fpdfsdk/fpdf_editpage.cpp
++++ b/fpdfsdk/fpdf_editpage.cpp
+@@ -12,12 +12,14 @@
+ #include <vector>
#include "core/fpdfapi/edit/cpdf_pagecontentgenerator.h"
+#include "core/fpdfapi/font/cpdf_font.h"
@@ -149,16 +129,16 @@ index ca2cf3f..1eaa232 100644
#include "core/fpdfapi/page/cpdf_shadingobject.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_document.h"
-@@ -24,6 +26,7 @@
+@@ -25,6 +27,7 @@
#include "core/fpdfapi/parser/cpdf_string.h"
#include "core/fpdfdoc/cpdf_annot.h"
#include "core/fpdfdoc/cpdf_annotlist.h"
+#include "core/fpdftext/cpdf_textpage.h"
- #include "fpdfsdk/fsdk_define.h"
+ #include "fpdfsdk/cpdfsdk_helpers.h"
#include "public/fpdf_formfill.h"
#include "third_party/base/logging.h"
-@@ -363,3 +366,240 @@ FPDFPageObj_GetBounds(FPDF_PAGEOBJECT pageObject,
- *top = bbox.top;
+@@ -624,3 +627,245 @@ FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap) {
+ pPageObj->SetDirty(true);
return true;
}
+
@@ -252,7 +232,7 @@ index ca2cf3f..1eaa232 100644
+ int ret_count = byte_str_len / sizeof(unsigned short);
+
+ ASSERT(ret_count <= char_count + 1); // +1 to account for the NUL terminator.
-+ memcpy(result, byte_str.GetBuffer(byte_str_len), byte_str_len);
++ memcpy(result, byte_str.GetBuffer(byte_str_len).data(), byte_str_len);
+ return ret_count;
+}
+
@@ -292,7 +272,7 @@ index ca2cf3f..1eaa232 100644
+ int ret_count = byte_str_len / kBytesPerCharacter;
+
+ ASSERT(ret_count <= char_count + 1); // +1 to account for the NUL terminator.
-+ memcpy(result, byte_str.GetBuffer(byte_str_len), byte_str_len);
++ memcpy(result, byte_str.GetBuffer(byte_str_len).data(), byte_str_len);
+ return ret_count;
+}
+
@@ -335,10 +315,15 @@ index ca2cf3f..1eaa232 100644
+ return false;
+ }
+
-+ const uint32_t RGB = bStroke ? pTxtObj->m_ColorState.GetStrokeRGB() : pTxtObj->m_ColorState.GetFillRGB();
-+ *R = FXSYS_GetRValue(RGB);
-+ *G = FXSYS_GetGValue(RGB);
-+ *B = FXSYS_GetBValue(RGB);
++ const CPDF_Color* pColor = bStroke ? pTxtObj->m_ColorState.GetStrokeColor() : pTxtObj->m_ColorState.GetFillColor();
++ if (pColor == nullptr)
++ return false;
++
++ int r, g, b;
++ pColor->GetRGB(&r, &g, &b);
++ *R = r;
++ *G = g;
++ *B = b;
+ *A = static_cast<unsigned int>(
+ (pTxtObj->m_GeneralState.GetStrokeAlpha() * 255.f) + 0.5f);
+
@@ -368,7 +353,7 @@ index ca2cf3f..1eaa232 100644
+ const CFX_Matrix& matrix = pFrmObj->form_matrix();
+ const CPDF_PageObjectList* pObjectList = pFrmObj->form()->GetPageObjectList();
+ if (pObjectList)
-+ return pObjectList->GetPageObjectByIndex(index);
++ return FPDFPageObjectFromCPDFPageObject(pObjectList->GetPageObjectByIndex(index));
+ }
+
+ return nullptr;
@@ -398,11 +383,11 @@ index ca2cf3f..1eaa232 100644
+ *f = matrix.f;
+ }
+}
-diff --git a/fpdfsdk/fpdfeditpath.cpp b/fpdfsdk/fpdfeditpath.cpp
-index a291987..0202284 100644
---- a/fpdfsdk/fpdfeditpath.cpp
-+++ b/fpdfsdk/fpdfeditpath.cpp
-@@ -101,6 +101,16 @@ FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width) {
+diff --git a/fpdfsdk/fpdf_editpath.cpp b/fpdfsdk/fpdf_editpath.cpp
+index aca2beb..017dbcd 100644
+--- a/fpdfsdk/fpdf_editpath.cpp
++++ b/fpdfsdk/fpdf_editpath.cpp
+@@ -117,6 +117,16 @@ FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width) {
return true;
}
@@ -419,7 +404,7 @@ index a291987..0202284 100644
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetFillColor(FPDF_PAGEOBJECT path,
unsigned int R,
unsigned int G,
-@@ -217,6 +227,25 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
+@@ -235,6 +245,25 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
return true;
}
@@ -445,7 +430,7 @@ index a291987..0202284 100644
FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineJoin(FPDF_PAGEOBJECT path,
int line_join) {
if (!path)
-@@ -250,6 +279,30 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineCap(FPDF_PAGEOBJECT path,
+@@ -268,6 +297,30 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineCap(FPDF_PAGEOBJECT path,
}
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
@@ -476,22 +461,11 @@ index a291987..0202284 100644
FPDFPathSegment_GetPoint(FPDF_PATHSEGMENT segment, float* x, float* y) {
auto* pPathPoint = FXPathPointFromFPDFPathSegment(segment);
if (!pPathPoint || !x || !y)
-diff --git a/fpdfsdk/fpdftext.cpp b/fpdfsdk/fpdftext.cpp
-index 68bf4f8..1cac9c7 100644
---- a/fpdfsdk/fpdftext.cpp
-+++ b/fpdfsdk/fpdftext.cpp
-@@ -31,10 +31,6 @@ namespace {
-
- constexpr size_t kBytesPerCharacter = sizeof(unsigned short);
-
--CPDF_TextPage* CPDFTextPageFromFPDFTextPage(FPDF_TEXTPAGE text_page) {
-- return static_cast<CPDF_TextPage*>(text_page);
--}
--
- CPDF_TextPageFind* CPDFTextPageFindFromFPDFSchHandle(FPDF_SCHHANDLE handle) {
- return static_cast<CPDF_TextPageFind*>(handle);
- }
-@@ -105,6 +101,28 @@ FPDF_EXPORT double FPDF_CALLCONV FPDFText_GetFontSize(FPDF_TEXTPAGE text_page,
+diff --git a/fpdfsdk/fpdf_text.cpp b/fpdfsdk/fpdf_text.cpp
+index a1bbbb4..01b74c9 100644
+--- a/fpdfsdk/fpdf_text.cpp
++++ b/fpdfsdk/fpdf_text.cpp
+@@ -95,6 +95,28 @@ FPDF_EXPORT double FPDF_CALLCONV FPDFText_GetFontSize(FPDF_TEXTPAGE text_page,
return charinfo.m_FontSize;
}
@@ -520,65 +494,13 @@ index 68bf4f8..1cac9c7 100644
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetCharBox(FPDF_TEXTPAGE text_page,
int index,
double* left,
-diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
-index e890aa0..09d2345 100644
---- a/fpdfsdk/fpdfview.cpp
-+++ b/fpdfsdk/fpdfview.cpp
-@@ -336,6 +336,20 @@ CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {
- #endif // PDF_ENABLE_XFA
- }
-
-+CPDF_TextPage* CPDFTextPageFromFPDFTextPage(FPDF_TEXTPAGE text_page) {
-+ return static_cast<CPDF_TextPage*>(text_page);
-+}
-+
-+CPDF_TextObject* CPDFTextObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object) {
-+ auto* obj = CPDFPageObjectFromFPDFPageObject(page_object);
-+ return obj ? obj->AsText() : nullptr;
-+}
-+
-+CPDF_FormObject* CPDFFormObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object) {
-+ auto* obj = CPDFPageObjectFromFPDFPageObject(page_object);
-+ return obj ? obj->AsForm() : nullptr;
-+}
-+
- CPDF_PathObject* CPDFPathObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object) {
- auto* obj = CPDFPageObjectFromFPDFPageObject(page_object);
- return obj ? obj->AsPath() : nullptr;
-diff --git a/fpdfsdk/fsdk_define.h b/fpdfsdk/fsdk_define.h
-index 77c2315..e9a309a 100644
---- a/fpdfsdk/fsdk_define.h
-+++ b/fpdfsdk/fsdk_define.h
-@@ -25,6 +25,9 @@ class CPDF_Annot;
- class CPDF_Page;
- class CPDF_PageObject;
- class CPDF_PageRenderContext;
-+class CPDF_TextObject;
-+class CPDF_TextPage;
-+class CPDF_FormObject;
- class CPDF_PathObject;
- class CPDF_Stream;
- class IFSDK_PAUSE_Adapter;
-@@ -65,6 +68,12 @@ FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc);
-
- CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page);
-
-+CPDF_TextPage* CPDFTextPageFromFPDFTextPage(FPDF_TEXTPAGE text_page);
-+
-+CPDF_TextObject* CPDFTextObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object);
-+
-+CPDF_FormObject* CPDFFormObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object);
-+
- CPDF_PathObject* CPDFPathObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object);
-
- CPDF_PageObject* CPDFPageObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object);
diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
-index 54735a3..4d81aac 100644
+index c0766a3..4351649 100644
--- a/public/fpdf_edit.h
+++ b/public/fpdf_edit.h
-@@ -520,6 +520,15 @@ FPDFPath_GetStrokeColor(FPDF_PAGEOBJECT path,
- FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
- FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width);
+@@ -660,6 +660,15 @@ FPDFPageObj_GetStrokeColor(FPDF_PAGEOBJECT page_object,
+ unsigned int* B,
+ unsigned int* A);
+// Get the stroke width of a path.
+//
@@ -589,10 +511,10 @@ index 54735a3..4d81aac 100644
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
+FPDFPath_GetStrokeWidth(FPDF_PAGEOBJECT path, float* width);
+
- // Set the line join of |page_object|.
+ // Set the stroke width of a path.
//
- // page_object - handle to a page object.
-@@ -688,6 +697,36 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
+ // path - the handle to the path object.
+@@ -898,6 +907,36 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
int fillmode,
FPDF_BOOL stroke);
@@ -629,7 +551,7 @@ index 54735a3..4d81aac 100644
// Create a new text object using one of the standard PDF fonts.
//
// document - handle to the document.
-@@ -761,6 +800,125 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
+@@ -971,6 +1010,125 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
FPDF_FONT font,
float font_size);
@@ -756,7 +678,7 @@ index 54735a3..4d81aac 100644
} // extern "C"
#endif // __cplusplus
diff --git a/public/fpdf_text.h b/public/fpdf_text.h
-index 043dc16..fe3b971 100644
+index 3502337..6524cd3 100644
--- a/public/fpdf_text.h
+++ b/public/fpdf_text.h
@@ -342,6 +342,26 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetSchCount(FPDF_SCHHANDLE handle);
@@ -787,10 +709,10 @@ index 043dc16..fe3b971 100644
// Prepare information about weblinks in a page.
// Parameters:
diff --git a/public/fpdfview.h b/public/fpdfview.h
-index 35e87ae..80ab0ad 100644
+index 0ccd140..b451b9c 100644
--- a/public/fpdfview.h
+++ b/public/fpdfview.h
-@@ -908,6 +908,9 @@ FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_CreateEx(int width,
+@@ -905,6 +905,9 @@ FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_CreateEx(int width,
// function; see the list of such formats above.
FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetFormat(FPDF_BITMAP bitmap);
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 930142469d86..24102a135ece 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1027,7 +1027,8 @@ void ImpSdrPdfImport::MapScaling()
void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectIndex*/)
{
- std::unique_ptr<void, FPDFBitmapDeleter> bitmap(FPDFImageObj_GetBitmapBgra(pPageObject));
+ std::unique_ptr<std::remove_pointer<FPDF_BITMAP>::type, FPDFBitmapDeleter>
+ bitmap(FPDFImageObj_GetBitmapBgra(pPageObject));
if (!bitmap)
{
SAL_WARN("sd.filter", "Failed to get IMAGE");
diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx
index 6ff8b5259c5b..a4a59a8bff82 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -40,9 +40,9 @@ class SdrModel;
class SdrPage;
class SdrObject;
class SvdProgressInfo;
-typedef void* FPDF_DOCUMENT;
-typedef void* FPDF_PAGEOBJECT;
-typedef void* FPDF_TEXTPAGE;
+typedef struct fpdf_document_t__* FPDF_DOCUMENT;
+typedef struct fpdf_pageobject_t__* FPDF_PAGEOBJECT; // (text, path, etc.)
+typedef struct fpdf_textpage_t__* FPDF_TEXTPAGE;
// Helper Class to import PDF
class ImpSdrPdfImport final
commit cc84e3d4122cd5eb435f59298f34f099fa93a495
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon May 14 08:55:58 2018 +0200
pdfium: update to 3426
Allows dropping the ugly freetype.patch.1.
Reviewed-on: https://gerrit.libreoffice.org/54294
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
(cherry picked from commit 56195a4d0bbb21edeed1cea7a45283141c733f18)
Change-Id: Ifa8a6dac02a49a2c13572e59773261a847efad3f
diff --git a/download.lst b/download.lst
index e394c3cd1fb2..6bcc3d59974c 100644
--- a/download.lst
+++ b/download.lst
@@ -216,8 +216,8 @@ export OWNCLOUD_ANDROID_LIB_SHA256SUM := b18b3e3ef7fae6a79b62f2bb43cc47a5346b633
export OWNCLOUD_ANDROID_LIB_TARBALL := owncloud-android-library-0.9.4-no-binary-deps.tar.gz
export PAGEMAKER_SHA256SUM := 66adacd705a7d19895e08eac46d1e851332adf2e736c566bef1164e7a442519d
export PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz
-export PDFIUM_SHA256SUM := 0cd451fb1b301dc1df55f91e644092e505032dcddbdeaf3e2744039377d1bfd0
-export PDFIUM_TARBALL := pdfium-3358.tar.bz2
+export PDFIUM_SHA256SUM := 80331b48166501a192d65476932f17044eeb5f10faa6ea50f4f175169475c957
+export PDFIUM_TARBALL := pdfium-3426.tar.bz2
export PIXMAN_SHA256SUM := 21b6b249b51c6800dc9553b65106e1e37d0e25df942c90531d4c3997aa20a88e
export PIXMAN_TARBALL := e80ebae4da01e77f68744319f01d52a3-pixman-0.34.0.tar.gz
export LIBPNG_SHA256SUM := 2f1e960d92ce3b3abd03d06dfec9637dfbd22febf107a536b44f7a47c60659f6
diff --git a/external/pdfium/Library_pdfium.mk b/external/pdfium/Library_pdfium.mk
index 46f1edeb6f42..5f845154203d 100644
--- a/external/pdfium/Library_pdfium.mk
+++ b/external/pdfium/Library_pdfium.mk
@@ -40,7 +40,6 @@ $(eval $(call gb_Library_set_generated_cxx_suffix,pdfium,cpp))
# pdfium
$(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
- UnpackedTarball/pdfium/fpdfsdk/cba_annotiterator \
UnpackedTarball/pdfium/fpdfsdk/cfx_systemhandler \
UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_annot \
UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_annothandlermgr \
@@ -61,22 +60,27 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/fpdfsdk/fpdf_structtree \
UnpackedTarball/pdfium/fpdfsdk/fpdf_sysfontinfo \
UnpackedTarball/pdfium/fpdfsdk/fpdf_transformpage \
- UnpackedTarball/pdfium/fpdfsdk/fpdfdoc \
- UnpackedTarball/pdfium/fpdfsdk/fpdfeditimg \
- UnpackedTarball/pdfium/fpdfsdk/fpdfeditpage \
- UnpackedTarball/pdfium/fpdfsdk/fpdfeditpath \
- UnpackedTarball/pdfium/fpdfsdk/fpdfedittext \
- UnpackedTarball/pdfium/fpdfsdk/fpdfformfill \
- UnpackedTarball/pdfium/fpdfsdk/fpdfsave \
- UnpackedTarball/pdfium/fpdfsdk/fpdftext \
- UnpackedTarball/pdfium/fpdfsdk/fpdfview \
- UnpackedTarball/pdfium/fpdfsdk/fsdk_actionhandler \
- UnpackedTarball/pdfium/fpdfsdk/fsdk_pauseadapter \
- UnpackedTarball/pdfium/fpdfsdk/pdfsdk_fieldaction \
- UnpackedTarball/pdfium/fpdfsdk/fsdk_filewriteadapter \
- UnpackedTarball/pdfium/fpdfsdk/fpdfannot \
- UnpackedTarball/pdfium/fpdfsdk/fpdfattachment \
- UnpackedTarball/pdfium/fpdfsdk/fpdfcatalog \
+ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_actionhandler \
+ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_annotiterator \
+ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_customaccess \
+ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_fieldaction \
+ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_filewriteadapter \
+ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_helpers \
+ UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_memoryaccess \
+ UnpackedTarball/pdfium/fpdfsdk/fpdf_annot \
+ UnpackedTarball/pdfium/fpdfsdk/fpdf_attachment \
+ UnpackedTarball/pdfium/fpdfsdk/fpdf_catalog \
+ UnpackedTarball/pdfium/fpdfsdk/fpdf_doc \
+ UnpackedTarball/pdfium/fpdfsdk/fpdf_editimg \
+ UnpackedTarball/pdfium/fpdfsdk/fpdf_editpage \
+ UnpackedTarball/pdfium/fpdfsdk/fpdf_editpath \
+ UnpackedTarball/pdfium/fpdfsdk/fpdf_edittext \
+ UnpackedTarball/pdfium/fpdfsdk/fpdf_formfill \
+ UnpackedTarball/pdfium/fpdfsdk/fpdf_save \
+ UnpackedTarball/pdfium/fpdfsdk/fpdf_text \
+ UnpackedTarball/pdfium/fpdfsdk/fpdf_view \
+ UnpackedTarball/pdfium/fpdfsdk/ipdfsdk_pauseadapter \
+ UnpackedTarball/pdfium/fpdfsdk/cpdf_annotcontext \
))
# fdrm
@@ -356,7 +360,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
# fxcrt
$(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
- UnpackedTarball/pdfium/core/fxcrt/cfx_blockbuffer \
UnpackedTarball/pdfium/core/fxcrt/cfx_memorystream \
UnpackedTarball/pdfium/core/fxcrt/cfx_seekablestreamproxy \
UnpackedTarball/pdfium/core/fxcrt/fx_bidi \
@@ -367,13 +370,13 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fxcrt/fx_system \
UnpackedTarball/pdfium/core/fxcrt/fx_ucddata \
UnpackedTarball/pdfium/core/fxcrt/fx_unicode \
- UnpackedTarball/pdfium/core/fxcrt/xml/cxml_attritem \
- UnpackedTarball/pdfium/core/fxcrt/xml/cxml_databufacc \
- UnpackedTarball/pdfium/core/fxcrt/xml/cxml_element \
- UnpackedTarball/pdfium/core/fxcrt/xml/cxml_parser \
- UnpackedTarball/pdfium/core/fxcrt/xml/cxml_content \
- UnpackedTarball/pdfium/core/fxcrt/xml/cxml_object \
- UnpackedTarball/pdfium/core/fxcrt/xml/cfx_saxcontext \
+ UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmldocument \
+ UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmlelement \
+ UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmlparser \
+ UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmlnode \
+ UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmlinstruction \
+ UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmltext \
+ UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmlchardata \
UnpackedTarball/pdfium/core/fxcrt/css/cfx_csscolorvalue \
UnpackedTarball/pdfium/core/fxcrt/css/cfx_csscomputedstyle \
UnpackedTarball/pdfium/core/fxcrt/css/cfx_csscustomproperty \
@@ -406,6 +409,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fxcrt/widestring \
UnpackedTarball/pdfium/core/fxcrt/cfx_seekablemultistream \
UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssdata \
+ UnpackedTarball/pdfium/core/fxcrt/fx_codepage \
))
# fxge
@@ -439,7 +443,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fxge/fontdata/chromefontdata/FoxitSerifMM \
UnpackedTarball/pdfium/core/fxge/fontdata/chromefontdata/FoxitSymbol \
UnpackedTarball/pdfium/core/fxge/freetype/fx_freetype \
- UnpackedTarball/pdfium/core/fxge/ifx_renderdevicedriver \
+ UnpackedTarball/pdfium/core/fxge/renderdevicedriver_iface \
UnpackedTarball/pdfium/core/fxge/agg/fx_agg_driver \
UnpackedTarball/pdfium/core/fxge/cfx_cliprgn \
UnpackedTarball/pdfium/core/fxge/cfx_color \
@@ -466,6 +470,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
$(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/fxjs/cjs_event_context_stub \
UnpackedTarball/pdfium/fxjs/cjs_runtimestub \
+ UnpackedTarball/pdfium/fxjs/ijs_runtime \
))
# pwl
@@ -546,6 +551,8 @@ $(eval $(call gb_Library_use_externals,pdfium,\
libjpeg \
lcms2 \
zlib \
+ icu_headers \
+ icuuc \
))
ifeq ($(OS),LINUX)
@@ -579,10 +586,8 @@ $(eval $(call gb_Library_add_generated_cobjects,pdfium,\
UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftbitmap \
UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftglyph \
UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftinit \
- UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftlcdfil \
UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftmm \
UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftsystem \
- UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftfntfmt \
UnpackedTarball/pdfium/third_party/freetype/src/src/cff/cff \
UnpackedTarball/pdfium/third_party/freetype/src/src/cid/type1cid \
UnpackedTarball/pdfium/third_party/freetype/src/src/psaux/psaux \
@@ -603,7 +608,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
UnpackedTarball/pdfium/core/fxge/win32/cpsoutput \
UnpackedTarball/pdfium/core/fxge/win32/fx_win32_device \
UnpackedTarball/pdfium/core/fxge/win32/fx_win32_dib \
- UnpackedTarball/pdfium/core/fxge/win32/fx_win32_dwrite \
UnpackedTarball/pdfium/core/fxge/win32/fx_win32_gdipext \
UnpackedTarball/pdfium/core/fxge/win32/fx_win32_print \
))
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk
index c917d63a4cdd..6a20b8f7d590 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -10,7 +10,7 @@
pdfium_patches :=
pdfium_patches += visibility.patch.1
pdfium_patches += ubsan.patch
-pdfium_patches += freetype.patch.1
+pdfium_patches += icu.patch.1
# Fixes build on our baseline.
pdfium_patches += build.patch.1
# Adds missing editing API
diff --git a/external/pdfium/build.patch.1 b/external/pdfium/build.patch.1
index b852383ff84b..89d8e5e7d8d0 100644
--- a/external/pdfium/build.patch.1
+++ b/external/pdfium/build.patch.1
@@ -19,3 +19,106 @@ index 8e01127b0..f4ce4d915 100644
if (m_Storer.GetBitmap()->IsAlphaMask()) {
CalcAlpha(cdata);
} else {
+diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
+index 05694cf24..101253814 100644
+--- a/core/fxcrt/string_view_template.h
++++ b/core/fxcrt/string_view_template.h
+@@ -231,9 +231,6 @@ inline bool operator<(const T* lhs, const StringViewTemplate<T>& rhs) {
+ return rhs > lhs;
+ }
+
+-extern template class StringViewTemplate<char>;
+-extern template class StringViewTemplate<wchar_t>;
+-
+ using ByteStringView = StringViewTemplate<char>;
+ using WideStringView = StringViewTemplate<wchar_t>;
+
+diff --git a/core/fpdfdoc/cpdf_metadata.cpp b/core/fpdfdoc/cpdf_metadata.cpp
+index 323de4ffc..f11a0b0ad 100644
+--- a/core/fpdfdoc/cpdf_metadata.cpp
++++ b/core/fpdfdoc/cpdf_metadata.cpp
+@@ -74,7 +74,7 @@ std::vector<UnsupportedFeature> CPDF_Metadata::CheckForSharedForm() const {
+ CFX_XMLParser parser(stream);
+ std::unique_ptr<CFX_XMLDocument> doc = parser.Parse();
+ if (!doc)
+- return {};
++ return std::vector<UnsupportedFeature>();
+
+ std::vector<UnsupportedFeature> unsupported;
+ CheckForSharedFormInternal(doc->GetRoot(), &unsupported);
+diff --git a/fpdfsdk/cpdf_annotcontext.cpp b/fpdfsdk/cpdf_annotcontext.cpp
+index 20c5fc343..a40cd1eae 100644
+--- a/fpdfsdk/cpdf_annotcontext.cpp
++++ b/fpdfsdk/cpdf_annotcontext.cpp
+@@ -16,12 +16,12 @@ CPDF_AnnotContext::CPDF_AnnotContext(CPDF_Dictionary* pAnnotDict,
+ CPDF_Page* pPage,
+ CPDF_Stream* pStream)
+ : m_pAnnotDict(pAnnotDict), m_pPage(pPage) {
+- SetForm(pStream);
++ SetForm_(pStream);
+ }
+
+ CPDF_AnnotContext::~CPDF_AnnotContext() = default;
+
+-void CPDF_AnnotContext::SetForm(CPDF_Stream* pStream) {
++void CPDF_AnnotContext::SetForm_(CPDF_Stream* pStream) {
+ if (!pStream)
+ return;
+
+diff --git a/fpdfsdk/cpdf_annotcontext.h b/fpdfsdk/cpdf_annotcontext.h
+index 38cc91e03..7904ae044 100644
+--- a/fpdfsdk/cpdf_annotcontext.h
++++ b/fpdfsdk/cpdf_annotcontext.h
+@@ -23,7 +23,7 @@ class CPDF_AnnotContext {
+ CPDF_Stream* pStream);
+ ~CPDF_AnnotContext();
+
+- void SetForm(CPDF_Stream* pStream);
++ void SetForm_(CPDF_Stream* pStream);
+ bool HasForm() const { return !!m_pAnnotForm; }
+ CPDF_Form* GetForm() const { return m_pAnnotForm.get(); }
+ CPDF_Dictionary* GetAnnotDict() const { return m_pAnnotDict.Get(); }
+diff --git a/third_party/base/span.h b/third_party/base/span.h
+index 0fb627ba8..f71c362e2 100644
+--- a/third_party/base/span.h
++++ b/third_party/base/span.h
+@@ -214,7 +214,7 @@ class span {
+ // Conversions from spans of compatible types: this allows a span<T> to be
+ // seamlessly used as a span<const T>, but not the other way around.
+ template <typename U, typename = internal::EnableIfLegalSpanConversion<U, T>>
+- constexpr span(const span<U>& other) : span(other.data(), other.size()) {}
++ span(const span<U>& other) : span(other.data(), other.size()) {}
+ span& operator=(const span& other) noexcept = default;
+ ~span() noexcept {
+ if (!size_) {
+diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp
+index d3bf38d31..e8aea9707 100644
+--- a/fpdfsdk/fpdf_annot.cpp
++++ b/fpdfsdk/fpdf_annot.cpp
+@@ -389,7 +389,7 @@ FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj) {
+
+ // Get the annotation's corresponding form object for parsing its AP stream.
+ if (!pAnnot->HasForm())
+- pAnnot->SetForm(pStream);
++ pAnnot->SetForm_(pStream);
+
+ // Check that the object did not come from the same annotation. If this check
+ // succeeds, then it is assumed that the object came from
+@@ -425,7 +425,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetObjectCount(FPDF_ANNOTATION annot) {
+ if (!pStream)
+ return 0;
+
+- pAnnot->SetForm(pStream);
++ pAnnot->SetForm_(pStream);
+ }
+ return pdfium::CollectionSize<int>(*pAnnot->GetForm()->GetPageObjectList());
+ }
+@@ -442,7 +442,7 @@ FPDFAnnot_GetObject(FPDF_ANNOTATION annot, int index) {
+ if (!pStream)
+ return nullptr;
+
+- pAnnot->SetForm(pStream);
++ pAnnot->SetForm_(pStream);
+ }
+
+ return FPDFPageObjectFromCPDFPageObject(
diff --git a/external/pdfium/freetype.patch.1 b/external/pdfium/freetype.patch.1
deleted file mode 100644
index 90f230c54e69..000000000000
--- a/external/pdfium/freetype.patch.1
+++ /dev/null
@@ -1,18 +0,0 @@
-Upstream provides this define from the commandline, but while this define is
-needed for fxge, it breaks the build for the bundled freetype. gbuild doesn't
-support having different defines within the same Library, so just patch the
-single translation unit that actually needs the define.
-
-Long-term perhaps the solution is to enable freetype on all platforms inside
-LO, then we don't have to build freetype as part of pdfium, so we can let
-gbuild define this from the commandline.
-
-diff --git a/core/fxge/freetype/fx_freetype.cpp b/core/fxge/freetype/fx_freetype.cpp
-index 0ae207b02..879bf5ab9 100644
---- a/core/fxge/freetype/fx_freetype.cpp
-+++ b/core/fxge/freetype/fx_freetype.cpp
-@@ -1,3 +1,4 @@
-+#define DEFINE_PS_TABLES
- // Copyright 2014 PDFium Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
diff --git a/external/pdfium/icu.patch.1 b/external/pdfium/icu.patch.1
new file mode 100644
index 000000000000..85e837d9b99f
--- /dev/null
+++ b/external/pdfium/icu.patch.1
@@ -0,0 +1,13 @@
+diff --git a/core/fxcrt/fx_extension.h b/core/fxcrt/fx_extension.h
+index ff96de0f7..0195bd06f 100644
+--- a/core/fxcrt/fx_extension.h
++++ b/core/fxcrt/fx_extension.h
+@@ -13,7 +13,7 @@
+
+ #include "core/fxcrt/fx_string.h"
+ #include "third_party/base/span.h"
+-#include "third_party/icu/source/common/unicode/uchar.h"
++#include <unicode/uchar.h>
+
+ #define FX_INVALID_OFFSET static_cast<uint32_t>(-1)
+
diff --git a/external/pdfium/ubsan.patch b/external/pdfium/ubsan.patch
index af39e3d95db3..91428326fc5d 100644
--- a/external/pdfium/ubsan.patch
+++ b/external/pdfium/ubsan.patch
@@ -22,22 +22,3 @@
int rowbytes = std::min(abs(src_pitch), dest_pitch);
for (int row = 0; row < bmheight; row++)
memcpy(pDestBuf + row * dest_pitch, pSrcBuf + row * src_pitch, rowbytes);
---- third_party/agg23/agg_rasterizer_scanline_aa.h
-+++ third_party/agg23/agg_rasterizer_scanline_aa.h
-@@ -349,14 +349,14 @@ public:
- cover += cur_cell->cover;
- }
- if(area) {
-- alpha = calculate_alpha((cover << (poly_base_shift + 1)) - area, no_smooth);
-+ alpha = calculate_alpha(int(unsigned(cover) << (poly_base_shift + 1)) - area, no_smooth);
- if(alpha) {
- sl.add_cell(x, alpha);
- }
- x++;
- }
- if(num_cells && cur_cell->x > x) {
-- alpha = calculate_alpha(cover << (poly_base_shift + 1), no_smooth);
-+ alpha = calculate_alpha(unsigned(cover) << (poly_base_shift + 1), no_smooth);
- if(alpha) {
- sl.add_span(x, cur_cell->x - x, alpha);
- }
commit d8712247b9b5a573c2eb838793d2e7f62022aa1d
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Fri May 18 09:15:36 2018 -0400
svx: cleanup pdfium importer
Change-Id: Id925ba7734a2c73270e40f19d3fc50552441c34e
diff --git a/external/pdfium/edit.patch.1 b/external/pdfium/edit.patch.1
index a110313017da..5b23140c2069 100644
--- a/external/pdfium/edit.patch.1
+++ b/external/pdfium/edit.patch.1
@@ -1,43 +1,8 @@
diff --git a/core/fpdfapi/page/cpdf_colorstate.cpp b/core/fpdfapi/page/cpdf_colorstate.cpp
-index 693fcf1..d3e1202 100644
+index 693fcf1..14e883f 100644
--- a/core/fpdfapi/page/cpdf_colorstate.cpp
+++ b/core/fpdfapi/page/cpdf_colorstate.cpp
-@@ -74,6 +74,8 @@ void CPDF_ColorState::SetFillColor(CPDF_ColorSpace* pCS,
- uint32_t nValues) {
- ColorData* pData = m_Ref.GetPrivateCopy();
- SetColor(pData->m_FillColor, pData->m_FillRGB, pCS, pValue, nValues);
-+ if (pData->m_FillRGB != 0 && pData->m_FillRGB != 0xFFFFFFFF)
-+ fprintf(stderr, "COLOR FILL!!!!> %x\n", pData->m_FillRGB);
- }
-
- void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS,
-@@ -81,6 +83,8 @@ void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS,
- uint32_t nValues) {
- ColorData* pData = m_Ref.GetPrivateCopy();
- SetColor(pData->m_StrokeColor, pData->m_StrokeRGB, pCS, pValue, nValues);
-+ if (pData->m_StrokeRGB != 0 && pData->m_StrokeRGB != 0xFFFFFFFF)
-+ fprintf(stderr, "COLOR STROkE!!!!> %x\n", pData->m_StrokeRGB);
- }
-
- void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
-@@ -99,6 +103,8 @@ void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
- }
- }
- pData->m_FillRGB = ret ? FXSYS_RGB(R, G, B) : 0xFFFFFFFF;
-+ if (pData->m_FillRGB != 0 && pData->m_FillRGB != 0xFFFFFFFF)
-+ fprintf(stderr, "COLOR FILL!!!!> %x\n", pData->m_FillRGB);
- }
-
- void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
-@@ -118,13 +124,15 @@ void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
- }
- pData->m_StrokeRGB =
- pData->m_StrokeColor.GetRGB(&R, &G, &B) ? FXSYS_RGB(R, G, B) : 0xFFFFFFFF;
-+ if (pData->m_StrokeRGB != 0 && pData->m_StrokeRGB != 0xFFFFFFFF)
-+ fprintf(stderr, "COLOR STROkE!!!!> %x\n", pData->m_StrokeRGB);
- }
-
- void CPDF_ColorState::SetColor(CPDF_Color& color,
+@@ -124,7 +124,7 @@ void CPDF_ColorState::SetColor(CPDF_Color& color,
uint32_t& rgb,
CPDF_ColorSpace* pCS,
float* pValue,
@@ -59,57 +24,6 @@ index 9619051..dbe9c47 100644
SharedCopyOnWrite<ColorData> m_Ref;
};
-diff --git a/core/fpdfapi/page/cpdf_imageobject.cpp b/core/fpdfapi/page/cpdf_imageobject.cpp
-index 3b5a740..416d82d 100644
---- a/core/fpdfapi/page/cpdf_imageobject.cpp
-+++ b/core/fpdfapi/page/cpdf_imageobject.cpp
-@@ -43,6 +43,7 @@ const CPDF_ImageObject* CPDF_ImageObject::AsImage() const {
- void CPDF_ImageObject::CalcBoundingBox() {
- std::tie(m_Left, m_Right, m_Top, m_Bottom) =
- m_Matrix.TransformRect(0.f, 1.f, 1.f, 0.f);
-+ // fprintf(stderr, "Image BB: %f, %f, %f, %f\n", m_Left, m_Right, m_Top, m_Bottom);
- }
-
- void CPDF_ImageObject::SetImage(const RetainPtr<CPDF_Image>& pImage) {
-diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
-index ba93f4a..70d398b 100644
---- a/core/fpdfapi/page/cpdf_page.cpp
-+++ b/core/fpdfapi/page/cpdf_page.cpp
-@@ -35,12 +35,14 @@ CPDF_Page::CPDF_Page(CPDF_Document* pDocument,
- CFX_FloatRect mediabox = GetBox("MediaBox");
- if (mediabox.IsEmpty())
- mediabox = CFX_FloatRect(0, 0, 612, 792);
-+ fprintf(stderr, "Page mediabox: %f, %f, %f, %f\n", mediabox.left, mediabox.right, mediabox.top, mediabox.bottom);
-
- m_BBox = GetBox("CropBox");
- if (m_BBox.IsEmpty())
- m_BBox = mediabox;
- else
- m_BBox.Intersect(mediabox);
-+ fprintf(stderr, "Page cropbox: %f, %f, %f, %f\n", m_BBox.left, m_BBox.right, m_BBox.top, m_BBox.bottom);
-
- m_PageSize.width = m_BBox.Width();
- m_PageSize.height = m_BBox.Height();
-@@ -48,6 +50,7 @@ CPDF_Page::CPDF_Page(CPDF_Document* pDocument,
- int rotate = GetPageRotation();
- if (rotate % 2)
- std::swap(m_PageSize.width, m_PageSize.height);
-+ fprintf(stderr, "Page rotate: %d, Page Width: %f, Page Height: %f\n", rotate, m_PageSize.width, m_PageSize.height);
-
- switch (rotate) {
- case 0:
-diff --git a/core/fpdfapi/page/cpdf_pageobject.cpp b/core/fpdfapi/page/cpdf_pageobject.cpp
-index 8bb5bf5..9b5e2ce 100644
---- a/core/fpdfapi/page/cpdf_pageobject.cpp
-+++ b/core/fpdfapi/page/cpdf_pageobject.cpp
-@@ -98,5 +98,7 @@ FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const {
- if (pMatrix)
- rect = pMatrix->TransformRect(rect);
-
-+ FX_RECT rc = rect.GetOuterRect();
-+ fprintf(stderr, "PageObject BB: %f, %f, %f, %f\n", rc.left, rc.right, rc.top, rc.bottom);
- return rect.GetOuterRect();
- }
diff --git a/core/fpdfapi/page/cpdf_pageobjectlist.cpp b/core/fpdfapi/page/cpdf_pageobjectlist.cpp
index afd2c98..2c8e061 100644
--- a/core/fpdfapi/page/cpdf_pageobjectlist.cpp
@@ -135,18 +49,6 @@ index b450537..77c7d81 100644
};
#endif // CORE_FPDFAPI_PAGE_CPDF_PAGEOBJECTLIST_H_
-diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
-index 0a01ae0..6947e3a 100644
---- a/core/fpdfapi/render/cpdf_renderstatus.cpp
-+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
-@@ -1793,6 +1793,7 @@ bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj,
- return true;
-
- float font_size = textobj->m_TextState.GetFontSize();
-+// fprintf(stderr, "Font size: %f, matrix a: %f, b: %f, c: %f, d: %f, e: %f, f: %f\n", font_size, text_matrix.a, text_matrix.b, text_matrix.c, text_matrix.d, text_matrix.e, text_matrix.f);
- if (bPattern) {
- DrawTextPathWithPattern(textobj, pObj2Device, pFont, font_size,
- &text_matrix, bFill, bStroke);
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index e712549..a7973f7 100644
--- a/core/fpdftext/cpdf_textpage.cpp
@@ -197,26 +99,6 @@ index c87ab00..e5a1ba8 100644
int CountRects(int start, int nCount);
bool GetRect(int rectIndex, CFX_FloatRect* pRect) const;
-diff --git a/core/fxge/cfx_pathdata.cpp b/core/fxge/cfx_pathdata.cpp
-index 4ac5cf6..4286de4 100644
---- a/core/fxge/cfx_pathdata.cpp
-+++ b/core/fxge/cfx_pathdata.cpp
-@@ -199,6 +199,7 @@ void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) {
- void CFX_PathData::AppendPoint(const CFX_PointF& point,
- FXPT_TYPE type,
- bool closeFigure) {
-+// fprintf(stderr, "Append: %f, %f (%s)\n", point.x, point.y, closeFigure ? "CLOSE" : "OPEN");
- m_Points.push_back(FX_PATHPOINT(point, type, closeFigure));
- }
-
-@@ -290,6 +291,7 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(float line_width,
- void CFX_PathData::Transform(const CFX_Matrix* pMatrix) {
- if (!pMatrix)
- return;
-+// fprintf(stderr, "XForm: %f, %f %f, %f, %f, %f\n", pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, pMatrix->e, pMatrix->f);
- for (auto& point : m_Points)
- point.m_Point = pMatrix->Transform(point.m_Point);
- }
diff --git a/fpdfsdk/fpdfeditimg.cpp b/fpdfsdk/fpdfeditimg.cpp
index 0d7ba56..37bdf99 100644
--- a/fpdfsdk/fpdfeditimg.cpp
@@ -249,7 +131,7 @@ index 0d7ba56..37bdf99 100644
FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object,
void* buffer,
diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
-index ca2cf3f..2162625 100644
+index ca2cf3f..1eaa232 100644
--- a/fpdfsdk/fpdfeditpage.cpp
+++ b/fpdfsdk/fpdfeditpage.cpp
@@ -11,12 +11,14 @@
@@ -275,7 +157,7 @@ index ca2cf3f..2162625 100644
#include "fpdfsdk/fsdk_define.h"
#include "public/fpdf_formfill.h"
#include "third_party/base/logging.h"
-@@ -363,3 +366,252 @@ FPDFPageObj_GetBounds(FPDF_PAGEOBJECT pageObject,
+@@ -363,3 +366,240 @@ FPDFPageObj_GetBounds(FPDF_PAGEOBJECT pageObject,
*top = bbox.top;
return true;
}
@@ -363,17 +245,6 @@ index ca2cf3f..2162625 100644
+ str += pFont->UnicodeFromCharCode(charcode);
+ }
+
-+// CFX_WideTextBuf m_TextBuf;
-+// WideString str = textpage->GetPageText(char_start, char_count);
-+// return WideString(m_TextBuf.AsStringView().Mid(
-+// static_cast<size_t>(text_start), static_cast<size_t>(text_count)));
-+
-+// if (str.GetLength() > static_cast<size_t>(char_count))
-+// str = str.Left(static_cast<size_t>(char_count));
-+
-+ // Reincode in UTF-16.
-+// WideString str = text.UTF8Decode();
-+
+ // UFT16LE_Encode doesn't handle surrogate pairs properly, so it is expected
+ // the number of items to stay the same.
+ ByteString byte_str = str.UTF16LE_Encode();
@@ -495,7 +366,6 @@ index ca2cf3f..2162625 100644
+ if (pFrmObj)
+ {
+ const CFX_Matrix& matrix = pFrmObj->form_matrix();
-+ fprintf(stderr, "Form matrix a: %f, b: %f, c: %f, d: %f, e: %f, f: %f\n", matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
+ const CPDF_PageObjectList* pObjectList = pFrmObj->form()->GetPageObjectList();
+ if (pObjectList)
+ return pObjectList->GetPageObjectByIndex(index);
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 2ffbe762f675..930142469d86 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -198,7 +198,6 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools:
}
mnPageCount = FPDF_GetPageCount(mpPdfDocument);
- SAL_WARN("sd.filter", "Scale Rect: " << maScaleRect);
}
ImpSdrPdfImport::~ImpSdrPdfImport()
@@ -207,11 +206,10 @@ ImpSdrPdfImport::~ImpSdrPdfImport()
FPDF_DestroyLibrary();
}
-void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport,
+void ImpSdrPdfImport::DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport,
int nPageIndex)
{
const int nPageCount = FPDF_GetPageCount(mpPdfDocument);
- SAL_WARN("sd.filter", "Importing page " << nPageIndex << " of " << nPageCount);
if (nPageCount > 0 && nPageIndex >= 0 && nPageIndex < nPageCount)
{
// Render next page.
@@ -221,187 +219,24 @@ void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pAc
const double dPageWidth = FPDF_GetPageWidth(pPdfPage);
const double dPageHeight = FPDF_GetPageHeight(pPdfPage);
- SAL_WARN("sd.filter", "Loaded page: " << nPageIndex << ", width: " << dPageWidth
- << ", height: " << dPageHeight);
SetupPageScale(dPageWidth, dPageHeight);
// Load the page text to extract it when we get text elements.
FPDF_TEXTPAGE pTextPage = FPDFText_LoadPage(pPdfPage);
const int nPageObjectCount = FPDFPage_CountObject(pPdfPage);
+ if (pProgrInfo)
+ pProgrInfo->SetActionCount(nPageObjectCount);
+
for (int nPageObjectIndex = 0; nPageObjectIndex < nPageObjectCount; ++nPageObjectIndex)
{
FPDF_PAGEOBJECT pPageObject = FPDFPage_GetObject(pPdfPage, nPageObjectIndex);
ImportPdfObject(pPageObject, pTextPage, nPageObjectIndex);
- }
-
- FPDFText_ClosePage(pTextPage);
-
-#if 0
- // Now do the text.
- FPDF_TEXTPAGE pTextPage = FPDFText_LoadPage(pPdfPage);
- if (pTextPage != nullptr)
- {
- SAL_WARN("sd.filter", "TEXT TEXT TEXT");
-
- const int nChars = FPDFText_CountChars(pTextPage);
- SAL_WARN("sd.filter", "Got page chars: " << nChars);
-
- const int nRects = FPDFText_CountRects(pTextPage, 0, nChars);
- SAL_WARN("sd.filter", "Got Rects: " << nRects);
-
- std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nChars + 1]); // + terminating null
- for (int nRectIndex = 0; nRectIndex < nRects; ++nRectIndex)
- {
- SAL_WARN("sd.filter",
- "Processing Text Rect #" << nRectIndex + 1 << " of " << nRects);
-
- double left = 0;
- double top = 0;
- double right = 0;
- double bottom = 0;
- FPDFText_GetRect(pTextPage, nRectIndex, &left, &top, &right, &bottom);
- SAL_WARN("sd.filter", "Got Text Rect: " << left << ", " << right << ", " << top
- << ", " << bottom);
- tools::Rectangle aRect = PointsToLogic(left, right, top, bottom);
-
- if (right < left)
- std::swap(right, left);
- if (bottom < top)
- std::swap(bottom, top);
-
- SAL_WARN("sd.filter", "Got Text Rect: " << left << ", " << right << ", " << top
- << ", " << bottom);
- SAL_WARN("sd.filter", "Logic Text Rect: " << aRect);
-
- unsigned short* pShortText = reinterpret_cast<unsigned short*>(pText.get());
- const int nBoundedChars = FPDFText_GetBoundedText(pTextPage, left, top, right,
- bottom, pShortText, nChars);
- OUString sText(pText.get(), nBoundedChars);
- SAL_WARN("sd.filter", "Got Text #" << nRectIndex + 1 << " (" << nBoundedChars
- << "): [" << sText << "].");
-
- const double dHalfCharWidth = (right - left) / nBoundedChars / 2.0;
- SAL_WARN("sd.filter", "Half Char Width: " << dHalfCharWidth);
- const int nCharIndex = FPDFText_GetCharIndexAtPos(pTextPage, left + dHalfCharWidth,
- top + dHalfCharWidth,
- dHalfCharWidth, dHalfCharWidth);
- SAL_WARN("sd.filter", "Got Char Index: " << nCharIndex);
-
- // FPDF_FONT pFont = FPDFText_GetFont(pTextPage, nCharIndex);
- // const int nFontAscent = FPDFFont_GetAscent(pFont);
- // const int nFontDescent = FPDFFont_GetDescent(pFont);
- // FPDF_BYTESTRING sFontName = FPDFFont_GetName(pFont);
- // SAL_WARN("sd.filter", "Char #" << nCharIndex << ", Got Font [" << sFontName <<
- // "], Ascent: "<< nFontAscent << ", Descent: " << nFontDescent);
-
- // FontMetric aFontMetric = mpVD->GetFontMetric();
- // aFontMetric.SetAscent(nFontAscent);
- // aFontMetric.SetDescent(nFontDescent);
-
- double dFontScale = 1.0;
- geometry::Matrix2D aMatrix;
- if (!FPDFText_GetMatrix(pTextPage, nCharIndex, &aMatrix.m00, &aMatrix.m01,
- &aMatrix.m10, &aMatrix.m11))
- {
- SAL_WARN("sd.filter", "No font scale matrix, will use heuristic height of "
- << aRect.GetHeight() << ".");
- dFontScale = aRect.GetHeight();
- }
- else if (aMatrix.m00 != aMatrix.m11 || aMatrix.m00 <= 0)
- {
- SAL_WARN("sd.filter", "Bogus font scale matrix ("
- << aMatrix.m00 << ',' << aMatrix.m11
- << "), will use heuristic height of "
- << aRect.GetHeight() << ".");
- dFontScale = aRect.GetHeight();
- }
- else
- dFontScale = aMatrix.m00;
-
- double dFontSize = FPDFText_GetFontSize(pTextPage, nCharIndex);
- SAL_WARN("sd.filter", "Got Font Size: " << dFontSize);
- dFontSize *= dFontScale;
- SAL_WARN("sd.filter", "Got Font Size Scaled: " << dFontSize);
- dFontSize = lcl_PointToPixel(dFontSize);
- SAL_WARN("sd.filter", "Got Font Pixel Size: " << dFontSize);
- dFontSize = lcl_ToLogic(dFontSize);
- SAL_WARN("sd.filter", "Got Font Logic Size: " << dFontSize);
- vcl::Font aFnt = mpVD->GetFont();
- aFnt.SetFontSize(Size(dFontSize, dFontSize));
- mpVD->SetFont(aFnt);
-
- double x = 0;
- double y = 0;
- FPDFText_GetCharOrigin(pTextPage, nCharIndex, &x, &y);
- SAL_WARN("sd.filter", "Got Char Origin: " << x << ", " << y);
- Point aPos = PointsToLogic(x, y);
- SAL_WARN("sd.filter", "Got Char Origin Logic: " << aPos);
- // aRect.Move(aPos.X(), aPos.Y());
-
- // geometry::RealRectangle2D aRect;
- // aRect.X1 = left;
- // aRect.Y1 = top;
- // aRect.X2 = right;
- // aRect.Y2 = bottom;
-
- // geometry::Matrix2D aMatrix;
- // FPDFText_GetMatrix(pTextPage, nCharIndex, &aMatrix.m00, &aMatrix.m01, &aMatrix.m10, &aMatrix.m11);
-
- // basegfx::B2DHomMatrix fontMatrix(
- // aMatrix.m00, aMatrix.m01, 0.0,
- // aMatrix.m10, aMatrix.m11, 0.0);
- // fontMatrix.scale(dFontSize, dFontSize);
-
- // x = fontMatrix.get(0, 0) * x + fontMatrix.get(1, 0) * y + x;
- // y = fontMatrix.get(0, 1) * x + fontMatrix.get(1, 1) * y + y;
- // SAL_WARN("sd.filter", "Char Origin after xform: " << x << ", " << y);
-
- // basegfx::B2DHomMatrix totalTextMatrix1(fontMatrix);
- // basegfx::B2DHomMatrix totalTextMatrix2(fontMatrix);
- // totalTextMatrix1.translate(rRect.X1, rRect.Y1);
- // totalTextMatrix2.translate(rRect.X2, rRect.Y2);
-
- // basegfx::B2DHomMatrix corrMatrix;
- // corrMatrix.scale(1.0, -1.0);
- // // corrMatrix.translate(0.0, ascent);
- // totalTextMatrix1 = totalTextMatrix1 * corrMatrix;
- // totalTextMatrix2 = totalTextMatrix2 * corrMatrix;
-
- // totalTextMatrix1 *= getCurrentContext().Transformation;
- // totalTextMatrix2 *= getCurrentContext().Transformation;
-
- // basegfx::B2DHomMatrix invMatrix(totalTextMatrix1);
- // basegfx::B2DHomMatrix invPrevMatrix(prevTextMatrix);
- // invMatrix.invert();
- // invPrevMatrix.invert();
- // basegfx::B2DHomMatrix offsetMatrix1(totalTextMatrix1);
- // basegfx::B2DHomMatrix offsetMatrix2(totalTextMatrix2);
- // offsetMatrix1 *= invPrevMatrix;
- // offsetMatrix2 *= invMatrix;
-
- // double charWidth = offsetMatrix2.get(0, 2);
- // double prevSpaceWidth = offsetMatrix1.get(0, 2) - prevCharWidth;
-
- ImportText(aRect.TopLeft(), sText);
- }
-
- FPDFText_ClosePage(pTextPage);
- }
-#endif
-
- FPDF_ClosePage(pPdfPage);
- }
-
- // const sal_uLong nCount(rMtf.GetActionSize());
-
- for (sal_uLong a(0); a < 0UL; a++)
- {
if (pProgrInfo && pActionsToReport)
{
(*pActionsToReport)++;
- if (*pActionsToReport >= 16) // update all 16 actions
+ if (*pActionsToReport >= 16)
{
if (!pProgrInfo->ReportActions(*pActionsToReport))
break;
@@ -410,6 +245,10 @@ void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pAc
}
}
}
+
+ FPDFText_ClosePage(pTextPage);
+ FPDF_ClosePage(pPdfPage);
+ }
}
void ImpSdrPdfImport::SetupPageScale(const double dPageWidth, const double dPageHeight)
@@ -422,8 +261,6 @@ void ImpSdrPdfImport::SetupPageScale(const double dPageWidth, const double dPage
Size aPageSize(lcl_ToLogic(lcl_PointToPixel(dPageWidth)),
lcl_ToLogic(lcl_PointToPixel(dPageHeight)));
- SAL_WARN("sd.filter", "Logical Page Size: " << aPageSize);
- SAL_WARN("sd.filter", "Scale Rect: " << maScaleRect);
if (aPageSize.Width() && aPageSize.Height() && (!maScaleRect.IsEmpty()))
{
@@ -458,23 +295,15 @@ void ImpSdrPdfImport::SetupPageScale(const double dPageWidth, const double dPage
maScaleY = Fraction(maScaleRect.GetHeight() - 1, aPageSize.Height());
mbSize = true;
}
-
- //SAL_WARN("sd.filter", "ScaleX: " << maScaleX << "(" << mfScaleX << "), ScaleY: " << maScaleY
- // << "(" << mfScaleY << ")");
}
size_t ImpSdrPdfImport::DoImport(SdrObjList& rOL, size_t nInsPos, int nPageNumber,
SvdProgressInfo* pProgrInfo)
{
- if (pProgrInfo)
- {
- // pProgrInfo->SetActionCount(rMtf.GetActionSize());
- }
-
sal_uInt32 nActionsToReport(0);
// execute
- DoLoopActions(pProgrInfo, &nActionsToReport, nPageNumber);
+ DoObjects(pProgrInfo, &nActionsToReport, nPageNumber);
if (pProgrInfo)
{
@@ -615,7 +444,6 @@ void ImpSdrPdfImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr)
{
vcl::Font aFnt(mpVD->GetFont());
const sal_uInt32 nHeight(FRound(aFnt.GetFontSize().Height() * mfScaleY));
- SAL_WARN("sd.filter", "Font Height: " << nHeight);
mpTextAttr->Put(SvxFontItem(aFnt.GetFamilyType(), aFnt.GetFamilyName(), aFnt.GetStyleName(),
aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO));
@@ -1027,10 +855,8 @@ void ImpSdrPdfImport::ImportPdfObject(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE
}
void ImpSdrPdfImport::ImportForm(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage,
- int nPageObjectIndex)
+ int /*nPageObjectIndex*/)
{
- SAL_WARN("sd.filter", "Got page object FORM: " << nPageObjectIndex);
-
// Get the form matrix to perform correct translation/scaling of the form sub-objects.
const Matrix aOldMatrix = mCurMatrix;
@@ -1050,9 +876,8 @@ void ImpSdrPdfImport::ImportForm(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
}
void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage,
- int nPageObjectIndex)
+ int /*nPageObjectIndex*/)
{
- SAL_WARN("sd.filter", "Got page object TEXT: " << nPageObjectIndex);
float left;
float bottom;
float right;
@@ -1063,30 +888,14 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
}
if (left == right || top == bottom)
- {
- SAL_WARN("sd.filter", "Skipping empty TEXT #" << nPageObjectIndex << " left: " << left
- << ", right: " << right << ", top: " << top
- << ", bottom: " << bottom);
return;
- }
double a, b, c, d, e, f;
FPDFTextObj_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
- // Matrix aTextMatrix(a, b, c, d, e, f);
Matrix aTextMatrix(mCurMatrix);
- SAL_WARN("sd.filter", "Got text matrix " << aTextMatrix.toString());
- SAL_WARN("sd.filter", "Context matrix " << mCurMatrix.toString());
- // aTextMatrix.Concatinate(mCurMatrix);
- // SAL_WARN("sd.filter", "Got text matrix concat " << aTextMatrix.toString());
- Point aPos = PointsToLogic(aTextMatrix.e(), aTextMatrix.f());
- SAL_WARN("sd.filter", "Got TEXT origin: " << aPos);
-
- const tools::Rectangle aRect2 = PointsToLogic(left, right, top, bottom);
- SAL_WARN("sd.filter", "Untransformed TEXT Bounds: " << aRect2);
aTextMatrix.Transform(left, right, top, bottom);
const tools::Rectangle aRect = PointsToLogic(left, right, top, bottom);
- SAL_WARN("sd.filter", "Transformed TEXT Bounds: " << aRect);
const int nChars = FPDFTextObj_CountChars(pPageObject) * 2;
std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nChars + 1]); // + terminating null
@@ -1096,24 +905,18 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
= FPDFTextObj_GetTextProcessed(pPageObject, pTextPage, 0, nChars, pShortText);
if (nActualChars <= 0)
{
- SAL_WARN("sd.filter", "Got no TEXT");
return;
}
OUString sText(pText.get(), nActualChars);
- SAL_WARN("sd.filter", "Got Text (" << nChars << "): [" << sText << "].");
const double dFontSize = FPDFTextObj_GetFontSize(pPageObject);
double dFontSizeH = fabs(sqrt2(a, c) * dFontSize);
double dFontSizeV = fabs(sqrt2(b, d) * dFontSize);
- SAL_WARN("sd.filter", "Got Font Size: " << dFontSize << ", Scaled Font Size H: " << dFontSizeH
- << ", V: " << dFontSizeV);
dFontSizeH = lcl_PointToPixel(dFontSizeH);
dFontSizeV = lcl_PointToPixel(dFontSizeV);
- SAL_WARN("sd.filter", "Got Pixel Font Size H: " << dFontSizeH << ", V: " << dFontSizeV);
dFontSizeH = lcl_ToLogic(dFontSizeH);
dFontSizeV = lcl_ToLogic(dFontSizeV);
- SAL_WARN("sd.filter", "Got Logic Font Size H: " << dFontSizeH << ", V: " << dFontSizeV);
const Size aFontSize(dFontSizeH, dFontSizeV);
vcl::Font aFnt = mpVD->GetFont();
@@ -1146,26 +949,18 @@ void ImpSdrPdfImport::ImportText(const Point& rPos, const Size& rSize, const OUS
vcl::Font aFnt(mpVD->GetFont());
FontAlign eAlg(aFnt.GetAlignment());
- sal_Int32 nTextWidth = static_cast<sal_Int32>(mpVD->GetTextWidth(rStr) * mfScaleX);
+ // sal_Int32 nTextWidth = static_cast<sal_Int32>(mpVD->GetTextWidth(rStr) * mfScaleX);
sal_Int32 nTextHeight = static_cast<sal_Int32>(mpVD->GetTextHeight() * mfScaleY);
- SAL_WARN("sd.filter",
- "Unscaled text size: " << mpVD->GetTextWidth(rStr) << 'x' << mpVD->GetTextHeight()
- << ", Scaled: " << nTextWidth << 'x' << nTextHeight);
Point aPos(FRound(rPos.X() * mfScaleX + maOfs.X()), FRound(rPos.Y() * mfScaleY + maOfs.Y()));
- Size bSize(FRound(rSize.Width() * mfScaleX), FRound(rSize.Height() * mfScaleY));
- Size aSize(nTextWidth, nTextHeight);
+ Size aSize(FRound(rSize.Width() * mfScaleX), FRound(rSize.Height() * mfScaleY));
if (eAlg == ALIGN_BASELINE)
aPos.Y() -= FRound(aFontMetric.GetAscent() * mfScaleY);
else if (eAlg == ALIGN_BOTTOM)
aPos.Y() -= nTextHeight;
- SAL_WARN("sd.filter", "Final POS: " << aPos);
- SAL_WARN("sd.filter", "Final Text Size: " << aSize);
- SAL_WARN("sd.filter", "Final Bound Size: " << bSize);
- tools::Rectangle aTextRect(aPos, bSize);
- // SAL_WARN("sd.filter", "Text Rect: " << aTextRect);
+ tools::Rectangle aTextRect(aPos, aSize);
SdrRectObj* pText = new SdrRectObj(OBJ_TEXT, aTextRect);
pText->SetModel(mpModel);
@@ -1230,9 +1025,8 @@ void ImpSdrPdfImport::MapScaling()
mnMapScalingOfs = nCount;
}
-void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex)
+void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectIndex*/)
{
- SAL_WARN("sd.filter", "Got page object IMAGE: " << nPageObjectIndex);
std::unique_ptr<void, FPDFBitmapDeleter> bitmap(FPDFImageObj_GetBitmapBgra(pPageObject));
if (!bitmap)
{
@@ -1256,27 +1050,13 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
switch (format)
{
- case FPDFBitmap_Gray:
- SAL_WARN("sd.filter", "Got IMAGE width: " << nWidth << ", height: " << nHeight
- << ", stride: " << nStride
- << ", format: Gray");
- break;
case FPDFBitmap_BGR:
- SAL_WARN("sd.filter", "Got IMAGE width: " << nWidth << ", height: " << nHeight
- << ", stride: " << nStride
- << ", format: BGR");
ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N24BitTcBgr, nHeight, nStride);
break;
case FPDFBitmap_BGRx:
- SAL_WARN("sd.filter", "Got IMAGE width: " << nWidth << ", height: " << nHeight
- << ", stride: " << nStride
- << ", format: BGRx");
ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N32BitTcRgba, nHeight, nStride);
break;
case FPDFBitmap_BGRA:
- SAL_WARN("sd.filter", "Got IMAGE width: " << nWidth << ", height: " << nHeight
- << ", stride: " << nStride
- << ", format: BGRA");
ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N32BitTcBgra, nHeight, nStride);
break;
default:
@@ -1286,18 +1066,6 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
break;
}
- // double a, b, c, d, e, f;
- // if (!FPDFImageObj_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f))
- // {
- // SAL_WARN("sd.filter", "FAILED to get image Matrix");
- // }
- // SAL_WARN("sd.filter", "Got image Matrix: " << a << ", " << b << ", " << c << ", " << d << ", " << e << ", " << f);
-
- // if (!FPDFImageObj_SetMatrix(pPageObject, a, b, c, d, e, f))
- // {
- // SAL_WARN("sd.filter", "FAILED to set image Matrix");
- // }
-
float left;
float bottom;
float right;
@@ -1307,12 +1075,9 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
SAL_WARN("sd.filter", "FAILED to get image bounds");
}
- SAL_WARN("sd.filter", "Got IMAGE bounds left: " << left << ", right: " << right
- << ", top: " << top << ", bottom: " << bottom);
tools::Rectangle aRect = PointsToLogic(left, right, top, bottom);
aRect.MoveRight(1);
aRect.MoveBottom(1);
- SAL_WARN("sd.filter", "IMAGE Logical Rect FINAL: " << aRect);
SdrGrafObj* pGraf = new SdrGrafObj(Graphic(aBitmap), aRect);
pGraf->SetModel(mpModel);
@@ -1323,7 +1088,7 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
InsertObj(pGraf);
}
-void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex)
+void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectIndex*/)
{
double a, b, c, d, e, f;
FPDFPath_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
@@ -1335,9 +1100,6 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
std::vector<basegfx::B2DPoint> aBezier;
const int nSegments = FPDFPath_CountSegments(pPageObject);
- SAL_WARN("sd.filter",
- "Got page object PATH: " << nPageObjectIndex << " with " << nSegments << " segments.");
-
for (int nSegmentIndex = 0; nSegmentIndex < nSegments; ++nSegmentIndex)
{
FPDF_PATHSEGMENT pPathSegment = FPDFPath_GetPathSegment(pPageObject, nSegmentIndex);
@@ -1357,11 +1119,6 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
if (bClose)
aPoly.setClosed(bClose); // TODO: Review
- SAL_WARN("sd.filter", "Got " << (bClose ? "CLOSE" : "OPEN") << " point (" << fx << ", "
- << fy << ") matrix (" << a << ", " << b << ", " << c
- << ", " << d << ", " << e << ", " << f << ") -> (" << x
- << ", " << y << ")");
-
Point aPoint = PointsToLogic(x, y);
x = aPoint.X();
y = aPoint.Y();
@@ -1370,12 +1127,10 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
switch (nSegmentType)
{
case FPDF_SEGMENT_LINETO:
- SAL_WARN("sd.filter", "Got LineTo Segment.");
aPoly.append(basegfx::B2DPoint(x, y));
break;
case FPDF_SEGMENT_BEZIERTO:
- SAL_WARN("sd.filter", "Got BezierTo Segment.");
aBezier.emplace_back(x, y);
if (aBezier.size() == 3)
{
@@ -1385,7 +1140,6 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
break;
case FPDF_SEGMENT_MOVETO:
- SAL_WARN("sd.filter", "Got MoveTo Segment.");
// New Poly.
if (aPoly.count() > 0)
{
@@ -1424,15 +1178,11 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
FPDFPath_GetStrokeWidth(pPageObject, &fWidth);
const double dWidth = 0.5 * fabs(sqrt2(aPathMatrix.a(), aPathMatrix.c()) * fWidth);
mnLineWidth = lcl_ToLogic(lcl_PointToPixel(dWidth));
- // mnLineWidth /= 2;
- SAL_WARN("sd.filter", "Path Stroke Width: " << fWidth << ", scaled: " << dWidth
- << ", Logical: " << mnLineWidth);
int nFillMode = FPDF_FILLMODE_ALTERNATE;
FPDF_BOOL bStroke = true;
if (FPDFPath_GetDrawMode(pPageObject, &nFillMode, &bStroke))
{
- SAL_WARN("sd.filter", "Got PATH FillMode: " << nFillMode << ", Storke: " << bStroke);
if (nFillMode == FPDF_FILLMODE_ALTERNATE)
mpVD->SetDrawMode(DrawModeFlags::Default);
else if (nFillMode == FPDF_FILLMODE_WINDING)
@@ -1446,39 +1196,32 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
unsigned int nB;
unsigned int nA;
FPDFPath_GetFillColor(pPageObject, &nR, &nG, &nB, &nA);
- SAL_WARN("sd.filter", "Got PATH fill color: " << nR << ", " << nG << ", " << nB << ", " << nA);
mpVD->SetFillColor(Color(nR, nG, nB));
if (bStroke)
{
FPDFPath_GetStrokeColor(pPageObject, &nR, &nG, &nB, &nA);
- SAL_WARN("sd.filter",
- "Got PATH stroke color: " << nR << ", " << nG << ", " << nB << ", " << nA);
mpVD->SetLineColor(Color(nR, nG, nB));
}
else
mpVD->SetLineColor(COL_TRANSPARENT);
- // if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
-
+ if (!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aPolyPoly)))
+ {
SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aPolyPoly);
pPath->SetModel(mpModel);
SetAttributes(pPath);
InsertObj(pPath, false);
}
+}
Point ImpSdrPdfImport::PointsToLogic(double x, double y) const
{
y = correctVertOrigin(y);
- // SAL_WARN("sd.filter", "Corrected point x: " << x << ", y: " << y);
x = lcl_PointToPixel(x);
y = lcl_PointToPixel(y);
- // SAL_WARN("sd.filter", "Pixel point x: " << x << ", y: " << y);
-
Point aPos(lcl_ToLogic(x), lcl_ToLogic(y));
- // SAL_WARN("sd.filter", "Logical Pos: " << aPos);
-
return aPos;
}
@@ -1487,21 +1230,15 @@ tools::Rectangle ImpSdrPdfImport::PointsToLogic(double left, double right, doubl
{
top = correctVertOrigin(top);
bottom = correctVertOrigin(bottom);
- // SAL_WARN("sd.filter", "Corrected bounds left: " << left << ", right: " << right
- // << ", top: " << top << ", bottom: " << bottom);
+
left = lcl_PointToPixel(left);
right = lcl_PointToPixel(right);
top = lcl_PointToPixel(top);
bottom = lcl_PointToPixel(bottom);
- // SAL_WARN("sd.filter", "Pixel bounds left: " << left << ", right: " << right << ", top: " << top
- // << ", bottom: " << bottom);
-
Point aPos(lcl_ToLogic(left), lcl_ToLogic(top));
Size aSize(lcl_ToLogic(right - left), lcl_ToLogic(bottom - top));
tools::Rectangle aRect(aPos, aSize);
- // SAL_WARN("sd.filter", "Logical BBox: " << aRect);
-
return aRect;
}
diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx
index 0b18056375a5..6ff8b5259c5b 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -109,44 +109,34 @@ class ImpSdrPdfImport final
/// Transform the rectangle (left, right, top, bottom) by this Matrix.
template <typename T> void Transform(T& left, T& right, T& top, T& bottom)
{
- SAL_WARN("sd.filter",
- "Transforming: " << left << ", " << right << ", " << top << ", " << bottom);
T leftTopX = left;
T leftTopY = top;
Transform(leftTopX, leftTopY);
- SAL_WARN("sd.filter", "Left-Top: " << leftTopX << ", " << leftTopY);
T leftBottomX = left;
T leftBottomY = bottom;
Transform(leftBottomX, leftBottomY);
- SAL_WARN("sd.filter", "Left-Bottom: " << leftBottomX << ", " << leftBottomY);
T rightTopX = right;
T rightTopY = top;
Transform(rightTopX, rightTopY);
- SAL_WARN("sd.filter", "Right-Top: " << rightTopX << ", " << rightTopY);
T rightBottomX = right;
T rightBottomY = bottom;
Transform(rightBottomX, rightBottomY);
- SAL_WARN("sd.filter", "Right-Bottom: " << rightBottomX << ", " << rightBottomY);
left = std::min(leftTopX, leftBottomX);
- SAL_WARN("sd.filter", "left: " << left);
right = std::max(rightTopX, rightBottomX);
- SAL_WARN("sd.filter", "right: " << right);
if (top > bottom)
top = std::max(leftTopY, rightTopY);
else
top = std::min(leftTopY, rightTopY);
- SAL_WARN("sd.filter", "top: " << top);
if (top > bottom)
bottom = std::max(leftBottomY, rightBottomY);
else
bottom = std::max(leftBottomY, rightBottomY);
- SAL_WARN("sd.filter", "bottom: " << bottom);
}
std::string toString() const
@@ -233,7 +223,7 @@ class ImpSdrPdfImport final
bool CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly);
bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
- void DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex);
+ void DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex);
// Copy assignment is forbidden and not implemented.
ImpSdrPdfImport(const ImpSdrPdfImport&) = delete;
commit 25924d0822dc673d679abaa8bd665b487b976652
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon May 14 19:57:15 2018 -0400
svx: transform PDF text rectangles while importing
Change-Id: I7675a183bfb691a8783950f33dc34826f91cb768
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 7f76e2a97ab3..2ffbe762f675 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1070,17 +1070,23 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
return;
}
- const tools::Rectangle aRect = PointsToLogic(left, right, top, bottom);
-
double a, b, c, d, e, f;
FPDFTextObj_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
- Matrix aTextMatrix(a, b, c, d, e, f);
- aTextMatrix.Concatinate(mCurMatrix);
- SAL_WARN("sd.filter", "Got font scale matrix (" << a << ", " << b << ", " << c << ", " << d
- << ", " << e << ", " << f << ')');
- Point aPos = PointsToLogic(e, f);
+ // Matrix aTextMatrix(a, b, c, d, e, f);
+ Matrix aTextMatrix(mCurMatrix);
+ SAL_WARN("sd.filter", "Got text matrix " << aTextMatrix.toString());
+ SAL_WARN("sd.filter", "Context matrix " << mCurMatrix.toString());
+ // aTextMatrix.Concatinate(mCurMatrix);
+ // SAL_WARN("sd.filter", "Got text matrix concat " << aTextMatrix.toString());
+
+ Point aPos = PointsToLogic(aTextMatrix.e(), aTextMatrix.f());
SAL_WARN("sd.filter", "Got TEXT origin: " << aPos);
- SAL_WARN("sd.filter", "Got TEXT Bounds: " << aRect);
+
+ const tools::Rectangle aRect2 = PointsToLogic(left, right, top, bottom);
+ SAL_WARN("sd.filter", "Untransformed TEXT Bounds: " << aRect2);
+ aTextMatrix.Transform(left, right, top, bottom);
+ const tools::Rectangle aRect = PointsToLogic(left, right, top, bottom);
+ SAL_WARN("sd.filter", "Transformed TEXT Bounds: " << aRect);
const int nChars = FPDFTextObj_CountChars(pPageObject) * 2;
std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nChars + 1]); // + terminating null
@@ -1416,9 +1422,9 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
float fWidth = 1;
FPDFPath_GetStrokeWidth(pPageObject, &fWidth);
- const double dWidth = 0.5 * fabs(sqrt2(mCurMatrix.a(), mCurMatrix.c()) * fWidth);
+ const double dWidth = 0.5 * fabs(sqrt2(aPathMatrix.a(), aPathMatrix.c()) * fWidth);
mnLineWidth = lcl_ToLogic(lcl_PointToPixel(dWidth));
- mnLineWidth /= 2;
+ // mnLineWidth /= 2;
SAL_WARN("sd.filter", "Path Stroke Width: " << fWidth << ", scaled: " << dWidth
<< ", Logical: " << mnLineWidth);
diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx
index 53e00a305a39..0b18056375a5 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -87,6 +87,7 @@ class ImpSdrPdfImport final
double d() const { return md; }
double e() const { return me; }
double f() const { return mf; }
+
/// Mutliply this * other.
void Concatinate(const Matrix& other)
{
@@ -99,12 +100,63 @@ class ImpSdrPdfImport final
}
/// Transform the point (x, y) by this Matrix.
- void Transform(double& x, double& y)
+ template <typename T> void Transform(T& x, T& y)
{
x = ma * x + mc * y + me;
y = mb * x + md * y + mf;
}
+ /// Transform the rectangle (left, right, top, bottom) by this Matrix.
+ template <typename T> void Transform(T& left, T& right, T& top, T& bottom)
+ {
+ SAL_WARN("sd.filter",
+ "Transforming: " << left << ", " << right << ", " << top << ", " << bottom);
+ T leftTopX = left;
+ T leftTopY = top;
+ Transform(leftTopX, leftTopY);
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list