[Libreoffice-commits] core.git: 2 commits - include/sax include/sfx2 offapi/com sax/qa sax/source sc/source sfx2/source xmloff/source
Michael Stahl
mstahl at redhat.com
Mon Jul 15 06:27:21 PDT 2013
include/sax/tools/converter.hxx | 22 ++-
include/sfx2/dinfdlg.hxx | 12 +
offapi/com/sun/star/util/DateTimeWithTimezone.idl | 2
offapi/com/sun/star/util/DateWithTimezone.idl | 2
offapi/com/sun/star/util/TimeWithTimezone.idl | 2
sax/qa/cppunit/test_converter.cxx | 6
sax/source/tools/converter.cxx | 95 ++++++++-------
sc/source/filter/xml/XMLCalculationSettingsContext.cxx | 2
sc/source/filter/xml/XMLConverter.cxx | 2
sc/source/filter/xml/XMLTrackedChangesContext.cxx | 2
sfx2/source/dialog/dinfdlg.cxx | 68 ++++++++--
sfx2/source/doc/SfxDocumentMetaData.cxx | 75 ++++++++---
xmloff/source/chart/SchXMLCalculationSettingsContext.cxx | 2
xmloff/source/chart/SchXMLExport.cxx | 2
xmloff/source/core/DocumentSettingsContext.cxx | 2
xmloff/source/core/SettingsExportHelper.cxx | 2
xmloff/source/core/xmluconv.cxx | 2
xmloff/source/draw/sdxmlexp.cxx | 2
xmloff/source/draw/ximppage.cxx | 2
xmloff/source/forms/handler/vcl_date_handler.cxx | 4
xmloff/source/text/XMLChangedRegionImportContext.cxx | 2
xmloff/source/text/XMLRedlineExport.cxx | 4
xmloff/source/text/txtflde.cxx | 4
xmloff/source/text/txtfldi.cxx | 6
xmloff/source/xforms/SchemaRestrictionContext.cxx | 2
xmloff/source/xforms/xformsexport.cxx | 2
26 files changed, 209 insertions(+), 119 deletions(-)
New commits:
commit 20cbf5bd3042ed547408f324e020a3d6405705f7
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Jul 11 17:27:06 2013 +0200
i#108348: support DateTimeWithTimezone in user defined Document Properties
- fix interface of sax::Converter to allow passing time zones
(rename the parsing methods while at it to reduce pointless overloading)
- SfxDocumentMetaData supports DateWithTimezone and DateTimeWithTimezone
in user-defined properties
- add some ugly hacks to SfxCustomPropertiesPage to preserve existing
time zones (which are not displayed in UI currently)
Change-Id: Ice94112b9d79c285f80b5beda15f0ace91db97f3
diff --git a/include/sax/tools/converter.hxx b/include/sax/tools/converter.hxx
index 615308c..1e89d2c 100644
--- a/include/sax/tools/converter.hxx
+++ b/include/sax/tools/converter.hxx
@@ -22,6 +22,8 @@
#include "sax/saxdllapi.h"
+#include <boost/optional/optional.hpp>
+
#include <sal/types.h>
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
@@ -36,6 +38,8 @@ namespace com { namespace sun { namespace star {
namespace util {
struct Date;
struct DateTime;
+ struct DateWithTimeZone;
+ struct DateTimeWithTimeZone;
struct Duration;
}
} } }
@@ -153,23 +157,33 @@ public:
/** convert util::Date to ISO "date" string */
static void convertDate( OUStringBuffer& rBuffer,
- const com::sun::star::util::Date& rDate );
+ const com::sun::star::util::Date& rDate,
+ sal_Int16 const* pTimeZoneOffset);
/** convert util::DateTime to ISO "date" or "dateTime" string */
static void convertDateTime( OUStringBuffer& rBuffer,
const com::sun::star::util::DateTime& rDateTime,
+ sal_Int16 const* pTimeZoneOffset,
bool bAddTimeIf0AM = false );
+ static void convertDateTZ( OUStringBuffer& rBuffer,
+ com::sun::star::util::DateWithTimeZone const& rDate );
+
+ static void convertDateTimeTZ( OUStringBuffer& rBuffer,
+ com::sun::star::util::DateTimeWithTimeZone const& rDateTime );
+
/** convert ISO "date" or "dateTime" string to util::DateTime */
- static bool convertDateTime( com::sun::star::util::DateTime& rDateTime,
+ static bool parseDateTime( com::sun::star::util::DateTime& rDateTime,
+ boost::optional<sal_Int16> * pTimeZoneOffset,
const OUString& rString );
/** convert ISO "date" or "dateTime" string to util::DateTime or
util::Date */
- static bool convertDateOrDateTime(
- com::sun::star::util::Date & rDate,
+ static bool parseDateOrDateTime(
+ com::sun::star::util::Date * pDate,
com::sun::star::util::DateTime & rDateTime,
bool & rbDateTime,
+ boost::optional<sal_Int16> * pTimeZoneOffset,
const OUString & rString );
/** gets the position of the first comma after npos in the string
diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx
index c0758b5..5752b2c 100644
--- a/include/sfx2/dinfdlg.hxx
+++ b/include/sfx2/dinfdlg.hxx
@@ -16,8 +16,10 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef _SFX_DINFDLG_HXX
-#define _SFX_DINFDLG_HXX
+#ifndef SFX_DINFDLG_HXX
+#define SFX_DINFDLG_HXX
+
+#include <boost/optional/optional.hpp>
#include "sal/config.h"
#include "sfx2/dllapi.h"
@@ -285,6 +287,8 @@ private:
CustomPropertyLine* m_pLine;
public:
+ ::boost::optional<sal_Int16> m_TZ;
+
inline CustomPropertiesDateField(
Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
DateField( pParent, rResId ), m_pLine( pLine ) {}
@@ -297,9 +301,11 @@ private:
CustomPropertyLine* m_pLine;
public:
+ bool m_isUTC;
+
inline CustomPropertiesTimeField(
Window* pParent, const ResId& rResId, CustomPropertyLine* pLine ) :
- TimeField( pParent, rResId ), m_pLine( pLine ) {}
+ TimeField( pParent, rResId ), m_pLine( pLine ), m_isUTC(false) {}
inline CustomPropertyLine* GetLine() const { return m_pLine; }
};
diff --git a/sax/qa/cppunit/test_converter.cxx b/sax/qa/cppunit/test_converter.cxx
index cfda248..b1cb070 100644
--- a/sax/qa/cppunit/test_converter.cxx
+++ b/sax/qa/cppunit/test_converter.cxx
@@ -168,12 +168,12 @@ static void doTest(util::DateTime const & rdt, char const*const pis,
OUString is(OUString::createFromAscii(pis));
util::DateTime odt;
SAL_INFO("sax.cppunit","about to convert '" << is << "'");
- bool bSuccess( Converter::convertDateTime(odt, is) );
+ bool bSuccess( Converter::parseDateTime(odt, 0, is) );
SAL_INFO("sax.cppunit","Y:" << odt.Year << " M:" << odt.Month << " D:" << odt.Day << " H:" << odt.Hours << " M:" << odt.Minutes << " S:" << odt.Seconds << " nS:" << odt.NanoSeconds << " UTC: " << (bool)odt.IsUTC);
CPPUNIT_ASSERT(bSuccess);
CPPUNIT_ASSERT(eqDateTime(rdt, odt));
OUStringBuffer buf;
- Converter::convertDateTime(buf, odt, true);
+ Converter::convertDateTime(buf, odt, 0, true);
SAL_INFO("sax.cppunit","" << buf.getStr());
CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(pos),
buf.makeStringAndClear());
@@ -182,7 +182,7 @@ static void doTest(util::DateTime const & rdt, char const*const pis,
static void doTestDateTimeF(char const*const pis)
{
util::DateTime odt;
- bool bSuccess = Converter::convertDateTime(odt,
+ bool bSuccess = Converter::parseDateTime(odt, 0,
OUString::createFromAscii(pis));
SAL_INFO("sax.cppunit","Y:" << odt.Year << " M:" << odt.Month << " D:" << odt.Day << " H:" << odt.Hours << "H M:" << odt.Minutes << " S:" << odt.Seconds << " nS:" << odt.NanoSeconds);
CPPUNIT_ASSERT(!bSuccess);
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index e99690e..911de8a 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -22,6 +22,8 @@
#include <com/sun/star/i18n/UnicodeType.hpp>
#include <com/sun/star/util/DateTime.hpp>
#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/DateTimeWithTimeZone.hpp>
+#include <com/sun/star/util/DateWithTimeZone.hpp>
#include <com/sun/star/util/Duration.hpp>
#include <com/sun/star/util/Time.hpp>
#include <com/sun/star/uno/Sequence.hxx>
@@ -1221,20 +1223,34 @@ lcl_AppendTimezone(OUStringBuffer & i_rBuffer, sal_Int16 const nOffset)
}
}
+void Converter::convertDateTZ( OUStringBuffer& rBuffer,
+ com::sun::star::util::DateWithTimeZone const& rDate)
+{
+ convertDate(rBuffer, rDate.DateInTZ, &rDate.Timezone);
+}
+
+void Converter::convertDateTimeTZ( OUStringBuffer& rBuffer,
+ com::sun::star::util::DateTimeWithTimeZone const& rDateTime)
+{
+ convertDateTime(rBuffer, rDateTime.DateTimeInTZ, &rDateTime.Timezone);
+}
+
/** convert util::Date to ISO "date" string */
void Converter::convertDate(
OUStringBuffer& i_rBuffer,
- const util::Date& i_rDate)
+ const util::Date& i_rDate,
+ sal_Int16 const*const pTimeZoneOffset)
{
const util::DateTime dt(0, 0, 0, 0,
i_rDate.Day, i_rDate.Month, i_rDate.Year, false);
- convertDateTime(i_rBuffer, dt, false);
+ convertDateTime(i_rBuffer, dt, pTimeZoneOffset, false);
}
/** convert util::DateTime to ISO "date" or "dateTime" string */
void Converter::convertDateTime(
OUStringBuffer& i_rBuffer,
const com::sun::star::util::DateTime& i_rDateTime,
+ sal_Int16 const*const pTimeZoneOffset,
bool i_bAddTimeIf0AM )
{
const sal_Unicode dash('-');
@@ -1297,10 +1313,9 @@ void Converter::convertDateTime(
}
}
- sal_uInt16 * pTimezone(0); // FIXME pass this as parameter
- if (pTimezone)
+ if (pTimeZoneOffset)
{
- lcl_AppendTimezone(i_rBuffer, *pTimezone);
+ lcl_AppendTimezone(i_rBuffer, *pTimeZoneOffset);
}
else if (i_rDateTime.IsUTC)
{
@@ -1310,33 +1325,13 @@ void Converter::convertDateTime(
}
/** convert ISO "date" or "dateTime" string to util::DateTime */
-bool Converter::convertDateTime( util::DateTime& rDateTime,
+bool Converter::parseDateTime( util::DateTime& rDateTime,
+ boost::optional<sal_Int16> *const pTimeZoneOffset,
const OUString& rString )
{
bool isDateTime;
- util::Date date;
- if (convertDateOrDateTime(date, rDateTime, isDateTime, rString))
- {
- if (!isDateTime)
- {
- rDateTime.Year = date.Year;
- rDateTime.Month = date.Month;
- rDateTime.Day = date.Day;
- rDateTime.Hours = 0;
- rDateTime.Minutes = 0;
- rDateTime.Seconds = 0;
- rDateTime.NanoSeconds = 0;
- // FIXME
-#if 0
- rDateTime.IsUTC = date.IsUTC;
-#endif
- }
- return true;
- }
- else
- {
- return false;
- }
+ return parseDateOrDateTime(0, rDateTime, isDateTime, pTimeZoneOffset,
+ rString);
}
static bool lcl_isLeapYear(const sal_uInt32 nYear)
@@ -1456,9 +1451,11 @@ readDateTimeComponent(const OUString & rString,
/** convert ISO "date" or "dateTime" string to util::DateTime or util::Date */
-bool Converter::convertDateOrDateTime(
- util::Date & rDate, util::DateTime & rDateTime,
- bool & rbDateTime, const OUString & rString )
+bool Converter::parseDateOrDateTime(
+ util::Date *const pDate, util::DateTime & rDateTime,
+ bool & rbDateTime,
+ boost::optional<sal_Int16> *const pTimeZoneOffset,
+ const OUString & rString )
{
bool bSuccess = true;
bool isNegative(false);
@@ -1655,10 +1652,9 @@ bool Converter::convertDateOrDateTime(
if (bSuccess)
{
- sal_uInt16 * pTimezone(0); // FIXME pass this as parameter
sal_Int16 const nTimezoneOffset = ((bHaveTimezoneMinus) ? (-1) : (+1))
* ((nTimezoneHours * 60) + nTimezoneMinutes);
- if (bHaveTime) // time is optional
+ if (!pDate || bHaveTime) // time is optional
{
rDateTime.Year =
((isNegative) ? (-1) : (+1)) * static_cast<sal_Int16>(nYear);
@@ -1670,9 +1666,9 @@ bool Converter::convertDateOrDateTime(
rDateTime.NanoSeconds = static_cast<sal_uInt32>(nNanoSeconds);
if (bHaveTimezone)
{
- if (pTimezone)
+ if (pTimeZoneOffset)
{
- *pTimezone = nTimezoneOffset;
+ *pTimeZoneOffset = nTimezoneOffset;
rDateTime.IsUTC = (0 == nTimezoneOffset);
}
else
@@ -1685,21 +1681,25 @@ bool Converter::convertDateOrDateTime(
}
else
{
+ if (pTimeZoneOffset)
+ {
+ pTimeZoneOffset->reset();
+ }
rDateTime.IsUTC = false;
}
- rbDateTime = true;
+ rbDateTime = bHaveTime;
}
else
{
- rDate.Year =
+ pDate->Year =
((isNegative) ? (-1) : (+1)) * static_cast<sal_Int16>(nYear);
- rDate.Month = static_cast<sal_uInt16>(nMonth);
- rDate.Day = static_cast<sal_uInt16>(nDay);
+ pDate->Month = static_cast<sal_uInt16>(nMonth);
+ pDate->Day = static_cast<sal_uInt16>(nDay);
if (bHaveTimezone)
{
- if (pTimezone)
+ if (pTimeZoneOffset)
{
- *pTimezone = nTimezoneOffset;
+ *pTimeZoneOffset = nTimezoneOffset;
}
else
{
@@ -1707,6 +1707,13 @@ bool Converter::convertDateOrDateTime(
SAL_INFO("sax", "dropping timezone");
}
}
+ else
+ {
+ if (pTimeZoneOffset)
+ {
+ pTimeZoneOffset->reset();
+ }
+ }
rbDateTime = false;
}
}
@@ -2447,7 +2454,7 @@ bool Converter::convertAny(OUStringBuffer& rsValue,
aTempValue.Seconds = 0;
aTempValue.Minutes = 0;
aTempValue.Hours = 0;
- ::sax::Converter::convertDateTime(rsValue, aTempValue);
+ ::sax::Converter::convertDateTime(rsValue, aTempValue, 0);
}
else
if (rValue >>= aTime)
@@ -2469,7 +2476,7 @@ bool Converter::convertAny(OUStringBuffer& rsValue,
{
rsType.appendAscii("date");
bConverted = true;
- ::sax::Converter::convertDateTime(rsValue, aDateTime);
+ ::sax::Converter::convertDateTime(rsValue, aDateTime, 0);
}
}
break;
diff --git a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
index 104707b..c856447 100644
--- a/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
+++ b/sc/source/filter/xml/XMLCalculationSettingsContext.cxx
@@ -171,7 +171,7 @@ ScXMLNullDateContext::ScXMLNullDateContext( ScXMLImport& rImport,
if (nPrefix == XML_NAMESPACE_TABLE && IsXMLToken(aLocalName, XML_DATE_VALUE))
{
util::DateTime aDateTime;
- ::sax::Converter::convertDateTime(aDateTime, sValue);
+ ::sax::Converter::parseDateTime(aDateTime, 0, sValue);
util::Date aDate;
aDate.Day = aDateTime.Day;
aDate.Month = aDateTime.Month;
diff --git a/sc/source/filter/xml/XMLConverter.cxx b/sc/source/filter/xml/XMLConverter.cxx
index da12592..4d8b7db 100644
--- a/sc/source/filter/xml/XMLConverter.cxx
+++ b/sc/source/filter/xml/XMLConverter.cxx
@@ -341,7 +341,7 @@ void ScXMLConverter::ConvertDateTimeToString(const DateTime& aDateTime, OUString
{
util::DateTime aAPIDateTime;
ConvertCoreToAPIDateTime(aDateTime, aAPIDateTime);
- ::sax::Converter::convertDateTime(sDate, aAPIDateTime);
+ ::sax::Converter::convertDateTime(sDate, aAPIDateTime, 0);
}
void ScXMLConverter::ConvertCoreToAPIDateTime(const DateTime& aDateTime, util::DateTime& rDateTime)
diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
index 625e66b..b66b081 100644
--- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx
+++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
@@ -681,7 +681,7 @@ SvXMLImportContext *ScXMLChangeInfoContext::CreateChildContext( sal_uInt16 nPref
void ScXMLChangeInfoContext::EndElement()
{
aInfo.sUser = sAuthorBuffer.makeStringAndClear();
- ::sax::Converter::convertDateTime(aInfo.aDateTime,
+ ::sax::Converter::parseDateTime(aInfo.aDateTime, 0,
sDateTimeBuffer.makeStringAndClear());
aInfo.sComment = sCommentBuffer.makeStringAndClear();
pChangeTrackingImportHelper->SetActionInfo(aInfo);
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index c741c39..33c968d 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -41,7 +41,8 @@
#include <com/sun/star/beans/XPropertyContainer.hpp>
#include <com/sun/star/util/DateTime.hpp>
#include <com/sun/star/util/Date.hpp>
-#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTimeWithTimezone.hpp>
+#include <com/sun/star/util/DateWithTimezone.hpp>
#include <com/sun/star/util/Duration.hpp>
#include <com/sun/star/document/XDocumentProperties.hpp>
@@ -1715,6 +1716,8 @@ void CustomPropertiesWindow::AddLine( const OUString& sName, Any& rAny )
OUString sTmpValue;
util::DateTime aTmpDateTime;
util::Date aTmpDate;
+ util::DateTimeWithTimezone aTmpDateTimeTZ;
+ util::DateWithTimezone aTmpDateTZ;
util::Duration aTmpDuration;
SvtSysLocale aSysLocale;
const LocaleDataWrapper& rLocaleWrapper = aSysLocale.GetLocaleData();
@@ -1741,22 +1744,38 @@ void CustomPropertiesWindow::AddLine( const OUString& sName, Any& rAny )
}
else if ( rAny >>= aTmpDate )
{
- nType = CUSTOM_TYPE_DATE;
pNewLine->m_aDateField.SetDate( Date( aTmpDate.Day, aTmpDate.Month, aTmpDate.Year ) );
-
- }
- else if ( rAny >>= aTmpDuration )
- {
- nType = CUSTOM_TYPE_DURATION;
- pNewLine->m_aDurationField.SetDuration( aTmpDuration );
+ nType = CUSTOM_TYPE_DATE;
}
else if ( rAny >>= aTmpDateTime )
{
pNewLine->m_aDateField.SetDate( Date( aTmpDateTime.Day, aTmpDateTime.Month, aTmpDateTime.Year ) );
pNewLine->m_aTimeField.SetTime( Time( aTmpDateTime.Hours, aTmpDateTime.Minutes, aTmpDateTime.Seconds, aTmpDateTime.NanoSeconds ) );
-
+ pNewLine->m_aTimeField.m_isUTC = aTmpDateTime.IsUTC;
nType = CUSTOM_TYPE_DATETIME;
}
+ else if ( rAny >>= aTmpDateTZ )
+ {
+ pNewLine->m_aDateField.SetDate( Date( aTmpDateTZ.DateInTZ.Day,
+ aTmpDateTZ.DateInTZ.Month, aTmpDateTZ.DateInTZ.Year ) );
+ pNewLine->m_aDateField.m_TZ = aTmpDateTZ.Timezone;
+ nType = CUSTOM_TYPE_DATE;
+ }
+ else if ( rAny >>= aTmpDateTimeTZ )
+ {
+ util::DateTime const& rDT(aTmpDateTimeTZ.DateTimeInTZ);
+ pNewLine->m_aDateField.SetDate( Date( rDT.Day, rDT.Month, rDT.Year ) );
+ pNewLine->m_aTimeField.SetTime( Time( rDT.Hours, rDT.Minutes,
+ rDT.Seconds, rDT.NanoSeconds ) );
+ pNewLine->m_aTimeField.m_isUTC = rDT.IsUTC;
+ pNewLine->m_aDateField.m_TZ = aTmpDateTimeTZ.Timezone;
+ nType = CUSTOM_TYPE_DATETIME;
+ }
+ else if ( rAny >>= aTmpDuration )
+ {
+ nType = CUSTOM_TYPE_DURATION;
+ pNewLine->m_aDurationField.SetDuration( aTmpDuration );
+ }
if ( nType != CUSTOM_TYPE_UNKNOWN )
{
@@ -1870,20 +1889,35 @@ Sequence< beans::PropertyValue > CustomPropertiesWindow::GetCustomProperties() c
util::DateTime const aDateTime(aTmpTime.GetNanoSec(),
aTmpTime.GetSec(), aTmpTime.GetMin(), aTmpTime.GetHour(),
aTmpDate.GetDay(), aTmpDate.GetMonth(), aTmpDate.GetYear(),
- false);
- aPropertiesSeq[i].Value <<= aDateTime;
- }
- else if ( CUSTOM_TYPE_DURATION == nType )
- {
- aPropertiesSeq[i].Value <<= pLine->m_aDurationField.GetDuration();
+ pLine->m_aTimeField.m_isUTC);
+ if (pLine->m_aDateField.m_TZ.is_initialized())
+ {
+ aPropertiesSeq[i].Value <<= util::DateTimeWithTimezone(
+ aDateTime, pLine->m_aDateField.m_TZ.get());
+ }
+ else
+ {
+ aPropertiesSeq[i].Value <<= aDateTime;
+ }
}
else if ( CUSTOM_TYPE_DATE == nType )
{
Date aTmpDate = pLine->m_aDateField.GetDate();
util::Date const aDate(aTmpDate.GetDay(), aTmpDate.GetMonth(),
aTmpDate.GetYear());
- aPropertiesSeq[i].Value <<= aDate;
-
+ if (pLine->m_aDateField.m_TZ.is_initialized())
+ {
+ aPropertiesSeq[i].Value <<= util::DateWithTimezone(
+ aDate, pLine->m_aDateField.m_TZ.get());
+ }
+ else
+ {
+ aPropertiesSeq[i].Value <<= aDate;
+ }
+ }
+ else if ( CUSTOM_TYPE_DURATION == nType )
+ {
+ aPropertiesSeq[i].Value <<= pLine->m_aDurationField.GetDuration();
}
else
{
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx
index 520db84..f1fe123 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -54,6 +54,8 @@
#include "com/sun/star/xml/xpath/XPathAPI.hpp"
#include "com/sun/star/util/Date.hpp"
#include "com/sun/star/util/Time.hpp"
+#include "com/sun/star/util/DateWithTimezone.hpp"
+#include "com/sun/star/util/DateTimeWithTimezone.hpp"
#include "com/sun/star/util/Duration.hpp"
#include "SfxDocumentMetaData.hxx"
@@ -530,10 +532,11 @@ OUString SAL_CALL getNameSpace(const char* i_qname) throw ()
bool SAL_CALL
textToDateOrDateTime(css::util::Date & io_rd, css::util::DateTime & io_rdt,
- bool & o_rIsDateTime, OUString i_text) throw ()
+ bool & o_rIsDateTime, boost::optional<sal_Int16> & o_rTimeZone,
+ OUString i_text) throw ()
{
- if (::sax::Converter::convertDateOrDateTime(
- io_rd, io_rdt, o_rIsDateTime, i_text)) {
+ if (::sax::Converter::parseDateOrDateTime(
+ &io_rd, io_rdt, o_rIsDateTime, &o_rTimeZone, i_text)) {
return true;
} else {
DBG_WARNING1("SfxDocumentMetaData: invalid date: %s",
@@ -546,7 +549,7 @@ textToDateOrDateTime(css::util::Date & io_rd, css::util::DateTime & io_rdt,
bool SAL_CALL
textToDateTime(css::util::DateTime & io_rdt, OUString i_text) throw ()
{
- if (::sax::Converter::convertDateTime(io_rdt, i_text)) {
+ if (::sax::Converter::parseDateTime(io_rdt, 0, i_text)) {
return true;
} else {
DBG_WARNING1("SfxDocumentMetaData: invalid date: %s",
@@ -567,11 +570,12 @@ textToDateTimeDefault(OUString i_text) throw ()
// convert date to string
OUString SAL_CALL
-dateToText(css::util::Date const& i_rd) throw ()
+dateToText(css::util::Date const& i_rd,
+ sal_Int16 const*const pTimeZone = 0) throw ()
{
if (isValidDate(i_rd)) {
OUStringBuffer buf;
- ::sax::Converter::convertDate(buf, i_rd);
+ ::sax::Converter::convertDate(buf, i_rd, pTimeZone);
return buf.makeStringAndClear();
} else {
return OUString();
@@ -581,11 +585,12 @@ dateToText(css::util::Date const& i_rd) throw ()
// convert date/time to string
OUString SAL_CALL
-dateTimeToText(css::util::DateTime const& i_rdt) throw ()
+dateTimeToText(css::util::DateTime const& i_rdt,
+ sal_Int16 const*const pTimeZone = 0) throw ()
{
if (isValidDateTime(i_rdt)) {
OUStringBuffer buf;
- ::sax::Converter::convertDateTime(buf, i_rdt, true);
+ ::sax::Converter::convertDateTime(buf, i_rdt, pTimeZone, true);
return buf.makeStringAndClear();
} else {
return OUString();
@@ -960,6 +965,18 @@ propsToStrings(css::uno::Reference<css::beans::XPropertySet> const & i_xPropSet)
values.push_back(dateToText(d));
as.push_back(std::make_pair(vt,
OUString("date")));
+ } else if (type == ::cppu::UnoType<css::util::DateTimeWithTimezone>::get()) {
+ css::util::DateTimeWithTimezone dttz;
+ any >>= dttz;
+ values.push_back(dateTimeToText(dttz.DateTimeInTZ, &dttz.Timezone));
+ as.push_back(std::make_pair(vt,
+ OUString("date")));
+ } else if (type == ::cppu::UnoType<css::util::DateWithTimezone>::get()) {
+ css::util::DateWithTimezone dtz;
+ any >>= dtz;
+ values.push_back(dateToText(dtz.DateInTZ, &dtz.Timezone));
+ as.push_back(std::make_pair(vt,
+ OUString("date")));
} else if (type == ::cppu::UnoType<css::util::Time>::get()) {
// #i97029#: replaced by Duration
// Time is supported for backward compatibility with OOo 3.x, x<=2
@@ -1293,11 +1310,21 @@ void SAL_CALL SfxDocumentMetaData::init(
bool isDateTime;
css::util::Date d;
css::util::DateTime dt;
- if (textToDateOrDateTime(d, dt, isDateTime, text)) {
+ boost::optional<sal_Int16> nTimeZone;
+ if (textToDateOrDateTime(d, dt, isDateTime, nTimeZone, text)) {
if (isDateTime) {
- any <<= dt;
+ if (nTimeZone.is_initialized()) {
+ any <<= css::util::DateTimeWithTimezone(dt,
+ nTimeZone.get());
+ } else {
+ any <<= dt;
+ }
} else {
- any <<= d;
+ if (nTimeZone.is_initialized()) {
+ any <<= css::util::DateWithTimezone(d, nTimeZone.get());
+ } else {
+ any <<= d;
+ }
}
} else {
DBG_WARNING1("SfxDocumentMetaData: invalid date: %s",
@@ -2261,19 +2288,21 @@ void SfxDocumentMetaData::createUserDefined()
// values of allowed types
if ( !m_xUserDefined.is() )
{
- css::uno::Sequence<css::uno::Type> types(11);
- types[0] = ::cppu::UnoType<bool>::get();
- types[1] = ::cppu::UnoType< OUString>::get();
- types[2] = ::cppu::UnoType<css::util::DateTime>::get();
- types[3] = ::cppu::UnoType<css::util::Date>::get();
- types[4] = ::cppu::UnoType<css::util::Duration>::get();
- types[5] = ::cppu::UnoType<float>::get();
- types[6] = ::cppu::UnoType<double>::get();
- types[7] = ::cppu::UnoType<sal_Int16>::get();
- types[8] = ::cppu::UnoType<sal_Int32>::get();
- types[9] = ::cppu::UnoType<sal_Int64>::get();
+ css::uno::Sequence<css::uno::Type> types(13);
+ types[ 0] = ::cppu::UnoType<bool>::get();
+ types[ 1] = ::cppu::UnoType< OUString>::get();
+ types[ 2] = ::cppu::UnoType<css::util::DateTime>::get();
+ types[ 3] = ::cppu::UnoType<css::util::Date>::get();
+ types[ 4] = ::cppu::UnoType<css::util::DateTimeWithTimezone>::get();
+ types[ 5] = ::cppu::UnoType<css::util::DateWithTimezone>::get();
+ types[ 6] = ::cppu::UnoType<css::util::Duration>::get();
+ types[ 7] = ::cppu::UnoType<float>::get();
+ types[ 8] = ::cppu::UnoType<double>::get();
+ types[ 9] = ::cppu::UnoType<sal_Int16>::get();
+ types[10] = ::cppu::UnoType<sal_Int32>::get();
+ types[11] = ::cppu::UnoType<sal_Int64>::get();
// Time is supported for backward compatibility with OOo 3.x, x<=2
- types[10] = ::cppu::UnoType<css::util::Time>::get();
+ types[12] = ::cppu::UnoType<css::util::Time>::get();
// #i94175#: ODF allows empty user-defined property names!
m_xUserDefined.set(
css::beans::PropertyBag::createWithTypes( m_xContext, types, sal_True/*AllowEmptyPropertyName*/, sal_False/*AutomaticAddition*/ ),
diff --git a/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx b/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx
index 33971e2..b875aa7 100644
--- a/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx
+++ b/xmloff/source/chart/SchXMLCalculationSettingsContext.cxx
@@ -53,7 +53,7 @@ SchXMLCalculationSettingsContext::SchXMLCalculationSettingsContext( SvXMLImport&
{
util::DateTime aNullDate;
const OUString sValue = xAttrList->getValueByIndex( i );
- ::sax::Converter::convertDateTime(aNullDate, sValue);
+ ::sax::Converter::parseDateTime(aNullDate, 0, sValue);
m_aNullDate <<= aNullDate;
}
}
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 5602ea6..f66f062 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -1212,7 +1212,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >&
SvXMLElementExport aSet( mrExport, XML_NAMESPACE_TABLE, XML_CALCULATION_SETTINGS, sal_True, sal_True );
{
OUStringBuffer sBuffer;
- ::sax::Converter::convertDateTime(sBuffer, aNullDate);
+ ::sax::Converter::convertDateTime(sBuffer, aNullDate, 0);
mrExport.AddAttribute( XML_NAMESPACE_TABLE,XML_DATE_VALUE,sBuffer.makeStringAndClear());
SvXMLElementExport aNull( mrExport, XML_NAMESPACE_TABLE, XML_NULL_DATE, sal_True, sal_True );
}
diff --git a/xmloff/source/core/DocumentSettingsContext.cxx b/xmloff/source/core/DocumentSettingsContext.cxx
index f0a40fe..b741d51 100644
--- a/xmloff/source/core/DocumentSettingsContext.cxx
+++ b/xmloff/source/core/DocumentSettingsContext.cxx
@@ -631,7 +631,7 @@ void XMLConfigItemContext::EndElement()
else if (IsXMLToken(msType, XML_DATETIME))
{
util::DateTime aDateTime;
- ::sax::Converter::convertDateTime(aDateTime, msValue);
+ ::sax::Converter::parseDateTime(aDateTime, 0, msValue);
mrAny <<= aDateTime;
}
else if (IsXMLToken(msType, XML_BASE64BINARY))
diff --git a/xmloff/source/core/SettingsExportHelper.cxx b/xmloff/source/core/SettingsExportHelper.cxx
index 1f0fbf0..a2ff42a 100644
--- a/xmloff/source/core/SettingsExportHelper.cxx
+++ b/xmloff/source/core/SettingsExportHelper.cxx
@@ -267,7 +267,7 @@ void XMLSettingsExportHelper::exportDateTime(const util::DateTime& aValue, const
m_rContext.AddAttribute( XML_NAME, rName );
m_rContext.AddAttribute( XML_TYPE, XML_DATETIME );
OUStringBuffer sBuffer;
- ::sax::Converter::convertDateTime(sBuffer, aValue);
+ ::sax::Converter::convertDateTime(sBuffer, aValue, 0);
m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
m_rContext.Characters( sBuffer.makeStringAndClear() );
m_rContext.EndElement( sal_False );
diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx
index 0026161..efa5ba6 100644
--- a/xmloff/source/core/xmluconv.cxx
+++ b/xmloff/source/core/xmluconv.cxx
@@ -428,7 +428,7 @@ sal_Bool SvXMLUnitConverter::convertDateTime( double& fDateTime,
const OUString& rString, const com::sun::star::util::Date& aTempNullDate)
{
com::sun::star::util::DateTime aDateTime;
- sal_Bool bSuccess = ::sax::Converter::convertDateTime(aDateTime, rString);
+ bool bSuccess = ::sax::Converter::parseDateTime(aDateTime, 0, rString);
if (bSuccess)
{
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index e2b9c29..34beb14 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -2773,7 +2773,7 @@ void SdXMLExport::exportAnnotations( const Reference<XDrawPage>& xDrawPage )
{
// date time
com::sun::star::util::DateTime aDate( xAnnotation->getDateTime() );
- ::sax::Converter::convertDateTime(sStringBuffer, aDate, true);
+ ::sax::Converter::convertDateTime(sStringBuffer, aDate, 0, true);
SvXMLElementExport aDateElem( *this, XML_NAMESPACE_DC, XML_DATE, sal_True, sal_False );
Characters(sStringBuffer.makeStringAndClear());
}
diff --git a/xmloff/source/draw/ximppage.cxx b/xmloff/source/draw/ximppage.cxx
index 3c42b2d..f56af25 100644
--- a/xmloff/source/draw/ximppage.cxx
+++ b/xmloff/source/draw/ximppage.cxx
@@ -192,7 +192,7 @@ void DrawAnnotationContext::EndElement()
mxAnnotation->setAuthor( maAuthorBuffer.makeStringAndClear() );
util::DateTime aDateTime;
- if (::sax::Converter::convertDateTime(aDateTime,
+ if (::sax::Converter::parseDateTime(aDateTime, 0,
maDateBuffer.makeStringAndClear()))
{
mxAnnotation->setDateTime(aDateTime);
diff --git a/xmloff/source/forms/handler/vcl_date_handler.cxx b/xmloff/source/forms/handler/vcl_date_handler.cxx
index b306a65..a1ac74e 100644
--- a/xmloff/source/forms/handler/vcl_date_handler.cxx
+++ b/xmloff/source/forms/handler/vcl_date_handler.cxx
@@ -66,7 +66,7 @@ namespace xmloff
aDateTime.Year = aVCLDate.GetYear();
OUStringBuffer aBuffer;
- ::sax::Converter::convertDateTime( aBuffer, aDateTime, false );
+ ::sax::Converter::convertDateTime( aBuffer, aDateTime, 0, false );
return aBuffer.makeStringAndClear();
}
@@ -76,7 +76,7 @@ namespace xmloff
sal_Int32 nVCLDate(0);
DateTime aDateTime;
- if (::sax::Converter::convertDateTime( aDateTime, i_attributeValue ))
+ if (::sax::Converter::parseDateTime( aDateTime, 0, i_attributeValue ))
{
::Date aVCLDate( aDateTime.Day, aDateTime.Month, aDateTime.Year );
nVCLDate = aVCLDate.GetDate();
diff --git a/xmloff/source/text/XMLChangedRegionImportContext.cxx b/xmloff/source/text/XMLChangedRegionImportContext.cxx
index bb4e451..541554a 100644
--- a/xmloff/source/text/XMLChangedRegionImportContext.cxx
+++ b/xmloff/source/text/XMLChangedRegionImportContext.cxx
@@ -162,7 +162,7 @@ void XMLChangedRegionImportContext::SetChangeInfo(
const OUString& rDate)
{
util::DateTime aDateTime;
- if (::sax::Converter::convertDateTime(aDateTime, rDate))
+ if (::sax::Converter::parseDateTime(aDateTime, 0, rDate))
{
GetImport().GetTextImport()->RedlineAdd(
rType, sID, rAuthor, rComment, aDateTime, bMergeLastPara);
diff --git a/xmloff/source/text/XMLRedlineExport.cxx b/xmloff/source/text/XMLRedlineExport.cxx
index 6cc8f2d..7508dcc 100644
--- a/xmloff/source/text/XMLRedlineExport.cxx
+++ b/xmloff/source/text/XMLRedlineExport.cxx
@@ -484,7 +484,7 @@ void XMLRedlineExport::ExportChangeInfo(
aAny >>= aDateTime;
{
OUStringBuffer sBuf;
- ::sax::Converter::convertDateTime(sBuf, aDateTime);
+ ::sax::Converter::convertDateTime(sBuf, aDateTime, 0);
SvXMLElementExport aDateElem( rExport, XML_NAMESPACE_DC,
XML_DATE, sal_True,
sal_False );
@@ -525,7 +525,7 @@ void XMLRedlineExport::ExportChangeInfo(
util::DateTime aDateTime;
rVal.Value >>= aDateTime;
OUStringBuffer sBuf;
- ::sax::Converter::convertDateTime(sBuf, aDateTime);
+ ::sax::Converter::convertDateTime(sBuf, aDateTime, 0);
rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_CHG_DATE_TIME,
sBuf.makeStringAndClear());
}
diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index b034cba..2adbfaf 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -1745,7 +1745,7 @@ void XMLTextFieldExport::ExportFieldHelper(
util::DateTime aDate( GetDateTimeProperty(sPropertyDateTimeValue, rPropSet) );
{
OUStringBuffer aBuffer;
- ::sax::Converter::convertDateTime(aBuffer, aDate, true);
+ ::sax::Converter::convertDateTime(aBuffer, aDate, 0, true);
SvXMLElementExport aDateElem( GetExport(), XML_NAMESPACE_DC,
XML_DATE, sal_True,
sal_False );
@@ -2652,7 +2652,7 @@ void XMLTextFieldExport::ProcessDateTime(enum XMLTokenEnum eName,
}
// date/time value
- ::sax::Converter::convertDateTime(aBuffer, aDateTime);
+ ::sax::Converter::convertDateTime(aBuffer, aDateTime, 0);
// output attribute
ProcessString(eName, aBuffer.makeStringAndClear(), sal_True, nPrefix);
diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx
index c4af925..d793ab6 100644
--- a/xmloff/source/text/txtfldi.cxx
+++ b/xmloff/source/text/txtfldi.cxx
@@ -1114,7 +1114,7 @@ void XMLTimeFieldImportContext::ProcessAttribute(
bTimeOK = sal_True;
}
- if (::sax::Converter::convertDateTime(aDateTimeValue, sAttrValue))
+ if (::sax::Converter::parseDateTime(aDateTimeValue, 0, sAttrValue))
{
bTimeOK = sal_True;
}
@@ -1255,7 +1255,7 @@ void XMLDateFieldImportContext::ProcessAttribute(
bTimeOK = sal_True;
}
- if (::sax::Converter::convertDateTime(aDateTimeValue, sAttrValue))
+ if (::sax::Converter::parseDateTime(aDateTimeValue, 0, sAttrValue))
{
bTimeOK = sal_True;
}
@@ -3820,7 +3820,7 @@ void XMLAnnotationImportContext::PrepareField(
xPropertySet->setPropertyValue(sPropertyInitials, makeAny(sInitials));
util::DateTime aDateTime;
- if (::sax::Converter::convertDateTime(aDateTime,
+ if (::sax::Converter::parseDateTime(aDateTime, 0,
aDateBuffer.makeStringAndClear()))
{
/*
diff --git a/xmloff/source/xforms/SchemaRestrictionContext.cxx b/xmloff/source/xforms/SchemaRestrictionContext.cxx
index 34b64ae..ad3b9a4 100644
--- a/xmloff/source/xforms/SchemaRestrictionContext.cxx
+++ b/xmloff/source/xforms/SchemaRestrictionContext.cxx
@@ -201,7 +201,7 @@ Any xforms_date( const OUString& rValue )
Any xforms_dateTime( const OUString& rValue )
{
util::DateTime aDateTime;
- bool const bSuccess = ::sax::Converter::convertDateTime(aDateTime, rValue);
+ bool const bSuccess = ::sax::Converter::parseDateTime(aDateTime, 0, rValue);
return bSuccess ? makeAny( aDateTime ) : Any();
}
diff --git a/xmloff/source/xforms/xformsexport.cxx b/xmloff/source/xforms/xformsexport.cxx
index 9f8ccab..424baf4 100644
--- a/xmloff/source/xforms/xformsexport.cxx
+++ b/xmloff/source/xforms/xformsexport.cxx
@@ -693,7 +693,7 @@ void xforms_formatTime( OUStringBuffer& aBuffer, const com::sun::star::util::Tim
void xforms_formatDateTime( OUStringBuffer& aBuffer, const util::DateTime& aDateTime )
{
- ::sax::Converter::convertDateTime( aBuffer, aDateTime );
+ ::sax::Converter::convertDateTime(aBuffer, aDateTime, 0);
}
OUString xforms_whitespace( const Any& rAny )
commit 604aae1fd240254fe851d93dc35b5408bd13296c
Author: Michael Stahl <mstahl at redhat.com>
Date: Mon Jul 15 14:52:03 2013 +0200
i#108348: fix TimeZone -> Timezone in struct names
Change-Id: Id3b804b5de9328f0e5faf3410ca24295792c6f97
diff --git a/offapi/com/sun/star/util/DateTimeWithTimezone.idl b/offapi/com/sun/star/util/DateTimeWithTimezone.idl
index 6f40e6b..398ed5e 100644
--- a/offapi/com/sun/star/util/DateTimeWithTimezone.idl
+++ b/offapi/com/sun/star/util/DateTimeWithTimezone.idl
@@ -19,7 +19,7 @@ module com { module sun { module star { module util {
@since LibreOffice 4.1
*/
-struct DateTimeWithTimeZone
+struct DateTimeWithTimezone
{
/** the date and time (in TimeZone)
*/
diff --git a/offapi/com/sun/star/util/DateWithTimezone.idl b/offapi/com/sun/star/util/DateWithTimezone.idl
index 928a9c4..e60bcb7 100644
--- a/offapi/com/sun/star/util/DateWithTimezone.idl
+++ b/offapi/com/sun/star/util/DateWithTimezone.idl
@@ -19,7 +19,7 @@ module com { module sun { module star { module util {
@since LibreOffice 4.1
*/
-struct DateWithTimeZone
+struct DateWithTimezone
{
/** the date.
@note XMLSchema-2 defines this as a 24 hour interval.
diff --git a/offapi/com/sun/star/util/TimeWithTimezone.idl b/offapi/com/sun/star/util/TimeWithTimezone.idl
index 042ff83..70442ec 100644
--- a/offapi/com/sun/star/util/TimeWithTimezone.idl
+++ b/offapi/com/sun/star/util/TimeWithTimezone.idl
@@ -19,7 +19,7 @@ module com { module sun { module star { module util {
@since LibreOffice 4.1
*/
-struct TimeWithTimeZone
+struct TimeWithTimezone
{
/** the time (in TimeZone)
*/
More information about the Libreoffice-commits
mailing list