[Libreoffice-commits] core.git: i18npool/source rsc/inc rsc/source svtools/source
Noel Grandin
noel at peralex.com
Tue Oct 11 08:48:36 UTC 2016
i18npool/source/calendar/calendar_jewish.cxx | 22 +++++++++++-----------
rsc/inc/rscclobj.hxx | 2 +-
rsc/inc/rscdef.hxx | 1 -
rsc/inc/rscerror.h | 4 ++--
rsc/source/parser/erscerr.cxx | 8 ++++----
rsc/source/parser/rsclex.cxx | 2 +-
rsc/source/parser/rscyacc.y | 6 +++---
rsc/source/res/rscclobj.cxx | 4 ++--
rsc/source/res/rsccont.cxx | 6 +++---
rsc/source/res/rscmgr.cxx | 2 +-
rsc/source/res/rscrange.cxx | 2 +-
rsc/source/tools/rscdef.cxx | 5 -----
svtools/source/misc/ehdl.cxx | 12 ++++++------
13 files changed, 35 insertions(+), 41 deletions(-)
New commits:
commit d0304a8f57b3fe0065193a2a3f7089f414b1ffd9
Author: Noel Grandin <noel at peralex.com>
Date: Tue Oct 11 08:15:05 2016 +0200
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 at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/i18npool/source/calendar/calendar_jewish.cxx b/i18npool/source/calendar/calendar_jewish.cxx
index 19b62d3..a060aa9 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 eeb694f..7bbc5f1 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 279be92..c9a2f9e 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 758cf96..f0f9845 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 30c9119..ce67dfd 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 a1a3232..5d6040e 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 bf02089..8898f21 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 993be7f..80969f7 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 a487670..1f4ce70 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 2de220d..33f8058 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 d243ca8..1f99bed 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 0d2595b..5bf4eae 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 3f6e282..60fde45 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());
}
}
More information about the Libreoffice-commits
mailing list