Qt 4.8
Public Functions | Public Variables | List of all members
QPdfBaseEnginePrivate Class Reference

#include <qpdf_p.h>

Inheritance diagram for QPdfBaseEnginePrivate:
QAlphaPaintEnginePrivate QPaintEnginePrivate QPdfEnginePrivate QPSPrintEnginePrivate

Public Functions

void closePrintDevice ()
 
virtual void drawTextItem (const QPointF &p, const QTextItemInt &ti)
 
bool openPrintDevice ()
 
QRect pageRect () const
 
QRect paperRect () const
 
 QPdfBaseEnginePrivate (QPrinter::PrinterMode m)
 
uint requestObject ()
 
 ~QPdfBaseEnginePrivate ()
 
- Public Functions inherited from QAlphaPaintEnginePrivate
void addAlphaRect (const QRectF &rect)
 
QRectF addPenWidth (const QPainterPath &path)
 
void drawAlphaImage (const QRectF &rect)
 
bool fullyContained (const QRectF &rect) const
 
 QAlphaPaintEnginePrivate ()
 
void resetState (QPainter *p)
 
QRect toRect (const QRectF &rect) const
 
 ~QAlphaPaintEnginePrivate ()
 
- Public Functions inherited from QPaintEnginePrivate
void drawBoxTextItem (const QPointF &p, const QTextItemInt &ti)
 
 QPaintEnginePrivate ()
 
void setSystemTransform (const QTransform &xform)
 
void setSystemViewport (const QRegion &region)
 
virtual void systemStateChanged ()
 
void transformSystemClip ()
 
virtual ~QPaintEnginePrivate ()
 

Public Variables

bool allClipped
 
qreal bottomMargin
 
QBrush brush
 
QPointF brushOrigin
 
bool clipEnabled
 
QList< QPainterPathclips
 
bool collate
 
QPrinter::ColorMode colorMode
 
int copies
 
QString creator
 
QStringList cupsOptions
 
QRect cupsPageRect
 
QRect cupsPaperRect
 
QString cupsStringPageSize
 
QString cupsTempFile
 
int currentObject
 
QPdfPagecurrentPage
 
QSizeF customPaperSize
 
QPrinter::DuplexMode duplex
 
bool embedFonts
 
int fd
 
QHash< QFontEngine::FaceId, QFontSubset * > fonts
 
bool fullPage
 
bool hasBrush
 
bool hasCustomPageMargins
 
bool hasPen
 
qreal leftMargin
 
qreal opacity
 
QPrinter::Orientation orientation
 
QIODeviceoutDevice
 
QString outputFileName
 
QPrinter::PageOrder pageOrder
 
QPrinter::PaperSize paperSize
 
QPrinter::PaperSource paperSource
 
QPaintDevicepdev
 
QPen pen
 
bool postscript
 
QString printerName
 
QString printProgram
 
int resolution
 
qreal rightMargin
 
QString selectionOption
 
bool simplePen
 
QPdf::Stroker stroker
 
QString title
 
qreal topMargin
 
bool useAlphaEngine
 
- Public Variables inherited from QAlphaPaintEnginePrivate
bool m_advancedBrush
 
bool m_advancedPen
 
bool m_alphaBrush
 
bool m_alphaOpacity
 
bool m_alphaPen
 
QRegion m_alphargn
 
QRegion m_cliprgn
 
bool m_complexTransform
 
bool m_continueCall
 
bool m_emulateProjectiveTransforms
 
bool m_hasalpha
 
int m_pass
 
QPaintDevicem_pdev
 
QPen m_pen
 
QPicturem_pic
 
QPaintEnginem_picengine
 
QPainterm_picpainter
 
QPaintEngine::PaintEngineFeatures m_savedcaps
 
QTransform m_transform
 
- Public Variables inherited from QPaintEnginePrivate
QWidgetcurrentClipWidget
 
uint hasSystemTransform: 1
 
uint hasSystemViewport: 1
 
QPaintDevicepdev
 
QPaintEngineq_ptr
 
QRegion systemClip
 
QRect systemRect
 
QTransform systemTransform
 
QRegion systemViewport
 

Detailed Description

Definition at line 219 of file qpdf_p.h.

Constructors and Destructors

◆ QPdfBaseEnginePrivate()

QPdfBaseEnginePrivate::QPdfBaseEnginePrivate ( QPrinter::PrinterMode  m)

Definition at line 1595 of file qpdf.cpp.

