Kaydet (Commit) 7b9c61c7 authored tarafından Michael Stahl's avatar Michael Stahl

editeng: fix more 32-bit Time breakage

SfxDateTimeItem and SvxExtTimeField need to use 64-bit integer to store
Time as well.  These classes also have binary serialization
Load()/Save() methods but they are unlikely to be used in a persistent
way, just for the clipboard.

The problem is easy to reproduce in Impress: Insert->Field->Time(fixed)

(regression from 9830fd36)

Change-Id: I5946c5b94dd5a509805b6dc40461bbd910caffc4
üst 17dab5bf
...@@ -756,8 +756,8 @@ SV_IMPL_PERSIST1( SvxExtTimeField, SvxFieldData ); ...@@ -756,8 +756,8 @@ SV_IMPL_PERSIST1( SvxExtTimeField, SvxFieldData );
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
SvxExtTimeField::SvxExtTimeField() SvxExtTimeField::SvxExtTimeField()
: m_nFixTime( Time(Time::SYSTEM).GetTime() )
{ {
nFixTime = Time( Time::SYSTEM ).GetTime();
eType = SVXTIMETYPE_VAR; eType = SVXTIMETYPE_VAR;
eFormat = SVXTIMEFORMAT_STANDARD; eFormat = SVXTIMEFORMAT_STANDARD;
} }
...@@ -765,8 +765,8 @@ SvxExtTimeField::SvxExtTimeField() ...@@ -765,8 +765,8 @@ SvxExtTimeField::SvxExtTimeField()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
SvxExtTimeField::SvxExtTimeField( const Time& rTime, SvxTimeType eT, SvxTimeFormat eF ) SvxExtTimeField::SvxExtTimeField( const Time& rTime, SvxTimeType eT, SvxTimeFormat eF )
: m_nFixTime( rTime.GetTime() )
{ {
nFixTime = rTime.GetTime();
eType = eT; eType = eT;
eFormat = eF; eFormat = eF;
} }
...@@ -786,7 +786,7 @@ int SvxExtTimeField::operator==( const SvxFieldData& rOther ) const ...@@ -786,7 +786,7 @@ int SvxExtTimeField::operator==( const SvxFieldData& rOther ) const
return sal_False; return sal_False;
const SvxExtTimeField& rOtherFld = (const SvxExtTimeField&) rOther; const SvxExtTimeField& rOtherFld = (const SvxExtTimeField&) rOther;
return ( ( nFixTime == rOtherFld.nFixTime ) && return ((m_nFixTime == rOtherFld.m_nFixTime) &&
( eType == rOtherFld.eType ) && ( eType == rOtherFld.eType ) &&
( eFormat == rOtherFld.eFormat ) ); ( eFormat == rOtherFld.eFormat ) );
} }
...@@ -797,7 +797,7 @@ void SvxExtTimeField::Load( SvPersistStream & rStm ) ...@@ -797,7 +797,7 @@ void SvxExtTimeField::Load( SvPersistStream & rStm )
{ {
sal_uInt16 nType, nFormat; sal_uInt16 nType, nFormat;
rStm >> nFixTime; rStm.ReadInt64(m_nFixTime);
rStm >> nType; rStm >> nType;
rStm >> nFormat; rStm >> nFormat;
...@@ -809,7 +809,7 @@ void SvxExtTimeField::Load( SvPersistStream & rStm ) ...@@ -809,7 +809,7 @@ void SvxExtTimeField::Load( SvPersistStream & rStm )
void SvxExtTimeField::Save( SvPersistStream & rStm ) void SvxExtTimeField::Save( SvPersistStream & rStm )
{ {
rStm << nFixTime; rStm.WriteInt64(m_nFixTime);
rStm << (sal_uInt16) eType; rStm << (sal_uInt16) eType;
rStm << (sal_uInt16) eFormat; rStm << (sal_uInt16) eFormat;
} }
...@@ -820,7 +820,7 @@ OUString SvxExtTimeField::GetFormatted( SvNumberFormatter& rFormatter, LanguageT ...@@ -820,7 +820,7 @@ OUString SvxExtTimeField::GetFormatted( SvNumberFormatter& rFormatter, LanguageT
{ {
Time aTime( Time::EMPTY ); Time aTime( Time::EMPTY );
if ( eType == SVXTIMETYPE_FIX ) if ( eType == SVXTIMETYPE_FIX )
aTime.SetTime( nFixTime ); aTime.SetTime(m_nFixTime);
else else
aTime = Time( Time::SYSTEM ); // current time aTime = Time( Time::SYSTEM ); // current time
return GetFormatted( aTime, eFormat, rFormatter, eLang ); return GetFormatted( aTime, eFormat, rFormatter, eLang );
......
...@@ -196,7 +196,7 @@ inline Date setDate( util::DateTime& rDate ) ...@@ -196,7 +196,7 @@ inline Date setDate( util::DateTime& rDate )
return Date( rDate.Day, rDate.Month, rDate.Year ); return Date( rDate.Day, rDate.Month, rDate.Year );
} }
static util::DateTime getTime( long nTime ) static util::DateTime getTime(sal_Int64 const nTime)
{ {
util::DateTime aTime; util::DateTime aTime;
memset( &aTime, 0, sizeof( util::DateTime ) ); memset( &aTime, 0, sizeof( util::DateTime ) );
......
...@@ -257,7 +257,7 @@ enum SvxTimeFormat { SVXTIMEFORMAT_APPDEFAULT = 0, // Set as in App ...@@ -257,7 +257,7 @@ enum SvxTimeFormat { SVXTIMEFORMAT_APPDEFAULT = 0, // Set as in App
class EDITENG_DLLPUBLIC SvxExtTimeField : public SvxFieldData class EDITENG_DLLPUBLIC SvxExtTimeField : public SvxFieldData
{ {
private: private:
sal_uInt32 nFixTime; sal_Int64 m_nFixTime;
SvxTimeType eType; SvxTimeType eType;
SvxTimeFormat eFormat; SvxTimeFormat eFormat;
...@@ -268,8 +268,8 @@ public: ...@@ -268,8 +268,8 @@ public:
SvxTimeType eType = SVXTIMETYPE_VAR, SvxTimeType eType = SVXTIMETYPE_VAR,
SvxTimeFormat eFormat = SVXTIMEFORMAT_STANDARD ); SvxTimeFormat eFormat = SVXTIMEFORMAT_STANDARD );
sal_uInt32 GetFixTime() const { return nFixTime; } sal_Int64 GetFixTime() const { return m_nFixTime; }
void SetFixTime( const Time& rTime ) { nFixTime = rTime.GetTime(); } void SetFixTime( const Time& rTime ) { m_nFixTime = rTime.GetTime(); }
SvxTimeType GetType() const { return eType; } SvxTimeType GetType() const { return eType; }
void SetType( SvxTimeType eTp ) { eType = eTp; } void SetType( SvxTimeType eTp ) { eType = eTp; }
......
...@@ -90,9 +90,9 @@ SfxPoolItem* SfxDateTimeItem::Create( SvStream& rStream, sal_uInt16 ) const ...@@ -90,9 +90,9 @@ SfxPoolItem* SfxDateTimeItem::Create( SvStream& rStream, sal_uInt16 ) const
{ {
DBG_CHKTHIS(SfxDateTimeItem, 0); DBG_CHKTHIS(SfxDateTimeItem, 0);
sal_uInt32 nDate = 0; sal_uInt32 nDate = 0;
sal_Int32 nTime = 0; sal_Int64 nTime = 0;
rStream >> nDate; rStream >> nDate;
rStream >> nTime; rStream.ReadInt64(nTime);
DateTime aDT(nDate, nTime); DateTime aDT(nDate, nTime);
return new SfxDateTimeItem( Which(), aDT ); return new SfxDateTimeItem( Which(), aDT );
} }
...@@ -103,7 +103,7 @@ SvStream& SfxDateTimeItem::Store( SvStream& rStream, sal_uInt16 ) const ...@@ -103,7 +103,7 @@ SvStream& SfxDateTimeItem::Store( SvStream& rStream, sal_uInt16 ) const
{ {
DBG_CHKTHIS(SfxDateTimeItem, 0); DBG_CHKTHIS(SfxDateTimeItem, 0);
rStream << aDateTime.GetDate(); rStream << aDateTime.GetDate();
rStream << static_cast<sal_Int32>(aDateTime.GetTime()); rStream.WriteInt64(aDateTime.GetTime());
return rStream; return rStream;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment