diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-03-07 18:04:09 +0100 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-03-08 17:50:59 +0100 |
commit | b2385830711ec700956869ace7670edd845a50df (patch) | |
tree | 3ecc5b0eb28f5511aaf864639494273ba418cea6 /tools | |
parent | writerfilter: import date into docx date controls (diff) | |
download | core-b2385830711ec700956869ace7670edd845a50df.tar.gz core-b2385830711ec700956869ace7670edd845a50df.zip |
ooxml: export date controls properly
Export date controls as ooxml Standard Document Tags (SDT) instead
of replacing them with plain text.
SDT date controls contain the date in ISO format as an attribute of
<date> tag, a custom date format that can be specified by the user
in the <dateFormat> tag and the date formatted in that custom format
in the <w:sdtContent> tag.
The unit test testFormControl from ooxmlexport suite was removed,
it only checked if the date control was exported as text and it
obviously fails now. A new test that checks the values of the
exported control was written instead.
A pair of date format functions were added to datetimeutils.hxx.
TODO: to avoid supporting all the posible custom formats that can be
specified in the <dateFormat> tag, it is forced to dd/mm/yyyy on
export.
Change-Id: I9d1b6f840ee9e133831fdb04ad399fe31bcb2063
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/datetime/datetimeutils.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/source/datetime/datetimeutils.cxx b/tools/source/datetime/datetimeutils.cxx index 512ae8230f11..417271c60eee 100644 --- a/tools/source/datetime/datetimeutils.cxx +++ b/tools/source/datetime/datetimeutils.cxx @@ -54,3 +54,23 @@ OString DateTimeToOString( const DateTime& rDateTime ) return aBuffer.makeStringAndClear(); } + +OString DateToOString( const Date& rDate ) +{ + Time aTime( Time::EMPTY ); + return DateTimeToOString( DateTime( rDate, aTime ) ); +} + +OString DateToDDMMYYYYOString( const Date& rDate ) +{ + OStringBuffer aBuffer( 25 ); + lcl_AppendTwoDigits( aBuffer, rDate.GetDay() ); + aBuffer.append( '/' ); + + lcl_AppendTwoDigits( aBuffer, rDate.GetMonth() ); + aBuffer.append( '/' ); + + aBuffer.append( sal_Int32( rDate.GetYear() ) ); + + return aBuffer.makeStringAndClear(); +} |