1*466d5a0bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*466d5a0bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*466d5a0bSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*466d5a0bSAndrew Rist * distributed with this work for additional information
6*466d5a0bSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*466d5a0bSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*466d5a0bSAndrew Rist * "License"); you may not use this file except in compliance
9*466d5a0bSAndrew Rist * with the License. You may obtain a copy of the License at
10*466d5a0bSAndrew Rist *
11*466d5a0bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*466d5a0bSAndrew Rist *
13*466d5a0bSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*466d5a0bSAndrew Rist * software distributed under the License is distributed on an
15*466d5a0bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*466d5a0bSAndrew Rist * KIND, either express or implied. See the License for the
17*466d5a0bSAndrew Rist * specific language governing permissions and limitations
18*466d5a0bSAndrew Rist * under the License.
19*466d5a0bSAndrew Rist *
20*466d5a0bSAndrew Rist *************************************************************/
21*466d5a0bSAndrew Rist
22*466d5a0bSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include "prtsetup.hxx"
25cdf0e10cSrcweir #include "helper.hxx" // for PaResId
26cdf0e10cSrcweir #include "rtsetup.hrc"
27cdf0e10cSrcweir #include "cmddlg.hxx"
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include "vcl/fontmanager.hxx"
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include "osl/thread.h"
32cdf0e10cSrcweir
33cdf0e10cSrcweir #define LSCAPE_STRING String( RTL_CONSTASCII_USTRINGPARAM( "Landscape" ) )
34cdf0e10cSrcweir #define PORTRAIT_STRING String( RTL_CONSTASCII_USTRINGPARAM( "Portrait" ) )
35cdf0e10cSrcweir
36cdf0e10cSrcweir using namespace rtl;
37cdf0e10cSrcweir using namespace psp;
38cdf0e10cSrcweir using namespace padmin;
39cdf0e10cSrcweir
insertAllPPDValues(ListBox & rBox,const PPDParser * pParser,const PPDKey * pKey)40cdf0e10cSrcweir void RTSDialog::insertAllPPDValues( ListBox& rBox, const PPDParser* pParser, const PPDKey* pKey )
41cdf0e10cSrcweir {
42cdf0e10cSrcweir if( ! pKey || ! pParser )
43cdf0e10cSrcweir return;
44cdf0e10cSrcweir
45cdf0e10cSrcweir const PPDValue* pValue = NULL;
46cdf0e10cSrcweir sal_uInt16 nPos = 0;
47cdf0e10cSrcweir String aOptionText;
48cdf0e10cSrcweir
49cdf0e10cSrcweir for( int i = 0; i < pKey->countValues(); i++ )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir pValue = pKey->getValue( i );
52cdf0e10cSrcweir aOptionText = pParser->translateOption( pKey->getKey(), pValue->m_aOption) ;
53cdf0e10cSrcweir
54cdf0e10cSrcweir if( m_aJobData.m_aContext.checkConstraints( pKey, pValue ) )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir if( rBox.GetEntryPos( (void*)pValue ) == LISTBOX_ENTRY_NOTFOUND )
57cdf0e10cSrcweir {
58cdf0e10cSrcweir nPos = rBox.InsertEntry( aOptionText, LISTBOX_APPEND );
59cdf0e10cSrcweir rBox.SetEntryData( nPos, (void*)pValue );
60cdf0e10cSrcweir }
61cdf0e10cSrcweir }
62cdf0e10cSrcweir else
63cdf0e10cSrcweir {
64cdf0e10cSrcweir if( ( nPos = rBox.GetEntryPos( (void*)pValue ) ) != LISTBOX_ENTRY_NOTFOUND )
65cdf0e10cSrcweir rBox.RemoveEntry( nPos );
66cdf0e10cSrcweir }
67cdf0e10cSrcweir }
68cdf0e10cSrcweir pValue = m_aJobData.m_aContext.getValue( pKey );
69cdf0e10cSrcweir if( pValue )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir if( ( nPos = rBox.GetEntryPos( (void*)pValue ) ) != LISTBOX_ENTRY_NOTFOUND )
72cdf0e10cSrcweir rBox.SelectEntryPos( nPos );
73cdf0e10cSrcweir }
74cdf0e10cSrcweir else
75cdf0e10cSrcweir rBox.SelectEntry( m_aInvalidString );
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
78cdf0e10cSrcweir // --------------------------------------------------------------------------
79cdf0e10cSrcweir
80cdf0e10cSrcweir /*
81cdf0e10cSrcweir * RTSDialog
82cdf0e10cSrcweir */
83cdf0e10cSrcweir
RTSDialog(const PrinterInfo & rJobData,const String & rPrinter,bool bAllPages,Window * pParent)84cdf0e10cSrcweir RTSDialog::RTSDialog( const PrinterInfo& rJobData, const String& rPrinter, bool bAllPages, Window* pParent ) :
85cdf0e10cSrcweir TabDialog( pParent, PaResId( RID_RTS_RTSDIALOG ) ),
86cdf0e10cSrcweir m_aJobData( rJobData ),
87cdf0e10cSrcweir m_aPrinter( rPrinter ),
88cdf0e10cSrcweir m_aTabControl( this, PaResId( RID_RTS_RTSDIALOG_TABCONTROL ) ),
89cdf0e10cSrcweir m_aOKButton( this ),
90cdf0e10cSrcweir m_aCancelButton( this ),
91cdf0e10cSrcweir m_pPaperPage( NULL ),
92cdf0e10cSrcweir m_pDevicePage( NULL ),
93cdf0e10cSrcweir m_pOtherPage( NULL ),
94cdf0e10cSrcweir m_pFontSubstPage( NULL ),
95cdf0e10cSrcweir m_pCommandPage( NULL ),
96cdf0e10cSrcweir m_aInvalidString( PaResId( RID_RTS_RTSDIALOG_INVALID_TXT ) ),
97cdf0e10cSrcweir m_aFromDriverString( PaResId( RID_RTS_RTSDIALOG_FROMDRIVER_TXT ) )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir FreeResource();
100cdf0e10cSrcweir
101cdf0e10cSrcweir String aTitle( GetText() );
102cdf0e10cSrcweir aTitle.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), m_aJobData.m_aPrinterName );
103cdf0e10cSrcweir SetText( aTitle );
104cdf0e10cSrcweir
105cdf0e10cSrcweir if( ! bAllPages )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir m_aTabControl.RemovePage( RID_RTS_OTHERPAGE );
108cdf0e10cSrcweir m_aTabControl.RemovePage( RID_RTS_FONTSUBSTPAGE );
109cdf0e10cSrcweir m_aTabControl.RemovePage( RID_RTS_COMMANDPAGE );
110cdf0e10cSrcweir }
111cdf0e10cSrcweir else if( m_aJobData.m_aDriverName.compareToAscii( "CUPS:", 5 ) == 0 && ! PrinterInfoManager::get().isCUPSDisabled() )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir // command page makes no sense for CUPS printers
114cdf0e10cSrcweir m_aTabControl.RemovePage( RID_RTS_COMMANDPAGE );
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
117cdf0e10cSrcweir m_aTabControl.SetActivatePageHdl( LINK( this, RTSDialog, ActivatePage ) );
118cdf0e10cSrcweir m_aOKButton.SetClickHdl( LINK( this, RTSDialog, ClickButton ) );
119cdf0e10cSrcweir m_aCancelButton.SetClickHdl( LINK( this, RTSDialog, ClickButton ) );
120cdf0e10cSrcweir ActivatePage( &m_aTabControl );
121cdf0e10cSrcweir
122cdf0e10cSrcweir m_aOKButton.Show();
123cdf0e10cSrcweir m_aCancelButton.Show();
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir // --------------------------------------------------------------------------
127cdf0e10cSrcweir
~RTSDialog()128cdf0e10cSrcweir RTSDialog::~RTSDialog()
129cdf0e10cSrcweir {
130cdf0e10cSrcweir if( m_pPaperPage )
131cdf0e10cSrcweir delete m_pPaperPage;
132cdf0e10cSrcweir if( m_pDevicePage )
133cdf0e10cSrcweir delete m_pDevicePage;
134cdf0e10cSrcweir if( m_pOtherPage )
135cdf0e10cSrcweir delete m_pOtherPage;
136cdf0e10cSrcweir if( m_pFontSubstPage )
137cdf0e10cSrcweir delete m_pFontSubstPage;
138cdf0e10cSrcweir if( m_pCommandPage )
139cdf0e10cSrcweir delete m_pCommandPage;
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
142cdf0e10cSrcweir // --------------------------------------------------------------------------
143cdf0e10cSrcweir
IMPL_LINK(RTSDialog,ActivatePage,TabControl *,pTabCtrl)144cdf0e10cSrcweir IMPL_LINK( RTSDialog, ActivatePage, TabControl*, pTabCtrl )
145cdf0e10cSrcweir {
146cdf0e10cSrcweir if( pTabCtrl != &m_aTabControl )
147cdf0e10cSrcweir return 0;
148cdf0e10cSrcweir
149cdf0e10cSrcweir sal_uInt16 nId = m_aTabControl.GetCurPageId();
150cdf0e10cSrcweir
151cdf0e10cSrcweir if ( ! m_aTabControl.GetTabPage( nId ) )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir TabPage *pPage = NULL;
154cdf0e10cSrcweir if( nId == RID_RTS_PAPERPAGE )
155cdf0e10cSrcweir pPage = m_pPaperPage = new RTSPaperPage( this );
156cdf0e10cSrcweir else if( nId == RID_RTS_DEVICEPAGE )
157cdf0e10cSrcweir pPage = m_pDevicePage = new RTSDevicePage( this );
158cdf0e10cSrcweir else if( nId == RID_RTS_OTHERPAGE )
159cdf0e10cSrcweir pPage = m_pOtherPage = new RTSOtherPage( this );
160cdf0e10cSrcweir else if( nId == RID_RTS_FONTSUBSTPAGE )
161cdf0e10cSrcweir pPage = m_pFontSubstPage = new RTSFontSubstPage( this );
162cdf0e10cSrcweir else if( nId == RID_RTS_COMMANDPAGE )
163cdf0e10cSrcweir pPage = m_pCommandPage = new RTSCommandPage( this );
164cdf0e10cSrcweir if( pPage )
165cdf0e10cSrcweir m_aTabControl.SetTabPage( nId, pPage );
166cdf0e10cSrcweir }
167cdf0e10cSrcweir else
168cdf0e10cSrcweir {
169cdf0e10cSrcweir switch( nId )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir case RID_RTS_PAPERPAGE: m_pPaperPage->update();break;
172cdf0e10cSrcweir case RID_RTS_DEVICEPAGE: m_pDevicePage->update();break;
173cdf0e10cSrcweir default: break;
174cdf0e10cSrcweir }
175cdf0e10cSrcweir }
176cdf0e10cSrcweir
177cdf0e10cSrcweir return 0;
178cdf0e10cSrcweir }
179cdf0e10cSrcweir
180cdf0e10cSrcweir // --------------------------------------------------------------------------
181cdf0e10cSrcweir
IMPL_LINK(RTSDialog,ClickButton,Button *,pButton)182cdf0e10cSrcweir IMPL_LINK( RTSDialog, ClickButton, Button*, pButton )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir if( pButton == &m_aOKButton )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir // refresh the changed values
187cdf0e10cSrcweir if( m_pPaperPage )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir // orientation
190cdf0e10cSrcweir m_aJobData.m_eOrientation = m_pPaperPage->getOrientation().Equals( LSCAPE_STRING ) ? orientation::Landscape : orientation::Portrait;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir if( m_pDevicePage )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir m_aJobData.m_nColorDepth = m_pDevicePage->getDepth();
195cdf0e10cSrcweir m_aJobData.m_nColorDevice = m_pDevicePage->getColorDevice();
196cdf0e10cSrcweir m_aJobData.m_nPSLevel = m_pDevicePage->getLevel();
197cdf0e10cSrcweir m_aJobData.m_nPDFDevice = m_pDevicePage->getPDFDevice();
198cdf0e10cSrcweir }
199cdf0e10cSrcweir if( m_pOtherPage )
200cdf0e10cSrcweir // write other settings
201cdf0e10cSrcweir m_pOtherPage->save();
202cdf0e10cSrcweir if( m_pCommandPage )
203cdf0e10cSrcweir // write command settings
204cdf0e10cSrcweir m_pCommandPage->save();
205cdf0e10cSrcweir
206cdf0e10cSrcweir EndDialog( 1 );
207cdf0e10cSrcweir }
208cdf0e10cSrcweir else if( pButton == &m_aCancelButton )
209cdf0e10cSrcweir EndDialog( 0 );
210cdf0e10cSrcweir
211cdf0e10cSrcweir return 0;
212cdf0e10cSrcweir }
213cdf0e10cSrcweir
214cdf0e10cSrcweir // --------------------------------------------------------------------------
215cdf0e10cSrcweir
216cdf0e10cSrcweir /*
217cdf0e10cSrcweir * RTSPaperPage
218cdf0e10cSrcweir */
219cdf0e10cSrcweir
RTSPaperPage(RTSDialog * pParent)220cdf0e10cSrcweir RTSPaperPage::RTSPaperPage( RTSDialog* pParent ) :
221cdf0e10cSrcweir TabPage( & pParent->m_aTabControl, PaResId( RID_RTS_PAPERPAGE ) ),
222cdf0e10cSrcweir
223cdf0e10cSrcweir m_pParent( pParent ),
224cdf0e10cSrcweir
225cdf0e10cSrcweir m_aPaperText( this, PaResId( RID_RTS_PAPER_PAPER_TXT ) ),
226cdf0e10cSrcweir m_aPaperBox( this, PaResId( RID_RTS_PAPER_PAPER_BOX ) ),
227cdf0e10cSrcweir m_aOrientText( this, PaResId( RID_RTS_PAPER_ORIENTATION_TXT ) ),
228cdf0e10cSrcweir m_aOrientBox( this, PaResId( RID_RTS_PAPER_ORIENTATION_BOX ) ),
229cdf0e10cSrcweir m_aDuplexText( this, PaResId( RID_RTS_PAPER_DUPLEX_TXT ) ),
230cdf0e10cSrcweir m_aDuplexBox( this, PaResId( RID_RTS_PAPER_DUPLEX_BOX ) ),
231cdf0e10cSrcweir m_aSlotText( this, PaResId( RID_RTS_PAPER_SLOT_TXT ) ),
232cdf0e10cSrcweir m_aSlotBox( this, PaResId( RID_RTS_PAPER_SLOT_BOX ) )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir m_aPaperBox.SetSelectHdl( LINK( this, RTSPaperPage, SelectHdl ) );
235cdf0e10cSrcweir m_aOrientBox.SetSelectHdl( LINK( this, RTSPaperPage, SelectHdl ) );
236cdf0e10cSrcweir m_aDuplexBox.SetSelectHdl( LINK( this, RTSPaperPage, SelectHdl ) );
237cdf0e10cSrcweir m_aSlotBox.SetSelectHdl( LINK( this, RTSPaperPage, SelectHdl ) );
238cdf0e10cSrcweir
239cdf0e10cSrcweir FreeResource();
240cdf0e10cSrcweir
241cdf0e10cSrcweir sal_uInt16 nPos = 0;
242cdf0e10cSrcweir
243cdf0e10cSrcweir m_aOrientBox.InsertEntry( PORTRAIT_STRING );
244cdf0e10cSrcweir m_aOrientBox.InsertEntry( LSCAPE_STRING );
245cdf0e10cSrcweir // duplex
246cdf0e10cSrcweir nPos = m_aDuplexBox.InsertEntry( m_pParent->m_aInvalidString );
247cdf0e10cSrcweir m_aDuplexBox.SetEntryData( nPos, NULL );
248cdf0e10cSrcweir
249cdf0e10cSrcweir // paper does not have an invalid entry
250cdf0e10cSrcweir
251cdf0e10cSrcweir // input slots
252cdf0e10cSrcweir nPos = m_aSlotBox.InsertEntry( m_pParent->m_aInvalidString );
253cdf0e10cSrcweir m_aSlotBox.SetEntryData( nPos, NULL );
254cdf0e10cSrcweir
255cdf0e10cSrcweir update();
256cdf0e10cSrcweir }
257cdf0e10cSrcweir
258cdf0e10cSrcweir // --------------------------------------------------------------------------
259cdf0e10cSrcweir
~RTSPaperPage()260cdf0e10cSrcweir RTSPaperPage::~RTSPaperPage()
261cdf0e10cSrcweir {
262cdf0e10cSrcweir }
263cdf0e10cSrcweir
264cdf0e10cSrcweir // --------------------------------------------------------------------------
265cdf0e10cSrcweir
update()266cdf0e10cSrcweir void RTSPaperPage::update()
267cdf0e10cSrcweir {
268cdf0e10cSrcweir const PPDKey* pKey = NULL;
269cdf0e10cSrcweir
270cdf0e10cSrcweir // orientation
271cdf0e10cSrcweir m_aOrientBox.SelectEntry(
272cdf0e10cSrcweir m_pParent->m_aJobData.m_eOrientation == orientation::Landscape
273cdf0e10cSrcweir ? LSCAPE_STRING : PORTRAIT_STRING );
274cdf0e10cSrcweir
275cdf0e10cSrcweir // duplex
276cdf0e10cSrcweir if( m_pParent->m_aJobData.m_pParser &&
277cdf0e10cSrcweir (pKey = m_pParent->m_aJobData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) )) )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir m_pParent->insertAllPPDValues( m_aDuplexBox, m_pParent->m_aJobData.m_pParser, pKey );
280cdf0e10cSrcweir }
281cdf0e10cSrcweir else
282cdf0e10cSrcweir {
283cdf0e10cSrcweir m_aDuplexText.Enable( sal_False );
284cdf0e10cSrcweir m_aDuplexBox.Enable( sal_False );
285cdf0e10cSrcweir }
286cdf0e10cSrcweir
287cdf0e10cSrcweir // paper
288cdf0e10cSrcweir if( m_pParent->m_aJobData.m_pParser &&
289cdf0e10cSrcweir (pKey = m_pParent->m_aJobData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) )) )
290cdf0e10cSrcweir {
291cdf0e10cSrcweir m_pParent->insertAllPPDValues( m_aPaperBox, m_pParent->m_aJobData.m_pParser, pKey );
292cdf0e10cSrcweir }
293cdf0e10cSrcweir else
294cdf0e10cSrcweir {
295cdf0e10cSrcweir m_aPaperText.Enable( sal_False );
296cdf0e10cSrcweir m_aPaperBox.Enable( sal_False );
297cdf0e10cSrcweir }
298cdf0e10cSrcweir
299cdf0e10cSrcweir // input slots
300cdf0e10cSrcweir if( m_pParent->m_aJobData.m_pParser &&
301cdf0e10cSrcweir (pKey = m_pParent->m_aJobData.m_pParser->getKey( String::CreateFromAscii( "InputSlot" ) )) )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir m_pParent->insertAllPPDValues( m_aSlotBox, m_pParent->m_aJobData.m_pParser, pKey );
304cdf0e10cSrcweir }
305cdf0e10cSrcweir else
306cdf0e10cSrcweir {
307cdf0e10cSrcweir m_aSlotText.Enable( sal_False );
308cdf0e10cSrcweir m_aSlotBox.Enable( sal_False );
309cdf0e10cSrcweir }
310cdf0e10cSrcweir }
311cdf0e10cSrcweir
312cdf0e10cSrcweir // --------------------------------------------------------------------------
313cdf0e10cSrcweir
IMPL_LINK(RTSPaperPage,SelectHdl,ListBox *,pBox)314cdf0e10cSrcweir IMPL_LINK( RTSPaperPage, SelectHdl, ListBox*, pBox )
315cdf0e10cSrcweir {
316cdf0e10cSrcweir const PPDKey* pKey = NULL;
317cdf0e10cSrcweir if( pBox == &m_aPaperBox )
318cdf0e10cSrcweir {
319cdf0e10cSrcweir if( m_pParent->m_aJobData.m_pParser )
320cdf0e10cSrcweir pKey = m_pParent->m_aJobData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) );
321cdf0e10cSrcweir }
322cdf0e10cSrcweir else if( pBox == &m_aDuplexBox )
323cdf0e10cSrcweir {
324cdf0e10cSrcweir if( m_pParent->m_aJobData.m_pParser )
325cdf0e10cSrcweir pKey = m_pParent->m_aJobData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) );
326cdf0e10cSrcweir }
327cdf0e10cSrcweir else if( pBox == &m_aSlotBox )
328cdf0e10cSrcweir {
329cdf0e10cSrcweir if( m_pParent->m_aJobData.m_pParser )
330cdf0e10cSrcweir pKey = m_pParent->m_aJobData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) );
331cdf0e10cSrcweir }
332cdf0e10cSrcweir else if( pBox == &m_aOrientBox )
333cdf0e10cSrcweir {
334cdf0e10cSrcweir m_pParent->m_aJobData.m_eOrientation = m_aOrientBox.GetSelectEntry().Equals( LSCAPE_STRING ) ? orientation::Landscape : orientation::Portrait;
335cdf0e10cSrcweir }
336cdf0e10cSrcweir if( pKey )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir PPDValue* pValue =
339cdf0e10cSrcweir (PPDValue*)pBox->GetEntryData( pBox->GetSelectEntryPos() );
340cdf0e10cSrcweir m_pParent->m_aJobData.m_aContext.setValue( pKey, pValue );
341cdf0e10cSrcweir update();
342cdf0e10cSrcweir }
343cdf0e10cSrcweir return 0;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir
346cdf0e10cSrcweir // --------------------------------------------------------------------------
347cdf0e10cSrcweir
348cdf0e10cSrcweir /*
349cdf0e10cSrcweir * RTSDevicePage
350cdf0e10cSrcweir */
351cdf0e10cSrcweir
RTSDevicePage(RTSDialog * pParent)352cdf0e10cSrcweir RTSDevicePage::RTSDevicePage( RTSDialog* pParent ) :
353cdf0e10cSrcweir TabPage( & pParent->m_aTabControl, PaResId( RID_RTS_DEVICEPAGE ) ),
354cdf0e10cSrcweir
355cdf0e10cSrcweir m_pParent( pParent ),
356cdf0e10cSrcweir
357cdf0e10cSrcweir m_aSpaceColor( PaResId( RID_RTS_DEVICE_COLOR_TXT ) ),
358cdf0e10cSrcweir m_aSpaceGray( PaResId( RID_RTS_DEVICE_GRAY_TXT ) ),
359cdf0e10cSrcweir m_aPPDKeyText( this, PaResId( RID_RTS_DEVICE_PPDKEY_TXT ) ),
360cdf0e10cSrcweir m_aPPDKeyBox( this, PaResId( RID_RTS_DEVICE_PPDKEY_BOX ) ),
361cdf0e10cSrcweir m_aPPDValueText( this, PaResId( RID_RTS_DEVICE_PPDVALUE_TXT ) ),
362cdf0e10cSrcweir m_aPPDValueBox( this, PaResId( RID_RTS_DEVICE_PPDVALUE_BOX ) ),
363cdf0e10cSrcweir m_aLevelText( this, PaResId( RID_RTS_DEVICE_PRINTLANG_TXT ) ),
364cdf0e10cSrcweir m_aLevelBox( this, PaResId( RID_RTS_DEVICE_PRINTLANG_BOX ) ),
365cdf0e10cSrcweir m_aSpaceText( this, PaResId( RID_RTS_DEVICE_SPACE_TXT ) ),
366cdf0e10cSrcweir m_aSpaceBox( this, PaResId( RID_RTS_DEVICE_SPACE_BOX ) ),
367cdf0e10cSrcweir m_aDepthText( this, PaResId( RID_RTS_DEVICE_DEPTH_TXT ) ),
368cdf0e10cSrcweir m_aDepthBox( this, PaResId( RID_RTS_DEVICE_DEPTH_BOX ) )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir FreeResource();
371cdf0e10cSrcweir
372cdf0e10cSrcweir m_aPPDKeyBox.SetSelectHdl( LINK( this, RTSDevicePage, SelectHdl ) );
373cdf0e10cSrcweir m_aPPDValueBox.SetSelectHdl( LINK( this, RTSDevicePage, SelectHdl ) );
374cdf0e10cSrcweir
375cdf0e10cSrcweir m_aSpaceBox.InsertEntry( m_pParent->m_aFromDriverString );
376cdf0e10cSrcweir m_aSpaceBox.InsertEntry( m_aSpaceColor );
377cdf0e10cSrcweir m_aSpaceBox.InsertEntry( m_aSpaceGray );
378cdf0e10cSrcweir switch( m_pParent->m_aJobData.m_nColorDevice )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir case -1: m_aSpaceBox.SelectEntry( m_aSpaceGray );break;
381cdf0e10cSrcweir case 0: m_aSpaceBox.SelectEntry( m_pParent->m_aFromDriverString );break;
382cdf0e10cSrcweir case 1: m_aSpaceBox.SelectEntry( m_aSpaceColor );break;
383cdf0e10cSrcweir }
384cdf0e10cSrcweir
385cdf0e10cSrcweir sal_uLong nLevelEntryData = 0;
386cdf0e10cSrcweir if( m_pParent->m_aJobData.m_nPDFDevice > 0 )
387cdf0e10cSrcweir nLevelEntryData = 10;
388cdf0e10cSrcweir else
389cdf0e10cSrcweir nLevelEntryData = m_pParent->m_aJobData.m_nPSLevel+1;
390cdf0e10cSrcweir for( sal_uInt16 i = 0; i < m_aLevelBox.GetEntryCount(); i++ )
391cdf0e10cSrcweir {
392cdf0e10cSrcweir if( (sal_uLong)m_aLevelBox.GetEntryData( i ) == nLevelEntryData )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir m_aLevelBox.SelectEntryPos( i );
395cdf0e10cSrcweir break;
396cdf0e10cSrcweir }
397cdf0e10cSrcweir }
398cdf0e10cSrcweir
399cdf0e10cSrcweir m_aDepthBox.SelectEntry( String::CreateFromInt32( m_pParent->m_aJobData.m_nColorDepth ).AppendAscii( " Bit" ) );
400cdf0e10cSrcweir
401cdf0e10cSrcweir // fill ppd boxes
402cdf0e10cSrcweir if( m_pParent->m_aJobData.m_pParser )
403cdf0e10cSrcweir {
404cdf0e10cSrcweir for( int i = 0; i < m_pParent->m_aJobData.m_pParser->getKeys(); i++ )
405cdf0e10cSrcweir {
406cdf0e10cSrcweir const PPDKey* pKey = m_pParent->m_aJobData.m_pParser->getKey( i );
407cdf0e10cSrcweir if( pKey->isUIKey() &&
408cdf0e10cSrcweir ! pKey->getKey().EqualsAscii( "PageSize" ) &&
409cdf0e10cSrcweir ! pKey->getKey().EqualsAscii( "InputSlot" ) &&
410cdf0e10cSrcweir ! pKey->getKey().EqualsAscii( "PageRegion" ) &&
411cdf0e10cSrcweir ! pKey->getKey().EqualsAscii( "Duplex" )
412cdf0e10cSrcweir )
413cdf0e10cSrcweir {
414cdf0e10cSrcweir String aEntry( m_pParent->m_aJobData.m_pParser->translateKey( pKey->getKey() ) );
415cdf0e10cSrcweir sal_uInt16 nPos = m_aPPDKeyBox.InsertEntry( aEntry );
416cdf0e10cSrcweir m_aPPDKeyBox.SetEntryData( nPos, (void*)pKey );
417cdf0e10cSrcweir }
418cdf0e10cSrcweir }
419cdf0e10cSrcweir }
420cdf0e10cSrcweir }
421cdf0e10cSrcweir
422cdf0e10cSrcweir // --------------------------------------------------------------------------
423cdf0e10cSrcweir
~RTSDevicePage()424cdf0e10cSrcweir RTSDevicePage::~RTSDevicePage()
425cdf0e10cSrcweir {
426cdf0e10cSrcweir }
427cdf0e10cSrcweir
428cdf0e10cSrcweir // --------------------------------------------------------------------------
429cdf0e10cSrcweir
update()430cdf0e10cSrcweir void RTSDevicePage::update()
431cdf0e10cSrcweir {
432cdf0e10cSrcweir }
433cdf0e10cSrcweir
434cdf0e10cSrcweir // ------------------------------------------------------------------
435cdf0e10cSrcweir
getLevel()436cdf0e10cSrcweir sal_uLong RTSDevicePage::getLevel()
437cdf0e10cSrcweir {
438cdf0e10cSrcweir sal_uLong nLevel = (sal_uLong)m_aLevelBox.GetEntryData( m_aLevelBox.GetSelectEntryPos() );
439cdf0e10cSrcweir return nLevel < 10 ? nLevel-1 : 0;
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
442cdf0e10cSrcweir // ------------------------------------------------------------------
443cdf0e10cSrcweir
getPDFDevice()444cdf0e10cSrcweir sal_uLong RTSDevicePage::getPDFDevice()
445cdf0e10cSrcweir {
446cdf0e10cSrcweir sal_uLong nLevel = (sal_uLong)m_aLevelBox.GetEntryData( m_aLevelBox.GetSelectEntryPos() );
447cdf0e10cSrcweir return nLevel > 9 ? 1 : 0;
448cdf0e10cSrcweir }
449cdf0e10cSrcweir
450cdf0e10cSrcweir // ------------------------------------------------------------------
451cdf0e10cSrcweir
IMPL_LINK(RTSDevicePage,SelectHdl,ListBox *,pBox)452cdf0e10cSrcweir IMPL_LINK( RTSDevicePage, SelectHdl, ListBox*, pBox )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir if( pBox == &m_aPPDKeyBox )
455cdf0e10cSrcweir {
456cdf0e10cSrcweir const PPDKey* pKey = (PPDKey*)m_aPPDKeyBox.GetEntryData( m_aPPDKeyBox.GetSelectEntryPos() );
457cdf0e10cSrcweir FillValueBox( pKey );
458cdf0e10cSrcweir }
459cdf0e10cSrcweir else if( pBox == &m_aPPDValueBox )
460cdf0e10cSrcweir {
461cdf0e10cSrcweir const PPDKey* pKey = (PPDKey*)m_aPPDKeyBox.GetEntryData( m_aPPDKeyBox.GetSelectEntryPos() );
462cdf0e10cSrcweir const PPDValue* pValue = (PPDValue*)m_aPPDValueBox.GetEntryData( m_aPPDValueBox.GetSelectEntryPos() );
463cdf0e10cSrcweir if( pKey && pValue )
464cdf0e10cSrcweir {
465cdf0e10cSrcweir m_pParent->m_aJobData.m_aContext.setValue( pKey, pValue );
466cdf0e10cSrcweir FillValueBox( pKey );
467cdf0e10cSrcweir }
468cdf0e10cSrcweir }
469cdf0e10cSrcweir return 0;
470cdf0e10cSrcweir }
471cdf0e10cSrcweir
472cdf0e10cSrcweir // ------------------------------------------------------------------
473cdf0e10cSrcweir
FillValueBox(const PPDKey * pKey)474cdf0e10cSrcweir void RTSDevicePage::FillValueBox( const PPDKey* pKey )
475cdf0e10cSrcweir {
476cdf0e10cSrcweir m_aPPDValueBox.Clear();
477cdf0e10cSrcweir
478cdf0e10cSrcweir if( ! pKey )
479cdf0e10cSrcweir return;
480cdf0e10cSrcweir
481cdf0e10cSrcweir const PPDValue* pValue = NULL;
482cdf0e10cSrcweir for( int i = 0; i < pKey->countValues(); i++ )
483cdf0e10cSrcweir {
484cdf0e10cSrcweir pValue = pKey->getValue( i );
485cdf0e10cSrcweir if( m_pParent->m_aJobData.m_aContext.checkConstraints( pKey, pValue ) &&
486cdf0e10cSrcweir m_pParent->m_aJobData.m_pParser )
487cdf0e10cSrcweir {
488cdf0e10cSrcweir String aEntry( m_pParent->m_aJobData.m_pParser->translateOption( pKey->getKey(), pValue->m_aOption ) );
489cdf0e10cSrcweir sal_uInt16 nPos = m_aPPDValueBox.InsertEntry( aEntry );
490cdf0e10cSrcweir m_aPPDValueBox.SetEntryData( nPos, (void*)pValue );
491cdf0e10cSrcweir }
492cdf0e10cSrcweir }
493cdf0e10cSrcweir pValue = m_pParent->m_aJobData.m_aContext.getValue( pKey );
494cdf0e10cSrcweir m_aPPDValueBox.SelectEntryPos( m_aPPDValueBox.GetEntryPos( (void*)pValue ) );
495cdf0e10cSrcweir }
496cdf0e10cSrcweir
497cdf0e10cSrcweir // --------------------------------------------------------------------------
498cdf0e10cSrcweir
499cdf0e10cSrcweir /*
500cdf0e10cSrcweir * RTSOtherPage
501cdf0e10cSrcweir */
502cdf0e10cSrcweir
RTSOtherPage(RTSDialog * pParent)503cdf0e10cSrcweir RTSOtherPage::RTSOtherPage( RTSDialog* pParent ) :
504cdf0e10cSrcweir TabPage( &pParent->m_aTabControl, PaResId( RID_RTS_OTHERPAGE ) ),
505cdf0e10cSrcweir m_pParent( pParent ),
506cdf0e10cSrcweir m_aLeftTxt( this, PaResId( RID_RTS_OTHER_LEFTMARGIN_TXT ) ),
507cdf0e10cSrcweir m_aLeftLB( this, PaResId( RID_RTS_OTHER_LEFTMARGIN_BOX ) ),
508cdf0e10cSrcweir m_aTopTxt( this, PaResId( RID_RTS_OTHER_TOPMARGIN_TXT ) ),
509cdf0e10cSrcweir m_aTopLB( this, PaResId( RID_RTS_OTHER_TOPMARGIN_BOX ) ),
510cdf0e10cSrcweir m_aRightTxt( this, PaResId( RID_RTS_OTHER_RIGHTMARGIN_TXT ) ),
511cdf0e10cSrcweir m_aRightLB( this, PaResId( RID_RTS_OTHER_RIGHTMARGIN_BOX ) ),
512cdf0e10cSrcweir m_aBottomTxt( this, PaResId( RID_RTS_OTHER_BOTTOMMARGIN_TXT ) ),
513cdf0e10cSrcweir m_aBottomLB( this, PaResId( RID_RTS_OTHER_BOTTOMMARGIN_BOX ) ),
514cdf0e10cSrcweir m_aCommentTxt( this, PaResId( RID_RTS_OTHER_COMMENT_TXT ) ),
515cdf0e10cSrcweir m_aCommentEdt( this, PaResId( RID_RTS_OTHER_COMMENT_EDT ) ),
516cdf0e10cSrcweir m_aDefaultBtn( this, PaResId( RID_RTS_OTHER_DEFAULT_BTN ) )
517cdf0e10cSrcweir {
518cdf0e10cSrcweir FreeResource();
519cdf0e10cSrcweir
520cdf0e10cSrcweir m_aTopLB.EnableEmptyFieldValue( sal_True );
521cdf0e10cSrcweir m_aBottomLB.EnableEmptyFieldValue( sal_True );
522cdf0e10cSrcweir m_aLeftLB.EnableEmptyFieldValue( sal_True );
523cdf0e10cSrcweir m_aRightLB.EnableEmptyFieldValue( sal_True );
524cdf0e10cSrcweir
525cdf0e10cSrcweir m_aDefaultBtn.SetClickHdl( LINK( this, RTSOtherPage, ClickBtnHdl ) );
526cdf0e10cSrcweir
527cdf0e10cSrcweir initValues();
528cdf0e10cSrcweir }
529cdf0e10cSrcweir
530cdf0e10cSrcweir // ------------------------------------------------------------------
531cdf0e10cSrcweir
~RTSOtherPage()532cdf0e10cSrcweir RTSOtherPage::~RTSOtherPage()
533cdf0e10cSrcweir {
534cdf0e10cSrcweir }
535cdf0e10cSrcweir
536cdf0e10cSrcweir // ------------------------------------------------------------------
537cdf0e10cSrcweir
initValues()538cdf0e10cSrcweir void RTSOtherPage::initValues()
539cdf0e10cSrcweir {
540cdf0e10cSrcweir int nMarginLeft = 0;
541cdf0e10cSrcweir int nMarginTop = 0;
542cdf0e10cSrcweir int nMarginRight = 0;
543cdf0e10cSrcweir int nMarginBottom = 0;
544cdf0e10cSrcweir
545cdf0e10cSrcweir if( m_pParent->m_aJobData.m_pParser )
546cdf0e10cSrcweir {
547cdf0e10cSrcweir m_pParent->m_aJobData.m_pParser->
548cdf0e10cSrcweir getMargins( m_pParent->m_aJobData.m_pParser->getDefaultPaperDimension(),
549cdf0e10cSrcweir nMarginLeft,
550cdf0e10cSrcweir nMarginRight,
551cdf0e10cSrcweir nMarginTop,
552cdf0e10cSrcweir nMarginBottom );
553cdf0e10cSrcweir }
554cdf0e10cSrcweir
555cdf0e10cSrcweir nMarginLeft += m_pParent->m_aJobData.m_nLeftMarginAdjust;
556cdf0e10cSrcweir nMarginRight += m_pParent->m_aJobData.m_nRightMarginAdjust;
557cdf0e10cSrcweir nMarginTop += m_pParent->m_aJobData.m_nTopMarginAdjust;
558cdf0e10cSrcweir nMarginBottom += m_pParent->m_aJobData.m_nBottomMarginAdjust;
559cdf0e10cSrcweir
560cdf0e10cSrcweir m_aLeftLB.SetValue( nMarginLeft, FUNIT_POINT );
561cdf0e10cSrcweir m_aRightLB.SetValue( nMarginRight, FUNIT_POINT );
562cdf0e10cSrcweir m_aTopLB.SetValue( nMarginTop, FUNIT_POINT );
563cdf0e10cSrcweir m_aBottomLB.SetValue( nMarginBottom, FUNIT_POINT );
564cdf0e10cSrcweir m_aCommentEdt.SetText( m_pParent->m_aJobData.m_aComment );
565cdf0e10cSrcweir }
566cdf0e10cSrcweir
567cdf0e10cSrcweir // ------------------------------------------------------------------
568cdf0e10cSrcweir
save()569cdf0e10cSrcweir void RTSOtherPage::save()
570cdf0e10cSrcweir {
571cdf0e10cSrcweir int nMarginLeft = 0;
572cdf0e10cSrcweir int nMarginTop = 0;
573cdf0e10cSrcweir int nMarginRight = 0;
574cdf0e10cSrcweir int nMarginBottom = 0;
575cdf0e10cSrcweir
576cdf0e10cSrcweir if( m_pParent->m_aJobData.m_pParser )
577cdf0e10cSrcweir {
578cdf0e10cSrcweir m_pParent->m_aJobData.m_pParser->
579cdf0e10cSrcweir getMargins( m_pParent->m_aJobData.m_pParser->getDefaultPaperDimension(),
580cdf0e10cSrcweir nMarginLeft,
581cdf0e10cSrcweir nMarginRight,
582cdf0e10cSrcweir nMarginTop,
583cdf0e10cSrcweir nMarginBottom );
584cdf0e10cSrcweir }
585cdf0e10cSrcweir
586cdf0e10cSrcweir m_pParent->m_aJobData.m_nLeftMarginAdjust = m_aLeftLB.GetValue( FUNIT_POINT ) - nMarginLeft;
587cdf0e10cSrcweir m_pParent->m_aJobData.m_nRightMarginAdjust = m_aRightLB.GetValue( FUNIT_POINT ) - nMarginRight;
588cdf0e10cSrcweir m_pParent->m_aJobData.m_nTopMarginAdjust = m_aTopLB.GetValue( FUNIT_POINT ) - nMarginTop;
589cdf0e10cSrcweir m_pParent->m_aJobData.m_nBottomMarginAdjust = m_aBottomLB.GetValue( FUNIT_POINT ) - nMarginBottom;
590cdf0e10cSrcweir m_pParent->m_aJobData.m_aComment = m_aCommentEdt.GetText();
591cdf0e10cSrcweir }
592cdf0e10cSrcweir
593cdf0e10cSrcweir // ------------------------------------------------------------------
594cdf0e10cSrcweir
IMPL_LINK(RTSOtherPage,ClickBtnHdl,Button *,pButton)595cdf0e10cSrcweir IMPL_LINK( RTSOtherPage, ClickBtnHdl, Button*, pButton )
596cdf0e10cSrcweir {
597cdf0e10cSrcweir if( pButton == &m_aDefaultBtn )
598cdf0e10cSrcweir {
599cdf0e10cSrcweir m_pParent->m_aJobData.m_nLeftMarginAdjust =
600cdf0e10cSrcweir m_pParent->m_aJobData.m_nRightMarginAdjust =
601cdf0e10cSrcweir m_pParent->m_aJobData.m_nTopMarginAdjust =
602cdf0e10cSrcweir m_pParent->m_aJobData.m_nBottomMarginAdjust = 0;
603cdf0e10cSrcweir
604cdf0e10cSrcweir initValues();
605cdf0e10cSrcweir }
606cdf0e10cSrcweir return 0;
607cdf0e10cSrcweir }
608cdf0e10cSrcweir
609cdf0e10cSrcweir // ------------------------------------------------------------------
610cdf0e10cSrcweir
611cdf0e10cSrcweir /*
612cdf0e10cSrcweir * RTSFontSubstPage
613cdf0e10cSrcweir */
614cdf0e10cSrcweir
RTSFontSubstPage(RTSDialog * pParent)615cdf0e10cSrcweir RTSFontSubstPage::RTSFontSubstPage( RTSDialog* pParent ) :
616cdf0e10cSrcweir TabPage( &pParent->m_aTabControl, PaResId( RID_RTS_FONTSUBSTPAGE ) ),
617cdf0e10cSrcweir m_pParent( pParent ),
618cdf0e10cSrcweir m_aSubstitutionsText( this, PaResId( RID_RTS_FS_SUBST_TXT ) ),
619cdf0e10cSrcweir m_aSubstitutionsBox( this, PaResId( RID_RTS_FS_SUBST_BOX ) ),
620cdf0e10cSrcweir m_aFromFontText( this, PaResId( RID_RTS_FS_FROM_TXT ) ),
621cdf0e10cSrcweir m_aFromFontBox( this, PaResId( RID_RTS_FS_FROM_BOX ) ),
622cdf0e10cSrcweir m_aToFontText( this, PaResId( RID_RTS_FS_TO_TXT ) ),
623cdf0e10cSrcweir m_aToFontBox( this, PaResId( RID_RTS_FS_TO_BOX ) ),
624cdf0e10cSrcweir m_aAddButton( this, PaResId( RID_RTS_FS_ADD_BTN ) ),
625cdf0e10cSrcweir m_aRemoveButton( this, PaResId( RID_RTS_FS_REMOVE_BTN ) ),
626cdf0e10cSrcweir m_aEnableBox( this, PaResId( RID_RTS_FS_ENABLE_BTN ) )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir FreeResource();
629cdf0e10cSrcweir
630cdf0e10cSrcweir // fill to box
631cdf0e10cSrcweir PrintFontManager& rFontManager = PrintFontManager::get();
632cdf0e10cSrcweir ::std::list< FastPrintFontInfo > aFonts;
633cdf0e10cSrcweir rFontManager.getFontListWithFastInfo( aFonts, m_pParent->m_aJobData.m_pParser, false );
634cdf0e10cSrcweir ::std::list< FastPrintFontInfo >::const_iterator it;
635cdf0e10cSrcweir ::std::hash_map< OUString, int, OUStringHash > aToMap, aFromMap;
636cdf0e10cSrcweir for( it = aFonts.begin(); it != aFonts.end(); ++it )
637cdf0e10cSrcweir {
638cdf0e10cSrcweir if( it->m_eType == fonttype::Builtin )
639cdf0e10cSrcweir {
640cdf0e10cSrcweir if( aToMap.find( it->m_aFamilyName ) == aToMap.end() )
641cdf0e10cSrcweir {
642cdf0e10cSrcweir m_aToFontBox.InsertEntry( it->m_aFamilyName );
643cdf0e10cSrcweir aToMap[ it->m_aFamilyName ] = 1;
644cdf0e10cSrcweir }
645cdf0e10cSrcweir }
646cdf0e10cSrcweir else
647cdf0e10cSrcweir {
648cdf0e10cSrcweir if( aFromMap.find( it->m_aFamilyName ) == aFromMap.end() )
649cdf0e10cSrcweir {
650cdf0e10cSrcweir m_aFromFontBox.InsertEntry( it->m_aFamilyName );
651cdf0e10cSrcweir aFromMap[ it->m_aFamilyName ] = 1;
652cdf0e10cSrcweir }
653cdf0e10cSrcweir }
654cdf0e10cSrcweir }
655cdf0e10cSrcweir
656cdf0e10cSrcweir m_aEnableBox.Check( m_pParent->m_aJobData.m_bPerformFontSubstitution );
657cdf0e10cSrcweir m_aRemoveButton.Enable( sal_False );
658cdf0e10cSrcweir if( ! m_pParent->m_aJobData.m_bPerformFontSubstitution )
659cdf0e10cSrcweir {
660cdf0e10cSrcweir m_aSubstitutionsBox.Enable( sal_False );
661cdf0e10cSrcweir m_aSubstitutionsText.Enable( sal_False );
662cdf0e10cSrcweir m_aAddButton.Enable( sal_False );
663cdf0e10cSrcweir m_aToFontBox.Enable( sal_False );
664cdf0e10cSrcweir m_aToFontText.Enable( sal_False );
665cdf0e10cSrcweir m_aFromFontBox.Enable( sal_False );
666cdf0e10cSrcweir m_aFromFontText.Enable( sal_False );
667cdf0e10cSrcweir }
668cdf0e10cSrcweir
669cdf0e10cSrcweir update();
670cdf0e10cSrcweir
671cdf0e10cSrcweir m_aAddButton.SetClickHdl( LINK( this, RTSFontSubstPage, ClickBtnHdl ) );
672cdf0e10cSrcweir m_aRemoveButton.SetClickHdl( LINK( this, RTSFontSubstPage, ClickBtnHdl ) );
673cdf0e10cSrcweir m_aEnableBox.SetClickHdl( LINK( this, RTSFontSubstPage, ClickBtnHdl ) );
674cdf0e10cSrcweir m_aSubstitutionsBox.SetSelectHdl( LINK( this, RTSFontSubstPage, SelectHdl ) );
675cdf0e10cSrcweir m_aSubstitutionsBox.setDelPressedLink( LINK( this, RTSFontSubstPage, DelPressedHdl ) );
676cdf0e10cSrcweir }
677cdf0e10cSrcweir
~RTSFontSubstPage()678cdf0e10cSrcweir RTSFontSubstPage::~RTSFontSubstPage()
679cdf0e10cSrcweir {
680cdf0e10cSrcweir }
681cdf0e10cSrcweir
update()682cdf0e10cSrcweir void RTSFontSubstPage::update()
683cdf0e10cSrcweir {
684cdf0e10cSrcweir m_aSubstitutionsBox.Clear();
685cdf0e10cSrcweir m_aRemoveButton.Enable( sal_False );
686cdf0e10cSrcweir // fill substitutions box
687cdf0e10cSrcweir ::std::hash_map< OUString, OUString, OUStringHash >::const_iterator it;
688cdf0e10cSrcweir for( it = m_pParent->m_aJobData.m_aFontSubstitutes.begin();
689cdf0e10cSrcweir it != m_pParent->m_aJobData.m_aFontSubstitutes.end(); ++it )
690cdf0e10cSrcweir {
691cdf0e10cSrcweir String aEntry( it->first );
692cdf0e10cSrcweir aEntry.AppendAscii( " -> " );
693cdf0e10cSrcweir aEntry.Append( String( it->second ) );
694cdf0e10cSrcweir m_aSubstitutionsBox.InsertEntry( aEntry );
695cdf0e10cSrcweir }
696cdf0e10cSrcweir }
697cdf0e10cSrcweir
IMPL_LINK(RTSFontSubstPage,DelPressedHdl,ListBox *,pBox)698cdf0e10cSrcweir IMPL_LINK( RTSFontSubstPage, DelPressedHdl, ListBox*, pBox )
699cdf0e10cSrcweir {
700cdf0e10cSrcweir if( pBox == &m_aSubstitutionsBox &&
701cdf0e10cSrcweir m_aRemoveButton.IsEnabled() )
702cdf0e10cSrcweir ClickBtnHdl( &m_aRemoveButton );
703cdf0e10cSrcweir return 0;
704cdf0e10cSrcweir }
705cdf0e10cSrcweir
IMPL_LINK(RTSFontSubstPage,SelectHdl,ListBox *,pBox)706cdf0e10cSrcweir IMPL_LINK( RTSFontSubstPage, SelectHdl, ListBox*, pBox )
707cdf0e10cSrcweir {
708cdf0e10cSrcweir if( pBox == &m_aSubstitutionsBox )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir m_aRemoveButton.Enable( m_aSubstitutionsBox.GetSelectEntryCount() && m_pParent->m_aJobData.m_bPerformFontSubstitution );
711cdf0e10cSrcweir }
712cdf0e10cSrcweir return 0;
713cdf0e10cSrcweir }
714cdf0e10cSrcweir
IMPL_LINK(RTSFontSubstPage,ClickBtnHdl,Button *,pButton)715cdf0e10cSrcweir IMPL_LINK( RTSFontSubstPage, ClickBtnHdl, Button*, pButton )
716cdf0e10cSrcweir {
717cdf0e10cSrcweir if( pButton == &m_aAddButton )
718cdf0e10cSrcweir {
719cdf0e10cSrcweir m_pParent->m_aJobData.m_aFontSubstitutes[ m_aFromFontBox.GetText() ] = m_aToFontBox.GetSelectEntry();
720cdf0e10cSrcweir update();
721cdf0e10cSrcweir }
722cdf0e10cSrcweir else if( pButton == &m_aRemoveButton )
723cdf0e10cSrcweir {
724cdf0e10cSrcweir for( int i = 0; i < m_aSubstitutionsBox.GetSelectEntryCount(); i++ )
725cdf0e10cSrcweir {
726cdf0e10cSrcweir String aEntry( m_aSubstitutionsBox.GetSelectEntry( i ) );
727cdf0e10cSrcweir sal_uInt16 nPos = aEntry.SearchAscii( " -> " );
728cdf0e10cSrcweir aEntry.Erase( nPos );
729cdf0e10cSrcweir m_pParent->m_aJobData.m_aFontSubstitutes.erase( aEntry );
730cdf0e10cSrcweir }
731cdf0e10cSrcweir update();
732cdf0e10cSrcweir }
733cdf0e10cSrcweir else if( pButton == &m_aEnableBox )
734cdf0e10cSrcweir {
735cdf0e10cSrcweir m_pParent->m_aJobData.m_bPerformFontSubstitution = m_aEnableBox.IsChecked() ? true : false;
736cdf0e10cSrcweir m_aSubstitutionsBox.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
737cdf0e10cSrcweir m_aSubstitutionsText.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
738cdf0e10cSrcweir m_aAddButton.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
739cdf0e10cSrcweir m_aRemoveButton.Enable( m_aSubstitutionsBox.GetSelectEntryCount() && m_pParent->m_aJobData.m_bPerformFontSubstitution );
740cdf0e10cSrcweir m_aToFontBox.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
741cdf0e10cSrcweir m_aToFontText.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
742cdf0e10cSrcweir m_aFromFontBox.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
743cdf0e10cSrcweir m_aFromFontText.Enable( m_pParent->m_aJobData.m_bPerformFontSubstitution );
744cdf0e10cSrcweir }
745cdf0e10cSrcweir return 0;
746cdf0e10cSrcweir }
747cdf0e10cSrcweir
748cdf0e10cSrcweir
749cdf0e10cSrcweir class RTSPWDialog : public ModalDialog
750cdf0e10cSrcweir {
751cdf0e10cSrcweir FixedText m_aText;
752cdf0e10cSrcweir FixedText m_aUserText;
753cdf0e10cSrcweir Edit m_aUserEdit;
754cdf0e10cSrcweir FixedText m_aPassText;
755cdf0e10cSrcweir Edit m_aPassEdit;
756cdf0e10cSrcweir
757cdf0e10cSrcweir OKButton m_aOKButton;
758cdf0e10cSrcweir CancelButton m_aCancelButton;
759cdf0e10cSrcweir public:
760cdf0e10cSrcweir RTSPWDialog( const OString& rServer, const OString& rUserName, Window* pParent );
761cdf0e10cSrcweir ~RTSPWDialog();
762cdf0e10cSrcweir
763cdf0e10cSrcweir OString getUserName() const;
764cdf0e10cSrcweir OString getPassword() const;
765cdf0e10cSrcweir };
766cdf0e10cSrcweir
RTSPWDialog(const OString & rServer,const OString & rUserName,Window * pParent)767cdf0e10cSrcweir RTSPWDialog::RTSPWDialog( const OString& rServer, const OString& rUserName, Window* pParent )
768cdf0e10cSrcweir :
769cdf0e10cSrcweir ModalDialog( pParent, PaResId( RID_RTS_PWDIALOG ) ),
770cdf0e10cSrcweir m_aText( this, PaResId( RID_RTS_PWDIALOG_TXT ) ),
771cdf0e10cSrcweir m_aUserText( this, PaResId( RID_RTS_PWDIALOG_USER_TXT ) ),
772cdf0e10cSrcweir m_aUserEdit( this, PaResId( RID_RTS_PWDIALOG_USER_EDT ) ),
773cdf0e10cSrcweir m_aPassText( this, PaResId( RID_RTS_PWDIALOG_PASS_TXT ) ),
774cdf0e10cSrcweir m_aPassEdit( this, PaResId( RID_RTS_PWDIALOG_PASS_EDT ) ),
775cdf0e10cSrcweir m_aOKButton( this, PaResId( RID_RTS_PWDIALOG_OK_BTN ) ),
776cdf0e10cSrcweir m_aCancelButton( this, PaResId( RID_RTS_PWDIALOG_CANCEL_BTN ) )
777cdf0e10cSrcweir {
778cdf0e10cSrcweir FreeResource();
779cdf0e10cSrcweir String aText( m_aText.GetText() );
780cdf0e10cSrcweir aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), OStringToOUString( rServer, osl_getThreadTextEncoding() ) );
781cdf0e10cSrcweir m_aText.SetText( aText );
782cdf0e10cSrcweir m_aUserEdit.SetText( OStringToOUString( rUserName, osl_getThreadTextEncoding() ) );
783cdf0e10cSrcweir }
784cdf0e10cSrcweir
~RTSPWDialog()785cdf0e10cSrcweir RTSPWDialog::~RTSPWDialog()
786cdf0e10cSrcweir {
787cdf0e10cSrcweir }
788cdf0e10cSrcweir
getUserName() const789cdf0e10cSrcweir OString RTSPWDialog::getUserName() const
790cdf0e10cSrcweir {
791cdf0e10cSrcweir return rtl::OUStringToOString( m_aUserEdit.GetText(), osl_getThreadTextEncoding() );
792cdf0e10cSrcweir }
793cdf0e10cSrcweir
getPassword() const794cdf0e10cSrcweir OString RTSPWDialog::getPassword() const
795cdf0e10cSrcweir {
796cdf0e10cSrcweir return rtl::OUStringToOString( m_aPassEdit.GetText(), osl_getThreadTextEncoding() );
797cdf0e10cSrcweir }
798cdf0e10cSrcweir
799cdf0e10cSrcweir extern "C" {
800cdf0e10cSrcweir
Sal_SetupPrinterDriver(::psp::PrinterInfo & rJobData)801cdf0e10cSrcweir int SPA_DLLPUBLIC Sal_SetupPrinterDriver( ::psp::PrinterInfo& rJobData )
802cdf0e10cSrcweir {
803cdf0e10cSrcweir int nRet = 0;
804cdf0e10cSrcweir RTSDialog aDialog( rJobData, rJobData.m_aPrinterName, false );
805cdf0e10cSrcweir
806cdf0e10cSrcweir if( aDialog.Execute() )
807cdf0e10cSrcweir {
808cdf0e10cSrcweir rJobData = aDialog.getSetup();
809cdf0e10cSrcweir nRet = 1;
810cdf0e10cSrcweir }
811cdf0e10cSrcweir
812cdf0e10cSrcweir return nRet;
813cdf0e10cSrcweir }
814cdf0e10cSrcweir
Sal_queryFaxNumber(String & rNumber)815cdf0e10cSrcweir int SPA_DLLPUBLIC Sal_queryFaxNumber( String& rNumber )
816cdf0e10cSrcweir {
817cdf0e10cSrcweir String aTmpString( PaResId( RID_TXT_QUERYFAXNUMBER ) );
818cdf0e10cSrcweir QueryString aQuery( NULL, aTmpString, rNumber );
819cdf0e10cSrcweir return aQuery.Execute();
820cdf0e10cSrcweir }
821cdf0e10cSrcweir
Sal_authenticateQuery(const OString & rServer,OString & rUserName,OString & rPassword)822cdf0e10cSrcweir bool SPA_DLLPUBLIC Sal_authenticateQuery( const OString& rServer, OString& rUserName, OString& rPassword )
823cdf0e10cSrcweir {
824cdf0e10cSrcweir bool bRet = false;
825cdf0e10cSrcweir
826cdf0e10cSrcweir RTSPWDialog aDialog( rServer, rUserName, NULL );
827cdf0e10cSrcweir if( aDialog.Execute() )
828cdf0e10cSrcweir {
829cdf0e10cSrcweir rUserName = aDialog.getUserName();
830cdf0e10cSrcweir rPassword = aDialog.getPassword();
831cdf0e10cSrcweir bRet = true;
832cdf0e10cSrcweir }
833cdf0e10cSrcweir return bRet;
834cdf0e10cSrcweir }
835cdf0e10cSrcweir
836cdf0e10cSrcweir } // extern "C"
837