[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl sd/qa svx/source vcl/qa vcl/source

2020-06-29 Thread Tomaž Vajngerl (via logerrit)
 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 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl sd/qa

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/vectorgraphicdata.hxx |2 ++
 sd/qa/unit/data/pdf/multipage.pdf |binary
 sd/qa/unit/import-tests.cxx   |4 +++-
 3 files changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 125eda6df4267541177a9b25aa0f1d7c140a49a9
Author: Tomaž Vajngerl 
AuthorDate: Thu Mar 26 12:25:10 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:25:31 2020 +0200

sd: extend test to check the PDF pages aren't rendered when loaded

Change-Id: I9e407bb20a00ec620fe3f772f50708f997027942
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91093
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 56a1f9bea2f1b64dee4111ec6671caf42ef63c91)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95631
Tested-by: Tomaž Vajngerl 

diff --git a/include/vcl/vectorgraphicdata.hxx 
b/include/vcl/vectorgraphicdata.hxx
index 86b0e6e1ad2f..28828426ac2e 100644
--- a/include/vcl/vectorgraphicdata.hxx
+++ b/include/vcl/vectorgraphicdata.hxx
@@ -111,6 +111,8 @@ public:
 BitmapChecksum GetChecksum() const;
 
 sal_Int32 getPageIndex() const { return mnPageIndex; }
+
+bool isPrimitiveSequenceCreated() const { return mbSequenceCreated; }
 };
 
 typedef std::shared_ptr< VectorGraphicData > VectorGraphicDataPtr;
diff --git a/sd/qa/unit/data/pdf/multipage.pdf 
b/sd/qa/unit/data/pdf/multipage.pdf
index 5cd8b4e4e569..65c8eeaa32a5 100644
Binary files a/sd/qa/unit/data/pdf/multipage.pdf and 
b/sd/qa/unit/data/pdf/multipage.pdf differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 006adedcd588..bd719567104c 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -1283,11 +1283,13 @@ void SdImportTest::testPDFImportShared()
 
 const GraphicObject& rGraphicObject = 
pSdrGrafObj->GetGraphicObject().GetGraphic();
 const Graphic& rGraphic = rGraphicObject.GetGraphic();
+CPPUNIT_ASSERT_MESSAGE("After loading, the PDF shouldn't have the 
primitive sequence created yet",
+   
!rGraphic.getVectorGraphicData()->isPrimitiveSequenceCreated());
 aGraphics.push_back(rGraphic);
 }
 }
 
-CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected more than one page.", size_t(3), 
aGraphics.size());
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected more than one page.", size_t(9), 
aGraphics.size());
 
 Graphic const & rFirstGraphic = aGraphics[0];
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits