@ -109,7 +109,11 @@ CSheetId::CSheetId( const string& sheetName )
CSheetId : : CSheetId ( const std : : string & sheetName , const std : : string & defaultType )
CSheetId : : CSheetId ( const std : : string & sheetName , const std : : string & defaultType )
{
{
if ( CFile : : getExtension ( sheetName ) = = " " & & defaultType ! = " " )
if ( CFile : : getExtension ( sheetName ) = = " " & & defaultType ! = " " )
* this = CSheetId ( sheetName + " . " + defaultType ) ;
{
std : : string withType = sheetName + " . " + defaultType ;
* this = CSheetId ( withType ) ;
nldebug ( " SHEETID: Constructing CSheetId from name '%s' without explicit type, defaulting as '%s' to '%s' " , sheetName . c_str ( ) , defaultType . c_str ( ) , withType . c_str ( ) ) ;
}
else
else
* this = CSheetId ( sheetName ) ;
* this = CSheetId ( sheetName ) ;
}
}
@ -131,6 +135,7 @@ bool CSheetId::buildSheetId(const std::string& sheetName)
if ( it = = _DevSheetNameToId . end ( ) )
if ( it = = _DevSheetNameToId . end ( ) )
{
{
// Create a new dynamic sheet ID.
// Create a new dynamic sheet ID.
nldebug ( " SHEETID: Creating a new dynamic sheet id for '%s' " , sheetName . c_str ( ) ) ;
std : : string sheetType = CFile : : getExtension ( sheetNameLc ) ;
std : : string sheetType = CFile : : getExtension ( sheetNameLc ) ;
std : : string sheetName = CFile : : getFilenameWithoutExtension ( sheetNameLc ) ;
std : : string sheetName = CFile : : getFilenameWithoutExtension ( sheetNameLc ) ;
std : : map < std : : string , uint32 > : : iterator tit = _DevTypeNameToId . find ( sheetType ) ;
std : : map < std : : string , uint32 > : : iterator tit = _DevTypeNameToId . find ( sheetType ) ;
@ -149,7 +154,9 @@ bool CSheetId::buildSheetId(const std::string& sheetName)
_DevSheetIdToName [ typeId ] . push_back ( sheetName ) ;
_DevSheetIdToName [ typeId ] . push_back ( sheetName ) ;
_Id . IdInfos . Type = typeId ;
_Id . IdInfos . Type = typeId ;
_Id . IdInfos . Id = _DevSheetIdToName [ typeId ] . size ( ) - 1 ;
_Id . IdInfos . Id = _DevSheetIdToName [ typeId ] . size ( ) - 1 ;
// nldebug("SHEETID: Type %i, id %i, sheetid %i", _Id.IdInfos.Type, _Id.IdInfos.Id, _Id.Id);
_DevSheetNameToId [ sheetNameLc ] = _Id . Id ;
_DevSheetNameToId [ sheetNameLc ] = _Id . Id ;
return true ;
}
}
_Id . Id = it - > second ;
_Id . Id = it - > second ;
return true ;
return true ;
@ -326,7 +333,8 @@ void CSheetId::init(bool removeUnknownSheet)
// allow multiple calls to init in case libraries depending on sheetid call this init from their own
// allow multiple calls to init in case libraries depending on sheetid call this init from their own
if ( _Initialised )
if ( _Initialised )
{
{
nlassert ( ! _DontHaveSheetKnowledge ) ;
if ( _DontHaveSheetKnowledge )
nlinfo ( " SHEETID: CSheetId is already initialized without sheet_id.bin " ) ;
return ;
return ;
}
}
@ -357,8 +365,9 @@ void CSheetId::initWithoutSheet()
_DevSheetIdToName [ 0 ] . push_back ( " unknown " ) ;
_DevSheetIdToName [ 0 ] . push_back ( " unknown " ) ;
_DevSheetNameToId [ " unknown.unknown " ] = 0 ; */
_DevSheetNameToId [ " unknown.unknown " ] = 0 ; */
CSheetId unknown = CSheetId ( " unknown.unknown " ) ;
CSheetId unknownunknown = CSheetId ( " unknown.unknown " ) ;
nlassert ( unknown = = CSheetId : : Unknown ) ;
// nldebug("SHEETID: unknown: %i, Unknown: %i", unknownunknown._Id, Unknown._Id);
nlassert ( unknownunknown = = CSheetId : : Unknown ) ;
}
}