diff options
author | Eike Rathke <erack@redhat.com> | 2017-07-18 19:43:05 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-07-18 19:43:35 +0200 |
commit | 038063a352f59bad1ecdeeb63016e37f6945a420 (patch) | |
tree | b64769d58f9bc001dbf235f420038ba436344a33 /sw | |
parent | 71c3113e9dbf61693fd947262370cc61cdf31ac7 (diff) |
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
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/bastyp/calc.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/fields/dbfld.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/fields/docufld.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/fields/flddat.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/text/EnhancedPDFExportHelper.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/dbui/dbinsdlg.cxx | 8 |
6 files changed, 17 insertions, 17 deletions
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, |