summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorRosemary Sebastian <rosemaryseb8@gmail.com>2016-01-25 12:40:35 +0530
committerKatarina Behrens <Katarina.Behrens@cib.de>2016-01-27 22:41:58 +0000
commit2b0669eec0d86e973a7d8def8744c522bbf8af8b (patch)
tree16f619b45f28da40ad83bfdc0bce326ecbe33715 /sd
parent678ce97d38167c886697d5e842eeace6bc25ca15 (diff)
Format the datetime fields properly on import
Make sure that, after export, the datetime fields in impress are imported with the correct number format. Change-Id: I5565fef69b3a62e7dd59ea0d39cde151fb0af976 Reviewed-on: https://gerrit.libreoffice.org/21610 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/data/odp/numfmt.odpbin0 -> 10608 bytes
-rwxr-xr-xsd/qa/unit/data/pptx/numfmt.pptxbin0 -> 41105 bytes
-rw-r--r--sd/qa/unit/export-tests.cxx90
3 files changed, 90 insertions, 0 deletions
diff --git a/sd/qa/unit/data/odp/numfmt.odp b/sd/qa/unit/data/odp/numfmt.odp
new file mode 100644
index 000000000000..6fd32ce0a66d
--- /dev/null
+++ b/sd/qa/unit/data/odp/numfmt.odp
Binary files differ
diff --git a/sd/qa/unit/data/pptx/numfmt.pptx b/sd/qa/unit/data/pptx/numfmt.pptx
new file mode 100755
index 000000000000..aca6927101d6
--- /dev/null
+++ b/sd/qa/unit/data/pptx/numfmt.pptx
Binary files differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 211cff25eb4d..17ecbd2f91f0 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -137,6 +137,8 @@ public:
void testParaMarginAndindentation();
void testTransparentBackground();
void testExportTransitionsPPTX();
+ void testDatetimeFieldNumberFormat();
+ void testDatetimeFieldNumberFormatPPTX();
void testFdo90607();
void testTdf91378();
@@ -188,6 +190,8 @@ public:
CPPUNIT_TEST(testExportTransitionsPPTX);
CPPUNIT_TEST(testTdf92527);
+ CPPUNIT_TEST(testDatetimeFieldNumberFormat);
+ CPPUNIT_TEST(testDatetimeFieldNumberFormatPPTX);
CPPUNIT_TEST_SUITE_END();
@@ -1499,6 +1503,92 @@ void SdExportTest::testTdf92527()
xDocShRef->DoClose();
}
+namespace {
+
+void matchNumberFormat( int nPage, uno::Reference< text::XTextRange > xRun)
+{
+ uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
+
+ uno::Reference<text::XTextField> xField;
+ xPropSet->getPropertyValue("TextField") >>= xField;
+ CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() );
+
+ xPropSet.set(xField, uno::UNO_QUERY);
+ sal_Int32 nNumFmt;
+ xPropSet->getPropertyValue("NumberFormat") >>= nNumFmt;
+ switch( nPage )
+ {
+ case 0: // 13/02/96
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date fields don't match", sal_Int32(2), nNumFmt);
+ break;
+ case 1: // 13/02/1996
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date fields don't match", sal_Int32(5), nNumFmt);
+ break;
+ case 2: // 13 February 1996
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date fields don't match", sal_Int32(3), nNumFmt);
+ break;
+ case 3: // 13:49:38
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time fields don't match", sal_Int32(2), nNumFmt);
+ break;
+ case 4: // 13:49
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time fields don't match", sal_Int32(3), nNumFmt);
+ break;
+ case 5: // 01:49 PM
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time fields don't match", sal_Int32(6), nNumFmt);
+ break;
+ case 6: // 01:49:38 PM
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time fields don't match", sal_Int32(7), nNumFmt);
+ }
+}
+
+}
+
+void SdExportTest::testDatetimeFieldNumberFormat()
+{
+ ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/numfmt.odp"), ODP);
+
+ xDocShRef = saveAndReload( xDocShRef, PPTX );
+
+ for(sal_uInt16 i = 0; i <= 6; ++i)
+ {
+ // get TextShape 1 from page i
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, i, xDocShRef ) );
+
+ // Get first paragraph
+ uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) );
+
+ // first chunk of text
+ uno::Reference<text::XTextRange> xRun( getRunFromParagraph( 0, xParagraph ) );
+
+ matchNumberFormat( i, xRun );
+ }
+
+ xDocShRef->DoClose();
+}
+
+void SdExportTest::testDatetimeFieldNumberFormatPPTX()
+{
+ ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/numfmt.pptx"), PPTX);
+
+ xDocShRef = saveAndReload( xDocShRef, PPTX );
+
+ for(sal_uInt16 i = 0; i <= 6; ++i)
+ {
+ // get TextShape 1 from page i
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, i, xDocShRef ) );
+
+ // Get first paragraph
+ uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) );
+
+ // first chunk of text
+ uno::Reference<text::XTextRange> xRun( getRunFromParagraph( 0, xParagraph ) );
+
+ matchNumberFormat( i, xRun );
+ }
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();