Kaydet (Commit) bda95539 authored tarafından Michael Meeks's avatar Michael Meeks

PPD parsing: set default as well as value, add more parsing info.

Change-Id: I44ea2518d957b5ceee70df1b9a15779ffd5eb7a4
Reviewed-on: https://gerrit.libreoffice.org/38317Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 97fa7024
...@@ -473,7 +473,8 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter ) ...@@ -473,7 +473,8 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter )
SAL_INFO("vcl.unx.print", "ppdOpenFile failed, falling back to generic driver"); SAL_INFO("vcl.unx.print", "ppdOpenFile failed, falling back to generic driver");
// remove temporary PPD file // remove temporary PPD file
unlink( aPPDFile.getStr() ); if (!getenv("SAL_CUPS_PPD_RETAIN_TMP"))
unlink( aPPDFile.getStr() );
} }
else else
SAL_INFO("vcl.unx.print", "cupsGetPPD failed, falling back to generic driver"); SAL_INFO("vcl.unx.print", "cupsGetPPD failed, falling back to generic driver");
...@@ -490,6 +491,7 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter ) ...@@ -490,6 +491,7 @@ const PPDParser* CUPSManager::createCUPSParser( const OUString& rPrinter )
{ {
// get the default PPD // get the default PPD
pNewParser = PPDParser::getParser( "SGENPRT" ); pNewParser = PPDParser::getParser( "SGENPRT" );
SAL_WARN("vcl.unx.print", "Parsing default SGENPRT PPD" );
PrinterInfo& rInfo = m_aPrinters[ aPrinter ].m_aInfo; PrinterInfo& rInfo = m_aPrinters[ aPrinter ].m_aInfo;
......
...@@ -548,6 +548,10 @@ const PPDParser* PPDParser::getParser( const OUString& rFile ) ...@@ -548,6 +548,10 @@ const PPDParser* PPDParser::getParser( const OUString& rFile )
<< rFile << "\" !"); << rFile << "\" !");
return nullptr; return nullptr;
} }
else
SAL_INFO("vcl.unx.print", "Parsing printer info from \""
<< rFile << "\" !");
PPDCache &rPPDCache = thePPDCache::get(); PPDCache &rPPDCache = thePPDCache::get();
for( ::std::list< PPDParser* >::const_iterator it = rPPDCache.aAllParsers.begin(); it != rPPDCache.aAllParsers.end(); ++it ) for( ::std::list< PPDParser* >::const_iterator it = rPPDCache.aAllParsers.begin(); it != rPPDCache.aAllParsers.end(); ++it )
...@@ -865,6 +869,9 @@ void PPDParser::parse( ::std::list< OString >& rLines ) ...@@ -865,6 +869,9 @@ void PPDParser::parse( ::std::list< OString >& rLines )
{ {
OString aCurrentLine( *line ); OString aCurrentLine( *line );
++line; ++line;
SAL_INFO("vcl.unx.print", "Parse line '" << aCurrentLine << "'");
if (aCurrentLine.getLength() < 2 || aCurrentLine[0] != '*') if (aCurrentLine.getLength() < 2 || aCurrentLine[0] != '*')
continue; continue;
if( aCurrentLine[1] == '%' ) if( aCurrentLine[1] == '%' )
...@@ -1124,6 +1131,7 @@ void PPDParser::parse( ::std::list< OString >& rLines ) ...@@ -1124,6 +1131,7 @@ void PPDParser::parse( ::std::list< OString >& rLines )
OString aLine(*line); OString aLine(*line);
if (aLine.startsWith("*Default")) if (aLine.startsWith("*Default"))
{ {
SAL_INFO("vcl.unx.print", "Found a default: '" << aLine << "'");
OUString aKey(OStringToOUString(aLine.copy(8), RTL_TEXTENCODING_MS_1252)); OUString aKey(OStringToOUString(aLine.copy(8), RTL_TEXTENCODING_MS_1252));
sal_Int32 nPos = aKey.indexOf( ':' ); sal_Int32 nPos = aKey.indexOf( ':' );
if( nPos != -1 ) if( nPos != -1 )
...@@ -1148,6 +1156,7 @@ void PPDParser::parse( ::std::list< OString >& rLines ) ...@@ -1148,6 +1156,7 @@ void PPDParser::parse( ::std::list< OString >& rLines )
// so invent that key here and have a default value // so invent that key here and have a default value
PPDKey* pKey = new PPDKey( aKey ); PPDKey* pKey = new PPDKey( aKey );
pKey->insertValue( aOption, eInvocation /*or what ?*/ ); pKey->insertValue( aOption, eInvocation /*or what ?*/ );
pKey->m_pDefaultValue = pKey->getValue( aOption );
insertKey( aKey, pKey ); insertKey( aKey, pKey );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment