diff options
-rw-r--r-- | include/vcl/ppdparser.hxx | 4 | ||||
-rw-r--r-- | vcl/generic/print/prtsetup.cxx | 11 | ||||
-rw-r--r-- | vcl/unx/generic/printer/ppdparser.cxx | 40 |
3 files changed, 48 insertions, 7 deletions
diff --git a/include/vcl/ppdparser.hxx b/include/vcl/ppdparser.hxx index 71cc2105006a..02fb83a730cb 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 }; @@ -96,6 +97,7 @@ public: const PPDValue* getValueCaseInsensitive( const OUString& rOption ) const; const PPDValue* getDefaultValue() const { return m_pDefaultValue; } const PPDValue* getQueryValue() const { return m_bQueryValue ? &m_aQueryValue : NULL; } + const OUString& getGroup() const { return m_aGroup; } const OUString& getKey() const { return m_aKey; } bool isUIKey() const { return m_bUIOption; } @@ -184,7 +186,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 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) |