Change nonsense non-const Date* GetNullDate() to const Date&
* first, a non-const Date* may leave the impression that one could change the NullDate through the pointer, which is only partly successful; luckily no one did that * second, there is always a NullDate so checking for nullptr is superfluous * third, the pointer was dereferenced (maybe after a check) everywhere to obtain the NullDate, luckily.. Change-Id: I3c3a788ba0336596ac6bde4c96e77a0cdb7a4a95
This commit is contained in:
parent
71c3113e9d
commit
038063a352
@ -79,9 +79,7 @@ Date NumberFormatterWrapper::getNullDate() const
|
||||
}
|
||||
else if( m_pNumberFormatter )
|
||||
{
|
||||
Date* pDate = m_pNumberFormatter->GetNullDate();
|
||||
if( pDate )
|
||||
aRet = *pDate;
|
||||
aRet = m_pNumberFormatter->GetNullDate();
|
||||
}
|
||||
return aRet;
|
||||
}
|
||||
@ -101,13 +99,10 @@ OUString NumberFormatterWrapper::getFormattedString( sal_Int32 nNumberFormatKey,
|
||||
sal_uInt16 nDay = 30,nMonth = 12;
|
||||
if ( m_aNullDate.hasValue() )
|
||||
{
|
||||
Date* pDate = m_pNumberFormatter->GetNullDate();
|
||||
if ( pDate )
|
||||
{
|
||||
nYear = pDate->GetYear();
|
||||
nMonth = pDate->GetMonth();
|
||||
nDay = pDate->GetDay();
|
||||
} // if ( pDate )
|
||||
const Date& rDate = m_pNumberFormatter->GetNullDate();
|
||||
nYear = rDate.GetYear();
|
||||
nMonth = rDate.GetMonth();
|
||||
nDay = rDate.GetDay();
|
||||
util::Date aNewNullDate;
|
||||
m_aNullDate >>= aNewNullDate;
|
||||
m_pNumberFormatter->ChangeNullDate(aNewNullDate.Day,aNewNullDate.Month,aNewNullDate.Year);
|
||||
|
@ -145,10 +145,10 @@ void SvxOnlineUpdateTabPage::UpdateLastCheckedText()
|
||||
LanguageType eUILang = Application::GetSettings().GetUILanguageTag().getLanguageType();
|
||||
SvNumberFormatter *pNumberFormatter = new SvNumberFormatter( ::comphelper::getProcessComponentContext(), eUILang );
|
||||
Color* pColor = nullptr;
|
||||
Date* pNullDate = pNumberFormatter->GetNullDate();
|
||||
const Date& rNullDate = pNumberFormatter->GetNullDate();
|
||||
sal_uInt32 nFormat = pNumberFormatter->GetStandardFormat( css::util::NumberFormat::DATE, eUILang );
|
||||
|
||||
pNumberFormatter->GetOutputString( aDate - *pNullDate, nFormat, aDateStr, &pColor );
|
||||
pNumberFormatter->GetOutputString( aDate - rNullDate, nFormat, aDateStr, &pColor );
|
||||
|
||||
nFormat = pNumberFormatter->GetStandardFormat( css::util::NumberFormat::TIME, eUILang );
|
||||
pNumberFormatter->GetOutputString( aTime.GetTimeInDays(), nFormat, aTimeStr, &pColor );
|
||||
|
@ -479,7 +479,7 @@ OUString SvxDateField::GetFormatted( Date& aDate, SvxDateFormat eFormat, SvNumbe
|
||||
nFormatKey = rFormatter.GetStandardFormat( css::util::NumberFormat::DATE, eLang );
|
||||
}
|
||||
|
||||
double fDiffDate = aDate - *(rFormatter.GetNullDate());
|
||||
double fDiffDate = aDate - rFormatter.GetNullDate();
|
||||
OUString aStr;
|
||||
Color* pColor = nullptr;
|
||||
rFormatter.GetOutputString( fDiffDate, nFormatKey, aStr, &pColor );
|
||||
|
@ -281,7 +281,7 @@ namespace pcr
|
||||
::DateTime aDateTime( ::DateTime::EMPTY );
|
||||
::utl::typeConvert( aUNODateTime, aDateTime );
|
||||
|
||||
double nValue = aDateTime - ::DateTime( *getTypedControlWindow()->GetFormatter()->GetNullDate() );
|
||||
double nValue = aDateTime - ::DateTime( getTypedControlWindow()->GetFormatter()->GetNullDate() );
|
||||
getTypedControlWindow()->SetValue( nValue );
|
||||
}
|
||||
}
|
||||
@ -294,7 +294,7 @@ namespace pcr
|
||||
{
|
||||
double nValue = getTypedControlWindow()->GetValue();
|
||||
|
||||
::DateTime aDateTime( *getTypedControlWindow()->GetFormatter()->GetNullDate() );
|
||||
::DateTime aDateTime( getTypedControlWindow()->GetFormatter()->GetNullDate() );
|
||||
|
||||
// add the "days" part
|
||||
double nDays = floor( nValue );
|
||||
|
@ -574,7 +574,7 @@ public:
|
||||
LanguageType eLnge, SvNumberformat* pFormat );
|
||||
|
||||
/// Return the reference date
|
||||
Date* GetNullDate();
|
||||
const Date& GetNullDate();
|
||||
/// Return the standard decimal precision
|
||||
sal_uInt16 GetStandardPrec();
|
||||
/// Return whether zero suppression is switched on
|
||||
|
@ -1619,11 +1619,11 @@ bool ScCondDateFormatEntry::IsValid( const ScAddress& rPos ) const
|
||||
|
||||
const Date& rActDate = *mpCache;
|
||||
SvNumberFormatter* pFormatter = mpDoc->GetFormatTable();
|
||||
long nCurrentDate = rActDate - *(pFormatter->GetNullDate());
|
||||
long nCurrentDate = rActDate - pFormatter->GetNullDate();
|
||||
|
||||
double nVal = rCell.getValue();
|
||||
long nCellDate = (long) ::rtl::math::approxFloor(nVal);
|
||||
Date aCellDate = *(pFormatter->GetNullDate());
|
||||
Date aCellDate = pFormatter->GetNullDate();
|
||||
aCellDate += (long) ::rtl::math::approxFloor(nVal);
|
||||
|
||||
switch(meType)
|
||||
|
@ -95,7 +95,7 @@ void ScDatabaseDocUtil::PutData( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB
|
||||
SvNumberFormatter* pFormTable = pDoc->GetFormatTable();
|
||||
nFormatIndex = pFormTable->GetStandardFormat(
|
||||
css::util::NumberFormat::DATE, ScGlobal::eLnge );
|
||||
nVal = Date( aDate ) - *pFormTable->GetNullDate();
|
||||
nVal = Date( aDate ) - pFormTable->GetNullDate();
|
||||
}
|
||||
bValue = true;
|
||||
}
|
||||
@ -125,7 +125,7 @@ void ScDatabaseDocUtil::PutData( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB
|
||||
|
||||
util::DateTime aStamp = xRow->getTimestamp(nRowPos);
|
||||
nVal = ( Date( aStamp.Day, aStamp.Month, aStamp.Year ) -
|
||||
*pFormTable->GetNullDate() ) +
|
||||
pFormTable->GetNullDate() ) +
|
||||
aStamp.Hours / static_cast<double>(::tools::Time::hourPerDay) +
|
||||
aStamp.Minutes / static_cast<double>(::tools::Time::minutePerDay) +
|
||||
aStamp.Seconds / static_cast<double>(::tools::Time::secondPerDay) +
|
||||
|
@ -694,7 +694,7 @@ void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPFilteredCache::Criterio
|
||||
// grouped by dates.
|
||||
aCri.mpFilter.reset(
|
||||
new ScDPGroupDateFilter(
|
||||
aMatchValues, *pDoc->GetFormatTable()->GetNullDate(), *pNumInfo));
|
||||
aMatchValues, pDoc->GetFormatTable()->GetNullDate(), *pNumInfo));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -727,7 +727,7 @@ void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPFilteredCache::Criterio
|
||||
aCri.mnFieldIndex = nSrcDim; // use the source dimension, not the group dimension.
|
||||
aCri.mpFilter.reset(
|
||||
new ScDPGroupDateFilter(
|
||||
aMatchValues, *pDoc->GetFormatTable()->GetNullDate(), *pNumInfo));
|
||||
aMatchValues, pDoc->GetFormatTable()->GetNullDate(), *pNumInfo));
|
||||
|
||||
aNewCriteria.push_back(aCri);
|
||||
}
|
||||
|
@ -3224,7 +3224,7 @@ const ScDPCache* ScDPCollection::DBCaches::getCache(
|
||||
|
||||
::std::unique_ptr<ScDPCache> pCache(new ScDPCache(mpDoc));
|
||||
SvNumberFormatter aFormat( comphelper::getProcessComponentContext(), ScGlobal::eLnge);
|
||||
DBConnector aDB(*pCache, xRowSet, *aFormat.GetNullDate());
|
||||
DBConnector aDB(*pCache, xRowSet, aFormat.GetNullDate());
|
||||
if (!aDB.isValid())
|
||||
return nullptr;
|
||||
|
||||
@ -3327,7 +3327,7 @@ void ScDPCollection::DBCaches::updateCache(
|
||||
}
|
||||
|
||||
SvNumberFormatter aFormat( comphelper::getProcessComponentContext(), ScGlobal::eLnge);
|
||||
DBConnector aDB(rCache, xRowSet, *aFormat.GetNullDate());
|
||||
DBConnector aDB(rCache, xRowSet, aFormat.GetNullDate());
|
||||
if (!aDB.isValid())
|
||||
return;
|
||||
|
||||
|
@ -122,7 +122,7 @@ OUString ScDPUtil::getDateGroupName(
|
||||
{
|
||||
Date aDate(1, 1, SC_DP_LEAPYEAR);
|
||||
aDate += (nValue - 1); // nValue is 1-based
|
||||
Date aNullDate = *pFormatter->GetNullDate();
|
||||
Date aNullDate = pFormatter->GetNullDate();
|
||||
long nDays = aDate - aNullDate;
|
||||
|
||||
const sal_uInt32 nFormat = pFormatter->GetFormatIndex(NF_DATE_SYS_DDMMM, ScGlobal::eLnge);
|
||||
@ -334,7 +334,7 @@ sal_Int32 ScDPUtil::getDatePartValue(
|
||||
}
|
||||
else
|
||||
{
|
||||
Date aDate = *(pFormatter->GetNullDate());
|
||||
Date aDate = pFormatter->GetNullDate();
|
||||
aDate += (long)::rtl::math::approxFloor(fValue);
|
||||
|
||||
switch ( nDatePart )
|
||||
|
@ -590,7 +590,7 @@ Label_fallback_to_unambiguous:
|
||||
else
|
||||
{
|
||||
if (pFormatter)
|
||||
fValue = aDate - *(pFormatter->GetNullDate());
|
||||
fValue = aDate - pFormatter->GetNullDate();
|
||||
else
|
||||
{
|
||||
SAL_WARN("sc.core","ScGlobal::ConvertStringToValue - fixed null date");
|
||||
|
@ -267,7 +267,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
|
||||
if (nCount > 1)
|
||||
{
|
||||
double nVal;
|
||||
Date aNullDate = *pDocument->GetFormatTable()->GetNullDate();
|
||||
Date aNullDate = pDocument->GetFormatTable()->GetNullDate();
|
||||
Date aDate1 = aNullDate;
|
||||
nVal = aFirstCell.mfValue;
|
||||
aDate1 += (long)nVal;
|
||||
@ -1077,7 +1077,7 @@ void ScTable::IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillD
|
||||
const sal_uInt16 nMaxYear = 9956;
|
||||
|
||||
long nInc = (long) nStep; // upper/lower limits ?
|
||||
Date aNullDate = *pDocument->GetFormatTable()->GetNullDate();
|
||||
Date aNullDate = pDocument->GetFormatTable()->GetNullDate();
|
||||
Date aDate = aNullDate;
|
||||
aDate += (long)rVal;
|
||||
switch (eCmd)
|
||||
|
@ -94,7 +94,7 @@ double ScInterpreter::GetDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int1
|
||||
if (!bStrict)
|
||||
aDate += nDay - 1;
|
||||
if (aDate.IsValidAndGregorian())
|
||||
return (double) (aDate - *(pFormatter->GetNullDate()));
|
||||
return (double) (aDate - pFormatter->GetNullDate());
|
||||
else
|
||||
{
|
||||
SetError(FormulaError::NoValue);
|
||||
@ -106,7 +106,7 @@ void ScInterpreter::ScGetActDate()
|
||||
{
|
||||
nFuncFmtType = css::util::NumberFormat::DATE;
|
||||
Date aActDate( Date::SYSTEM );
|
||||
long nDiff = aActDate - *(pFormatter->GetNullDate());
|
||||
long nDiff = aActDate - pFormatter->GetNullDate();
|
||||
PushDouble((double) nDiff);
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ void ScInterpreter::ScGetActTime()
|
||||
{
|
||||
nFuncFmtType = css::util::NumberFormat::DATETIME;
|
||||
Date aActDate( Date::SYSTEM );
|
||||
long nDiff = aActDate - *(pFormatter->GetNullDate());
|
||||
long nDiff = aActDate - pFormatter->GetNullDate();
|
||||
tools::Time aActTime( tools::Time::SYSTEM );
|
||||
double nTime = aActTime.GetHour() / static_cast<double>(::tools::Time::hourPerDay) +
|
||||
aActTime.GetMin() / static_cast<double>(::tools::Time::minutePerDay) +
|
||||
@ -125,21 +125,21 @@ void ScInterpreter::ScGetActTime()
|
||||
|
||||
void ScInterpreter::ScGetYear()
|
||||
{
|
||||
Date aDate = *(pFormatter->GetNullDate());
|
||||
Date aDate = pFormatter->GetNullDate();
|
||||
aDate += (long) GetInt32();
|
||||
PushDouble( (double) aDate.GetYear() );
|
||||
}
|
||||
|
||||
void ScInterpreter::ScGetMonth()
|
||||
{
|
||||
Date aDate = *(pFormatter->GetNullDate());
|
||||
Date aDate = pFormatter->GetNullDate();
|
||||
aDate += (long) GetInt32();
|
||||
PushDouble( (double) aDate.GetMonth() );
|
||||
}
|
||||
|
||||
void ScInterpreter::ScGetDay()
|
||||
{
|
||||
Date aDate = *(pFormatter->GetNullDate());
|
||||
Date aDate = pFormatter->GetNullDate();
|
||||
aDate += (long) GetInt32();
|
||||
PushDouble((double) aDate.GetDay());
|
||||
}
|
||||
@ -199,7 +199,7 @@ void ScInterpreter::ScGetDayOfWeek()
|
||||
else
|
||||
nFlag = 1;
|
||||
|
||||
Date aDate = *(pFormatter->GetNullDate());
|
||||
Date aDate = pFormatter->GetNullDate();
|
||||
aDate += (long) GetInt32();
|
||||
int nVal = (int) aDate.GetDayOfWeek(); // MONDAY = 0
|
||||
switch (nFlag)
|
||||
@ -241,7 +241,7 @@ void ScInterpreter::ScWeeknumOOo()
|
||||
{
|
||||
sal_Int16 nFlag = GetInt16();
|
||||
|
||||
Date aDate = *(pFormatter->GetNullDate());
|
||||
Date aDate = pFormatter->GetNullDate();
|
||||
aDate += (long) GetInt32();
|
||||
PushInt( (int) aDate.GetWeekOfYear( nFlag == 1 ? SUNDAY : MONDAY ));
|
||||
}
|
||||
@ -258,7 +258,7 @@ void ScInterpreter::ScGetWeekOfYear()
|
||||
else
|
||||
nFlag = GetInt16();
|
||||
|
||||
Date aDate = *(pFormatter->GetNullDate());
|
||||
Date aDate = pFormatter->GetNullDate();
|
||||
aDate += (long) GetInt32();
|
||||
|
||||
sal_Int32 nMinimumNumberOfDaysInWeek;
|
||||
@ -301,7 +301,7 @@ void ScInterpreter::ScGetIsoWeekOfYear()
|
||||
{
|
||||
if ( MustHaveParamCount( GetByte(), 1 ) )
|
||||
{
|
||||
Date aDate = *(pFormatter->GetNullDate());
|
||||
Date aDate = pFormatter->GetNullDate();
|
||||
aDate += (long) GetInt32();
|
||||
PushInt( (int) aDate.GetWeekOfYear() );
|
||||
}
|
||||
@ -513,7 +513,7 @@ void ScInterpreter::ScNetWorkdays( bool bOOXML_Version )
|
||||
{
|
||||
vector<double> nSortArray;
|
||||
bool bWeekendMask[ 7 ];
|
||||
Date aNullDate = *( pFormatter->GetNullDate() );
|
||||
Date aNullDate = pFormatter->GetNullDate();
|
||||
sal_uInt32 nNullDate = Date::DateToDays( aNullDate.GetDay(), aNullDate.GetMonth(), aNullDate.GetYear() );
|
||||
FormulaError nErr;
|
||||
if ( bOOXML_Version )
|
||||
@ -574,7 +574,7 @@ void ScInterpreter::ScWorkday_MS()
|
||||
nFuncFmtType = css::util::NumberFormat::DATE;
|
||||
vector<double> nSortArray;
|
||||
bool bWeekendMask[ 7 ];
|
||||
Date aNullDate = *( pFormatter->GetNullDate() );
|
||||
Date aNullDate = pFormatter->GetNullDate();
|
||||
sal_uInt32 nNullDate = Date::DateToDays( aNullDate.GetDay(), aNullDate.GetMonth(), aNullDate.GetYear() );
|
||||
FormulaError nErr = GetWeekendAndHolidayMasks_MS( nParamCount, nNullDate,
|
||||
nSortArray, bWeekendMask, true );
|
||||
@ -736,9 +736,9 @@ void ScInterpreter::ScGetDiffDate360()
|
||||
}
|
||||
else
|
||||
fSign = 1.0;
|
||||
Date aDate1 = *(pFormatter->GetNullDate());
|
||||
Date aDate1 = pFormatter->GetNullDate();
|
||||
aDate1 += (long) ::rtl::math::approxFloor(nDate1);
|
||||
Date aDate2 = *(pFormatter->GetNullDate());
|
||||
Date aDate2 = pFormatter->GetNullDate();
|
||||
aDate2 += (long) ::rtl::math::approxFloor(nDate2);
|
||||
if (aDate1.GetDay() == 31)
|
||||
aDate1 -= (sal_uLong) 1;
|
||||
@ -810,12 +810,12 @@ void ScInterpreter::ScGetDateDif()
|
||||
// split dates in day, month, year for use with formats other than "d"
|
||||
sal_uInt16 d1, m1, d2, m2;
|
||||
sal_Int16 y1, y2;
|
||||
Date aDate1( *( pFormatter->GetNullDate()));
|
||||
Date aDate1( pFormatter->GetNullDate());
|
||||
aDate1 += nDate1;
|
||||
y1 = aDate1.GetYear();
|
||||
m1 = aDate1.GetMonth();
|
||||
d1 = aDate1.GetDay();
|
||||
Date aDate2( *( pFormatter->GetNullDate()));
|
||||
Date aDate2( pFormatter->GetNullDate());
|
||||
aDate2 += nDate2;
|
||||
y2 = aDate2.GetYear();
|
||||
m2 = aDate2.GetMonth();
|
||||
|
@ -192,7 +192,7 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co
|
||||
// Method: assume there is an month interval and verify.
|
||||
// If month interval is used, replace maRange.X with month values
|
||||
// for ease of calculations.
|
||||
Date aNullDate = *( mpFormatter->GetNullDate() );
|
||||
Date aNullDate = mpFormatter->GetNullDate();
|
||||
Date aDate = aNullDate + static_cast< long >( maRange[ 0 ].X );
|
||||
mnMonthDay = aDate.GetDay();
|
||||
for ( SCSIZE i = 1; i < mnCount && mnMonthDay; i++ )
|
||||
@ -812,7 +812,7 @@ void ScETSForecastCalculation::refill()
|
||||
|
||||
double ScETSForecastCalculation::convertXtoMonths( double x )
|
||||
{
|
||||
Date aNullDate = *( mpFormatter->GetNullDate() );
|
||||
Date aNullDate = mpFormatter->GetNullDate();
|
||||
Date aDate = aNullDate + static_cast< long >( x );
|
||||
int nYear = aDate.GetYear();
|
||||
int nMonth = aDate.GetMonth();
|
||||
|
@ -286,9 +286,9 @@ const sal_uInt8* ExcDummy_041::GetData() const
|
||||
|
||||
Exc1904::Exc1904( ScDocument& rDoc )
|
||||
{
|
||||
Date* pDate = rDoc.GetFormatTable()->GetNullDate();
|
||||
bVal = pDate && (*pDate == Date( 1, 1, 1904 ));
|
||||
bDateCompatibility = pDate && !( *pDate == Date( 30, 12, 1899 ));
|
||||
const Date& rDate = rDoc.GetFormatTable()->GetNullDate();
|
||||
bVal = (rDate == Date( 1, 1, 1904 ));
|
||||
bDateCompatibility = !(rDate == Date( 30, 12, 1899 ));
|
||||
}
|
||||
|
||||
sal_uInt16 Exc1904::GetNum() const
|
||||
|
@ -316,7 +316,7 @@ SvNumberFormatter& XclRoot::GetFormatter() const
|
||||
|
||||
DateTime XclRoot::GetNullDate() const
|
||||
{
|
||||
return *GetFormatter().GetNullDate();
|
||||
return GetFormatter().GetNullDate();
|
||||
}
|
||||
|
||||
sal_uInt16 XclRoot::GetBaseYear() const
|
||||
|
@ -529,7 +529,7 @@ void ScOrcusSheet::set_date_time(
|
||||
sal_uInt32 nSec = floor(second);
|
||||
sal_uInt32 nNanoSec = (second - nSec) * ::tools::Time::nanoSecPerSec;
|
||||
tools::Time aTime(hour, minute, nSec, nNanoSec);
|
||||
Date aNullDate(*pFormatter->GetNullDate());
|
||||
Date aNullDate(pFormatter->GetNullDate());
|
||||
long nDateDiff = aDate - aNullDate;
|
||||
|
||||
double fTime =
|
||||
|
@ -1434,7 +1434,7 @@ void ScCheckListMenuWindow::addDateMember(const OUString& rsName, double nVal, b
|
||||
SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
|
||||
|
||||
// Convert the numeric date value to a date object.
|
||||
Date aDate = *(pFormatter->GetNullDate());
|
||||
Date aDate = pFormatter->GetNullDate();
|
||||
aDate += static_cast<long>(rtl::math::approxFloor(nVal));
|
||||
|
||||
sal_Int16 nYear = aDate.GetYear();
|
||||
|
@ -966,7 +966,7 @@ ErrCode ScDocShell::DBaseExport( const OUString& rFullFileName, rtl_TextEncoding
|
||||
}
|
||||
else
|
||||
{
|
||||
Date aDate = *(pNumFmt->GetNullDate()); // tools date
|
||||
Date aDate = pNumFmt->GetNullDate(); // tools date
|
||||
aDate += (long)fVal; //! approxfloor?
|
||||
xRowUpdate->updateDate( nCol+1, aDate.GetUNODate() );
|
||||
}
|
||||
|
@ -1162,7 +1162,7 @@ static bool lcl_PutString(
|
||||
pCalendar->setValue( i18n::CalendarFieldIndex::MILLISECOND, nMilli );
|
||||
if ( pCalendar->isValid() )
|
||||
{
|
||||
double fDiff = DateTime(*pDocFormatter->GetNullDate()) -
|
||||
double fDiff = DateTime(pDocFormatter->GetNullDate()) -
|
||||
pCalendar->getEpochStart();
|
||||
// #i14974# must use getLocalDateTime to get the same
|
||||
// date values as set above
|
||||
|
@ -689,7 +689,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
|
||||
}
|
||||
if(eFillCmd==FILL_DATE)
|
||||
{
|
||||
Date aNullDate = *pDoc->GetFormatTable()->GetNullDate();
|
||||
Date aNullDate = pDoc->GetFormatTable()->GetNullDate();
|
||||
Date aStartDate = aNullDate;
|
||||
aStartDate+= (long)fStartVal;
|
||||
Date aEndDate = aNullDate;
|
||||
@ -1119,7 +1119,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
|
||||
{
|
||||
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
|
||||
OSL_ENSURE( pFact, "ScAbstractFactory create fail!" );
|
||||
Date aNullDate( *GetViewData()->GetDocument()->GetFormatTable()->GetNullDate() );
|
||||
Date aNullDate( GetViewData()->GetDocument()->GetFormatTable()->GetNullDate() );
|
||||
ScopedVclPtr<AbstractScDPDateGroupDlg> pDlg( pFact->CreateScDPDateGroupDlg(
|
||||
pTabViewShell->GetDialogParent(),
|
||||
aNumInfo, nParts, aNullDate ) );
|
||||
|
@ -280,7 +280,7 @@ void ScViewFunc::InsertCurrentTime(short nReqFmt, const OUString& rUndoStr)
|
||||
case css::util::NumberFormat::DATE:
|
||||
{
|
||||
Date aActDate( Date::SYSTEM );
|
||||
fVal = aActDate - *pFormatter->GetNullDate();
|
||||
fVal = aActDate - pFormatter->GetNullDate();
|
||||
if (nCurNumFormatType == css::util::NumberFormat::DATE)
|
||||
nFormat = nCurNumFormat;
|
||||
}
|
||||
@ -300,7 +300,7 @@ void ScViewFunc::InsertCurrentTime(short nReqFmt, const OUString& rUndoStr)
|
||||
case css::util::NumberFormat::DATETIME:
|
||||
{
|
||||
DateTime aActDateTime( DateTime::SYSTEM );
|
||||
fVal = aActDateTime - DateTime( *pFormatter->GetNullDate());
|
||||
fVal = aActDateTime - DateTime( pFormatter->GetNullDate());
|
||||
if (nCurNumFormatType == css::util::NumberFormat::DATETIME)
|
||||
nFormat = nCurNumFormat;
|
||||
}
|
||||
@ -353,7 +353,7 @@ void ScViewFunc::InsertCurrentTime(short nReqFmt, const OUString& rUndoStr)
|
||||
// date, which otherwise would only be possible by
|
||||
// applying a date format.
|
||||
double fDate = rtl::math::approxFloor( fCell);
|
||||
if (fDate == (Date( Date::SYSTEM) - *pFormatter->GetNullDate()))
|
||||
if (fDate == (Date( Date::SYSTEM) - pFormatter->GetNullDate()))
|
||||
bForceReqFmt = true;
|
||||
}
|
||||
break;
|
||||
@ -379,7 +379,7 @@ void ScViewFunc::InsertCurrentTime(short nReqFmt, const OUString& rUndoStr)
|
||||
// zero and date is current date, else force time only.
|
||||
double fDate = rtl::math::approxFloor( fCell);
|
||||
double fTime = fCell - fDate;
|
||||
if (fTime == 0.0 && fDate == (Date( Date::SYSTEM) - *pFormatter->GetNullDate()))
|
||||
if (fTime == 0.0 && fDate == (Date( Date::SYSTEM) - pFormatter->GetNullDate()))
|
||||
nReqFmt = css::util::NumberFormat::DATETIME;
|
||||
else
|
||||
bForceReqFmt = true;
|
||||
@ -400,7 +400,7 @@ void ScViewFunc::InsertCurrentTime(short nReqFmt, const OUString& rUndoStr)
|
||||
case css::util::NumberFormat::DATE:
|
||||
{
|
||||
Date aActDate( Date::SYSTEM );
|
||||
fVal = aActDate - *pFormatter->GetNullDate();
|
||||
fVal = aActDate - pFormatter->GetNullDate();
|
||||
}
|
||||
break;
|
||||
case css::util::NumberFormat::TIME:
|
||||
@ -423,7 +423,7 @@ void ScViewFunc::InsertCurrentTime(short nReqFmt, const OUString& rUndoStr)
|
||||
{
|
||||
double fTime = fCell - rtl::math::approxFloor( fCell);
|
||||
Date aActDate( Date::SYSTEM );
|
||||
fVal = (aActDate - *pFormatter->GetNullDate()) + fTime;
|
||||
fVal = (aActDate - pFormatter->GetNullDate()) + fTime;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -432,7 +432,7 @@ void ScViewFunc::InsertCurrentTime(short nReqFmt, const OUString& rUndoStr)
|
||||
// Converting the null date to DateTime forces the
|
||||
// correct operator-() to be used, resulting in a
|
||||
// fractional date+time instead of only date value.
|
||||
fVal = aActDateTime - DateTime( *pFormatter->GetNullDate());
|
||||
fVal = aActDateTime - DateTime( pFormatter->GetNullDate());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -927,11 +927,8 @@ uno::Any SAL_CALL SvNumberFormatSettingsObj::getPropertyValue( const OUString& a
|
||||
}
|
||||
else if (aPropertyName == PROPERTYNAME_NULLDATE)
|
||||
{
|
||||
Date* pDate = pFormatter->GetNullDate();
|
||||
if (pDate)
|
||||
{
|
||||
aRet <<= pDate->GetUNODate();
|
||||
}
|
||||
const Date& rDate = pFormatter->GetNullDate();
|
||||
aRet <<= rDate.GetUNODate();
|
||||
}
|
||||
else if (aPropertyName == PROPERTYNAME_STDDEC)
|
||||
aRet <<= (sal_Int16)( pFormatter->GetStandardPrec() );
|
||||
|
@ -395,7 +395,7 @@ void SvNumberFormatter::ChangeNullDate(sal_uInt16 nDay,
|
||||
pStringScanner->ChangeNullDate(nDay, nMonth, nYear);
|
||||
}
|
||||
|
||||
Date* SvNumberFormatter::GetNullDate()
|
||||
const Date& SvNumberFormatter::GetNullDate()
|
||||
{
|
||||
return pFormatScanner->GetNullDate();
|
||||
}
|
||||
|
@ -2997,7 +2997,7 @@ bool SvNumberformat::ImpGetTimeOutput(double fNumber,
|
||||
case NF_KEY_AMPM: // AM/PM
|
||||
if ( !bCalendarSet )
|
||||
{
|
||||
double fDiff = DateTime(*(rScan.GetNullDate())) - GetCal().getEpochStart();
|
||||
double fDiff = DateTime(rScan.GetNullDate()) - GetCal().getEpochStart();
|
||||
fDiff += fNumberOrig;
|
||||
GetCal().setLocalDateTime( fDiff );
|
||||
bCalendarSet = true;
|
||||
@ -3454,7 +3454,7 @@ bool SvNumberformat::ImpGetDateOutput(double fNumber,
|
||||
bool bRes = false;
|
||||
|
||||
CalendarWrapper& rCal = GetCal();
|
||||
double fDiff = DateTime(*(rScan.GetNullDate())) - rCal.getEpochStart();
|
||||
double fDiff = DateTime(rScan.GetNullDate()) - rCal.getEpochStart();
|
||||
fNumber += fDiff;
|
||||
rCal.setLocalDateTime( fNumber );
|
||||
int nUseMonthCase = 0; // Not decided yet
|
||||
@ -3661,7 +3661,7 @@ bool SvNumberformat::ImpGetDateTimeOutput(double fNumber,
|
||||
bool bRes = false;
|
||||
|
||||
CalendarWrapper& rCal = GetCal();
|
||||
double fDiff = DateTime(*(rScan.GetNullDate())) - rCal.getEpochStart();
|
||||
double fDiff = DateTime(rScan.GetNullDate()) - rCal.getEpochStart();
|
||||
fNumber += fDiff;
|
||||
|
||||
const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info();
|
||||
|
@ -40,7 +40,8 @@ const sal_Unicode cNoBreakSpace = 0xA0;
|
||||
const sal_Unicode cNarrowNoBreakSpace = 0x202F;
|
||||
|
||||
ImpSvNumberformatScan::ImpSvNumberformatScan( SvNumberFormatter* pFormatterP )
|
||||
: eNewLnge(LANGUAGE_DONTKNOW)
|
||||
: maNullDate( 30, 12, 1899)
|
||||
, eNewLnge(LANGUAGE_DONTKNOW)
|
||||
, eTmpLnge(LANGUAGE_DONTKNOW)
|
||||
, nCurrPos(-1)
|
||||
{
|
||||
@ -77,7 +78,6 @@ ImpSvNumberformatScan::ImpSvNumberformatScan( SvNumberFormatter* pFormatterP )
|
||||
StandardColor[8] = Color(COL_YELLOW);
|
||||
StandardColor[9] = Color(COL_WHITE);
|
||||
|
||||
pNullDate = new Date(30,12,1899);
|
||||
nStandardPrec = 2;
|
||||
|
||||
sErrStr = "###";
|
||||
@ -86,7 +86,6 @@ ImpSvNumberformatScan::ImpSvNumberformatScan( SvNumberFormatter* pFormatterP )
|
||||
|
||||
ImpSvNumberformatScan::~ImpSvNumberformatScan()
|
||||
{
|
||||
delete pNullDate;
|
||||
Reset();
|
||||
}
|
||||
|
||||
@ -429,10 +428,14 @@ void ImpSvNumberformatScan::SetDependentKeywords()
|
||||
|
||||
void ImpSvNumberformatScan::ChangeNullDate(sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear)
|
||||
{
|
||||
if ( pNullDate )
|
||||
*pNullDate = Date(nDay, nMonth, nYear);
|
||||
else
|
||||
pNullDate = new Date(nDay, nMonth, nYear);
|
||||
maNullDate = Date(nDay, nMonth, nYear);
|
||||
if (!maNullDate.IsValidDate())
|
||||
{
|
||||
maNullDate.Normalize();
|
||||
SAL_WARN("svl.numbers","ImpSvNumberformatScan::ChangeNullDate - not valid"
|
||||
" d: " << nDay << " m: " << nMonth << " y: " << nYear << " normalized to"
|
||||
" d: " << maNullDate.GetDay() << " m: " << maNullDate.GetMonth() << " y: " << maNullDate.GetYear());
|
||||
}
|
||||
}
|
||||
|
||||
void ImpSvNumberformatScan::ChangeStandardPrec(sal_uInt16 nPrec)
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
const OUString& GetBooleanString() const { return GetKeywords()[NF_KEY_BOOLEAN]; }
|
||||
const OUString& GetErrorString() const { return sErrStr; }
|
||||
|
||||
Date* GetNullDate() const { return pNullDate; }
|
||||
const Date& GetNullDate() const { return maNullDate; }
|
||||
const OUString& GetStandardName() const
|
||||
{
|
||||
if ( bKeywordsNeedInit )
|
||||
@ -150,7 +150,7 @@ public:
|
||||
private: // Private section
|
||||
NfKeywordTable sKeyword; // Syntax keywords
|
||||
Color StandardColor[NF_MAX_DEFAULT_COLORS]; // Standard color array
|
||||
Date* pNullDate; // 30Dec1899
|
||||
Date maNullDate; // 30Dec1899
|
||||
OUString sNameStandardFormat; // "Standard"
|
||||
sal_uInt16 nStandardPrec; // Default Precision for Standardformat
|
||||
SvNumberFormatter* pFormatter; // Pointer to the FormatList
|
||||
|
@ -220,9 +220,9 @@ static double lcl_ConvertToDateValue( SwDoc& rDoc, sal_Int32 nDate )
|
||||
SvNumberFormatter* pFormatter = rDoc.GetNumberFormatter();
|
||||
if( pFormatter )
|
||||
{
|
||||
Date* pNull = pFormatter->GetNullDate();
|
||||
const Date& rNull = pFormatter->GetNullDate();
|
||||
Date aDate( nDate >> 24, (nDate& 0x00FF0000) >> 16, nDate& 0x0000FFFF );
|
||||
nRet = aDate - *pNull;
|
||||
nRet = aDate - rNull;
|
||||
}
|
||||
return nRet;
|
||||
}
|
||||
|
@ -275,8 +275,8 @@ bool SwDBField::FormatValue( SvNumberFormatter* pDocFormatter, OUString &aString
|
||||
DataType::TIMESTAMP == nColumnType )
|
||||
{
|
||||
Date aStandard( 1, 1, 1900 );
|
||||
if( *pDocFormatter->GetNullDate() != aStandard )
|
||||
aNumber += (aStandard - *pDocFormatter->GetNullDate());
|
||||
if( pDocFormatter->GetNullDate() != aStandard )
|
||||
aNumber += (aStandard - pDocFormatter->GetNullDate());
|
||||
}
|
||||
bValidValue = true;
|
||||
if( pField )
|
||||
|
@ -1070,15 +1070,15 @@ OUString SwDocInfoField::Expand() const
|
||||
if( aAny >>= aDate)
|
||||
{
|
||||
SvNumberFormatter* pFormatter = pDocShell->GetDoc()->GetNumberFormatter();
|
||||
Date* pNullDate = pFormatter->GetNullDate();
|
||||
sVal = ExpandValue( lcl_DateToDouble<util::Date>( aDate, *pNullDate ), GetFormat(), GetLanguage());
|
||||
const Date& rNullDate = pFormatter->GetNullDate();
|
||||
sVal = ExpandValue( lcl_DateToDouble<util::Date>( aDate, rNullDate ), GetFormat(), GetLanguage());
|
||||
}
|
||||
else if( aAny >>= aDateTime )
|
||||
{
|
||||
double fDateTime = lcl_TimeToDouble<util::DateTime>( aDateTime );
|
||||
SvNumberFormatter* pFormatter = pDocShell->GetDoc()->GetNumberFormatter();
|
||||
Date* pNullDate = pFormatter->GetNullDate();
|
||||
fDateTime += lcl_DateToDouble<util::DateTime>( aDateTime, *pNullDate );
|
||||
const Date& rNullDate = pFormatter->GetNullDate();
|
||||
fDateTime += lcl_DateToDouble<util::DateTime>( aDateTime, rNullDate );
|
||||
sVal = ExpandValue( fDateTime, GetFormat(), GetLanguage());
|
||||
}
|
||||
else if( aAny >>= aDuration )
|
||||
|
@ -121,9 +121,9 @@ void SwDateTimeField::SetDateTime(const DateTime& rDT)
|
||||
double SwDateTimeField::GetDateTime(SwDoc* pDoc, const DateTime& rDT)
|
||||
{
|
||||
SvNumberFormatter* pFormatter = pDoc->GetNumberFormatter();
|
||||
Date* pNullDate = pFormatter->GetNullDate();
|
||||
const Date& rNullDate = pFormatter->GetNullDate();
|
||||
|
||||
double fResult = rDT - DateTime(*pNullDate);
|
||||
double fResult = rDT - DateTime(rNullDate);
|
||||
|
||||
return fResult;
|
||||
}
|
||||
@ -139,11 +139,11 @@ double SwDateTimeField::GetValue() const
|
||||
Date SwDateTimeField::GetDate() const
|
||||
{
|
||||
SvNumberFormatter* pFormatter = GetDoc()->GetNumberFormatter();
|
||||
Date* pNullDate = pFormatter->GetNullDate();
|
||||
const Date& rNullDate = pFormatter->GetNullDate();
|
||||
|
||||
long nVal = static_cast<long>( GetValue() );
|
||||
|
||||
Date aDate = *pNullDate + nVal;
|
||||
Date aDate = rNullDate + nVal;
|
||||
|
||||
return aDate;
|
||||
}
|
||||
|
@ -1595,7 +1595,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
|
||||
const SwPostItField* pField = static_cast<SwPostItField*>(pFirst->GetField());
|
||||
SvNumberFormatter* pNumFormatter = pDoc->GetNumberFormatter();
|
||||
const Date aDateDiff( pField->GetDate() -
|
||||
*pNumFormatter->GetNullDate() );
|
||||
pNumFormatter->GetNullDate() );
|
||||
const sal_uLong nFormat =
|
||||
pNumFormatter->GetStandardFormat( css::util::NumberFormat::DATE, pField->GetLanguage() );
|
||||
OUString sDate;
|
||||
|
@ -1136,8 +1136,8 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
|
||||
if(rNumFormatr.GetType(aNumFormat.GetValue()) & css::util::NumberFormat::DATE)
|
||||
{
|
||||
::Date aStandard(1,1,1900);
|
||||
if (*rNumFormatr.GetNullDate() != aStandard)
|
||||
fVal += (aStandard - *rNumFormatr.GetNullDate());
|
||||
if (rNumFormatr.GetNullDate() != aStandard)
|
||||
fVal += (aStandard - rNumFormatr.GetNullDate());
|
||||
}
|
||||
aTableSet.Put( SwTableBoxValue( fVal ));
|
||||
}
|
||||
@ -1370,8 +1370,8 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
|
||||
if(rNumFormatr.GetType(pDBCol->nFormat) & css::util::NumberFormat::DATE)
|
||||
{
|
||||
::Date aStandard(1,1,1900);
|
||||
if (*rNumFormatr.GetNullDate() != aStandard)
|
||||
nValue += (aStandard - *rNumFormatr.GetNullDate());
|
||||
if (rNumFormatr.GetNullDate() != aStandard)
|
||||
nValue += (aStandard - rNumFormatr.GetNullDate());
|
||||
}
|
||||
rNumFormatr.GetOutputString( nValue,
|
||||
pDBCol->nFormat,
|
||||
|
@ -120,11 +120,11 @@ getLocalizedDatTimeStr(
|
||||
SvNumberFormatter *pNumberFormatter = new SvNumberFormatter( xContext, eUILang );
|
||||
OUString aTmpStr;
|
||||
Color* pColor = nullptr;
|
||||
Date* pNullDate = pNumberFormatter->GetNullDate();
|
||||
const Date& rNullDate = pNumberFormatter->GetNullDate();
|
||||
sal_uInt32 nFormat
|
||||
= pNumberFormatter->GetStandardFormat( css::util::NumberFormat::DATE, eUILang );
|
||||
|
||||
pNumberFormatter->GetOutputString( aDate - *pNullDate, nFormat, aTmpStr, &pColor );
|
||||
pNumberFormatter->GetOutputString( aDate - rNullDate, nFormat, aTmpStr, &pColor );
|
||||
aDateTimeStr = aTmpStr + " ";
|
||||
|
||||
nFormat = pNumberFormatter->GetStandardFormat( css::util::NumberFormat::TIME, eUILang );
|
||||
|
Loading…
x
Reference in New Issue
Block a user