diff options
author | Noel Grandin <noel@peralex.com> | 2016-10-11 08:15:05 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-10-11 08:43:33 +0000 |
commit | d0304a8f57b3fe0065193a2a3f7089f414b1ffd9 (patch) | |
tree | 6ac18f078dc91b56ae7db204028c15089113339c | |
parent | 52dfb06b194bf890510352a98540c64bc3d44b70 (diff) |
remove some conversion operator methods
which, in these cases, only serve to make the code harder to read
Change-Id: Ic9bcf42545b4fcfd60a535fb63956092d392f469
Reviewed-on: https://gerrit.libreoffice.org/29685
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | i18npool/source/calendar/calendar_jewish.cxx | 22 | ||||
-rw-r--r-- | rsc/inc/rscclobj.hxx | 2 | ||||
-rw-r--r-- | rsc/inc/rscdef.hxx | 1 | ||||
-rw-r--r-- | rsc/inc/rscerror.h | 4 | ||||
-rw-r--r-- | rsc/source/parser/erscerr.cxx | 8 | ||||
-rw-r--r-- | rsc/source/parser/rsclex.cxx | 2 | ||||
-rw-r--r-- | rsc/source/parser/rscyacc.y | 6 | ||||
-rw-r--r-- | rsc/source/res/rscclobj.cxx | 4 | ||||
-rw-r--r-- | rsc/source/res/rsccont.cxx | 6 | ||||
-rw-r--r-- | rsc/source/res/rscmgr.cxx | 2 | ||||
-rw-r--r-- | rsc/source/res/rscrange.cxx | 2 | ||||
-rw-r--r-- | rsc/source/tools/rscdef.cxx | 5 | ||||
-rw-r--r-- | svtools/source/misc/ehdl.cxx | 12 |
13 files changed, 35 insertions, 41 deletions
diff --git a/i18npool/source/calendar/calendar_jewish.cxx b/i18npool/source/calendar/calendar_jewish.cxx index 19b62d3229e5..a060aa9d5bf6 100644 --- a/i18npool/source/calendar/calendar_jewish.cxx +++ b/i18npool/source/calendar/calendar_jewish.cxx @@ -139,20 +139,20 @@ public: explicit HebrewDate(sal_Int32 d) { // Computes the Hebrew date from the absolute date. year = (d + HebrewEpoch) / 366; // Approximation from below. // Search forward for year from the approximation. - while (d >= HebrewDate(7,1,year + 1)) + while (d >= HebrewDate(7,1,year + 1).GetAbsoluteDate()) year++; // Search forward for month from either Tishri or Nisan. - if (d < HebrewDate(1, 1, year)) + if (d < HebrewDate(1, 1, year).GetAbsoluteDate()) month = 7; // Start at Tishri else month = 1; // Start at Nisan - while (d > HebrewDate(month, (LastDayOfHebrewMonth(month,year)), year)) + while (d > HebrewDate(month, (LastDayOfHebrewMonth(month,year)), year).GetAbsoluteDate()) month++; // Calculate the day by subtraction. - day = d - HebrewDate(month, 1, year) + 1; + day = d - HebrewDate(month, 1, year).GetAbsoluteDate() + 1; } - operator int() { // Computes the absolute date of Hebrew date. + int GetAbsoluteDate() const { // Computes the absolute date of Hebrew date. sal_Int32 DayInYear = day; // Days so far this month. if (month < 7) { // Before Tishri, so add days in prior months // this year before and after Nisan. @@ -217,16 +217,16 @@ public: explicit GregorianDate(int d) { // Computes the Gregorian date from the absolute date. // Search forward year by year from approximate year year = d/366; - while (d >= GregorianDate(1,1,year+1)) + while (d >= GregorianDate(1,1,year+1).GetAbsoluteDate()) year++; // Search forward month by month from January month = 1; - while (d > GregorianDate(month, LastDayOfGregorianMonth(month,year), year)) + while (d > GregorianDate(month, LastDayOfGregorianMonth(month,year), year).GetAbsoluteDate()) month++; - day = d - GregorianDate(month,1,year) + 1; + day = d - GregorianDate(month,1,year).GetAbsoluteDate() + 1; } - operator int() { // Computes the absolute date from the Gregorian date. + int GetAbsoluteDate() const { // Computes the absolute date from the Gregorian date. int N = day; // days this month for (int m = month - 1; m > 0; m--) // days in prior months this year N = N + LastDayOfGregorianMonth(m, year); @@ -251,7 +251,7 @@ void Calendar_jewish::mapFromGregorian() throw(RuntimeException) if (fieldValue[CalendarFieldIndex::ERA] == 0) y = 1 - y; GregorianDate Temp(fieldValue[CalendarFieldIndex::MONTH] + 1, fieldValue[CalendarFieldIndex::DAY_OF_MONTH], y); - HebrewDate hd(Temp); + HebrewDate hd(Temp.GetAbsoluteDate()); fieldValue[CalendarFieldIndex::ERA] = hd.GetYear() <= 0 ? 0 : 1; fieldValue[CalendarFieldIndex::MONTH] = sal::static_int_cast<sal_Int16>( hd.GetMonth() - 1 ); @@ -268,7 +268,7 @@ void Calendar_jewish::mapToGregorian() throw(RuntimeException) if (fieldSetValue[CalendarFieldIndex::ERA] == 0) y = 1 - y; HebrewDate Temp(fieldSetValue[CalendarFieldIndex::MONTH] + 1, fieldSetValue[CalendarFieldIndex::DAY_OF_MONTH], y); - GregorianDate gd(Temp); + GregorianDate gd(Temp.GetAbsoluteDate()); fieldSetValue[CalendarFieldIndex::ERA] = gd.GetYear() <= 0 ? 0 : 1; fieldSetValue[CalendarFieldIndex::MONTH] = sal::static_int_cast<sal_Int16>( gd.GetMonth() - 1 ); diff --git a/rsc/inc/rscclobj.hxx b/rsc/inc/rscclobj.hxx index eeb694f25cb7..7bbc5f1c1f46 100644 --- a/rsc/inc/rscclobj.hxx +++ b/rsc/inc/rscclobj.hxx @@ -42,7 +42,7 @@ public: sal_uLong GetFileKey() const { return lFileKey; }; ObjNode* Search( const RscId &rName ) const //< search the index in the b-tree { - return static_cast<ObjNode *>(IdNode::Search( rName )); + return static_cast<ObjNode *>(IdNode::Search( rName.GetNumber() )); } bool Insert( ObjNode* pTN ) //< insert a new node in the b-tree diff --git a/rsc/inc/rscdef.hxx b/rsc/inc/rscdef.hxx index 279be92cbcf1..c9a2f9e6af45 100644 --- a/rsc/inc/rscdef.hxx +++ b/rsc/inc/rscdef.hxx @@ -103,7 +103,6 @@ public: RscId& operator = ( const RscId& rRscId ); static void SetNames( bool bSet = true ); - operator sal_Int32() const; // returns the number OString GetName() const; // returns the define bool operator < ( const RscId& rRscId ) const; bool operator > ( const RscId& rRscId ) const; diff --git a/rsc/inc/rscerror.h b/rsc/inc/rscerror.h index 758cf967a171..f0f984589d44 100644 --- a/rsc/inc/rscerror.h +++ b/rsc/inc/rscerror.h @@ -93,11 +93,11 @@ public: ERRTYPE( sal_uInt32 nErr ) { nError = nErr; } ERRTYPE( const ERRTYPE & ) = default; ERRTYPE& operator = ( const ERRTYPE & rError ); - operator sal_uInt32() const { return nError; } + sal_uInt32 GetError() const { return nError; } bool IsError() const { return nError <= ERR_ERROREND; } bool IsOk() const { return !IsError(); } bool IsWarning() const { return nError >= ERR_WARNINGSTART && nError <= ERR_WARNINGEND;} - void Clear(){ nError = ERR_OK; } + void Clear() { nError = ERR_OK; } }; // Rsc Error diff --git a/rsc/source/parser/erscerr.cxx b/rsc/source/parser/erscerr.cxx index 30c911965e0d..ce67dfd9c60b 100644 --- a/rsc/source/parser/erscerr.cxx +++ b/rsc/source/parser/erscerr.cxx @@ -72,7 +72,7 @@ void RscError::StdLstErr( const char * pStr ){ void RscError::WriteError( const ERRTYPE& rError, const char * pMessage ) { - switch( rError ) + switch( rError.GetError() ) { case ERR_ERROR: { StdLstErr( "!! " ); @@ -338,7 +338,7 @@ void RscError::ErrorFormat( const ERRTYPE& rError, RscTop * pClass, StdLstErr( "\n" ); } StdLstErr( "f" ); - sprintf( buf, "%u", (unsigned int)rError ); + sprintf( buf, "%u", (unsigned int)rError.GetError() ); StdLstErr( buf ); if( pFI && pTC ){ @@ -375,7 +375,7 @@ void RscError::ErrorFormat( const ERRTYPE& rError, RscTop * pClass, void RscError::Error( const ERRTYPE& rError, RscTop * pClass, const RscId & aId, const char * pMessage ) { - if( WRN_LOCALID == rError ) // ignore warnings + if( WRN_LOCALID == rError.GetError() ) // ignore warnings return; if( rError.IsError() ) nErrors++; @@ -389,7 +389,7 @@ void RscError::Error( const ERRTYPE& rError, RscTop * pClass, void RscError::FatalError( const ERRTYPE& rError, const RscId &aId, const char * pMessage ) { - if( ERR_USAGE != rError ){ + if( ERR_USAGE != rError.GetError() ){ nErrors++; ErrorFormat( rError, nullptr, aId ); WriteError( rError, pMessage ); diff --git a/rsc/source/parser/rsclex.cxx b/rsc/source/parser/rsclex.cxx index a1a32320f77b..5d6040edd235 100644 --- a/rsc/source/parser/rsclex.cxx +++ b/rsc/source/parser/rsclex.cxx @@ -413,7 +413,7 @@ ERRTYPE parser( RscFileInst * pFileInst ) EndParser(); // yyparser returns 0 on success - if( 0 == aError ) + if( 0 == aError.GetError() ) aError.Clear(); if( pFileInst->pTypCont->pEH->nErrors ) aError = ERR_ERROR; diff --git a/rsc/source/parser/rscyacc.y b/rsc/source/parser/rscyacc.y index bf020892ed76..8898f21eb452 100644 --- a/rsc/source/parser/rscyacc.y +++ b/rsc/source/parser/rscyacc.y @@ -172,7 +172,7 @@ bool DoClassHeader( RSCHEADER * pHeader, bool bMember ) { if( S.IsEmpty() ) { - if( (sal_Int32)aName1 < 256 ) + if( aName1.GetNumber() < 256 ) pTC->pEH->Error( WRN_GLOBALID, pHeader->pClass, aName1 ); if( aCopyInst.IsInst() ) @@ -197,7 +197,7 @@ bool DoClassHeader( RSCHEADER * pHeader, bool bMember ) RSCINST aTmpI; ERRTYPE aError; - if( (sal_Int32)aName1 >= 256 && aName1.IsId() ) + if( aName1.GetNumber() >= 256 && aName1.IsId() ) pTC->pEH->Error( WRN_LOCALID, pHeader->pClass, aName1 ); aError = S.Top().pClass->GetElement( S.Top(), aName1, @@ -209,7 +209,7 @@ bool DoClassHeader( RSCHEADER * pHeader, bool bMember ) } else if( aError.IsError() ) { - if( ERR_CONT_INVALIDTYPE == aError ) + if( ERR_CONT_INVALIDTYPE == aError.GetError() ) pTC->pEH->Error( aError, S.Top().pClass, aName1, pHS->getString( pHeader->pClass->GetId() ).getStr() ); else diff --git a/rsc/source/res/rscclobj.cxx b/rsc/source/res/rscclobj.cxx index 993be7fbd285..80969f704553 100644 --- a/rsc/source/res/rscclobj.cxx +++ b/rsc/source/res/rscclobj.cxx @@ -95,14 +95,14 @@ ObjNode * ObjNode::DelObjNode( RscTop * pClass, sal_uLong nFileKey ) sal_uInt32 ObjNode::GetId() const { - return (sal_uInt32)(long)aRscId; + return aRscId.GetNumber(); } bool ObjNode::IsConsistent() { bool bRet = true; - if( (long)aRscId > 0x7FFF || (long)aRscId < 1 ) + if( aRscId.GetNumber() > 0x7FFF || aRscId.GetNumber() < 1 ) { bRet = false; } diff --git a/rsc/source/res/rsccont.cxx b/rsc/source/res/rsccont.cxx index a48767089f0e..1f4ce70df5d0 100644 --- a/rsc/source/res/rsccont.cxx +++ b/rsc/source/res/rsccont.cxx @@ -506,7 +506,7 @@ ERRTYPE RscBaseCont::SetRef( const RSCINST & rInst, const RscId & rRefId ) aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); aError = aTmpI.pClass->GetRef( aTmpI, &aId ); if( aError.IsOk() ) - aError = aTmpI.pClass->SetNumber( aTmpI, rRefId ); + aError = aTmpI.pClass->SetNumber( aTmpI, rRefId.GetNumber() ); } if( aError.IsError() ) @@ -534,8 +534,8 @@ bool RscBaseCont::IsConsistent( const RSCINST & rInst ) { if( !bNoId ) { - if( (sal_Int32)pClassData->pEntries[ i ].aName > 0x7FFF || - (sal_Int32)pClassData->pEntries[ i ].aName < 1 ) + if( (sal_Int32)pClassData->pEntries[ i ].aName.GetNumber() > 0x7FFF || + (sal_Int32)pClassData->pEntries[ i ].aName.GetNumber() < 1 ) { bRet = false; } diff --git a/rsc/source/res/rscmgr.cxx b/rsc/source/res/rscmgr.cxx index 2de220dca5f1..33f805830718 100644 --- a/rsc/source/res/rscmgr.cxx +++ b/rsc/source/res/rscmgr.cxx @@ -233,7 +233,7 @@ ERRTYPE RscMgr::WriteRcHeader( const RSCINST & rInst, RscWriteRc & rMem, sal_uInt32 nLocalOff; // local offset }; */ - sal_uInt32 nID = rId; + sal_uInt32 nID = rId.GetNumber(); rMem.PutAt( nOldSize, nID ); rMem.PutAt( nOldSize +4, (sal_uInt32)rInst.pClass->GetTypId() ); rMem.PutAt( nOldSize +8, (sal_uInt32)(rMem.Size() - nOldSize) ); diff --git a/rsc/source/res/rscrange.cxx b/rsc/source/res/rscrange.cxx index d243ca8a4be7..1f99bed6b786 100644 --- a/rsc/source/res/rscrange.cxx +++ b/rsc/source/res/rscrange.cxx @@ -345,7 +345,7 @@ ERRTYPE RscIdRange::SetRef( const RSCINST & rInst, const RscId & rRscId ) ERRTYPE aError; if( rRscId.IsId() ) { - aError = SetNumber( rInst, rRscId ); + aError = SetNumber( rInst, rRscId.GetNumber() ); if( aError.IsOk() ) { *reinterpret_cast<RscId *>(rInst.pData) = rRscId; diff --git a/rsc/source/tools/rscdef.cxx b/rsc/source/tools/rscdef.cxx index 0d2595bee4ac..5bf4eae70644 100644 --- a/rsc/source/tools/rscdef.cxx +++ b/rsc/source/tools/rscdef.cxx @@ -99,11 +99,6 @@ bool RscId::operator > ( const RscId& rRscId ) const return GetNumber() > rRscId.GetNumber(); } -RscId::operator sal_Int32() const -{ - return GetNumber(); -} - OString RscId::GetName() const { OStringBuffer aStr; diff --git a/svtools/source/misc/ehdl.cxx b/svtools/source/misc/ehdl.cxx index 3f6e282621b4..60fde45acf6a 100644 --- a/svtools/source/misc/ehdl.cxx +++ b/svtools/source/misc/ehdl.cxx @@ -243,8 +243,8 @@ struct ErrorResource_Impl : private Resource ~ErrorResource_Impl() { FreeResource(); } - operator ResString() { return ResString( aResId ); } - operator bool() { return IsAvailableRes(aResId.SetRT(RSC_STRING)); } + ResString GetResString() { return ResString( aResId ); } + operator bool() { return IsAvailableRes(aResId.SetRT(RSC_STRING)); } }; @@ -266,7 +266,7 @@ void SfxErrorHandler::GetClassString(sal_uLong lClassId, OUString &rStr) ErrorResource_Impl aEr(aId, (sal_uInt16)lClassId); if(aEr) { - rStr = static_cast<ResString>(aEr).GetString(); + rStr = aEr.GetResString().GetString(); } } } @@ -293,7 +293,7 @@ bool SfxErrorHandler::GetErrorString( ErrorResource_Impl aEr(aResId, (sal_uInt16)lErrId); if(aEr) { - ResString aErrorString(aEr); + ResString aErrorString(aEr.GetResString()); sal_uInt16 nResFlags = aErrorString.GetFlags(); if ( nResFlags ) @@ -362,7 +362,7 @@ bool SfxErrorContext::GetString(sal_uLong nErrId, OUString &rStr) ErrorResource_Impl aTestEr( aResId, nCtxId ); if ( aTestEr ) { - rStr = static_cast<ResString>(aTestEr).GetString(); + rStr = aTestEr.GetResString().GetString(); rStr = rStr.replaceAll("$(ARG1)", aArg1); bRet = true; } @@ -377,7 +377,7 @@ bool SfxErrorContext::GetString(sal_uLong nErrId, OUString &rStr) sal_uInt16 nId = ( nErrId & ERRCODE_WARNING_MASK ) ? ERRCTX_WARNING : ERRCTX_ERROR; ResId aSfxResId( RID_ERRCTX, *pMgr ); ErrorResource_Impl aEr( aSfxResId, nId ); - rStr = rStr.replaceAll("$(ERR)", static_cast<ResString>(aEr).GetString()); + rStr = rStr.replaceAll("$(ERR)", aEr.GetResString().GetString()); } } |