1596  : clipEnabled(false), allClipped(false), hasPen(true), hasBrush(false), simplePen(false),
1597  useAlphaEngine(false),
1598  outDevice(0), fd(-1),
1599  duplex(QPrinter::DuplexNone), collate(false), fullPage(false), embedFonts(true), copies(1),
1602  hasCustomPageMargins(false),
1604 {
1605  resolution = 72;
1606  if (m == QPrinter::HighResolution)
1607  resolution = 1200;
1608  else if (m == QPrinter::ScreenResolution)
1610 
1611  postscript = false;
1612  currentObject = 1;
1613  currentPage = 0;
1614  stroker.stream = 0;
1615 }
QPrinter::Orientation orientation
Definition: qpdf_p.h:276
QPrinter::PageOrder pageOrder
Definition: qpdf_p.h:275
QPdf::Stroker stroker
Definition: qpdf_p.h:240
QPrinter::DuplexMode duplex
Definition: qpdf_p.h:269
bool hasCustomPageMargins
Definition: qpdf_p.h:286
QPrinter::ColorMode colorMode
Definition: qpdf_p.h:278
QPrinter::PaperSize paperSize
Definition: qpdf_p.h:277
Q_GUI_EXPORT int qt_defaultDpi()
Definition: qfont.cpp:240
QIODevice * outDevice
Definition: qpdf_p.h:259
QPdfPage * currentPage
Definition: qpdf_p.h:239
ByteStream * stream
Definition: qpdf_p.h:137
QPrinter::PaperSource paperSource
Definition: qpdf_p.h:279

◆ ~QPdfBaseEnginePrivate()

QPdfBaseEnginePrivate::~QPdfBaseEnginePrivate ( )

Definition at line 1903 of file qpdf.cpp.

1904 {
1905  qDeleteAll(fonts);
1906  delete currentPage;
1907 }
QHash< QFontEngine::FaceId, QFontSubset * > fonts
Definition: qpdf_p.h:254
QPdfPage * currentPage
Definition: qpdf_p.h:239
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

Functions

◆ closePrintDevice()

void QPdfBaseEnginePrivate::closePrintDevice ( )

Definition at line 1808 of file qpdf.cpp.

1809 {
1810  if (!outDevice)
1811  return;
1812  outDevice->close();
1813  if (fd >= 0)
1814 #if defined(Q_OS_WIN) && defined(_MSC_VER) && _MSC_VER >= 1400
1815  ::_close(fd);
1816 #else
1817  ::close(fd);
1818 #endif
1819  fd = -1;
1820  delete outDevice;
1821  outDevice = 0;
1822 
1823 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
1824  if (!cupsTempFile.isEmpty()) {
1825  QString tempFile = cupsTempFile;
1826  cupsTempFile.clear();
1827  QCUPSSupport cups;
1828 
1829  // Set up print options.
1830  QByteArray prnName;
1832  QVector<cups_option_t> cupsOptStruct;
1833 
1834  if (!printerName.isEmpty()) {
1835  prnName = printerName.toLocal8Bit();
1836  } else {
1838  if (def.isNull()) {
1839  qWarning("Could not determine printer to print to");
1840  QFile::remove(tempFile);
1841  return;
1842  }
1843  prnName = def.printerName().toLocal8Bit();
1844  }
1845 
1846  if (!cupsStringPageSize.isEmpty()) {
1848  }
1849 
1850  if (copies > 1) {
1851  options.append(QPair<QByteArray, QByteArray>("copies", QString::number(copies).toLocal8Bit()));
1852  }
1853 
1854  if (collate) {
1855  options.append(QPair<QByteArray, QByteArray>("Collate", "True"));
1856  }
1857 
1858  switch (duplex) {
1859  case QPrinter::DuplexNone:
1860  options.append(QPair<QByteArray, QByteArray>("sides", "one-sided"));
1861  break;
1862  case QPrinter::DuplexAuto:
1864  options.append(QPair<QByteArray, QByteArray>("sides", "two-sided-long-edge"));
1865  else
1866  options.append(QPair<QByteArray, QByteArray>("sides", "two-sided-short-edge"));
1867  break;
1869  options.append(QPair<QByteArray, QByteArray>("sides", "two-sided-long-edge"));
1870  break;
1872  options.append(QPair<QByteArray, QByteArray>("sides", "two-sided-short-edge"));
1873  break;
1874  }
1875 
1877  options.append(QPair<QByteArray, QByteArray>("landscape", ""));
1878  }
1879 
1881  while (it != cupsOptions.constEnd()) {
1882  options.append(QPair<QByteArray, QByteArray>((*it).toLocal8Bit(), (*(it+1)).toLocal8Bit()));
1883  it += 2;
1884  }
1885 
1886  for (int c = 0; c < options.size(); ++c) {
1887  cups_option_t opt;
1888  opt.name = options[c].first.data();
1889  opt.value = options[c].second.data();
1890  cupsOptStruct.append(opt);
1891  }
1892 
1893  // Print the file.
1894  cups_option_t* optPtr = cupsOptStruct.size() ? &cupsOptStruct.first() : 0;
1895  cups.printFile(prnName.constData(), tempFile.toLocal8Bit().constData(),
1896  title.toLocal8Bit().constData(), cupsOptStruct.size(), optPtr);
1897 
1898  QFile::remove(tempFile);
1899  }
1900 #endif
1901 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
static QPrinterInfo defaultPrinter()
Returns the default printer on the system.
unsigned char c[8]
Definition: qnumeric_p.h:62
QStringList cupsOptions
Definition: qpdf_p.h:281
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
Definition: qiodevice.cpp:590
#define it(className, varName)
QPrinter::Orientation orientation
Definition: qpdf_p.h:276
T & first()
Returns a reference to the first item in the vector.
Definition: qvector.h:260
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
QString cupsTempFile
Definition: qpdf_p.h:290
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
friend class const_iterator
Definition: qlist.h:264
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int printFile(const char *printerName, const char *filename, const char *title, int num_options, cups_option_t *options)
Definition: qcups.cpp:394
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
Q_CORE_EXPORT void qWarning(const char *,...)
QString printerName
Definition: qpdf_p.h:264
QPrinter::DuplexMode duplex
Definition: qpdf_p.h:269
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
The QPrinterInfo class gives access to information about existing printers.
Definition: qprinterinfo.h:58
QString printerName() const
Returns the name of the printer.
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QIODevice * outDevice
Definition: qpdf_p.h:259
bool isNull() const
Returns whether this QPrinterInfo object holds a printer definition.
bool remove()
Removes the file specified by fileName().
Definition: qfile.cpp:715
QString cupsStringPageSize
Definition: qpdf_p.h:284
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
static int cupsVersion()
Definition: qcups_p.h:75
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ drawTextItem()

