Kaydet (Commit) 41d213e9 authored tarafından Katarina Behrens's avatar Katarina Behrens Kaydeden (comit) Thorsten Behrens

Use generic unx PspSalInfoPrinter instead of Qt5InfoPrinter

the latter provides (so far) no added value, quite the contrary:
File > Print > $printer > Properties didn't display generic unx/CUPS
dlg but just failed silently

Change-Id: Ide2ad175ffe55b5c9ac5ca3efad4a43b692f9984
Reviewed-on: https://gerrit.libreoffice.org/60040
Tested-by: Jenkins
Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 46b2350c
......@@ -22,13 +22,6 @@
#include <unx/genprn.h>
class SalFrame;
class ImplJobSetup;
class Qt5InfoPrinter : public PspSalInfoPrinter
{
public:
virtual bool Setup(weld::Window* pFrame, ImplJobSetup* pSetupData) override;
};
class Qt5Printer : public PspSalPrinter
{
......
......@@ -56,130 +56,12 @@ static OUString getPdfDir(const PrinterInfo& rInfo)
return aDir;
}
inline int PtTo10Mu(int nPoints)
{
return static_cast<int>((static_cast<double>(nPoints) * 35.27777778) + 0.5);
}
static void copyJobDataToJobSetup(ImplJobSetup* pJobSetup, JobData& rData)
{
pJobSetup->SetOrientation(rData.m_eOrientation == orientation::Landscape
? Orientation::Landscape
: Orientation::Portrait);
// copy page size
OUString aPaper;
int width, height;
rData.m_aContext.getPageSize(aPaper, width, height);
pJobSetup->SetPaperFormat(
PaperInfo::fromPSName(OUStringToOString(aPaper, RTL_TEXTENCODING_ISO_8859_1)));
pJobSetup->SetPaperWidth(0);
pJobSetup->SetPaperHeight(0);
if (pJobSetup->GetPaperFormat() == PAPER_USER)
{
// transform to 100dth mm
width = PtTo10Mu(width);
height = PtTo10Mu(height);
if (rData.m_eOrientation == psp::orientation::Portrait)
{
pJobSetup->SetPaperWidth(width);
pJobSetup->SetPaperHeight(height);
}
else
{
pJobSetup->SetPaperWidth(height);
pJobSetup->SetPaperHeight(width);
}
}
// copy input slot
const PPDKey* pKey = nullptr;
const PPDValue* pValue = nullptr;
pJobSetup->SetPaperBin(0xffff);
if (rData.m_pParser)
pKey = rData.m_pParser->getKey(OUString("InputSlot"));
if (pKey)
pValue = rData.m_aContext.getValue(pKey);
if (pKey && pValue)
{
int nPaperBin;
for (nPaperBin = 0; pValue != pKey->getValue(nPaperBin) && nPaperBin < pKey->countValues();
nPaperBin++)
;
pJobSetup->SetPaperBin(
(nPaperBin == pKey->countValues() || pValue == pKey->getDefaultValue()) ? 0xffff
: nPaperBin);
}
// copy duplex
pKey = nullptr;
pValue = nullptr;
pJobSetup->SetDuplexMode(DuplexMode::Unknown);
if (rData.m_pParser)
pKey = rData.m_pParser->getKey(OUString("Duplex"));
if (pKey)
pValue = rData.m_aContext.getValue(pKey);
if (pKey && pValue)
{
if (pValue->m_aOption.equalsIgnoreAsciiCase("None")
|| pValue->m_aOption.startsWithIgnoreAsciiCase("Simplex"))
{
pJobSetup->SetDuplexMode(DuplexMode::Off);
}
else if (pValue->m_aOption.equalsIgnoreAsciiCase("DuplexNoTumble"))
{
pJobSetup->SetDuplexMode(DuplexMode::LongEdge);
}
else if (pValue->m_aOption.equalsIgnoreAsciiCase("DuplexTumble"))
{
pJobSetup->SetDuplexMode(DuplexMode::ShortEdge);
}
}
// copy the whole context
if (pJobSetup->GetDriverData())
std::free(const_cast<sal_uInt8*>(pJobSetup->GetDriverData()));
sal_uInt32 nBytes;
void* pBuffer = nullptr;
if (rData.getStreamBuffer(pBuffer, nBytes))
{
pJobSetup->SetDriverDataLen(nBytes);
pJobSetup->SetDriverData(static_cast<sal_uInt8*>(pBuffer));
}
else
{
pJobSetup->SetDriverDataLen(0);
pJobSetup->SetDriverData(nullptr);
}
}
SalInfoPrinter* Qt5Instance::CreateInfoPrinter(SalPrinterQueueInfo* pQueueInfo,
ImplJobSetup* pJobSetup)
{
// create and initialize SalInfoPrinter
Qt5InfoPrinter* pPrinter = new Qt5InfoPrinter;
if (pJobSetup)
{
PrinterInfoManager& rManager(PrinterInfoManager::get());
PrinterInfo aInfo(rManager.getPrinterInfo(pQueueInfo->maPrinterName));
pPrinter->m_aJobData = aInfo;
pPrinter->m_aPrinterGfx.Init(pPrinter->m_aJobData);
if (pJobSetup->GetDriverData())
JobData::constructFromStreamBuffer(pJobSetup->GetDriverData(),
pJobSetup->GetDriverDataLen(), aInfo);
pJobSetup->SetSystem(JOBSETUP_SYSTEM_UNIX);
pJobSetup->SetPrinterName(pQueueInfo->maPrinterName);
pJobSetup->SetDriver(aInfo.m_aDriverName);
copyJobDataToJobSetup(pJobSetup, aInfo);
}
PspSalInfoPrinter* pPrinter = new PspSalInfoPrinter;
configurePspInfoPrinter(pPrinter, pQueueInfo, pJobSetup);
return pPrinter;
}
......@@ -190,7 +72,7 @@ std::unique_ptr<SalPrinter> Qt5Instance::CreatePrinter(SalInfoPrinter* pInfoPrin
{
// create and initialize SalPrinter
Qt5Printer* pPrinter = new Qt5Printer(pInfoPrinter);
pPrinter->m_aJobData = static_cast<Qt5InfoPrinter*>(pInfoPrinter)->m_aJobData;
pPrinter->m_aJobData = static_cast<PspSalInfoPrinter*>(pInfoPrinter)->m_aJobData;
return std::unique_ptr<SalPrinter>(pPrinter);
}
......
......@@ -19,8 +19,6 @@
#include <Qt5Printer.hxx>
bool Qt5InfoPrinter::Setup(weld::Window*, ImplJobSetup*) { return false; }
Qt5Printer::Qt5Printer(SalInfoPrinter* pInfoPrinter)
: PspSalPrinter(pInfoPrinter)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment