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