void QPdfBaseEnginePrivate::drawTextItem ( const QPointF p,
const QTextItemInt ti 
)
virtual

Reimplemented in QPdfEnginePrivate.

Definition at line 1909 of file qpdf.cpp.

Referenced by QPdfEnginePrivate::drawTextItem().

1910 {
1912 
1913  QFontEngine *fe = ti.fontEngine;
1914 
1915  QFontEngine::FaceId face_id = fe->faceId();
1916  bool noEmbed = false;
1917  if (face_id.filename.isEmpty()
1918  || (!postscript && ((fe->fsType & 0x200) /* bitmap embedding only */
1919  || (fe->fsType == 2) /* no embedding allowed */))) {
1920  *currentPage << "Q\n";
1921  q->QPaintEngine::drawTextItem(p, ti);
1922  *currentPage << "q\n";
1923  if (face_id.filename.isEmpty())
1924  return;
1925  noEmbed = true;
1926  }
1927 
1928  QFontSubset *font = fonts.value(face_id, 0);
1929  if (!font) {
1930  font = new QFontSubset(fe, requestObject());
1931  font->noEmbed = noEmbed;
1932  }
1933  fonts.insert(face_id, font);
1934 
1935  if (!currentPage->fonts.contains(font->object_id))
1937 
1938  qreal size = ti.fontEngine->fontDef.pixelSize;
1939 #ifdef Q_WS_WIN
1940  if (ti.fontEngine->type() == QFontEngine::Win) {
1941  QFontEngineWin *fe = static_cast<QFontEngineWin *>(ti.fontEngine);
1942  size = fe->tm.tmHeight;
1943  }
1944 #endif
1945 
1946  QVarLengthArray<glyph_t> glyphs;
1948  QTransform m = QTransform::fromTranslate(p.x(), p.y());
1949  ti.fontEngine->getGlyphPositions(ti.glyphs, m, ti.flags,
1950  glyphs, positions);
1951  if (glyphs.size() == 0)
1952  return;
1953  int synthesized = ti.fontEngine->synthesized();
1954  qreal stretch = synthesized & QFontEngine::SynthesizedStretch ? ti.fontEngine->fontDef.stretch/100. : 1.;
1955 
1956  *currentPage << "BT\n"
1957  << "/F" << font->object_id << size << "Tf "
1958  << stretch << (synthesized & QFontEngine::SynthesizedItalic
1959  ? "0 .3 -1 0 0 Tm\n"
1960  : "0 0 -1 0 0 Tm\n");
1961 
1962 
1963 #if 0
1964  // #### implement actual text for complex languages
1965  const unsigned short *logClusters = ti.logClusters;
1966  int pos = 0;
1967  do {
1968  int end = pos + 1;
1969  while (end < ti.num_chars && logClusters[end] == logClusters[pos])
1970  ++end;
1971  *currentPage << "/Span << /ActualText <FEFF";
1972  for (int i = pos; i < end; ++i) {
1973  s << toHex((ushort)ti.chars[i].unicode(), buf);
1974  }
1975  *currentPage << "> >>\n"
1976  "BDC\n"
1977  "<";
1978  int ge = end == ti.num_chars ? ti.num_glyphs : logClusters[end];
1979  for (int gs = logClusters[pos]; gs < ge; ++gs)
1980  *currentPage << toHex((ushort)ti.glyphs[gs].glyph, buf);
1981  *currentPage << "> Tj\n"
1982  "EMC\n";
1983  pos = end;
1984  } while (pos < ti.num_chars);
1985 #else
1986  qreal last_x = 0.;
1987  qreal last_y = 0.;
1988  for (int i = 0; i < glyphs.size(); ++i) {
1989  qreal x = positions[i].x.toReal();
1990  qreal y = positions[i].y.toReal();
1991  if (synthesized & QFontEngine::SynthesizedItalic)
1992  x += .3*y;
1993  x /= stretch;
1994  char buf[5];
1995  int g = font->addGlyph(glyphs[i]);
1996  *currentPage << x - last_x << last_y - y << "Td <"
1997  << QPdf::toHex((ushort)g, buf) << "> Tj\n";
1998  last_x = x;
1999  last_y = y;
2000  }
2001  if (synthesized & QFontEngine::SynthesizedBold) {
2002  *currentPage << stretch << (synthesized & QFontEngine::SynthesizedItalic
2003  ? "0 .3 -1 0 0 Tm\n"
2004  : "0 0 -1 0 0 Tm\n");
2005  *currentPage << "/Span << /ActualText <> >> BDC\n";
2006  last_x = 0.5*fe->lineThickness().toReal();
2007  last_y = 0.;
2008  for (int i = 0; i < glyphs.size(); ++i) {
2009  qreal x = positions[i].x.toReal();
2010  qreal y = positions[i].y.toReal();
2011  if (synthesized & QFontEngine::SynthesizedItalic)
2012  x += .3*y;
2013  x /= stretch;
2014  char buf[5];
2015  int g = font->addGlyph(glyphs[i]);
2016  *currentPage << x - last_x << last_y - y << "Td <"
2017  << QPdf::toHex((ushort)g, buf) << "> Tj\n";
2018  last_x = x;
2019  last_y = y;
2020  }
2021  *currentPage << "EMC\n";
2022  }
2023 #endif
2024 
2025  *currentPage << "ET\n";
2026 }
virtual QFixed lineThickness() const
QFontEngine * fontEngine
double qreal
Definition: qglobal.h:1193
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
const QChar * chars
int addGlyph(int index)
RenderFlags flags
virtual int synthesized() const
const unsigned short * logClusters
QVector< uint > fonts
Definition: qpdf_p.h:170
virtual Type type() const =0
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define Q_Q(Class)
Definition: qglobal.h:2483
QGlyphLayout glyphs
static char toHex(quint8 c)
Definition: qurl.cpp:4440
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Definition: qcssparser.cpp:329
void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
uint requestObject()
Definition: qpdf_p.h:231
virtual FaceId faceId() const
QHash< QFontEngine::FaceId, QFontSubset * > fonts
Definition: qpdf_p.h:254
qreal pixelSize
Definition: qfont_p.h:90
const char * toHex(ushort u, char *buffer)
Definition: qpdf.cpp:862
unsigned short ushort
Definition: qglobal.h:995
int last_x
qreal toReal() const
Definition: qfixed_p.h:77
uint stretch
Definition: qfont_p.h:98
bool contains(const T &t) const
Returns true if the vector contains an occurrence of value; otherwise returns false.
Definition: qvector.h:731
QPdfPage * currentPage
Definition: qpdf_p.h:239
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
static QTransform fromTranslate(qreal dx, qreal dy)
Creates a matrix which corresponds to a translation of dx along the x axis and dy along the y axis...
Definition: qtransform.cpp:462
QFontDef fontDef
int last_y
static const KeyPair *const end
const int object_id
Definition: qfontsubset_p.h:84
int size() const
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ openPrintDevice()

