adddlg.cxx (466d5a0b) | adddlg.cxx (b8c015e0) |
---|---|
1/************************************************************** | 1/************************************************************** |
2 * | 2 * |
3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at | 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at |
10 * | 10 * |
11 * http://www.apache.org/licenses/LICENSE-2.0 | 11 * http://www.apache.org/licenses/LICENSE-2.0 |
12 * | 12 * |
13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. | 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. |
19 * | 19 * |
20 *************************************************************/ 21 22 23 24#include <unistd.h> 25 26#include "adddlg.hxx" 27#include "newppdlg.hxx" --- 10 unchanged lines hidden (view full) --- 38 39using namespace rtl; 40using namespace psp; 41using namespace padmin; 42using namespace std; 43 44APTabPage::APTabPage( AddPrinterDialog* pParent, const ResId& rResId ) 45 : TabPage( pParent, rResId ), | 20 *************************************************************/ 21 22 23 24#include <unistd.h> 25 26#include "adddlg.hxx" 27#include "newppdlg.hxx" --- 10 unchanged lines hidden (view full) --- 38 39using namespace rtl; 40using namespace psp; 41using namespace padmin; 42using namespace std; 43 44APTabPage::APTabPage( AddPrinterDialog* pParent, const ResId& rResId ) 45 : TabPage( pParent, rResId ), |
46 m_aTitle( PaResId( RID_ADDP_STR_TITLE ) ), 47 m_pParent( pParent ) | 46 m_aTitle( PaResId( RID_ADDP_STR_TITLE ) ), 47 m_pParent( pParent ) |
48{ 49} 50 51APChooseDevicePage::APChooseDevicePage( AddPrinterDialog* pParent ) : 52 APTabPage( pParent, PaResId( RID_ADDP_PAGE_CHOOSEDEV ) ), 53 m_aPrinterBtn( this, PaResId( RID_ADDP_CHDEV_BTN_PRINTER ) ), 54 m_aFaxBtn( this, PaResId( RID_ADDP_CHDEV_BTN_FAX ) ), 55 m_aPDFBtn( this, PaResId( RID_ADDP_CHDEV_BTN_PDF ) ), 56 m_aOldBtn( this, PaResId( RID_ADDP_CHDEV_BTN_OLD ) ), 57 m_aOverTxt( this, PaResId( RID_ADDP_CHDEV_TXT_OVER ) ) 58{ 59 FreeResource(); 60 m_aPrinterBtn.Check( sal_True ); 61 m_aFaxBtn.Check( sal_False ); 62 m_aPDFBtn.Check( sal_False ); 63 m_aOldBtn.Check( sal_False ); | 48{ 49} 50 51APChooseDevicePage::APChooseDevicePage( AddPrinterDialog* pParent ) : 52 APTabPage( pParent, PaResId( RID_ADDP_PAGE_CHOOSEDEV ) ), 53 m_aPrinterBtn( this, PaResId( RID_ADDP_CHDEV_BTN_PRINTER ) ), 54 m_aFaxBtn( this, PaResId( RID_ADDP_CHDEV_BTN_FAX ) ), 55 m_aPDFBtn( this, PaResId( RID_ADDP_CHDEV_BTN_PDF ) ), 56 m_aOldBtn( this, PaResId( RID_ADDP_CHDEV_BTN_OLD ) ), 57 m_aOverTxt( this, PaResId( RID_ADDP_CHDEV_TXT_OVER ) ) 58{ 59 FreeResource(); 60 m_aPrinterBtn.Check( sal_True ); 61 m_aFaxBtn.Check( sal_False ); 62 m_aPDFBtn.Check( sal_False ); 63 m_aOldBtn.Check( sal_False ); |
64 if( ! AddPrinterDialog::getOldPrinterLocation().Len() ) 65 m_aOldBtn.Enable( sal_False ); 66 if( ! PrinterInfoManager::get().addOrRemovePossible() ) 67 { 68 m_aPrinterBtn.Check( sal_False ); 69 m_aFaxBtn.Check( sal_True ); 70 m_aPrinterBtn.Enable( sal_False ); 71 m_aOldBtn.Enable( sal_False ); 72 } | 64 if( ! AddPrinterDialog::getOldPrinterLocation().Len() ) 65 m_aOldBtn.Enable( sal_False ); 66 if( ! PrinterInfoManager::get().addOrRemovePossible() ) 67 { 68 m_aPrinterBtn.Check( sal_False ); 69 m_aFaxBtn.Check( sal_True ); 70 m_aPrinterBtn.Enable( sal_False ); 71 m_aOldBtn.Enable( sal_False ); 72 } |
73} 74 75APChooseDevicePage::~APChooseDevicePage() 76{ 77} 78 79bool APChooseDevicePage::check() 80{ --- 43 unchanged lines hidden (view full) --- 124} 125 126void APChooseDriverPage::fill( PrinterInfo& rInfo ) 127{ 128 sal_uInt16 nPos = m_aDriverBox.GetSelectEntryPos(); 129 String* pDriver = (String*)m_aDriverBox.GetEntryData( nPos ); 130 rInfo.m_aDriverName = *pDriver; 131#if OSL_DEBUG_LEVEL > 1 | 73} 74 75APChooseDevicePage::~APChooseDevicePage() 76{ 77} 78 79bool APChooseDevicePage::check() 80{ --- 43 unchanged lines hidden (view full) --- 124} 125 126void APChooseDriverPage::fill( PrinterInfo& rInfo ) 127{ 128 sal_uInt16 nPos = m_aDriverBox.GetSelectEntryPos(); 129 String* pDriver = (String*)m_aDriverBox.GetEntryData( nPos ); 130 rInfo.m_aDriverName = *pDriver; 131#if OSL_DEBUG_LEVEL > 1 |
132 fprintf( stderr, "m_aLastPrinterName = \"%s\", rInfo.m_aPrinterName = \"%s\"\n", 133 OUStringToOString( m_aLastPrinterName, RTL_TEXTENCODING_ISO_8859_1 ).getStr(), 134 OUStringToOString( rInfo.m_aPrinterName, RTL_TEXTENCODING_ISO_8859_1 ).getStr() ); | 132 fprintf( stderr, "m_aLastPrinterName = \"%s\", rInfo.m_aPrinterName = \"%s\"\n", 133 OUStringToOString( m_aLastPrinterName, RTL_TEXTENCODING_ISO_8859_1 ).getStr(), 134 OUStringToOString( rInfo.m_aPrinterName, RTL_TEXTENCODING_ISO_8859_1 ).getStr() ); |
135#endif 136 if( rInfo.m_aPrinterName.equals( m_aLastPrinterName ) ) 137 { 138 String aPrinter( AddPrinterDialog::uniquePrinterName( m_aDriverBox.GetEntry( nPos ) ) ); 139 rInfo.m_aPrinterName = m_aLastPrinterName = aPrinter; 140 } 141} 142 143void APChooseDriverPage::updateDrivers( bool bRefresh, const rtl::OUString& rSelectDriver ) 144{ 145 for( int k = 0; k < m_aDriverBox.GetEntryCount(); k++ ) 146 delete (String*)m_aDriverBox.GetEntryData( k ); 147 m_aDriverBox.Clear(); 148 | 135#endif 136 if( rInfo.m_aPrinterName.equals( m_aLastPrinterName ) ) 137 { 138 String aPrinter( AddPrinterDialog::uniquePrinterName( m_aDriverBox.GetEntry( nPos ) ) ); 139 rInfo.m_aPrinterName = m_aLastPrinterName = aPrinter; 140 } 141} 142 143void APChooseDriverPage::updateDrivers( bool bRefresh, const rtl::OUString& rSelectDriver ) 144{ 145 for( int k = 0; k < m_aDriverBox.GetEntryCount(); k++ ) 146 delete (String*)m_aDriverBox.GetEntryData( k ); 147 m_aDriverBox.Clear(); 148 |
149 std::list< rtl::OUString > aDrivers; 150 psp::PPDParser::getKnownPPDDrivers( aDrivers, bRefresh ); 151 152 rtl::OUString aSelectDriver( psp::PPDParser::getPPDPrinterName( rSelectDriver ) ); | 149 std::list< rtl::OUString > aDrivers; 150 psp::PPDParser::getKnownPPDDrivers( aDrivers, bRefresh ); |
153 | 151 |
154 rtl::OUString aSelectedEntry; 155 for( std::list< rtl::OUString >::const_iterator it = aDrivers.begin(); it != aDrivers.end(); ++it ) 156 { 157 rtl::OUString aDriver( psp::PPDParser::getPPDPrinterName( *it ) ); 158 if( aDriver.getLength() ) 159 { 160 int nPos = m_aDriverBox.InsertEntry( aDriver ); 161 m_aDriverBox.SetEntryData( nPos, new String( *it ) ); 162 if( aDriver == aSelectDriver ) 163 aSelectedEntry = aDriver; 164 } 165 } | 152 rtl::OUString aSelectDriver( psp::PPDParser::getPPDPrinterName( rSelectDriver ) ); |
166 | 153 |
167 m_aDriverBox.SelectEntry( aSelectedEntry ); | 154 rtl::OUString aSelectedEntry; 155 for( std::list< rtl::OUString >::const_iterator it = aDrivers.begin(); it != aDrivers.end(); ++it ) 156 { 157 rtl::OUString aDriver( psp::PPDParser::getPPDPrinterName( *it ) ); 158 if( aDriver.getLength() ) 159 { 160 int nPos = m_aDriverBox.InsertEntry( aDriver ); 161 m_aDriverBox.SetEntryData( nPos, new String( *it ) ); 162 if( aDriver == aSelectDriver ) 163 aSelectedEntry = aDriver; 164 } 165 } 166 167 m_aDriverBox.SelectEntry( aSelectedEntry ); |
168 m_aRemBtn.Enable( m_aDriverBox.GetEntryCount() > 0 ); 169} 170 171IMPL_LINK( APChooseDriverPage, DelPressedHdl, ListBox*, pListBox ) 172{ 173 if( pListBox == &m_aDriverBox ) 174 ClickBtnHdl( &m_aRemBtn ); 175 176 return 0; 177} 178 179IMPL_LINK( APChooseDriverPage, ClickBtnHdl, PushButton*, pButton ) 180{ 181 if( pButton == &m_aAddBtn ) 182 { 183 PPDImportDialog aDlg( this ); 184 if( aDlg.Execute() ) | 168 m_aRemBtn.Enable( m_aDriverBox.GetEntryCount() > 0 ); 169} 170 171IMPL_LINK( APChooseDriverPage, DelPressedHdl, ListBox*, pListBox ) 172{ 173 if( pListBox == &m_aDriverBox ) 174 ClickBtnHdl( &m_aRemBtn ); 175 176 return 0; 177} 178 179IMPL_LINK( APChooseDriverPage, ClickBtnHdl, PushButton*, pButton ) 180{ 181 if( pButton == &m_aAddBtn ) 182 { 183 PPDImportDialog aDlg( this ); 184 if( aDlg.Execute() ) |
185 { 186 const std::list< rtl::OUString >& rImported( aDlg.getImportedFiles() ); 187 if( rImported.empty() ) 188 updateDrivers( true ); 189 else 190 updateDrivers( true, rImported.front() ); 191 } | 185 { 186 const std::list< rtl::OUString >& rImported( aDlg.getImportedFiles() ); 187 if( rImported.empty() ) 188 updateDrivers( true ); 189 else 190 updateDrivers( true, rImported.front() ); 191 } |
192 } 193 else if( pButton == &m_aRemBtn ) 194 { 195 rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); 196 PrinterInfoManager& rPIManager( PrinterInfoManager::get() ); 197 198 for( int i = 0; i < m_aDriverBox.GetSelectEntryCount(); i++ ) 199 { 200 int nSelect = m_aDriverBox.GetSelectEntryPos(i); 201 String aDriver( *(String*)m_aDriverBox.GetEntryData( nSelect ) ); 202 if( aDriver.Len() ) 203 { | 192 } 193 else if( pButton == &m_aRemBtn ) 194 { 195 rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); 196 PrinterInfoManager& rPIManager( PrinterInfoManager::get() ); 197 198 for( int i = 0; i < m_aDriverBox.GetSelectEntryCount(); i++ ) 199 { 200 int nSelect = m_aDriverBox.GetSelectEntryPos(i); 201 String aDriver( *(String*)m_aDriverBox.GetEntryData( nSelect ) ); 202 if( aDriver.Len() ) 203 { |
204 // never delete the default driver 205 if( aDriver.EqualsIgnoreCaseAscii( "SGENPRT" ) ) 206 { | 204 // never delete the default driver 205 if( aDriver.EqualsIgnoreCaseAscii( "SGENPRT" ) ) 206 { |
207 String aText( PaResId( RID_ERR_REMOVESGENPRT ) ); 208 aText.SearchAndReplace( String::CreateFromAscii( "%s" ), m_aDriverBox.GetSelectEntry( i ) ); 209 ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aText ); 210 aErrorBox.SetText( m_aRemStr ); 211 aErrorBox.Execute(); | 207 String aText( PaResId( RID_ERR_REMOVESGENPRT ) ); 208 aText.SearchAndReplace( String::CreateFromAscii( "%s" ), m_aDriverBox.GetSelectEntry( i ) ); 209 ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aText ); 210 aErrorBox.SetText( m_aRemStr ); 211 aErrorBox.Execute(); |
212 continue; 213 } | 212 continue; 213 } |
214 215 PrinterInfo aDefInfo( rPIManager.getPrinterInfo( rPIManager.getDefaultPrinter() ) ); | 214 215 PrinterInfo aDefInfo( rPIManager.getPrinterInfo( rPIManager.getDefaultPrinter() ) ); |
216 // for comparisons convert to a OUString | 216 // for comparisons convert to a OUString |
217 OUString aPPD( aDriver ); 218 if( aDefInfo.m_aDriverName == aPPD ) 219 { 220 String aText( PaResId( RID_ERR_REMOVEDEFAULTDRIVER ) ); 221 aText.SearchAndReplace( String::CreateFromAscii( "%s" ), m_aDriverBox.GetSelectEntry( i ) ); 222 ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aText ); 223 aErrorBox.SetText( m_aRemStr ); 224 aErrorBox.Execute(); --- 33 unchanged lines hidden (view full) --- 258 for( it = aPrinters.begin(); it != aPrinters.end(); ++it ) 259 { 260 PrinterInfo aInfo( rPIManager.getPrinterInfo( *it ) ); 261 if( aInfo.m_aDriverName == aPPD ) 262 rPIManager.removePrinter( *it ); 263 } 264 265 std::list< rtl::OUString > aDirs; | 217 OUString aPPD( aDriver ); 218 if( aDefInfo.m_aDriverName == aPPD ) 219 { 220 String aText( PaResId( RID_ERR_REMOVEDEFAULTDRIVER ) ); 221 aText.SearchAndReplace( String::CreateFromAscii( "%s" ), m_aDriverBox.GetSelectEntry( i ) ); 222 ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aText ); 223 aErrorBox.SetText( m_aRemStr ); 224 aErrorBox.Execute(); --- 33 unchanged lines hidden (view full) --- 258 for( it = aPrinters.begin(); it != aPrinters.end(); ++it ) 259 { 260 PrinterInfo aInfo( rPIManager.getPrinterInfo( *it ) ); 261 if( aInfo.m_aDriverName == aPPD ) 262 rPIManager.removePrinter( *it ); 263 } 264 265 std::list< rtl::OUString > aDirs; |
266 // get only psprint's directories, not eventual system dirs | 266 // get only psprint's directories, not eventual system dirs |
267 psp::getPrinterPathList( aDirs, NULL ); | 267 psp::getPrinterPathList( aDirs, NULL ); |
268 std::list< rtl::OUString >::iterator dir; | 268 std::list< rtl::OUString >::iterator dir; |
269 for( dir = aDirs.begin(); dir != aDirs.end(); ++dir ) 270 { 271 ::std::list< String > aFiles; 272 ::std::list< String >::iterator file; | 269 for( dir = aDirs.begin(); dir != aDirs.end(); ++dir ) 270 { 271 ::std::list< String > aFiles; 272 ::std::list< String >::iterator file; |
273 OUStringBuffer aDir( *dir ); 274 aDir.append( sal_Unicode( '/' ) ); 275 aDir.appendAscii( PRINTER_PPDDIR ); 276 rtl::OUString aPPDDir( aDir.makeStringAndClear() ); | 273 OUStringBuffer aDir( *dir ); 274 aDir.append( sal_Unicode( '/' ) ); 275 aDir.appendAscii( PRINTER_PPDDIR ); 276 rtl::OUString aPPDDir( aDir.makeStringAndClear() ); |
277 FindFiles( aPPDDir, aFiles, String( RTL_CONSTASCII_USTRINGPARAM( "PS;PPD;PS.GZ;PPD.GZ" ) ), true ); 278 for( file = aFiles.begin(); file != aFiles.end(); ++file ) 279 { 280 String aFile( aPPDDir ); 281 if( aFile.GetChar( aFile.Len() ) != '/' ) 282 aFile.AppendAscii( "/" ); 283 aFile.Append( *file ); 284 285 int nPos = file->SearchBackward( '.' ); 286 if( file->Copy( 0, nPos ) == String( aPPD ) ) 287 { 288 ByteString aSysPath( aFile, aEncoding ); 289 if( unlink( aSysPath.GetBuffer() ) ) | 277 FindFiles( aPPDDir, aFiles, String( RTL_CONSTASCII_USTRINGPARAM( "PS;PPD;PS.GZ;PPD.GZ" ) ), true ); 278 for( file = aFiles.begin(); file != aFiles.end(); ++file ) 279 { 280 String aFile( aPPDDir ); 281 if( aFile.GetChar( aFile.Len() ) != '/' ) 282 aFile.AppendAscii( "/" ); 283 aFile.Append( *file ); 284 285 int nPos = file->SearchBackward( '.' ); 286 if( file->Copy( 0, nPos ) == String( aPPD ) ) 287 { 288 ByteString aSysPath( aFile, aEncoding ); 289 if( unlink( aSysPath.GetBuffer() ) ) |
290 { 291 String aText( PaResId( RID_ERR_REMOVEDRIVERFAILED ) ); 292 aText.SearchAndReplace( String::CreateFromAscii( "%s1" ), m_aDriverBox.GetSelectEntry( i ) ); 293 aText.SearchAndReplace( String::CreateFromAscii( "%s2" ), aFile ); 294 ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aText ); 295 aErrorBox.SetText( m_aRemStr ); 296 aErrorBox.Execute(); 297 } | 290 { 291 String aText( PaResId( RID_ERR_REMOVEDRIVERFAILED ) ); 292 aText.SearchAndReplace( String::CreateFromAscii( "%s1" ), m_aDriverBox.GetSelectEntry( i ) ); 293 aText.SearchAndReplace( String::CreateFromAscii( "%s2" ), aFile ); 294 ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aText ); 295 aErrorBox.SetText( m_aRemStr ); 296 aErrorBox.Execute(); 297 } |
298 } 299 } 300 } 301 } 302 } 303 updateDrivers(); 304 } 305 return 0; --- 58 unchanged lines hidden (view full) --- 364 m_aPdfDirTxt( this, PaResId( RID_ADDP_CMD_TXT_PDFDIR ) ), 365 m_aPdfDirEdt( this, PaResId( RID_ADDP_CMD_EDT_PDFDIR ) ), 366 m_aPdfDirBtn( this, PaResId( RID_ADDP_CMD_BTN_PDFDIR ) ), 367 m_eKind( eKind ) 368{ 369 FreeResource(); 370 ::std::list< String > aCommands; 371 if( m_eKind == DeviceKind::Printer ) | 298 } 299 } 300 } 301 } 302 } 303 updateDrivers(); 304 } 305 return 0; --- 58 unchanged lines hidden (view full) --- 364 m_aPdfDirTxt( this, PaResId( RID_ADDP_CMD_TXT_PDFDIR ) ), 365 m_aPdfDirEdt( this, PaResId( RID_ADDP_CMD_EDT_PDFDIR ) ), 366 m_aPdfDirBtn( this, PaResId( RID_ADDP_CMD_BTN_PDFDIR ) ), 367 m_eKind( eKind ) 368{ 369 FreeResource(); 370 ::std::list< String > aCommands; 371 if( m_eKind == DeviceKind::Printer ) |
372 { | 372 { |
373 m_aHelpBtn.Show( sal_False ); | 373 m_aHelpBtn.Show( sal_False ); |
374 Size aSize = m_aCommandTxt.GetSizePixel(); 375 aSize.Width() = m_aCommandBox.GetSizePixel().Width(); 376 m_aCommandTxt.SetSizePixel( aSize ); 377 } | 374 Size aSize = m_aCommandTxt.GetSizePixel(); 375 aSize.Width() = m_aCommandBox.GetSizePixel().Width(); 376 m_aCommandTxt.SetSizePixel( aSize ); 377 } |
378 if( m_eKind != DeviceKind::Pdf ) 379 { 380 m_aPdfDirBtn.Show( sal_False ); 381 m_aPdfDirEdt.Show( sal_False ); 382 m_aPdfDirTxt.Show( sal_False ); 383 } 384 switch( m_eKind ) 385 { 386 case DeviceKind::Printer: CommandStore::getPrintCommands( aCommands );break; 387 case DeviceKind::Fax: CommandStore::getFaxCommands( aCommands );break; 388 case DeviceKind::Pdf: CommandStore::getPdfCommands( aCommands );break; 389 } | 378 if( m_eKind != DeviceKind::Pdf ) 379 { 380 m_aPdfDirBtn.Show( sal_False ); 381 m_aPdfDirEdt.Show( sal_False ); 382 m_aPdfDirTxt.Show( sal_False ); 383 } 384 switch( m_eKind ) 385 { 386 case DeviceKind::Printer: CommandStore::getPrintCommands( aCommands );break; 387 case DeviceKind::Fax: CommandStore::getFaxCommands( aCommands );break; 388 case DeviceKind::Pdf: CommandStore::getPdfCommands( aCommands );break; 389 } |
390 // adjust height of command text and help button 391 Rectangle aPosSize( m_aCommandTxt.GetPosPixel(), m_aCommandTxt.GetSizePixel() ); 392 Rectangle aTextSize = m_aCommandTxt.GetTextRect( Rectangle( Point(), aPosSize.GetSize() ), m_aCommandTxt.GetText() ); 393 if( aTextSize.GetWidth() <= 2*(aPosSize.GetWidth()+1) ) 394 { 395 Size aNewSize( aPosSize.GetWidth(), aPosSize.GetHeight()*2/3 ); 396 if( aNewSize.Height() < m_aHelpBtn.GetSizePixel().Height()+2 ) 397 aNewSize.Height() = m_aHelpBtn.GetSizePixel().Height()+2; 398 Point aNewPos( aPosSize.Left(), aPosSize.Top() + aPosSize.GetHeight() - aNewSize.Height() ); 399 m_aCommandTxt.SetPosSizePixel( aNewPos, aNewSize ); 400 aNewPos.X() = m_aHelpBtn.GetPosPixel().X(); 401 m_aHelpBtn.SetPosPixel( aNewPos ); 402 } | 390 // adjust height of command text and help button 391 Rectangle aPosSize( m_aCommandTxt.GetPosPixel(), m_aCommandTxt.GetSizePixel() ); 392 Rectangle aTextSize = m_aCommandTxt.GetTextRect( Rectangle( Point(), aPosSize.GetSize() ), m_aCommandTxt.GetText() ); 393 if( aTextSize.GetWidth() <= 2*(aPosSize.GetWidth()+1) ) 394 { 395 Size aNewSize( aPosSize.GetWidth(), aPosSize.GetHeight()*2/3 ); 396 if( aNewSize.Height() < m_aHelpBtn.GetSizePixel().Height()+2 ) 397 aNewSize.Height() = m_aHelpBtn.GetSizePixel().Height()+2; 398 Point aNewPos( aPosSize.Left(), aPosSize.Top() + aPosSize.GetHeight() - aNewSize.Height() ); 399 m_aCommandTxt.SetPosSizePixel( aNewPos, aNewSize ); 400 aNewPos.X() = m_aHelpBtn.GetPosPixel().X(); 401 m_aHelpBtn.SetPosPixel( aNewPos ); 402 } |
403 | 403 |
404 // fill in commands | 404 // fill in commands |
405 ::std::list< String >::iterator it; 406 for( it = aCommands.begin(); it != aCommands.end(); ++it ) 407 m_aCommandBox.InsertEntry( *it ); 408 409 m_aHelpBtn.SetClickHdl( LINK( this, APCommandPage, ClickBtnHdl ) ); 410 m_aPdfDirBtn.SetClickHdl( LINK( this, APCommandPage, ClickBtnHdl ) ); | 405 ::std::list< String >::iterator it; 406 for( it = aCommands.begin(); it != aCommands.end(); ++it ) 407 m_aCommandBox.InsertEntry( *it ); 408 409 m_aHelpBtn.SetClickHdl( LINK( this, APCommandPage, ClickBtnHdl ) ); 410 m_aPdfDirBtn.SetClickHdl( LINK( this, APCommandPage, ClickBtnHdl ) ); |
411 if( m_eKind != DeviceKind::Printer ) 412 { 413 m_aCommandBox.SetModifyHdl( LINK( this, APCommandPage, ModifyHdl ) ); 414 m_pParent->enableNext( false ); 415 } | 411 if( m_eKind != DeviceKind::Printer ) 412 { 413 m_aCommandBox.SetModifyHdl( LINK( this, APCommandPage, ModifyHdl ) ); 414 m_pParent->enableNext( false ); 415 } |
416} 417 418APCommandPage::~APCommandPage() 419{ 420 ::std::list< String > aCommands; 421 String aLastCommand( m_aCommandBox.GetText() ); 422 for( int i = 0; i < m_aCommandBox.GetEntryCount(); i++ ) 423 { --- 14 unchanged lines hidden (view full) --- 438{ 439 if( pButton == &m_aHelpBtn ) 440 { 441 InfoBox aBox( this, m_aHelpTxt ); 442 aBox.Execute(); 443 } 444 else if( pButton == &m_aPdfDirBtn ) 445 { | 416} 417 418APCommandPage::~APCommandPage() 419{ 420 ::std::list< String > aCommands; 421 String aLastCommand( m_aCommandBox.GetText() ); 422 for( int i = 0; i < m_aCommandBox.GetEntryCount(); i++ ) 423 { --- 14 unchanged lines hidden (view full) --- 438{ 439 if( pButton == &m_aHelpBtn ) 440 { 441 InfoBox aBox( this, m_aHelpTxt ); 442 aBox.Execute(); 443 } 444 else if( pButton == &m_aPdfDirBtn ) 445 { |
446 String aPath( m_aPdfDirEdt.GetText() ); 447 if( chooseDirectory( aPath ) ) 448 m_aPdfDirEdt.SetText( aPath ); | 446 String aPath( m_aPdfDirEdt.GetText() ); 447 if( chooseDirectory( aPath ) ) 448 m_aPdfDirEdt.SetText( aPath ); |
449 } 450 return 0; 451} 452 453IMPL_LINK( APCommandPage, ModifyHdl, ComboBox*, pBox ) 454{ | 449 } 450 return 0; 451} 452 453IMPL_LINK( APCommandPage, ModifyHdl, ComboBox*, pBox ) 454{ |
455 if( pBox == &m_aCommandBox ) 456 { 457 m_pParent->enableNext( m_aCommandBox.GetText().Len() ); 458 } 459 return 0; | 455 if( pBox == &m_aCommandBox ) 456 { 457 m_pParent->enableNext( m_aCommandBox.GetText().Len() ); 458 } 459 return 0; |
460} 461 462bool APCommandPage::check() 463{ 464 return true; 465} 466 467void APCommandPage::fill( PrinterInfo& rInfo ) --- 7 unchanged lines hidden (view full) --- 475 : APTabPage( pParent, PaResId( RID_ADDP_PAGE_OLDPRINTERS ) ), 476 m_aOldPrinterTxt( this, PaResId( RID_ADDP_OLD_TXT_PRINTERS ) ), 477 m_aOldPrinterBox( this, PaResId( RID_ADDP_OLD_BOX_PRINTERS ) ), 478 m_aSelectAllBtn( this, PaResId( RID_ADDP_OLD_BTN_SELECTALL ) ) 479{ 480 FreeResource(); 481 482 m_aSelectAllBtn.SetClickHdl( LINK( this, APOldPrinterPage, ClickBtnHdl ) ); | 460} 461 462bool APCommandPage::check() 463{ 464 return true; 465} 466 467void APCommandPage::fill( PrinterInfo& rInfo ) --- 7 unchanged lines hidden (view full) --- 475 : APTabPage( pParent, PaResId( RID_ADDP_PAGE_OLDPRINTERS ) ), 476 m_aOldPrinterTxt( this, PaResId( RID_ADDP_OLD_TXT_PRINTERS ) ), 477 m_aOldPrinterBox( this, PaResId( RID_ADDP_OLD_BOX_PRINTERS ) ), 478 m_aSelectAllBtn( this, PaResId( RID_ADDP_OLD_BTN_SELECTALL ) ) 479{ 480 FreeResource(); 481 482 m_aSelectAllBtn.SetClickHdl( LINK( this, APOldPrinterPage, ClickBtnHdl ) ); |
483 rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); | 483 rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); |
484 | 484 |
485 String aFileName( AddPrinterDialog::getOldPrinterLocation() ); 486 Config aConfig( aFileName ); | 485 String aFileName( AddPrinterDialog::getOldPrinterLocation() ); 486 Config aConfig( aFileName ); |
487 | 487 |
488 // read defaults 489 aConfig.SetGroup( "Xprinter,PostScript" ); 490 ByteString aDefPageSize( aConfig.ReadKey( "PageSize" ) ); 491 ByteString aDefOrientation( aConfig.ReadKey( "Orientation" ) ); 492 ByteString aDefMarginLeft( aConfig.ReadKey( "MarginLeft" ) ); 493 ByteString aDefMarginRight( aConfig.ReadKey( "MarginRight" ) ); 494 ByteString aDefMarginTop( aConfig.ReadKey( "MarginTop" ) ); 495 ByteString aDefMarginBottom( aConfig.ReadKey( "MarginBottom" ) ); 496 ByteString aDefScale( aConfig.ReadKey( "Scale" ) ); 497 ByteString aDefCopies( aConfig.ReadKey( "Copies" ) ); 498 ByteString aDefDPI( aConfig.ReadKey( "DPI" ) ); | 488 // read defaults 489 aConfig.SetGroup( "Xprinter,PostScript" ); 490 ByteString aDefPageSize( aConfig.ReadKey( "PageSize" ) ); 491 ByteString aDefOrientation( aConfig.ReadKey( "Orientation" ) ); 492 ByteString aDefMarginLeft( aConfig.ReadKey( "MarginLeft" ) ); 493 ByteString aDefMarginRight( aConfig.ReadKey( "MarginRight" ) ); 494 ByteString aDefMarginTop( aConfig.ReadKey( "MarginTop" ) ); 495 ByteString aDefMarginBottom( aConfig.ReadKey( "MarginBottom" ) ); 496 ByteString aDefScale( aConfig.ReadKey( "Scale" ) ); 497 ByteString aDefCopies( aConfig.ReadKey( "Copies" ) ); 498 ByteString aDefDPI( aConfig.ReadKey( "DPI" ) ); |
499 | 499 |
500 aConfig.SetGroup( "devices" ); 501 int nDevices = aConfig.GetKeyCount(); 502 for( int nKey = 0; nKey < nDevices; nKey++ ) 503 { 504 aConfig.SetGroup( "devices" ); 505 ByteString aPrinter( aConfig.GetKeyName( nKey ) ); 506 ByteString aValue( aConfig.ReadKey( aPrinter ) ); 507 ByteString aPort( aValue.GetToken( 1, ',' ) ); 508 ByteString aDriver( aValue.GetToken( 0, ' ' ) ); 509 ByteString aPS( aValue.GetToken( 0, ',' ).GetToken( 1, ' ' ) ); 510 ByteString aNewDriver( aDriver ); 511 if( aDriver == "GENERIC" ) 512 aNewDriver = "SGENPRT"; | 500 aConfig.SetGroup( "devices" ); 501 int nDevices = aConfig.GetKeyCount(); 502 for( int nKey = 0; nKey < nDevices; nKey++ ) 503 { 504 aConfig.SetGroup( "devices" ); 505 ByteString aPrinter( aConfig.GetKeyName( nKey ) ); 506 ByteString aValue( aConfig.ReadKey( aPrinter ) ); 507 ByteString aPort( aValue.GetToken( 1, ',' ) ); 508 ByteString aDriver( aValue.GetToken( 0, ' ' ) ); 509 ByteString aPS( aValue.GetToken( 0, ',' ).GetToken( 1, ' ' ) ); 510 ByteString aNewDriver( aDriver ); 511 if( aDriver == "GENERIC" ) 512 aNewDriver = "SGENPRT"; |
513 | 513 |
514 if( aPS != "PostScript" ) 515 continue; | 514 if( aPS != "PostScript" ) 515 continue; |
516 | 516 |
517 const PPDParser* pParser = PPDParser::getParser( String( aNewDriver, aEncoding ) ); 518 if( pParser == NULL ) 519 { 520 String aText( PaResId( RID_TXT_DRIVERDOESNOTEXIST ) ); 521 aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s1" ) ), String( aPrinter, aEncoding ) ); 522 aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s2" ) ), String( aDriver, aEncoding ) ); 523 InfoBox aBox( this, aText ); 524 aBox.Execute(); 525 continue; 526 } | 517 const PPDParser* pParser = PPDParser::getParser( String( aNewDriver, aEncoding ) ); 518 if( pParser == NULL ) 519 { 520 String aText( PaResId( RID_TXT_DRIVERDOESNOTEXIST ) ); 521 aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s1" ) ), String( aPrinter, aEncoding ) ); 522 aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s2" ) ), String( aDriver, aEncoding ) ); 523 InfoBox aBox( this, aText ); 524 aBox.Execute(); 525 continue; 526 } |
527 | 527 |
528 // read the command 529 aConfig.SetGroup( "ports" ); 530 ByteString aCommand( aConfig.ReadKey( aPort ) ); 531 if( ! aCommand.Len() ) 532 { 533 String aText( PaResId( RID_TXT_PRINTERWITHOUTCOMMAND ) ); 534 aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), String( aPrinter, aEncoding ) ); 535 InfoBox aBox( this, aText ); 536 aBox.Execute(); 537 continue; 538 } | 528 // read the command 529 aConfig.SetGroup( "ports" ); 530 ByteString aCommand( aConfig.ReadKey( aPort ) ); 531 if( ! aCommand.Len() ) 532 { 533 String aText( PaResId( RID_TXT_PRINTERWITHOUTCOMMAND ) ); 534 aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), String( aPrinter, aEncoding ) ); 535 InfoBox aBox( this, aText ); 536 aBox.Execute(); 537 continue; 538 } |
539 540 | 539 540 |
541 String aUPrinter( AddPrinterDialog::uniquePrinterName( String( aPrinter, aEncoding ) ) ); | 541 String aUPrinter( AddPrinterDialog::uniquePrinterName( String( aPrinter, aEncoding ) ) ); |
542 | 542 |
543 PrinterInfo aInfo; 544 aInfo.m_aDriverName = String( aNewDriver, aEncoding ); 545 aInfo.m_pParser = pParser; 546 aInfo.m_aContext.setParser( pParser ); 547 aInfo.m_aPrinterName = aUPrinter; 548 aInfo.m_aCommand = String( aCommand, aEncoding ); | 543 PrinterInfo aInfo; 544 aInfo.m_aDriverName = String( aNewDriver, aEncoding ); 545 aInfo.m_pParser = pParser; 546 aInfo.m_aContext.setParser( pParser ); 547 aInfo.m_aPrinterName = aUPrinter; 548 aInfo.m_aCommand = String( aCommand, aEncoding ); |
549 | 549 |
550 // read the printer settings 551 ByteString aGroup( aDriver ); 552 aGroup += ",PostScript,"; 553 aGroup += aPort; 554 aConfig.SetGroup( aGroup ); | 550 // read the printer settings 551 ByteString aGroup( aDriver ); 552 aGroup += ",PostScript,"; 553 aGroup += aPort; 554 aConfig.SetGroup( aGroup ); |
555 | 555 |
556 aValue = aConfig.ReadKey( "PageSize", aDefPageSize ); 557 int nLeft, nRight, nTop, nBottom; 558 if( aValue.Len() && 559 aInfo.m_pParser->getMargins( String( aValue, aEncoding ), 560 nLeft, nRight, nTop, nBottom ) ) 561 { 562 const PPDKey* pKey = aInfo.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) ); 563 const PPDValue* pValue = pKey ? pKey->getValue( String( aValue, aEncoding ) ) : NULL; 564 if( pKey && pValue ) 565 aInfo.m_aContext.setValue( pKey, pValue ); 566 aValue = aConfig.ReadKey( "MarginLeft", aDefMarginLeft ); 567 if( aValue.Len() ) 568 aInfo.m_nLeftMarginAdjust = aValue.ToInt32() - (int)((double)nLeft * 35.27777778 ); 569 aValue = aConfig.ReadKey( "MarginRight", aDefMarginRight ); 570 if( aValue.Len() ) 571 aInfo.m_nRightMarginAdjust = aValue.ToInt32() - (int)((double)nRight * 35.27777778 ); 572 aValue = aConfig.ReadKey( "MarginTop", aDefMarginTop ); 573 if( aValue.Len() ) 574 aInfo.m_nTopMarginAdjust = aValue.ToInt32() - (int)((double)nTop * 35.27777778 ); 575 aValue = aConfig.ReadKey( "MarginBottom", aDefMarginBottom ); 576 if( aValue.Len() ) 577 aInfo.m_nBottomMarginAdjust = aValue.ToInt32() - (int)((double)nBottom * 35.27777778 ); 578 } | 556 aValue = aConfig.ReadKey( "PageSize", aDefPageSize ); 557 int nLeft, nRight, nTop, nBottom; 558 if( aValue.Len() && 559 aInfo.m_pParser->getMargins( String( aValue, aEncoding ), 560 nLeft, nRight, nTop, nBottom ) ) 561 { 562 const PPDKey* pKey = aInfo.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) ); 563 const PPDValue* pValue = pKey ? pKey->getValue( String( aValue, aEncoding ) ) : NULL; 564 if( pKey && pValue ) 565 aInfo.m_aContext.setValue( pKey, pValue ); 566 aValue = aConfig.ReadKey( "MarginLeft", aDefMarginLeft ); 567 if( aValue.Len() ) 568 aInfo.m_nLeftMarginAdjust = aValue.ToInt32() - (int)((double)nLeft * 35.27777778 ); 569 aValue = aConfig.ReadKey( "MarginRight", aDefMarginRight ); 570 if( aValue.Len() ) 571 aInfo.m_nRightMarginAdjust = aValue.ToInt32() - (int)((double)nRight * 35.27777778 ); 572 aValue = aConfig.ReadKey( "MarginTop", aDefMarginTop ); 573 if( aValue.Len() ) 574 aInfo.m_nTopMarginAdjust = aValue.ToInt32() - (int)((double)nTop * 35.27777778 ); 575 aValue = aConfig.ReadKey( "MarginBottom", aDefMarginBottom ); 576 if( aValue.Len() ) 577 aInfo.m_nBottomMarginAdjust = aValue.ToInt32() - (int)((double)nBottom * 35.27777778 ); 578 } |
579 | 579 |
580 aValue = aConfig.ReadKey( "Copies", aDefScale ); 581 if( aValue.Len() ) 582 aInfo.m_nCopies = aValue.ToInt32(); | 580 aValue = aConfig.ReadKey( "Copies", aDefScale ); 581 if( aValue.Len() ) 582 aInfo.m_nCopies = aValue.ToInt32(); |
583 | 583 |
584 aValue = aConfig.ReadKey( "Comment" ); 585 aInfo.m_aComment = String( aValue, aEncoding ); | 584 aValue = aConfig.ReadKey( "Comment" ); 585 aInfo.m_aComment = String( aValue, aEncoding ); |
586 | 586 |
587 aValue = aConfig.ReadKey( "Level" ); 588 if( aValue.Len() ) 589 aInfo.m_nPSLevel = aValue.ToInt32(); | 587 aValue = aConfig.ReadKey( "Level" ); 588 if( aValue.Len() ) 589 aInfo.m_nPSLevel = aValue.ToInt32(); |
590 | 590 |
591 aValue = aConfig.ReadKey( "Orientation", aDefOrientation ); 592 if( aValue.Len() ) 593 aInfo.m_eOrientation = aValue.CompareIgnoreCaseToAscii( "landscape" ) == COMPARE_EQUAL ? orientation::Landscape : orientation::Portrait; 594 int nGroupKeys = aConfig.GetKeyCount(); 595 for( int nPPDKey = 0; nPPDKey < nGroupKeys; nPPDKey++ ) 596 { 597 ByteString aPPDKey( aConfig.GetKeyName( nPPDKey ) ); 598 // ignore page region 599 // there are some ppd keys in old Xpdefaults that 600 // should never have been writte because they are defaults 601 // PageRegion leads to problems in conjunction 602 // with a not matching PageSize 603 if( aPPDKey.CompareTo( "PPD_", 4 ) == COMPARE_EQUAL && 604 aPPDKey != "PPD_PageRegion" 605 ) 606 { 607 aValue = aConfig.ReadKey( nPPDKey ); 608 aPPDKey.Erase( 0, 4 ); 609 const PPDKey* pKey = aInfo.m_pParser->getKey( String( aPPDKey, RTL_TEXTENCODING_ISO_8859_1 ) ); 610 const PPDValue* pValue = pKey ? ( aValue.Equals( "*nil" ) ? NULL : pKey->getValue( String( aValue, RTL_TEXTENCODING_ISO_8859_1 ) ) ) : NULL; 611 if( pKey ) 612 aInfo.m_aContext.setValue( pKey, pValue, true ); 613 } 614 } | 591 aValue = aConfig.ReadKey( "Orientation", aDefOrientation ); 592 if( aValue.Len() ) 593 aInfo.m_eOrientation = aValue.CompareIgnoreCaseToAscii( "landscape" ) == COMPARE_EQUAL ? orientation::Landscape : orientation::Portrait; 594 int nGroupKeys = aConfig.GetKeyCount(); 595 for( int nPPDKey = 0; nPPDKey < nGroupKeys; nPPDKey++ ) 596 { 597 ByteString aPPDKey( aConfig.GetKeyName( nPPDKey ) ); 598 // ignore page region 599 // there are some ppd keys in old Xpdefaults that 600 // should never have been written because they are defaults 601 // PageRegion leads to problems in conjunction 602 // with a not matching PageSize 603 if( aPPDKey.CompareTo( "PPD_", 4 ) == COMPARE_EQUAL && 604 aPPDKey != "PPD_PageRegion" 605 ) 606 { 607 aValue = aConfig.ReadKey( nPPDKey ); 608 aPPDKey.Erase( 0, 4 ); 609 const PPDKey* pKey = aInfo.m_pParser->getKey( String( aPPDKey, RTL_TEXTENCODING_ISO_8859_1 ) ); 610 const PPDValue* pValue = pKey ? ( aValue.Equals( "*nil" ) ? NULL : pKey->getValue( String( aValue, RTL_TEXTENCODING_ISO_8859_1 ) ) ) : NULL; 611 if( pKey ) 612 aInfo.m_aContext.setValue( pKey, pValue, true ); 613 } 614 } |
615 | 615 |
616 m_aOldPrinters.push_back( aInfo ); 617 int nPos = m_aOldPrinterBox.InsertEntry( aInfo.m_aPrinterName ); 618 m_aOldPrinterBox.SetEntryData( nPos, & m_aOldPrinters.back() ); 619 } | 616 m_aOldPrinters.push_back( aInfo ); 617 int nPos = m_aOldPrinterBox.InsertEntry( aInfo.m_aPrinterName ); 618 m_aOldPrinterBox.SetEntryData( nPos, & m_aOldPrinters.back() ); 619 } |
620} 621 622APOldPrinterPage::~APOldPrinterPage() 623{ 624} 625 626IMPL_LINK( APOldPrinterPage, ClickBtnHdl, PushButton*, pButton ) 627{ 628 if( pButton == &m_aSelectAllBtn ) 629 { | 620} 621 622APOldPrinterPage::~APOldPrinterPage() 623{ 624} 625 626IMPL_LINK( APOldPrinterPage, ClickBtnHdl, PushButton*, pButton ) 627{ 628 if( pButton == &m_aSelectAllBtn ) 629 { |
630 for( int i = 0; i < m_aOldPrinterBox.GetEntryCount(); i++ ) 631 m_aOldPrinterBox.SelectEntryPos( i ); 632 } | 630 for( int i = 0; i < m_aOldPrinterBox.GetEntryCount(); i++ ) 631 m_aOldPrinterBox.SelectEntryPos( i ); 632 } |
633 return 0; 634} 635 636void APOldPrinterPage::addOldPrinters() 637{ 638 PrinterInfoManager& rManager( PrinterInfoManager::get() ); 639 for( int i = 0; i < m_aOldPrinterBox.GetSelectEntryCount(); i++ ) 640 { --- 90 unchanged lines hidden (view full) --- 731 732AddPrinterDialog::AddPrinterDialog( Window* pParent ) 733 : ModalDialog( pParent, PaResId( RID_ADD_PRINTER_DIALOG ) ), 734 m_aCancelPB( this, PaResId( RID_ADDP_BTN_CANCEL ) ), 735 m_aPrevPB( this, PaResId( RID_ADDP_BTN_PREV ) ), 736 m_aNextPB( this, PaResId( RID_ADDP_BTN_NEXT ) ), 737 m_aFinishPB( this, PaResId( RID_ADDP_BTN_FINISH ) ), 738 m_aLine( this, PaResId( RID_ADDP_LINE ) ), | 633 return 0; 634} 635 636void APOldPrinterPage::addOldPrinters() 637{ 638 PrinterInfoManager& rManager( PrinterInfoManager::get() ); 639 for( int i = 0; i < m_aOldPrinterBox.GetSelectEntryCount(); i++ ) 640 { --- 90 unchanged lines hidden (view full) --- 731 732AddPrinterDialog::AddPrinterDialog( Window* pParent ) 733 : ModalDialog( pParent, PaResId( RID_ADD_PRINTER_DIALOG ) ), 734 m_aCancelPB( this, PaResId( RID_ADDP_BTN_CANCEL ) ), 735 m_aPrevPB( this, PaResId( RID_ADDP_BTN_PREV ) ), 736 m_aNextPB( this, PaResId( RID_ADDP_BTN_NEXT ) ), 737 m_aFinishPB( this, PaResId( RID_ADDP_BTN_FINISH ) ), 738 m_aLine( this, PaResId( RID_ADDP_LINE ) ), |
739 m_aTitleImage( this, PaResId( RID_ADDP_CTRL_TITLE ) ), | 739 m_aTitleImage( this, PaResId( RID_ADDP_CTRL_TITLE ) ), |
740 m_pCurrentPage( NULL ), 741 m_pChooseDevicePage( NULL ), 742 m_pCommandPage( NULL ), 743 m_pChooseDriverPage( NULL ), 744 m_pNamePage( NULL ), 745 m_pOldPrinterPage( NULL ), 746 m_pFaxDriverPage( NULL ), 747 m_pFaxSelectDriverPage( NULL ), --- 10 unchanged lines hidden (view full) --- 758 m_aFinishPB.Enable( sal_False ); 759 m_aPrevPB.Enable( sal_False ); 760 761 m_aNextPB.SetClickHdl( LINK( this, AddPrinterDialog, ClickBtnHdl ) ); 762 m_aPrevPB.SetClickHdl( LINK( this, AddPrinterDialog, ClickBtnHdl ) ); 763 m_aFinishPB.SetClickHdl( LINK( this, AddPrinterDialog, ClickBtnHdl ) ); 764 m_aCancelPB.SetClickHdl( LINK( this, AddPrinterDialog, ClickBtnHdl ) ); 765 | 740 m_pCurrentPage( NULL ), 741 m_pChooseDevicePage( NULL ), 742 m_pCommandPage( NULL ), 743 m_pChooseDriverPage( NULL ), 744 m_pNamePage( NULL ), 745 m_pOldPrinterPage( NULL ), 746 m_pFaxDriverPage( NULL ), 747 m_pFaxSelectDriverPage( NULL ), --- 10 unchanged lines hidden (view full) --- 758 m_aFinishPB.Enable( sal_False ); 759 m_aPrevPB.Enable( sal_False ); 760 761 m_aNextPB.SetClickHdl( LINK( this, AddPrinterDialog, ClickBtnHdl ) ); 762 m_aPrevPB.SetClickHdl( LINK( this, AddPrinterDialog, ClickBtnHdl ) ); 763 m_aFinishPB.SetClickHdl( LINK( this, AddPrinterDialog, ClickBtnHdl ) ); 764 m_aCancelPB.SetClickHdl( LINK( this, AddPrinterDialog, ClickBtnHdl ) ); 765 |
766 m_aTitleImage.SetBackgroundColor( Color( 0xff, 0xff, 0xff ) ); 767 m_aTitleImage.SetText( m_pCurrentPage->getTitle() ); 768 updateSettings(); | 766 m_aTitleImage.SetBackgroundColor( Color( 0xff, 0xff, 0xff ) ); 767 m_aTitleImage.SetText( m_pCurrentPage->getTitle() ); 768 updateSettings(); |
769} 770 771AddPrinterDialog::~AddPrinterDialog() 772{ 773 if( m_pChooseDevicePage ) 774 delete m_pChooseDevicePage; 775 if( m_pChooseDriverPage ) 776 delete m_pChooseDriverPage; --- 18 unchanged lines hidden (view full) --- 795 if( m_pPdfNamePage ) 796 delete m_pPdfNamePage; 797 if( m_pPdfCommandPage ) 798 delete m_pPdfCommandPage; 799} 800 801void AddPrinterDialog::updateSettings() 802{ | 769} 770 771AddPrinterDialog::~AddPrinterDialog() 772{ 773 if( m_pChooseDevicePage ) 774 delete m_pChooseDevicePage; 775 if( m_pChooseDriverPage ) 776 delete m_pChooseDriverPage; --- 18 unchanged lines hidden (view full) --- 795 if( m_pPdfNamePage ) 796 delete m_pPdfNamePage; 797 if( m_pPdfCommandPage ) 798 delete m_pPdfCommandPage; 799} 800 801void AddPrinterDialog::updateSettings() 802{ |
803 if( ! GetSettings().GetStyleSettings().GetHighContrastMode() ) 804 m_aTitleImage.SetImage( Image( BitmapEx( PaResId( RID_BMP_PRINTER ) ) ) ); 805 else 806 m_aTitleImage.SetImage( Image( BitmapEx( PaResId( RID_BMP_PRINTER_HC ) ) ) ); | 803 if( ! GetSettings().GetStyleSettings().GetHighContrastMode() ) 804 m_aTitleImage.SetImage( Image( BitmapEx( PaResId( RID_BMP_PRINTER ) ) ) ); 805 else 806 m_aTitleImage.SetImage( Image( BitmapEx( PaResId( RID_BMP_PRINTER_HC ) ) ) ); |
807} 808 809void AddPrinterDialog::DataChanged( const DataChangedEvent& rEv ) 810{ | 807} 808 809void AddPrinterDialog::DataChanged( const DataChangedEvent& rEv ) 810{ |
811 ModalDialog::DataChanged( rEv ); 812 if( (rEv.GetType() == DATACHANGED_SETTINGS) && 813 (rEv.GetFlags() & SETTINGS_STYLE) ) 814 { 815 updateSettings(); 816 } | 811 ModalDialog::DataChanged( rEv ); 812 if( (rEv.GetType() == DATACHANGED_SETTINGS) && 813 (rEv.GetFlags() & SETTINGS_STYLE) ) 814 { 815 updateSettings(); 816 } |
817} 818 819void AddPrinterDialog::advance() 820{ 821 m_pCurrentPage->Show( sal_False ); 822 if( m_pCurrentPage == m_pChooseDevicePage ) 823 { 824 if( m_pChooseDevicePage->isPrinter() ) 825 { | 817} 818 819void AddPrinterDialog::advance() 820{ 821 m_pCurrentPage->Show( sal_False ); 822 if( m_pCurrentPage == m_pChooseDevicePage ) 823 { 824 if( m_pChooseDevicePage->isPrinter() ) 825 { |
826 if( ! m_pChooseDriverPage ) 827 m_pChooseDriverPage = new APChooseDriverPage( this ); 828 m_pCurrentPage = m_pChooseDriverPage; | 826 if( ! m_pChooseDriverPage ) 827 m_pChooseDriverPage = new APChooseDriverPage( this ); 828 m_pCurrentPage = m_pChooseDriverPage; |
829 m_aPrevPB.Enable( sal_True ); 830 } 831 else if( m_pChooseDevicePage->isOld() ) 832 { 833 if( ! m_pOldPrinterPage ) 834 m_pOldPrinterPage = new APOldPrinterPage( this ); 835 m_pCurrentPage = m_pOldPrinterPage; 836 m_aPrevPB.Enable( sal_True ); --- 12 unchanged lines hidden (view full) --- 849 if( ! m_pPdfDriverPage ) 850 m_pPdfDriverPage = new APPdfDriverPage( this ); 851 m_pCurrentPage = m_pPdfDriverPage; 852 m_aPrevPB.Enable( sal_True ); 853 } 854 } 855 else if( m_pCurrentPage == m_pChooseDriverPage ) 856 { | 829 m_aPrevPB.Enable( sal_True ); 830 } 831 else if( m_pChooseDevicePage->isOld() ) 832 { 833 if( ! m_pOldPrinterPage ) 834 m_pOldPrinterPage = new APOldPrinterPage( this ); 835 m_pCurrentPage = m_pOldPrinterPage; 836 m_aPrevPB.Enable( sal_True ); --- 12 unchanged lines hidden (view full) --- 849 if( ! m_pPdfDriverPage ) 850 m_pPdfDriverPage = new APPdfDriverPage( this ); 851 m_pCurrentPage = m_pPdfDriverPage; 852 m_aPrevPB.Enable( sal_True ); 853 } 854 } 855 else if( m_pCurrentPage == m_pChooseDriverPage ) 856 { |
857 if( ! m_pCommandPage ) 858 m_pCommandPage = new APCommandPage( this, DeviceKind::Printer ); 859 m_pCurrentPage = m_pCommandPage; | 857 if( ! m_pCommandPage ) 858 m_pCommandPage = new APCommandPage( this, DeviceKind::Printer ); 859 m_pCurrentPage = m_pCommandPage; |
860 } 861 else if( m_pCurrentPage == m_pCommandPage ) 862 { 863 if( ! m_pNamePage ) 864 m_pNamePage = new APNamePage( this, m_aPrinter.m_aPrinterName, DeviceKind::Printer ); | 860 } 861 else if( m_pCurrentPage == m_pCommandPage ) 862 { 863 if( ! m_pNamePage ) 864 m_pNamePage = new APNamePage( this, m_aPrinter.m_aPrinterName, DeviceKind::Printer ); |
865 else 866 m_pNamePage->setText( m_aPrinter.m_aPrinterName ); | 865 else 866 m_pNamePage->setText( m_aPrinter.m_aPrinterName ); |
867 m_pCurrentPage = m_pNamePage; 868 m_aFinishPB.Enable( sal_True ); 869 m_aNextPB.Enable( sal_False ); 870 } 871 else if( m_pCurrentPage == m_pFaxDriverPage ) 872 { 873 if( ! m_pFaxDriverPage->isDefault() ) 874 { 875 if( ! m_pFaxSelectDriverPage ) 876 m_pFaxSelectDriverPage = new APChooseDriverPage( this ); 877 m_pCurrentPage = m_pFaxSelectDriverPage; 878 } 879 else 880 { | 867 m_pCurrentPage = m_pNamePage; 868 m_aFinishPB.Enable( sal_True ); 869 m_aNextPB.Enable( sal_False ); 870 } 871 else if( m_pCurrentPage == m_pFaxDriverPage ) 872 { 873 if( ! m_pFaxDriverPage->isDefault() ) 874 { 875 if( ! m_pFaxSelectDriverPage ) 876 m_pFaxSelectDriverPage = new APChooseDriverPage( this ); 877 m_pCurrentPage = m_pFaxSelectDriverPage; 878 } 879 else 880 { |
881 if( ! m_pFaxCommandPage ) 882 m_pFaxCommandPage = new APCommandPage( this, DeviceKind::Fax ); 883 m_pCurrentPage = m_pFaxCommandPage; | 881 if( ! m_pFaxCommandPage ) 882 m_pFaxCommandPage = new APCommandPage( this, DeviceKind::Fax ); 883 m_pCurrentPage = m_pFaxCommandPage; |
884 } 885 } 886 else if( m_pCurrentPage == m_pFaxSelectDriverPage ) 887 { 888 if( ! m_pFaxCommandPage ) 889 m_pFaxCommandPage = new APCommandPage( this, DeviceKind::Fax ); 890 m_pCurrentPage = m_pFaxCommandPage; 891 } --- 10 unchanged lines hidden (view full) --- 902 if( ! m_pPdfDriverPage->isDefault() && ! m_pPdfDriverPage->isDist() ) 903 { 904 if( ! m_pPdfSelectDriverPage ) 905 m_pPdfSelectDriverPage = new APChooseDriverPage( this ); 906 m_pCurrentPage = m_pPdfSelectDriverPage; 907 } 908 else 909 { | 884 } 885 } 886 else if( m_pCurrentPage == m_pFaxSelectDriverPage ) 887 { 888 if( ! m_pFaxCommandPage ) 889 m_pFaxCommandPage = new APCommandPage( this, DeviceKind::Fax ); 890 m_pCurrentPage = m_pFaxCommandPage; 891 } --- 10 unchanged lines hidden (view full) --- 902 if( ! m_pPdfDriverPage->isDefault() && ! m_pPdfDriverPage->isDist() ) 903 { 904 if( ! m_pPdfSelectDriverPage ) 905 m_pPdfSelectDriverPage = new APChooseDriverPage( this ); 906 m_pCurrentPage = m_pPdfSelectDriverPage; 907 } 908 else 909 { |
910 if( ! m_pPdfCommandPage ) 911 m_pPdfCommandPage = new APCommandPage( this, DeviceKind::Pdf ); 912 m_pCurrentPage = m_pPdfCommandPage; | 910 if( ! m_pPdfCommandPage ) 911 m_pPdfCommandPage = new APCommandPage( this, DeviceKind::Pdf ); 912 m_pCurrentPage = m_pPdfCommandPage; |
913 } 914 } 915 else if( m_pCurrentPage == m_pPdfSelectDriverPage ) 916 { 917 if( ! m_pPdfCommandPage ) 918 m_pPdfCommandPage = new APCommandPage( this, DeviceKind::Pdf ); 919 m_pCurrentPage = m_pPdfCommandPage; 920 } 921 else if( m_pCurrentPage == m_pPdfCommandPage ) 922 { 923 if( ! m_pPdfNamePage ) 924 m_pPdfNamePage = new APNamePage( this, String(), DeviceKind::Pdf ); 925 m_pCurrentPage = m_pPdfNamePage; 926 m_aNextPB.Enable( sal_False ); 927 m_aFinishPB.Enable( sal_True ); 928 } 929 930 m_pCurrentPage->Show( sal_True ); | 913 } 914 } 915 else if( m_pCurrentPage == m_pPdfSelectDriverPage ) 916 { 917 if( ! m_pPdfCommandPage ) 918 m_pPdfCommandPage = new APCommandPage( this, DeviceKind::Pdf ); 919 m_pCurrentPage = m_pPdfCommandPage; 920 } 921 else if( m_pCurrentPage == m_pPdfCommandPage ) 922 { 923 if( ! m_pPdfNamePage ) 924 m_pPdfNamePage = new APNamePage( this, String(), DeviceKind::Pdf ); 925 m_pCurrentPage = m_pPdfNamePage; 926 m_aNextPB.Enable( sal_False ); 927 m_aFinishPB.Enable( sal_True ); 928 } 929 930 m_pCurrentPage->Show( sal_True ); |
931 m_aTitleImage.SetText( m_pCurrentPage->getTitle() ); | 931 m_aTitleImage.SetText( m_pCurrentPage->getTitle() ); |
932} 933 934void AddPrinterDialog::back() 935{ 936 m_pCurrentPage->Show( sal_False ); 937 if( m_pCurrentPage == m_pChooseDriverPage ) 938 { 939 m_pCurrentPage = m_pChooseDevicePage; --- 26 unchanged lines hidden (view full) --- 966 else if( m_pCurrentPage == m_pFaxNamePage ) 967 { 968 m_pCurrentPage = m_pFaxCommandPage; 969 m_aNextPB.Enable( sal_True ); 970 } 971 else if( m_pCurrentPage == m_pFaxCommandPage ) 972 { 973 m_pCurrentPage = m_pFaxDriverPage->isDefault() ? (APTabPage*)m_pFaxDriverPage : (APTabPage*)m_pFaxSelectDriverPage; | 932} 933 934void AddPrinterDialog::back() 935{ 936 m_pCurrentPage->Show( sal_False ); 937 if( m_pCurrentPage == m_pChooseDriverPage ) 938 { 939 m_pCurrentPage = m_pChooseDevicePage; --- 26 unchanged lines hidden (view full) --- 966 else if( m_pCurrentPage == m_pFaxNamePage ) 967 { 968 m_pCurrentPage = m_pFaxCommandPage; 969 m_aNextPB.Enable( sal_True ); 970 } 971 else if( m_pCurrentPage == m_pFaxCommandPage ) 972 { 973 m_pCurrentPage = m_pFaxDriverPage->isDefault() ? (APTabPage*)m_pFaxDriverPage : (APTabPage*)m_pFaxSelectDriverPage; |
974 m_aNextPB.Enable( sal_True ); | 974 m_aNextPB.Enable( sal_True ); |
975 } 976 else if( m_pCurrentPage == m_pPdfDriverPage ) 977 { 978 m_pCurrentPage = m_pChooseDevicePage; 979 m_aPrevPB.Enable( sal_False ); 980 } 981 else if( m_pCurrentPage == m_pPdfSelectDriverPage ) 982 { --- 5 unchanged lines hidden (view full) --- 988 m_aNextPB.Enable( sal_True ); 989 } 990 else if( m_pCurrentPage == m_pPdfCommandPage ) 991 { 992 m_pCurrentPage = m_pPdfDriverPage->isDefault() || m_pPdfDriverPage->isDist() ? (APTabPage*)m_pPdfDriverPage : (APTabPage*)m_pPdfSelectDriverPage; 993 m_aNextPB.Enable( sal_True ); 994 } 995 m_pCurrentPage->Show( sal_True ); | 975 } 976 else if( m_pCurrentPage == m_pPdfDriverPage ) 977 { 978 m_pCurrentPage = m_pChooseDevicePage; 979 m_aPrevPB.Enable( sal_False ); 980 } 981 else if( m_pCurrentPage == m_pPdfSelectDriverPage ) 982 { --- 5 unchanged lines hidden (view full) --- 988 m_aNextPB.Enable( sal_True ); 989 } 990 else if( m_pCurrentPage == m_pPdfCommandPage ) 991 { 992 m_pCurrentPage = m_pPdfDriverPage->isDefault() || m_pPdfDriverPage->isDist() ? (APTabPage*)m_pPdfDriverPage : (APTabPage*)m_pPdfSelectDriverPage; 993 m_aNextPB.Enable( sal_True ); 994 } 995 m_pCurrentPage->Show( sal_True ); |
996 m_aTitleImage.SetText( m_pCurrentPage->getTitle() ); | 996 m_aTitleImage.SetText( m_pCurrentPage->getTitle() ); |
997} 998 999void AddPrinterDialog::addPrinter() 1000{ 1001 PrinterInfoManager& rManager( PrinterInfoManager::get() ); 1002 if( ! m_pChooseDevicePage->isOld() ) 1003 { 1004 m_aPrinter.m_aPrinterName = uniquePrinterName( m_aPrinter.m_aPrinterName ); --- 59 unchanged lines hidden (view full) --- 1064 1065String AddPrinterDialog::uniquePrinterName( const String& rBase ) 1066{ 1067 String aResult( rBase ); 1068 1069 PrinterInfoManager& rManager( PrinterInfoManager::get() ); 1070 1071 int nVersion = 1; | 997} 998 999void AddPrinterDialog::addPrinter() 1000{ 1001 PrinterInfoManager& rManager( PrinterInfoManager::get() ); 1002 if( ! m_pChooseDevicePage->isOld() ) 1003 { 1004 m_aPrinter.m_aPrinterName = uniquePrinterName( m_aPrinter.m_aPrinterName ); --- 59 unchanged lines hidden (view full) --- 1064 1065String AddPrinterDialog::uniquePrinterName( const String& rBase ) 1066{ 1067 String aResult( rBase ); 1068 1069 PrinterInfoManager& rManager( PrinterInfoManager::get() ); 1070 1071 int nVersion = 1; |
1072 list< OUString > aPrinterList; 1073 rManager.listPrinters( aPrinterList ); 1074 hash_set< OUString, OUStringHash > aPrinters; 1075 for( list< OUString >::const_iterator it = aPrinterList.begin(); it != aPrinterList.end(); ++it ) 1076 aPrinters.insert( *it ); 1077 while( aPrinters.find( aResult ) != aPrinters.end() ) 1078 { 1079 aResult = rBase; 1080 aResult.AppendAscii( "_" ); 1081 aResult += String::CreateFromInt32( nVersion++ ); 1082 } | 1072 list< OUString > aPrinterList; 1073 rManager.listPrinters( aPrinterList ); 1074 hash_set< OUString, OUStringHash > aPrinters; 1075 for( list< OUString >::const_iterator it = aPrinterList.begin(); it != aPrinterList.end(); ++it ) 1076 aPrinters.insert( *it ); 1077 while( aPrinters.find( aResult ) != aPrinters.end() ) 1078 { 1079 aResult = rBase; 1080 aResult.AppendAscii( "_" ); 1081 aResult += String::CreateFromInt32( nVersion++ ); 1082 } |
1083 1084 return aResult; 1085} 1086 1087String AddPrinterDialog::getOldPrinterLocation() 1088{ 1089 static const char* pHome = getenv( "HOME" ); | 1083 1084 return aResult; 1085} 1086 1087String AddPrinterDialog::getOldPrinterLocation() 1088{ 1089 static const char* pHome = getenv( "HOME" ); |
1090 String aRet; 1091 ByteString aFileName; | 1090 String aRet; 1091 ByteString aFileName; |
1092 1093 rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); 1094 if( pHome ) 1095 { 1096 aFileName = pHome; 1097 aFileName.Append( "/.Xpdefaults" ); | 1092 1093 rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); 1094 if( pHome ) 1095 { 1096 aFileName = pHome; 1097 aFileName.Append( "/.Xpdefaults" ); |
1098 if( access( aFileName.GetBuffer(), F_OK ) ) 1099 { 1100 aFileName = pHome; 1101 aFileName.Append( "/.sversionrc" ); 1102 Config aSVer( String( aFileName, aEncoding ) ); 1103 aSVer.SetGroup( "Versions" ); 1104 aFileName = aSVer.ReadKey( "StarOffice 5.2" ); 1105 if( aFileName.Len() ) 1106 aFileName.Append( "/share/xp3/Xpdefaults" ); 1107 else if( 1108 (aFileName = aSVer.ReadKey( "StarOffice 5.1" ) ).Len() 1109 || 1110 (aFileName = aSVer.ReadKey( "StarOffice 5.0" ) ).Len() 1111 || 1112 (aFileName = aSVer.ReadKey( "StarOffice 4.0" ) ).Len() 1113 ) 1114 { 1115 aFileName.Append( "/xp3/Xpdefaults" ); 1116 } 1117 if( aFileName.Len() && access( aFileName.GetBuffer(), F_OK ) ) 1118 aFileName.Erase(); 1119 } 1120 } 1121 if( aFileName.Len() ) 1122 aRet = String( aFileName, aEncoding ); 1123 return aRet; | 1098 if( access( aFileName.GetBuffer(), F_OK ) ) 1099 { 1100 aFileName = pHome; 1101 aFileName.Append( "/.sversionrc" ); 1102 Config aSVer( String( aFileName, aEncoding ) ); 1103 aSVer.SetGroup( "Versions" ); 1104 aFileName = aSVer.ReadKey( "StarOffice 5.2" ); 1105 if( aFileName.Len() ) 1106 aFileName.Append( "/share/xp3/Xpdefaults" ); 1107 else if( 1108 (aFileName = aSVer.ReadKey( "StarOffice 5.1" ) ).Len() 1109 || 1110 (aFileName = aSVer.ReadKey( "StarOffice 5.0" ) ).Len() 1111 || 1112 (aFileName = aSVer.ReadKey( "StarOffice 4.0" ) ).Len() 1113 ) 1114 { 1115 aFileName.Append( "/xp3/Xpdefaults" ); 1116 } 1117 if( aFileName.Len() && access( aFileName.GetBuffer(), F_OK ) ) 1118 aFileName.Erase(); 1119 } 1120 } 1121 if( aFileName.Len() ) 1122 aRet = String( aFileName, aEncoding ); 1123 return aRet; |
1124} | 1124} |
1125 1126/* vim: set noet sw=4 ts=4: */ |
|