diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 926d4d49c2..d93c218a90 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -383,7 +383,7 @@ void SCH_SEXPR_PLUGIN::Format( SCH_SHEET* aSheet ) { case SCH_SYMBOL_T: m_out->Print( 0, "\n" ); - saveSymbol( static_cast( item ), nullptr, 1 ); + saveSymbol( static_cast( item ), nullptr, 1, false ); break; case SCH_BITMAP_T: @@ -474,7 +474,7 @@ void SCH_SEXPR_PLUGIN::Format( SCH_SHEET* aSheet ) void SCH_SEXPR_PLUGIN::Format( EE_SELECTION* aSelection, SCH_SHEET_PATH* aSelectionPath, SCH_SHEET_LIST* aFullSheetHierarchy, - OUTPUTFORMATTER* aFormatter ) + OUTPUTFORMATTER* aFormatter, bool aForClipboard ) { wxCHECK( aSelection && aSelectionPath && aFullSheetHierarchy && aFormatter, /* void */ ); @@ -515,7 +515,7 @@ void SCH_SEXPR_PLUGIN::Format( EE_SELECTION* aSelection, SCH_SHEET_PATH* aSelect { m_out->Print( 0, "(lib_symbols\n" ); - for( auto libSymbol : libSymbols ) + for( const std::pair& libSymbol : libSymbols ) SCH_SEXPR_PLUGIN_CACHE::SaveSymbol( libSymbol.second, *m_out, 1, libSymbol.first ); m_out->Print( 0, ")\n\n" ); @@ -534,7 +534,7 @@ void SCH_SEXPR_PLUGIN::Format( EE_SELECTION* aSelection, SCH_SHEET_PATH* aSelect switch( item->Type() ) { case SCH_SYMBOL_T: - saveSymbol( static_cast( item ), aSelectionPath, 0 ); + saveSymbol( static_cast( item ), aSelectionPath, 0, aForClipboard ); aSelectionPath->AppendSymbol( selectedSymbols, static_cast( item ), true, true ); @@ -623,7 +623,7 @@ void SCH_SEXPR_PLUGIN::Format( EE_SELECTION* aSelection, SCH_SHEET_PATH* aSelect void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPath, - int aNestLevel ) + int aNestLevel, bool aForClipboard ) { wxCHECK_RET( aSymbol != nullptr && m_out != nullptr, "" ); @@ -720,19 +720,22 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPa int id = field.GetId(); wxString value = field.GetText(); - // The instance fields are always set to the default instance regardless of the - // sheet instance to prevent file churn. - if( id == REFERENCE_FIELD ) + if( !aForClipboard ) { - field.SetText( aSymbol->GetDefaultInstance().m_Reference ); - } - else if( id == VALUE_FIELD ) - { - field.SetText( aSymbol->GetDefaultInstance().m_Value ); - } - else if( id == FOOTPRINT_FIELD ) - { - field.SetText( aSymbol->GetDefaultInstance().m_Footprint ); + // The instance fields are always set to the default instance regardless of the + // sheet instance to prevent file churn. + if( id == REFERENCE_FIELD ) + { + field.SetText( aSymbol->GetDefaultInstance().m_Reference ); + } + else if( id == VALUE_FIELD ) + { + field.SetText( aSymbol->GetDefaultInstance().m_Value ); + } + else if( id == FOOTPRINT_FIELD ) + { + field.SetText( aSymbol->GetDefaultInstance().m_Footprint ); + } } try diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h index f768249b4e..bd9ec54071 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h @@ -108,7 +108,8 @@ public: void Format( SCH_SHEET* aSheet ); void Format( EE_SELECTION* aSelection, SCH_SHEET_PATH* aSelectionPath, - SCH_SHEET_LIST* aFullSheetHierarchy, OUTPUTFORMATTER* aFormatter ); + SCH_SHEET_LIST* aFullSheetHierarchy, OUTPUTFORMATTER* aFormatter, + bool aForClipboard ); void EnumerateSymbolLib( wxArrayString& aSymbolNameList, const wxString& aLibraryPath, @@ -142,7 +143,8 @@ private: void loadHierarchy( SCH_SHEET* aSheet ); void loadFile( const wxString& aFileName, SCH_SHEET* aSheet ); - void saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPath, int aNestLevel ); + void saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPath, int aNestLevel, + bool aForClipboard ); void saveField( SCH_FIELD* aField, int aNestLevel ); void saveBitmap( SCH_BITMAP* aBitmap, int aNestLevel ); void saveSheet( SCH_SHEET* aSheet, int aNestLevel ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index c0c8c94926..bda1b7ae31 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -1388,7 +1388,7 @@ bool SCH_EDITOR_CONTROL::doCopy( bool aUseLocalClipboard ) SCH_SHEET_LIST hierarchy = schematic.GetSheets(); SCH_SHEET_PATH selPath = m_frame->GetCurrentSheet(); - plugin.Format( &selection, &selPath, &hierarchy, &formatter ); + plugin.Format( &selection, &selPath, &hierarchy, &formatter, true ); if( aUseLocalClipboard ) {