bool QPdfBaseEnginePrivate::openPrintDevice ( )

Definition at line 1666 of file qpdf.cpp.

1667 {
1668  if(outDevice)
1669  return false;
1670 
1671  if (!outputFileName.isEmpty()) {
1672  QFile *file = new QFile(outputFileName);
1673  if (! file->open(QFile::WriteOnly|QFile::Truncate)) {
1674  delete file;
1675  return false;
1676  }
1677  outDevice = file;
1678 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
1679  } else if (QCUPSSupport::isAvailable()) {
1680  QCUPSSupport cups;
1681  QPair<int, QString> ret = cups.tempFd();
1682  if (ret.first < 0) {
1683  qWarning("QPdfPrinter: Could not open temporary file to print");
1684  return false;
1685  }
1686  cupsTempFile = ret.second;
1687  outDevice = new QFile();
1688  static_cast<QFile *>(outDevice)->open(ret.first, QIODevice::WriteOnly);
1689  fd = ret.first;
1690 #endif
1691 #ifndef QT_NO_LPR
1692  } else {
1693  QString pr;
1694  if (!printerName.isEmpty())
1695  pr = printerName;
1696  int fds[2];
1697  if (qt_safe_pipe(fds) != 0) {
1698  qWarning("QPdfPrinter: Could not open pipe to print");
1699  return false;
1700  }
1701 
1702  pid_t pid = fork();
1703  if (pid == 0) { // child process
1704  // if possible, exit quickly, so the actual lp/lpr
1705  // becomes a child of init, and ::waitpid() is
1706  // guaranteed not to wait.
1707  if (fork() > 0) {
1708  closeAllOpenFds();
1709 
1710  // try to replace this process with "true" - this prevents
1711  // global destructors from being called (that could possibly
1712  // do wrong things to the parent process)
1713  (void)execlp("true", "true", (char *)0);
1714  (void)execl("/bin/true", "true", (char *)0);
1715  (void)execl("/usr/bin/true", "true", (char *)0);
1716  ::_exit(0);
1717  }
1718  qt_safe_dup2(fds[0], 0, 0);
1719 
1720  closeAllOpenFds();
1721 
1722  if (!printProgram.isEmpty()) {
1723  if (!selectionOption.isEmpty())
1725  else
1726  pr.prepend(QLatin1String("-P"));
1727  (void)execlp(printProgram.toLocal8Bit().data(), printProgram.toLocal8Bit().data(),
1728  pr.toLocal8Bit().data(), (char *)0);
1729  } else {
1730  // if no print program has been specified, be smart
1731  // about the option string too.
1732  QList<QByteArray> lprhack;
1733  QList<QByteArray> lphack;
1734  QByteArray media;
1735  if (!pr.isEmpty() || !selectionOption.isEmpty()) {
1736  if (!selectionOption.isEmpty()) {
1738  for (int i = 0; i < list.size(); ++i)
1739  lprhack.append(list.at(i).toLocal8Bit());
1740  lphack = lprhack;
1741  } else {
1742  lprhack.append("-P");
1743  lphack.append("-d");
1744  }
1745  lprhack.append(pr.toLocal8Bit());
1746  lphack.append(pr.toLocal8Bit());
1747  }
1748  lphack.append("-s");
1749 
1750  char ** lpargs = new char *[lphack.size()+6];
1751  char lp[] = "lp";
1752  lpargs[0] = lp;
1753  int i;
1754  for (i = 0; i < lphack.size(); ++i)
1755  lpargs[i+1] = (char *)lphack.at(i).constData();
1756 #ifndef Q_OS_OSF
1757  char dash_o[] = "-o";
1759  lpargs[++i] = dash_o;
1760  lpargs[++i] = const_cast<char *>(QPdf::paperSizeToString(paperSize));
1761  lpargs[++i] = dash_o;
1762  media = "media=";
1764  lpargs[++i] = media.data();
1765  }
1766 #endif
1767  lpargs[++i] = 0;
1768  char **lprargs = new char *[lprhack.size()+2];
1769  char lpr[] = "lpr";
1770  lprargs[0] = lpr;
1771  for (int i = 0; i < lprhack.size(); ++i)
1772  lprargs[i+1] = (char *)lprhack[i].constData();
1773  lprargs[lprhack.size() + 1] = 0;
1774  (void)execvp("lp", lpargs);
1775  (void)execvp("lpr", lprargs);
1776  (void)execv("/bin/lp", lpargs);
1777  (void)execv("/bin/lpr", lprargs);
1778  (void)execv("/usr/bin/lp", lpargs);
1779  (void)execv("/usr/bin/lpr", lprargs);
1780 
1781  delete []lpargs;
1782  delete []lprargs;
1783  }
1784  // if we couldn't exec anything, close the fd,
1785  // wait for a second so the parent process (the
1786  // child of the GUI process) has exited. then
1787  // exit.
1788  QT_CLOSE(0);
1789  (void)::sleep(1);
1790  ::_exit(0);
1791  }
1792  // parent process
1793  QT_CLOSE(fds[0]);
1794  fd = fds[1];
1795  (void)qt_safe_waitpid(pid, 0, 0);
1796 
1797  if (fd < 0)
1798  return false;
1799 
1800  outDevice = new QFile();
1801  static_cast<QFile *>(outDevice)->open(fd, QIODevice::WriteOnly);
1802 #endif
1803  }
1804 
1805  return true;
1806 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition: qfile.cpp:1064
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QString & prepend(QChar c)
Definition: qstring.h:261
T1 first
Definition: qpair.h:65
T2 second
Definition: qpair.h:66
QString selectionOption
Definition: qpdf_p.h:266
QString cupsTempFile
Definition: qpdf_p.h:290
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
const char * paperSizeToString(QPrinter::PaperSize paperSize)
Definition: qpdf.cpp:912
static bool isAvailable()
Definition: qcups.cpp:216
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
Q_CORE_EXPORT void qWarning(const char *,...)
static int qt_safe_dup2(int oldfd, int newfd, int flags=FD_CLOEXEC)
Definition: qcore_unix_p.h:251
static int qt_safe_pipe(int pipefd[2], int flags=0)
Definition: qcore_unix_p.h:191
QPair< int, QString > tempFd()
Definition: qcups.cpp:386
QString printerName
Definition: qpdf_p.h:264
static void closeAllOpenFds()
Definition: qpdf.cpp:1645
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
QString outputFileName
Definition: qpdf_p.h:263
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QPrinter::PaperSize paperSize
Definition: qpdf_p.h:277
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
QString printProgram
Definition: qpdf_p.h:265
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QIODevice * outDevice
Definition: qpdf_p.h:259
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
static pid_t qt_safe_waitpid(pid_t pid, int *status, int options)
Definition: qcore_unix_p.h:333
int open(const char *, int,...)
#define QT_CLOSE
Definition: qcore_unix_p.h:304

