[Libreoffice-commits] core.git: chart2/source cui/source editeng/source extensions/source include/svl sc/source svl/source sw/source uui/source
Eike Rathke
erack at redhat.com
Tue Jul 18 17:44:09 UTC 2017
chart2/source/tools/NumberFormatterWrapper.cxx | 15 +++--------
cui/source/options/optupdt.cxx | 4 +--
editeng/source/items/flditem.cxx | 2 -
extensions/source/propctrlr/standardcontrol.cxx | 4 +--
include/svl/zforlist.hxx | 2 -
sc/source/core/data/conditio.cxx | 4 +--
sc/source/core/data/dbdocutl.cxx | 4 +--
sc/source/core/data/dpgroup.cxx | 4 +--
sc/source/core/data/dpobject.cxx | 4 +--
sc/source/core/data/dputil.cxx | 4 +--
sc/source/core/data/global2.cxx | 2 -
sc/source/core/data/table4.cxx | 4 +--
sc/source/core/tool/interpr2.cxx | 32 ++++++++++++------------
sc/source/core/tool/interpr8.cxx | 4 +--
sc/source/filter/excel/excrecds.cxx | 6 ++--
sc/source/filter/excel/xlroot.cxx | 2 -
sc/source/filter/orcus/interface.cxx | 2 -
sc/source/ui/cctrl/checklistmenu.cxx | 2 -
sc/source/ui/docshell/docsh8.cxx | 2 -
sc/source/ui/docshell/impex.cxx | 2 -
sc/source/ui/view/cellsh1.cxx | 4 +--
sc/source/ui/view/viewfun6.cxx | 14 +++++-----
svl/source/numbers/numfmuno.cxx | 7 +----
svl/source/numbers/zforlist.cxx | 2 -
svl/source/numbers/zformat.cxx | 6 ++--
svl/source/numbers/zforscan.cxx | 17 +++++++-----
svl/source/numbers/zforscan.hxx | 4 +--
sw/source/core/bastyp/calc.cxx | 4 +--
sw/source/core/fields/dbfld.cxx | 4 +--
sw/source/core/fields/docufld.cxx | 8 +++---
sw/source/core/fields/flddat.cxx | 8 +++---
sw/source/core/text/EnhancedPDFExportHelper.cxx | 2 -
sw/source/ui/dbui/dbinsdlg.cxx | 8 +++---
uui/source/iahndl-ssl.cxx | 4 +--
34 files changed, 96 insertions(+), 101 deletions(-)
New commits:
commit 038063a352f59bad1ecdeeb63016e37f6945a420
Author: Eike Rathke <erack at redhat.com>
Date: Tue Jul 18 19:43:05 2017 +0200
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
diff --git a/chart2/source/tools/NumberFormatterWrapper.cxx b/chart2/source/tools/NumberFormatterWrapper.cxx
index ead2d47e4cb4..11597d87818a 100644
--- a/chart2/source/tools/NumberFormatterWrapper.cxx
+++ b/chart2/source/tools/NumberFormatterWrapper.cxx
@@ -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);
diff --git a/cui/source/options/optupdt.cxx b/cui/source/options/optupdt.cxx
index d229fef9f242..fef9e395d7f9 100644
--- a/cui/source/options/optupdt.cxx
+++ b/cui/source/options/optupdt.cxx
@@ -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 );
diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx
index cb2c69f3abb1..deff10eb19b6 100644
--- a/editeng/source/items/flditem.cxx
+++ b/editeng/source/items/flditem.cxx
@@ -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 );
diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx
index dc6e6d492b72..8381a7abad88 100644
--- a/extensions/source/propctrlr/standardcontrol.cxx
+++ b/extensions/source/propctrlr/standardcontrol.cxx
@@ -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 );
diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx
index f6f338972886..a22e05afb731 100644
--- a/include/svl/zforlist.hxx
+++ b/include/svl/zforlist.hxx
@@ -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
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 2256947ed7b7..5c5c3125851c 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -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)
diff --git a/sc/source/core/data/dbdocutl.cxx b/sc/source/core/data/dbdocutl.cxx
index 4f8f2bba8f45..0dc3d4f8b014 100644
--- a/sc/source/core/data/dbdocutl.cxx
+++ b/sc/source/core/data/dbdocutl.cxx
@@ -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) +
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 97c87bff236f..1c2dcaed5164 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -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);
}
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 2ae64ecf64e3..3e07c82eddf1 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -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;
diff --git a/sc/source/core/data/dputil.cxx b/sc/source/core/data/dputil.cxx
index 440ac8d4e0bc..5bff6bb4d927 100644
--- a/sc/source/core/data/dputil.cxx
+++ b/sc/source/core/data/dputil.cxx
@@ -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 )
diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx
index 1ef86f537b23..ab50f5aae7a4 100644
--- a/sc/source/core/data/global2.cxx
+++ b/sc/source/core/data/global2.cxx
@@ -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");
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 324eb2201a93..77d51762f3ef 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -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)
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 75a1d6b2debe..2eefbc3093c2 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -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();
diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx
index b661a220ec27..96da08bb6e58 100644
--- a/sc/source/core/tool/interpr8.cxx
+++ b/sc/source/core/tool/interpr8.cxx
@@ -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();
diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx
index fd0ce5977ddb..9b2c67cbbb85 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -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
diff --git a/sc/source/filter/excel/xlroot.cxx b/sc/source/filter/excel/xlroot.cxx
index 262f40b409ba..72b1450a5084 100644
--- a/sc/source/filter/excel/xlroot.cxx
+++ b/sc/source/filter/excel/xlroot.cxx
@@ -316,7 +316,7 @@ SvNumberFormatter& XclRoot::GetFormatter() const
DateTime XclRoot::GetNullDate() const
{
- return *GetFormatter().GetNullDate();
+ return GetFormatter().GetNullDate();
}
sal_uInt16 XclRoot::GetBaseYear() const
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
index 35e9ffacfafa..c56f1c67cb80 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -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 =
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index e877e38097c0..86f8a2d446cf 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -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();
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 5a676d24d029..2cdcbbfe96c6 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -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() );
}
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 76f6ed8a9803..f992c18061c0 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -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
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index ff173fda39fe..99e6ba02476a 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -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 ) );
diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx
index 97ca1bdb4f23..9816afda8d20 100644
--- a/sc/source/ui/view/viewfun6.cxx
+++ b/sc/source/ui/view/viewfun6.cxx
@@ -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;
diff --git a/svl/source/numbers/numfmuno.cxx b/svl/source/numbers/numfmuno.cxx
index bef4075994e1..9c014f06ccac 100644
--- a/svl/source/numbers/numfmuno.cxx
+++ b/svl/source/numbers/numfmuno.cxx
@@ -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() );
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 1acc79778e4a..2f3059ec4378 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -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();
}
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index a736c16518dc..224190550edd 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -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();
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index 25014fa7e0f5..13c0362e873f 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -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)
diff --git a/svl/source/numbers/zforscan.hxx b/svl/source/numbers/zforscan.hxx
index 13d5b1a67177..5aaee72f870f 100644
--- a/svl/source/numbers/zforscan.hxx
+++ b/svl/source/numbers/zforscan.hxx
@@ -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
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index 80f10a9821f0..2fd656296bf4 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -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;
}
diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx
index 1790ae8eabe3..0df616a710cc 100644
--- a/sw/source/core/fields/dbfld.cxx
+++ b/sw/source/core/fields/dbfld.cxx
@@ -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 )
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index 692fb7ee723d..aae7cacee181 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -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 )
diff --git a/sw/source/core/fields/flddat.cxx b/sw/source/core/fields/flddat.cxx
index 56c532c66b8c..5ae5da51a9c3 100644
--- a/sw/source/core/fields/flddat.cxx
+++ b/sw/source/core/fields/flddat.cxx
@@ -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;
}
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index bf26e0d4900b..3f0ddffcacd5 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -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;
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index 97abb559b731..207da08081b4 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -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,
diff --git a/uui/source/iahndl-ssl.cxx b/uui/source/iahndl-ssl.cxx
index 1aee36d03639..2937b0ee3d81 100644
--- a/uui/source/iahndl-ssl.cxx
+++ b/uui/source/iahndl-ssl.cxx
@@ -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 );
More information about the Libreoffice-commits
mailing list