summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-23 08:48:06 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-27 11:48:46 +0200
commit1534025a0386584a7b8f3f929b10ce5eb33257cf (patch)
tree7f12dd6763148089cd4fb5495c8fffe84f415e12 /vcl
parent0f2e01677cd0e8857faec99c61d71e88eee78b27 (diff)
loplugin:methodcycles more graph theory for the win
implemeent a reduction approach, which is good at finding virtual methods that only themselves or their virtual partners. The accessibility GetVisArea stuff is dead since commit 891e41fac81fbd8d5cdb277b26639abfd25a7143 Date: Wed Apr 4 11:23:22 2018 +0200 dead code in AccessibleTextHelper_Impl::UpdateVisibleChildren Change-Id: I78d9d8bca585ecec8394f2c3fe2baa93db0e58f5 Reviewed-on: https://gerrit.libreoffice.org/60912 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/printerinfomanager.hxx22
-rw-r--r--vcl/inc/unx/cpdmgr.hxx6
-rw-r--r--vcl/inc/unx/cupsmgr.hxx7
-rw-r--r--vcl/source/control/field.cxx7
-rw-r--r--vcl/source/control/field2.cxx6
-rw-r--r--vcl/unx/generic/printer/cpdmgr.cxx39
-rw-r--r--vcl/unx/generic/printer/cupsmgr.cxx93
-rw-r--r--vcl/unx/generic/printer/printerinfomanager.cxx267
8 files changed, 0 insertions, 447 deletions
diff --git a/vcl/inc/printerinfomanager.hxx b/vcl/inc/printerinfomanager.hxx
index dbfb14bec43e..fda53207c550 100644
--- a/vcl/inc/printerinfomanager.hxx
+++ b/vcl/inc/printerinfomanager.hxx
@@ -153,28 +153,6 @@ public:
// printer discovery to finish
virtual bool checkPrintersChanged( bool bWait );
- // members for administration
-
- // add a named printer
- // addPrinter fails if a printer with the same name already exists
- // or the driver does not exist
- virtual bool addPrinter( const OUString& rPrinterName, const OUString& rDriverName );
-
- // remove a named printer
- // this fails if the config file belonging to this printer
- // is not writeable
- // if bCheckOnly is true, the printer is not really removed;
- // this is for checking if the removal would fail
- virtual bool removePrinter( const OUString& rPrinterName, bool bCheckOnly );
-
- // save the changes to all printers. this fails if there
- // is no writable config file at all
- virtual bool writePrinterConfig();
-
- // set a new default printer
- // fails if the specified printer does not exist
- virtual bool setDefaultPrinter( const OUString& rPrinterName );
-
// abstract print command
// returns a stdio FILE* that a postscript file may be written to
// this may either be a regular file or the result of popen()
diff --git a/vcl/inc/unx/cpdmgr.hxx b/vcl/inc/unx/cpdmgr.hxx
index a9caaead9942..8e15cb0ba27b 100644
--- a/vcl/inc/unx/cpdmgr.hxx
+++ b/vcl/inc/unx/cpdmgr.hxx
@@ -116,12 +116,6 @@ public:
// check if the printer configuration has changed
virtual bool checkPrintersChanged( bool bWait ) override;
-
- // members for administration
- // disable for CPD
- virtual bool addPrinter( const OUString& rPrinterName, const OUString& rDriverName ) override;
- virtual bool removePrinter( const OUString& rPrinterName, bool bCheckOnly ) override;
- virtual bool setDefaultPrinter( const OUString& rPrinterName ) override;
};
} // namespace psp
diff --git a/vcl/inc/unx/cupsmgr.hxx b/vcl/inc/unx/cupsmgr.hxx
index 46076c09fa70..2283880c0b2d 100644
--- a/vcl/inc/unx/cupsmgr.hxx
+++ b/vcl/inc/unx/cupsmgr.hxx
@@ -82,13 +82,6 @@ public:
/// check if the printer configuration has changed
virtual bool checkPrintersChanged( bool bWait ) override;
-
- // members for administration
- // disable for CUPS
- virtual bool addPrinter( const OUString& rPrinterName, const OUString& rDriverName ) override;
- virtual bool removePrinter( const OUString& rPrinterName, bool bCheckOnly ) override;
- virtual bool writePrinterConfig() override;
- virtual bool setDefaultPrinter( const OUString& rPrinterName ) override;
};
} // namespace psp
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index d287257b9436..e724730dff99 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -408,13 +408,6 @@ void FormatterBase::SetStrictFormat( bool bStrict )
}
}
-void FormatterBase::SetLocale( const lang::Locale& rLocale )
-{
- ImplGetLocaleDataWrapper().setLanguageTag( LanguageTag( rLocale) );
- mbDefaultLocale = false;
- ReformatAll();
-}
-
const lang::Locale& FormatterBase::GetLocale() const
{
if ( !mpLocaleDataWrapper || mbDefaultLocale )
diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx
index 62f1b5bb8278..912b104eb56e 100644
--- a/vcl/source/control/field2.cxx
+++ b/vcl/source/control/field2.cxx
@@ -1423,12 +1423,6 @@ DateFormatter::~DateFormatter()
{
}
-void DateFormatter::SetLocale( const css::lang::Locale& rLocale )
-{
- mpCalendarWrapper.reset();
- FormatterBase::SetLocale( rLocale );
-}
-
CalendarWrapper& DateFormatter::GetCalendarWrapper() const
{
if ( !mpCalendarWrapper )
diff --git a/vcl/unx/generic/printer/cpdmgr.cxx b/vcl/unx/generic/printer/cpdmgr.cxx
index 356f943b62dc..f46987e28ec1 100644
--- a/vcl/unx/generic/printer/cpdmgr.cxx
+++ b/vcl/unx/generic/printer/cpdmgr.cxx
@@ -754,44 +754,5 @@ bool CPDManager::checkPrintersChanged( bool )
#endif
}
-bool CPDManager::addPrinter( const OUString& rName, const OUString& rDriver )
-{
-#if ENABLE_DBUS && ENABLE_GIO
- // don't touch the CPD printers
- if (m_aCPDDestMap.find( rName ) != m_aCPDDestMap.end() || rDriver.startsWith("CPD:"))
- return false;
-#endif
- return PrinterInfoManager::addPrinter( rName, rDriver );
-}
-
-bool CPDManager::removePrinter( const OUString& rName, bool bCheck )
-{
-#if ENABLE_DBUS && ENABLE_GIO
- // don't touch the CPD printers
- if( m_aCPDDestMap.find( rName ) != m_aCPDDestMap.end() )
- return false;
-#endif
- return PrinterInfoManager::removePrinter( rName, bCheck );
-}
-
-bool CPDManager::setDefaultPrinter( const OUString& rName )
-{
- bool bSuccess = false;
-#if ENABLE_DBUS && ENABLE_GIO
- std::unordered_map< OUString, CPDPrinter * >::iterator nit =
- m_aCPDDestMap.find( rName );
- if( nit != m_aCPDDestMap.end())
- {
- m_aDefaultPrinter = rName;
- bSuccess = true;
- }
- else
- bSuccess = PrinterInfoManager::setDefaultPrinter( rName );
-#else
- (void)rName;
-#endif
- return bSuccess;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/printer/cupsmgr.cxx b/vcl/unx/generic/printer/cupsmgr.cxx
index 4434ee0af464..2c791e426929 100644
--- a/vcl/unx/generic/printer/cupsmgr.cxx
+++ b/vcl/unx/generic/printer/cupsmgr.cxx
@@ -732,99 +732,6 @@ bool CUPSManager::checkPrintersChanged( bool bWait )
return bChanged;
}
-bool CUPSManager::addPrinter( const OUString& rName, const OUString& rDriver )
-{
- // don't touch the CUPS printers
- if( m_aCUPSDestMap.find( rName ) != m_aCUPSDestMap.end() ||
- rDriver.startsWith("CUPS:")
- )
- return false;
- return PrinterInfoManager::addPrinter( rName, rDriver );
-}
-
-bool CUPSManager::removePrinter( const OUString& rName, bool bCheck )
-{
- // don't touch the CUPS printers
- if( m_aCUPSDestMap.find( rName ) != m_aCUPSDestMap.end() )
- return false;
- return PrinterInfoManager::removePrinter( rName, bCheck );
-}
-
-bool CUPSManager::setDefaultPrinter( const OUString& rName )
-{
- bool bSuccess = false;
- std::unordered_map< OUString, int >::iterator nit =
- m_aCUPSDestMap.find( rName );
- if( nit != m_aCUPSDestMap.end() && m_aCUPSMutex.tryToAcquire() )
- {
- cups_dest_t* pDests = static_cast<cups_dest_t*>(m_pDests);
- for( int i = 0; i < m_nDests; i++ )
- pDests[i].is_default = 0;
- pDests[ nit->second ].is_default = 1;
- cupsSetDests( m_nDests, static_cast<cups_dest_t*>(m_pDests) );
- m_aDefaultPrinter = rName;
- m_aCUPSMutex.release();
- bSuccess = true;
- }
- else
- bSuccess = PrinterInfoManager::setDefaultPrinter( rName );
-
- return bSuccess;
-}
-
-bool CUPSManager::writePrinterConfig()
-{
- bool bDestModified = false;
- rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
-
- for( std::unordered_map< OUString, Printer >::iterator prt =
- m_aPrinters.begin(); prt != m_aPrinters.end(); ++prt )
- {
- std::unordered_map< OUString, int >::iterator nit =
- m_aCUPSDestMap.find( prt->first );
- if( nit == m_aCUPSDestMap.end() )
- continue;
-
- if( ! prt->second.m_bModified )
- continue;
-
- if( m_aCUPSMutex.tryToAcquire() )
- {
- bDestModified = true;
- cups_dest_t* pDest = static_cast<cups_dest_t*>(m_pDests) + nit->second;
- PrinterInfo& rInfo = prt->second.m_aInfo;
-
- // create new option list
- int nNewOptions = 0;
- cups_option_t* pNewOptions = nullptr;
- int nValues = rInfo.m_aContext.countValuesModified();
- for( int i = 0; i < nValues; i++ )
- {
- const PPDKey* pKey = rInfo.m_aContext.getModifiedKey( i );
- const PPDValue* pValue = rInfo.m_aContext.getValue( pKey );
- if( pKey && pValue ) // sanity check
- {
- OString aName = OUStringToOString( pKey->getKey(), aEncoding );
- OString aValue = OUStringToOString( pValue->m_aOption, aEncoding );
- nNewOptions = cupsAddOption( aName.getStr(), aValue.getStr(), nNewOptions, &pNewOptions );
- }
- }
- // set PPD options on CUPS dest
- cupsFreeOptions( pDest->num_options, pDest->options );
- pDest->num_options = nNewOptions;
- pDest->options = pNewOptions;
- m_aCUPSMutex.release();
- }
- }
- if( bDestModified && m_aCUPSMutex.tryToAcquire() )
- {
- cupsSetDests( m_nDests, static_cast<cups_dest_t*>(m_pDests) );
- m_aCUPSMutex.release();
- }
-
- return PrinterInfoManager::writePrinterConfig();
-}
-
namespace
{
class RTSPWDialog : public weld::GenericDialogController
diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx
index 8ac756342f37..8ca49d1d3ff2 100644
--- a/vcl/unx/generic/printer/printerinfomanager.cxx
+++ b/vcl/unx/generic/printer/printerinfomanager.cxx
@@ -558,273 +558,6 @@ const PrinterInfo& PrinterInfoManager::getPrinterInfo( const OUString& rPrinter
return it != m_aPrinters.end() ? it->second.m_aInfo : aEmptyInfo;
}
-// need to check writeability / creatability of config files
-static bool checkWriteability( const OUString& rUniPath )
-{
- bool bRet = false;
- OUString aSysPath;
- FileBase::getSystemPathFromFileURL( rUniPath, aSysPath );
- SvFileStream aStream( aSysPath, StreamMode::READ | StreamMode::WRITE );
- if( aStream.IsOpen() && aStream.IsWritable() )
- bRet = true;
- return bRet;
-}
-
-bool PrinterInfoManager::writePrinterConfig()
-{
- // find at least one writeable config
- std::unordered_map< OUString, std::unique_ptr<Config> > files;
- std::unordered_map< OUString, int > rofiles;
- std::unordered_map< OUString, std::unique_ptr<Config> >::iterator file_it;
-
- for (auto const& watchFile : m_aWatchFiles)
- {
- if( checkWriteability( watchFile.m_aFilePath ) )
- {
- files[ watchFile.m_aFilePath ].reset(new Config( watchFile.m_aFilePath ));
- break;
- }
- }
-
- if( files.empty() )
- return false;
-
- Config* pGlobal = files.begin()->second.get();
- pGlobal->SetGroup( GLOBAL_DEFAULTS_GROUP );
-
- for (auto & printer : m_aPrinters)
- {
- if( ! printer.second.m_bModified )
- // printer was not changed, do nothing
- continue;
-
- // don't save autoqueue printers
- sal_Int32 nIndex = 0;
- bool bAutoQueue = false;
- while( nIndex != -1 && ! bAutoQueue )
- {
- OUString aToken( printer.second.m_aInfo.m_aFeatures.getToken( 0, ',', nIndex ) );
- if( aToken == "autoqueue" )
- bAutoQueue = true;
- }
- if( bAutoQueue )
- continue;
-
- if( !printer.second.m_aFile.isEmpty() )
- {
- // check if file is writable
- if( files.find( printer.second.m_aFile ) == files.end() )
- {
- bool bInsertToNewFile = false;
- // maybe it is simply not inserted yet
- if( rofiles.find( printer.second.m_aFile ) == rofiles.end() )
- {
- if( checkWriteability( printer.second.m_aFile ) )
- files[ printer.second.m_aFile ].reset( new Config( printer.second.m_aFile ) );
- else
- bInsertToNewFile = true;
- }
- else
- bInsertToNewFile = true;
- // original file is read only, insert printer in a new writeable file
- if( bInsertToNewFile )
- {
- rofiles[ printer.second.m_aFile ] = 1;
- // update alternate file list
- // be sure m_aAlternateFiles doesn't contain the m_aFile value
- printer.second.m_aAlternateFiles.erase( files.begin()->first );
- printer.second.m_aAlternateFiles.insert( printer.second.m_aFile );
- // update file
- printer.second.m_aFile = files.begin()->first;
- }
- }
- }
- else // a new printer, write it to the first file available
- printer.second.m_aFile = files.begin()->first;
-
- if( printer.second.m_aGroup.isEmpty() ) // probably a new printer
- printer.second.m_aGroup = OString( printer.first.getStr(), printer.first.getLength(), RTL_TEXTENCODING_UTF8 );
-
- if( files.find( printer.second.m_aFile ) != files.end() )
- {
- Config* pConfig = files[ printer.second.m_aFile ].get();
- pConfig->DeleteGroup( printer.second.m_aGroup ); // else some old keys may remain
- pConfig->SetGroup( printer.second.m_aGroup );
-
- OStringBuffer aValue(OUStringToOString(printer.second.m_aInfo.m_aDriverName, RTL_TEXTENCODING_UTF8));
- aValue.append('/');
- aValue.append(OUStringToOString(printer.first, RTL_TEXTENCODING_UTF8));
- pConfig->WriteKey("Printer", aValue.makeStringAndClear());
- pConfig->WriteKey( "DefaultPrinter", printer.first == m_aDefaultPrinter ? "1" : "0" );
- pConfig->WriteKey( "Location", OUStringToOString(printer.second.m_aInfo.m_aLocation, RTL_TEXTENCODING_UTF8) );
- pConfig->WriteKey( "Comment", OUStringToOString(printer.second.m_aInfo.m_aComment, RTL_TEXTENCODING_UTF8) );
- pConfig->WriteKey( "Command", OUStringToOString(printer.second.m_aInfo.m_aCommand, RTL_TEXTENCODING_UTF8) );
- pConfig->WriteKey( "QuickCommand", OUStringToOString(printer.second.m_aInfo.m_aQuickCommand, RTL_TEXTENCODING_UTF8) );
- pConfig->WriteKey( "Features", OUStringToOString(printer.second.m_aInfo.m_aFeatures, RTL_TEXTENCODING_UTF8) );
- pConfig->WriteKey("Copies", OString::number(printer.second.m_aInfo.m_nCopies));
- pConfig->WriteKey( "Orientation", printer.second.m_aInfo.m_eOrientation == orientation::Landscape ? "Landscape" : "Portrait" );
- pConfig->WriteKey("PSLevel", OString::number(printer.second.m_aInfo.m_nPSLevel));
- pConfig->WriteKey("PDFDevice", OString::number(printer.second.m_aInfo.m_nPDFDevice));
- pConfig->WriteKey("ColorDevice", OString::number(printer.second.m_aInfo.m_nColorDevice));
- pConfig->WriteKey("ColorDepth", OString::number(printer.second.m_aInfo.m_nColorDepth));
- aValue.append(static_cast<sal_Int32>(printer.second.m_aInfo.m_nLeftMarginAdjust));
- aValue.append(',');
- aValue.append(static_cast<sal_Int32>(printer.second.m_aInfo.m_nRightMarginAdjust));
- aValue.append(',');
- aValue.append(static_cast<sal_Int32>(printer.second.m_aInfo.m_nTopMarginAdjust));
- aValue.append(',');
- aValue.append(static_cast<sal_Int32>(printer.second.m_aInfo.m_nBottomMarginAdjust));
- pConfig->WriteKey("MarginAdjust", aValue.makeStringAndClear());
-
- if( ! printer.second.m_aInfo.m_aDriverName.startsWith( "CUPS:" ) )
- {
- // write PPDContext (not for CUPS)
- for( int i = 0; i < printer.second.m_aInfo.m_aContext.countValuesModified(); i++ )
- {
- const PPDKey* pKey = printer.second.m_aInfo.m_aContext.getModifiedKey( i );
- OStringBuffer aKey("PPD_");
- aKey.append(OUStringToOString(pKey->getKey(), RTL_TEXTENCODING_ISO_8859_1));
-
- const PPDValue* pValue = printer.second.m_aInfo.m_aContext.getValue( pKey );
- if (pValue)
- aValue.append(OUStringToOString(pValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1));
- else
- aValue.append("*nil");
- pConfig->WriteKey(aKey.makeStringAndClear(), aValue.makeStringAndClear());
- }
- }
- }
- }
-
- // get rid of Config objects. this also writes any changes
- files.clear();
-
- return true;
-}
-
-bool PrinterInfoManager::addPrinter( const OUString& rPrinterName, const OUString& rDriverName )
-{
- bool bSuccess = false;
-
- const PPDParser* pParser = nullptr;
- if( m_aPrinters.find( rPrinterName ) == m_aPrinters.end() && ( pParser = PPDParser::getParser( rDriverName ) ) )
- {
- Printer aPrinter;
- aPrinter.m_bModified = true;
- aPrinter.m_aInfo = m_aGlobalDefaults;
- aPrinter.m_aInfo.m_aDriverName = rDriverName;
- aPrinter.m_aInfo.m_pParser = pParser;
- aPrinter.m_aInfo.m_aContext.setParser( pParser );
- aPrinter.m_aInfo.m_aPrinterName = rPrinterName;
-
- // merge PPD values with global defaults
- for( int nPPDValueModified = 0; nPPDValueModified < m_aGlobalDefaults.m_aContext.countValuesModified(); nPPDValueModified++ )
- {
- const PPDKey* pDefKey = m_aGlobalDefaults.m_aContext.getModifiedKey( nPPDValueModified );
- const PPDValue* pDefValue = m_aGlobalDefaults.m_aContext.getValue( pDefKey );
- const PPDKey* pPrinterKey = pDefKey ? aPrinter.m_aInfo.m_pParser->getKey( pDefKey->getKey() ) : nullptr;
- if( pDefKey && pPrinterKey )
- // at least the options exist in both PPDs
- {
- if( pDefValue )
- {
- const PPDValue* pPrinterValue = pPrinterKey->getValue( pDefValue->m_aOption );
- if( pPrinterValue )
- // the printer has a corresponding option for the key
- aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, pPrinterValue );
- }
- else
- aPrinter.m_aInfo.m_aContext.setValue( pPrinterKey, nullptr );
- }
- }
-
- m_aPrinters[ rPrinterName ] = aPrinter;
- bSuccess = true;
- #if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "new printer %s, level = %d, pdfdevice = %d, colordevice = %d, depth = %d\n",
- OUStringToOString( rPrinterName, osl_getThreadTextEncoding() ).getStr(),
- m_aPrinters[rPrinterName].m_aInfo.m_nPSLevel,
- m_aPrinters[rPrinterName].m_aInfo.m_nPDFDevice,
- m_aPrinters[rPrinterName].m_aInfo.m_nColorDevice,
- m_aPrinters[rPrinterName].m_aInfo.m_nColorDepth );
- #endif
- // comment: logically one should writePrinterConfig() here
- // but immediately after addPrinter() a changePrinterInfo()
- // will follow which writes it again, so we can currently save some
- // performance here
- }
- return bSuccess;
-}
-
-bool PrinterInfoManager::removePrinter( const OUString& rPrinterName, bool bCheckOnly )
-{
- bool bSuccess = true;
-
- std::unordered_map< OUString, Printer >::iterator it = m_aPrinters.find( rPrinterName );
- if( it != m_aPrinters.end() )
- {
- if( !it->second.m_aFile.isEmpty() )
- {
- // this printer already exists in a config file
-
- // check writeability of config file(s)
- if( ! checkWriteability( it->second.m_aFile ) )
- bSuccess = false;
- else
- {
- for (auto const& file : it->second.m_aAlternateFiles)
- {
- if( ! checkWriteability(file) )
- {
- bSuccess = false;
- break;
- }
- }
- }
- if( bSuccess && ! bCheckOnly )
- {
-
- Config aConfig( it->second.m_aFile );
- aConfig.DeleteGroup( it->second.m_aGroup );
- aConfig.Flush();
- for (auto const& file : it->second.m_aAlternateFiles)
- {
- Config aAltConfig( file );
- aAltConfig.DeleteGroup( it->second.m_aGroup );
- aAltConfig.Flush();
- }
- }
- }
- if( bSuccess && ! bCheckOnly )
- {
- m_aPrinters.erase( it );
- // need this here because someone may call
- // checkPrintersChanged after the removal
- // but then other added printers were not flushed
- // to disk, so they are discarded
- writePrinterConfig();
- }
- }
- return bSuccess;
-}
-
-bool PrinterInfoManager::setDefaultPrinter( const OUString& rPrinterName )
-{
- bool bSuccess = false;
-
- std::unordered_map< OUString, Printer >::iterator it = m_aPrinters.find( rPrinterName );
- if( it != m_aPrinters.end() )
- {
- bSuccess = true;
- it->second.m_bModified = true;
- if( ( it = m_aPrinters.find( m_aDefaultPrinter ) ) != m_aPrinters.end() )
- it->second.m_bModified = true;
- m_aDefaultPrinter = rPrinterName;
- writePrinterConfig();
- }
- return bSuccess;
-}
-
bool PrinterInfoManager::checkFeatureToken( const OUString& rPrinterName, const char* pToken ) const
{
const PrinterInfo& rPrinterInfo( getPrinterInfo( rPrinterName ) );