◆ pageRect()

QRect QPdfBaseEnginePrivate::pageRect ( ) const

Definition at line 2057 of file qpdf.cpp.

Referenced by QPSPrintEnginePrivate::emitHeader(), and QPdfEnginePrivate::pageMatrix().

2058 {
2059  if(fullPage)
2060  return paperRect();
2061 
2062  QRect r;
2063 
2064 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
2066  r = cupsPageRect;
2067  if (r == cupsPaperRect) {
2068  // if cups doesn't define any margins, give it at least approx 3.5 mm
2069  r = QRect(10, 10, r.width() - 20, r.height() - 20);
2070  }
2071  } else
2072 #endif
2073  {
2074  QPdf::PaperSize s;
2075  if (paperSize == QPrinter::Custom) {
2078  } else {
2080  }
2082  r = QRect(0, 0, s.width, s.height);
2083  else
2084  r = QRect(72/3, 72/3, s.width - 2*72/3, s.height - 2*72/3);
2085  }
2086 
2087  int x = qRound(r.left()*resolution/72.);
2088  int y = qRound(r.top()*resolution/72.);
2089  int w = qRound(r.width()*resolution/72.);
2090  int h = qRound(r.height()*resolution/72.);
2092  r = QRect(x, y, w, h);
2093  else
2094  r = QRect(y, x, h, w);
2095 
2096  if (hasCustomPageMargins) {
2098  qRound(topMargin*(resolution/72.)),
2099  -qRound(rightMargin*(resolution/72.)),
2100  -qRound(bottomMargin*(resolution/72.)));
2101  }
2102  return r;
2103 }
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
PaperSize paperSize(QPrinter::PaperSize paperSize)
Definition: qpdf.cpp:905
QPrinter::Orientation orientation
Definition: qpdf_p.h:276
qreal width() const
Returns the width.
Definition: qsize.h:284
qreal height() const
Returns the height.
Definition: qsize.h:287
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
static bool isAvailable()
Definition: qcups.cpp:216
QSizeF customPaperSize
Definition: qpdf_p.h:285
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
bool hasCustomPageMargins
Definition: qpdf_p.h:286
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
QPrinter::PaperSize paperSize
Definition: qpdf_p.h:277
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QRect paperRect() const
Definition: qpdf.cpp:2028
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ paperRect()

