[poppler] qt4/src
Pino Toscano
pino at kemper.freedesktop.org
Sat Sep 6 07:38:07 PDT 2008
qt4/src/poppler-ps-converter.cc | 34 ++++++++++++++++++++++++++--------
qt4/src/poppler-qt4.h | 26 ++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 8 deletions(-)
New commits:
commit 3366059a25611f19ab592cda18c5efe0b9359771
Author: Pino Toscano <pino at kde.org>
Date: Sat Sep 6 16:34:58 2008 +0200
[Qt4] add option flags for the PS converter
- map the 'strictMargins' and 'forceRasterize' bool options as flags
- add a flag for setting the "printing" mode
diff --git a/qt4/src/poppler-ps-converter.cc b/qt4/src/poppler-ps-converter.cc
index 8562656..c805a40 100644
--- a/qt4/src/poppler-ps-converter.cc
+++ b/qt4/src/poppler-ps-converter.cc
@@ -47,15 +47,14 @@ class PSConverterPrivate : public BaseConverterPrivate
int marginBottom;
int marginLeft;
int marginTop;
- bool strictMargins;
- bool forceRasterize;
+ PSConverter::PSOptions opts;
};
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)
+ opts(0)
{
}
@@ -140,13 +139,31 @@ void PSConverter::setTopMargin(int marginTop)
void PSConverter::setStrictMargins(bool strictMargins)
{
Q_D(PSConverter);
- d->strictMargins = strictMargins;
+ if (strictMargins)
+ d->opts |= StrictMargins;
+ else
+ d->opts &= ~StrictMargins;
}
void PSConverter::setForceRasterize(bool forceRasterize)
{
Q_D(PSConverter);
- d->forceRasterize = forceRasterize;
+ if (forceRasterize)
+ d->opts |= ForceRasterization;
+ else
+ d->opts &= ~ForceRasterization;
+}
+
+void PSConverter::setPSOptions(PSConverter::PSOptions options)
+{
+ Q_D(PSConverter);
+ d->opts = options;
+}
+
+PSConverter::PSOptions PSConverter::psOptions() const
+{
+ Q_D(const PSConverter);
+ return d->opts;
}
bool PSConverter::convert()
@@ -180,9 +197,9 @@ bool PSConverter::convert()
d->marginBottom,
d->paperWidth - d->marginRight,
d->paperHeight - d->marginTop,
- d->forceRasterize);
+ (d->opts & ForceRasterization));
- if (d->strictMargins)
+ if (d->opts & StrictMargins)
{
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;
@@ -191,9 +208,10 @@ bool PSConverter::convert()
if (psOut->isOk())
{
+ GBool isPrinting = (d->opts & Printing) ? gTrue : gFalse;
foreach(int page, d->pageList)
{
- d->document->doc->displayPage(psOut, page, d->hDPI, d->vDPI, d->rotate, gFalse, gTrue, gTrue);
+ d->document->doc->displayPage(psOut, page, d->hDPI, d->vDPI, d->rotate, gFalse, gTrue, isPrinting);
}
delete psOut;
d->closeDevice();
diff --git a/qt4/src/poppler-qt4.h b/qt4/src/poppler-qt4.h
index b677b4d..fa706a3 100644
--- a/qt4/src/poppler-qt4.h
+++ b/qt4/src/poppler-qt4.h
@@ -1037,6 +1037,18 @@ height = dummy.height();
friend class Document;
public:
/**
+ Options for the PS export.
+
+ \since 0.10
+ */
+ enum PSOption {
+ Printing = 0x00000001, ///< The PS is generated for priting purpouses
+ StrictMargins = 0x00000002,
+ ForceRasterization = 0x00000004
+ };
+ Q_DECLARE_FLAGS( PSOptions, PSOption )
+
+ /**
Destructor.
*/
~PSConverter();
@@ -1106,6 +1118,19 @@ height = dummy.height();
/** Defines if the page will be rasterized to an image before printing. Defaults to false */
void setForceRasterize(bool forceRasterize);
+ /**
+ Sets the options for the PS export.
+
+ \since 0.10
+ */
+ void setPSOptions(PSOptions options);
+ /**
+ The currently set options for the PS export.
+
+ \since 0.10
+ */
+ PSOptions psOptions() const;
+
bool convert();
private:
@@ -1297,5 +1322,6 @@ height = dummy.height();
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::Document::RenderHints)
Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PDFConverter::PDFOptions)
+Q_DECLARE_OPERATORS_FOR_FLAGS(Poppler::PSConverter::PSOptions)
#endif
More information about the poppler
mailing list