summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2017-05-10 16:42:01 +0200
committerJan Holesovsky <kendy@collabora.com>2017-05-10 17:46:46 +0200
commitc43ee7161ab57a22b53655b7b8d6e20ce1a70daa (patch)
treed3e67c9d4d88b4e684da4cef804de6386744ea48 /sw/qa
parentbb0543f6de926a2d89797162a974bb01772d890d (diff)
related tdf#107677 html import: Fix the legacy datetime format reading.
Also includes unit test for both the legacy and new format. Change-Id: I254c40af45a4700319577f11e6cb8ff5f0ff6128
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/htmlimport/data/meta-ISO8601-dates.html20
-rw-r--r--sw/qa/extras/htmlimport/htmlimport.cxx22
2 files changed, 42 insertions, 0 deletions
diff --git a/sw/qa/extras/htmlimport/data/meta-ISO8601-dates.html b/sw/qa/extras/htmlimport/data/meta-ISO8601-dates.html
new file mode 100644
index 000000000000..86390d77eade
--- /dev/null
+++ b/sw/qa/extras/htmlimport/data/meta-ISO8601-dates.html
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
+ <title></title>
+ <meta name="generator" content="LibreOfficeDev 5.4.0.0.alpha1 (Linux)"/>
+ <meta name="created" content="2017-05-07T12:34:03.921000000"/>
+ <meta name="changed" content="20170508;124700386000000"/>
+ <style type="text/css">
+ @page { size: 21cm 29.7cm; margin: 2cm }
+ p { margin-bottom: 0.25cm; line-height: 120% }
+ td p { margin-bottom: 0cm }
+ </style>
+</head>
+<body>
+<p>
+Test
+</p>
+</body>
+</html>
diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx
index 216b7f42f12c..1e73ac89fc2b 100644
--- a/sw/qa/extras/htmlimport/htmlimport.cxx
+++ b/sw/qa/extras/htmlimport/htmlimport.cxx
@@ -13,6 +13,8 @@
#include <com/sun/star/graphic/GraphicType.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/BitmapMode.hpp>
+#include <tools/datetime.hxx>
+#include <unotools/datetime.hxx>
#include <vcl/GraphicNativeTransform.hxx>
#include <sfx2/linkmgr.hxx>
@@ -174,6 +176,26 @@ DECLARE_HTMLIMPORT_TEST(testListStyleType, "list-style.html")
CPPUNIT_FAIL("no NumberingType property found for para 14");
}
+DECLARE_HTMLIMPORT_TEST(testMetaIsoDates, "meta-ISO8601-dates.html")
+{
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ SwDocShell* pDocShell(pTextDoc->GetDocShell());
+ uno::Reference<document::XDocumentProperties> xDocProps;
+
+ CPPUNIT_ASSERT(pDocShell);
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(pDocShell->GetModel(), uno::UNO_QUERY);
+ xDocProps.set(xDPS->getDocumentProperties());
+
+ // get the document properties
+ CPPUNIT_ASSERT(xDocProps.is());
+ DateTime aCreated(xDocProps->getCreationDate()); // in the new format
+ DateTime aModified(xDocProps->getModificationDate()); // in the legacy format (what LibreOffice used to write)
+
+ CPPUNIT_ASSERT_EQUAL(DateTime(Date(7, 5, 2017), tools::Time(12, 34, 3, 921000000)), aCreated);
+ CPPUNIT_ASSERT_EQUAL(DateTime(Date(8, 5, 2017), tools::Time(12, 47, 0, 386000000)), aModified);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */