Substitute variables in PDF plotter URI links and add file:// URI handler.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14250

(cherry picked from commit 43c3cd57eb)
This commit is contained in:
Wayne Stambaugh
2024-11-08 14:55:19 -05:00
parent b80334baa1
commit f8d694e4d0
10 changed files with 49 additions and 21 deletions
+20 -2
View File
@@ -7,7 +7,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 Lorenzo Marcantonio, [email protected]
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023, 2024 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
@@ -37,7 +37,8 @@
#include <wx/datstrm.h>
#include <advanced_config.h>
#include <eda_text.h> // for IsGotoPageHref
#include <common.h> // ResolveUriByEnvVars
#include <eda_text.h> // for IsGotoPageHref
#include <font/font.h>
#include <core/ignore.h>
#include <macros.h>
@@ -1332,6 +1333,9 @@ bool PDF_PLOTTER::EndPlot()
{
wxString href = property.substr( property.Find( "http:" ) );
if( m_project )
href = ResolveUriByEnvVars( href, m_project );
js += wxString::Format( wxT( "[\"%s\", \"%s\"],\n" ),
EscapeString( property, CTX_JS_STR ),
EscapeString( href, CTX_JS_STR ) );
@@ -1340,6 +1344,20 @@ bool PDF_PLOTTER::EndPlot()
{
wxString href = property.substr( property.Find( "https:" ) );
if( m_project )
href = ResolveUriByEnvVars( href, m_project );
js += wxString::Format( wxT( "[\"%s\", \"%s\"],\n" ),
EscapeString( property, CTX_JS_STR ),
EscapeString( href, CTX_JS_STR ) );
}
else if( property.Find( "file:" ) >= 0 )
{
wxString href = property.substr( property.Find( "file:" ) );
if( m_project )
href = ResolveUriByEnvVars( href, m_project );
js += wxString::Format( wxT( "[\"%s\", \"%s\"],\n" ),
EscapeString( property, CTX_JS_STR ),
EscapeString( href, CTX_JS_STR ) );