[poppler] qt4/src

Albert Astals Cid aacid at kemper.freedesktop.org
Tue Jan 22 14:28:27 PST 2008


 qt4/src/Makefile.am                          |    5 
 qt4/src/poppler-base-converter.cc            |   99 ++++++++++++++++
 qt4/src/poppler-converter-private.h          |   48 ++++++++
 qt4/src/poppler-document.cc                  |    5 
 qt4/src/poppler-pdf-converter.cc             |   68 +++++++++++
 qt4/src/poppler-ps-converter.cc              |  162 +++++++++++----------------
 qt4/src/poppler-qiodeviceoutstream-private.h |   47 +++++++
 qt4/src/poppler-qiodeviceoutstream.cc        |   71 +++++++++++
 qt4/src/poppler-qt4.h                        |   85 +++++++++++---
 9 files changed, 483 insertions(+), 107 deletions(-)

New commits:
commit eccf84b51a1cf5d478c0ec84be3fc9be8e458f4f
Author: Pino Toscano <pino at kde.org>
Date:   Tue Jan 22 23:28:16 2008 +0100

    Refactor the PSConverter and add a PDFConverter (for PDF export/save).
    
    Add an OutStream subclass to redirect the output to a QIODevice.
    Split the PSConverter in a base class (BaseConverter) w/ d_ptr structure.
    Add a new PDFConverter that inherit BaseConverter, and do the actual export
    making use of the new QIODeviceOutStream.
    The BaseConverter now handles automatically file or QIODevice output.

diff --git a/qt4/src/Makefile.am b/qt4/src/Makefile.am
index 0ac6ef4..f8b3e68 100644
--- a/qt4/src/Makefile.am
+++ b/qt4/src/Makefile.am
@@ -28,11 +28,16 @@ libpoppler_qt4_la_SOURCES =			\
 	../../qt/poppler-page-transition.cc	\
 	poppler-sound.cc			\
 	poppler-form.cc				\
+	poppler-base-converter.cc		\
 	poppler-ps-converter.cc			\
+	poppler-pdf-converter.cc		\
+	poppler-qiodeviceoutstream.cc		\
 	poppler-annotation-helper.h		\
 	poppler-page-private.h			\
 	poppler-link-extractor-private.h	\
 	poppler-annotation-private.h		\
+	poppler-converter-private.h		\
+	poppler-qiodeviceoutstream-private.h	\
 	poppler-private.h
 
 libpoppler_qt4_la_LIBADD = 			\
