Commit 682a15fc authored by Albert Astals Cid's avatar Albert Astals Cid

* poppler-document.cc:

       * poppler-page.cc:
       * poppler-private.h:
       * poppler-qt4.h:
       No need to destroy the Splash output device to change its paper color.
       Add the possibility to set flags that affect the rendering (some
       backends supports only some of them, though).
       Add a Page::label to get the label associated with a page.
       Patches by Pino Toscano <pino@kde.org>.
parent 7331bc46
2007-01-21 Albert Astals Cid <aacid@kde.org>
* poppler-document.cc:
* poppler-page.cc:
* poppler-private.h:
* poppler-qt4.h:
No need to destroy the Splash output device to change its paper color.
Add the possibility to set flags that affect the rendering (some
backends supports only some of them, though).
Add a Page::label to get the label associated with a page.
Patches by Pino Toscano <pino@kde.org>.
2007-01-17 Albert Astals Cid <aacid@kde.org>
* poppler/Sound.h:
......
......@@ -478,6 +478,26 @@ namespace Poppler {
return ret;
}
void Document::setRenderHint( Document::RenderHint hint, bool on )
{
if ( on )
m_doc->m_hints |= hint;
else
m_doc->m_hints &= ~(int)hint;
// the only way to set the textAA for Splash is on creation
if ( m_doc->m_backend == Document::SplashBackend && hint == Document::TextAntialiasing )
{
delete m_doc->m_outputDev;
m_doc->m_outputDev = NULL;
}
}
Document::RenderHints Document::renderHints() const
{
return Document::RenderHints() & m_doc->m_hints;
}
QDateTime convertDate( char *dateString )
{
int year;
......
......@@ -215,7 +215,10 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h,
QImage tmpimg(w == -1 ? size.width() : w, h == -1 ? size.height() : h, QImage::Format_ARGB32);
QPainter painter(&tmpimg);
painter.setRenderHint(QPainter::Antialiasing);
if (m_page->parentDoc->m_doc->m_hints & Document::Antialiasing)
painter.setRenderHint(QPainter::Antialiasing);
if (m_page->parentDoc->m_doc->m_hints & Document::TextAntialiasing)
painter.setRenderHint(QPainter::TextAntialiasing);
painter.save();
painter.translate(x == -1 ? 0 : -x, y == -1 ? 0 : -y);
if (w == -1 && h == -1)
......@@ -1242,5 +1245,14 @@ double Page::duration() const
else return -1;
}
QString Page::label() const
{
GooString goo;
if (!m_page->parentDoc->m_doc->doc->getCatalog()->indexToLabel(m_page->index, &goo))
return QString();
return QString(goo.getCString());
}
}
......@@ -125,7 +125,8 @@ namespace Poppler {
bgColor[0] = paperColor.red();
bgColor[1] = paperColor.green();
bgColor[2] = paperColor.blue();
SplashOutputDev * splashOutputDev = new SplashOutputDev(splashModeRGB8Qt, 4, gFalse, bgColor);
GBool AA = m_hints & Document::TextAntialiasing ? gTrue : gFalse;
SplashOutputDev * splashOutputDev = new SplashOutputDev(splashModeRGB8Qt, 4, gFalse, bgColor, gTrue, AA);
splashOutputDev->startDoc(doc->getXRef());
m_outputDev = splashOutputDev;
#endif
......@@ -193,11 +194,28 @@ namespace Poppler {
void setPaperColor(const QColor &color)
{
if (color != paperColor)
if (color == paperColor)
return;
paperColor = color;
if ( m_outputDev == NULL )
return;
switch ( m_backend )
{
paperColor = color;
delete m_outputDev;
m_outputDev = NULL;
case Document::SplashBackend:
{
#if defined(HAVE_SPLASH)
SplashOutputDev *splash_output = static_cast<SplashOutputDev *>( m_outputDev );
SplashColor bgColor;
bgColor[0] = paperColor.red();
bgColor[1] = paperColor.green();
bgColor[2] = paperColor.blue();
splash_output->setPaperColor(bgColor);
#endif
break;
}
default: ;
}
}
......@@ -223,6 +241,7 @@ namespace Poppler {
OutputDev *m_outputDev;
QList<EmbeddedFile*> m_embeddedFiles;
QColor paperColor;
int m_hints;
static int count;
};
......
......@@ -382,6 +382,11 @@ namespace Poppler {
*/
double duration() const;
/**
Returns the label of the page, or a null string is the page has no label.
**/
QString label() const;
private:
Page(const Document *doc, int index);
PageData *m_page;
......@@ -431,6 +436,15 @@ namespace Poppler {
ArthurBackend ///< Arthur (Qt4) backend
};
/**
The render hints available
*/
enum RenderHint {
Antialiasing = 0x00000001, ///< Antialiasing for graphics
TextAntialiasing = 0x00000002 ///< Antialiasing for text
};
Q_DECLARE_FLAGS( RenderHints, RenderHint )
/**
Load the document from a file on disk
......@@ -737,6 +751,17 @@ height = dummy.height();
*/
static QSet<RenderBackend> availableRenderBackends();
/**
Sets the render \p hint .
\param on whether the flag should be added or removed.
*/
void setRenderHint( RenderHint hint, bool on = true );
/**
The currently set render hints.
*/
RenderHints renderHints() const;
~Document();
private:
......
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