include/vcl/ppdparser.hxx | 4 ++- vcl/generic/print/prtsetup.cxx | 11 +++++++-- vcl/unx/generic/printer/ppdparser.cxx | 40 ++++++++++++++++++++++++++++++---- 3 files changed, 48 insertions(+), 7 deletions(-)
New commits: commit f8d0dc09e15b36ae83a5e89280d1f7fbc01da48b Author: Michael Weghorn <m.wegh...@posteo.de> Date: Tue Oct 27 11:06:22 2015 +0100 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. Change-Id: I4a3abf23a711ad98556c0b608a07ef0a91e77e2b Reviewed-on: https://gerrit.libreoffice.org/19623 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Katarina Behrens <katarina.behr...@cib.de> diff --git a/include/vcl/ppdparser.hxx b/include/vcl/ppdparser.hxx index 43dec31..3f8f9c7 100644 --- a/include/vcl/ppdparser.hxx +++ b/include/vcl/ppdparser.hxx @@ -71,6 +71,7 @@ class VCL_DLLPUBLIC PPDKey const PPDValue* m_pDefaultValue; bool m_bQueryValue; PPDValue m_aQueryValue; + OUString m_aGroup; public: enum UIType { PickOne, PickMany, Boolean }; @@ -95,6 +96,7 @@ public: const PPDValue* getValue( const OUString& rOption ) const; const PPDValue* getValueCaseInsensitive( const OUString& rOption ) const; const PPDValue* getDefaultValue() const { return m_pDefaultValue; } + const OUString& getGroup() const { return m_aGroup; } const OUString& getKey() const { return m_aKey; } bool isUIKey() const { return m_bUIOption; } @@ -182,7 +184,7 @@ private: ~PPDParser(); void parseOrderDependency(const OString& rLine); - void parseOpenUI(const OString& rLine); + void parseOpenUI(const OString& rLine, const OString& rPPDGroup); void parseConstraint(const OString& rLine); void parse( std::list< OString >& rLines ); diff --git a/vcl/generic/print/prtsetup.cxx b/vcl/generic/print/prtsetup.cxx index 07ca538..3f8d0da 100644 --- a/vcl/generic/print/prtsetup.cxx +++ b/vcl/generic/print/prtsetup.cxx @@ -367,12 +367,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 84e4057..9ed3e7d 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -874,8 +874,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 ); @@ -897,10 +911,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") || @@ -911,7 +941,7 @@ void PPDParser::parse( ::std::list< OString >& rLines ) if ((aKey == "OpenUI") || (aKey == "JCLOpenUI")) { - parseOpenUI( aCurrentLine ); + parseOpenUI( aCurrentLine, aCurrentGroup); continue; } else if (aKey == "OrderDependency") @@ -1159,7 +1189,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; @@ -1198,6 +1228,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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits