padialog.cxx (466d5a0b) | padialog.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 <stdio.h> 25#include <stdlib.h> 26#include <unistd.h> 27#include <string.h> --- 53 unchanged lines hidden (view full) --- 81 m_aDriverTxt( this, PaResId( RID_PA_TXT_DRIVER ) ), 82 m_aDriver( this, PaResId( RID_PA_TXT_DRIVER_STRING ) ), 83 m_aLocationTxt( this, PaResId( RID_PA_TXT_LOCATION ) ), 84 m_aLocation( this, PaResId( RID_PA_TXT_LOCATION_STRING ) ), 85 m_aCommandTxt( this, PaResId( RID_PA_TXT_COMMAND ) ), 86 m_aCommand( this, PaResId( RID_PA_TXT_COMMAND_STRING ) ), 87 m_aCommentTxt( this, PaResId( RID_PA_TXT_COMMENT ) ), 88 m_aComment( this, PaResId( RID_PA_TXT_COMMENT_STRING ) ), | 20 *************************************************************/ 21 22 23 24#include <stdio.h> 25#include <stdlib.h> 26#include <unistd.h> 27#include <string.h> --- 53 unchanged lines hidden (view full) --- 81 m_aDriverTxt( this, PaResId( RID_PA_TXT_DRIVER ) ), 82 m_aDriver( this, PaResId( RID_PA_TXT_DRIVER_STRING ) ), 83 m_aLocationTxt( this, PaResId( RID_PA_TXT_LOCATION ) ), 84 m_aLocation( this, PaResId( RID_PA_TXT_LOCATION_STRING ) ), 85 m_aCommandTxt( this, PaResId( RID_PA_TXT_COMMAND ) ), 86 m_aCommand( this, PaResId( RID_PA_TXT_COMMAND_STRING ) ), 87 m_aCommentTxt( this, PaResId( RID_PA_TXT_COMMENT ) ), 88 m_aComment( this, PaResId( RID_PA_TXT_COMMENT_STRING ) ), |
89 m_aCUPSFL( this, PaResId( RID_PA_FL_CUPSUSAGE ) ), 90 m_aCUPSCB( this, PaResId( RID_PA_CB_CUPSUSAGE ) ), 91 m_aSepButtonFL( this, PaResId( RID_PA_FL_SEPBUTTON ) ), | 89 m_aCUPSFL( this, PaResId( RID_PA_FL_CUPSUSAGE ) ), 90 m_aCUPSCB( this, PaResId( RID_PA_CB_CUPSUSAGE ) ), 91 m_aSepButtonFL( this, PaResId( RID_PA_FL_SEPBUTTON ) ), |
92 m_aAddPB( this, PaResId( RID_PA_BTN_ADD ) ), 93 m_aFontsPB( this, PaResId( RID_PA_BTN_FONTS ) ), 94 m_aCancelButton( this, PaResId( RID_PA_BTN_CANCEL ) ), 95 m_aDefPrt( PaResId( RID_PA_STR_DEFPRT ) ), 96 m_aRenameStr( PaResId( RID_PA_STR_RENAME ) ), 97 m_rPIManager( PrinterInfoManager::get() ) 98{ 99 FreeResource(); | 92 m_aAddPB( this, PaResId( RID_PA_BTN_ADD ) ), 93 m_aFontsPB( this, PaResId( RID_PA_BTN_FONTS ) ), 94 m_aCancelButton( this, PaResId( RID_PA_BTN_CANCEL ) ), 95 m_aDefPrt( PaResId( RID_PA_STR_DEFPRT ) ), 96 m_aRenameStr( PaResId( RID_PA_STR_RENAME ) ), 97 m_rPIManager( PrinterInfoManager::get() ) 98{ 99 FreeResource(); |
100 updateSettings(); | 100 updateSettings(); |
101 Init(); 102} 103 104void PADialog::updateSettings() 105{ | 101 Init(); 102} 103 104void PADialog::updateSettings() 105{ |
106 if( ! GetSettings().GetStyleSettings().GetHighContrastMode() ) 107 { 108 m_aPrinterImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PRINTER ) ) ); 109 m_aFaxImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_FAX ) ) ); 110 m_aPdfImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PDF ) ) ); 111 } 112 else 113 { 114 m_aPrinterImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PRINTER_HC ) ) ); 115 m_aFaxImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_FAX_HC ) ) ); 116 m_aPdfImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PDF_HC ) ) ); 117 } | 106 if( ! GetSettings().GetStyleSettings().GetHighContrastMode() ) 107 { 108 m_aPrinterImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PRINTER ) ) ); 109 m_aFaxImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_FAX ) ) ); 110 m_aPdfImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PDF ) ) ); 111 } 112 else 113 { 114 m_aPrinterImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PRINTER_HC ) ) ); 115 m_aFaxImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_FAX_HC ) ) ); 116 m_aPdfImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PDF_HC ) ) ); 117 } |
118} 119 120void PADialog::Init() 121{ | 118} 119 120void PADialog::Init() 121{ |
122 // #i79787# initially ensure printer discovery has ended 123 m_rPIManager.checkPrintersChanged( true ); 124 m_aCUPSCB.Check( m_rPIManager.isCUPSDisabled() ); 125 | 122 // #i79787# initially ensure printer discovery has ended 123 m_rPIManager.checkPrintersChanged( true ); 124 m_aCUPSCB.Check( m_rPIManager.isCUPSDisabled() ); 125 |
126 UpdateDevice(); 127 UpdateText(); 128 129 m_aRemPB.Enable( sal_False ); 130 131 m_aDevicesLB.SetDoubleClickHdl( LINK( this, PADialog, DoubleClickHdl ) ); 132 m_aDevicesLB.SetSelectHdl( LINK( this, PADialog, SelectHdl ) ); 133 m_aStdPB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 134 m_aRemPB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 135 m_aConfPB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 136 m_aRenamePB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 137 m_aTestPagePB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 138 m_aFontsPB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 139 m_aAddPB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 140 m_aDevicesLB.setDelPressedLink( LINK( this, PADialog, DelPressedHdl ) ); | 126 UpdateDevice(); 127 UpdateText(); 128 129 m_aRemPB.Enable( sal_False ); 130 131 m_aDevicesLB.SetDoubleClickHdl( LINK( this, PADialog, DoubleClickHdl ) ); 132 m_aDevicesLB.SetSelectHdl( LINK( this, PADialog, SelectHdl ) ); 133 m_aStdPB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 134 m_aRemPB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 135 m_aConfPB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 136 m_aRenamePB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 137 m_aTestPagePB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 138 m_aFontsPB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 139 m_aAddPB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); 140 m_aDevicesLB.setDelPressedLink( LINK( this, PADialog, DelPressedHdl ) ); |
141 m_aCUPSCB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); | 141 m_aCUPSCB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); |
142 143 ::psp::PrintFontManager& rFontManager( ::psp::PrintFontManager::get() ); 144 if( ! rFontManager.checkImportPossible() ) 145 m_aFontsPB.Enable( sal_False ); | 142 143 ::psp::PrintFontManager& rFontManager( ::psp::PrintFontManager::get() ); 144 if( ! rFontManager.checkImportPossible() ) 145 m_aFontsPB.Enable( sal_False ); |
146 if( rFontManager.hasFontconfig() ) 147 { 148 m_aFontsPB.Enable( sal_False ); 149 m_aFontsPB.Show( sal_False ); 150 } 151 152 // at this point no actual changes will be written 153 // but the write will have checked whether any writeable config exists 154 if( ! m_rPIManager.writePrinterConfig() ) 155 { 156 m_aAddPB.Enable( sal_False ); 157 m_aRemPB.Enable( sal_False ); 158 m_aConfPB.Enable( sal_False ); 159 m_aRenamePB.Enable( sal_False ); 160 m_aStdPB.Enable( sal_False ); 161 m_aCUPSCB.Enable( sal_False ); 162 ErrorBox aBox( GetParent(), WB_OK | WB_DEF_OK, String( PaResId( RID_ERR_NOWRITE ) ) ); 163 aBox.Execute(); 164 } | 146 if( rFontManager.hasFontconfig() ) 147 { 148 m_aFontsPB.Enable( sal_False ); 149 m_aFontsPB.Show( sal_False ); 150 } 151 152 // at this point no actual changes will be written 153 // but the write will have checked whether any writable config exists 154 if( ! m_rPIManager.writePrinterConfig() ) 155 { 156 m_aAddPB.Enable( sal_False ); 157 m_aRemPB.Enable( sal_False ); 158 m_aConfPB.Enable( sal_False ); 159 m_aRenamePB.Enable( sal_False ); 160 m_aStdPB.Enable( sal_False ); 161 m_aCUPSCB.Enable( sal_False ); 162 ErrorBox aBox( GetParent(), WB_OK | WB_DEF_OK, String( PaResId( RID_ERR_NOWRITE ) ) ); 163 aBox.Execute(); 164 } |
165} 166 167PADialog::~PADialog() 168{ 169 m_rPIManager.writePrinterConfig(); 170 freePadminRC(); 171} 172 173long PADialog::Notify( NotifyEvent& rEv ) 174{ | 165} 166 167PADialog::~PADialog() 168{ 169 m_rPIManager.writePrinterConfig(); 170 freePadminRC(); 171} 172 173long PADialog::Notify( NotifyEvent& rEv ) 174{ |
175 if( IsVisible() && 176 (rEv.GetType() == EVENT_GETFOCUS || rEv.GetType() == EVENT_LOSEFOCUS ) 177 ) 178 { 179 if( m_rPIManager.checkPrintersChanged( true ) ) 180 { 181 String aSelectEntry = m_aDevicesLB.GetSelectEntry(); 182 UpdateDevice(); 183 UpdateText(); 184 m_aDevicesLB.SelectEntry( aSelectEntry ); 185 } 186 } 187 return ModalDialog::Notify( rEv ); | 175 if( IsVisible() && 176 (rEv.GetType() == EVENT_GETFOCUS || rEv.GetType() == EVENT_LOSEFOCUS ) 177 ) 178 { 179 if( m_rPIManager.checkPrintersChanged( true ) ) 180 { 181 String aSelectEntry = m_aDevicesLB.GetSelectEntry(); 182 UpdateDevice(); 183 UpdateText(); 184 m_aDevicesLB.SelectEntry( aSelectEntry ); 185 } 186 } 187 return ModalDialog::Notify( rEv ); |
188} 189 190void PADialog::DataChanged( const DataChangedEvent& rEv ) 191{ | 188} 189 190void PADialog::DataChanged( const DataChangedEvent& rEv ) 191{ |
192 ModalDialog::DataChanged( rEv ); 193 if( (rEv.GetType() == DATACHANGED_SETTINGS) && 194 (rEv.GetFlags() & SETTINGS_STYLE) ) 195 { 196 updateSettings(); 197 // push the new images into the listbox 198 UpdateDevice(); 199 } | 192 ModalDialog::DataChanged( rEv ); 193 if( (rEv.GetType() == DATACHANGED_SETTINGS) && 194 (rEv.GetFlags() & SETTINGS_STYLE) ) 195 { 196 updateSettings(); 197 // push the new images into the listbox 198 UpdateDevice(); 199 } |
200} 201 202String PADialog::getSelectedDevice() 203{ 204 int nPos = m_aDevicesLB.GetSelectEntryPos(); 205 int nLen = (int)(sal_IntPtr)m_aDevicesLB.GetEntryData( nPos ); 206 return m_aDevicesLB.GetEntry( nPos ).Copy( 0, nLen ); 207} --- 19 unchanged lines hidden (view full) --- 227 PrintTestPage(); 228 else if( pButton == &m_aAddPB ) 229 AddDevice(); 230 else if( pButton == &m_aFontsPB ) 231 { 232 FontNameDlg aDialog( this ); 233 aDialog.Execute(); 234 } | 200} 201 202String PADialog::getSelectedDevice() 203{ 204 int nPos = m_aDevicesLB.GetSelectEntryPos(); 205 int nLen = (int)(sal_IntPtr)m_aDevicesLB.GetEntryData( nPos ); 206 return m_aDevicesLB.GetEntry( nPos ).Copy( 0, nLen ); 207} --- 19 unchanged lines hidden (view full) --- 227 PrintTestPage(); 228 else if( pButton == &m_aAddPB ) 229 AddDevice(); 230 else if( pButton == &m_aFontsPB ) 231 { 232 FontNameDlg aDialog( this ); 233 aDialog.Execute(); 234 } |
235 else if( static_cast<Button*>(pButton) == &m_aCUPSCB ) 236 { 237 m_rPIManager.setCUPSDisabled( m_aCUPSCB.IsChecked() ); 238 UpdateDevice(); 239 UpdateText(); 240 } | 235 else if( static_cast<Button*>(pButton) == &m_aCUPSCB ) 236 { 237 m_rPIManager.setCUPSDisabled( m_aCUPSCB.IsChecked() ); 238 UpdateDevice(); 239 UpdateText(); 240 } |
241 242 return 0; 243} 244 245IMPL_LINK( PADialog, DoubleClickHdl, ListBox*, pListBox ) 246{ 247 if( pListBox == &m_aDevicesLB ) 248 UpdateDefPrt(); --- 12 unchanged lines hidden (view full) --- 261 m_aRemPB.Enable( sal_True ); 262 UpdateText(); 263 } 264 return 0; 265} 266 267void PADialog::UpdateDefPrt() 268{ | 241 242 return 0; 243} 244 245IMPL_LINK( PADialog, DoubleClickHdl, ListBox*, pListBox ) 246{ 247 if( pListBox == &m_aDevicesLB ) 248 UpdateDefPrt(); --- 12 unchanged lines hidden (view full) --- 261 m_aRemPB.Enable( sal_True ); 262 UpdateText(); 263 } 264 return 0; 265} 266 267void PADialog::UpdateDefPrt() 268{ |
269 m_rPIManager.setDefaultPrinter( getSelectedDevice() ); | 269 m_rPIManager.setDefaultPrinter( getSelectedDevice() ); |
270 | 270 |
271 UpdateDevice(); 272 UpdateText(); | 271 UpdateDevice(); 272 UpdateText(); |
273 | 273 |
274 if( m_aRemPB.HasFocus() ) 275 m_aDevicesLB.GetFocus(); 276 m_aRemPB.Enable( sal_False ); | 274 if( m_aRemPB.HasFocus() ) 275 m_aDevicesLB.GetFocus(); 276 m_aRemPB.Enable( sal_False ); |
277} 278 279void PADialog::UpdateText() 280{ | 277} 278 279void PADialog::UpdateText() 280{ |
281 OUString aDev( getSelectedDevice() ); 282 if( aDev.getLength() ) 283 { 284 const PrinterInfo& rInfo = m_rPIManager.getPrinterInfo( aDev ); 285 String aDriver( rInfo.m_aPrinterName ); 286 aDriver.AppendAscii( " (" ); 287 aDriver += String( rInfo.m_aDriverName ); 288 aDriver.Append( ')' ); 289 m_aDriver.SetText( aDriver ); 290 m_aCommand.SetText( rInfo.m_aCommand ); 291 m_aComment.SetText( rInfo.m_aComment ); 292 m_aLocation.SetText( rInfo.m_aLocation ); 293 } 294 else // nothing selected 295 { 296 String aEmpty; 297 m_aDriver.SetText( aEmpty ); 298 m_aCommand.SetText( aEmpty ); 299 m_aComment.SetText( aEmpty ); 300 m_aLocation.SetText( aEmpty ); 301 } | 281 OUString aDev( getSelectedDevice() ); 282 if( aDev.getLength() ) 283 { 284 const PrinterInfo& rInfo = m_rPIManager.getPrinterInfo( aDev ); 285 String aDriver( rInfo.m_aPrinterName ); 286 aDriver.AppendAscii( " (" ); 287 aDriver += String( rInfo.m_aDriverName ); 288 aDriver.Append( ')' ); 289 m_aDriver.SetText( aDriver ); 290 m_aCommand.SetText( rInfo.m_aCommand ); 291 m_aComment.SetText( rInfo.m_aComment ); 292 m_aLocation.SetText( rInfo.m_aLocation ); 293 } 294 else // nothing selected 295 { 296 String aEmpty; 297 m_aDriver.SetText( aEmpty ); 298 m_aCommand.SetText( aEmpty ); 299 m_aComment.SetText( aEmpty ); 300 m_aLocation.SetText( aEmpty ); 301 } |
302} 303 304static Point project( const Point& rPoint ) 305{ 306 const double angle_x = M_PI / 6.0; 307 const double angle_z = M_PI / 6.0; 308 309 // transform planar coordinates to 3d --- 61 unchanged lines hidden (view full) --- 371 aColor.SetBlue( rFrom.GetBlue() ); 372 373 return aColor; 374} 375 376class SpaPrinterController : public vcl::PrinterController 377{ 378public: | 302} 303 304static Point project( const Point& rPoint ) 305{ 306 const double angle_x = M_PI / 6.0; 307 const double angle_z = M_PI / 6.0; 308 309 // transform planar coordinates to 3d --- 61 unchanged lines hidden (view full) --- 371 aColor.SetBlue( rFrom.GetBlue() ); 372 373 return aColor; 374} 375 376class SpaPrinterController : public vcl::PrinterController 377{ 378public: |
379 SpaPrinterController( const boost::shared_ptr<Printer>& i_pPrinter ) 380 : vcl::PrinterController( i_pPrinter ) 381 {} 382 virtual ~SpaPrinterController() 383 {} 384 385 virtual int getPageCount() const { return 1; } 386 virtual Sequence< PropertyValue > getPageParameters( int i_nPage ) const; 387 virtual void printPage( int i_nPage ) const; 388 virtual void jobFinished( com::sun::star::view::PrintableState ); | 379 SpaPrinterController( const boost::shared_ptr<Printer>& i_pPrinter ) 380 : vcl::PrinterController( i_pPrinter ) 381 {} 382 virtual ~SpaPrinterController() 383 {} 384 385 virtual int getPageCount() const { return 1; } 386 virtual Sequence< PropertyValue > getPageParameters( int i_nPage ) const; 387 virtual void printPage( int i_nPage ) const; 388 virtual void jobFinished( com::sun::star::view::PrintableState ); |
389}; 390 391Sequence< PropertyValue > SpaPrinterController::getPageParameters( int ) const 392{ | 389}; 390 391Sequence< PropertyValue > SpaPrinterController::getPageParameters( int ) const 392{ |
393 Sequence< PropertyValue > aRet( 1 ); 394 395 Size aPageSize( getPrinter()->GetPaperSizePixel() ); 396 aPageSize = getPrinter()->PixelToLogic( aPageSize, MapMode( MAP_100TH_MM ) ); 397 398 awt::Size aSize; 399 aSize.Width = aPageSize.Width(); 400 aSize.Height = aPageSize.Height(); 401 aRet[0].Value = makeAny(aSize); 402 403 return aRet; | 393 Sequence< PropertyValue > aRet( 1 ); 394 395 Size aPageSize( getPrinter()->GetPaperSizePixel() ); 396 aPageSize = getPrinter()->PixelToLogic( aPageSize, MapMode( MAP_100TH_MM ) ); 397 398 awt::Size aSize; 399 aSize.Width = aPageSize.Width(); 400 aSize.Height = aPageSize.Height(); 401 aRet[0].Value = makeAny(aSize); 402 403 return aRet; |
404} 405 406void SpaPrinterController::printPage( int ) const 407{ | 404} 405 406void SpaPrinterController::printPage( int ) const 407{ |
408 const double DELTA = 5.0; 409 410 boost::shared_ptr<Printer> pPrinter( getPrinter() ); | 408 const double DELTA = 5.0; |
411 | 409 |
410 boost::shared_ptr<Printer> pPrinter( getPrinter() ); 411 |
|
412 PrinterInfo aInfo( psp::PrinterInfoManager::get().getPrinterInfo( pPrinter->GetName() ) ); 413 const PPDParser* pPrintParser = aInfo.m_pParser; 414 415 MapMode aMapMode( MAP_100TH_MM ); 416 417 Bitmap aButterfly( PaResId( RID_BUTTERFLY ) ); 418 419 pPrinter->SetMapMode( aMapMode ); 420 | 412 PrinterInfo aInfo( psp::PrinterInfoManager::get().getPrinterInfo( pPrinter->GetName() ) ); 413 const PPDParser* pPrintParser = aInfo.m_pParser; 414 415 MapMode aMapMode( MAP_100TH_MM ); 416 417 Bitmap aButterfly( PaResId( RID_BUTTERFLY ) ); 418 419 pPrinter->SetMapMode( aMapMode ); 420 |
421 Any aRet = utl::ConfigManager::GetDirectConfigProperty( utl::ConfigManager::PRODUCTNAME ); 422 OUString aJobName; 423 aRet >>= aJobName; | 421 Any aRet = utl::ConfigManager::GetDirectConfigProperty( utl::ConfigManager::PRODUCTNAME ); 422 OUString aJobName; 423 aRet >>= aJobName; |
424 425 aJobName = aJobName + OUString( RTL_CONSTASCII_USTRINGPARAM( " Testpage" ) ); 426 427 Size aPaperSize=pPrinter->GetOutputSize(); 428 Point aCenter( aPaperSize.Width()/2-300, 429 aPaperSize.Height() - aPaperSize.Width()/2 ); 430 Point aP1( aPaperSize.Width()/48, 0), aP2( aPaperSize.Width()/40, 0 ), aPoint; 431 --- 12 unchanged lines hidden (view full) --- 444 aFont.SetWeight( WEIGHT_NORMAL ); 445 aFont.SetItalic( ITALIC_NONE ); 446 pPrinter->SetFont( aFont ); 447 448 OUStringBuffer aPrintText(1024); 449 long nWidth = 0, nMaxWidth = 0; 450 String aToken; 451 | 424 425 aJobName = aJobName + OUString( RTL_CONSTASCII_USTRINGPARAM( " Testpage" ) ); 426 427 Size aPaperSize=pPrinter->GetOutputSize(); 428 Point aCenter( aPaperSize.Width()/2-300, 429 aPaperSize.Height() - aPaperSize.Width()/2 ); 430 Point aP1( aPaperSize.Width()/48, 0), aP2( aPaperSize.Width()/40, 0 ), aPoint; 431 --- 12 unchanged lines hidden (view full) --- 444 aFont.SetWeight( WEIGHT_NORMAL ); 445 aFont.SetItalic( ITALIC_NONE ); 446 pPrinter->SetFont( aFont ); 447 448 OUStringBuffer aPrintText(1024); 449 long nWidth = 0, nMaxWidth = 0; 450 String aToken; 451 |
452 static const struct 453 { 454 const char* const pDirect; 455 sal_uInt16 nResId; 456 } aResIds[] = 457 { 458 { NULL, RID_TXT_TESTPAGE_NAME }, 459 { NULL, RID_TXT_TESTPAGE_MODEL }, 460 { "PPD", 0 }, 461 { NULL, RID_TXT_TESTPAGE_QUEUE }, 462 { NULL, RID_TXT_TESTPAGE_COMMENT }, 463 { NULL, RID_TXT_TESTPAGE_DATE }, 464 { NULL, RID_TXT_TESTPAGE_TIME } 465 }; | 452 static const struct 453 { 454 const char* const pDirect; 455 sal_uInt16 nResId; 456 } aResIds[] = 457 { 458 { NULL, RID_TXT_TESTPAGE_NAME }, 459 { NULL, RID_TXT_TESTPAGE_MODEL }, 460 { "PPD", 0 }, 461 { NULL, RID_TXT_TESTPAGE_QUEUE }, 462 { NULL, RID_TXT_TESTPAGE_COMMENT }, 463 { NULL, RID_TXT_TESTPAGE_DATE }, 464 { NULL, RID_TXT_TESTPAGE_TIME } 465 }; |
466 | 466 |
467 for( unsigned int i = 0; i < sizeof(aResIds)/sizeof(aResIds[0]); i++ ) 468 { 469 if( aResIds[i].pDirect ) 470 aToken = String::CreateFromAscii( aResIds[i].pDirect ); 471 else 472 aToken = String( PaResId( aResIds[i].nResId ) ); 473 nMaxWidth = ( nWidth = pPrinter->GetTextWidth( aToken ) ) > nMaxWidth ? nWidth : nMaxWidth; 474 aPrintText.append( aToken ); 475 aPrintText.append( (sal_Unicode)'\n' ); 476 }; | 467 for( unsigned int i = 0; i < sizeof(aResIds)/sizeof(aResIds[0]); i++ ) 468 { 469 if( aResIds[i].pDirect ) 470 aToken = String::CreateFromAscii( aResIds[i].pDirect ); 471 else 472 aToken = String( PaResId( aResIds[i].nResId ) ); 473 nMaxWidth = ( nWidth = pPrinter->GetTextWidth( aToken ) ) > nMaxWidth ? nWidth : nMaxWidth; 474 aPrintText.append( aToken ); 475 aPrintText.append( (sal_Unicode)'\n' ); 476 }; |
477 478 pPrinter->DrawText( Rectangle( Point( 1000, 1000 ), 479 Size( aPaperSize.Width() - 2000, 480 aPaperSize.Height() - 4000 ) ), | 477 478 pPrinter->DrawText( Rectangle( Point( 1000, 1000 ), 479 Size( aPaperSize.Width() - 2000, 480 aPaperSize.Height() - 4000 ) ), |
481 aPrintText.makeStringAndClear(), 482 TEXT_DRAW_MULTILINE ); | 481 aPrintText.makeStringAndClear(), 482 TEXT_DRAW_MULTILINE ); |
483 | 483 |
484 AllSettings aSettings( Application::GetSettings() ); 485 const LocaleDataWrapper& rLocaleWrapper( aSettings.GetLocaleDataWrapper() ); | 484 AllSettings aSettings( Application::GetSettings() ); 485 const LocaleDataWrapper& rLocaleWrapper( aSettings.GetLocaleDataWrapper() ); |
486 487 aPrintText.appendAscii( ": " ); 488 aPrintText.append( pPrinter->GetName() ); 489 aPrintText.appendAscii( "\n: " ); | 486 487 aPrintText.appendAscii( ": " ); 488 aPrintText.append( pPrinter->GetName() ); 489 aPrintText.appendAscii( "\n: " ); |
490 if( pPrintParser ) 491 aPrintText.append( pPrintParser->getPrinterName() ); | 490 if( pPrintParser ) 491 aPrintText.append( pPrintParser->getPrinterName() ); |
492 aPrintText.appendAscii( "\n: " ); 493 INetURLObject aDriverPath( pPrintParser ? pPrintParser->getFilename() : String( RTL_CONSTASCII_USTRINGPARAM( "<undef>" ) ), | 492 aPrintText.appendAscii( "\n: " ); 493 INetURLObject aDriverPath( pPrintParser ? pPrintParser->getFilename() : String( RTL_CONSTASCII_USTRINGPARAM( "<undef>" ) ), |
494 INET_PROT_FILE, INetURLObject::ENCODE_ALL ); | 494 INET_PROT_FILE, INetURLObject::ENCODE_ALL ); |
495 aPrintText.append( aDriverPath.GetName() ); 496 aPrintText.appendAscii( "\n: " ); 497 aPrintText.append( aInfo.m_aCommand ); 498 aPrintText.appendAscii( "\n: " ); 499 aPrintText.append( aInfo.m_aComment ); 500 aPrintText.appendAscii( "\n: " ); 501 aPrintText.append( rLocaleWrapper.getDate( Date() ) ); 502 aPrintText.appendAscii( "\n: " ); --- 90 unchanged lines hidden (view full) --- 593 aInfoBox.SetText( String( PaResId( RID_BXT_TESTPAGE ) ) ); 594 aInfoBox.Execute(); 595} 596 597void PADialog::PrintTestPage() 598{ 599 String sPrinter( getSelectedDevice() ); 600 | 495 aPrintText.append( aDriverPath.GetName() ); 496 aPrintText.appendAscii( "\n: " ); 497 aPrintText.append( aInfo.m_aCommand ); 498 aPrintText.appendAscii( "\n: " ); 499 aPrintText.append( aInfo.m_aComment ); 500 aPrintText.appendAscii( "\n: " ); 501 aPrintText.append( rLocaleWrapper.getDate( Date() ) ); 502 aPrintText.appendAscii( "\n: " ); --- 90 unchanged lines hidden (view full) --- 593 aInfoBox.SetText( String( PaResId( RID_BXT_TESTPAGE ) ) ); 594 aInfoBox.Execute(); 595} 596 597void PADialog::PrintTestPage() 598{ 599 String sPrinter( getSelectedDevice() ); 600 |
601 boost::shared_ptr<Printer> pPrinter( new Printer( sPrinter ) ); | 601 boost::shared_ptr<Printer> pPrinter( new Printer( sPrinter ) ); |
602 603 if( pPrinter->GetName() != sPrinter ) 604 { 605 String aString( PaResId( RID_ERR_NOPRINTER ) ); 606 aString.SearchAndReplaceAscii( "%s", sPrinter ); 607 608 ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aString ); 609 aErrorBox.SetText( String( PaResId( RID_BXT_ENVIRONMENT ) ) ); 610 aErrorBox.Execute(); 611 return; 612 } 613 | 602 603 if( pPrinter->GetName() != sPrinter ) 604 { 605 String aString( PaResId( RID_ERR_NOPRINTER ) ); 606 aString.SearchAndReplaceAscii( "%s", sPrinter ); 607 608 ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aString ); 609 aErrorBox.SetText( String( PaResId( RID_BXT_ENVIRONMENT ) ) ); 610 aErrorBox.Execute(); 611 return; 612 } 613 |
614 boost::shared_ptr<vcl::PrinterController> pController( new SpaPrinterController( pPrinter ) ); 615 JobSetup aJobSetup( pPrinter->GetJobSetup() ); 616 aJobSetup.SetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ), 617 String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); 618 Printer::PrintJob( pController, aJobSetup ); | 614 boost::shared_ptr<vcl::PrinterController> pController( new SpaPrinterController( pPrinter ) ); 615 JobSetup aJobSetup( pPrinter->GetJobSetup() ); 616 aJobSetup.SetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ), 617 String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); 618 Printer::PrintJob( pController, aJobSetup ); |
619} 620 621void PADialog::AddDevice() 622{ 623 AddPrinterDialog aDlg( this ); 624 625 if( aDlg.Execute() ) 626 UpdateDevice(); --- 53 unchanged lines hidden (view full) --- 680void PADialog::RenameDevice() 681{ 682 String aPrinter( getSelectedDevice() ); 683 OUString aOldPrinter( aPrinter ); 684 685 if( ! aPrinter.Len() ) 686 return; 687 | 619} 620 621void PADialog::AddDevice() 622{ 623 AddPrinterDialog aDlg( this ); 624 625 if( aDlg.Execute() ) 626 UpdateDevice(); --- 53 unchanged lines hidden (view full) --- 680void PADialog::RenameDevice() 681{ 682 String aPrinter( getSelectedDevice() ); 683 OUString aOldPrinter( aPrinter ); 684 685 if( ! aPrinter.Len() ) 686 return; 687 |
688 String aTmpString( PaResId( RID_QRY_PRTNAME ) ); | 688 String aTmpString( PaResId( RID_QRY_PRTNAME ) ); |
689 QueryString aQuery( this, 690 aTmpString, 691 aPrinter ); 692 aQuery.SetText( m_aRenameStr ); 693 aQuery.Execute(); 694 695 if( aPrinter.Len() ) 696 { 697 PrinterInfo aInfo( m_rPIManager.getPrinterInfo( aOldPrinter ) ); 698 aInfo.m_aPrinterName = aPrinter; 699 if( m_rPIManager.addPrinter( aPrinter, aInfo.m_aDriverName ) ) 700 { | 689 QueryString aQuery( this, 690 aTmpString, 691 aPrinter ); 692 aQuery.SetText( m_aRenameStr ); 693 aQuery.Execute(); 694 695 if( aPrinter.Len() ) 696 { 697 PrinterInfo aInfo( m_rPIManager.getPrinterInfo( aOldPrinter ) ); 698 aInfo.m_aPrinterName = aPrinter; 699 if( m_rPIManager.addPrinter( aPrinter, aInfo.m_aDriverName ) ) 700 { |
701 bool bWasDefault = m_rPIManager.getDefaultPrinter() == aOldPrinter; | 701 bool bWasDefault = m_rPIManager.getDefaultPrinter() == aOldPrinter; |
702 m_aPrinters.push_back( aPrinter ); 703 if( m_rPIManager.removePrinter( aOldPrinter ) ) 704 m_aPrinters.remove( aOldPrinter ); 705 m_rPIManager.changePrinterInfo( aPrinter, aInfo ); 706 if( bWasDefault ) 707 { 708 m_rPIManager.setDefaultPrinter( aPrinter ); 709 UpdateDefPrt(); 710 } 711 UpdateDevice(); 712 } 713 } 714} 715 716void PADialog::UpdateDevice() 717{ 718 m_aDevicesLB.Clear(); | 702 m_aPrinters.push_back( aPrinter ); 703 if( m_rPIManager.removePrinter( aOldPrinter ) ) 704 m_aPrinters.remove( aOldPrinter ); 705 m_rPIManager.changePrinterInfo( aPrinter, aInfo ); 706 if( bWasDefault ) 707 { 708 m_rPIManager.setDefaultPrinter( aPrinter ); 709 UpdateDefPrt(); 710 } 711 UpdateDevice(); 712 } 713 } 714} 715 716void PADialog::UpdateDevice() 717{ 718 m_aDevicesLB.Clear(); |
719 | 719 |
720 m_rPIManager.listPrinters( m_aPrinters ); 721 ::std::list< OUString >::iterator it; 722 for( it = m_aPrinters.begin(); it != m_aPrinters.end(); ++it ) 723 { | 720 m_rPIManager.listPrinters( m_aPrinters ); 721 ::std::list< OUString >::iterator it; 722 for( it = m_aPrinters.begin(); it != m_aPrinters.end(); ++it ) 723 { |
724 const PrinterInfo& rInfo( m_rPIManager.getPrinterInfo( *it ) ); 725 sal_Int32 nIndex = 0; 726 bool bAutoQueue = false; 727 bool bFax = false; 728 bool bPdf = false; 729 while( nIndex != -1 && ! bAutoQueue ) 730 { 731 OUString aToken( rInfo.m_aFeatures.getToken( 0, ',', nIndex ) ); 732 if( aToken.getLength() ) 733 { 734 if( aToken.compareToAscii( "autoqueue" ) == 0 ) 735 bAutoQueue = true; 736 else if( aToken.compareToAscii( "pdf=", 4 ) == 0 ) 737 bPdf = true; 738 else if( aToken.compareToAscii( "fax", 3 ) == 0 ) 739 bFax = true; 740 } 741 } 742 if( bAutoQueue ) 743 continue; | 724 const PrinterInfo& rInfo( m_rPIManager.getPrinterInfo( *it ) ); 725 sal_Int32 nIndex = 0; 726 bool bAutoQueue = false; 727 bool bFax = false; 728 bool bPdf = false; 729 while( nIndex != -1 && ! bAutoQueue ) 730 { 731 OUString aToken( rInfo.m_aFeatures.getToken( 0, ',', nIndex ) ); 732 if( aToken.getLength() ) 733 { 734 if( aToken.compareToAscii( "autoqueue" ) == 0 ) 735 bAutoQueue = true; 736 else if( aToken.compareToAscii( "pdf=", 4 ) == 0 ) 737 bPdf = true; 738 else if( aToken.compareToAscii( "fax", 3 ) == 0 ) 739 bFax = true; 740 } 741 } 742 if( bAutoQueue ) 743 continue; |
744 745 String aEntry( *it ); 746 if( *it == m_rPIManager.getDefaultPrinter() ) 747 { 748 aEntry.AppendAscii( " (" ); 749 aEntry += m_aDefPrt; 750 aEntry.AppendAscii( ")" ); 751 } 752 int nPos = | 744 745 String aEntry( *it ); 746 if( *it == m_rPIManager.getDefaultPrinter() ) 747 { 748 aEntry.AppendAscii( " (" ); 749 aEntry += m_aDefPrt; 750 aEntry.AppendAscii( ")" ); 751 } 752 int nPos = |
753 m_aDevicesLB.InsertEntry( aEntry, 754 bFax ? m_aFaxImg : 755 bPdf ? m_aPdfImg : m_aPrinterImg 756 ); | 753 m_aDevicesLB.InsertEntry( aEntry, 754 bFax ? m_aFaxImg : 755 bPdf ? m_aPdfImg : m_aPrinterImg 756 ); |
757 m_aDevicesLB.SetEntryData( nPos, (void*)it->getLength() ); 758 if( *it == m_rPIManager.getDefaultPrinter() ) 759 { 760 m_aDevicesLB.SelectEntryPos( nPos ); 761 UpdateText(); 762 } 763 } 764} 765 | 757 m_aDevicesLB.SetEntryData( nPos, (void*)it->getLength() ); 758 if( *it == m_rPIManager.getDefaultPrinter() ) 759 { 760 m_aDevicesLB.SelectEntryPos( nPos ); 761 UpdateText(); 762 } 763 } 764} 765 |
766/* vim: set noet sw=4 ts=4: */ |
|