QRect QPdfBaseEnginePrivate::paperRect ( ) const

Definition at line 2028 of file qpdf.cpp.

Referenced by QPSPrintEnginePrivate::emitHeader(), and pageRect().

2029 {
2030  int w;
2031  int h;
2032  if (paperSize == QPrinter::Custom) {
2035  } else {
2036 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
2038  QRect r = cupsPaperRect;
2039  w = r.width();
2040  h = r.height();
2041  } else
2042 #endif
2043  {
2045  w = s.width;
2046  h = s.height;
2047  }
2048  w = qRound(w*resolution/72.);
2049  h = qRound(h*resolution/72.);
2050  }
2052  return QRect(0, 0, w, h);
2053  else
2054  return QRect(0, 0, h, w);
2055 }
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
PaperSize paperSize(QPrinter::PaperSize paperSize)
Definition: qpdf.cpp:905
QPrinter::Orientation orientation
Definition: qpdf_p.h:276
qreal width() const
Returns the width.
Definition: qsize.h:284
qreal height() const
Returns the height.
Definition: qsize.h:287
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
static bool isAvailable()
Definition: qcups.cpp:216
QSizeF customPaperSize
Definition: qpdf_p.h:285
QPrinter::PaperSize paperSize
Definition: qpdf_p.h:277
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ requestObject()

