summaryrefslogtreecommitdiff
path: root/vcl/qa/cppunit/PDFiumLibraryTest.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-06-18 13:50:15 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-06-21 21:02:38 +0200
commit4e3196ceedc2b79d58bb57dba86f2f0158d32998 (patch)
treee403030503ba791ed80fc9ecea3049ab632e62c9 /vcl/qa/cppunit/PDFiumLibraryTest.cxx
parenta641e68077b8c91db8f7520f817da9f7949d0e6d (diff)
support date and time for PDFium and use it for annotations
PDF annotations have the modification date and time accessible in the PDF specific format. With PDFium we read the annotation date and time and convert that to css::utils::DateTime (by converting to ISO8601 compatible string first). Add support for modification date and tme for annotations into ImportPDFUnloaded and when the annotations are inserted into the document as comments (in Draw document). Change-Id: I24aacde84b7530365d67ed335b1eefbaee706eca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96759 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa/cppunit/PDFiumLibraryTest.cxx')
-rw-r--r--vcl/qa/cppunit/PDFiumLibraryTest.cxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/PDFiumLibraryTest.cxx b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
index c786b6edc211..61b3981731f6 100644
--- a/vcl/qa/cppunit/PDFiumLibraryTest.cxx
+++ b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
@@ -16,6 +16,9 @@
#include <unotest/bootstrapfixturebase.hxx>
#include <unotest/directories.hxx>
+#include <unotools/datetime.hxx>
+
+#include <com/sun/star/util/DateTime.hpp>
#include <vcl/graph.hxx>
#include <vcl/graphicfilter.hxx>
@@ -34,12 +37,14 @@ class PDFiumLibraryTest : public test::BootstrapFixtureBase
void testPages();
void testAnnotationsMadeInEvince();
void testAnnotationsMadeInAcrobat();
+ void testTools();
CPPUNIT_TEST_SUITE(PDFiumLibraryTest);
CPPUNIT_TEST(testDocument);
CPPUNIT_TEST(testPages);
CPPUNIT_TEST(testAnnotationsMadeInEvince);
CPPUNIT_TEST(testAnnotationsMadeInAcrobat);
+ CPPUNIT_TEST(testTools);
CPPUNIT_TEST_SUITE_END();
};
@@ -144,6 +149,10 @@ void PDFiumLibraryTest::testAnnotationsMadeInEvince()
CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationIndex(pPopupAnnotation));
CPPUNIT_ASSERT_EQUAL(16, pPopupAnnotation->getSubType());
+
+ OUString sDateTimeString
+ = pAnnotation->getString(vcl::pdf::constDictionaryKeyModificationDate);
+ CPPUNIT_ASSERT_EQUAL(OUString("D:20200612201322+02'00"), sDateTimeString);
}
{
@@ -231,6 +240,22 @@ void PDFiumLibraryTest::testAnnotationsMadeInAcrobat()
}
}
+void PDFiumLibraryTest::testTools()
+{
+ OUString sConverted = vcl::pdf::convertPdfDateToISO8601("D:20200612201322+02'00");
+
+ css::util::DateTime aDateTime;
+ CPPUNIT_ASSERT(utl::ISO8601parseDateTime(sConverted, aDateTime));
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(2020), aDateTime.Year);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(6), aDateTime.Month);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(12), aDateTime.Day);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), aDateTime.Hours);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(13), aDateTime.Minutes);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(22), aDateTime.Seconds);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), aDateTime.NanoSeconds);
+ CPPUNIT_ASSERT_EQUAL(false, bool(aDateTime.IsUTC));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(PDFiumLibraryTest);
CPPUNIT_PLUGIN_IMPLEMENT();