sc: ScHeaderFieldData always stores a datetime

It does not change only the date part nor the time part
separately, thus holding single DateTime is sufficient.

Change-Id: Ic619608ce7a961287c299698b9a004cbf7038702
Reviewed-on: https://gerrit.libreoffice.org/54058
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
This commit is contained in:
Takeshi Abe
2018-06-11 12:35:49 +02:00
committed by Eike Rathke
parent 3f8fdfced0
commit 9804cc4eff
6 changed files with 13 additions and 23 deletions
+2 -4
View File
@@ -25,8 +25,7 @@
#include "types.hxx"
#include <editeng/editeng.hxx>
#include <svx/pageitem.hxx>
#include <tools/date.hxx>
#include <tools/time.hxx>
#include <tools/datetime.hxx>
#include <tools/gen.hxx>
#include <tools/fract.hxx>
#include <vcl/outdev.hxx>
@@ -190,8 +189,7 @@ struct ScHeaderFieldData
OUString aLongDocName; // path and file name
OUString aShortDocName; // pure file name
OUString aTabName;
Date aDate;
tools::Time aTime;
DateTime aDateTime;
long nPageNo;
long nTotalPages;
SvxNumType eNumType;
+3 -5
View File
@@ -783,9 +783,7 @@ static OUString lcl_GetNumStr(sal_Int32 nNo, SvxNumType eType)
}
ScHeaderFieldData::ScHeaderFieldData()
:
aDate( Date::EMPTY ),
aTime( tools::Time::EMPTY )
: aDateTime ( DateTime::EMPTY )
{
nPageNo = nTotalPages = 0;
eNumType = SVX_NUM_ARABIC;
@@ -817,7 +815,7 @@ OUString ScHeaderEditEngine::CalcFieldValue( const SvxFieldItem& rField,
case text::textfield::Type::EXTENDED_TIME:
case text::textfield::Type::TIME:
// For now, time field in the header / footer is always dynamic.
aRet = ScGlobal::pLocaleData->getTime(aData.aTime);
aRet = ScGlobal::pLocaleData->getTime(aData.aDateTime);
break;
case text::textfield::Type::DOCINFO_TITLE:
aRet = aData.aTitle;
@@ -838,7 +836,7 @@ OUString ScHeaderEditEngine::CalcFieldValue( const SvxFieldItem& rField,
aRet = aData.aTabName;
break;
case text::textfield::Type::DATE:
aRet = ScGlobal::pLocaleData->getDate(aData.aDate);
aRet = ScGlobal::pLocaleData->getDate(aData.aDateTime);
break;
default:
aRet = "?";
+1 -2
View File
@@ -47,8 +47,7 @@ private:
long nTabPage; // Page of sheet
long nTabStart; // First (real) page of the sheet
long nDisplayStart; // same as above, relative to the start of counting
Date aDate;
tools::Time aTime;
DateTime aDateTime;
long nTotalPages;
Size aPageSize; // for GetOptimalZoom
ScPrintState aState;
+1 -1
View File
@@ -303,7 +303,7 @@ public:
void SetOffset( const Point& rOfs );
void SetManualZoom( sal_uInt16 nNewZoom );
void SetDateTime( const Date& rDate, const tools::Time& rTime );
void SetDateTime( const DateTime& );
void SetClearFlag( bool bFlag );
void SetUseStyleColor( bool bFlag );
+3 -7
View File
@@ -96,8 +96,7 @@ ScPreview::ScPreview( vcl::Window* pParent, ScDocShell* pDocSh, ScPreviewShell*
nTabPage( 0 ),
nTabStart( 0 ),
nDisplayStart( 0 ),
aDate( Date::SYSTEM ),
aTime( tools::Time::SYSTEM ),
aDateTime( DateTime::SYSTEM ),
nTotalPages( 0 ),
pLocationData( nullptr ),
pDrawView( nullptr ),
@@ -401,7 +400,7 @@ void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
pPrintFunc->SetOffset(aOffset);
pPrintFunc->SetManualZoom(nZoom);
pPrintFunc->SetDateTime(aDate,aTime);
pPrintFunc->SetDateTime(aDateTime);
pPrintFunc->SetClearFlag(true);
pPrintFunc->SetUseStyleColor( pScMod->GetAccessOptions().GetIsForPagePreviews() );
@@ -701,10 +700,7 @@ const ScPreviewLocationData& ScPreview::GetLocationData()
void ScPreview::DataChanged(bool bNewTime)
{
if (bNewTime)
{
aDate = Date( Date::SYSTEM );
aTime = tools::Time( tools::Time::SYSTEM );
}
aDateTime = DateTime( DateTime::SYSTEM );
bValid = false;
InvalidateLocationData( SfxHintId::ScDataChanged );
+3 -4
View File
@@ -1075,7 +1075,7 @@ void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
else
aFieldData.nTotalPages = nTotalPages;
SetDateTime( Date( Date::SYSTEM ), tools::Time( tools::Time::SYSTEM ) );
SetDateTime( DateTime( DateTime::SYSTEM ) );
if( pDocShell->getDocProperties()->getTitle().getLength() != 0 )
aFieldData.aTitle = pDocShell->getDocProperties()->getTitle();
@@ -1111,10 +1111,9 @@ void ScPrintFunc::GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr )
rDocFtr = aFtr.nHeight;
}
void ScPrintFunc::SetDateTime( const Date& rDate, const tools::Time& rTime )
void ScPrintFunc::SetDateTime( const DateTime& rDateTime )
{
aFieldData.aDate = rDate;
aFieldData.aTime = rTime;
aFieldData.aDateTime = rDateTime;
}
static void lcl_DrawGraphic( const Graphic &rGraphic, vcl::RenderContext *pOut,