summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2022-03-02 16:41:04 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-03-03 17:18:21 +0100
commit902e23d6e95f86a6ffbc642e57e35dcd27a6e83b (patch)
tree0c3a20839949df1d748d3ebcda6afc476fcd4c6a
parent268bddd26cc006a7b4a1f9142245aecbff51c173 (diff)
tdf#146171 DOCX: fix loss of change tracking, if no date
was specified, or it was specified as zero date (e.g. in a LO DOCX export). DateTime attribute w:date is optional in w:ins/w:del according to the OOXML standard. Not specified w:date was imported as invalid zero date "0-00-00T00:00:00Z" resulting loss of change tracking data completely during an ODF roundtrip. Import this invalid zero date as Epoch time to avoid losing change tracking data. Change-Id: If8442db9aa5e41c470827545c36c64f598887101 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130885 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130907
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf146171.docxbin0 -> 11710 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx4
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport16.cxx18
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx11
4 files changed, 30 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf146171.docx b/sw/qa/extras/ooxmlexport/data/tdf146171.docx
new file mode 100644
index 000000000000..bdd534527a99
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf146171.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index d2922e940bf8..d39c1fdd6bcd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -933,8 +933,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf145720, "tdf104797.docx")
// mandatory authors and dates
assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart", "author", u"Tekijä");
assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart", "author", u"Tekijä");
- assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart", "date", "0-00-00T00:00:00Z");
- assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart", "date", "0-00-00T00:00:00Z");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:moveFrom/w:moveFromRangeStart", "date", "1970-01-01T00:00:00Z");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:moveTo/w:moveToRangeStart", "date", "1970-01-01T00:00:00Z");
}
}
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index e3eb50c29ea4..78db013bc159 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -647,6 +647,24 @@ CPPUNIT_TEST_FIXTURE(Test, testTextframeHyperlink)
assertXPath(pXmlDoc, "//w:pict/v:rect", "href", "https://libreoffice.org/");
}
+CPPUNIT_TEST_FIXTURE(Test, testTdf146171_invalid_change_date)
+{
+ load(mpTestDocumentPath, "tdf146171.docx");
+ // false alarm? during ODF roundtrip:
+ // 'Error: "1970-01-01" does not satisfy the "dateTime" type'
+ // disable and check only the conversion of the invalid (zeroed) change date
+ // reload("writer8", "tdf146171.odt");
+ reload("Office Open XML Text", "tdf146171.docx");
+
+ xmlDocUniquePtr pXmlDoc = parseExport();
+ // This was 0
+ assertXPath(pXmlDoc, "//w:ins", 4);
+ // This was 0
+ assertXPath(pXmlDoc, "//w:del", 1);
+ // This was 0000-00-00T00:00:00Z, resulting loss of change tracking during ODF roundtrip
+ assertXPath(pXmlDoc, "//w:del", "date", "1970-01-01T00:00:00Z");
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf139580, "tdf139580.odt")
{
// Without the fix in place, this test would have crashed at export time
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 13f1fb9056b9..8afcede51d13 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3144,7 +3144,16 @@ void DomainMapper_Impl::CreateRedline(uno::Reference<text::XTextRange> const& xR
pRedlineProperties[0].Name = getPropertyName( PROP_REDLINE_AUTHOR );
pRedlineProperties[0].Value <<= pRedline->m_sAuthor;
pRedlineProperties[1].Name = getPropertyName( PROP_REDLINE_DATE_TIME );
- pRedlineProperties[1].Value <<= ConversionHelper::ConvertDateStringToDateTime( pRedline->m_sDate );
+ util::DateTime aDateTime = ConversionHelper::ConvertDateStringToDateTime( pRedline->m_sDate );
+ // tdf#146171 import not specified w:date (or specified as zero date "0-00-00")
+ // as Epoch time to avoid of losing change tracking data during ODF roundtrip
+ if ( aDateTime.Year == 0 && aDateTime.Month == 0 && aDateTime.Day == 0 )
+ {
+ aDateTime.Year = 1970;
+ aDateTime.Month = 1;
+ aDateTime.Day = 1;
+ }
+ pRedlineProperties[1].Value <<= aDateTime;
pRedlineProperties[2].Name = getPropertyName( PROP_REDLINE_REVERT_PROPERTIES );
pRedlineProperties[2].Value <<= pRedline->m_aRevertProperties;
pRedlineProperties[3].Name = "RedlineMoved";