uint QPdfBaseEnginePrivate::requestObject ( )
inline

Properties

◆ allClipped

bool QPdfBaseEnginePrivate::allClipped

Definition at line 247 of file qpdf_p.h.

◆ bottomMargin

qreal QPdfBaseEnginePrivate::bottomMargin

Definition at line 287 of file qpdf_p.h.

Referenced by pageRect().

◆ brush

QBrush QPdfBaseEnginePrivate::brush

Definition at line 243 of file qpdf_p.h.

Referenced by QPdfEnginePrivate::addBrushPattern().

◆ brushOrigin

QPointF QPdfBaseEnginePrivate::brushOrigin

Definition at line 242 of file qpdf_p.h.

Referenced by QPdfEnginePrivate::addBrushPattern().

◆ clipEnabled

bool QPdfBaseEnginePrivate::clipEnabled

Definition at line 246 of file qpdf_p.h.

◆ clips

QList<QPainterPath> QPdfBaseEnginePrivate::clips

Definition at line 245 of file qpdf_p.h.

◆ collate

bool QPdfBaseEnginePrivate::collate

Definition at line 270 of file qpdf_p.h.

Referenced by closePrintDevice().

◆ colorMode

QPrinter::ColorMode QPdfBaseEnginePrivate::colorMode

Definition at line 278 of file qpdf_p.h.

Referenced by QPdfEnginePrivate::addImage(), and QPSPrintEnginePrivate::drawImage().

◆ copies

int QPdfBaseEnginePrivate::copies

Definition at line 273 of file qpdf_p.h.

Referenced by closePrintDevice(), and QPSPrintEnginePrivate::emitHeader().

◆ creator

QString QPdfBaseEnginePrivate::creator

Definition at line 268 of file qpdf_p.h.

Referenced by QPSPrintEnginePrivate::emitHeader(), and QPdfEnginePrivate::writeInfo().

◆ cupsOptions

QStringList QPdfBaseEnginePrivate::cupsOptions

Definition at line 281 of file qpdf_p.h.

Referenced by closePrintDevice().

◆ cupsPageRect

QRect QPdfBaseEnginePrivate::cupsPageRect

Definition at line 283 of file qpdf_p.h.

Referenced by pageRect().

◆ cupsPaperRect

QRect QPdfBaseEnginePrivate::cupsPaperRect

Definition at line 282 of file qpdf_p.h.

Referenced by pageRect(), and paperRect().

◆ cupsStringPageSize

QString QPdfBaseEnginePrivate::cupsStringPageSize

Definition at line 284 of file qpdf_p.h.

Referenced by closePrintDevice().

◆ cupsTempFile

QString QPdfBaseEnginePrivate::cupsTempFile

Definition at line 290 of file qpdf_p.h.

Referenced by closePrintDevice(), and openPrintDevice().

◆ currentObject

int QPdfBaseEnginePrivate::currentObject

Definition at line 237 of file qpdf_p.h.

Referenced by QPdfBaseEnginePrivate().

◆ currentPage

QPdfPage* QPdfBaseEnginePrivate::currentPage

◆ customPaperSize