diff --git a/qt4/src/poppler-base-converter.cc b/qt4/src/poppler-base-converter.cc
new file mode 100644
index 0000000..012ba9e
--- /dev/null
+++ b/qt4/src/poppler-base-converter.cc
@@ -0,0 +1,99 @@
+/* poppler-base-converter.cc: qt interface to poppler
+ * Copyright (C) 2007, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2008, Pino Toscano <pino at kde.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "poppler-qt4.h"
+
+#include "poppler-converter-private.h"
+
+#include <QtCore/QFile>
+
+namespace Poppler {
+
+BaseConverterPrivate::BaseConverterPrivate()
+	: document(0), iodev(0), ownIodev(true)
+{
+}
+
+BaseConverterPrivate::~BaseConverterPrivate()
+{
+}
+
+QIODevice* BaseConverterPrivate::openDevice()
+{
+	if (!iodev)
+	{
+		Q_ASSERT(!outputFileName.isEmpty());
+		QFile *f = new QFile(outputFileName);
+		iodev = f;
+		ownIodev = true;
+	}
+	Q_ASSERT(iodev);
+	if (!iodev->isOpen())
+	{
+		if (!iodev->open(QIODevice::ReadWrite))
+		{
+			if (ownIodev)
+			{
+				delete iodev;
+				iodev = 0;
+			}
+			else
+			{
+				return 0;
+			}
+		}
+	}
+	return iodev;
+}
+
+void BaseConverterPrivate::closeDevice()
+{
+	if (ownIodev)
+	{
+		iodev->close();
+		delete iodev;
+		iodev = 0;
+	}
+}
+
+
+BaseConverter::BaseConverter(BaseConverterPrivate &dd)
+	: d_ptr(&dd)
+{
+}
+
+BaseConverter::~BaseConverter()
+{
+	delete d_ptr;
+}
+
+void BaseConverter::setOutputFileName(const QString &outputFileName)
+{
+	Q_D(BaseConverter);
+	d->outputFileName = outputFileName;
+}
+
+void BaseConverter::setOutputDevice(QIODevice *device)
+{
+	Q_D(BaseConverter);
+	d->iodev = device;
+	d->ownIodev = false;
+}
+
+}
diff --git a/qt4/src/poppler-converter-private.h b/qt4/src/poppler-converter-private.h
new file mode 100644
index 0000000..051d9eb
--- /dev/null
+++ b/qt4/src/poppler-converter-private.h
@@ -0,0 +1,48 @@
+/* poppler-converter-private.h: Qt4 interface to poppler
+ * Copyright (C) 2007, Albert Astals Cid <aacid at kde.org>
+ * Copyright (C) 2008, Pino Toscano <pino at kde.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef POPPLER_QT4_CONVERTER_PRIVATE_H
+#define POPPLER_QT4_CONVERTER_PRIVATE_H
+
+#include <QtCore/QString>
+
+class QIODevice;
+
+namespace Poppler {
+
+class DocumentData;
+
+class BaseConverterPrivate
+{
+	public:
+		BaseConverterPrivate();
+		~BaseConverterPrivate();
+
+		QIODevice* openDevice();
+		void closeDevice();
+
+		DocumentData *document;
+		QString outputFileName;
+		QIODevice *iodev;
+		bool ownIodev : 1;
+};
+
+}
+
+#endif
diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc
index b9431d8..fd9473c 100644
--- a/qt4/src/poppler-document.cc
+++ b/qt4/src/poppler-document.cc
@@ -458,6 +458,11 @@ namespace Poppler {
         return new PSConverter(m_doc);
     }
 
+    PDFConverter *Document::pdfConverter() const
+    {
+        return new PDFConverter(m_doc);
+    }
+
     QString Document::metadata() const
     {
         QString result;
diff --git a/qt4/src/poppler-pdf-converter.cc b/qt4/src/poppler-pdf-converter.cc
new file mode 100644
index 0000000..a1b94cd
--- /dev/null
+++ b/qt4/src/poppler-pdf-converter.cc
@@ -0,0 +1,68 @@
+/* poppler-pdf-converter.cc: qt4 interface to poppler
+ * Copyright (C) 2008, Pino Toscano <pino at kde.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "poppler-qt4.h"
+
+#include "poppler-private.h"
+#include "poppler-converter-private.h"
+#include "poppler-qiodeviceoutstream-private.h"
+
+namespace Poppler {
+
+class PDFConverterPrivate : public BaseConverterPrivate
+{
+	public:
+		PDFConverterPrivate();
+};
+
+PDFConverterPrivate::PDFConverterPrivate()
+	: BaseConverterPrivate()
+{
+}
+
+
+PDFConverter::PDFConverter(DocumentData *document)
+	: BaseConverter(*new PDFConverterPrivate())
+{
+	Q_D(PDFConverter);
+	d->document = document;
+}
+
+PDFConverter::~PDFConverter()
+{
+}
+
+bool PDFConverter::convert()
+{
+	Q_D(PDFConverter);
+
+	if (d->document->locked)
+		return false;
+
+	QIODevice *dev = d->openDevice();
+	if (!dev)
+		return false;
+
+	QIODeviceOutStream stream(dev);
+	d->document->doc->saveAs(&stream);
+	d->closeDevice();
+
+	return true;
+}
+
+}
diff --git a/qt4/src/poppler-ps-converter.cc b/qt4/src/poppler-ps-converter.cc
index 52f8159..1598308 100644
--- a/qt4/src/poppler-ps-converter.cc
+++ b/qt4/src/poppler-ps-converter.cc
@@ -17,12 +17,12 @@
  */
 
 #include "poppler-qt4.h"
