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 <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn 2024-08-26 13:30:58 +02:00
parent d80363beb1
commit c5cad121e5
5 changed files with 20 additions and 10 deletions

View file

@ -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 \

View file

@ -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: */

View file

@ -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])

View file

@ -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 \

View file

@ -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;