QSizeF QPdfBaseEnginePrivate::customPaperSize

Definition at line 285 of file qpdf_p.h.

Referenced by pageRect(), and paperRect().

◆ duplex

QPrinter::DuplexMode QPdfBaseEnginePrivate::duplex

Definition at line 269 of file qpdf_p.h.

Referenced by closePrintDevice().

◆ embedFonts

bool QPdfBaseEnginePrivate::embedFonts

Definition at line 272 of file qpdf_p.h.

Referenced by QPSPrintEnginePrivate::QPSPrintEnginePrivate().

◆ fd

int QPdfBaseEnginePrivate::fd

Definition at line 260 of file qpdf_p.h.

Referenced by closePrintDevice(), and openPrintDevice().

◆ fonts

QHash<QFontEngine::FaceId, QFontSubset *> QPdfBaseEnginePrivate::fonts

◆ fullPage

bool QPdfBaseEnginePrivate::fullPage

◆ hasBrush

bool QPdfBaseEnginePrivate::hasBrush

Definition at line 249 of file qpdf_p.h.

◆ hasCustomPageMargins

bool QPdfBaseEnginePrivate::hasCustomPageMargins

Definition at line 286 of file qpdf_p.h.

Referenced by pageRect().

◆ hasPen

bool QPdfBaseEnginePrivate::hasPen

Definition at line 248 of file qpdf_p.h.

◆ leftMargin

qreal QPdfBaseEnginePrivate::leftMargin

Definition at line 287 of file qpdf_p.h.

Referenced by pageRect().

◆ opacity

qreal QPdfBaseEnginePrivate::opacity

Definition at line 251 of file qpdf_p.h.

Referenced by QPdfEnginePrivate::addBrushPattern().

◆ orientation

QPrinter::Orientation QPdfBaseEnginePrivate::orientation

◆ outDevice

QIODevice* QPdfBaseEnginePrivate::outDevice

◆ outputFileName

QString QPdfBaseEnginePrivate::outputFileName

Definition at line 263 of file qpdf_p.h.

Referenced by QPSPrintEnginePrivate::emitHeader(), and openPrintDevice().

◆ pageOrder

QPrinter::PageOrder QPdfBaseEnginePrivate::pageOrder

Definition at line 275 of file qpdf_p.h.

Referenced by QPdfEnginePrivate::QPdfEnginePrivate().

◆ paperSize

QPrinter::PaperSize QPdfBaseEnginePrivate::paperSize

Definition at line 277 of file qpdf_p.h.

Referenced by pageRect(), and paperRect().

◆ paperSource

QPrinter::PaperSource QPdfBaseEnginePrivate::paperSource

Definition at line 279 of file qpdf_p.h.

◆ pdev

QPaintDevice* QPdfBaseEnginePrivate::pdev

Definition at line 256 of file qpdf_p.h.

Referenced by QPdfBaseEngine::begin(), and QPSPrintEnginePrivate::emitHeader().

◆ pen

QPen QPdfBaseEnginePrivate::pen

Definition at line 244 of file qpdf_p.h.

Referenced by QPdfEnginePrivate::addBrushPattern().

◆ postscript

bool QPdfBaseEnginePrivate::postscript

◆ printerName

QString QPdfBaseEnginePrivate::printerName

Definition at line 264 of file qpdf_p.h.

Referenced by closePrintDevice(), and openPrintDevice().

◆ printProgram

QString QPdfBaseEnginePrivate::printProgram

Definition at line 265 of file qpdf_p.h.

◆ resolution

int QPdfBaseEnginePrivate::resolution

◆ rightMargin

qreal QPdfBaseEnginePrivate::rightMargin

Definition at line 287 of file qpdf_p.h.

Referenced by pageRect().

◆ selectionOption

QString QPdfBaseEnginePrivate::selectionOption

Definition at line 266 of file qpdf_p.h.

◆ simplePen

bool QPdfBaseEnginePrivate::simplePen

Definition at line 250 of file qpdf_p.h.

◆ stroker

QPdf::Stroker QPdfBaseEnginePrivate::stroker

◆ title

QString QPdfBaseEnginePrivate::title

◆ topMargin

qreal QPdfBaseEnginePrivate::topMargin

Definition at line 287 of file qpdf_p.h.

Referenced by pageRect().

◆ useAlphaEngine

bool QPdfBaseEnginePrivate::useAlphaEngine

Definition at line 252 of file qpdf_p.h.

Referenced by QPSPrintEnginePrivate::QPSPrintEnginePrivate().


The documentation for this class was generated from the following files: