external/pdfium/AnnotationLineStartAndEnd.patch.1 |   48 ++++++++++++++++++++++
 external/pdfium/UnpackedTarball_pdfium.mk         |    1 
 include/vcl/filter/PDFiumLibrary.hxx              |    1 
 vcl/qa/cppunit/PDFiumLibraryTest.cxx              |   12 +++++
 vcl/source/pdf/PDFiumLibrary.cxx                  |   13 +++++
 5 files changed, 75 insertions(+)

New commits:
commit aa301119c98bc5103d3738263b1df90b30013e32
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Oct 15 14:11:54 2020 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Sun Oct 18 21:22:46 2020 +0200

    pdfium: add reading of line points to the wrapper
    
    Change-Id: I3e596254b2e4ecc9f56ff09eeb63b66195ea6a2e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104376
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/external/pdfium/AnnotationLineStartAndEnd.patch.1 
b/external/pdfium/AnnotationLineStartAndEnd.patch.1
new file mode 100644
index 000000000000..00ebb6d20ed1
--- /dev/null
+++ b/external/pdfium/AnnotationLineStartAndEnd.patch.1
@@ -0,0 +1,48 @@
+diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp
+index 229651d82..b43f378bc 100644
+--- a/fpdfsdk/fpdf_annot.cpp
++++ b/fpdfsdk/fpdf_annot.cpp
+@@ -552,6 +552,25 @@ FPDFAnnot_GetInkStrokePoints(FPDF_ANNOTATION annot, int 
index,
+   return true;
+ }
+
++FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetLine(FPDF_ANNOTATION annot,
++                                                      FS_POINTF* start,
++                                                      FS_POINTF* end) {
++  CPDF_Dictionary* pAnnotDict = GetAnnotDictFromFPDFAnnotation(annot);
++  if (!pAnnotDict || !start || !end)
++    return false;
++
++  CPDF_Array* pLineArray = pAnnotDict->GetArrayFor("L");
++  if (!pLineArray || pLineArray->size() < 4)
++    return false;
++
++  start->x = pLineArray->GetNumberAt(0);
++  start->y = pLineArray->GetNumberAt(1);
++  end->x = pLineArray->GetNumberAt(2);
++  end->y = pLineArray->GetNumberAt(3);
++
++  return true;
++}
++
+ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
+ FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj) {
+   CPDF_AnnotContext* pAnnot = CPDFAnnotContextFromFPDFAnnotation(annot);
+diff --git a/public/fpdf_annot.h b/public/fpdf_annot.h
+index ce033cde3..c4b0f71b3 100644
+--- a/public/fpdf_annot.h
++++ b/public/fpdf_annot.h
+@@ -232,6 +232,10 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
+ FPDFAnnot_GetInkStrokePoints(FPDF_ANNOTATION annot, int index,
+                              FS_POINTF* points);
+
++FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
++FPDFAnnot_GetLine(FPDF_ANNOTATION annot, FS_POINTF* start,
++                  FS_POINTF* end);
++
+ // Experimental API.
+ // Add |obj| to |annot|. |obj| must have been created by
+ // FPDFPageObj_CreateNew{Path|Rect}() or FPDFPageObj_New{Text|Image}Obj(), and
+--
+2.26.2
+
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk 
b/external/pdfium/UnpackedTarball_pdfium.mk
index 5eccb92001eb..152178c2b1ca 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -16,6 +16,7 @@ pdfium_patches += windows7.patch.1
 pdfium_patches += c++20-comparison.patch
 pdfium_patches += AnnotationInkAndVertices.patch.1
 pdfium_patches += AnnotationBorderProperties.patch.1
+pdfium_patches += AnnotationLineStartAndEnd.patch.1
 
 # Work around <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94141> "c++20 
rewritten operator==
 # recursive call mixing friend and external operators for template class" in 
GCC with
diff --git a/include/vcl/filter/PDFiumLibrary.hxx 
b/include/vcl/filter/PDFiumLibrary.hxx
index ee8a453a8b15..474f509df46b 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -103,6 +103,7 @@ public:
     basegfx::B2DSize getBorderCornerRadius();
     size_t getAttachmentPointsCount();
     std::vector<basegfx::B2DPoint> getAttachmentPoints(size_t nIndex);
+    std::vector<basegfx::B2DPoint> getLineGeometry();
 };
 
 class PDFiumPage;
