eeschema: fixing title block variable expanding in text objects

Also fixing an off-by-one error, which also affects pcbnew.

Fixes https://gitlab.com/kicad/code/kicad/issues/7489
This commit is contained in:
Zoltan Gyarmati 2021-02-12 17:23:24 +01:00 committed by Jeff Young
parent f88be65825
commit f997deec75
4 changed files with 29 additions and 15 deletions

View File

@ -94,20 +94,7 @@ void WS_DRAW_ITEM_LIST::GetTextVars( wxArrayString* aVars )
aVars->push_back( wxT( "FILENAME" ) );
aVars->push_back( wxT( "PAPER" ) );
aVars->push_back( wxT( "LAYER" ) );
aVars->push_back( wxT( "ISSUE_DATE" ) );
aVars->push_back( wxT( "REVISION" ) );
aVars->push_back( wxT( "TITLE" ) );
aVars->push_back( wxT( "COMPANY" ) );
aVars->push_back( wxT( "COMMENT0" ) );
aVars->push_back( wxT( "COMMENT1" ) );
aVars->push_back( wxT( "COMMENT2" ) );
aVars->push_back( wxT( "COMMENT3" ) );
aVars->push_back( wxT( "COMMENT4" ) );
aVars->push_back( wxT( "COMMENT5" ) );
aVars->push_back( wxT( "COMMENT6" ) );
aVars->push_back( wxT( "COMMENT7" ) );
aVars->push_back( wxT( "COMMENT8" ) );
aVars->push_back( wxT( "COMMENT9" ) );
TITLE_BLOCK::GetContextualTextVars( aVars );
}

View File

@ -70,6 +70,24 @@ void TITLE_BLOCK::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aCont
}
}
void TITLE_BLOCK::GetContextualTextVars( wxArrayString* aVars )
{
aVars->push_back( wxT( "ISSUE_DATE" ) );
aVars->push_back( wxT( "REVISION" ) );
aVars->push_back( wxT( "TITLE" ) );
aVars->push_back( wxT( "COMPANY" ) );
aVars->push_back( wxT( "COMMENT0" ) );
aVars->push_back( wxT( "COMMENT1" ) );
aVars->push_back( wxT( "COMMENT2" ) );
aVars->push_back( wxT( "COMMENT3" ) );
aVars->push_back( wxT( "COMMENT4" ) );
aVars->push_back( wxT( "COMMENT5" ) );
aVars->push_back( wxT( "COMMENT6" ) );
aVars->push_back( wxT( "COMMENT7" ) );
aVars->push_back( wxT( "COMMENT8" ) );
aVars->push_back( wxT( "COMMENT9" ) );
}
bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) const
{
@ -111,7 +129,7 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c
case '7':
case '8':
case '9':
*aToken = GetComment( c - '0' );
*aToken = GetComment( c - '1' );
tokenUpdated = true;
}
}

View File

@ -201,6 +201,7 @@ void SCH_SHEET::GetContextualTextVars( wxArrayString* aVars ) const
aVars->push_back( wxT( "#" ) );
aVars->push_back( wxT( "##" ) );
m_screen->GetTitleBlock().GetContextualTextVars( aVars );
}
@ -224,6 +225,13 @@ bool SCH_SHEET::ResolveTextVar( wxString* token, int aDepth ) const
}
}
PROJECT *project = &Schematic()->Prj();
if( m_screen->GetTitleBlock().TextVarResolver( token, project ) )
{
return true;
}
if( token->IsSameAs( wxT( "#" ) ) )
{
for( const SCH_SHEET_PATH& sheet : Schematic()->GetSheets() )

View File

@ -116,6 +116,7 @@ public:
m_tbTexts.Clear();
}
static void GetContextualTextVars( wxArrayString* aVars );
bool TextVarResolver( wxString* aToken, const PROJECT* aProject ) const;
/**