RepositoryExternal.mk | 3 -- config_host/config_cups.h.in | 14 ++++++++++++ configure.ac | 2 + sfx2/Library_sfx.mk | 4 --- vcl/unx/generic/print/genprnpsp.cxx | 39 +++++----------------------------- vcl/unx/generic/printer/ppdparser.cxx | 7 +++--- 6 files changed, 26 insertions(+), 43 deletions(-)
New commits: commit ee472dcaedccad37de0ff326d6c79bdd9bbc9e52 Author: Michael Weghorn <[email protected]> AuthorDate: Mon Aug 26 14:18:46 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Aug 27 07:30:14 2024 +0200 vcl: Drop logically dead "PrinterUpdate::nActiveJobs > 0" code `PrinterUpdate::nActiveJobs` is initialized to 0 and never increased, so cod paths for it being >= 0 are logically dead. Therefore, drop them and `PrinterUpdate::nActiveJobs` altogether. Also drop the now unused `UpdateTimerHdl`. `PrinterUpdate::jobStarted` that would have increased `PrinterUpdate::nActiveJobs` was dropped in commit 3564e11a41c8d3f06c8be387691d5997942e9738 Date: Sun Jul 30 23:20:36 2023 +0200 tdf#156230 remove now unused various bit and pieces Change-Id: I431171094d4981552f641af89940d877147ffa71 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172398 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx index 9c00c6240206..c2beec916b56 100644 --- a/vcl/unx/generic/print/genprnpsp.cxx +++ b/vcl/unx/generic/print/genprnpsp.cxx @@ -1023,10 +1023,8 @@ namespace { class PrinterUpdate { static Idle* pPrinterUpdateIdle; - static int nActiveJobs; static void doUpdate(); - DECL_STATIC_LINK( PrinterUpdate, UpdateTimerHdl, Timer*, void ); public: static void update(SalGenericInstance const &rInstance); static void jobEnded(); @@ -1035,7 +1033,6 @@ public: } Idle* PrinterUpdate::pPrinterUpdateIdle = nullptr; -int PrinterUpdate::nActiveJobs = 0; void PrinterUpdate::doUpdate() { @@ -1045,18 +1042,6 @@ void PrinterUpdate::doUpdate() pInst->PostPrintersChanged(); } -IMPL_STATIC_LINK_NOARG( PrinterUpdate, UpdateTimerHdl, Timer*, void ) -{ - if( nActiveJobs < 1 ) - { - doUpdate(); - delete pPrinterUpdateIdle; - pPrinterUpdateIdle = nullptr; - } - else - pPrinterUpdateIdle->Start(); -} - void PrinterUpdate::update(SalGenericInstance const &rInstance) { if( Application::GetSettings().GetMiscSettings().GetDisablePrinting() ) @@ -1069,15 +1054,7 @@ void PrinterUpdate::update(SalGenericInstance const &rInstance) return; } - if( nActiveJobs < 1 ) - doUpdate(); - else if( ! pPrinterUpdateIdle ) - { - pPrinterUpdateIdle = new Idle("PrinterUpdateTimer"); - pPrinterUpdateIdle->SetPriority( TaskPriority::LOWEST ); - pPrinterUpdateIdle->SetInvokeHandler( LINK( nullptr, PrinterUpdate, UpdateTimerHdl ) ); - pPrinterUpdateIdle->Start(); - } + doUpdate(); } void SalGenericInstance::updatePrinterUpdate() @@ -1087,16 +1064,12 @@ void SalGenericInstance::updatePrinterUpdate() void PrinterUpdate::jobEnded() { - nActiveJobs--; - if( nActiveJobs < 1 ) + if( pPrinterUpdateIdle ) { - if( pPrinterUpdateIdle ) - { - pPrinterUpdateIdle->Stop(); - delete pPrinterUpdateIdle; - pPrinterUpdateIdle = nullptr; - doUpdate(); - } + pPrinterUpdateIdle->Stop(); + delete pPrinterUpdateIdle; + pPrinterUpdateIdle = nullptr; + doUpdate(); } } commit c5cad121e5b68c2209fee2aa4611b1b609e2d4cf Author: Michael Weghorn <[email protected]> AuthorDate: Mon Aug 26 13:30:58 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Aug 27 07:30:03 2024 +0200 Add a CUPS config header In line with what's done for most optional, build-time configurable features, use a config header `config_cups.h` that has a `ENABLE_CUPS` define, include that header in the relevant source file and use #if ENABLE_CUPS for code depending on CUPS being enabled instead of defining a macro and using #ifdef ENABLE_CUPS This also aligns this with the `ENABLE_CPDB` macro used in the same source file. Change-Id: I71a5205fd63f9fc18470afcaf808c489ff833319 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172397 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index 1b2f147df595..2d35152eb0b8 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -2594,9 +2594,6 @@ endif # ENABLE_CPDB ifeq ($(ENABLE_CUPS),TRUE) define gb_LinkTarget__use_cups -$(call gb_LinkTarget_add_defs,$(1),\ - -DENABLE_CUPS \ -) $(call gb_LinkTarget_add_libs,$(1),\ -lcups \ diff --git a/config_host/config_cups.h.in b/config_host/config_cups.h.in new file mode 100644 index 000000000000..5dd46d67ba49 --- /dev/null +++ b/config_host/config_cups.h.in @@ -0,0 +1,14 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#define ENABLE_CUPS 0 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/configure.ac b/configure.ac index 98ec7071cba1..f441745f0b4b 100644 --- a/configure.ac +++ b/configure.ac @@ -6421,6 +6421,7 @@ if test "$test_cups" = yes -a "$enable_cups" != no; then if test "$ac_cv_lib_cups_cupsPrintFiles" != "yes" -o "$ac_cv_header_cups_cups_h" != "yes"; then AC_MSG_ERROR([Could not find CUPS. Install libcups2-dev or cups-devel.]) fi + AC_DEFINE([ENABLE_CUPS],[1]) else AC_MSG_RESULT([no]) fi @@ -15722,6 +15723,7 @@ AC_CONFIG_HEADERS([config_host/config_box2d.h]) AC_CONFIG_HEADERS([config_host/config_clang.h]) AC_CONFIG_HEADERS([config_host/config_cpdb.h]) AC_CONFIG_HEADERS([config_host/config_crypto.h]) +AC_CONFIG_HEADERS([config_host/config_cups.h]) AC_CONFIG_HEADERS([config_host/config_dconf.h]) AC_CONFIG_HEADERS([config_host/config_eot.h]) AC_CONFIG_HEADERS([config_host/config_extensions.h]) diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index cda747e3d9b0..db88eaa72b40 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -44,10 +44,6 @@ $(eval $(call gb_Library_set_include,sfx,\ $(eval $(call gb_Library_add_defs,sfx,-DSFX2_DLLIMPLEMENTATION)) -$(eval $(call gb_Library_add_defs,sfx,\ - $(if $(filter TRUE,$(ENABLE_CUPS)),-DENABLE_CUPS) \ -)) - $(eval $(call gb_Library_use_libraries,sfx,\ basegfx \ comphelper \ diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index 40ba184603da..cc16c4f563bb 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -19,6 +19,7 @@ #include <sal/config.h> #include <config_cpdb.h> +#include <config_cups.h> #include <stdlib.h> @@ -55,7 +56,7 @@ #include <mutex> #include <unordered_map> -#ifdef ENABLE_CUPS +#if ENABLE_CUPS #include <cups/cups.h> #endif @@ -568,7 +569,7 @@ const PPDParser* PPDParser::getParser( const OUString& rFile ) PrinterInfoManager& rMgr = PrinterInfoManager::get(); if( rMgr.getType() == PrinterInfoManager::Type::CUPS ) { -#ifdef ENABLE_CUPS +#if ENABLE_CUPS pNewParser = const_cast<PPDParser*>(static_cast<CUPSManager&>(rMgr).createCUPSParser( aFile )); #endif } else if ( rMgr.getType() == PrinterInfoManager::Type::CPD ) @@ -617,7 +618,7 @@ PPDParser::PPDParser(OUString aFile, const std::vector<PPDKey*>& keys) if ( pKey ) { std::unique_ptr<PPDKey> pImageableAreas(new PPDKey(u"ImageableArea"_ustr)); std::unique_ptr<PPDKey> pPaperDimensions(new PPDKey(u"PaperDimension"_ustr)); -#ifdef ENABLE_CUPS +#if ENABLE_CUPS for (int i = 0; i < pKey->countValues(); i++) { const PPDValue* pValue = pKey -> getValue(i); OUString aValueName = pValue -> m_aOption;