+
 #include "poppler-private.h"
+#include "poppler-converter-private.h"
 
 #include "PSOutputDev.h"
 
-#include <QtCore/QFile>
-
 static void outputToQIODevice(void *stream, char *data, int len)
 {
 	static_cast<QIODevice*>(stream)->write(data, len);
@@ -30,13 +30,11 @@ static void outputToQIODevice(void *stream, char *data, int len)
 
 namespace Poppler {
 
-class PSConverterData
+class PSConverterPrivate : public BaseConverterPrivate
 {
 	public:
-		DocumentData *document;
-		QString outputFileName;
-		QIODevice *iodev;
-		bool ownIodev;
+		PSConverterPrivate();
+
 		QList<int> pageList;
 		QString title;
 		double hDPI;
@@ -52,180 +50,158 @@ class PSConverterData
 		bool forceRasterize;
 };
 
-PSConverter::PSConverter(DocumentData *document)
+PSConverterPrivate::PSConverterPrivate()
+	: BaseConverterPrivate(),
+	hDPI(72), vDPI(72), rotate(0), paperWidth(-1), paperHeight(-1),
+	marginRight(0), marginBottom(0), marginLeft(0), marginTop(0),
+	strictMargins(false), forceRasterize(false)
 {
-	m_data = new PSConverterData();
-	m_data->document = document;
-	m_data->iodev = 0;
-	m_data->ownIodev = true;
-	m_data->hDPI = 72;
-	m_data->vDPI = 72;
-	m_data->rotate = 0;
-	m_data->paperWidth = -1;
-	m_data->paperHeight = -1;
-	m_data->marginRight = 0;
-	m_data->marginBottom = 0;
-	m_data->marginLeft = 0;
-	m_data->marginTop = 0;
-	m_data->strictMargins = false;
-	m_data->forceRasterize = false;
 }
 
-PSConverter::~PSConverter()
-{
-	delete m_data;
-}
 
-void PSConverter::setOutputFileName(const QString &outputFileName)
+PSConverter::PSConverter(DocumentData *document)
+	: BaseConverter(*new PSConverterPrivate())
 {
-	m_data->outputFileName = outputFileName;
+	Q_D(PSConverter);
+	d->document = document;
 }
 
-void PSConverter::setOutputDevice(QIODevice *device)
+PSConverter::~PSConverter()
 {
-	m_data->iodev = device;
-	m_data->ownIodev = false;
 }
 
 void PSConverter::setPageList(const QList<int> &pageList)
 {
-	m_data->pageList = pageList;
+	Q_D(PSConverter);
+	d->pageList = pageList;
 }
 
 void PSConverter::setTitle(const QString &title)
 {
-	m_data->title = title;
+	Q_D(PSConverter);
+	d->title = title;
 }
 
 void PSConverter::setHDPI(double hDPI)
 {
-	m_data->hDPI = hDPI;
+	Q_D(PSConverter);
+	d->hDPI = hDPI;
 }
 
 void PSConverter::setVDPI(double vDPI)
 {
-	m_data->vDPI = vDPI;
+	Q_D(PSConverter);
+	d->vDPI = vDPI;
 }
 
 void PSConverter::setRotate(int rotate)
 {
-	m_data->rotate = rotate;
+	Q_D(PSConverter);
+	d->rotate = rotate;
 }
 
 void PSConverter::setPaperWidth(int paperWidth)
 {
-	m_data->paperWidth = paperWidth;
+	Q_D(PSConverter);
+	d->paperWidth = paperWidth;
 }
 
 void PSConverter::setPaperHeight(int paperHeight)
 {
-	m_data->paperHeight = paperHeight;
+	Q_D(PSConverter);
+	d->paperHeight = paperHeight;
 }
 
 void PSConverter::setRightMargin(int marginRight)
 {
-	m_data->marginRight = marginRight;
+	Q_D(PSConverter);
+	d->marginRight = marginRight;
 }
 
 void PSConverter::setBottomMargin(int marginBottom)
 {
-	m_data->marginBottom = marginBottom;
+	Q_D(PSConverter);
+	d->marginBottom = marginBottom;
 }
 
 void PSConverter::setLeftMargin(int marginLeft)
 {
-	m_data->marginLeft = marginLeft;
+	Q_D(PSConverter);
+	d->marginLeft = marginLeft;
 }
 
 void PSConverter::setTopMargin(int marginTop)
 {
-	m_data->marginTop = marginTop;
+	Q_D(PSConverter);
+	d->marginTop = marginTop;
 }
 
 void PSConverter::setStrictMargins(bool strictMargins)
 {
-	m_data->strictMargins = strictMargins;
+	Q_D(PSConverter);
+	d->strictMargins = strictMargins;
 }
 
 void PSConverter::setForceRasterize(bool forceRasterize)
 {
-	m_data->forceRasterize = forceRasterize;
+	Q_D(PSConverter);
+	d->forceRasterize = forceRasterize;
 }
 
 bool PSConverter::convert()
 {
-	if (!m_data->iodev)
-	{
-		Q_ASSERT(!m_data->outputFileName.isEmpty());
-		QFile *f = new QFile(m_data->outputFileName);
-		m_data->iodev = f;
-		m_data->ownIodev = true;
-	}
-	Q_ASSERT(m_data->iodev);
-	if (!m_data->iodev->isOpen())
-	{
-		if (!m_data->iodev->open(QIODevice::ReadWrite))
-		{
-			return false;
-		}
-	}
+	Q_D(PSConverter);
 
-	Q_ASSERT(!m_data->pageList.isEmpty());
-	Q_ASSERT(m_data->paperWidth != -1);
-	Q_ASSERT(m_data->paperHeight != -1);
+	Q_ASSERT(!d->pageList.isEmpty());
+	Q_ASSERT(d->paperWidth != -1);
+	Q_ASSERT(d->paperHeight != -1);
 	
-	QByteArray pstitle8Bit = m_data->title.toLocal8Bit();
+	QIODevice *dev = d->openDevice();
+	if (!dev)
+		return false;
+
+	QByteArray pstitle8Bit = d->title.toLocal8Bit();
 	char* pstitlechar;
-	if (!m_data->title.isEmpty()) pstitlechar = pstitle8Bit.data();
+	if (!d->title.isEmpty()) pstitlechar = pstitle8Bit.data();
 	else pstitlechar = 0;
 	
-	PSOutputDev *psOut = new PSOutputDev(outputToQIODevice, m_data->iodev,
+	PSOutputDev *psOut = new PSOutputDev(outputToQIODevice, dev,
 	                                     pstitlechar,
-	                                     m_data->document->doc->getXRef(),
-	                                     m_data->document->doc->getCatalog(),
+	                                     d->document->doc->getXRef(),
+	                                     d->document->doc->getCatalog(),
 	                                     1,
-	                                     m_data->document->doc->getNumPages(),
+	                                     d->document->doc->getNumPages(),
 	                                     psModePS,
-	                                     m_data->paperWidth,
-	                                     m_data->paperHeight,
+	                                     d->paperWidth,
+	                                     d->paperHeight,
 	                                     gFalse,
-	                                     m_data->marginLeft,
-	                                     m_data->marginBottom,
-	                                     m_data->paperWidth - m_data->marginRight,
-	                                     m_data->paperHeight - m_data->marginTop,
-	                                     m_data->forceRasterize);
+	                                     d->marginLeft,
+	                                     d->marginBottom,
+	                                     d->paperWidth - d->marginRight,
+	                                     d->paperHeight - d->marginTop,
+	                                     d->forceRasterize);
 	
-	if (m_data->strictMargins)
+	if (d->strictMargins)
 	{
-		double xScale = ((double)m_data->paperWidth - (double)m_data->marginLeft - (double)m_data->marginRight) / (double)m_data->paperWidth;
-		double yScale = ((double)m_data->paperHeight - (double)m_data->marginBottom - (double)m_data->marginTop) / (double)m_data->paperHeight;
+		double xScale = ((double)d->paperWidth - (double)d->marginLeft - (double)d->marginRight) / (double)d->paperWidth;
+		double yScale = ((double)d->paperHeight - (double)d->marginBottom - (double)d->marginTop) / (double)d->paperHeight;
 		psOut->setScale(xScale, yScale);
 	}
 	
 	if (psOut->isOk())
 	{
-		foreach(int page, m_data->pageList)
+		foreach(int page, d->pageList)
 		{
-			m_data->document->doc->displayPage(psOut, page, m_data->hDPI, m_data->vDPI, m_data->rotate, gFalse, gTrue, gFalse);
+			d->document->doc->displayPage(psOut, page, d->hDPI, d->vDPI, d->rotate, gFalse, gTrue, gFalse);
 		}
 		delete psOut;
-		if (m_data->ownIodev)
-		{
-			m_data->iodev->close();
-			delete m_data->iodev;
-			m_data->iodev = 0;
-		}
+		d->closeDevice();
 		return true;
 	}
 	else
 	{
 		delete psOut;
-		if (m_data->ownIodev)
-		{
-			m_data->iodev->close();
-			delete m_data->iodev;
-			m_data->iodev = 0;
-		}
+		d->closeDevice();
 		return false;
 	}
 }
diff --git a/qt4/src/poppler-qiodeviceoutstream-private.h b/qt4/src/poppler-qiodeviceoutstream-private.h
new file mode 100644
index 0000000..74b56ca
--- /dev/null
+++ b/qt4/src/poppler-qiodeviceoutstream-private.h
@@ -0,0 +1,47 @@
+/* poppler-qiodevicestream-private.h: Qt4 interface to poppler
+ * Copyright (C) 2008, Pino Toscano <pino at kde.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef POPPLER_QIODEVICESTREAM_PRIVATE_H
+#define POPPLER_QIODEVICESTREAM_PRIVATE_H
+
+#include "Object.h"
+#include "Stream.h"
+
+class QIODevice;
+
+namespace Poppler {
+
+class QIODeviceOutStream : public OutStream
+{
+  public:
+    QIODeviceOutStream(QIODevice* device);
+    virtual ~QIODeviceOutStream();
+
+    virtual void reset();
+    virtual void close();
+    virtual int getPos();
+    virtual void put(char c);
+    virtual void printf(const char *format, ...);
+
+  private:
+    QIODevice *m_device;
+};
+
+}
+
+#endif
diff --git a/qt4/src/poppler-qiodeviceoutstream.cc b/qt4/src/poppler-qiodeviceoutstream.cc
new file mode 100644
index 0000000..11fab97
--- /dev/null
+++ b/qt4/src/poppler-qiodeviceoutstream.cc
@@ -0,0 +1,71 @@
+/* poppler-qiodevicestream.cc: Qt4 interface to poppler
+ * Copyright (C) 2008, Pino Toscano <pino at kde.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "poppler-qiodeviceoutstream-private.h"
+
+#include <QtCore/QIODevice>
+
+#include <iostream>
+
+#include <stdio.h>
+
+namespace Poppler {
+
+QIODeviceOutStream::QIODeviceOutStream(QIODevice* device)
+  : m_device(device)
+{
+}
+
+QIODeviceOutStream::~QIODeviceOutStream()
+{
+}
+
+void QIODeviceOutStream::reset()
+{
+  m_device->reset();
+}
+
+void QIODeviceOutStream::close()
+{
+}
+
+int QIODeviceOutStream::getPos()
+{
+  return (int)m_device->pos();
+}
+
+void QIODeviceOutStream::put(char c)
+{
+  m_device->putChar(c);
+}
+
+void QIODeviceOutStream::printf(const char *format, ...)
+{
+  va_list ap;
+  va_start(ap, format);
+  char* buf = 0;
+  size_t bufsize = 0;
+  FILE* stream = open_memstream(&buf, &bufsize);
+  vfprintf(stream, format, ap);
+  va_end(ap);
+  fclose(stream);
+  m_device->write(buf, bufsize);
+  free(buf);
+}
+
+}
diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h
index cb3a340..33c091f 100644
--- a/qt4/src/poppler-qt4.h
+++ b/qt4/src/poppler-qt4.h
@@ -47,6 +47,7 @@ namespace Poppler {
 
     class TextBoxData;
 
+    class PDFConverter;
     class PSConverter;
 
     /**
@@ -853,6 +854,13 @@ QString subject = m_doc->info("Subject");
 	PSConverter *psConverter() const;
 	
 	/**
+	  Gets a new PDF converter for this document.
+
+	  The caller gets the ownership of the returned converter.
+	 */
+	PDFConverter *pdfConverter() const;
+	
+	/**
 	  Gets the metadata stream contents
 	*/
 	QString metadata() const;
@@ -871,7 +879,47 @@ QString subject = m_doc->info("Subject");
 	static Document *checkDocument(DocumentData *doc);
     };
     
-    class PSConverterData;
+    class BaseConverterPrivate;
+    class PSConverterPrivate;
+    class PDFConverterPrivate;
+    /**
+       \brief Base converter.
+
+       This is the base class for the converters.
+    */
+    class BaseConverter
+    {
+        friend class Document;
+        public:
+            /**
+              Destructor.
+            */
+            virtual ~BaseConverter();
+
+            /** Sets the output file name. You must set this or the output device. */
+            void setOutputFileName(const QString &outputFileName);
+
+            /** Sets the output device. You must set this or the output file name. */
+            void setOutputDevice(QIODevice *device);
+
+            /**
+              Does the conversion.
+
+              \return whether the conversion succeeded
+            */
+            virtual bool convert() = 0;
+
+        protected:
+            /// \cond PRIVATE
+            BaseConverter(BaseConverterPrivate &dd);
+            Q_DECLARE_PRIVATE(BaseConverter)
+            BaseConverterPrivate *d_ptr;
+            /// \endcond
+
+        private:
+            Q_DISABLE_COPY(BaseConverter)
+    };
+
     /**
        Converts a PDF to PS
 
@@ -886,7 +934,7 @@ width = dummy.width();
 height = dummy.height();
        \endcode
     */
-    class PSConverter
+    class PSConverter : public BaseConverter
     {
         friend class Document;
         public:
@@ -895,12 +943,6 @@ height = dummy.height();
             */
             ~PSConverter();
 
-            /** Sets the output file name. You must set this or the output device. */
-            void setOutputFileName(const QString &outputFileName);
-
-            /** Sets the output device. You must set this or the output file name. */
-            void setOutputDevice(QIODevice *device);
-
             /** Sets the list of pages to print. Mandatory. */
             void setPageList(const QList<int> &pageList);
 
@@ -966,19 +1008,34 @@ height = dummy.height();
             /** Defines if the page will be rasterized to an image before printing. Defaults to false */
             void setForceRasterize(bool forceRasterize);
 
-            /**
-              Does the conversion.
-
-              \return whether the conversion succeeded
-            */
             bool convert();
 
         private:
+            Q_DECLARE_PRIVATE(PSConverter)
             Q_DISABLE_COPY(PSConverter)
 
             PSConverter(DocumentData *document);
+    };
+
+    /**
+       Converts a PDF to PDF (thus saves a copy of the document).
+    */
+    class PDFConverter : public BaseConverter
+    {
+        friend class Document;
+        public:
+            /**
+              Destructor.
+            */
+            virtual ~PDFConverter();
+
+            bool convert();
+
+        private:
+            Q_DECLARE_PRIVATE(PDFConverter)
+            Q_DISABLE_COPY(PDFConverter)
 
-            PSConverterData *m_data;
+            PDFConverter(DocumentData *document);
     };
 
     /**


More information about the poppler mailing list