summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2013-07-28 16:08:26 +0200
committerStephan Bergmann <sbergman@redhat.com>2013-08-04 11:02:56 +0200
commit43ea97e1f9cecd6c7cba8db35ce1307c858c6857 (patch)
tree5d4f81ad7e3a9e9e3af563ffe2df1661cb643bee /xmloff
parent9d07f380bb0d5053571a9f3866b0415fe8339c5b (diff)
fdo#67235 adapt form control code to time nanosecond API change
squash of steps 1, 2 and 3 in master Change-Id: If68ecf0691919d71d06d7b97d46db115013f9805 Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/forms/handler/vcl_date_handler.cxx25
-rw-r--r--xmloff/source/forms/handler/vcl_time_handler.cxx32
2 files changed, 32 insertions, 25 deletions
diff --git a/xmloff/source/forms/handler/vcl_date_handler.cxx b/xmloff/source/forms/handler/vcl_date_handler.cxx
index b306a65ce04b..452dc5df2793 100644
--- a/xmloff/source/forms/handler/vcl_date_handler.cxx
+++ b/xmloff/source/forms/handler/vcl_date_handler.cxx
@@ -23,6 +23,7 @@
#include <rtl/ustrbuf.hxx>
#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/util/Date.hpp>
#include <sax/tools/converter.hxx>
@@ -37,6 +38,7 @@ namespace xmloff
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::makeAny;
using ::com::sun::star::util::DateTime;
+ using ::com::sun::star::util::Date;
//==================================================================================================================
//= VCLDateHandler
@@ -56,14 +58,13 @@ namespace xmloff
//------------------------------------------------------------------------------------------------------------------
OUString VCLDateHandler::getAttributeValue( const Any& i_propertyValue ) const
{
- sal_Int32 nVCLDate(0);
- OSL_VERIFY( i_propertyValue >>= nVCLDate );
- ::Date aVCLDate( nVCLDate );
+ Date aDate;
+ OSL_VERIFY( i_propertyValue >>= aDate );
DateTime aDateTime; // default-inited to 0
- aDateTime.Day = aVCLDate.GetDay();
- aDateTime.Month = aVCLDate.GetMonth();
- aDateTime.Year = aVCLDate.GetYear();
+ aDateTime.Day = aDate.Day;
+ aDateTime.Month = aDate.Month;
+ aDateTime.Year = aDate.Year;
OUStringBuffer aBuffer;
::sax::Converter::convertDateTime( aBuffer, aDateTime, false );
@@ -73,25 +74,27 @@ namespace xmloff
//------------------------------------------------------------------------------------------------------------------
bool VCLDateHandler::getPropertyValues( const OUString i_attributeValue, PropertyValues& o_propertyValues ) const
{
- sal_Int32 nVCLDate(0);
-
DateTime aDateTime;
+ Date aDate;
if (::sax::Converter::convertDateTime( aDateTime, i_attributeValue ))
{
- ::Date aVCLDate( aDateTime.Day, aDateTime.Month, aDateTime.Year );
- nVCLDate = aVCLDate.GetDate();
+ aDate.Day = aDateTime.Day;
+ aDate.Month = aDateTime.Month;
+ aDate.Year = aDateTime.Year;
}
else
{
// compatibility format, before we wrote those values in XML-schema compatible form
+ sal_Int32 nVCLDate(0);
if (!::sax::Converter::convertNumber(nVCLDate, i_attributeValue))
{
OSL_ENSURE( false, "VCLDateHandler::getPropertyValues: unknown date format (no XML-schema date, no legacy integer)!" );
return false;
}
+ aDate = ::Date(nVCLDate).GetUNODate();
}
- const Any aPropertyValue( makeAny( nVCLDate ) );
+ const Any aPropertyValue( makeAny( aDate ) );
OSL_ENSURE( o_propertyValues.size() == 1, "VCLDateHandler::getPropertyValues: date strings represent exactly one property - not more, not less!" );
for ( PropertyValues::iterator prop = o_propertyValues.begin();
diff --git a/xmloff/source/forms/handler/vcl_time_handler.cxx b/xmloff/source/forms/handler/vcl_time_handler.cxx
index c73392f75a14..bbf9698d7c49 100644
--- a/xmloff/source/forms/handler/vcl_time_handler.cxx
+++ b/xmloff/source/forms/handler/vcl_time_handler.cxx
@@ -23,6 +23,7 @@
#include <rtl/ustrbuf.hxx>
#include <com/sun/star/util/Duration.hpp>
+#include <com/sun/star/util/Time.hpp>
#include <sax/tools/converter.hxx>
@@ -37,6 +38,7 @@ namespace xmloff
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::makeAny;
using ::com::sun::star::util::Duration;
+ using ::com::sun::star::util::Time;
//==================================================================================================================
//= VCLTimeHandler
@@ -56,15 +58,14 @@ namespace xmloff
//------------------------------------------------------------------------------------------------------------------
OUString VCLTimeHandler::getAttributeValue( const Any& i_propertyValue ) const
{
- sal_Int32 nVCLTime(0);
- OSL_VERIFY( i_propertyValue >>= nVCLTime );
- ::Time aVCLTime( nVCLTime );
+ Time aTime;
+ OSL_VERIFY( i_propertyValue >>= aTime );
Duration aDuration; // default-inited to 0
- aDuration.Hours = aVCLTime.GetHour();
- aDuration.Minutes = aVCLTime.GetMin();
- aDuration.Seconds = aVCLTime.GetSec();
- aDuration.NanoSeconds = aVCLTime.GetNanoSec();
+ aDuration.Hours = aTime.Hours;
+ aDuration.Minutes = aTime.Minutes;
+ aDuration.Seconds = aTime.Seconds;
+ aDuration.NanoSeconds = aTime.NanoSeconds;
OUStringBuffer aBuffer;
::sax::Converter::convertDuration( aBuffer, aDuration );
@@ -74,26 +75,29 @@ namespace xmloff
//------------------------------------------------------------------------------------------------------------------
bool VCLTimeHandler::getPropertyValues( const OUString i_attributeValue, PropertyValues& o_propertyValues ) const
{
- sal_Int32 nVCLTime(0);
-
Duration aDuration;
+ Time aTime;
if (::sax::Converter::convertDuration( aDuration, i_attributeValue ))
{
- ::Time aVCLTime(aDuration.Hours, aDuration.Minutes,
- aDuration.Seconds, aDuration.NanoSeconds);
- nVCLTime = aVCLTime.GetTime();
+ aTime = Time(aDuration.NanoSeconds, aDuration.Seconds,
+ aDuration.Minutes, aDuration.Hours,
+ false);
}
else
{
// compatibility format, before we wrote those values in XML-schema compatible form
- if (!::sax::Converter::convertNumber(nVCLTime, i_attributeValue))
+ sal_Int64 nVCLTime(0);
+ if (!::sax::Converter::convertNumber64(nVCLTime, i_attributeValue))
{
OSL_ENSURE( false, "VCLTimeHandler::getPropertyValues: unknown time format (no XML-schema time, no legacy integer)!" );
return false;
}
+ // legacy integer was in centiseconds
+ nVCLTime *= ::Time::nanoPerCenti;
+ aTime = ::Time(nVCLTime).GetUNOTime();
}
- const Any aPropertyValue( makeAny( nVCLTime ) );
+ const Any aPropertyValue( makeAny( aTime ) );
OSL_ENSURE( o_propertyValues.size() == 1, "VCLTimeHandler::getPropertyValues: time strings represent exactly one property - not more, not less!" );
for ( PropertyValues::iterator prop = o_propertyValues.begin();