diff --git a/common/plugins/eagle/eagle_parser.cpp b/common/plugins/eagle/eagle_parser.cpp index 3459df2915..d80b7c4664 100644 --- a/common/plugins/eagle/eagle_parser.cpp +++ b/common/plugins/eagle/eagle_parser.cpp @@ -60,6 +60,7 @@ bool substituteVariable( wxString* aText ) else if( *aText == wxT( ">SHEETNR_TOTAL" ) ) *aText = wxT( "${#}" ); else if( *aText == wxT( ">SHEETS_TOTAL" ) ) *aText = wxT( "${##}" ); else if( *aText == wxT( ">SHEET_TOTAL" ) ) *aText = wxT( "${#}/${##}" ); + else if( *aText == wxT( ">SHEET_HEADLINE" ) ) *aText = wxT( "${SHEETNAME}" ); else if( *aText == wxT( ">ASSEMBLY_VARIANT" ) ) *aText = wxT( "${ASSEMBLY_VARIANT}" ); else if( *aText == wxT( ">DRAWING_NAME" ) ) *aText = wxT( "${TITLE}" ); else if( *aText == wxT( ">LAST_DATE_TIME" ) ) *aText = wxT( "${ISSUE_DATE}" ); diff --git a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp index 1536cfec07..efd24ddb9a 100644 --- a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp +++ b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp @@ -2355,16 +2355,26 @@ LIB_TEXT* SCH_EAGLE_PLUGIN::loadSymbolText( std::unique_ptr& aSymbol libtext->SetUnit( aGateNumber ); libtext->SetPosition( VECTOR2I( etext.x.ToSchUnits(), etext.y.ToSchUnits() ) ); - // Eagle supports multiple line text in library symbols. Legacy library symbol text cannot - // contain CRs or LFs. - // - // @todo Split this into multiple text objects and offset the Y position so that it looks - // more like the original Eagle schematic. - wxString text = aLibText->GetNodeContent(); - std::replace( text.begin(), text.end(), '\n', '_' ); - std::replace( text.begin(), text.end(), '\r', '_' ); + const wxString& eagleText = aLibText->GetNodeContent(); + wxString adjustedText; + wxStringTokenizer tokenizer( eagleText, "\r\n" ); - libtext->SetText( text.IsEmpty() ? wxT( "~" ) : text ); + // Strip the whitespace from both ends of each line. + while( tokenizer.HasMoreTokens() ) + { + wxString tmp = tokenizer.GetNextToken().Trim( true ).Trim( false ); + wxString var = tmp.Upper(); + + if( substituteVariable( &var ) ) + tmp = var; + + if( tokenizer.HasMoreTokens() ) + tmp += wxT( "\n" ); + + adjustedText += tmp; + } + + libtext->SetText( adjustedText.IsEmpty() ? wxT( "~" ) : adjustedText ); loadTextAttributes( libtext.get(), etext ); return libtext.release(); @@ -2565,10 +2575,9 @@ SCH_TEXT* SCH_EAGLE_PLUGIN::loadPlainText( wxXmlNode* aSchText ) std::unique_ptr schtext = std::make_unique(); ETEXT etext = ETEXT( aSchText ); - const wxString& thetext = aSchText->GetNodeContent(); - - wxString adjustedText; - wxStringTokenizer tokenizer( thetext, "\r\n" ); + const wxString& eagleText = aSchText->GetNodeContent(); + wxString adjustedText; + wxStringTokenizer tokenizer( eagleText, "\r\n" ); // Strip the whitespace from both ends of each line. while( tokenizer.HasMoreTokens() )