Kaydet (Commit) b24a9f8b authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

make o3tl::strong_int constructor explicit

Could have sworn I did this originally, somehow it got lost.
Also fix a thinko in tools::ResId I introduced in commit
2b70fb58
"Use o3tl::strong_int on RESOURCE_TYPE"

Change-Id: Id3b39962255297010cd1feaaca6d822168311081
Reviewed-on: https://gerrit.libreoffice.org/35108Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 41c7ee5f
...@@ -40,7 +40,7 @@ template <typename UNDERLYING_TYPE, typename PHANTOM_TYPE> ...@@ -40,7 +40,7 @@ template <typename UNDERLYING_TYPE, typename PHANTOM_TYPE>
struct strong_int struct strong_int
{ {
public: public:
strong_int(UNDERLYING_TYPE value) : m_value(value) {} explicit strong_int(UNDERLYING_TYPE value) : m_value(value) {}
strong_int() : m_value(0) {} strong_int() : m_value(0) {}
explicit operator UNDERLYING_TYPE() const { return m_value; } explicit operator UNDERLYING_TYPE() const { return m_value; }
......
...@@ -47,11 +47,11 @@ class SAL_WARN_UNUSED ResId ...@@ -47,11 +47,11 @@ class SAL_WARN_UNUSED ResId
release the Resource context after loading this id. release the Resource context after loading this id.
*/ */
RSHEADER_TYPE* m_pResource; RSHEADER_TYPE* m_pResource;
mutable RESOURCE_TYPE m_nResId; // Resource Identifier mutable sal_uInt32 m_nResId; // Resource Identifier
mutable RESOURCE_TYPE m_nRT; // type for loading (mutable to be set later) mutable RESOURCE_TYPE m_nRT; // type for loading (mutable to be set later)
mutable ResMgr * m_pResMgr; // load from this ResMgr (mutable for setting on demand) mutable ResMgr * m_pResMgr; // load from this ResMgr (mutable for setting on demand)
void ImplInit( RESOURCE_TYPE nId, ResMgr& rMgr, RSHEADER_TYPE* pRes ) void ImplInit( sal_uInt32 nId, ResMgr& rMgr, RSHEADER_TYPE* pRes )
{ {
m_pResource = pRes; m_nResId = nId; m_nRT = RSC_NOTYPE; m_pResMgr = &rMgr; m_pResource = pRes; m_nResId = nId; m_nRT = RSC_NOTYPE; m_pResMgr = &rMgr;
OSL_ENSURE( m_pResMgr != nullptr, "ResId without ResMgr created" ); OSL_ENSURE( m_pResMgr != nullptr, "ResId without ResMgr created" );
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
{ {
ImplInit( 0, rMgr, pRc ); ImplInit( 0, rMgr, pRc );
} }
ResId( RESOURCE_TYPE nId, ResMgr& rMgr ) ResId( sal_uInt32 nId, ResMgr& rMgr )
{ {
ImplInit( nId, rMgr, nullptr ); ImplInit( nId, rMgr, nullptr );
} }
...@@ -89,9 +89,9 @@ public: ...@@ -89,9 +89,9 @@ public:
ResMgr * GetResMgr() const { return m_pResMgr; } ResMgr * GetResMgr() const { return m_pResMgr; }
void ClearResMgr() const { m_pResMgr = nullptr; } void ClearResMgr() const { m_pResMgr = nullptr; }
bool IsAutoRelease() const { return !(sal_uInt32(m_nResId) & RSC_DONTRELEASE); } bool IsAutoRelease() const { return !(m_nResId & RSC_DONTRELEASE); }
sal_uInt32 GetId() const { return sal_uInt32(m_nResId) & ~RSC_DONTRELEASE; } sal_uInt32 GetId() const { return m_nResId & ~RSC_DONTRELEASE; }
RSHEADER_TYPE* GetpResource() const { return m_pResource; } RSHEADER_TYPE* GetpResource() const { return m_pResource; }
TOOLS_DLLPUBLIC OUString toString() const; TOOLS_DLLPUBLIC OUString toString() const;
......
...@@ -36,7 +36,7 @@ private: ...@@ -36,7 +36,7 @@ private:
Index nUniqIndex; Index nUniqIndex;
public: public:
UniqueIndexImpl( Index nStartIndex = 0 ) UniqueIndexImpl( Index nStartIndex = Index(0) )
: maMap(), nUniqIndex(nStartIndex) {} : maMap(), nUniqIndex(nStartIndex) {}
Index Insert( void* p ); Index Insert( void* p );
...@@ -57,7 +57,7 @@ public: ...@@ -57,7 +57,7 @@ public:
using UniqueIndexImpl::Index; using UniqueIndexImpl::Index;
using UniqueIndexImpl::IndexNotFound; using UniqueIndexImpl::IndexNotFound;
UniqueIndex<T>( Index _nStartIndex = 0 ) : UniqueIndexImpl(_nStartIndex) {} UniqueIndex<T>( Index _nStartIndex = Index(0) ) : UniqueIndexImpl(_nStartIndex) {}
Index Insert(T* p) { return UniqueIndexImpl::Insert(p); } Index Insert(T* p) { return UniqueIndexImpl::Insert(p); }
T* Get(Index idx) const { return static_cast<T*>( UniqueIndexImpl::Get(idx) ); } T* Get(Index idx) const { return static_cast<T*>( UniqueIndexImpl::Get(idx) ); }
......
...@@ -41,18 +41,18 @@ enum class MapUnit; ...@@ -41,18 +41,18 @@ enum class MapUnit;
struct WriteRcContext struct WriteRcContext
{ {
FILE * fOutput; FILE * fOutput;
OString aOutputRc; OString aOutputRc;
OString aOutputSysList; OString aOutputSysList;
RscCmdLine* pCmdLine; RscCmdLine* pCmdLine;
}; };
// table for system dependent resources // table for system dependent resources
struct RscSysEntry struct RscSysEntry
{ {
sal_uInt32 nKey; sal_uInt32 nKey;
sal_uInt32 nRscTyp; RESOURCE_TYPE nRscTyp;
OString aFileName; OString aFileName;
sal_uInt32 nTyp; sal_uInt32 nTyp;
sal_uInt32 nRefId; sal_uInt32 nRefId;
}; };
...@@ -129,7 +129,7 @@ public: ...@@ -129,7 +129,7 @@ public:
void SetSysSearchPath( const OString& rStr ) { aSysSearchPath = rStr; } void SetSysSearchPath( const OString& rStr ) { aSysSearchPath = rStr; }
// deletes all resource objects of this file // deletes all resource objects of this file
void Delete( RscFileTab::Index lFileKey ); void Delete( RscFileTab::Index lFileKey );
sal_uInt32 PutSysName( sal_uInt32 nRscTyp, char * pName ); sal_uInt32 PutSysName( RESOURCE_TYPE nRscTyp, char * pName );
void ClearSysNames(); void ClearSysNames();
ERRTYPE WriteRc( WriteRcContext& rContext ); ERRTYPE WriteRc( WriteRcContext& rContext );
void WriteSrc( FILE * fOutput, RscFileTab::Index nFileIndex ); void WriteSrc( FILE * fOutput, RscFileTab::Index nFileIndex );
......
...@@ -44,7 +44,7 @@ class RscTop : public RefNode ...@@ -44,7 +44,7 @@ class RscTop : public RefNode
{ {
RscTop * pSuperClass; RscTop * pSuperClass;
RSCINST aDfltInst; RSCINST aDfltInst;
sal_uInt32 nTypId; RESOURCE_TYPE nTypId;
RscTop * pRefClass; RscTop * pRefClass;
protected: protected:
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
RscTop* GetSuperClass() const RscTop* GetSuperClass() const
{ return pSuperClass; } { return pSuperClass; }
// returns the type identifier // returns the type identifier
sal_uInt32 GetTypId() const RESOURCE_TYPE GetTypId() const
{ return nTypId; }; { return nTypId; };
// returns the super class // returns the super class
bool InHierarchy( RscTop * pClass ); bool InHierarchy( RscTop * pClass );
......
...@@ -200,7 +200,7 @@ void RscTypCont::ClearSysNames() ...@@ -200,7 +200,7 @@ void RscTypCont::ClearSysNames()
aSysLst.clear(); aSysLst.clear();
} }
sal_uInt32 RscTypCont::PutSysName( sal_uInt32 nRscTyp, char * pFileName ) sal_uInt32 RscTypCont::PutSysName( RESOURCE_TYPE nRscTyp, char * pFileName )
{ {
RscSysEntry *pFoundEntry = nullptr; RscSysEntry *pFoundEntry = nullptr;
......
...@@ -467,7 +467,7 @@ bool SwView::InsertGraphicDlg( SfxRequest& rReq ) ...@@ -467,7 +467,7 @@ bool SwView::InsertGraphicDlg( SfxRequest& rReq )
rSh.SetFrameFormat( pFormat ); rSh.SetFrameFormat( pFormat );
} }
RESOURCE_TYPE nResId = 0; sal_uInt32 nResId(0);
switch( nError ) switch( nError )
{ {
case GRFILTER_OPENERROR: case GRFILTER_OPENERROR:
......
...@@ -671,7 +671,7 @@ void ResMgr::RscError_Impl( const sal_Char* pMessage, ResMgr* pResMgr, ...@@ -671,7 +671,7 @@ void ResMgr::RscError_Impl( const sal_Char* pMessage, ResMgr* pResMgr,
aStr.append('\n'); aStr.append('\n');
aStr.append(" Class: "); aStr.append(" Class: ");
aStr.append(OUStringToOString(GetTypeRes_Impl(ResId(nRT, *pNewResMgr)), aStr.append(OUStringToOString(GetTypeRes_Impl(ResId((sal_uInt32)nRT, *pNewResMgr)),
RTL_TEXTENCODING_UTF8)); RTL_TEXTENCODING_UTF8));
aStr.append(", Id: "); aStr.append(", Id: ");
aStr.append(static_cast<sal_Int32>(nId)); aStr.append(static_cast<sal_Int32>(nId));
...@@ -682,7 +682,7 @@ void ResMgr::RscError_Impl( const sal_Char* pMessage, ResMgr* pResMgr, ...@@ -682,7 +682,7 @@ void ResMgr::RscError_Impl( const sal_Char* pMessage, ResMgr* pResMgr,
{ {
aStr.append(" [ Class: "); aStr.append(" [ Class: ");
aStr.append(OUStringToOString(GetTypeRes_Impl( aStr.append(OUStringToOString(GetTypeRes_Impl(
ResId(rResStack[nDepth].pResource->GetRT(), *pNewResMgr)), ResId((sal_uInt32)rResStack[nDepth].pResource->GetRT(), *pNewResMgr)),
RTL_TEXTENCODING_UTF8)); RTL_TEXTENCODING_UTF8));
aStr.append(", Id: "); aStr.append(", Id: ");
aStr.append(static_cast<sal_Int32>( aStr.append(static_cast<sal_Int32>(
......
...@@ -54,10 +54,10 @@ SvCreateInstancePersist SvClassManager::Get( sal_Int32 nClassId ) ...@@ -54,10 +54,10 @@ SvCreateInstancePersist SvClassManager::Get( sal_Int32 nClassId )
SvPersistStream::SvPersistStream( SvClassManager & rMgr, SvStream * pStream ) SvPersistStream::SvPersistStream( SvClassManager & rMgr, SvStream * pStream )
: rClassMgr( rMgr ) : rClassMgr( rMgr )
, pStm( pStream ) , pStm( pStream )
, aPUIdx( 1 ) , aPUIdx( UniqueIndex<SvPersistBase>::Index(1) )
, nStartIdx( 1 ) , nStartIdx( 1 )
{ {
DBG_ASSERT( nStartIdx != 0, "zero index not allowed" ); DBG_ASSERT( nStartIdx != Index(0), "zero index not allowed" );
m_isWritable = true; m_isWritable = true;
if( pStm ) if( pStm )
{ {
...@@ -117,7 +117,7 @@ SvPersistStream::Index SvPersistStream::GetIndex( SvPersistBase * pObj ) const ...@@ -117,7 +117,7 @@ SvPersistStream::Index SvPersistStream::GetIndex( SvPersistBase * pObj ) const
PersistBaseMap::const_iterator it = aPTable.find( pObj ); PersistBaseMap::const_iterator it = aPTable.find( pObj );
if( it == aPTable.end() ) if( it == aPTable.end() )
{ {
return 0; return Index(0);
} }
return it->second; return it->second;
} }
...@@ -357,18 +357,18 @@ static void ReadId ...@@ -357,18 +357,18 @@ static void ReadId
nClassId = 0; nClassId = 0;
rStm.ReadUChar( nHdr ); rStm.ReadUChar( nHdr );
if( nHdr & P_ID_0 ) if( nHdr & P_ID_0 )
nId = 0; nId = SvPersistStream::Index(0);
else else
{ {
if( (nHdr & P_VER_MASK) == 0 ) if( (nHdr & P_VER_MASK) == 0 )
{ {
if( (nHdr & P_DBGUTIL) || !(nHdr & P_OBJ) ) if( (nHdr & P_DBGUTIL) || !(nHdr & P_OBJ) )
nId = SvPersistStream::ReadCompressed( rStm ); nId = SvPersistStream::Index(SvPersistStream::ReadCompressed( rStm ));
else else
nId = 0; nId = SvPersistStream::Index(0);
} }
else if( nHdr & P_ID ) else if( nHdr & P_ID )
nId = SvPersistStream::ReadCompressed( rStm ); nId = SvPersistStream::Index(SvPersistStream::ReadCompressed( rStm ));
if( (nHdr & P_DBGUTIL) || (nHdr & P_OBJ) ) if( (nHdr & P_DBGUTIL) || (nHdr & P_OBJ) )
nClassId = (sal_uInt16)SvPersistStream::ReadCompressed( rStm ); nClassId = (sal_uInt16)SvPersistStream::ReadCompressed( rStm );
...@@ -429,7 +429,7 @@ void SvPersistStream::ReadObj ...@@ -429,7 +429,7 @@ void SvPersistStream::ReadObj
) )
{ {
sal_uInt8 nHdr; sal_uInt8 nHdr;
Index nId = 0; Index nId(0);
sal_uInt16 nClassId; sal_uInt16 nClassId;
rpObj = nullptr; // specification: 0 in case of error rpObj = nullptr; // specification: 0 in case of error
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment