diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-03-31 15:41:42 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-03-31 15:46:15 +0100 |
commit | a13362ef97d7cb7216009fe7002a050516895cb4 (patch) | |
tree | 7c0e19e639e4501ab9a341ac7d3270d9fca3c027 | |
parent | dcc8c9173d76c3f31af6b1098d920c5491ed150e (diff) |
Resolves: fdo#43049 basic PPD custom options support
because this is another way seen in the wild to transmit a fax number through
cups as an alternative to using fax4CUPS
Change-Id: I32db38aa05213e469442136eb46d0028098a8b7e
-rw-r--r-- | include/vcl/ppdparser.hxx | 13 | ||||
-rw-r--r-- | vcl/generic/print/prtsetup.cxx | 39 | ||||
-rw-r--r-- | vcl/generic/print/prtsetup.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/svids.hrc | 1 | ||||
-rw-r--r-- | vcl/source/src/print.src | 5 | ||||
-rw-r--r-- | vcl/uiconfig/ui/printerdevicepage.ui | 37 | ||||
-rw-r--r-- | vcl/unx/generic/printer/cupsmgr.cxx | 10 | ||||
-rw-r--r-- | vcl/unx/generic/printer/ppdparser.cxx | 19 |
8 files changed, 104 insertions, 24 deletions
diff --git a/include/vcl/ppdparser.hxx b/include/vcl/ppdparser.hxx index 9ac90cef72cd..217340bfd465 100644 --- a/include/vcl/ppdparser.hxx +++ b/include/vcl/ppdparser.hxx @@ -42,9 +42,14 @@ enum PPDValueType { eInvocation, eQuoted, eSymbol, eString, eNo }; struct VCL_DLLPUBLIC PPDValue { - PPDValueType m_eType; - OUString m_aOption; - OUString m_aValue; + PPDValueType m_eType; + //CustomOption stuff for fdo#43049 + //see http://www.cups.org/documentation.php/spec-ppd.html#OPTIONS + //for full specs, only the basics are implemented here + bool m_bCustomOption; + mutable OUString m_aCustomOption; + OUString m_aOption; + OUString m_aValue; }; @@ -82,7 +87,7 @@ public: PPDKey( const OUString& rKey ); ~PPDKey(); - PPDValue* insertValue( const OUString& rOption, PPDValueType eType ); + PPDValue* insertValue(const OUString& rOption, PPDValueType eType, bool bCustomOption = false); int countValues() const { return m_aValues.size(); } // neither getValue will return the query option diff --git a/vcl/generic/print/prtsetup.cxx b/vcl/generic/print/prtsetup.cxx index 2cb770fbcbe7..de30492d9343 100644 --- a/vcl/generic/print/prtsetup.cxx +++ b/vcl/generic/print/prtsetup.cxx @@ -39,6 +39,8 @@ void RTSDialog::insertAllPPDValues( ListBox& rBox, const PPDParser* pParser, con for( int i = 0; i < pKey->countValues(); i++ ) { pValue = pKey->getValue( i ); + if (pValue->m_bCustomOption) + continue; aOptionText = pParser->translateOption( pKey->getKey(), pValue->m_aOption) ; if( m_aJobData.m_aContext.checkConstraints( pKey, pValue ) ) @@ -56,7 +58,7 @@ void RTSDialog::insertAllPPDValues( ListBox& rBox, const PPDParser* pParser, con } } pValue = m_aJobData.m_aContext.getValue( pKey ); - if( pValue ) + if (pValue && !pValue->m_bCustomOption) { if( ( nPos = rBox.GetEntryPos( (void*)pValue ) ) != LISTBOX_ENTRY_NOTFOUND ) rBox.SelectEntryPos( nPos ); @@ -286,8 +288,9 @@ IMPL_LINK( RTSPaperPage, SelectHdl, ListBox*, pBox ) */ RTSDevicePage::RTSDevicePage( RTSDialog* pParent ) - : TabPage(pParent->m_pTabControl, "PrinterDevicePage", "vcl/ui/printerdevicepage.ui" ) - , m_pParent( pParent ) + : TabPage(pParent->m_pTabControl, "PrinterDevicePage", "vcl/ui/printerdevicepage.ui") + , m_pParent(pParent) + , m_pCustomValue(NULL) { get(m_pPPDKeyBox, "options"); get(m_pPPDValueBox, "values"); @@ -295,6 +298,9 @@ RTSDevicePage::RTSDevicePage( RTSDialog* pParent ) m_pPPDKeyBox->SetDropDownLineCount(12); m_pPPDValueBox->SetDropDownLineCount(12); + get(m_pCustomEdit, "custom"); + m_pCustomEdit->SetModifyHdl(LINK(this, RTSDevicePage, ModifyHdl)); + get(m_pLevelBox, "level"); get(m_pSpaceBox, "colorspace"); get(m_pDepthBox, "colordepth"); @@ -423,7 +429,14 @@ sal_uLong RTSDevicePage::getPDFDevice() return -1; //explicitly PS } - +IMPL_LINK( RTSDevicePage, ModifyHdl, Edit*, pEdit ) +{ + if (m_pCustomValue) + { + m_pCustomValue->m_aCustomOption = m_pCustomEdit->GetText(); + } + return 0; +} IMPL_LINK( RTSDevicePage, SelectHdl, ListBox*, pBox ) { @@ -436,7 +449,7 @@ IMPL_LINK( RTSDevicePage, SelectHdl, ListBox*, pBox ) { const PPDKey* pKey = (PPDKey*)m_pPPDKeyBox->GetEntryData( m_pPPDKeyBox->GetSelectEntryPos() ); const PPDValue* pValue = (PPDValue*)m_pPPDValueBox->GetEntryData( m_pPPDValueBox->GetSelectEntryPos() ); - if( pKey && pValue ) + if (pKey && pValue) { m_pParent->m_aJobData.m_aContext.setValue( pKey, pValue ); FillValueBox( pKey ); @@ -445,11 +458,10 @@ IMPL_LINK( RTSDevicePage, SelectHdl, ListBox*, pBox ) return 0; } - - void RTSDevicePage::FillValueBox( const PPDKey* pKey ) { m_pPPDValueBox->Clear(); + m_pCustomEdit->Hide(); if( ! pKey ) return; @@ -461,13 +473,24 @@ void RTSDevicePage::FillValueBox( const PPDKey* pKey ) if( m_pParent->m_aJobData.m_aContext.checkConstraints( pKey, pValue ) && m_pParent->m_aJobData.m_pParser ) { - OUString aEntry( m_pParent->m_aJobData.m_pParser->translateOption( pKey->getKey(), pValue->m_aOption ) ); + OUString aEntry; + if (pValue->m_bCustomOption) + aEntry = VclResId(SV_PRINT_CUSTOM_TXT); + else + aEntry = OUString(m_pParent->m_aJobData.m_pParser->translateOption( pKey->getKey(), pValue->m_aOption)); sal_uInt16 nPos = m_pPPDValueBox->InsertEntry( aEntry ); m_pPPDValueBox->SetEntryData( nPos, (void*)pValue ); } } pValue = m_pParent->m_aJobData.m_aContext.getValue( pKey ); m_pPPDValueBox->SelectEntryPos( m_pPPDValueBox->GetEntryPos( (void*)pValue ) ); + if (pValue->m_bCustomOption) + { + m_pCustomValue = pValue; + m_pParent->m_aJobData.m_aContext.setValue(pKey, pValue); + m_pCustomEdit->SetText(m_pCustomValue->m_aCustomOption); + m_pCustomEdit->Show(); + } } int SetupPrinterDriver(::psp::PrinterInfo& rJobData) diff --git a/vcl/generic/print/prtsetup.hxx b/vcl/generic/print/prtsetup.hxx index 27a46a768b3d..6a037900e7ba 100644 --- a/vcl/generic/print/prtsetup.hxx +++ b/vcl/generic/print/prtsetup.hxx @@ -26,6 +26,7 @@ #include "vcl/tabpage.hxx" #include "vcl/tabctrl.hxx" #include "vcl/button.hxx" +#include "vcl/edit.hxx" #include "vcl/fixed.hxx" #include "vcl/lstbox.hxx" #include "vcl/field.hxx" @@ -102,6 +103,8 @@ class RTSDevicePage : public TabPage ListBox* m_pPPDKeyBox; ListBox* m_pPPDValueBox; + const psp::PPDValue* m_pCustomValue; + Edit* m_pCustomEdit; ListBox* m_pLevelBox; ListBox* m_pSpaceBox; @@ -110,6 +113,7 @@ class RTSDevicePage : public TabPage void FillValueBox( const ::psp::PPDKey* ); DECL_LINK( SelectHdl, ListBox* ); + DECL_LINK( ModifyHdl, Edit* ); public: RTSDevicePage( RTSDialog* ); ~RTSDevicePage(); diff --git a/vcl/inc/svids.hrc b/vcl/inc/svids.hrc index 2bd0e223de30..8f4e3320bbce 100644 --- a/vcl/inc/svids.hrc +++ b/vcl/inc/svids.hrc @@ -214,6 +214,7 @@ #define SV_PRINT_NOCOLLATE_IMG 10614 #define SV_PRINT_QUERYFAXNUMBER_TXT 10615 #define SV_PRINT_INVALID_TXT 10616 +#define SV_PRINT_CUSTOM_TXT 10617 #define SV_EDIT_WARNING_BOX 10650 diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src index bd9f85b0991c..e959e92df6ed 100644 --- a/vcl/source/src/print.src +++ b/vcl/source/src/print.src @@ -115,4 +115,9 @@ String SV_PRINT_INVALID_TXT Text [ en-US ] = "<ignore>"; }; +String SV_PRINT_CUSTOM_TXT +{ + Text [ en-US ] = "Custom"; +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/uiconfig/ui/printerdevicepage.ui b/vcl/uiconfig/ui/printerdevicepage.ui index 2102d6da50a0..20eb96bffafd 100644 --- a/vcl/uiconfig/ui/printerdevicepage.ui +++ b/vcl/uiconfig/ui/printerdevicepage.ui @@ -71,7 +71,7 @@ <property name="xalign">0</property> <property name="label" translatable="yes">Current _value</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">values:border</property> + <property name="mnemonic_widget">valuegrid</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -195,13 +195,40 @@ </packing> </child> <child> - <object class="GtkTreeView" id="values:border"> + <object class="GtkGrid" id="valuegrid"> <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="can_focus">False</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection2"/> + <property name="row_spacing">6</property> + <child> + <object class="GtkEntry" id="custom"> + <property name="can_focus">True</property> + <property name="no_show_all">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkTreeView" id="values:border"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="treeview-selection"/> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> </child> </object> <packing> diff --git a/vcl/unx/generic/printer/cupsmgr.cxx b/vcl/unx/generic/printer/cupsmgr.cxx index b9e5af03bb19..de8a5606be27 100644 --- a/vcl/unx/generic/printer/cupsmgr.cxx +++ b/vcl/unx/generic/printer/cupsmgr.cxx @@ -591,10 +591,16 @@ void CUPSManager::getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner { const PPDKey* pKey = aKeys[i]; const PPDValue* pValue = rJob.m_aContext.getValue( pKey ); - if(pValue && pValue->m_eType == eInvocation && !pValue->m_aOption.isEmpty() ) + OUString sPayLoad; + if (pValue && pValue->m_eType == eInvocation) + { + sPayLoad = pValue->m_bCustomOption ? pValue->m_aCustomOption : pValue->m_aOption; + } + + if (!sPayLoad.isEmpty()) { OString aKey = OUStringToOString( pKey->getKey(), RTL_TEXTENCODING_ASCII_US ); - OString aValue = OUStringToOString( pValue->m_aOption, RTL_TEXTENCODING_ASCII_US ); + OString aValue = OUStringToOString( sPayLoad, RTL_TEXTENCODING_ASCII_US ); rNumOptions = cupsAddOption( aKey.getStr(), aValue.getStr(), rNumOptions, (cups_option_t**)rOptions ); } } diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index 7e56085a4cf1..42eeffc2e3a0 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -933,6 +933,18 @@ void PPDParser::parse( ::std::list< OString >& rLines ) } else if( aKey == "CustomPageSize" ) // currently not handled continue; + else if (aKey.startsWith("Custom", &aKey) ) + { + //fdo#43049 very basic support for Custom entries, we ignore the + //validation params and types + PPDKey* pKey = NULL; + OUString aUniKey(OStringToOUString(aKey, RTL_TEXTENCODING_MS_1252)); + keyit = m_aKeys.find( aUniKey ); + if(keyit != m_aKeys.end()) + pKey = keyit->second; + pKey->insertValue("Custom", eInvocation, true); + continue; + } // default values are parsed in pass 2 if (aKey.startsWith("Default")) @@ -1525,15 +1537,14 @@ void PPDKey::eraseValue( const OUString& rOption ) m_aValues.erase( it ); } - - -PPDValue* PPDKey::insertValue( const OUString& rOption, PPDValueType eType ) +PPDValue* PPDKey::insertValue(const OUString& rOption, PPDValueType eType, bool bCustomOption) { if( m_aValues.find( rOption ) != m_aValues.end() ) return NULL; PPDValue aValue; aValue.m_aOption = rOption; + aValue.m_bCustomOption = bCustomOption; aValue.m_eType = eType; m_aValues[ rOption ] = aValue; PPDValue* pValue = &m_aValues[rOption]; @@ -1541,8 +1552,6 @@ PPDValue* PPDKey::insertValue( const OUString& rOption, PPDValueType eType ) return pValue; } - - /* * PPDContext */ |