Recurse into title block fields when resovling text vars.
Fixes https://gitlab.com/kicad/code/kicad/issues/4554
This commit is contained in:
parent
9f2be3714f
commit
2c0f3c8088
|
@ -92,64 +92,66 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
|
||||||
std::function<bool( wxString* )> wsResolver =
|
std::function<bool( wxString* )> wsResolver =
|
||||||
[ this ]( wxString* token ) -> bool
|
[ this ]( wxString* token ) -> bool
|
||||||
{
|
{
|
||||||
|
bool tokenUpdated = false;
|
||||||
|
|
||||||
if( token->IsSameAs( wxT( "KICAD_VERSION" ) ) )
|
if( token->IsSameAs( wxT( "KICAD_VERSION" ) ) )
|
||||||
{
|
{
|
||||||
*token = wxString::Format( wxT( "%s%s %s" ),
|
*token = wxString::Format( wxT( "%s%s %s" ),
|
||||||
productName,
|
productName,
|
||||||
Pgm().App().GetAppName(),
|
Pgm().App().GetAppName(),
|
||||||
GetBuildVersion() );
|
GetBuildVersion() );
|
||||||
return true;
|
tokenUpdated = true;
|
||||||
}
|
}
|
||||||
else if( token->IsSameAs( wxT( "#" ) ) )
|
else if( token->IsSameAs( wxT( "#" ) ) )
|
||||||
{
|
{
|
||||||
*token = wxString::Format( wxT( "%d" ), m_sheetNumber );
|
*token = wxString::Format( wxT( "%d" ), m_sheetNumber );
|
||||||
return true;
|
tokenUpdated = true;
|
||||||
}
|
}
|
||||||
else if( token->IsSameAs( wxT( "##" ) ) )
|
else if( token->IsSameAs( wxT( "##" ) ) )
|
||||||
{
|
{
|
||||||
*token = wxString::Format( wxT( "%d" ), m_sheetCount );
|
*token = wxString::Format( wxT( "%d" ), m_sheetCount );
|
||||||
return true;
|
tokenUpdated = true;
|
||||||
}
|
}
|
||||||
else if( token->IsSameAs( wxT( "SHEETNAME" ) ) )
|
else if( token->IsSameAs( wxT( "SHEETNAME" ) ) )
|
||||||
{
|
{
|
||||||
*token = m_sheetFullName;
|
*token = m_sheetFullName;
|
||||||
return true;
|
tokenUpdated = true;
|
||||||
}
|
}
|
||||||
else if( token->IsSameAs( wxT( "FILENAME" ) ) )
|
else if( token->IsSameAs( wxT( "FILENAME" ) ) )
|
||||||
{
|
{
|
||||||
wxFileName fn( m_fileName );
|
wxFileName fn( m_fileName );
|
||||||
*token = fn.GetFullName();
|
*token = fn.GetFullName();
|
||||||
return true;
|
tokenUpdated = true;
|
||||||
}
|
}
|
||||||
else if( token->IsSameAs( wxT( "PAPER" ) ) )
|
else if( token->IsSameAs( wxT( "PAPER" ) ) )
|
||||||
{
|
{
|
||||||
*token = m_paperFormat ? *m_paperFormat : wxString( "" );
|
*token = m_paperFormat ? *m_paperFormat : wxString( "" );
|
||||||
return true;
|
tokenUpdated = true;
|
||||||
}
|
}
|
||||||
else if( token->IsSameAs( wxT( "LAYER" ) ) )
|
else if( token->IsSameAs( wxT( "LAYER" ) ) )
|
||||||
{
|
{
|
||||||
*token = m_sheetLayer ? *m_sheetLayer : wxString( "" );
|
*token = m_sheetLayer ? *m_sheetLayer : wxString( "" );
|
||||||
return true;
|
tokenUpdated = true;
|
||||||
}
|
}
|
||||||
else if( token->IsSameAs( wxT( "ISSUE_DATE" ) ) )
|
else if( token->IsSameAs( wxT( "ISSUE_DATE" ) ) )
|
||||||
{
|
{
|
||||||
*token = m_titleBlock ? m_titleBlock->GetDate() : wxString( "" );
|
*token = m_titleBlock ? m_titleBlock->GetDate() : wxString( "" );
|
||||||
return true;
|
tokenUpdated = true;
|
||||||
}
|
}
|
||||||
else if( token->IsSameAs( wxT( "REVISION" ) ) )
|
else if( token->IsSameAs( wxT( "REVISION" ) ) )
|
||||||
{
|
{
|
||||||
*token = m_titleBlock ? m_titleBlock->GetRevision() : wxString( "" );
|
*token = m_titleBlock ? m_titleBlock->GetRevision() : wxString( "" );
|
||||||
return true;
|
tokenUpdated = true;
|
||||||
}
|
}
|
||||||
else if( token->IsSameAs( wxT( "TITLE" ) ) )
|
else if( token->IsSameAs( wxT( "TITLE" ) ) )
|
||||||
{
|
{
|
||||||
*token = m_titleBlock ? m_titleBlock->GetTitle() : wxString( "" );
|
*token = m_titleBlock ? m_titleBlock->GetTitle() : wxString( "" );
|
||||||
return true;
|
tokenUpdated = true;
|
||||||
}
|
}
|
||||||
else if( token->IsSameAs( wxT( "COMPANY" ) ) )
|
else if( token->IsSameAs( wxT( "COMPANY" ) ) )
|
||||||
{
|
{
|
||||||
*token = m_titleBlock ? m_titleBlock->GetCompany() : wxString( "" );
|
*token = m_titleBlock ? m_titleBlock->GetCompany() : wxString( "" );
|
||||||
return true;
|
tokenUpdated = true;
|
||||||
}
|
}
|
||||||
else if( token->Left( token->Len() - 1 ).IsSameAs( wxT( "COMMENT" ) ) )
|
else if( token->Left( token->Len() - 1 ).IsSameAs( wxT( "COMMENT" ) ) )
|
||||||
{
|
{
|
||||||
|
@ -169,10 +171,16 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase )
|
||||||
case '9':
|
case '9':
|
||||||
*token = m_titleBlock ? m_titleBlock->GetComment( c - '0' )
|
*token = m_titleBlock ? m_titleBlock->GetComment( c - '0' )
|
||||||
: wxString( "" );
|
: wxString( "" );
|
||||||
return true;
|
tokenUpdated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( tokenUpdated )
|
||||||
|
{
|
||||||
|
*token = ExpandTextVars( *token, nullptr, m_project );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue