From 2c0f3c8088aa74e81b3f2298660aecded991bd09 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 28 May 2020 17:35:41 +0100 Subject: [PATCH] Recurse into title block fields when resovling text vars. Fixes https://gitlab.com/kicad/code/kicad/issues/4554 --- common/page_layout/ws_painter.cpp | 32 +++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/common/page_layout/ws_painter.cpp b/common/page_layout/ws_painter.cpp index eaec92dbbd..b9e1e679ea 100644 --- a/common/page_layout/ws_painter.cpp +++ b/common/page_layout/ws_painter.cpp @@ -92,64 +92,66 @@ wxString WS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase ) std::function wsResolver = [ this ]( wxString* token ) -> bool { + bool tokenUpdated = false; + if( token->IsSameAs( wxT( "KICAD_VERSION" ) ) ) { *token = wxString::Format( wxT( "%s%s %s" ), productName, Pgm().App().GetAppName(), GetBuildVersion() ); - return true; + tokenUpdated = true; } else if( token->IsSameAs( wxT( "#" ) ) ) { *token = wxString::Format( wxT( "%d" ), m_sheetNumber ); - return true; + tokenUpdated = true; } else if( token->IsSameAs( wxT( "##" ) ) ) { *token = wxString::Format( wxT( "%d" ), m_sheetCount ); - return true; + tokenUpdated = true; } else if( token->IsSameAs( wxT( "SHEETNAME" ) ) ) { *token = m_sheetFullName; - return true; + tokenUpdated = true; } else if( token->IsSameAs( wxT( "FILENAME" ) ) ) { wxFileName fn( m_fileName ); *token = fn.GetFullName(); - return true; + tokenUpdated = true; } else if( token->IsSameAs( wxT( "PAPER" ) ) ) { *token = m_paperFormat ? *m_paperFormat : wxString( "" ); - return true; + tokenUpdated = true; } else if( token->IsSameAs( wxT( "LAYER" ) ) ) { *token = m_sheetLayer ? *m_sheetLayer : wxString( "" ); - return true; + tokenUpdated = true; } else if( token->IsSameAs( wxT( "ISSUE_DATE" ) ) ) { *token = m_titleBlock ? m_titleBlock->GetDate() : wxString( "" ); - return true; + tokenUpdated = true; } else if( token->IsSameAs( wxT( "REVISION" ) ) ) { *token = m_titleBlock ? m_titleBlock->GetRevision() : wxString( "" ); - return true; + tokenUpdated = true; } else if( token->IsSameAs( wxT( "TITLE" ) ) ) { *token = m_titleBlock ? m_titleBlock->GetTitle() : wxString( "" ); - return true; + tokenUpdated = true; } else if( token->IsSameAs( wxT( "COMPANY" ) ) ) { *token = m_titleBlock ? m_titleBlock->GetCompany() : wxString( "" ); - return true; + tokenUpdated = true; } 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': *token = m_titleBlock ? m_titleBlock->GetComment( c - '0' ) : wxString( "" ); - return true; + tokenUpdated = true; } } + if( tokenUpdated ) + { + *token = ExpandTextVars( *token, nullptr, m_project ); + return true; + } + return false; };