diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-12-10 15:14:00 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-12-10 15:32:28 +0100 |
commit | 8fde1076f82c82213f232ca6b0c5fcf609dade60 (patch) | |
tree | 2ed3dbe6d5c55bc375daf0aab0b2c86ca92c850d /xmloff | |
parent | 0f6f072fcf7c967a1546f65da9ff15d8a5e0e81d (diff) |
sax, xmloff: fix ODF import/export of text:time/text:time-value
The value written for an Impress time field is something like
text:time-value="0000-00-00T23:28:07" (in LO 3.5+) or
text:time-value="0-00-00T23:28:07" (in OOo 3.3) which contains an
invalid all-zero date. Such values are actually rejected by the
ODF import since commit ae3e2f170045a1525f67e9f3e9b7e03d94f2b56b.
Actually there was no real support to read the RelaxNG type
timeOrDateTime before.
So fix that by:
- adding convertTimeOrDateTime/parseTimeOrDateTime functions to
sax::Converter
- recognizing and ignoring the 2 invalid all-zero values written by
LO 3.5 and historic OOo respectively
- writing a bare "time" in text:time-value if the DateTime struct
contains zero Date members
(Older OOo versions and AOO cannot actually read that, but everything
they _can_ read is invalid ODF...)
Change-Id: I754076caee74a5163ed3f972af0f23796aa14f9f
(cherry picked from commit cc407e50e8a1a74f9d1ed29d444dce9bd2e9167a)
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/inc/txtflde.hxx | 6 | ||||
-rw-r--r-- | xmloff/source/text/txtflde.cxx | 22 | ||||
-rw-r--r-- | xmloff/source/text/txtfldi.cxx | 4 |
3 files changed, 27 insertions, 5 deletions
diff --git a/xmloff/inc/txtflde.hxx b/xmloff/inc/txtflde.hxx index 6d5b38755fa1..6728690074d0 100644 --- a/xmloff/inc/txtflde.hxx +++ b/xmloff/inc/txtflde.hxx @@ -366,6 +366,12 @@ protected: sal_Bool bIsDate, /// export as date (rather than date/time)? sal_uInt16 nPrefix = XML_NAMESPACE_TEXT); /// attribute name prefix + /// export time or dateTime + void ProcessTimeOrDateTime( + enum ::xmloff::token::XMLTokenEnum eXMLName, /// attribute token + const ::com::sun::star::util::DateTime& rTime, /// date/time value + sal_uInt16 nPrefix = XML_NAMESPACE_TEXT); /// attribute name prefix + /// export all attributes for bibliography data fields void ProcessBibliographyData( const ::com::sun::star::uno::Reference < diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index 4c5ebb43d7ad..cc9ca75cfc8a 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -1261,17 +1261,17 @@ void XMLTextFieldExport::ExportFieldHelper( if (xPropSetInfo->hasPropertyByName(sPropertyDateTimeValue)) { // no value -> current time - ProcessDateTime(XML_TIME_VALUE, + ProcessTimeOrDateTime(XML_TIME_VALUE, GetDateTimeProperty(sPropertyDateTimeValue, rPropSet), - sal_False ); + XML_NAMESPACE_TEXT); } if (xPropSetInfo->hasPropertyByName(sPropertyDateTime)) { // no value -> current time - ProcessDateTime(XML_TIME_VALUE, + ProcessTimeOrDateTime(XML_TIME_VALUE, GetDateTimeProperty(sPropertyDateTime,rPropSet), - sal_False ); + XML_NAMESPACE_TEXT); } if (xPropSetInfo->hasPropertyByName(sPropertyIsFixed)) { @@ -2674,6 +2674,20 @@ void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName, } } +/// export a time or dateTime +void XMLTextFieldExport::ProcessTimeOrDateTime(enum XMLTokenEnum eName, + const util::DateTime& rTime, + sal_uInt16 nPrefix) +{ + OUStringBuffer aBuffer; + + // date/time value + ::sax::Converter::convertTimeOrDateTime(aBuffer, rTime, 0); + + // output attribute + ProcessString(eName, aBuffer.makeStringAndClear(), sal_True, nPrefix); +} + SvXMLEnumMapEntry const aBibliographyDataTypeMap[] = { diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index 90553d6ac276..bea669e5bbca 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -1095,6 +1095,7 @@ void XMLTimeFieldImportContext::ProcessAttribute( { case XML_TOK_TEXTFIELD_TIME_VALUE: { + // FIXME double appears unused? double fTmp; if (GetImport().GetMM100UnitConverter(). convertDateTime(fTmp, sAttrValue)) @@ -1103,7 +1104,8 @@ void XMLTimeFieldImportContext::ProcessAttribute( bTimeOK = sal_True; } - if (::sax::Converter::parseDateTime(aDateTimeValue, 0, sAttrValue)) + if (::sax::Converter::parseTimeOrDateTime(aDateTimeValue, 0, + sAttrValue)) { bTimeOK = sal_True; } |