diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2015-10-27 11:06:22 +0100 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2015-10-28 12:48:10 +0000 |
commit | 2f03a169d2311ed4337103d19f33173e997d0f40 (patch) | |
tree | 6247badda7002d75152067c3336bd7282a8f1517 /vcl | |
parent | 40cfb7780291a9ba5ca9be54371a2aa30db7a8eb (diff) |
tdf#94022 Print dialog: hide Installable Options
Options specified in PPD files can be grouped using the
keywords "OpenGroup" and "CloseGroup".
The keyword "InstallableOptions" is used as a group name
for a group containing options that define
optional hardware features of the printer that can
be present or not (s. section 5.4 in version 4.3 of
the PPD specification).
As they are not print job specific, it is recommended
not to show them in the print dialog.
To be able to distinguish those options, the
PPD group name was added as an attribute to the PPDKey
class.
Reviewed-on: https://gerrit.libreoffice.org/19623
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
(cherry picked from commit f8d0dc09e15b36ae83a5e89280d1f7fbc01da48b)
Conflicts:
include/vcl/ppdparser.hxx
Change-Id: I4a3abf23a711ad98556c0b608a07ef0a91e77e2b
Reviewed-on: https://gerrit.libreoffice.org/19630
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Tested-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/generic/print/prtsetup.cxx | 11 | ||||
-rw-r--r-- | vcl/unx/generic/printer/ppdparser.cxx | 40 |
2 files changed, 45 insertions, 6 deletions
diff --git a/vcl/generic/print/prtsetup.cxx b/vcl/generic/print/prtsetup.cxx index 8a5fd70c82f6..6aadc0a7f013 100644 --- a/vcl/generic/print/prtsetup.cxx +++ b/vcl/generic/print/prtsetup.cxx @@ -371,12 +371,19 @@ RTSDevicePage::RTSDevicePage( RTSDialog* pParent ) for( int i = 0; i < m_pParent->m_aJobData.m_pParser->getKeys(); i++ ) { const PPDKey* pKey = m_pParent->m_aJobData.m_pParser->getKey( i ); + + // skip options already shown somewhere else + // also skip options from the "InstallableOptions" PPD group + // Options in that group define hardware features that are not + // job-specific and should better be handled in the system-wide + // printer configuration. Keyword is defined in PPD specification + // (version 4.3), section 5.4. if( pKey->isUIKey() && pKey->getKey() != "PageSize" && pKey->getKey() != "InputSlot" && pKey->getKey() != "PageRegion" && - pKey->getKey() != "Duplex" - ) + pKey->getKey() != "Duplex" && + pKey->getGroup() != "InstallableOptions") { OUString aEntry( m_pParent->m_aJobData.m_pParser->translateKey( pKey->getKey() ) ); sal_uInt16 nPos = m_pPPDKeyBox->InsertEntry( aEntry ); diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index c1de3696f5c4..9d22a95bc6f7 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -875,8 +875,22 @@ namespace void PPDParser::parse( ::std::list< OString >& rLines ) { + // Name for PPD group into which all options are put for which the PPD + // does not explicitly define a group. + // This is similar to how CUPS handles it, + // s. Sweet, Michael R. (2001): Common UNIX Printing System, p. 251: + // "Each option in turn is associated with a group stored in the + // ppd_group_t structure. Groups can be specified in the PPD file; if an + // option is not associated with a group, it is put in a "General" or + // "Extra" group depending on the option. + static const OString aDefaultPPDGroupName("General"); + std::list< OString >::iterator line = rLines.begin(); PPDParser::hash_type::const_iterator keyit; + + // name of the PPD group that is currently being processed + OString aCurrentGroup = aDefaultPPDGroupName; + while( line != rLines.end() ) { OString aCurrentLine( *line ); @@ -898,10 +912,26 @@ void PPDParser::parse( ::std::list< OString >& rLines ) { continue; } + + if (aKey == "CloseGroup") + { + aCurrentGroup = aDefaultPPDGroupName; + continue; + } + if (aKey == "OpenGroup") + { + OString aGroupName = aCurrentLine; + sal_Int32 nPosition = aGroupName.indexOf('/'); + if (nPosition != -1) + { + aGroupName = aGroupName.copy(0, nPosition); + } + + aCurrentGroup = GetCommandLineToken(1, aGroupName); + continue; + } if ((aKey == "CloseUI") || (aKey == "JCLCloseUI") || - (aKey == "OpenGroup") || - (aKey == "CloseGroup") || (aKey == "End") || (aKey == "JCLEnd") || (aKey == "OpenSubGroup") || @@ -912,7 +942,7 @@ void PPDParser::parse( ::std::list< OString >& rLines ) if ((aKey == "OpenUI") || (aKey == "JCLOpenUI")) { - parseOpenUI( aCurrentLine ); + parseOpenUI( aCurrentLine, aCurrentGroup); continue; } else if (aKey == "OrderDependency") @@ -1160,7 +1190,7 @@ void PPDParser::parse( ::std::list< OString >& rLines ) } } -void PPDParser::parseOpenUI(const OString& rLine) +void PPDParser::parseOpenUI(const OString& rLine, const OString& rPPDGroup) { OUString aTranslation; OString aKey = rLine; @@ -1199,6 +1229,8 @@ void PPDParser::parseOpenUI(const OString& rLine) pKey->m_eUIType = PPDKey::PickMany; else pKey->m_eUIType = PPDKey::PickOne; + + pKey->m_aGroup = OStringToOUString(rPPDGroup, RTL_TEXTENCODING_MS_1252); } void PPDParser::parseOrderDependency(const OString& rLine) |