7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

Ensure non handled text properties are never written in .kicad_pcb files

ctl_flags.h: fix two duplicate flag values.
This commit is contained in:
jean-pierre charras 2024-07-14 20:45:40 +02:00
parent a075a80b3c
commit 3bacfacf95
3 changed files with 15 additions and 6 deletions
common
include
pcbnew/pcb_io/kicad_sexpr

View File

@ -940,7 +940,7 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
if( IsItalic() )
aFormatter->Print( 0, " (italic yes)" );
if( GetTextColor() != COLOR4D::UNSPECIFIED )
if( !( aControlBits & CTL_OMIT_COLOR ) && GetTextColor() != COLOR4D::UNSPECIFIED )
{
aFormatter->Print( 0, " (color %d %d %d %s)",
KiROUND( GetTextColor().r * 255.0 ),
@ -971,7 +971,7 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
if( !( aControlBits & CTL_OMIT_HIDE ) && !IsVisible() )
aFormatter->Print( 0, " (hide yes)" );
if( HasHyperlink() )
if( !( aControlBits & CTL_OMIT_HYPERLINK ) && HasHyperlink() )
{
aFormatter->Print( 0, " (href %s)", aFormatter->Quotew( GetHyperlink() ).c_str() );
}

View File

@ -27,18 +27,21 @@
#define CTL_OMIT_EXTRA (1 << 0)
#define CTL_OMIT_NETS (1 << 1)
#define CTL_OMIT_PAD_NETS (1 << 1) ///< Omit pads net names (useless in library)
#define CTL_OMIT_FILTERS (1 << 2)
#define CTL_OMIT_UUIDS (1 << 2) ///< Omit component unique ids (useless in library)
#define CTL_OMIT_FP_UUID (1 << 3) ///< Don't prefix the footprint UUID to the sheet path.
#define CTL_OMIT_INITIAL_COMMENTS (1 << 3) ///< omit FOOTPRINT initial comments
#define CTL_OMIT_PATH (1 << 4) ///< Omit component sheet time stamp (useless in library)
#define CTL_OMIT_AT (1 << 5) ///< Omit position and rotation. (always saved
///< with position 0,0 and rotation = 0 in library).
// If set, when calling EDA_TEXT::Format, disable writing the "hide" keyword in save file
#define CTL_OMIT_HIDE (1 << 6)
#define CTL_OMIT_HIDE (1 << 6) ///< Omit the hide attribute in .kicad_xxx files
#define CTL_OMIT_LIBNAME (1 << 7) ///< Omit lib alias when saving (used for
///< board/not library).
#define CTL_OMIT_FOOTPRINT_VERSION (1 << 8) ///< Omit the version string from the (footprint)
///< sexpr group
#define CTL_OMIT_FILTERS (1 << 9) ///< Omit the ki_fp_filters attribute in .kicad_xxx files
#define CTL_OMIT_INITIAL_COMMENTS (1 << 10) ///< omit FOOTPRINT initial comments
#define CTL_OMIT_COLOR (1 << 11) ///< Omit the color attribute in .kicad_xxx files
#define CTL_OMIT_HYPERLINK (1 << 12) ///< Omit the hyperlink attribute in .kicad_xxx files

View File

@ -1902,7 +1902,13 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TEXT* aText, int aNestLevel ) const
KICAD_FORMAT::FormatUuid( m_out, aText->m_Uuid );
aText->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
int ctl_flags = m_ctl | CTL_OMIT_HIDE;
// Currently, texts have no specific color and no hyperlink.
// so ensure they are never written in kicad_pcb file
ctl_flags |= CTL_OMIT_COLOR | CTL_OMIT_HYPERLINK;
aText->EDA_TEXT::Format( m_out, aNestLevel, ctl_flags );
if( aText->GetFont() && aText->GetFont()->IsOutline() )
formatRenderCache( aText, aNestLevel + 1 );