diff --git a/vcl/qa/cppunit/PDFiumLibraryTest.cxx 
b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
index 2ef9ba942f27..6b4dbedff185 100644
--- a/vcl/qa/cppunit/PDFiumLibraryTest.cxx
+++ b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
@@ -325,6 +325,8 @@ void PDFiumLibraryTest::testAnnotationsDifferentTypes()
         CPPUNIT_ASSERT_EQUAL(0, pAnnotation->getObjectCount());
         OUString aContentsString = 
pAnnotation->getString(vcl::pdf::constDictionaryKeyContents);
         CPPUNIT_ASSERT_EQUAL(OUString("Inline Note"), aContentsString);
+        auto const& rLineGeometry = pAnnotation->getLineGeometry();
+        CPPUNIT_ASSERT_EQUAL(true, rLineGeometry.empty());
     }
 
     {
@@ -339,6 +341,8 @@ void PDFiumLibraryTest::testAnnotationsDifferentTypes()
         auto const& aPoints = aInkStrokes[0];
         CPPUNIT_ASSERT_EQUAL(size_t(74), aPoints.size());
         CPPUNIT_ASSERT_DOUBLES_EQUAL(2.0f, pAnnotation->getBorderWidth(), 
1E-2);
+        auto const& rLineGeometry = pAnnotation->getLineGeometry();
+        CPPUNIT_ASSERT_EQUAL(true, rLineGeometry.empty());
     }
 
     {
@@ -348,6 +352,8 @@ void PDFiumLibraryTest::testAnnotationsDifferentTypes()
         CPPUNIT_ASSERT_EQUAL(0, pAnnotation->getObjectCount());
         OUString aContentsString = 
pAnnotation->getString(vcl::pdf::constDictionaryKeyContents);
         CPPUNIT_ASSERT_EQUAL(OUString("Line Text"), aContentsString);
+        auto const& rLineGeometry = pAnnotation->getLineGeometry();
+        CPPUNIT_ASSERT_EQUAL(false, rLineGeometry.empty());
     }
 
     {
@@ -361,6 +367,8 @@ void PDFiumLibraryTest::testAnnotationsDifferentTypes()
         auto const& aVertices = pAnnotation->getVertices();
         CPPUNIT_ASSERT_EQUAL(size_t(3), aVertices.size());
         CPPUNIT_ASSERT_DOUBLES_EQUAL(2.0f, pAnnotation->getBorderWidth(), 
1E-2);
+        auto const& rLineGeometry = pAnnotation->getLineGeometry();
+        CPPUNIT_ASSERT_EQUAL(true, rLineGeometry.empty());
     }
 
     {
@@ -370,6 +378,8 @@ void PDFiumLibraryTest::testAnnotationsDifferentTypes()
         CPPUNIT_ASSERT_EQUAL(0, pAnnotation->getObjectCount());
         OUString aContentsString = 
pAnnotation->getString(vcl::pdf::constDictionaryKeyContents);
         CPPUNIT_ASSERT_EQUAL(OUString("Ellipse Text"), aContentsString);
+        auto const& rLineGeometry = pAnnotation->getLineGeometry();
+        CPPUNIT_ASSERT_EQUAL(true, rLineGeometry.empty());
     }
 
     {
@@ -381,6 +391,8 @@ void PDFiumLibraryTest::testAnnotationsDifferentTypes()
         CPPUNIT_ASSERT_EQUAL(OUString("Rectangle Text"), aContentsString);
         CPPUNIT_ASSERT_EQUAL(Color(0xFF, 0xE0, 0x00), pAnnotation->getColor());
         CPPUNIT_ASSERT_EQUAL(false, 
pAnnotation->hasKey(vcl::pdf::constDictionaryKeyInteriorColor));
+        auto const& rLineGeometry = pAnnotation->getLineGeometry();
+        CPPUNIT_ASSERT_EQUAL(true, rLineGeometry.empty());
     }
 }
 
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index 32c33580d1df..0b5114830c71 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -525,6 +525,19 @@ std::vector<basegfx::B2DPoint> 
PDFiumAnnotation::getAttachmentPoints(size_t nInd
     return aQuads;
 }
 
+std::vector<basegfx::B2DPoint> PDFiumAnnotation::getLineGeometry()
+{
+    std::vector<basegfx::B2DPoint> aLine;
+    FS_POINTF aStart;
+    FS_POINTF aEnd;
+    if (FPDFAnnot_GetLine(mpAnnotation, &aStart, &aEnd))
+    {
+        aLine.emplace_back(aStart.x, aStart.y);
+        aLine.emplace_back(aEnd.x, aEnd.y);
+    }
+    return aLine;
+}
+
 namespace
 {
 bool getBorderProperties(FPDF_ANNOTATION mpAnnotation, float& 
rHorizontalCornerRadius,
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to