Fix issue with predefined variable texts ${COMMENT0} to ${COMMENT9}

- remove ${COMMENT0}, that was broken (returned the same as ${COMPANY}.
- So ${COMMENT1} to ${COMMENT9} are only recognized for Comment1 to Comment9
  in page settings dlg, and are equivalent to our old %C0 to %C8 format string
- fix a minor coding style issue.
Fixes #7642
https://gitlab.com/kicad/code/kicad/issues/7642
This commit is contained in:
jean-pierre charras 2021-02-21 18:27:28 +01:00
parent 18d4d517b0
commit f43c639a4d
3 changed files with 30 additions and 34 deletions

View File

@ -168,16 +168,15 @@ wxString convertLegacyVariableRefs( const wxString& aTextbase )
switch( format )
{
case '0': msg += wxT( "${COMMENT0}" ); break;
case '1': msg += wxT( "${COMMENT1}" ); break;
case '2': msg += wxT( "${COMMENT2}" ); break;
case '3': msg += wxT( "${COMMENT3}" ); break;
case '4': msg += wxT( "${COMMENT4}" ); break;
case '5': msg += wxT( "${COMMENT5}" ); break;
case '6': msg += wxT( "${COMMENT6}" ); break;
case '7': msg += wxT( "${COMMENT7}" ); break;
case '8': msg += wxT( "${COMMENT8}" ); break;
case '9': msg += wxT( "${COMMENT9}" ); break;
case '0': msg += wxT( "${COMMENT1}" ); break;
case '1': msg += wxT( "${COMMENT2}" ); break;
case '2': msg += wxT( "${COMMENT3}" ); break;
case '3': msg += wxT( "${COMMENT4}" ); break;
case '4': msg += wxT( "${COMMENT5}" ); break;
case '5': msg += wxT( "${COMMENT6}" ); break;
case '6': msg += wxT( "${COMMENT7}" ); break;
case '7': msg += wxT( "${COMMENT8}" ); break;
case '8': msg += wxT( "${COMMENT9}" ); break;
}
break;

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
*
* This program is free software; you can redistribute it and/or
@ -76,7 +76,6 @@ void TITLE_BLOCK::GetContextualTextVars( wxArrayString* aVars )
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" ) );
@ -119,7 +118,6 @@ bool TITLE_BLOCK::TextVarResolver( wxString* aToken, const PROJECT* aProject ) c
switch( c )
{
case '0':
case '1':
case '2':
case '3':

View File

@ -1,7 +1,9 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Dick Hollenbeck
*
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -34,21 +36,18 @@ class PROJECT;
/**
* Hold the information shown in the lower right corner of a plot, printout, or
* editing view.
*
* @author Dick Hollenbeck
*/
class TITLE_BLOCK
{
// Texts are stored in wxArraystring.
// textsIdx gives the index of known texts in
// this array
enum textsIdx
// TEXTS_IDX gives the index of known texts in this array
enum TEXTS_IDX
{
titleIdx = 0,
dateIdx,
revisionIdx,
companyIdx,
m_commentIdx
TITLE_IDX = 0,
DATE_IDX,
REVISION_IDX,
COMPANY_IDX,
COMMENT1_IDX // idx of the first comment: one can have more than 1 comment
};
public:
@ -58,12 +57,12 @@ public:
void SetTitle( const wxString& aTitle )
{
setTbText( titleIdx, aTitle );
setTbText( TITLE_IDX, aTitle );
}
const wxString& GetTitle() const
{
return getTbText( titleIdx );
return getTbText( TITLE_IDX );
}
/**
@ -71,43 +70,43 @@ public:
*/
void SetDate( const wxString& aDate )
{
setTbText( dateIdx, aDate );
setTbText( DATE_IDX, aDate );
}
const wxString& GetDate() const
{
return getTbText( dateIdx );
return getTbText( DATE_IDX );
}
void SetRevision( const wxString& aRevision )
{
setTbText( revisionIdx, aRevision );
setTbText( REVISION_IDX, aRevision );
}
const wxString& GetRevision() const
{
return getTbText( revisionIdx );
return getTbText( REVISION_IDX );
}
void SetCompany( const wxString& aCompany )
{
setTbText( companyIdx, aCompany );
setTbText( COMPANY_IDX, aCompany );
}
const wxString& GetCompany() const
{
return getTbText( companyIdx );
return getTbText( COMPANY_IDX );
}
void SetComment( int aIdx, const wxString& aComment )
{
aIdx += m_commentIdx;
aIdx += COMMENT1_IDX;
return setTbText( aIdx, aComment );
}
const wxString& GetComment( int aIdx ) const
{
aIdx += m_commentIdx;
aIdx += COMMENT1_IDX;
return getTbText( aIdx );
}