2009-02-04 15:25:03 +00:00
|
|
|
/****************************/
|
|
|
|
/* EESchema - libalias.cpp */
|
|
|
|
/****************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* Routines de maintenanace des librairies: gestion des alias des composants
|
2009-02-04 15:25:03 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
/* Variables locales */
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2009-02-04 15:25:03 +00:00
|
|
|
bool BuildAliasData( LibraryStruct* Lib, EDA_LibComponentStruct* component )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************************/
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Create the alias data for the lib component to edit
|
2009-02-04 15:25:03 +00:00
|
|
|
* Alias data is:
|
|
|
|
* alias name
|
|
|
|
* doc string
|
|
|
|
* keywords string
|
|
|
|
* doc file name
|
|
|
|
*
|
|
|
|
* in .m_AliastList
|
|
|
|
* Alias data (4 strings) replace each alias name.
|
|
|
|
*
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-02-04 15:25:03 +00:00
|
|
|
wxArrayString List;
|
|
|
|
LibCmpEntry* CmpEntry;
|
|
|
|
unsigned ii;
|
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
if( component == NULL || Lib == NULL
|
|
|
|
|| component->m_AliasList.GetCount() == 0 )
|
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
List = component->m_AliasList;
|
|
|
|
component->m_AliasList.Clear();
|
|
|
|
for( ii = 0; ii < List.GetCount(); ii++ )
|
|
|
|
{
|
2009-08-27 11:41:56 +00:00
|
|
|
CmpEntry = FindLibPart( List[ii], Lib->m_Name, ALIAS );
|
2009-02-04 15:25:03 +00:00
|
|
|
if( CmpEntry && CmpEntry->Type != ALIAS )
|
|
|
|
{
|
|
|
|
DisplayError( NULL,
|
|
|
|
wxT( "BuildListAlias err: alias is a ROOT entry!" ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( LocateAlias( component->m_AliasList, List[ii] ) < 0 )
|
|
|
|
{
|
|
|
|
/* Alias not found in list: create it (datas must be in this order) */
|
|
|
|
component->m_AliasList.Add( List[ii] );
|
|
|
|
component->m_AliasList.Add( CmpEntry->m_Doc );
|
|
|
|
component->m_AliasList.Add( CmpEntry->m_KeyWord );
|
|
|
|
component->m_AliasList.Add( CmpEntry->m_DocFile );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
2009-02-04 15:25:03 +00:00
|
|
|
int LocateAlias( const wxArrayString& AliasData, const wxString& Name )
|
2007-06-05 12:10:51 +00:00
|
|
|
/***********************************************************************/
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Return an index in alias data list
|
2009-02-04 15:25:03 +00:00
|
|
|
* ( -1 if not found )
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-02-04 15:25:03 +00:00
|
|
|
int index = -1;
|
|
|
|
unsigned ii;
|
|
|
|
|
|
|
|
for( ii = 0; ii < AliasData.GetCount(); ii += ALIAS_NEXT )
|
|
|
|
{
|
|
|
|
if( Name.CmpNoCase( AliasData[ii + ALIAS_NAME].GetData() ) == 0 )
|
|
|
|
{
|
|
|
|
index = ii;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return index;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|