1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: prtsetup.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "prtsetup.hxx"
32 #include "helper.hxx" // for PaResId
33 #include "rtsetup.hrc"
36 #include "vcl/fontmanager.hxx"
38 #include "osl/thread.h"
40 #define LSCAPE_STRING String( RTL_CONSTASCII_USTRINGPARAM( "Landscape" ) )
41 #define PORTRAIT_STRING String( RTL_CONSTASCII_USTRINGPARAM( "Portrait" ) )
45 using namespace padmin
;
47 void RTSDialog::insertAllPPDValues( ListBox
& rBox
, const PPDKey
* pKey
)
52 const PPDValue
* pValue
= NULL
;
56 for( int i
= 0; i
< pKey
->countValues(); i
++ )
58 pValue
= pKey
->getValue( i
);
59 aOptionText
= pValue
->m_aOptionTranslation
.Len() ? pValue
->m_aOptionTranslation
: pValue
->m_aOption
;
61 if( m_aJobData
.m_aContext
.checkConstraints( pKey
, pValue
) )
63 if( rBox
.GetEntryPos( (void*)pValue
) == LISTBOX_ENTRY_NOTFOUND
)
65 nPos
= rBox
.InsertEntry( aOptionText
, LISTBOX_APPEND
);
66 rBox
.SetEntryData( nPos
, (void*)pValue
);
71 if( ( nPos
= rBox
.GetEntryPos( (void*)pValue
) ) != LISTBOX_ENTRY_NOTFOUND
)
72 rBox
.RemoveEntry( nPos
);
75 pValue
= m_aJobData
.m_aContext
.getValue( pKey
);
78 if( ( nPos
= rBox
.GetEntryPos( (void*)pValue
) ) != LISTBOX_ENTRY_NOTFOUND
)
79 rBox
.SelectEntryPos( nPos
);
82 rBox
.SelectEntry( m_aInvalidString
);
85 // --------------------------------------------------------------------------
91 RTSDialog::RTSDialog( const PrinterInfo
& rJobData
, const String
& rPrinter
, bool bAllPages
, Window
* pParent
) :
92 TabDialog( pParent
, PaResId( RID_RTS_RTSDIALOG
) ),
93 m_aJobData( rJobData
),
94 m_aPrinter( rPrinter
),
95 m_aTabControl( this, PaResId( RID_RTS_RTSDIALOG_TABCONTROL
) ),
97 m_aCancelButton( this ),
99 m_pDevicePage( NULL
),
100 m_pOtherPage( NULL
),
101 m_pFontSubstPage( NULL
),
102 m_pCommandPage( NULL
),
103 m_aInvalidString( PaResId( RID_RTS_RTSDIALOG_INVALID_TXT
) ),
104 m_aFromDriverString( PaResId( RID_RTS_RTSDIALOG_FROMDRIVER_TXT
) )
108 String
aTitle( GetText() );
109 aTitle
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), m_aJobData
.m_aPrinterName
);
114 m_aTabControl
.RemovePage( RID_RTS_OTHERPAGE
);
115 m_aTabControl
.RemovePage( RID_RTS_FONTSUBSTPAGE
);
116 m_aTabControl
.RemovePage( RID_RTS_COMMANDPAGE
);
118 else if( m_aJobData
.m_aDriverName
.compareToAscii( "CUPS:", 5 ) == 0 && ! PrinterInfoManager::get().isCUPSDisabled() )
120 // command page makes no sense for CUPS printers
121 m_aTabControl
.RemovePage( RID_RTS_COMMANDPAGE
);
124 m_aTabControl
.SetActivatePageHdl( LINK( this, RTSDialog
, ActivatePage
) );
125 m_aOKButton
.SetClickHdl( LINK( this, RTSDialog
, ClickButton
) );
126 m_aCancelButton
.SetClickHdl( LINK( this, RTSDialog
, ClickButton
) );
127 ActivatePage( &m_aTabControl
);
130 m_aCancelButton
.Show();
133 // --------------------------------------------------------------------------
135 RTSDialog::~RTSDialog()
140 delete m_pDevicePage
;
143 if( m_pFontSubstPage
)
144 delete m_pFontSubstPage
;
146 delete m_pCommandPage
;
149 // --------------------------------------------------------------------------
151 IMPL_LINK( RTSDialog
, ActivatePage
, TabControl
*, pTabCtrl
)
153 if( pTabCtrl
!= &m_aTabControl
)
156 USHORT nId
= m_aTabControl
.GetCurPageId();
158 if ( ! m_aTabControl
.GetTabPage( nId
) )
160 TabPage
*pPage
= NULL
;
161 if( nId
== RID_RTS_PAPERPAGE
)
162 pPage
= m_pPaperPage
= new RTSPaperPage( this );
163 else if( nId
== RID_RTS_DEVICEPAGE
)
164 pPage
= m_pDevicePage
= new RTSDevicePage( this );
165 else if( nId
== RID_RTS_OTHERPAGE
)
166 pPage
= m_pOtherPage
= new RTSOtherPage( this );
167 else if( nId
== RID_RTS_FONTSUBSTPAGE
)
168 pPage
= m_pFontSubstPage
= new RTSFontSubstPage( this );
169 else if( nId
== RID_RTS_COMMANDPAGE
)
170 pPage
= m_pCommandPage
= new RTSCommandPage( this );
172 m_aTabControl
.SetTabPage( nId
, pPage
);
178 case RID_RTS_PAPERPAGE
: m_pPaperPage
->update();break;
179 case RID_RTS_DEVICEPAGE
: m_pDevicePage
->update();break;
187 // --------------------------------------------------------------------------
189 IMPL_LINK( RTSDialog
, ClickButton
, Button
*, pButton
)
191 if( pButton
== &m_aOKButton
)
193 // refresh the changed values
197 m_aJobData
.m_eOrientation
= m_pPaperPage
->getOrientation().Equals( LSCAPE_STRING
) ? orientation::Landscape
: orientation::Portrait
;
201 m_aJobData
.m_nColorDepth
= m_pDevicePage
->getDepth();
202 m_aJobData
.m_nColorDevice
= m_pDevicePage
->getColorDevice();
203 m_aJobData
.m_nPSLevel
= m_pDevicePage
->getLevel();
206 // write other settings
207 m_pOtherPage
->save();
209 // write command settings
210 m_pCommandPage
->save();
214 else if( pButton
== &m_aCancelButton
)
220 // --------------------------------------------------------------------------
226 RTSPaperPage::RTSPaperPage( RTSDialog
* pParent
) :
227 TabPage( & pParent
->m_aTabControl
, PaResId( RID_RTS_PAPERPAGE
) ),
229 m_pParent( pParent
),
231 m_aPaperText( this, PaResId( RID_RTS_PAPER_PAPER_TXT
) ),
232 m_aPaperBox( this, PaResId( RID_RTS_PAPER_PAPER_BOX
) ),
233 m_aOrientText( this, PaResId( RID_RTS_PAPER_ORIENTATION_TXT
) ),
234 m_aOrientBox( this, PaResId( RID_RTS_PAPER_ORIENTATION_BOX
) ),
235 m_aDuplexText( this, PaResId( RID_RTS_PAPER_DUPLEX_TXT
) ),
236 m_aDuplexBox( this, PaResId( RID_RTS_PAPER_DUPLEX_BOX
) ),
237 m_aSlotText( this, PaResId( RID_RTS_PAPER_SLOT_TXT
) ),
238 m_aSlotBox( this, PaResId( RID_RTS_PAPER_SLOT_BOX
) )
240 m_aPaperBox
.SetSelectHdl( LINK( this, RTSPaperPage
, SelectHdl
) );
241 m_aOrientBox
.SetSelectHdl( LINK( this, RTSPaperPage
, SelectHdl
) );
242 m_aDuplexBox
.SetSelectHdl( LINK( this, RTSPaperPage
, SelectHdl
) );
243 m_aSlotBox
.SetSelectHdl( LINK( this, RTSPaperPage
, SelectHdl
) );
249 m_aOrientBox
.InsertEntry( PORTRAIT_STRING
);
250 m_aOrientBox
.InsertEntry( LSCAPE_STRING
);
252 nPos
= m_aDuplexBox
.InsertEntry( m_pParent
->m_aInvalidString
);
253 m_aDuplexBox
.SetEntryData( nPos
, NULL
);
255 // paper does not have an invalid entry
258 nPos
= m_aSlotBox
.InsertEntry( m_pParent
->m_aInvalidString
);
259 m_aSlotBox
.SetEntryData( nPos
, NULL
);
264 // --------------------------------------------------------------------------
266 RTSPaperPage::~RTSPaperPage()
270 // --------------------------------------------------------------------------
272 void RTSPaperPage::update()
274 const PPDKey
* pKey
= NULL
;
277 m_aOrientBox
.SelectEntry(
278 m_pParent
->m_aJobData
.m_eOrientation
== orientation::Landscape
279 ? LSCAPE_STRING
: PORTRAIT_STRING
);
282 if( m_pParent
->m_aJobData
.m_pParser
&&
283 (pKey
= m_pParent
->m_aJobData
.m_pParser
->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) )) )
285 m_pParent
->insertAllPPDValues( m_aDuplexBox
, pKey
);
289 m_aDuplexText
.Enable( FALSE
);
290 m_aDuplexBox
.Enable( FALSE
);
294 if( m_pParent
->m_aJobData
.m_pParser
&&
295 (pKey
= m_pParent
->m_aJobData
.m_pParser
->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) )) )
297 m_pParent
->insertAllPPDValues( m_aPaperBox
, pKey
);
301 m_aPaperText
.Enable( FALSE
);
302 m_aPaperBox
.Enable( FALSE
);
306 if( m_pParent
->m_aJobData
.m_pParser
&&
307 (pKey
= m_pParent
->m_aJobData
.m_pParser
->getKey( String::CreateFromAscii( "InputSlot" ) )) )
309 m_pParent
->insertAllPPDValues( m_aSlotBox
, pKey
);
313 m_aSlotText
.Enable( FALSE
);
314 m_aSlotBox
.Enable( FALSE
);
318 // --------------------------------------------------------------------------
320 IMPL_LINK( RTSPaperPage
, SelectHdl
, ListBox
*, pBox
)
322 const PPDKey
* pKey
= NULL
;
323 if( pBox
== &m_aPaperBox
)
325 if( m_pParent
->m_aJobData
.m_pParser
)
326 pKey
= m_pParent
->m_aJobData
.m_pParser
->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) );
328 else if( pBox
== &m_aDuplexBox
)
330 if( m_pParent
->m_aJobData
.m_pParser
)
331 pKey
= m_pParent
->m_aJobData
.m_pParser
->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "Duplex" ) ) );
333 else if( pBox
== &m_aSlotBox
)
335 if( m_pParent
->m_aJobData
.m_pParser
)
336 pKey
= m_pParent
->m_aJobData
.m_pParser
->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) );
338 else if( pBox
== &m_aOrientBox
)
340 m_pParent
->m_aJobData
.m_eOrientation
= m_aOrientBox
.GetSelectEntry().Equals( LSCAPE_STRING
) ? orientation::Landscape
: orientation::Portrait
;
345 (PPDValue
*)pBox
->GetEntryData( pBox
->GetSelectEntryPos() );
346 m_pParent
->m_aJobData
.m_aContext
.setValue( pKey
, pValue
);
352 // --------------------------------------------------------------------------
358 RTSDevicePage::RTSDevicePage( RTSDialog
* pParent
) :
359 TabPage( & pParent
->m_aTabControl
, PaResId( RID_RTS_DEVICEPAGE
) ),
361 m_pParent( pParent
),
363 m_aSpaceColor( PaResId( RID_RTS_DEVICE_COLOR_TXT
) ),
364 m_aSpaceGray( PaResId( RID_RTS_DEVICE_GRAY_TXT
) ),
365 m_aPPDKeyText( this, PaResId( RID_RTS_DEVICE_PPDKEY_TXT
) ),
366 m_aPPDKeyBox( this, PaResId( RID_RTS_DEVICE_PPDKEY_BOX
) ),
367 m_aPPDValueText( this, PaResId( RID_RTS_DEVICE_PPDVALUE_TXT
) ),
368 m_aPPDValueBox( this, PaResId( RID_RTS_DEVICE_PPDVALUE_BOX
) ),
369 m_aLevelText( this, PaResId( RID_RTS_DEVICE_LEVEL_TXT
) ),
370 m_aLevelBox( this, PaResId( RID_RTS_DEVICE_LEVEL_BOX
) ),
371 m_aSpaceText( this, PaResId( RID_RTS_DEVICE_SPACE_TXT
) ),
372 m_aSpaceBox( this, PaResId( RID_RTS_DEVICE_SPACE_BOX
) ),
373 m_aDepthText( this, PaResId( RID_RTS_DEVICE_DEPTH_TXT
) ),
374 m_aDepthBox( this, PaResId( RID_RTS_DEVICE_DEPTH_BOX
) )
378 m_aPPDKeyBox
.SetSelectHdl( LINK( this, RTSDevicePage
, SelectHdl
) );
379 m_aPPDValueBox
.SetSelectHdl( LINK( this, RTSDevicePage
, SelectHdl
) );
381 m_aSpaceBox
.InsertEntry( m_pParent
->m_aFromDriverString
);
382 m_aSpaceBox
.InsertEntry( m_aSpaceColor
);
383 m_aSpaceBox
.InsertEntry( m_aSpaceGray
);
384 switch( m_pParent
->m_aJobData
.m_nColorDevice
)
386 case -1: m_aSpaceBox
.SelectEntry( m_aSpaceGray
);break;
387 case 0: m_aSpaceBox
.SelectEntry( m_pParent
->m_aFromDriverString
);break;
388 case 1: m_aSpaceBox
.SelectEntry( m_aSpaceColor
);break;
391 m_aLevelBox
.InsertEntry( m_pParent
->m_aFromDriverString
);
392 m_aLevelBox
.InsertEntry( String( RTL_CONSTASCII_USTRINGPARAM( "1" ) ) );
393 m_aLevelBox
.InsertEntry( String( RTL_CONSTASCII_USTRINGPARAM( "2" ) ) );
394 if( m_pParent
->m_aJobData
.m_nPSLevel
== 0 )
395 m_aLevelBox
.SelectEntry( m_pParent
->m_aFromDriverString
);
397 m_aLevelBox
.SelectEntry( String::CreateFromInt32( m_pParent
->m_aJobData
.m_nPSLevel
) );
399 m_aDepthBox
.SelectEntry( String::CreateFromInt32( m_pParent
->m_aJobData
.m_nColorDepth
).AppendAscii( " Bit" ) );
402 if( m_pParent
->m_aJobData
.m_pParser
)
404 for( int i
= 0; i
< m_pParent
->m_aJobData
.m_pParser
->getKeys(); i
++ )
406 const PPDKey
* pKey
= m_pParent
->m_aJobData
.m_pParser
->getKey( i
);
407 if( pKey
->isUIKey() &&
408 ! pKey
->getKey().EqualsAscii( "PageSize" ) &&
409 ! pKey
->getKey().EqualsAscii( "InputSlot" ) &&
410 ! pKey
->getKey().EqualsAscii( "PageRegion" ) &&
411 ! pKey
->getKey().EqualsAscii( "Duplex" )
415 m_aPPDKeyBox
.InsertEntry( pKey
->getUITranslation().Len() ? pKey
->getUITranslation() : pKey
->getKey() );
416 m_aPPDKeyBox
.SetEntryData( nPos
, (void*)pKey
);
422 // --------------------------------------------------------------------------
424 RTSDevicePage::~RTSDevicePage()
428 // --------------------------------------------------------------------------
430 void RTSDevicePage::update()
434 // ------------------------------------------------------------------
436 IMPL_LINK( RTSDevicePage
, SelectHdl
, ListBox
*, pBox
)
438 if( pBox
== &m_aPPDKeyBox
)
440 const PPDKey
* pKey
= (PPDKey
*)m_aPPDKeyBox
.GetEntryData( m_aPPDKeyBox
.GetSelectEntryPos() );
441 FillValueBox( pKey
);
443 else if( pBox
== &m_aPPDValueBox
)
445 const PPDKey
* pKey
= (PPDKey
*)m_aPPDKeyBox
.GetEntryData( m_aPPDKeyBox
.GetSelectEntryPos() );
446 const PPDValue
* pValue
= (PPDValue
*)m_aPPDValueBox
.GetEntryData( m_aPPDValueBox
.GetSelectEntryPos() );
449 m_pParent
->m_aJobData
.m_aContext
.setValue( pKey
, pValue
);
450 FillValueBox( pKey
);
456 // ------------------------------------------------------------------
458 void RTSDevicePage::FillValueBox( const PPDKey
* pKey
)
460 m_aPPDValueBox
.Clear();
465 const PPDValue
* pValue
= NULL
;
466 for( int i
= 0; i
< pKey
->countValues(); i
++ )
468 pValue
= pKey
->getValue( i
);
469 if( m_pParent
->m_aJobData
.m_aContext
.checkConstraints( pKey
, pValue
) )
472 m_aPPDValueBox
.InsertEntry( pValue
->m_aOptionTranslation
.Len() ? pValue
->m_aOptionTranslation
: pValue
->m_aOption
);
473 m_aPPDValueBox
.SetEntryData( nPos
, (void*)pValue
);
476 pValue
= m_pParent
->m_aJobData
.m_aContext
.getValue( pKey
);
477 m_aPPDValueBox
.SelectEntryPos( m_aPPDValueBox
.GetEntryPos( (void*)pValue
) );
480 // --------------------------------------------------------------------------
486 RTSOtherPage::RTSOtherPage( RTSDialog
* pParent
) :
487 TabPage( &pParent
->m_aTabControl
, PaResId( RID_RTS_OTHERPAGE
) ),
488 m_pParent( pParent
),
489 m_aLeftTxt( this, PaResId( RID_RTS_OTHER_LEFTMARGIN_TXT
) ),
490 m_aLeftLB( this, PaResId( RID_RTS_OTHER_LEFTMARGIN_BOX
) ),
491 m_aTopTxt( this, PaResId( RID_RTS_OTHER_TOPMARGIN_TXT
) ),
492 m_aTopLB( this, PaResId( RID_RTS_OTHER_TOPMARGIN_BOX
) ),
493 m_aRightTxt( this, PaResId( RID_RTS_OTHER_RIGHTMARGIN_TXT
) ),
494 m_aRightLB( this, PaResId( RID_RTS_OTHER_RIGHTMARGIN_BOX
) ),
495 m_aBottomTxt( this, PaResId( RID_RTS_OTHER_BOTTOMMARGIN_TXT
) ),
496 m_aBottomLB( this, PaResId( RID_RTS_OTHER_BOTTOMMARGIN_BOX
) ),
497 m_aCommentTxt( this, PaResId( RID_RTS_OTHER_COMMENT_TXT
) ),
498 m_aCommentEdt( this, PaResId( RID_RTS_OTHER_COMMENT_EDT
) ),
499 m_aDefaultBtn( this, PaResId( RID_RTS_OTHER_DEFAULT_BTN
) )
503 m_aTopLB
.EnableEmptyFieldValue( TRUE
);
504 m_aBottomLB
.EnableEmptyFieldValue( TRUE
);
505 m_aLeftLB
.EnableEmptyFieldValue( TRUE
);
506 m_aRightLB
.EnableEmptyFieldValue( TRUE
);
508 m_aDefaultBtn
.SetClickHdl( LINK( this, RTSOtherPage
, ClickBtnHdl
) );
513 // ------------------------------------------------------------------
515 RTSOtherPage::~RTSOtherPage()
519 // ------------------------------------------------------------------
521 void RTSOtherPage::initValues()
525 int nMarginRight
= 0;
526 int nMarginBottom
= 0;
528 if( m_pParent
->m_aJobData
.m_pParser
)
530 m_pParent
->m_aJobData
.m_pParser
->
531 getMargins( m_pParent
->m_aJobData
.m_pParser
->getDefaultPaperDimension(),
538 nMarginLeft
+= m_pParent
->m_aJobData
.m_nLeftMarginAdjust
;
539 nMarginRight
+= m_pParent
->m_aJobData
.m_nRightMarginAdjust
;
540 nMarginTop
+= m_pParent
->m_aJobData
.m_nTopMarginAdjust
;
541 nMarginBottom
+= m_pParent
->m_aJobData
.m_nBottomMarginAdjust
;
543 m_aLeftLB
.SetValue( nMarginLeft
, FUNIT_POINT
);
544 m_aRightLB
.SetValue( nMarginRight
, FUNIT_POINT
);
545 m_aTopLB
.SetValue( nMarginTop
, FUNIT_POINT
);
546 m_aBottomLB
.SetValue( nMarginBottom
, FUNIT_POINT
);
547 m_aCommentEdt
.SetText( m_pParent
->m_aJobData
.m_aComment
);
550 // ------------------------------------------------------------------
552 void RTSOtherPage::save()
556 int nMarginRight
= 0;
557 int nMarginBottom
= 0;
559 if( m_pParent
->m_aJobData
.m_pParser
)
561 m_pParent
->m_aJobData
.m_pParser
->
562 getMargins( m_pParent
->m_aJobData
.m_pParser
->getDefaultPaperDimension(),
569 m_pParent
->m_aJobData
.m_nLeftMarginAdjust
= m_aLeftLB
.GetValue( FUNIT_POINT
) - nMarginLeft
;
570 m_pParent
->m_aJobData
.m_nRightMarginAdjust
= m_aRightLB
.GetValue( FUNIT_POINT
) - nMarginRight
;
571 m_pParent
->m_aJobData
.m_nTopMarginAdjust
= m_aTopLB
.GetValue( FUNIT_POINT
) - nMarginTop
;
572 m_pParent
->m_aJobData
.m_nBottomMarginAdjust
= m_aBottomLB
.GetValue( FUNIT_POINT
) - nMarginBottom
;
573 m_pParent
->m_aJobData
.m_aComment
= m_aCommentEdt
.GetText();
576 // ------------------------------------------------------------------
578 IMPL_LINK( RTSOtherPage
, ClickBtnHdl
, Button
*, pButton
)
580 if( pButton
== &m_aDefaultBtn
)
582 m_pParent
->m_aJobData
.m_nLeftMarginAdjust
=
583 m_pParent
->m_aJobData
.m_nRightMarginAdjust
=
584 m_pParent
->m_aJobData
.m_nTopMarginAdjust
=
585 m_pParent
->m_aJobData
.m_nBottomMarginAdjust
= 0;
592 // ------------------------------------------------------------------
598 RTSFontSubstPage::RTSFontSubstPage( RTSDialog
* pParent
) :
599 TabPage( &pParent
->m_aTabControl
, PaResId( RID_RTS_FONTSUBSTPAGE
) ),
600 m_pParent( pParent
),
601 m_aSubstitutionsText( this, PaResId( RID_RTS_FS_SUBST_TXT
) ),
602 m_aSubstitutionsBox( this, PaResId( RID_RTS_FS_SUBST_BOX
) ),
603 m_aFromFontText( this, PaResId( RID_RTS_FS_FROM_TXT
) ),
604 m_aFromFontBox( this, PaResId( RID_RTS_FS_FROM_BOX
) ),
605 m_aToFontText( this, PaResId( RID_RTS_FS_TO_TXT
) ),
606 m_aToFontBox( this, PaResId( RID_RTS_FS_TO_BOX
) ),
607 m_aAddButton( this, PaResId( RID_RTS_FS_ADD_BTN
) ),
608 m_aRemoveButton( this, PaResId( RID_RTS_FS_REMOVE_BTN
) ),
609 m_aEnableBox( this, PaResId( RID_RTS_FS_ENABLE_BTN
) )
614 PrintFontManager
& rFontManager
= PrintFontManager::get();
615 ::std::list
< FastPrintFontInfo
> aFonts
;
616 rFontManager
.getFontListWithFastInfo( aFonts
, m_pParent
->m_aJobData
.m_pParser
, false );
617 ::std::list
< FastPrintFontInfo
>::const_iterator it
;
618 ::std::hash_map
< OUString
, int, OUStringHash
> aToMap
, aFromMap
;
619 for( it
= aFonts
.begin(); it
!= aFonts
.end(); ++it
)
621 if( it
->m_eType
== fonttype::Builtin
)
623 if( aToMap
.find( it
->m_aFamilyName
) == aToMap
.end() )
625 m_aToFontBox
.InsertEntry( it
->m_aFamilyName
);
626 aToMap
[ it
->m_aFamilyName
] = 1;
631 if( aFromMap
.find( it
->m_aFamilyName
) == aFromMap
.end() )
633 m_aFromFontBox
.InsertEntry( it
->m_aFamilyName
);
634 aFromMap
[ it
->m_aFamilyName
] = 1;
639 m_aEnableBox
.Check( m_pParent
->m_aJobData
.m_bPerformFontSubstitution
);
640 m_aRemoveButton
.Enable( FALSE
);
641 if( ! m_pParent
->m_aJobData
.m_bPerformFontSubstitution
)
643 m_aSubstitutionsBox
.Enable( FALSE
);
644 m_aSubstitutionsText
.Enable( FALSE
);
645 m_aAddButton
.Enable( FALSE
);
646 m_aToFontBox
.Enable( FALSE
);
647 m_aToFontText
.Enable( FALSE
);
648 m_aFromFontBox
.Enable( FALSE
);
649 m_aFromFontText
.Enable( FALSE
);
654 m_aAddButton
.SetClickHdl( LINK( this, RTSFontSubstPage
, ClickBtnHdl
) );
655 m_aRemoveButton
.SetClickHdl( LINK( this, RTSFontSubstPage
, ClickBtnHdl
) );
656 m_aEnableBox
.SetClickHdl( LINK( this, RTSFontSubstPage
, ClickBtnHdl
) );
657 m_aSubstitutionsBox
.SetSelectHdl( LINK( this, RTSFontSubstPage
, SelectHdl
) );
658 m_aSubstitutionsBox
.setDelPressedLink( LINK( this, RTSFontSubstPage
, DelPressedHdl
) );
661 RTSFontSubstPage::~RTSFontSubstPage()
665 void RTSFontSubstPage::update()
667 m_aSubstitutionsBox
.Clear();
668 m_aRemoveButton
.Enable( FALSE
);
669 // fill substitutions box
670 ::std::hash_map
< OUString
, OUString
, OUStringHash
>::const_iterator it
;
671 for( it
= m_pParent
->m_aJobData
.m_aFontSubstitutes
.begin();
672 it
!= m_pParent
->m_aJobData
.m_aFontSubstitutes
.end(); ++it
)
674 String
aEntry( it
->first
);
675 aEntry
.AppendAscii( " -> " );
676 aEntry
.Append( String( it
->second
) );
677 m_aSubstitutionsBox
.InsertEntry( aEntry
);
681 IMPL_LINK( RTSFontSubstPage
, DelPressedHdl
, ListBox
*, pBox
)
683 if( pBox
== &m_aSubstitutionsBox
&&
684 m_aRemoveButton
.IsEnabled() )
685 ClickBtnHdl( &m_aRemoveButton
);
689 IMPL_LINK( RTSFontSubstPage
, SelectHdl
, ListBox
*, pBox
)
691 if( pBox
== &m_aSubstitutionsBox
)
693 m_aRemoveButton
.Enable( m_aSubstitutionsBox
.GetSelectEntryCount() && m_pParent
->m_aJobData
.m_bPerformFontSubstitution
);
698 IMPL_LINK( RTSFontSubstPage
, ClickBtnHdl
, Button
*, pButton
)
700 if( pButton
== &m_aAddButton
)
702 m_pParent
->m_aJobData
.m_aFontSubstitutes
[ m_aFromFontBox
.GetText() ] = m_aToFontBox
.GetSelectEntry();
705 else if( pButton
== &m_aRemoveButton
)
707 for( int i
= 0; i
< m_aSubstitutionsBox
.GetSelectEntryCount(); i
++ )
709 String
aEntry( m_aSubstitutionsBox
.GetSelectEntry( i
) );
710 USHORT nPos
= aEntry
.SearchAscii( " -> " );
711 aEntry
.Erase( nPos
);
712 m_pParent
->m_aJobData
.m_aFontSubstitutes
.erase( aEntry
);
716 else if( pButton
== &m_aEnableBox
)
718 m_pParent
->m_aJobData
.m_bPerformFontSubstitution
= m_aEnableBox
.IsChecked() ? true : false;
719 m_aSubstitutionsBox
.Enable( m_pParent
->m_aJobData
.m_bPerformFontSubstitution
);
720 m_aSubstitutionsText
.Enable( m_pParent
->m_aJobData
.m_bPerformFontSubstitution
);
721 m_aAddButton
.Enable( m_pParent
->m_aJobData
.m_bPerformFontSubstitution
);
722 m_aRemoveButton
.Enable( m_aSubstitutionsBox
.GetSelectEntryCount() && m_pParent
->m_aJobData
.m_bPerformFontSubstitution
);
723 m_aToFontBox
.Enable( m_pParent
->m_aJobData
.m_bPerformFontSubstitution
);
724 m_aToFontText
.Enable( m_pParent
->m_aJobData
.m_bPerformFontSubstitution
);
725 m_aFromFontBox
.Enable( m_pParent
->m_aJobData
.m_bPerformFontSubstitution
);
726 m_aFromFontText
.Enable( m_pParent
->m_aJobData
.m_bPerformFontSubstitution
);
732 class RTSPWDialog
: public ModalDialog
735 FixedText m_aUserText
;
737 FixedText m_aPassText
;
740 OKButton m_aOKButton
;
741 CancelButton m_aCancelButton
;
743 RTSPWDialog( const OString
& rServer
, const OString
& rUserName
, Window
* pParent
);
746 OString
getUserName() const;
747 OString
getPassword() const;
750 RTSPWDialog::RTSPWDialog( const OString
& rServer
, const OString
& rUserName
, Window
* pParent
)
752 ModalDialog( pParent
, PaResId( RID_RTS_PWDIALOG
) ),
753 m_aText( this, PaResId( RID_RTS_PWDIALOG_TXT
) ),
754 m_aUserText( this, PaResId( RID_RTS_PWDIALOG_USER_TXT
) ),
755 m_aUserEdit( this, PaResId( RID_RTS_PWDIALOG_USER_EDT
) ),
756 m_aPassText( this, PaResId( RID_RTS_PWDIALOG_PASS_TXT
) ),
757 m_aPassEdit( this, PaResId( RID_RTS_PWDIALOG_PASS_EDT
) ),
758 m_aOKButton( this, PaResId( RID_RTS_PWDIALOG_OK_BTN
) ),
759 m_aCancelButton( this, PaResId( RID_RTS_PWDIALOG_CANCEL_BTN
) )
762 String
aText( m_aText
.GetText() );
763 aText
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), OStringToOUString( rServer
, osl_getThreadTextEncoding() ) );
764 m_aText
.SetText( aText
);
765 m_aUserEdit
.SetText( OStringToOUString( rUserName
, osl_getThreadTextEncoding() ) );
768 RTSPWDialog::~RTSPWDialog()
772 OString
RTSPWDialog::getUserName() const
774 return rtl::OUStringToOString( m_aUserEdit
.GetText(), osl_getThreadTextEncoding() );
777 OString
RTSPWDialog::getPassword() const
779 return rtl::OUStringToOString( m_aPassEdit
.GetText(), osl_getThreadTextEncoding() );
784 int Sal_SetupPrinterDriver( ::psp::PrinterInfo
& rJobData
)
787 RTSDialog
aDialog( rJobData
, rJobData
.m_aPrinterName
, false );
789 if( aDialog
.Execute() )
791 rJobData
= aDialog
.getSetup();
798 int Sal_queryFaxNumber( String
& rNumber
)
800 String
aTmpString( PaResId( RID_TXT_QUERYFAXNUMBER
) );
801 QueryString
aQuery( NULL
, aTmpString
, rNumber
);
802 return aQuery
.Execute();
805 bool Sal_authenticateQuery( const OString
& rServer
, OString
& rUserName
, OString
& rPassword
)
809 RTSPWDialog
aDialog( rServer
, rUserName
, NULL
);
810 if( aDialog
.Execute() )
812 rUserName
= aDialog
.getUserName();
813 rPassword
= aDialog
.getPassword();