nss: upgrade to release 3.73
[LibreOffice.git] / vcl / qt5 / Qt5Instance_Print.cxx
blob3670eb67e4cdc6524ca9c16e0623477d151b9930
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <Qt5Instance.hxx>
21 #include <Qt5Printer.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/timer.hxx>
25 #include <vcl/QueueInfo.hxx>
26 #include <printerinfomanager.hxx>
28 #include <jobset.h>
29 #include <print.h>
30 #include <salptype.hxx>
31 #include <saldatabasic.hxx>
33 #include <unx/genpspgraphics.h>
35 using namespace psp;
38 * static helpers
41 static OUString getPdfDir(const PrinterInfo& rInfo)
43 OUString aDir;
44 sal_Int32 nIndex = 0;
45 while (nIndex != -1)
47 OUString aToken(rInfo.m_aFeatures.getToken(0, ',', nIndex));
48 if (aToken.startsWith("pdf="))
50 sal_Int32 nPos = 0;
51 aDir = aToken.getToken(1, '=', nPos);
52 if (aDir.isEmpty())
53 aDir = OStringToOUString(OString(getenv("HOME")), osl_getThreadTextEncoding());
54 break;
57 return aDir;
60 SalInfoPrinter* Qt5Instance::CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
61 ImplJobSetup* pJobSetup)
63 // create and initialize SalInfoPrinter
64 PspSalInfoPrinter* pPrinter = new PspSalInfoPrinter;
65 configurePspInfoPrinter(pPrinter, pQueueInfo, pJobSetup);
67 return pPrinter;
70 void Qt5Instance::DestroyInfoPrinter(SalInfoPrinter* pPrinter) { delete pPrinter; }
72 std::unique_ptr<SalPrinter> Qt5Instance::CreatePrinter(SalInfoPrinter* pInfoPrinter)
74 // create and initialize SalPrinter
75 Qt5Printer* pPrinter = new Qt5Printer(pInfoPrinter);
76 pPrinter->m_aJobData = static_cast<PspSalInfoPrinter*>(pInfoPrinter)->m_aJobData;
78 return std::unique_ptr<SalPrinter>(pPrinter);
81 void Qt5Instance::GetPrinterQueueInfo(ImplPrnQueueList* pList)
83 PrinterInfoManager& rManager(PrinterInfoManager::get());
84 static const char* pNoSyncDetection = getenv("SAL_DISABLE_SYNCHRONOUS_PRINTER_DETECTION");
85 if (!pNoSyncDetection || !*pNoSyncDetection)
87 // #i62663# synchronize possible asynchronouse printer detection now
88 rManager.checkPrintersChanged(true);
90 ::std::vector<OUString> aPrinters;
91 rManager.listPrinters(aPrinters);
93 for (const auto& rPrinter : aPrinters)
95 const PrinterInfo& rInfo(rManager.getPrinterInfo(rPrinter));
96 // create new entry
97 std::unique_ptr<SalPrinterQueueInfo> pInfo(new SalPrinterQueueInfo);
98 pInfo->maPrinterName = rPrinter;
99 pInfo->maDriver = rInfo.m_aDriverName;
100 pInfo->maLocation = rInfo.m_aLocation;
101 pInfo->maComment = rInfo.m_aComment;
103 sal_Int32 nIndex = 0;
104 while (nIndex != -1)
106 OUString aToken(rInfo.m_aFeatures.getToken(0, ',', nIndex));
107 if (aToken.startsWith("pdf="))
109 pInfo->maLocation = getPdfDir(rInfo);
110 break;
114 pList->Add(std::move(pInfo));
118 void Qt5Instance::GetPrinterQueueState(SalPrinterQueueInfo*) {}
120 OUString Qt5Instance::GetDefaultPrinter()
122 PrinterInfoManager& rManager(PrinterInfoManager::get());
123 return rManager.getDefaultPrinter();
126 void Qt5Instance::PostPrintersChanged() {}
128 std::unique_ptr<GenPspGraphics> Qt5Instance::CreatePrintGraphics()
130 return std::make_unique<GenPspGraphics>();
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */