vcl/inc/qt5/QtInstance.hxx | 5 --- vcl/qt5/QtInstance_Print.cxx | 62 ------------------------------------------- 2 files changed, 67 deletions(-)
New commits: commit 2c869a9c33f65f76a3927ebfdd94237da367efbc Author: Michael Weghorn <[email protected]> AuthorDate: Wed Mar 11 03:57:13 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Thu Mar 12 07:44:53 2026 +0100 qt: Deduplicate print-related code with SalGenericInstance Drop various overrides of print-related SalGenericInstance methods. The implementation is the same, except that the base class implementations in SalGenericInstance all also have mbPrinterInit = true; at the beginning of each of these methods in addition. Apart from gtk3/gtk4-specific code, the only place where SalGenericInstance::isPrinterInit() is called to evaluate this SalGenericInstance::mbPrinterInit is in SalGenericInstance::updatePrinterUpdate. That in turn however only gets called from X11SalFrame::HandleFocusEvent or gtk3/gtk4-specific code again, i.e. only from code specific to the gen or gtk3/gtk4 vcl plugins. Therefore, whatever the reason was to override these methods in QtInstance to not set SalGenericInstance::mbPrinterInit, it should be unnecessary, as not doing so should not result in any change in behavior. Drop the overrides to reduce code duplication. Change-Id: I507e2fd102e929326aaea2cbf59ab36479c6630d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201420 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/inc/qt5/QtInstance.hxx b/vcl/inc/qt5/QtInstance.hxx index 2013b546ac7c..af1dccb22060 100644 --- a/vcl/inc/qt5/QtInstance.hxx +++ b/vcl/inc/qt5/QtInstance.hxx @@ -157,11 +157,6 @@ public: CreateVirtualDevice(SalGraphics& rGraphics, tools::Long& nDX, tools::Long& nDY, DeviceFormat eFormat, const SystemGraphicsData& rData) override; - virtual SalInfoPrinter* CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo, - ImplJobSetup* pSetupData) override; - virtual std::unique_ptr<SalPrinter> CreatePrinter(SalInfoPrinter* pInfoPrinter) override; - virtual void GetPrinterQueueInfo(ImplPrnQueueList* pList) override; - virtual OUString GetDefaultPrinter() override; virtual void PostPrintersChanged() override; virtual std::unique_ptr<SalMenu> CreateMenu(bool, Menu*) override; diff --git a/vcl/qt5/QtInstance_Print.cxx b/vcl/qt5/QtInstance_Print.cxx index 0728c9fcf91b..118e71bf7c78 100644 --- a/vcl/qt5/QtInstance_Print.cxx +++ b/vcl/qt5/QtInstance_Print.cxx @@ -19,72 +19,10 @@ #include <sal/config.h> -#include <string_view> - #include <QtInstance.hxx> -#include <printerinfomanager.hxx> - -#include <print.h> - -#include <unx/genpspgraphics.h> - using namespace psp; -SalInfoPrinter* QtInstance::CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo, - ImplJobSetup* pJobSetup) -{ - // create and initialize SalInfoPrinter - PspSalInfoPrinter* pPrinter = new PspSalInfoPrinter; - configurePspInfoPrinter(pPrinter, pQueueInfo, pJobSetup); - - return pPrinter; -} - -std::unique_ptr<SalPrinter> QtInstance::CreatePrinter(SalInfoPrinter* pInfoPrinter) -{ - // create and initialize SalPrinter - PspSalPrinter* pPrinter = new PspSalPrinter(pInfoPrinter); - pPrinter->m_aJobData = static_cast<PspSalInfoPrinter*>(pInfoPrinter)->m_aJobData; - - return std::unique_ptr<SalPrinter>(pPrinter); -} - -void QtInstance::GetPrinterQueueInfo(ImplPrnQueueList* pList) -{ - PrinterInfoManager& rManager(PrinterInfoManager::get()); - static const char* pNoSyncDetection = getenv("SAL_DISABLE_SYNCHRONOUS_PRINTER_DETECTION"); - if (!pNoSyncDetection || !*pNoSyncDetection) - { - // #i62663# synchronize possible asynchronouse printer detection now - rManager.checkPrintersChanged(true); - } - - std::vector<OUString> aPrinters = rManager.listPrinters(); - for (const auto& rPrinter : aPrinters) - { - const PrinterInfo& rInfo(rManager.getPrinterInfo(rPrinter)); - // create new entry - std::unique_ptr<SalPrinterQueueInfo> pInfo(new SalPrinterQueueInfo); - pInfo->maPrinterName = rPrinter; - pInfo->maDriver = rInfo.m_aDriverName; - pInfo->maLocation = rInfo.m_aLocation; - pInfo->maComment = rInfo.m_aComment; - - OUString sPdfDir; - if (getPdfDir(rInfo, sPdfDir)) - pInfo->maLocation = sPdfDir; - - pList->Add(std::move(pInfo)); - } -} - -OUString QtInstance::GetDefaultPrinter() -{ - PrinterInfoManager& rManager(PrinterInfoManager::get()); - return rManager.getDefaultPrinter(); -} - void QtInstance::PostPrintersChanged() {} /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
