bump product version to 6.4.0.3
[LibreOffice.git] / vcl / qt5 / Qt5Instance_Print.cxx
blobcab5757a31f4e51d2f56286516a20f082255909f
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 <printerinfomanager.hxx>
27 #include <jobset.h>
28 #include <print.h>
29 #include <salptype.hxx>
30 #include <saldatabasic.hxx>
32 #include <unx/genpspgraphics.h>
34 using namespace psp;
37 * static helpers
40 static OUString getPdfDir(const PrinterInfo& rInfo)
42 OUString aDir;
43 sal_Int32 nIndex = 0;
44 while (nIndex != -1)
46 OUString aToken(rInfo.m_aFeatures.getToken(0, ',', nIndex));
47 if (aToken.startsWith("pdf="))
49 sal_Int32 nPos = 0;
50 aDir = aToken.getToken(1, '=', nPos);
51 if (aDir.isEmpty())
52 aDir = OStringToOUString(OString(getenv("HOME")), osl_getThreadTextEncoding());
53 break;
56 return aDir;
59 SalInfoPrinter* Qt5Instance::CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
60 ImplJobSetup* pJobSetup)
62 // create and initialize SalInfoPrinter
63 PspSalInfoPrinter* pPrinter = new PspSalInfoPrinter;
64 configurePspInfoPrinter(pPrinter, pQueueInfo, pJobSetup);
66 return pPrinter;
69 void Qt5Instance::DestroyInfoPrinter(SalInfoPrinter* pPrinter) { delete pPrinter; }
71 std::unique_ptr<SalPrinter> Qt5Instance::CreatePrinter(SalInfoPrinter* pInfoPrinter)
73 // create and initialize SalPrinter
74 Qt5Printer* pPrinter = new Qt5Printer(pInfoPrinter);
75 pPrinter->m_aJobData = static_cast<PspSalInfoPrinter*>(pInfoPrinter)->m_aJobData;
77 return std::unique_ptr<SalPrinter>(pPrinter);
80 void Qt5Instance::GetPrinterQueueInfo(ImplPrnQueueList* pList)
82 PrinterInfoManager& rManager(PrinterInfoManager::get());
83 static const char* pNoSyncDetection = getenv("SAL_DISABLE_SYNCHRONOUS_PRINTER_DETECTION");
84 if (!pNoSyncDetection || !*pNoSyncDetection)
86 // #i62663# synchronize possible asynchronouse printer detection now
87 rManager.checkPrintersChanged(true);
89 ::std::vector<OUString> aPrinters;
90 rManager.listPrinters(aPrinters);
92 for (const auto& rPrinter : aPrinters)
94 const PrinterInfo& rInfo(rManager.getPrinterInfo(rPrinter));
95 // create new entry
96 std::unique_ptr<SalPrinterQueueInfo> pInfo(new SalPrinterQueueInfo);
97 pInfo->maPrinterName = rPrinter;
98 pInfo->maDriver = rInfo.m_aDriverName;
99 pInfo->maLocation = rInfo.m_aLocation;
100 pInfo->maComment = rInfo.m_aComment;
102 sal_Int32 nIndex = 0;
103 while (nIndex != -1)
105 OUString aToken(rInfo.m_aFeatures.getToken(0, ',', nIndex));
106 if (aToken.startsWith("pdf="))
108 pInfo->maLocation = getPdfDir(rInfo);
109 break;
113 pList->Add(std::move(pInfo));
117 void Qt5Instance::GetPrinterQueueState(SalPrinterQueueInfo*) {}
119 OUString Qt5Instance::GetDefaultPrinter()
121 PrinterInfoManager& rManager(PrinterInfoManager::get());
122 return rManager.getDefaultPrinter();
125 void Qt5Instance::PostPrintersChanged() {}
127 std::unique_ptr<GenPspGraphics> Qt5Instance::CreatePrintGraphics()
129 return std::make_unique<GenPspGraphics>();
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */