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