Kaydet (Commit) f8d0dc09 authored tarafından Michael Weghorn's avatar Michael Weghorn Kaydeden (comit) Katarina Behrens

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/19623Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst d4484f72
......@@ -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 );
......
......@@ -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 );
......
......@@ -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)
......
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