This is an automated email from the ASF dual-hosted git repository. mseidel pushed a commit to branch AOO42X in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO42X by this push: new b8c015e0bb Fixed typos, removed whitespace b8c015e0bb is described below commit b8c015e0bba87a82fe338343582792711e4ea3a3 Author: mseidel <msei...@apache.org> AuthorDate: Mon May 1 21:42:36 2023 +0200 Fixed typos, removed whitespace (cherry picked from commit 97679416e31bac29618986bf4c78080afcf870f0) --- main/padmin/source/adddlg.cxx | 616 ++++++++++++++++++++-------------------- main/padmin/source/helper.cxx | 248 ++++++++-------- main/padmin/source/padialog.cxx | 381 ++++++++++++------------- 3 files changed, 625 insertions(+), 620 deletions(-) diff --git a/main/padmin/source/adddlg.cxx b/main/padmin/source/adddlg.cxx index 93bba44a23..530a65e6df 100644 --- a/main/padmin/source/adddlg.cxx +++ b/main/padmin/source/adddlg.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -43,8 +43,8 @@ using namespace std; APTabPage::APTabPage( AddPrinterDialog* pParent, const ResId& rResId ) : TabPage( pParent, rResId ), - m_aTitle( PaResId( RID_ADDP_STR_TITLE ) ), - m_pParent( pParent ) + m_aTitle( PaResId( RID_ADDP_STR_TITLE ) ), + m_pParent( pParent ) { } @@ -61,15 +61,15 @@ APChooseDevicePage::APChooseDevicePage( AddPrinterDialog* pParent ) : m_aFaxBtn.Check( sal_False ); m_aPDFBtn.Check( sal_False ); m_aOldBtn.Check( sal_False ); - if( ! AddPrinterDialog::getOldPrinterLocation().Len() ) - m_aOldBtn.Enable( sal_False ); - if( ! PrinterInfoManager::get().addOrRemovePossible() ) - { - m_aPrinterBtn.Check( sal_False ); - m_aFaxBtn.Check( sal_True ); - m_aPrinterBtn.Enable( sal_False ); - m_aOldBtn.Enable( sal_False ); - } + if( ! AddPrinterDialog::getOldPrinterLocation().Len() ) + m_aOldBtn.Enable( sal_False ); + if( ! PrinterInfoManager::get().addOrRemovePossible() ) + { + m_aPrinterBtn.Check( sal_False ); + m_aFaxBtn.Check( sal_True ); + m_aPrinterBtn.Enable( sal_False ); + m_aOldBtn.Enable( sal_False ); + } } APChooseDevicePage::~APChooseDevicePage() @@ -129,9 +129,9 @@ void APChooseDriverPage::fill( PrinterInfo& rInfo ) String* pDriver = (String*)m_aDriverBox.GetEntryData( nPos ); rInfo.m_aDriverName = *pDriver; #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "m_aLastPrinterName = \"%s\", rInfo.m_aPrinterName = \"%s\"\n", - OUStringToOString( m_aLastPrinterName, RTL_TEXTENCODING_ISO_8859_1 ).getStr(), - OUStringToOString( rInfo.m_aPrinterName, RTL_TEXTENCODING_ISO_8859_1 ).getStr() ); + fprintf( stderr, "m_aLastPrinterName = \"%s\", rInfo.m_aPrinterName = \"%s\"\n", + OUStringToOString( m_aLastPrinterName, RTL_TEXTENCODING_ISO_8859_1 ).getStr(), + OUStringToOString( rInfo.m_aPrinterName, RTL_TEXTENCODING_ISO_8859_1 ).getStr() ); #endif if( rInfo.m_aPrinterName.equals( m_aLastPrinterName ) ) { @@ -146,25 +146,25 @@ void APChooseDriverPage::updateDrivers( bool bRefresh, const rtl::OUString& rSel delete (String*)m_aDriverBox.GetEntryData( k ); m_aDriverBox.Clear(); - std::list< rtl::OUString > aDrivers; - psp::PPDParser::getKnownPPDDrivers( aDrivers, bRefresh ); - - rtl::OUString aSelectDriver( psp::PPDParser::getPPDPrinterName( rSelectDriver ) ); - - rtl::OUString aSelectedEntry; - for( std::list< rtl::OUString >::const_iterator it = aDrivers.begin(); it != aDrivers.end(); ++it ) - { - rtl::OUString aDriver( psp::PPDParser::getPPDPrinterName( *it ) ); - if( aDriver.getLength() ) - { - int nPos = m_aDriverBox.InsertEntry( aDriver ); - m_aDriverBox.SetEntryData( nPos, new String( *it ) ); - if( aDriver == aSelectDriver ) - aSelectedEntry = aDriver; - } - } - - m_aDriverBox.SelectEntry( aSelectedEntry ); + std::list< rtl::OUString > aDrivers; + psp::PPDParser::getKnownPPDDrivers( aDrivers, bRefresh ); + + rtl::OUString aSelectDriver( psp::PPDParser::getPPDPrinterName( rSelectDriver ) ); + + rtl::OUString aSelectedEntry; + for( std::list< rtl::OUString >::const_iterator it = aDrivers.begin(); it != aDrivers.end(); ++it ) + { + rtl::OUString aDriver( psp::PPDParser::getPPDPrinterName( *it ) ); + if( aDriver.getLength() ) + { + int nPos = m_aDriverBox.InsertEntry( aDriver ); + m_aDriverBox.SetEntryData( nPos, new String( *it ) ); + if( aDriver == aSelectDriver ) + aSelectedEntry = aDriver; + } + } + + m_aDriverBox.SelectEntry( aSelectedEntry ); m_aRemBtn.Enable( m_aDriverBox.GetEntryCount() > 0 ); } @@ -182,13 +182,13 @@ IMPL_LINK( APChooseDriverPage, ClickBtnHdl, PushButton*, pButton ) { PPDImportDialog aDlg( this ); if( aDlg.Execute() ) - { - const std::list< rtl::OUString >& rImported( aDlg.getImportedFiles() ); - if( rImported.empty() ) - updateDrivers( true ); - else - updateDrivers( true, rImported.front() ); - } + { + const std::list< rtl::OUString >& rImported( aDlg.getImportedFiles() ); + if( rImported.empty() ) + updateDrivers( true ); + else + updateDrivers( true, rImported.front() ); + } } else if( pButton == &m_aRemBtn ) { @@ -201,19 +201,19 @@ IMPL_LINK( APChooseDriverPage, ClickBtnHdl, PushButton*, pButton ) String aDriver( *(String*)m_aDriverBox.GetEntryData( nSelect ) ); if( aDriver.Len() ) { - // never delete the default driver - if( aDriver.EqualsIgnoreCaseAscii( "SGENPRT" ) ) - { + // never delete the default driver + if( aDriver.EqualsIgnoreCaseAscii( "SGENPRT" ) ) + { String aText( PaResId( RID_ERR_REMOVESGENPRT ) ); aText.SearchAndReplace( String::CreateFromAscii( "%s" ), m_aDriverBox.GetSelectEntry( i ) ); ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aText ); aErrorBox.SetText( m_aRemStr ); aErrorBox.Execute(); - continue; - } + continue; + } PrinterInfo aDefInfo( rPIManager.getPrinterInfo( rPIManager.getDefaultPrinter() ) ); - // for comparisons convert to a OUString + // for comparisons convert to a OUString OUString aPPD( aDriver ); if( aDefInfo.m_aDriverName == aPPD ) { @@ -263,17 +263,17 @@ IMPL_LINK( APChooseDriverPage, ClickBtnHdl, PushButton*, pButton ) } std::list< rtl::OUString > aDirs; - // get only psprint's directories, not eventual system dirs + // get only psprint's directories, not eventual system dirs psp::getPrinterPathList( aDirs, NULL ); - std::list< rtl::OUString >::iterator dir; + std::list< rtl::OUString >::iterator dir; for( dir = aDirs.begin(); dir != aDirs.end(); ++dir ) { ::std::list< String > aFiles; ::std::list< String >::iterator file; - OUStringBuffer aDir( *dir ); - aDir.append( sal_Unicode( '/' ) ); - aDir.appendAscii( PRINTER_PPDDIR ); - rtl::OUString aPPDDir( aDir.makeStringAndClear() ); + OUStringBuffer aDir( *dir ); + aDir.append( sal_Unicode( '/' ) ); + aDir.appendAscii( PRINTER_PPDDIR ); + rtl::OUString aPPDDir( aDir.makeStringAndClear() ); FindFiles( aPPDDir, aFiles, String( RTL_CONSTASCII_USTRINGPARAM( "PS;PPD;PS.GZ;PPD.GZ" ) ), true ); for( file = aFiles.begin(); file != aFiles.end(); ++file ) { @@ -287,14 +287,14 @@ IMPL_LINK( APChooseDriverPage, ClickBtnHdl, PushButton*, pButton ) { ByteString aSysPath( aFile, aEncoding ); if( unlink( aSysPath.GetBuffer() ) ) - { - String aText( PaResId( RID_ERR_REMOVEDRIVERFAILED ) ); - aText.SearchAndReplace( String::CreateFromAscii( "%s1" ), m_aDriverBox.GetSelectEntry( i ) ); - aText.SearchAndReplace( String::CreateFromAscii( "%s2" ), aFile ); - ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aText ); - aErrorBox.SetText( m_aRemStr ); - aErrorBox.Execute(); - } + { + String aText( PaResId( RID_ERR_REMOVEDRIVERFAILED ) ); + aText.SearchAndReplace( String::CreateFromAscii( "%s1" ), m_aDriverBox.GetSelectEntry( i ) ); + aText.SearchAndReplace( String::CreateFromAscii( "%s2" ), aFile ); + ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK, aText ); + aErrorBox.SetText( m_aRemStr ); + aErrorBox.Execute(); + } } } } @@ -369,12 +369,12 @@ APCommandPage::APCommandPage( AddPrinterDialog* pParent, DeviceKind::type eKind FreeResource(); ::std::list< String > aCommands; if( m_eKind == DeviceKind::Printer ) - { + { m_aHelpBtn.Show( sal_False ); - Size aSize = m_aCommandTxt.GetSizePixel(); - aSize.Width() = m_aCommandBox.GetSizePixel().Width(); - m_aCommandTxt.SetSizePixel( aSize ); - } + Size aSize = m_aCommandTxt.GetSizePixel(); + aSize.Width() = m_aCommandBox.GetSizePixel().Width(); + m_aCommandTxt.SetSizePixel( aSize ); + } if( m_eKind != DeviceKind::Pdf ) { m_aPdfDirBtn.Show( sal_False ); @@ -387,32 +387,32 @@ APCommandPage::APCommandPage( AddPrinterDialog* pParent, DeviceKind::type eKind case DeviceKind::Fax: CommandStore::getFaxCommands( aCommands );break; case DeviceKind::Pdf: CommandStore::getPdfCommands( aCommands );break; } - // adjust height of command text and help button - Rectangle aPosSize( m_aCommandTxt.GetPosPixel(), m_aCommandTxt.GetSizePixel() ); - Rectangle aTextSize = m_aCommandTxt.GetTextRect( Rectangle( Point(), aPosSize.GetSize() ), m_aCommandTxt.GetText() ); - if( aTextSize.GetWidth() <= 2*(aPosSize.GetWidth()+1) ) - { - Size aNewSize( aPosSize.GetWidth(), aPosSize.GetHeight()*2/3 ); - if( aNewSize.Height() < m_aHelpBtn.GetSizePixel().Height()+2 ) - aNewSize.Height() = m_aHelpBtn.GetSizePixel().Height()+2; - Point aNewPos( aPosSize.Left(), aPosSize.Top() + aPosSize.GetHeight() - aNewSize.Height() ); - m_aCommandTxt.SetPosSizePixel( aNewPos, aNewSize ); - aNewPos.X() = m_aHelpBtn.GetPosPixel().X(); - m_aHelpBtn.SetPosPixel( aNewPos ); - } - - // fill in commands + // adjust height of command text and help button + Rectangle aPosSize( m_aCommandTxt.GetPosPixel(), m_aCommandTxt.GetSizePixel() ); + Rectangle aTextSize = m_aCommandTxt.GetTextRect( Rectangle( Point(), aPosSize.GetSize() ), m_aCommandTxt.GetText() ); + if( aTextSize.GetWidth() <= 2*(aPosSize.GetWidth()+1) ) + { + Size aNewSize( aPosSize.GetWidth(), aPosSize.GetHeight()*2/3 ); + if( aNewSize.Height() < m_aHelpBtn.GetSizePixel().Height()+2 ) + aNewSize.Height() = m_aHelpBtn.GetSizePixel().Height()+2; + Point aNewPos( aPosSize.Left(), aPosSize.Top() + aPosSize.GetHeight() - aNewSize.Height() ); + m_aCommandTxt.SetPosSizePixel( aNewPos, aNewSize ); + aNewPos.X() = m_aHelpBtn.GetPosPixel().X(); + m_aHelpBtn.SetPosPixel( aNewPos ); + } + + // fill in commands ::std::list< String >::iterator it; for( it = aCommands.begin(); it != aCommands.end(); ++it ) m_aCommandBox.InsertEntry( *it ); m_aHelpBtn.SetClickHdl( LINK( this, APCommandPage, ClickBtnHdl ) ); m_aPdfDirBtn.SetClickHdl( LINK( this, APCommandPage, ClickBtnHdl ) ); - if( m_eKind != DeviceKind::Printer ) - { - m_aCommandBox.SetModifyHdl( LINK( this, APCommandPage, ModifyHdl ) ); - m_pParent->enableNext( false ); - } + if( m_eKind != DeviceKind::Printer ) + { + m_aCommandBox.SetModifyHdl( LINK( this, APCommandPage, ModifyHdl ) ); + m_pParent->enableNext( false ); + } } APCommandPage::~APCommandPage() @@ -443,20 +443,20 @@ IMPL_LINK( APCommandPage, ClickBtnHdl, PushButton*, pButton ) } else if( pButton == &m_aPdfDirBtn ) { - String aPath( m_aPdfDirEdt.GetText() ); - if( chooseDirectory( aPath ) ) - m_aPdfDirEdt.SetText( aPath ); + String aPath( m_aPdfDirEdt.GetText() ); + if( chooseDirectory( aPath ) ) + m_aPdfDirEdt.SetText( aPath ); } return 0; } IMPL_LINK( APCommandPage, ModifyHdl, ComboBox*, pBox ) { - if( pBox == &m_aCommandBox ) - { - m_pParent->enableNext( m_aCommandBox.GetText().Len() ); - } - return 0; + if( pBox == &m_aCommandBox ) + { + m_pParent->enableNext( m_aCommandBox.GetText().Len() ); + } + return 0; } bool APCommandPage::check() @@ -480,143 +480,143 @@ APOldPrinterPage::APOldPrinterPage( AddPrinterDialog* pParent ) FreeResource(); m_aSelectAllBtn.SetClickHdl( LINK( this, APOldPrinterPage, ClickBtnHdl ) ); - rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); - - String aFileName( AddPrinterDialog::getOldPrinterLocation() ); - Config aConfig( aFileName ); - - // read defaults - aConfig.SetGroup( "Xprinter,PostScript" ); - ByteString aDefPageSize( aConfig.ReadKey( "PageSize" ) ); - ByteString aDefOrientation( aConfig.ReadKey( "Orientation" ) ); - ByteString aDefMarginLeft( aConfig.ReadKey( "MarginLeft" ) ); - ByteString aDefMarginRight( aConfig.ReadKey( "MarginRight" ) ); - ByteString aDefMarginTop( aConfig.ReadKey( "MarginTop" ) ); - ByteString aDefMarginBottom( aConfig.ReadKey( "MarginBottom" ) ); - ByteString aDefScale( aConfig.ReadKey( "Scale" ) ); - ByteString aDefCopies( aConfig.ReadKey( "Copies" ) ); - ByteString aDefDPI( aConfig.ReadKey( "DPI" ) ); - - aConfig.SetGroup( "devices" ); - int nDevices = aConfig.GetKeyCount(); - for( int nKey = 0; nKey < nDevices; nKey++ ) - { - aConfig.SetGroup( "devices" ); - ByteString aPrinter( aConfig.GetKeyName( nKey ) ); - ByteString aValue( aConfig.ReadKey( aPrinter ) ); - ByteString aPort( aValue.GetToken( 1, ',' ) ); - ByteString aDriver( aValue.GetToken( 0, ' ' ) ); - ByteString aPS( aValue.GetToken( 0, ',' ).GetToken( 1, ' ' ) ); - ByteString aNewDriver( aDriver ); - if( aDriver == "GENERIC" ) - aNewDriver = "SGENPRT"; - - if( aPS != "PostScript" ) - continue; - - const PPDParser* pParser = PPDParser::getParser( String( aNewDriver, aEncoding ) ); - if( pParser == NULL ) - { - String aText( PaResId( RID_TXT_DRIVERDOESNOTEXIST ) ); - aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s1" ) ), String( aPrinter, aEncoding ) ); - aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s2" ) ), String( aDriver, aEncoding ) ); - InfoBox aBox( this, aText ); - aBox.Execute(); - continue; - } - - // read the command - aConfig.SetGroup( "ports" ); - ByteString aCommand( aConfig.ReadKey( aPort ) ); - if( ! aCommand.Len() ) - { - String aText( PaResId( RID_TXT_PRINTERWITHOUTCOMMAND ) ); - aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), String( aPrinter, aEncoding ) ); - InfoBox aBox( this, aText ); - aBox.Execute(); - continue; - } - - - String aUPrinter( AddPrinterDialog::uniquePrinterName( String( aPrinter, aEncoding ) ) ); - - PrinterInfo aInfo; - aInfo.m_aDriverName = String( aNewDriver, aEncoding ); - aInfo.m_pParser = pParser; - aInfo.m_aContext.setParser( pParser ); - aInfo.m_aPrinterName = aUPrinter; - aInfo.m_aCommand = String( aCommand, aEncoding ); - - // read the printer settings - ByteString aGroup( aDriver ); - aGroup += ",PostScript,"; - aGroup += aPort; - aConfig.SetGroup( aGroup ); - - aValue = aConfig.ReadKey( "PageSize", aDefPageSize ); - int nLeft, nRight, nTop, nBottom; - if( aValue.Len() && - aInfo.m_pParser->getMargins( String( aValue, aEncoding ), - nLeft, nRight, nTop, nBottom ) ) - { - const PPDKey* pKey = aInfo.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) ); - const PPDValue* pValue = pKey ? pKey->getValue( String( aValue, aEncoding ) ) : NULL; - if( pKey && pValue ) - aInfo.m_aContext.setValue( pKey, pValue ); - aValue = aConfig.ReadKey( "MarginLeft", aDefMarginLeft ); - if( aValue.Len() ) - aInfo.m_nLeftMarginAdjust = aValue.ToInt32() - (int)((double)nLeft * 35.27777778 ); - aValue = aConfig.ReadKey( "MarginRight", aDefMarginRight ); - if( aValue.Len() ) - aInfo.m_nRightMarginAdjust = aValue.ToInt32() - (int)((double)nRight * 35.27777778 ); - aValue = aConfig.ReadKey( "MarginTop", aDefMarginTop ); - if( aValue.Len() ) - aInfo.m_nTopMarginAdjust = aValue.ToInt32() - (int)((double)nTop * 35.27777778 ); - aValue = aConfig.ReadKey( "MarginBottom", aDefMarginBottom ); - if( aValue.Len() ) - aInfo.m_nBottomMarginAdjust = aValue.ToInt32() - (int)((double)nBottom * 35.27777778 ); - } - - aValue = aConfig.ReadKey( "Copies", aDefScale ); - if( aValue.Len() ) - aInfo.m_nCopies = aValue.ToInt32(); - - aValue = aConfig.ReadKey( "Comment" ); - aInfo.m_aComment = String( aValue, aEncoding ); - - aValue = aConfig.ReadKey( "Level" ); - if( aValue.Len() ) - aInfo.m_nPSLevel = aValue.ToInt32(); - - aValue = aConfig.ReadKey( "Orientation", aDefOrientation ); - if( aValue.Len() ) - aInfo.m_eOrientation = aValue.CompareIgnoreCaseToAscii( "landscape" ) == COMPARE_EQUAL ? orientation::Landscape : orientation::Portrait; - int nGroupKeys = aConfig.GetKeyCount(); - for( int nPPDKey = 0; nPPDKey < nGroupKeys; nPPDKey++ ) - { - ByteString aPPDKey( aConfig.GetKeyName( nPPDKey ) ); - // ignore page region - // there are some ppd keys in old Xpdefaults that - // should never have been writte because they are defaults - // PageRegion leads to problems in conjunction - // with a not matching PageSize - if( aPPDKey.CompareTo( "PPD_", 4 ) == COMPARE_EQUAL && - aPPDKey != "PPD_PageRegion" - ) - { - aValue = aConfig.ReadKey( nPPDKey ); - aPPDKey.Erase( 0, 4 ); - const PPDKey* pKey = aInfo.m_pParser->getKey( String( aPPDKey, RTL_TEXTENCODING_ISO_8859_1 ) ); - const PPDValue* pValue = pKey ? ( aValue.Equals( "*nil" ) ? NULL : pKey->getValue( String( aValue, RTL_TEXTENCODING_ISO_8859_1 ) ) ) : NULL; - if( pKey ) - aInfo.m_aContext.setValue( pKey, pValue, true ); - } - } - - m_aOldPrinters.push_back( aInfo ); - int nPos = m_aOldPrinterBox.InsertEntry( aInfo.m_aPrinterName ); - m_aOldPrinterBox.SetEntryData( nPos, & m_aOldPrinters.back() ); - } + rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); + + String aFileName( AddPrinterDialog::getOldPrinterLocation() ); + Config aConfig( aFileName ); + + // read defaults + aConfig.SetGroup( "Xprinter,PostScript" ); + ByteString aDefPageSize( aConfig.ReadKey( "PageSize" ) ); + ByteString aDefOrientation( aConfig.ReadKey( "Orientation" ) ); + ByteString aDefMarginLeft( aConfig.ReadKey( "MarginLeft" ) ); + ByteString aDefMarginRight( aConfig.ReadKey( "MarginRight" ) ); + ByteString aDefMarginTop( aConfig.ReadKey( "MarginTop" ) ); + ByteString aDefMarginBottom( aConfig.ReadKey( "MarginBottom" ) ); + ByteString aDefScale( aConfig.ReadKey( "Scale" ) ); + ByteString aDefCopies( aConfig.ReadKey( "Copies" ) ); + ByteString aDefDPI( aConfig.ReadKey( "DPI" ) ); + + aConfig.SetGroup( "devices" ); + int nDevices = aConfig.GetKeyCount(); + for( int nKey = 0; nKey < nDevices; nKey++ ) + { + aConfig.SetGroup( "devices" ); + ByteString aPrinter( aConfig.GetKeyName( nKey ) ); + ByteString aValue( aConfig.ReadKey( aPrinter ) ); + ByteString aPort( aValue.GetToken( 1, ',' ) ); + ByteString aDriver( aValue.GetToken( 0, ' ' ) ); + ByteString aPS( aValue.GetToken( 0, ',' ).GetToken( 1, ' ' ) ); + ByteString aNewDriver( aDriver ); + if( aDriver == "GENERIC" ) + aNewDriver = "SGENPRT"; + + if( aPS != "PostScript" ) + continue; + + const PPDParser* pParser = PPDParser::getParser( String( aNewDriver, aEncoding ) ); + if( pParser == NULL ) + { + String aText( PaResId( RID_TXT_DRIVERDOESNOTEXIST ) ); + aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s1" ) ), String( aPrinter, aEncoding ) ); + aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s2" ) ), String( aDriver, aEncoding ) ); + InfoBox aBox( this, aText ); + aBox.Execute(); + continue; + } + + // read the command + aConfig.SetGroup( "ports" ); + ByteString aCommand( aConfig.ReadKey( aPort ) ); + if( ! aCommand.Len() ) + { + String aText( PaResId( RID_TXT_PRINTERWITHOUTCOMMAND ) ); + aText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), String( aPrinter, aEncoding ) ); + InfoBox aBox( this, aText ); + aBox.Execute(); + continue; + } + + + String aUPrinter( AddPrinterDialog::uniquePrinterName( String( aPrinter, aEncoding ) ) ); + + PrinterInfo aInfo; + aInfo.m_aDriverName = String( aNewDriver, aEncoding ); + aInfo.m_pParser = pParser; + aInfo.m_aContext.setParser( pParser ); + aInfo.m_aPrinterName = aUPrinter; + aInfo.m_aCommand = String( aCommand, aEncoding ); + + // read the printer settings + ByteString aGroup( aDriver ); + aGroup += ",PostScript,"; + aGroup += aPort; + aConfig.SetGroup( aGroup ); + + aValue = aConfig.ReadKey( "PageSize", aDefPageSize ); + int nLeft, nRight, nTop, nBottom; + if( aValue.Len() && + aInfo.m_pParser->getMargins( String( aValue, aEncoding ), + nLeft, nRight, nTop, nBottom ) ) + { + const PPDKey* pKey = aInfo.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) ); + const PPDValue* pValue = pKey ? pKey->getValue( String( aValue, aEncoding ) ) : NULL; + if( pKey && pValue ) + aInfo.m_aContext.setValue( pKey, pValue ); + aValue = aConfig.ReadKey( "MarginLeft", aDefMarginLeft ); + if( aValue.Len() ) + aInfo.m_nLeftMarginAdjust = aValue.ToInt32() - (int)((double)nLeft * 35.27777778 ); + aValue = aConfig.ReadKey( "MarginRight", aDefMarginRight ); + if( aValue.Len() ) + aInfo.m_nRightMarginAdjust = aValue.ToInt32() - (int)((double)nRight * 35.27777778 ); + aValue = aConfig.ReadKey( "MarginTop", aDefMarginTop ); + if( aValue.Len() ) + aInfo.m_nTopMarginAdjust = aValue.ToInt32() - (int)((double)nTop * 35.27777778 ); + aValue = aConfig.ReadKey( "MarginBottom", aDefMarginBottom ); + if( aValue.Len() ) + aInfo.m_nBottomMarginAdjust = aValue.ToInt32() - (int)((double)nBottom * 35.27777778 ); + } + + aValue = aConfig.ReadKey( "Copies", aDefScale ); + if( aValue.Len() ) + aInfo.m_nCopies = aValue.ToInt32(); + + aValue = aConfig.ReadKey( "Comment" ); + aInfo.m_aComment = String( aValue, aEncoding ); + + aValue = aConfig.ReadKey( "Level" ); + if( aValue.Len() ) + aInfo.m_nPSLevel = aValue.ToInt32(); + + aValue = aConfig.ReadKey( "Orientation", aDefOrientation ); + if( aValue.Len() ) + aInfo.m_eOrientation = aValue.CompareIgnoreCaseToAscii( "landscape" ) == COMPARE_EQUAL ? orientation::Landscape : orientation::Portrait; + int nGroupKeys = aConfig.GetKeyCount(); + for( int nPPDKey = 0; nPPDKey < nGroupKeys; nPPDKey++ ) + { + ByteString aPPDKey( aConfig.GetKeyName( nPPDKey ) ); + // ignore page region + // there are some ppd keys in old Xpdefaults that + // should never have been written because they are defaults + // PageRegion leads to problems in conjunction + // with a not matching PageSize + if( aPPDKey.CompareTo( "PPD_", 4 ) == COMPARE_EQUAL && + aPPDKey != "PPD_PageRegion" + ) + { + aValue = aConfig.ReadKey( nPPDKey ); + aPPDKey.Erase( 0, 4 ); + const PPDKey* pKey = aInfo.m_pParser->getKey( String( aPPDKey, RTL_TEXTENCODING_ISO_8859_1 ) ); + const PPDValue* pValue = pKey ? ( aValue.Equals( "*nil" ) ? NULL : pKey->getValue( String( aValue, RTL_TEXTENCODING_ISO_8859_1 ) ) ) : NULL; + if( pKey ) + aInfo.m_aContext.setValue( pKey, pValue, true ); + } + } + + m_aOldPrinters.push_back( aInfo ); + int nPos = m_aOldPrinterBox.InsertEntry( aInfo.m_aPrinterName ); + m_aOldPrinterBox.SetEntryData( nPos, & m_aOldPrinters.back() ); + } } APOldPrinterPage::~APOldPrinterPage() @@ -627,9 +627,9 @@ IMPL_LINK( APOldPrinterPage, ClickBtnHdl, PushButton*, pButton ) { if( pButton == &m_aSelectAllBtn ) { - for( int i = 0; i < m_aOldPrinterBox.GetEntryCount(); i++ ) - m_aOldPrinterBox.SelectEntryPos( i ); - } + for( int i = 0; i < m_aOldPrinterBox.GetEntryCount(); i++ ) + m_aOldPrinterBox.SelectEntryPos( i ); + } return 0; } @@ -736,7 +736,7 @@ AddPrinterDialog::AddPrinterDialog( Window* pParent ) m_aNextPB( this, PaResId( RID_ADDP_BTN_NEXT ) ), m_aFinishPB( this, PaResId( RID_ADDP_BTN_FINISH ) ), m_aLine( this, PaResId( RID_ADDP_LINE ) ), - m_aTitleImage( this, PaResId( RID_ADDP_CTRL_TITLE ) ), + m_aTitleImage( this, PaResId( RID_ADDP_CTRL_TITLE ) ), m_pCurrentPage( NULL ), m_pChooseDevicePage( NULL ), m_pCommandPage( NULL ), @@ -763,9 +763,9 @@ AddPrinterDialog::AddPrinterDialog( Window* pParent ) m_aFinishPB.SetClickHdl( LINK( this, AddPrinterDialog, ClickBtnHdl ) ); m_aCancelPB.SetClickHdl( LINK( this, AddPrinterDialog, ClickBtnHdl ) ); - m_aTitleImage.SetBackgroundColor( Color( 0xff, 0xff, 0xff ) ); - m_aTitleImage.SetText( m_pCurrentPage->getTitle() ); - updateSettings(); + m_aTitleImage.SetBackgroundColor( Color( 0xff, 0xff, 0xff ) ); + m_aTitleImage.SetText( m_pCurrentPage->getTitle() ); + updateSettings(); } AddPrinterDialog::~AddPrinterDialog() @@ -800,20 +800,20 @@ AddPrinterDialog::~AddPrinterDialog() void AddPrinterDialog::updateSettings() { - if( ! GetSettings().GetStyleSettings().GetHighContrastMode() ) - m_aTitleImage.SetImage( Image( BitmapEx( PaResId( RID_BMP_PRINTER ) ) ) ); - else - m_aTitleImage.SetImage( Image( BitmapEx( PaResId( RID_BMP_PRINTER_HC ) ) ) ); + if( ! GetSettings().GetStyleSettings().GetHighContrastMode() ) + m_aTitleImage.SetImage( Image( BitmapEx( PaResId( RID_BMP_PRINTER ) ) ) ); + else + m_aTitleImage.SetImage( Image( BitmapEx( PaResId( RID_BMP_PRINTER_HC ) ) ) ); } void AddPrinterDialog::DataChanged( const DataChangedEvent& rEv ) { - ModalDialog::DataChanged( rEv ); - if( (rEv.GetType() == DATACHANGED_SETTINGS) && - (rEv.GetFlags() & SETTINGS_STYLE) ) - { - updateSettings(); - } + ModalDialog::DataChanged( rEv ); + if( (rEv.GetType() == DATACHANGED_SETTINGS) && + (rEv.GetFlags() & SETTINGS_STYLE) ) + { + updateSettings(); + } } void AddPrinterDialog::advance() @@ -823,9 +823,9 @@ void AddPrinterDialog::advance() { if( m_pChooseDevicePage->isPrinter() ) { - if( ! m_pChooseDriverPage ) - m_pChooseDriverPage = new APChooseDriverPage( this ); - m_pCurrentPage = m_pChooseDriverPage; + if( ! m_pChooseDriverPage ) + m_pChooseDriverPage = new APChooseDriverPage( this ); + m_pCurrentPage = m_pChooseDriverPage; m_aPrevPB.Enable( sal_True ); } else if( m_pChooseDevicePage->isOld() ) @@ -854,16 +854,16 @@ void AddPrinterDialog::advance() } else if( m_pCurrentPage == m_pChooseDriverPage ) { - if( ! m_pCommandPage ) - m_pCommandPage = new APCommandPage( this, DeviceKind::Printer ); - m_pCurrentPage = m_pCommandPage; + if( ! m_pCommandPage ) + m_pCommandPage = new APCommandPage( this, DeviceKind::Printer ); + m_pCurrentPage = m_pCommandPage; } else if( m_pCurrentPage == m_pCommandPage ) { if( ! m_pNamePage ) m_pNamePage = new APNamePage( this, m_aPrinter.m_aPrinterName, DeviceKind::Printer ); - else - m_pNamePage->setText( m_aPrinter.m_aPrinterName ); + else + m_pNamePage->setText( m_aPrinter.m_aPrinterName ); m_pCurrentPage = m_pNamePage; m_aFinishPB.Enable( sal_True ); m_aNextPB.Enable( sal_False ); @@ -878,9 +878,9 @@ void AddPrinterDialog::advance() } else { - if( ! m_pFaxCommandPage ) - m_pFaxCommandPage = new APCommandPage( this, DeviceKind::Fax ); - m_pCurrentPage = m_pFaxCommandPage; + if( ! m_pFaxCommandPage ) + m_pFaxCommandPage = new APCommandPage( this, DeviceKind::Fax ); + m_pCurrentPage = m_pFaxCommandPage; } } else if( m_pCurrentPage == m_pFaxSelectDriverPage ) @@ -907,9 +907,9 @@ void AddPrinterDialog::advance() } else { - if( ! m_pPdfCommandPage ) - m_pPdfCommandPage = new APCommandPage( this, DeviceKind::Pdf ); - m_pCurrentPage = m_pPdfCommandPage; + if( ! m_pPdfCommandPage ) + m_pPdfCommandPage = new APCommandPage( this, DeviceKind::Pdf ); + m_pCurrentPage = m_pPdfCommandPage; } } else if( m_pCurrentPage == m_pPdfSelectDriverPage ) @@ -928,7 +928,7 @@ void AddPrinterDialog::advance() } m_pCurrentPage->Show( sal_True ); - m_aTitleImage.SetText( m_pCurrentPage->getTitle() ); + m_aTitleImage.SetText( m_pCurrentPage->getTitle() ); } void AddPrinterDialog::back() @@ -971,7 +971,7 @@ void AddPrinterDialog::back() else if( m_pCurrentPage == m_pFaxCommandPage ) { m_pCurrentPage = m_pFaxDriverPage->isDefault() ? (APTabPage*)m_pFaxDriverPage : (APTabPage*)m_pFaxSelectDriverPage; - m_aNextPB.Enable( sal_True ); + m_aNextPB.Enable( sal_True ); } else if( m_pCurrentPage == m_pPdfDriverPage ) { @@ -993,7 +993,7 @@ void AddPrinterDialog::back() m_aNextPB.Enable( sal_True ); } m_pCurrentPage->Show( sal_True ); - m_aTitleImage.SetText( m_pCurrentPage->getTitle() ); + m_aTitleImage.SetText( m_pCurrentPage->getTitle() ); } void AddPrinterDialog::addPrinter() @@ -1069,17 +1069,17 @@ String AddPrinterDialog::uniquePrinterName( const String& rBase ) PrinterInfoManager& rManager( PrinterInfoManager::get() ); int nVersion = 1; - list< OUString > aPrinterList; - rManager.listPrinters( aPrinterList ); - hash_set< OUString, OUStringHash > aPrinters; - for( list< OUString >::const_iterator it = aPrinterList.begin(); it != aPrinterList.end(); ++it ) - aPrinters.insert( *it ); - while( aPrinters.find( aResult ) != aPrinters.end() ) - { - aResult = rBase; - aResult.AppendAscii( "_" ); - aResult += String::CreateFromInt32( nVersion++ ); - } + list< OUString > aPrinterList; + rManager.listPrinters( aPrinterList ); + hash_set< OUString, OUStringHash > aPrinters; + for( list< OUString >::const_iterator it = aPrinterList.begin(); it != aPrinterList.end(); ++it ) + aPrinters.insert( *it ); + while( aPrinters.find( aResult ) != aPrinters.end() ) + { + aResult = rBase; + aResult.AppendAscii( "_" ); + aResult += String::CreateFromInt32( nVersion++ ); + } return aResult; } @@ -1087,38 +1087,40 @@ String AddPrinterDialog::uniquePrinterName( const String& rBase ) String AddPrinterDialog::getOldPrinterLocation() { static const char* pHome = getenv( "HOME" ); - String aRet; - ByteString aFileName; + String aRet; + ByteString aFileName; rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); if( pHome ) { aFileName = pHome; aFileName.Append( "/.Xpdefaults" ); - if( access( aFileName.GetBuffer(), F_OK ) ) - { - aFileName = pHome; - aFileName.Append( "/.sversionrc" ); - Config aSVer( String( aFileName, aEncoding ) ); - aSVer.SetGroup( "Versions" ); - aFileName = aSVer.ReadKey( "StarOffice 5.2" ); - if( aFileName.Len() ) - aFileName.Append( "/share/xp3/Xpdefaults" ); - else if( - (aFileName = aSVer.ReadKey( "StarOffice 5.1" ) ).Len() - || - (aFileName = aSVer.ReadKey( "StarOffice 5.0" ) ).Len() - || - (aFileName = aSVer.ReadKey( "StarOffice 4.0" ) ).Len() - ) - { - aFileName.Append( "/xp3/Xpdefaults" ); - } - if( aFileName.Len() && access( aFileName.GetBuffer(), F_OK ) ) - aFileName.Erase(); - } - } - if( aFileName.Len() ) - aRet = String( aFileName, aEncoding ); - return aRet; + if( access( aFileName.GetBuffer(), F_OK ) ) + { + aFileName = pHome; + aFileName.Append( "/.sversionrc" ); + Config aSVer( String( aFileName, aEncoding ) ); + aSVer.SetGroup( "Versions" ); + aFileName = aSVer.ReadKey( "StarOffice 5.2" ); + if( aFileName.Len() ) + aFileName.Append( "/share/xp3/Xpdefaults" ); + else if( + (aFileName = aSVer.ReadKey( "StarOffice 5.1" ) ).Len() + || + (aFileName = aSVer.ReadKey( "StarOffice 5.0" ) ).Len() + || + (aFileName = aSVer.ReadKey( "StarOffice 4.0" ) ).Len() + ) + { + aFileName.Append( "/xp3/Xpdefaults" ); + } + if( aFileName.Len() && access( aFileName.GetBuffer(), F_OK ) ) + aFileName.Erase(); + } + } + if( aFileName.Len() ) + aRet = String( aFileName, aEncoding ); + return aRet; } + +/* vim: set noet sw=4 ts=4: */ diff --git a/main/padmin/source/helper.cxx b/main/padmin/source/helper.cxx index 893473770e..8bb319b553 100644 --- a/main/padmin/source/helper.cxx +++ b/main/padmin/source/helper.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -61,33 +61,33 @@ ResId padmin::PaResId( sal_uInt32 nId ) static ResMgr* pPaResMgr = NULL; if( ! pPaResMgr ) { - ::com::sun::star::lang::Locale aLocale; + ::com::sun::star::lang::Locale aLocale; // LanguageType nLang = LANGUAGE_SYSTEM; - - utl::OConfigurationNode aNode = - utl::OConfigurationTreeRoot::tryCreateWithServiceFactory( - vcl::unohelper::GetMultiServiceFactory(), - OUString::createFromAscii( "org.openoffice.Setup/L10N" ) ); - if ( aNode.isValid() ) - { - rtl::OUString aLoc; - Any aValue = aNode.getNodeValue( OUString::createFromAscii( "ooLocale" ) ); - if( aValue >>= aLoc ) - { -// LanguageType nTmpLang = MsLangId::convertIsoStringToLanguage( aLoc ); -// if( nTmpLang != LANGUAGE_DONTKNOW ) -// nLang = nTmpLang; - sal_Int32 nIndex = 0; - aLocale.Language = aLoc.getToken( 0, '-', nIndex ); - aLocale.Country = aLoc.getToken( 0, '-', nIndex ); - aLocale.Variant = aLoc.getToken( 0, '-', nIndex ); - } - } + + utl::OConfigurationNode aNode = + utl::OConfigurationTreeRoot::tryCreateWithServiceFactory( + vcl::unohelper::GetMultiServiceFactory(), + OUString::createFromAscii( "org.openoffice.Setup/L10N" ) ); + if ( aNode.isValid() ) + { + rtl::OUString aLoc; + Any aValue = aNode.getNodeValue( OUString::createFromAscii( "ooLocale" ) ); + if( aValue >>= aLoc ) + { +// LanguageType nTmpLang = MsLangId::convertIsoStringToLanguage( aLoc ); +// if( nTmpLang != LANGUAGE_DONTKNOW ) +// nLang = nTmpLang; + sal_Int32 nIndex = 0; + aLocale.Language = aLoc.getToken( 0, '-', nIndex ); + aLocale.Country = aLoc.getToken( 0, '-', nIndex ); + aLocale.Variant = aLoc.getToken( 0, '-', nIndex ); + } + } pPaResMgr = ResMgr::SearchCreateResMgr( "spa", aLocale ); AllSettings aSettings = Application::GetSettings(); -// aSettings.SetUILanguage( nLang ); - aSettings.SetUILocale( aLocale ); - Application::SetSettings( aSettings ); +// aSettings.SetUILanguage( nLang ); + aSettings.SetUILocale( aLocale ); + Application::SetSettings( aSettings ); } return ResId( nId, *pPaResMgr ); } @@ -98,13 +98,13 @@ ResId padmin::PaResId( sal_uInt32 nId ) void padmin::FindFiles( const String& rDirectory, ::std::list< String >& rResult, const String& rSuffixes, bool bRecursive ) { - rResult.clear(); + rResult.clear(); OUString aDirPath; ::osl::FileBase::getFileURLFromSystemPath( rDirectory, aDirPath ); Directory aDir( aDirPath ); if( aDir.open() != FileBase::E_None ) - return; + return; DirectoryItem aItem; while( aDir.getNextItem( aItem ) == FileBase::E_None ) { @@ -112,43 +112,43 @@ void padmin::FindFiles( const String& rDirectory, ::std::list< String >& rResult FileStatusMask_Type ); if( aItem.getFileStatus( aStatus ) == FileBase::E_None ) - { - if( aStatus.getFileType() == FileStatus::Regular || - aStatus.getFileType() == FileStatus::Link ) - { - String aFileName = aStatus.getFileName(); - int nToken = rSuffixes.GetTokenCount( ';' ); - while( nToken-- ) - { - String aSuffix = rSuffixes.GetToken( nToken, ';' ); - if( aFileName.Len() > aSuffix.Len()+1 ) - { - String aExtension = aFileName.Copy( aFileName.Len()-aSuffix.Len() ); - if( aFileName.GetChar( aFileName.Len()-aSuffix.Len()-1 ) == '.' && - aExtension.EqualsIgnoreCaseAscii( aSuffix ) ) - { - rResult.push_back( aFileName ); - break; - } - } - } - } - else if( bRecursive && aStatus.getFileType() == FileStatus::Directory ) - { - OUStringBuffer aSubDir( rDirectory ); - aSubDir.appendAscii( "/", 1 ); - aSubDir.append( aStatus.getFileName() ); - std::list< String > subfiles; - FindFiles( aSubDir.makeStringAndClear(), subfiles, rSuffixes, bRecursive ); - for( std::list< String >::const_iterator it = subfiles.begin(); it != subfiles.end(); ++it ) - { - OUStringBuffer aSubFile( aStatus.getFileName() ); - aSubFile.appendAscii( "/", 1 ); - aSubFile.append( *it ); - rResult.push_back( aSubFile.makeStringAndClear() ); - } - } - } + { + if( aStatus.getFileType() == FileStatus::Regular || + aStatus.getFileType() == FileStatus::Link ) + { + String aFileName = aStatus.getFileName(); + int nToken = rSuffixes.GetTokenCount( ';' ); + while( nToken-- ) + { + String aSuffix = rSuffixes.GetToken( nToken, ';' ); + if( aFileName.Len() > aSuffix.Len()+1 ) + { + String aExtension = aFileName.Copy( aFileName.Len()-aSuffix.Len() ); + if( aFileName.GetChar( aFileName.Len()-aSuffix.Len()-1 ) == '.' && + aExtension.EqualsIgnoreCaseAscii( aSuffix ) ) + { + rResult.push_back( aFileName ); + break; + } + } + } + } + else if( bRecursive && aStatus.getFileType() == FileStatus::Directory ) + { + OUStringBuffer aSubDir( rDirectory ); + aSubDir.appendAscii( "/", 1 ); + aSubDir.append( aStatus.getFileName() ); + std::list< String > subfiles; + FindFiles( aSubDir.makeStringAndClear(), subfiles, rSuffixes, bRecursive ); + for( std::list< String >::const_iterator it = subfiles.begin(); it != subfiles.end(); ++it ) + { + OUStringBuffer aSubFile( aStatus.getFileName() ); + aSubFile.appendAscii( "/", 1 ); + aSubFile.append( *it ); + rResult.push_back( aSubFile.makeStringAndClear() ); + } + } + } } aDir.close(); } @@ -167,8 +167,8 @@ long DelMultiListBox::Notify( NotifyEvent& rEvent ) m_aDelPressedLink.Call( this ); nRet = 1; } - else - nRet = MultiListBox::Notify( rEvent ); + else + nRet = MultiListBox::Notify( rEvent ); return nRet; } @@ -187,8 +187,8 @@ long DelListBox::Notify( NotifyEvent& rEvent ) m_aDelPressedLink.Call( this ); nRet = 1; } - else - nRet = ListBox::Notify( rEvent ); + else + nRet = ListBox::Notify( rEvent ); return nRet; } @@ -203,27 +203,27 @@ QueryString::QueryString( Window* pParent, String& rQuery, String& rRet, const : m_aCancelButton( this, PaResId( RID_STRQRY_BTN_CANCEL ) ), m_aFixedText( this, PaResId( RID_STRQRY_TXT_RENAME ) ), m_aEdit( this, PaResId( RID_STRQRY_EDT_NEWNAME ) ), - m_aComboBox( this, PaResId( RID_STRQRY_BOX_NEWNAME ) ), + m_aComboBox( this, PaResId( RID_STRQRY_BOX_NEWNAME ) ), m_rReturnValue( rRet ) { FreeResource(); m_aOKButton.SetClickHdl( LINK( this, QueryString, ClickBtnHdl ) ); m_aFixedText.SetText( rQuery ); - if( rChoices.begin() != rChoices.end() ) - { - m_aComboBox.SetText( m_rReturnValue ); - m_aComboBox.InsertEntry( m_rReturnValue ); - for( ::std::list<String>::const_iterator it = rChoices.begin(); it != rChoices.end(); ++it ) - m_aComboBox.InsertEntry( *it ); - m_aEdit.Show( sal_False ); - m_bUseEdit = false; - } - else - { - m_aEdit.SetText( m_rReturnValue ); - m_aComboBox.Show( sal_False ); - m_bUseEdit = true; - } + if( rChoices.begin() != rChoices.end() ) + { + m_aComboBox.SetText( m_rReturnValue ); + m_aComboBox.InsertEntry( m_rReturnValue ); + for( ::std::list<String>::const_iterator it = rChoices.begin(); it != rChoices.end(); ++it ) + m_aComboBox.InsertEntry( *it ); + m_aEdit.Show( sal_False ); + m_bUseEdit = false; + } + else + { + m_aEdit.SetText( m_rReturnValue ); + m_aComboBox.Show( sal_False ); + m_bUseEdit = true; + } SetText( Application::GetDisplayName() ); } @@ -282,42 +282,44 @@ void padmin::freePadminRC() bool padmin::chooseDirectory( String& rInOutPath ) { - bool bRet = false; - Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); - if( xFactory.is() ) - { - Reference< XFolderPicker > xFolderPicker( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FolderPicker" ) ) ), UNO_QUERY ); - if( xFolderPicker.is() ) - { - Reference< XControlAccess > xCA( xFolderPicker, UNO_QUERY ); - if( xCA.is() ) - { - try - { - Any aState; - aState <<= sal_False; - xCA->setControlProperty( OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpButton" ) ), - OUString( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) ), - aState ); - - } - catch( ... ) - { - } - } - INetURLObject aObj( rInOutPath, INET_PROT_FILE, INetURLObject::ENCODE_ALL ); - xFolderPicker->setDisplayDirectory( aObj.GetMainURL(INetURLObject::DECODE_TO_IURI) ); - if( xFolderPicker->execute() == ExecutableDialogResults::OK ) - { - aObj = INetURLObject( xFolderPicker->getDirectory() ); - rInOutPath = aObj.PathToFileName(); - bRet = true; - } - } + bool bRet = false; + Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); + if( xFactory.is() ) + { + Reference< XFolderPicker > xFolderPicker( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FolderPicker" ) ) ), UNO_QUERY ); + if( xFolderPicker.is() ) + { + Reference< XControlAccess > xCA( xFolderPicker, UNO_QUERY ); + if( xCA.is() ) + { + try + { + Any aState; + aState <<= sal_False; + xCA->setControlProperty( OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpButton" ) ), + OUString( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) ), + aState ); + + } + catch( ... ) + { + } + } + INetURLObject aObj( rInOutPath, INET_PROT_FILE, INetURLObject::ENCODE_ALL ); + xFolderPicker->setDisplayDirectory( aObj.GetMainURL(INetURLObject::DECODE_TO_IURI) ); + if( xFolderPicker->execute() == ExecutableDialogResults::OK ) + { + aObj = INetURLObject( xFolderPicker->getDirectory() ); + rInOutPath = aObj.PathToFileName(); + bRet = true; + } + } #if OSL_DEBUG_LEVEL > 1 - else - fprintf( stderr, "could not get FolderPicker service\n" ); + else + fprintf( stderr, "could not get FolderPicker service\n" ); #endif - } - return bRet; + } + return bRet; } + +/* vim: set noet sw=4 ts=4: */ diff --git a/main/padmin/source/padialog.cxx b/main/padmin/source/padialog.cxx index be93b7515e..fb41cb9e39 100644 --- a/main/padmin/source/padialog.cxx +++ b/main/padmin/source/padialog.cxx @@ -1,5 +1,5 @@ /************************************************************** - * + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -7,16 +7,16 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * + * *************************************************************/ @@ -86,9 +86,9 @@ PADialog::PADialog( Window* pParent, sal_Bool /*bAdmin*/ ) : m_aCommand( this, PaResId( RID_PA_TXT_COMMAND_STRING ) ), m_aCommentTxt( this, PaResId( RID_PA_TXT_COMMENT ) ), m_aComment( this, PaResId( RID_PA_TXT_COMMENT_STRING ) ), - m_aCUPSFL( this, PaResId( RID_PA_FL_CUPSUSAGE ) ), - m_aCUPSCB( this, PaResId( RID_PA_CB_CUPSUSAGE ) ), - m_aSepButtonFL( this, PaResId( RID_PA_FL_SEPBUTTON ) ), + m_aCUPSFL( this, PaResId( RID_PA_FL_CUPSUSAGE ) ), + m_aCUPSCB( this, PaResId( RID_PA_CB_CUPSUSAGE ) ), + m_aSepButtonFL( this, PaResId( RID_PA_FL_SEPBUTTON ) ), m_aAddPB( this, PaResId( RID_PA_BTN_ADD ) ), m_aFontsPB( this, PaResId( RID_PA_BTN_FONTS ) ), m_aCancelButton( this, PaResId( RID_PA_BTN_CANCEL ) ), @@ -97,32 +97,32 @@ PADialog::PADialog( Window* pParent, sal_Bool /*bAdmin*/ ) : m_rPIManager( PrinterInfoManager::get() ) { FreeResource(); - updateSettings(); + updateSettings(); Init(); } void PADialog::updateSettings() { - if( ! GetSettings().GetStyleSettings().GetHighContrastMode() ) - { - m_aPrinterImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PRINTER ) ) ); - m_aFaxImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_FAX ) ) ); - m_aPdfImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PDF ) ) ); - } - else - { - m_aPrinterImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PRINTER_HC ) ) ); - m_aFaxImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_FAX_HC ) ) ); - m_aPdfImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PDF_HC ) ) ); - } + if( ! GetSettings().GetStyleSettings().GetHighContrastMode() ) + { + m_aPrinterImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PRINTER ) ) ); + m_aFaxImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_FAX ) ) ); + m_aPdfImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PDF ) ) ); + } + else + { + m_aPrinterImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PRINTER_HC ) ) ); + m_aFaxImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_FAX_HC ) ) ); + m_aPdfImg = Image( BitmapEx( PaResId( RID_BMP_SMALL_PDF_HC ) ) ); + } } void PADialog::Init() { - // #i79787# initially ensure printer discovery has ended - m_rPIManager.checkPrintersChanged( true ); - m_aCUPSCB.Check( m_rPIManager.isCUPSDisabled() ); - + // #i79787# initially ensure printer discovery has ended + m_rPIManager.checkPrintersChanged( true ); + m_aCUPSCB.Check( m_rPIManager.isCUPSDisabled() ); + UpdateDevice(); UpdateText(); @@ -138,30 +138,30 @@ void PADialog::Init() m_aFontsPB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); m_aAddPB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); m_aDevicesLB.setDelPressedLink( LINK( this, PADialog, DelPressedHdl ) ); - m_aCUPSCB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); + m_aCUPSCB.SetClickHdl( LINK( this, PADialog, ClickBtnHdl ) ); ::psp::PrintFontManager& rFontManager( ::psp::PrintFontManager::get() ); if( ! rFontManager.checkImportPossible() ) m_aFontsPB.Enable( sal_False ); - if( rFontManager.hasFontconfig() ) - { - m_aFontsPB.Enable( sal_False ); - m_aFontsPB.Show( sal_False ); - } - - // at this point no actual changes will be written - // but the write will have checked whether any writeable config exists - if( ! m_rPIManager.writePrinterConfig() ) - { - m_aAddPB.Enable( sal_False ); - m_aRemPB.Enable( sal_False ); - m_aConfPB.Enable( sal_False ); - m_aRenamePB.Enable( sal_False ); - m_aStdPB.Enable( sal_False ); - m_aCUPSCB.Enable( sal_False ); - ErrorBox aBox( GetParent(), WB_OK | WB_DEF_OK, String( PaResId( RID_ERR_NOWRITE ) ) ); - aBox.Execute(); - } + if( rFontManager.hasFontconfig() ) + { + m_aFontsPB.Enable( sal_False ); + m_aFontsPB.Show( sal_False ); + } + + // at this point no actual changes will be written + // but the write will have checked whether any writable config exists + if( ! m_rPIManager.writePrinterConfig() ) + { + m_aAddPB.Enable( sal_False ); + m_aRemPB.Enable( sal_False ); + m_aConfPB.Enable( sal_False ); + m_aRenamePB.Enable( sal_False ); + m_aStdPB.Enable( sal_False ); + m_aCUPSCB.Enable( sal_False ); + ErrorBox aBox( GetParent(), WB_OK | WB_DEF_OK, String( PaResId( RID_ERR_NOWRITE ) ) ); + aBox.Execute(); + } } PADialog::~PADialog() @@ -172,31 +172,31 @@ PADialog::~PADialog() long PADialog::Notify( NotifyEvent& rEv ) { - if( IsVisible() && - (rEv.GetType() == EVENT_GETFOCUS || rEv.GetType() == EVENT_LOSEFOCUS ) - ) - { - if( m_rPIManager.checkPrintersChanged( true ) ) - { - String aSelectEntry = m_aDevicesLB.GetSelectEntry(); - UpdateDevice(); - UpdateText(); - m_aDevicesLB.SelectEntry( aSelectEntry ); - } - } - return ModalDialog::Notify( rEv ); + if( IsVisible() && + (rEv.GetType() == EVENT_GETFOCUS || rEv.GetType() == EVENT_LOSEFOCUS ) + ) + { + if( m_rPIManager.checkPrintersChanged( true ) ) + { + String aSelectEntry = m_aDevicesLB.GetSelectEntry(); + UpdateDevice(); + UpdateText(); + m_aDevicesLB.SelectEntry( aSelectEntry ); + } + } + return ModalDialog::Notify( rEv ); } void PADialog::DataChanged( const DataChangedEvent& rEv ) { - ModalDialog::DataChanged( rEv ); - if( (rEv.GetType() == DATACHANGED_SETTINGS) && - (rEv.GetFlags() & SETTINGS_STYLE) ) - { - updateSettings(); - // push the new images into the listbox - UpdateDevice(); - } + ModalDialog::DataChanged( rEv ); + if( (rEv.GetType() == DATACHANGED_SETTINGS) && + (rEv.GetFlags() & SETTINGS_STYLE) ) + { + updateSettings(); + // push the new images into the listbox + UpdateDevice(); + } } String PADialog::getSelectedDevice() @@ -232,12 +232,12 @@ IMPL_LINK( PADialog, ClickBtnHdl, PushButton*, pButton ) FontNameDlg aDialog( this ); aDialog.Execute(); } - else if( static_cast<Button*>(pButton) == &m_aCUPSCB ) - { - m_rPIManager.setCUPSDisabled( m_aCUPSCB.IsChecked() ); - UpdateDevice(); - UpdateText(); - } + else if( static_cast<Button*>(pButton) == &m_aCUPSCB ) + { + m_rPIManager.setCUPSDisabled( m_aCUPSCB.IsChecked() ); + UpdateDevice(); + UpdateText(); + } return 0; } @@ -266,39 +266,39 @@ IMPL_LINK( PADialog, SelectHdl, ListBox*, pListBox ) void PADialog::UpdateDefPrt() { - m_rPIManager.setDefaultPrinter( getSelectedDevice() ); + m_rPIManager.setDefaultPrinter( getSelectedDevice() ); - UpdateDevice(); - UpdateText(); + UpdateDevice(); + UpdateText(); - if( m_aRemPB.HasFocus() ) - m_aDevicesLB.GetFocus(); - m_aRemPB.Enable( sal_False ); + if( m_aRemPB.HasFocus() ) + m_aDevicesLB.GetFocus(); + m_aRemPB.Enable( sal_False ); } void PADialog::UpdateText() { - OUString aDev( getSelectedDevice() ); - if( aDev.getLength() ) - { - const PrinterInfo& rInfo = m_rPIManager.getPrinterInfo( aDev ); - String aDriver( rInfo.m_aPrinterName ); - aDriver.AppendAscii( " (" ); - aDriver += String( rInfo.m_aDriverName ); - aDriver.Append( ')' ); - m_aDriver.SetText( aDriver ); - m_aCommand.SetText( rInfo.m_aCommand ); - m_aComment.SetText( rInfo.m_aComment ); - m_aLocation.SetText( rInfo.m_aLocation ); - } - else // nothing selected - { - String aEmpty; - m_aDriver.SetText( aEmpty ); - m_aCommand.SetText( aEmpty ); - m_aComment.SetText( aEmpty ); - m_aLocation.SetText( aEmpty ); - } + OUString aDev( getSelectedDevice() ); + if( aDev.getLength() ) + { + const PrinterInfo& rInfo = m_rPIManager.getPrinterInfo( aDev ); + String aDriver( rInfo.m_aPrinterName ); + aDriver.AppendAscii( " (" ); + aDriver += String( rInfo.m_aDriverName ); + aDriver.Append( ')' ); + m_aDriver.SetText( aDriver ); + m_aCommand.SetText( rInfo.m_aCommand ); + m_aComment.SetText( rInfo.m_aComment ); + m_aLocation.SetText( rInfo.m_aLocation ); + } + else // nothing selected + { + String aEmpty; + m_aDriver.SetText( aEmpty ); + m_aCommand.SetText( aEmpty ); + m_aComment.SetText( aEmpty ); + m_aLocation.SetText( aEmpty ); + } } static Point project( const Point& rPoint ) @@ -376,38 +376,38 @@ static Color approachColor( const Color& rFrom, const Color& rTo ) class SpaPrinterController : public vcl::PrinterController { public: - SpaPrinterController( const boost::shared_ptr<Printer>& i_pPrinter ) - : vcl::PrinterController( i_pPrinter ) - {} - virtual ~SpaPrinterController() - {} - - virtual int getPageCount() const { return 1; } - virtual Sequence< PropertyValue > getPageParameters( int i_nPage ) const; - virtual void printPage( int i_nPage ) const; - virtual void jobFinished( com::sun::star::view::PrintableState ); + SpaPrinterController( const boost::shared_ptr<Printer>& i_pPrinter ) + : vcl::PrinterController( i_pPrinter ) + {} + virtual ~SpaPrinterController() + {} + + virtual int getPageCount() const { return 1; } + virtual Sequence< PropertyValue > getPageParameters( int i_nPage ) const; + virtual void printPage( int i_nPage ) const; + virtual void jobFinished( com::sun::star::view::PrintableState ); }; Sequence< PropertyValue > SpaPrinterController::getPageParameters( int ) const { - Sequence< PropertyValue > aRet( 1 ); - - Size aPageSize( getPrinter()->GetPaperSizePixel() ); - aPageSize = getPrinter()->PixelToLogic( aPageSize, MapMode( MAP_100TH_MM ) ); - - awt::Size aSize; - aSize.Width = aPageSize.Width(); - aSize.Height = aPageSize.Height(); - aRet[0].Value = makeAny(aSize); - - return aRet; + Sequence< PropertyValue > aRet( 1 ); + + Size aPageSize( getPrinter()->GetPaperSizePixel() ); + aPageSize = getPrinter()->PixelToLogic( aPageSize, MapMode( MAP_100TH_MM ) ); + + awt::Size aSize; + aSize.Width = aPageSize.Width(); + aSize.Height = aPageSize.Height(); + aRet[0].Value = makeAny(aSize); + + return aRet; } void SpaPrinterController::printPage( int ) const { - const double DELTA = 5.0; - - boost::shared_ptr<Printer> pPrinter( getPrinter() ); + const double DELTA = 5.0; + + boost::shared_ptr<Printer> pPrinter( getPrinter() ); PrinterInfo aInfo( psp::PrinterInfoManager::get().getPrinterInfo( pPrinter->GetName() ) ); const PPDParser* pPrintParser = aInfo.m_pParser; @@ -418,9 +418,9 @@ void SpaPrinterController::printPage( int ) const pPrinter->SetMapMode( aMapMode ); - Any aRet = utl::ConfigManager::GetDirectConfigProperty( utl::ConfigManager::PRODUCTNAME ); - OUString aJobName; - aRet >>= aJobName; + Any aRet = utl::ConfigManager::GetDirectConfigProperty( utl::ConfigManager::PRODUCTNAME ); + OUString aJobName; + aRet >>= aJobName; aJobName = aJobName + OUString( RTL_CONSTASCII_USTRINGPARAM( " Testpage" ) ); @@ -449,49 +449,49 @@ void SpaPrinterController::printPage( int ) const long nWidth = 0, nMaxWidth = 0; String aToken; - static const struct - { - const char* const pDirect; - sal_uInt16 nResId; - } aResIds[] = - { - { NULL, RID_TXT_TESTPAGE_NAME }, - { NULL, RID_TXT_TESTPAGE_MODEL }, - { "PPD", 0 }, - { NULL, RID_TXT_TESTPAGE_QUEUE }, - { NULL, RID_TXT_TESTPAGE_COMMENT }, - { NULL, RID_TXT_TESTPAGE_DATE }, - { NULL, RID_TXT_TESTPAGE_TIME } - }; - - for( unsigned int i = 0; i < sizeof(aResIds)/sizeof(aResIds[0]); i++ ) - { - if( aResIds[i].pDirect ) - aToken = String::CreateFromAscii( aResIds[i].pDirect ); - else - aToken = String( PaResId( aResIds[i].nResId ) ); - nMaxWidth = ( nWidth = pPrinter->GetTextWidth( aToken ) ) > nMaxWidth ? nWidth : nMaxWidth; - aPrintText.append( aToken ); - aPrintText.append( (sal_Unicode)'\n' ); - }; + static const struct + { + const char* const pDirect; + sal_uInt16 nResId; + } aResIds[] = + { + { NULL, RID_TXT_TESTPAGE_NAME }, + { NULL, RID_TXT_TESTPAGE_MODEL }, + { "PPD", 0 }, + { NULL, RID_TXT_TESTPAGE_QUEUE }, + { NULL, RID_TXT_TESTPAGE_COMMENT }, + { NULL, RID_TXT_TESTPAGE_DATE }, + { NULL, RID_TXT_TESTPAGE_TIME } + }; + + for( unsigned int i = 0; i < sizeof(aResIds)/sizeof(aResIds[0]); i++ ) + { + if( aResIds[i].pDirect ) + aToken = String::CreateFromAscii( aResIds[i].pDirect ); + else + aToken = String( PaResId( aResIds[i].nResId ) ); + nMaxWidth = ( nWidth = pPrinter->GetTextWidth( aToken ) ) > nMaxWidth ? nWidth : nMaxWidth; + aPrintText.append( aToken ); + aPrintText.append( (sal_Unicode)'\n' ); + }; pPrinter->DrawText( Rectangle( Point( 1000, 1000 ), Size( aPaperSize.Width() - 2000, aPaperSize.Height() - 4000 ) ), - aPrintText.makeStringAndClear(), - TEXT_DRAW_MULTILINE ); + aPrintText.makeStringAndClear(), + TEXT_DRAW_MULTILINE ); - AllSettings aSettings( Application::GetSettings() ); - const LocaleDataWrapper& rLocaleWrapper( aSettings.GetLocaleDataWrapper() ); + AllSettings aSettings( Application::GetSettings() ); + const LocaleDataWrapper& rLocaleWrapper( aSettings.GetLocaleDataWrapper() ); aPrintText.appendAscii( ": " ); aPrintText.append( pPrinter->GetName() ); aPrintText.appendAscii( "\n: " ); - if( pPrintParser ) - aPrintText.append( pPrintParser->getPrinterName() ); + if( pPrintParser ) + aPrintText.append( pPrintParser->getPrinterName() ); aPrintText.appendAscii( "\n: " ); INetURLObject aDriverPath( pPrintParser ? pPrintParser->getFilename() : String( RTL_CONSTASCII_USTRINGPARAM( "<undef>" ) ), - INET_PROT_FILE, INetURLObject::ENCODE_ALL ); + INET_PROT_FILE, INetURLObject::ENCODE_ALL ); aPrintText.append( aDriverPath.GetName() ); aPrintText.appendAscii( "\n: " ); aPrintText.append( aInfo.m_aCommand ); @@ -598,7 +598,7 @@ void PADialog::PrintTestPage() { String sPrinter( getSelectedDevice() ); - boost::shared_ptr<Printer> pPrinter( new Printer( sPrinter ) ); + boost::shared_ptr<Printer> pPrinter( new Printer( sPrinter ) ); if( pPrinter->GetName() != sPrinter ) { @@ -611,11 +611,11 @@ void PADialog::PrintTestPage() return; } - boost::shared_ptr<vcl::PrinterController> pController( new SpaPrinterController( pPrinter ) ); - JobSetup aJobSetup( pPrinter->GetJobSetup() ); - aJobSetup.SetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ), - String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); - Printer::PrintJob( pController, aJobSetup ); + boost::shared_ptr<vcl::PrinterController> pController( new SpaPrinterController( pPrinter ) ); + JobSetup aJobSetup( pPrinter->GetJobSetup() ); + aJobSetup.SetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ), + String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); + Printer::PrintJob( pController, aJobSetup ); } void PADialog::AddDevice() @@ -685,7 +685,7 @@ void PADialog::RenameDevice() if( ! aPrinter.Len() ) return; - String aTmpString( PaResId( RID_QRY_PRTNAME ) ); + String aTmpString( PaResId( RID_QRY_PRTNAME ) ); QueryString aQuery( this, aTmpString, aPrinter ); @@ -698,7 +698,7 @@ void PADialog::RenameDevice() aInfo.m_aPrinterName = aPrinter; if( m_rPIManager.addPrinter( aPrinter, aInfo.m_aDriverName ) ) { - bool bWasDefault = m_rPIManager.getDefaultPrinter() == aOldPrinter; + bool bWasDefault = m_rPIManager.getDefaultPrinter() == aOldPrinter; m_aPrinters.push_back( aPrinter ); if( m_rPIManager.removePrinter( aOldPrinter ) ) m_aPrinters.remove( aOldPrinter ); @@ -716,31 +716,31 @@ void PADialog::RenameDevice() void PADialog::UpdateDevice() { m_aDevicesLB.Clear(); - + m_rPIManager.listPrinters( m_aPrinters ); ::std::list< OUString >::iterator it; for( it = m_aPrinters.begin(); it != m_aPrinters.end(); ++it ) { - const PrinterInfo& rInfo( m_rPIManager.getPrinterInfo( *it ) ); - sal_Int32 nIndex = 0; - bool bAutoQueue = false; - bool bFax = false; - bool bPdf = false; - while( nIndex != -1 && ! bAutoQueue ) - { - OUString aToken( rInfo.m_aFeatures.getToken( 0, ',', nIndex ) ); - if( aToken.getLength() ) - { - if( aToken.compareToAscii( "autoqueue" ) == 0 ) - bAutoQueue = true; - else if( aToken.compareToAscii( "pdf=", 4 ) == 0 ) - bPdf = true; - else if( aToken.compareToAscii( "fax", 3 ) == 0 ) - bFax = true; - } - } - if( bAutoQueue ) - continue; + const PrinterInfo& rInfo( m_rPIManager.getPrinterInfo( *it ) ); + sal_Int32 nIndex = 0; + bool bAutoQueue = false; + bool bFax = false; + bool bPdf = false; + while( nIndex != -1 && ! bAutoQueue ) + { + OUString aToken( rInfo.m_aFeatures.getToken( 0, ',', nIndex ) ); + if( aToken.getLength() ) + { + if( aToken.compareToAscii( "autoqueue" ) == 0 ) + bAutoQueue = true; + else if( aToken.compareToAscii( "pdf=", 4 ) == 0 ) + bPdf = true; + else if( aToken.compareToAscii( "fax", 3 ) == 0 ) + bFax = true; + } + } + if( bAutoQueue ) + continue; String aEntry( *it ); if( *it == m_rPIManager.getDefaultPrinter() ) @@ -750,10 +750,10 @@ void PADialog::UpdateDevice() aEntry.AppendAscii( ")" ); } int nPos = - m_aDevicesLB.InsertEntry( aEntry, - bFax ? m_aFaxImg : - bPdf ? m_aPdfImg : m_aPrinterImg - ); + m_aDevicesLB.InsertEntry( aEntry, + bFax ? m_aFaxImg : + bPdf ? m_aPdfImg : m_aPrinterImg + ); m_aDevicesLB.SetEntryData( nPos, (void*)it->getLength() ); if( *it == m_rPIManager.getDefaultPrinter() ) { @@ -763,3 +763,4 @@ void PADialog::UpdateDevice() } } +/* vim: set noet sw=4 ts=4: */