Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <stdio.h>
21 : #include <tools/config.hxx>
22 : #include <vcl/msgbox.hxx>
23 : #include <vcl/svapp.hxx>
24 : #include <rtsetup.hrc>
25 : #include <cmddlg.hxx>
26 : #include <padialog.hxx>
27 : #include <helper.hxx>
28 : #include <prtsetup.hxx>
29 :
30 : using namespace psp;
31 : using namespace padmin;
32 :
33 : using ::rtl::OUString;
34 :
35 : #define PRINTER_PERSISTENCE_GROUP "KnownPrinterCommands"
36 : #define FAX_PERSISTENCE_GROUP "KnownFaxCommands"
37 : #define PDF_PERSISTENCE_GROUP "KnowPdfCommands"
38 : #define MAX_COMMANDS 50
39 :
40 0 : void CommandStore::getSystemPrintCommands( ::std::list< String >& rCommands )
41 : {
42 0 : static ::std::list< OUString > aSysCommands;
43 : static bool bOnce = false;
44 0 : if( ! bOnce )
45 : {
46 0 : bOnce = true;
47 0 : PrinterInfoManager::get().getSystemPrintCommands( aSysCommands );
48 : }
49 :
50 0 : ::std::list< OUString >::const_iterator it;
51 0 : for( it = aSysCommands.begin(); it != aSysCommands.end(); ++it )
52 0 : rCommands.push_back( *it );
53 0 : }
54 :
55 0 : void CommandStore::getSystemPdfCommands( ::std::list< String >& rCommands )
56 : {
57 : static bool bOnce = false;
58 0 : static ::std::list< String > aSysCommands;
59 :
60 0 : if( ! bOnce )
61 : {
62 0 : bOnce = true;
63 : char pBuffer[1024];
64 : FILE* pPipe;
65 0 : String aCommand;
66 0 : rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
67 :
68 0 : pPipe = popen( "which gs 2>/dev/null", "r" );
69 0 : if( pPipe )
70 : {
71 0 : if (fgets( pBuffer, sizeof( pBuffer ), pPipe ) != NULL)
72 : {
73 0 : int nLen = strlen( pBuffer );
74 0 : if( pBuffer[nLen-1] == '\n' ) // strip newline
75 0 : pBuffer[--nLen] = 0;
76 0 : aCommand = rtl::OUString(pBuffer, nLen, aEncoding);
77 0 : if( ( ( aCommand.GetChar( 0 ) == '/' )
78 0 : || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '/' )
79 0 : || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '.' && aCommand.GetChar( 2 ) == '/' ) )
80 : && nLen > 2
81 0 : && aCommand.GetChar( nLen-2 ) == 'g'
82 0 : && aCommand.GetChar( nLen-1 ) == 's' )
83 : {
84 0 : aCommand.AppendAscii( " -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=\"(OUTFILE)\" -" );
85 0 : aSysCommands.push_back( aCommand );
86 : }
87 : }
88 0 : pclose( pPipe );
89 : }
90 :
91 0 : pPipe = popen( "which distill 2>/dev/null", "r" );
92 0 : if( pPipe )
93 : {
94 0 : if (fgets( pBuffer, sizeof( pBuffer ), pPipe ) != NULL)
95 : {
96 0 : int nLen = strlen( pBuffer );
97 0 : if( pBuffer[nLen-1] == '\n' ) // strip newline
98 0 : pBuffer[--nLen] = 0;
99 0 : aCommand = rtl::OUString(pBuffer, nLen, aEncoding);
100 0 : if( ( ( aCommand.GetChar( 0 ) == '/' )
101 0 : || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '/' )
102 0 : || ( aCommand.GetChar( 0 ) == '.' && aCommand.GetChar( 1 ) == '.' && aCommand.GetChar( 2 ) == '/' ) )
103 : && nLen > 7
104 0 : && aCommand.Copy( nLen - 8 ).EqualsAscii( "/distill" ) )
105 : {
106 0 : aCommand.AppendAscii( " (TMP) ; mv `echo (TMP) | sed s/\\.ps\\$/.pdf/` \"(OUTFILE)\"" );
107 0 : aSysCommands.push_back( aCommand );
108 : }
109 : }
110 0 : pclose( pPipe );
111 0 : }
112 : }
113 0 : ::std::list< String >::const_iterator it;
114 0 : for( it = aSysCommands.begin(); it != aSysCommands.end(); ++it )
115 0 : rCommands.push_back( *it );
116 0 : }
117 :
118 :
119 :
120 0 : void CommandStore::getStoredCommands( const char* pGroup, ::std::list< String >& rCommands )
121 : {
122 0 : Config& rConfig( getPadminRC() );
123 0 : rConfig.SetGroup( pGroup );
124 0 : sal_Int32 nKeys = rConfig.GetKeyCount();
125 0 : ::std::list< String >::const_iterator it;
126 0 : while( nKeys-- )
127 : {
128 0 : String aCommand( rConfig.ReadKey(rtl::OString::valueOf(nKeys), RTL_TEXTENCODING_UTF8 ) );
129 0 : if( aCommand.Len() )
130 : {
131 0 : for( it = rCommands.begin(); it != rCommands.end() && *it != aCommand; ++it )
132 : ;
133 0 : if( it == rCommands.end() )
134 0 : rCommands.push_back( aCommand );
135 : }
136 0 : }
137 0 : }
138 :
139 0 : void CommandStore::setCommands(
140 : const char* pGroup,
141 : const ::std::list< String >& rCommands,
142 : const ::std::list< String >& rSysCommands
143 : )
144 : {
145 0 : Config& rConfig( getPadminRC() );
146 0 : rConfig.DeleteGroup( pGroup );
147 0 : rConfig.SetGroup( pGroup );
148 0 : ::std::list< String >::const_iterator it, loop;
149 0 : ::std::list< String > aWriteList;
150 :
151 0 : sal_Int32 nWritten = 0;
152 0 : for( it = rCommands.begin(); it != rCommands.end(); ++it )
153 : {
154 0 : if( it->Len() )
155 : {
156 0 : for( loop = rSysCommands.begin(); loop != rSysCommands.end() && *loop != *it; ++loop )
157 : ;
158 0 : if( loop == rSysCommands.end() )
159 : {
160 0 : aWriteList.push_back( *it );
161 0 : nWritten++;
162 : }
163 : }
164 : }
165 0 : while( nWritten > MAX_COMMANDS )
166 : {
167 0 : aWriteList.pop_front();
168 0 : nWritten--;
169 : }
170 0 : for( nWritten = 0, it = aWriteList.begin(); it != aWriteList.end(); ++it, ++nWritten )
171 0 : rConfig.WriteKey( rtl::OString::valueOf(nWritten), rtl::OUStringToOString(*it, RTL_TEXTENCODING_UTF8) );
172 0 : }
173 :
174 :
175 0 : void CommandStore::getPrintCommands( ::std::list< String >& rCommands )
176 : {
177 0 : rCommands.clear();
178 0 : getSystemPrintCommands( rCommands );
179 0 : getStoredCommands( PRINTER_PERSISTENCE_GROUP, rCommands );
180 0 : }
181 :
182 0 : void CommandStore::getPdfCommands( ::std::list< String >& rCommands )
183 : {
184 0 : rCommands.clear();
185 0 : getSystemPdfCommands( rCommands );
186 0 : getStoredCommands( PDF_PERSISTENCE_GROUP, rCommands );
187 0 : }
188 :
189 0 : void CommandStore::getFaxCommands( ::std::list< String >& rCommands )
190 : {
191 0 : rCommands.clear();
192 0 : getStoredCommands( FAX_PERSISTENCE_GROUP, rCommands );
193 0 : }
194 :
195 0 : void CommandStore::setPrintCommands( const ::std::list< String >& rCommands )
196 : {
197 0 : ::std::list< String > aSysCmds;
198 0 : getSystemPrintCommands( aSysCmds );
199 0 : setCommands( PRINTER_PERSISTENCE_GROUP, rCommands, aSysCmds );
200 0 : }
201 :
202 0 : void CommandStore::setPdfCommands( const ::std::list< String >& rCommands )
203 : {
204 0 : ::std::list< String > aSysCmds;
205 0 : getSystemPdfCommands( aSysCmds );
206 0 : setCommands( PDF_PERSISTENCE_GROUP, rCommands, aSysCmds );
207 0 : }
208 :
209 0 : void CommandStore::setFaxCommands( const ::std::list< String >& rCommands )
210 : {
211 0 : ::std::list< String > aSysCmds;
212 0 : setCommands( FAX_PERSISTENCE_GROUP, rCommands, aSysCmds );
213 0 : }
214 :
215 :
216 0 : RTSCommandPage::RTSCommandPage( RTSDialog* pParent ) :
217 : TabPage( pParent->m_pTabControl, PaResId( RID_RTS_COMMANDPAGE ) ),
218 : m_pParent( pParent ),
219 : m_aCommandsCB( this, PaResId( RID_RTS_CMD_CB_COMMANDS ) ),
220 : m_aExternalCB( this, PaResId( RID_RTS_CMD_CB_EXTERNAL ) ),
221 : m_aQuickFT( this, PaResId( RID_RTS_CMD_FT_QUICKCMD ) ),
222 : m_aQuickCB( this, PaResId( RIT_RTS_CMD_CB_QUICKCMD ) ),
223 : m_aCommandTitle( this, PaResId( RID_RTS_CMD_FL_INSTALL ) ),
224 : m_aPrinterName( this, PaResId( RID_RTS_CMD_TXT_PRTNAME ) ),
225 : m_aConnectedTo( this, PaResId( RID_RTS_CMD_TXT_CONNECT ) ),
226 : m_aPrinterFL( this, PaResId( RID_RTS_CMD_FL_DEFAULT ) ),
227 : m_aConfigureText( this, PaResId( RID_RTS_CMD_TXT_CONFIGURE ) ),
228 : m_aConfigureBox( this, PaResId( RID_RTS_CMD_LB_CONFIGURE ) ),
229 : m_aPdfDirectoryText( this, PaResId( RID_RTS_CMD_TXT_PDFDIR ) ),
230 : m_aPdfDirectoryButton( this, PaResId( RID_RTS_CMD_BTN_PDFDIR ) ),
231 : m_aPdfDirectoryEdit( this, PaResId( RID_RTS_CMD_EDT_PDFDIR ) ),
232 : m_aFaxSwallowBox( this, PaResId( RID_RTS_CMD_BOX_SWALLOWFAXNO ) ),
233 : m_aHelpButton( this, PaResId( RID_RTS_CMD_BTN_HELP ) ),
234 : m_aRemovePB( this, PaResId( RID_RTS_CMD_BTN_REMOVE ) ),
235 : m_aFaxHelp( PaResId( RID_RTS_CMD_STR_FAXHELP ) ),
236 : m_aPrinterHelp( PaResId( RID_RTS_CMD_STR_PRINTERHELP ) ),
237 0 : m_aPdfHelp( PaResId( RID_RTS_CMD_STR_PDFHELP ) )
238 : {
239 : // configuring as printer is only sensible in default print system
240 0 : PrinterInfoManager& rMgr( PrinterInfoManager::get() );
241 0 : if( rMgr.getType() == PrinterInfoManager::Default || rMgr.isCUPSDisabled() )
242 0 : m_nPrinterEntry = m_aConfigureBox.InsertEntry( String( PaResId( RID_RTS_CMD_STR_CONFIGURE_PRINTER ) ) );
243 : else
244 0 : m_nPrinterEntry = ~0;
245 0 : m_nFaxEntry = m_aConfigureBox.InsertEntry( String( PaResId( RID_RTS_CMD_STR_CONFIGURE_FAX ) ) );
246 0 : m_nPdfEntry = m_aConfigureBox.InsertEntry( String( PaResId( RID_RTS_CMD_STR_CONFIGURE_PDF ) ) );
247 :
248 0 : FreeResource();
249 :
250 0 : CommandStore::getPrintCommands( m_aPrinterCommands );
251 0 : CommandStore::getFaxCommands( m_aFaxCommands );
252 0 : CommandStore::getPdfCommands( m_aPdfCommands );
253 :
254 0 : m_aPrinterName.SetText( m_pParent->m_aPrinter );
255 :
256 0 : m_aCommandsCB.SetDoubleClickHdl( LINK( this, RTSCommandPage, DoubleClickHdl ) );
257 0 : m_aCommandsCB.SetSelectHdl( LINK( this, RTSCommandPage, SelectHdl ) );
258 0 : m_aCommandsCB.SetModifyHdl( LINK( this, RTSCommandPage, ModifyHdl ) );
259 0 : m_aConfigureBox.SetSelectHdl( LINK( this, RTSCommandPage, SelectHdl ) );
260 0 : m_aHelpButton.SetClickHdl( LINK( this, RTSCommandPage, ClickBtnHdl ) );
261 0 : m_aRemovePB.SetClickHdl( LINK( this, RTSCommandPage, ClickBtnHdl ) );
262 0 : m_aPdfDirectoryButton.SetClickHdl( LINK( this, RTSCommandPage, ClickBtnHdl ) );
263 0 : m_aExternalCB.SetToggleHdl( LINK( this, RTSCommandPage, ClickBtnHdl ) );
264 :
265 0 : m_aPdfDirectoryButton.Show( sal_False );
266 0 : m_aPdfDirectoryEdit.Show( sal_False );
267 0 : m_aPdfDirectoryText.Show( sal_False );
268 0 : m_aFaxSwallowBox.Show( sal_False );
269 0 : m_aCommandsCB.SetText( m_pParent->m_aJobData.m_aCommand );
270 0 : m_aQuickCB.SetText( m_pParent->m_aJobData.m_aQuickCommand );
271 :
272 0 : m_bWasFax = false;
273 0 : m_bWasPdf = false;
274 0 : m_aConfigureBox.SelectEntryPos( m_nPrinterEntry );
275 0 : sal_Int32 nIndex = 0;
276 0 : while( nIndex != -1 )
277 : {
278 0 : OUString aToken( m_pParent->m_aJobData.m_aFeatures.getToken( 0, ',', nIndex ) );
279 0 : if( ! aToken.compareToAscii( "fax", 3 ) )
280 : {
281 0 : m_bWasFax = true;
282 0 : m_aFaxSwallowBox.Show( sal_True );
283 0 : sal_Int32 nPos = 0;
284 0 : m_aFaxSwallowBox.Check( ! aToken.getToken( 1, '=', nPos ).compareToAscii( "swallow", 7 ) ? sal_True : sal_False );
285 0 : m_aConfigureBox.SelectEntryPos( m_nFaxEntry );
286 : }
287 0 : else if( ! aToken.compareToAscii( "pdf=", 4 ) )
288 : {
289 0 : m_bWasPdf = true;
290 0 : sal_Int32 nPos = 0;
291 0 : m_aPdfDirectoryEdit.SetText( aToken.getToken( 1, '=', nPos ) );
292 0 : m_aPdfDirectoryEdit.Show( sal_True );
293 0 : m_aPdfDirectoryButton.Show( sal_True );
294 0 : m_aPdfDirectoryText.Show( sal_True );
295 0 : m_aConfigureBox.SelectEntryPos( m_nPdfEntry );
296 : }
297 0 : else if( ! aToken.compareToAscii( "external_dialog" ) )
298 : {
299 0 : m_aExternalCB.Check();
300 0 : m_bWasExternalDialog = true;
301 : }
302 0 : }
303 :
304 0 : m_aQuickCB.Enable( m_aExternalCB.IsChecked() );
305 :
306 0 : String aString( m_aConnectedTo.GetText() );
307 0 : aString += String( m_pParent->m_aJobData.m_aCommand );
308 0 : m_aConnectedTo.SetText( aString );
309 :
310 0 : UpdateCommands();
311 0 : }
312 :
313 0 : RTSCommandPage::~RTSCommandPage()
314 : {
315 0 : }
316 :
317 0 : void RTSCommandPage::save()
318 : {
319 0 : String aCommand,aQuickCommand;
320 0 : bool bHaveFax = m_aConfigureBox.GetSelectEntryPos() == m_nFaxEntry ? true : false;
321 0 : bool bHavePdf = m_aConfigureBox.GetSelectEntryPos() == m_nPdfEntry ? true : false;
322 0 : ::std::list< String >::iterator it;
323 :
324 0 : String aFeatures;
325 0 : sal_Int32 nIndex = 0;
326 0 : String aOldPdfPath;
327 0 : bool bOldFaxSwallow = false;
328 0 : bool bFaxSwallow = m_aFaxSwallowBox.IsChecked() ? true : false;
329 0 : bool bExternalDialog = m_aExternalCB.IsChecked() ? true : false;
330 :
331 0 : while( nIndex != -1 )
332 : {
333 0 : OUString aToken( m_pParent->m_aJobData.m_aFeatures.getToken( 0, ',', nIndex ) );
334 0 : if( aToken.compareToAscii( "fax", 3 ) &&
335 0 : aToken.compareToAscii( "pdf", 3 ) &&
336 0 : aToken.compareToAscii( "external_dialog" )
337 : )
338 : {
339 0 : if( !aToken.isEmpty() )
340 : {
341 0 : if( aFeatures.Len() )
342 0 : aFeatures += ',';
343 0 : aFeatures += String( aToken );
344 : }
345 : }
346 0 : else if( ! aToken.compareToAscii( "pdf=", 4 ) )
347 : {
348 0 : sal_Int32 nPos = 0;
349 0 : aOldPdfPath = aToken.getToken( 1, '=', nPos );
350 : }
351 0 : else if( ! aToken.compareToAscii( "fax=", 4 ) )
352 : {
353 0 : sal_Int32 nPos = 0;
354 0 : bOldFaxSwallow = aToken.getToken( 1, '=', nPos ).compareToAscii( "swallow", 7 ) ? false : true;
355 : }
356 0 : }
357 0 : ::std::list< String >* pList = &m_aPrinterCommands;
358 0 : if( bExternalDialog )
359 : {
360 0 : if( aFeatures.Len() )
361 0 : aFeatures += ',';
362 0 : aFeatures.AppendAscii( "external_dialog" );
363 : }
364 0 : if( bHaveFax )
365 : {
366 0 : if( aFeatures.Len() )
367 0 : aFeatures += ',';
368 0 : aFeatures.AppendAscii( "fax=" );
369 0 : if( bFaxSwallow )
370 0 : aFeatures.AppendAscii( "swallow" );
371 0 : pList = &m_aFaxCommands;
372 : }
373 0 : if( bHavePdf )
374 : {
375 0 : if( aFeatures.Len() )
376 0 : aFeatures += ',';
377 0 : aFeatures.AppendAscii( "pdf=" );
378 0 : aFeatures.Append( m_aPdfDirectoryEdit.GetText() );
379 0 : pList = &m_aPdfCommands;
380 : }
381 0 : aCommand = m_aCommandsCB.GetText();
382 0 : aQuickCommand = m_aQuickCB.GetText();
383 0 : for( it = pList->begin(); it != pList->end() && *it != aCommand; ++it )
384 : ;
385 0 : if( it == pList->end() )
386 0 : pList->push_back( aCommand );
387 :
388 0 : if( aCommand != String( m_pParent->m_aJobData.m_aCommand ) ||
389 0 : aQuickCommand != String( m_pParent->m_aJobData.m_aQuickCommand ) ||
390 0 : ( m_bWasFax && ! bHaveFax ) ||
391 0 : ( ! m_bWasFax && bHaveFax ) ||
392 0 : ( m_bWasPdf && ! bHavePdf ) ||
393 0 : ( ! m_bWasPdf && bHavePdf ) ||
394 0 : ( bHavePdf && aOldPdfPath != m_aPdfDirectoryEdit.GetText() ) ||
395 : ( bHaveFax && bFaxSwallow != bOldFaxSwallow ) ||
396 0 : ( m_bWasExternalDialog && ! bExternalDialog ) ||
397 0 : ( ! m_bWasExternalDialog && bExternalDialog )
398 : )
399 : {
400 0 : m_pParent->m_aJobData.m_aCommand = aCommand;
401 0 : m_pParent->m_aJobData.m_aQuickCommand = aQuickCommand;
402 0 : m_pParent->m_aJobData.m_aFeatures = aFeatures;
403 :
404 0 : PrinterInfoManager::get().changePrinterInfo( m_pParent->m_aPrinter, m_pParent->m_aJobData );
405 : }
406 0 : CommandStore::setPrintCommands( m_aPrinterCommands );
407 0 : CommandStore::setFaxCommands( m_aFaxCommands );
408 0 : CommandStore::setPdfCommands( m_aPdfCommands );
409 0 : }
410 :
411 :
412 0 : IMPL_LINK( RTSCommandPage, SelectHdl, Control*, pBox )
413 : {
414 0 : if( pBox == &m_aConfigureBox )
415 : {
416 0 : sal_Bool bEnable = m_aConfigureBox.GetSelectEntryPos() == m_nPdfEntry ? sal_True : sal_False;
417 0 : m_aPdfDirectoryButton.Show( bEnable );
418 0 : m_aPdfDirectoryEdit.Show( bEnable );
419 0 : m_aPdfDirectoryText.Show( bEnable );
420 0 : bEnable = m_aConfigureBox.GetSelectEntryPos() == m_nFaxEntry ? sal_True : sal_False;
421 0 : m_aFaxSwallowBox.Show( bEnable );
422 0 : UpdateCommands();
423 : }
424 0 : else if( pBox == &m_aCommandsCB )
425 : {
426 0 : m_aRemovePB.Enable( sal_True );
427 : }
428 :
429 0 : return 0;
430 : }
431 :
432 0 : IMPL_LINK( RTSCommandPage, ClickBtnHdl, Button*, pButton )
433 : {
434 0 : if( pButton == & m_aPdfDirectoryButton )
435 : {
436 0 : String aPath( m_aPdfDirectoryEdit.GetText() );
437 0 : if( chooseDirectory( aPath ) )
438 0 : m_aPdfDirectoryEdit.SetText( aPath );
439 : }
440 0 : else if( pButton == &m_aRemovePB )
441 : {
442 0 : String aEntry( m_aCommandsCB.GetText() );
443 : ::std::list< String >* pList;
444 0 : if( m_aConfigureBox.GetSelectEntryPos() == m_nPrinterEntry )
445 0 : pList = &m_aPrinterCommands;
446 0 : else if( m_aConfigureBox.GetSelectEntryPos() == m_nFaxEntry )
447 0 : pList = &m_aFaxCommands;
448 : else
449 0 : pList = &m_aPdfCommands;
450 :
451 0 : pList->remove( aEntry );
452 0 : m_aCommandsCB.RemoveEntry( aEntry );
453 0 : m_aQuickCB.RemoveEntry( aEntry );
454 : }
455 0 : else if( pButton == &m_aHelpButton )
456 : {
457 0 : String aHelpText;
458 0 : if( m_aConfigureBox.GetSelectEntryPos() == m_nPrinterEntry )
459 0 : aHelpText = m_aPrinterHelp;
460 0 : else if( m_aConfigureBox.GetSelectEntryPos() == m_nFaxEntry )
461 0 : aHelpText = m_aFaxHelp;
462 0 : else if( m_aConfigureBox.GetSelectEntryPos() == m_nPdfEntry )
463 0 : aHelpText = m_aPdfHelp;
464 :
465 0 : InfoBox aBox( this, aHelpText );
466 0 : aBox.Execute();
467 : }
468 0 : else if( pButton == &m_aExternalCB )
469 : {
470 0 : m_aQuickCB.Enable( m_aExternalCB.IsChecked() );
471 : }
472 0 : return 0;
473 : }
474 :
475 0 : IMPL_LINK( RTSCommandPage, DoubleClickHdl, ComboBox*, pComboBox )
476 : {
477 0 : if( pComboBox == &m_aCommandsCB )
478 0 : ConnectCommand();
479 0 : return 0;
480 : }
481 :
482 0 : IMPL_LINK( RTSCommandPage, ModifyHdl, Edit*, pEdit )
483 : {
484 0 : if( pEdit == &m_aCommandsCB )
485 0 : m_aRemovePB.Enable( m_aCommandsCB.GetEntryPos( m_aCommandsCB.GetText() ) != LISTBOX_ENTRY_NOTFOUND );
486 :
487 0 : return 0;
488 : }
489 :
490 0 : void RTSCommandPage::UpdateCommands()
491 : {
492 0 : m_aCommandsCB.Clear();
493 0 : ::std::list< String >::iterator it;
494 0 : if( m_aConfigureBox.GetSelectEntryPos() == m_nPrinterEntry )
495 : {
496 0 : for( it = m_aPrinterCommands.begin(); it != m_aPrinterCommands.end(); ++it )
497 : {
498 0 : m_aCommandsCB.InsertEntry( *it );
499 0 : m_aQuickCB.InsertEntry( *it );
500 : }
501 0 : if( ! m_bWasFax )
502 0 : m_aCommandsCB.SetText( m_pParent->m_aJobData.m_aCommand );
503 : else
504 0 : m_aCommandsCB.SetText( String() );
505 : }
506 0 : else if( m_aConfigureBox.GetSelectEntryPos() == m_nFaxEntry )
507 : {
508 0 : for( it = m_aFaxCommands.begin(); it != m_aFaxCommands.end(); ++it )
509 : {
510 0 : m_aCommandsCB.InsertEntry( *it );
511 0 : m_aQuickCB.InsertEntry( *it );
512 : }
513 0 : if( m_bWasFax )
514 0 : m_aCommandsCB.SetText( m_pParent->m_aJobData.m_aCommand );
515 : else
516 0 : m_aCommandsCB.SetText( String() );
517 : }
518 0 : else if( m_aConfigureBox.GetSelectEntryPos() == m_nPdfEntry )
519 : {
520 0 : for( it = m_aPdfCommands.begin(); it != m_aPdfCommands.end(); ++it )
521 : {
522 0 : m_aCommandsCB.InsertEntry( *it );
523 0 : m_aQuickCB.InsertEntry( *it );
524 : }
525 0 : if( m_bWasPdf )
526 0 : m_aCommandsCB.SetText( m_pParent->m_aJobData.m_aCommand );
527 : else
528 0 : m_aCommandsCB.SetText( String() );
529 : }
530 0 : }
531 :
532 0 : void RTSCommandPage::ConnectCommand()
533 : {
534 0 : String aString( m_aConnectedTo.GetText().GetToken( 0, ':' ) );
535 0 : aString.AppendAscii( ": " );
536 0 : aString += m_aCommandsCB.GetText();
537 :
538 0 : m_aConnectedTo.SetText( aString );
539 0 : }
540 :
541 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|