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