include/vcl/filter/PDFiumLibrary.hxx |7 +++
sd/qa/unit/SdrPdfImportTest.cxx | 11 -
svx/source/inc/svdpdf.hxx|4 +
svx/source/svdraw/svdpdf.cxx | 71 +--
vcl/qa/cppunit/PDFiumLibraryTest.cxx | 14 ++
vcl/source/pdf/PDFiumLibrary.cxx | 60 -
6 files changed, 110 insertions(+), 57 deletions(-)
New commits:
commit af7b619f2752fcac3492c53444e836371efbd5fe
Author: Tomaž Vajngerl
AuthorDate: Sun Jun 28 13:46:41 2020 +0200
Commit: Tomaž Vajngerl
CommitDate: Mon Jun 29 23:38:48 2020 +0200
pdf: add text page object attribs, refactor ImpSdrPdfImport, tests
This refactors ImpSdrPdfImport to push more functions into the
PDFium wrapper. The focus is on text page object attributes.
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97366
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl
(cherry picked from commit 4e9b03d04f740a0cbafa22a4f3cedfae7f37a994)
Change-Id: Ie1faf5e3743eec7c77050835651533f9e227c2a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97451
Tested-by: Jenkins CollaboraOffice
Reviewed-by: Tomaž Vajngerl
diff --git a/include/vcl/filter/PDFiumLibrary.hxx
b/include/vcl/filter/PDFiumLibrary.hxx
index 9f34bdb92ad6..f7dcc4b2c99e 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -22,6 +22,7 @@
#include
#include
#include
+#include
#include
@@ -93,6 +94,12 @@ public:
std::unique_ptr getFormObject(int nIndex);
basegfx::B2DHomMatrix getMatrix();
+basegfx::B2DRectangle getBounds();
+double getFontSize();
+OUString getFontName();
+int getTextRenderMode();
+Color getFillColor();
+Color getStrokeColor();
};
class VCL_DLLPUBLIC PDFiumTextPage final
diff --git a/sd/qa/unit/SdrPdfImportTest.cxx b/sd/qa/unit/SdrPdfImportTest.cxx
index ca022d585c48..2ac548bb6c85 100644
--- a/sd/qa/unit/SdrPdfImportTest.cxx
+++ b/sd/qa/unit/SdrPdfImportTest.cxx
@@ -89,6 +89,9 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testImportSimpleText)
SdPage* pPage = pViewShell->GetActualPage();
CPPUNIT_ASSERT(pPage);
+// Check there is one object on the page only
+CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
+
// Get the first object - there should be only one.
SdrObject* pObject = pPage->GetObj(0);
CPPUNIT_ASSERT(pObject);
@@ -110,11 +113,17 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest,
testImportSimpleText)
// Execute the break operation - to turn the PDF into shapes/objects
pViewShell->GetDrawView()->DoImportMarkedMtf();
-// Check Objects after import
+// Check there is one object on the page only
+CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
+// Get the object
SdrObject* pImportedObject = pPage->GetObj(0);
CPPUNIT_ASSERT(pImportedObject);
+// Check the object position
+CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(2011, 2098), Size(2106 + 1,
302 + 1)),
+ pImportedObject->GetLogicRect());
+
// Object should be a text object containing one paragraph with
// content "This is PDF!"
diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx
index 49c8d3e1b3c2..b1ad9d69ad12 100644
--- a/svx/source/inc/svdpdf.hxx
+++ b/svx/source/inc/svdpdf.hxx
@@ -120,7 +120,9 @@ class SVXCORE_DLLPUBLIC ImpSdrPdfImport final
int nPageObjectIndex);
void ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex);
void ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex);
-void ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage, int
nPageObjectIndex);
+void ImportText(std::unique_ptr const&
pPageObject,
+std::unique_ptr const& pTextPage,
+int nPageObjectIndex);
void InsertTextObject(const Point& rPos, const Size& rSize, const
OUString& rStr);
void SetupPageScale(const double dPageWidth, const double dPageHeight);
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 066c77f0798f..ff4029a00b54 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -694,7 +694,7 @@ void ImpSdrPdfImport::ImportPdfObject(
switch (nPageObjectType)
{
case FPDF_PAGEOBJ_TEXT:
-ImportText(pPageObject->getPointer(), pTextPage->getPointer(),
nPageObjectIndex);
+ImportText(pPageObject, pTextPage, nPageObjectIndex);
break;
case FPDF_PAGEOBJ_PATH:
ImportPath(pPageObject->getPointer(), nPageObjectIndex);
@@ -736,47 +736,23 @@ void
ImpSdrPdfImport::ImportForm(std::unique_ptr con
maCurrentMatrix = aOldMatrix;
}
-void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE
pTextPage,
+void ImpSdrPdfImport::ImportText(std::unique_ptr
const& pPageObject,
+ std::unique_ptr