r17419 by fschmid - Compile fixes for compiling with poppler 0.19.x
scribus-commit
scribus-commit at lists.scribus.net
Fri Apr 6 08:47:48 UTC 2012
Author: fschmid
Date: Fri Apr 6 08:47:47 2012
New Revision: 17419
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17419
Log:
Compile fixes for compiling with poppler 0.19.x
Modified:
trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp
trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
Modified: trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17419&path=/trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp Fri Apr 6 08:47:47 2012
@@ -315,7 +315,7 @@
GBool useMediaBox = gTrue;
GBool crop = gFalse;
GBool printing = gFalse;
- dev->startDoc(pdfDoc->getXRef(), pdfDoc->getCatalog());
+ dev->startDoc(pdfDoc, pdfDoc->getXRef(), pdfDoc->getCatalog());
int rotate = pdfDoc->getPageRotate(firstPage);
/* PDFRectangle *rect = pdfDoc->getPage(firstPage)->getMediaBox();
qDebug() << "Media Box" << rect->x1 << rect->y1 << rect->x2 << rect->y2;
Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17419&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp Fri Apr 6 08:47:47 2012
@@ -1,5 +1,6 @@
#include "slaoutput.h"
#include <GlobalParams.h>
+#include <poppler-config.h>
#include <QApplication>
#include <QFile>
#include "commonstrings.h"
@@ -45,10 +46,11 @@
}
-void SlaOutputDev::startDoc(XRef *xrefA, Catalog *catA)
+void SlaOutputDev::startDoc(PDFDoc *doc, XRef *xrefA, Catalog *catA)
{
xref = xrefA;
catalog = catA;
+ pdfDoc = doc;
firstPage = true;
pagecount = 1;
updateGUICounter = 0;
@@ -926,7 +928,11 @@
m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
QTransform mm = QTransform(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
QTransform mmx = mm * m_ctm;
+#ifdef POPPLER_VERSION
+ gfx = new Gfx(pdfDoc, this, resDict, &box, NULL);
+#else
gfx = new Gfx(xref, this, resDict, catalog, &box, NULL);
+#endif
gfx->display(str);
gElements = m_groupStack.pop();
tmpSel->clear();
@@ -1457,6 +1463,236 @@
// qDebug() << "End Marked Content";
}
+// POPPLER_VERSION appeared in 0.19.0 first
+#ifdef POPPLER_VERSION
+void SlaOutputDev::updateFont(GfxState *state)
+{
+ GfxFont *gfxFont;
+ GfxFontLoc *fontLoc;
+ GfxFontType fontType;
+ SplashOutFontFileID *id;
+ SplashFontFile *fontFile;
+ SplashFontSrc *fontsrc = NULL;
+ FoFiTrueType *ff;
+ Object refObj, strObj;
+ GooString *fileName;
+ char *tmpBuf;
+ int tmpBufLen;
+ int *codeToGID;
+ double *textMat;
+ double m11, m12, m21, m22, fontSize;
+ SplashCoord mat[4];
+ int n;
+ int faceIndex = 0;
+ SplashCoord matrix[6];
+
+ m_font = NULL;
+ fileName = NULL;
+ tmpBuf = NULL;
+ fontLoc = NULL;
+
+ if (!(gfxFont = state->getFont())) {
+ goto err1;
+ }
+ fontType = gfxFont->getType();
+ if (fontType == fontType3) {
+ goto err1;
+ }
+
+ // check the font file cache
+ id = new SplashOutFontFileID(gfxFont->getID());
+ if ((fontFile = m_fontEngine->getFontFile(id))) {
+ delete id;
+
+ } else {
+
+ if (!(fontLoc = gfxFont->locateFont(xref, gFalse))) {
+ error(errSyntaxError, -1, "Couldn't find a font for '{0:s}'",
+ gfxFont->getName() ? gfxFont->getName()->getCString()
+ : "(unnamed)");
+ goto err2;
+ }
+
+ // embedded font
+ if (fontLoc->locType == gfxFontLocEmbedded) {
+ // if there is an embedded font, read it to memory
+ tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen);
+ if (! tmpBuf)
+ goto err2;
+
+ // external font
+ } else { // gfxFontLocExternal
+ fileName = fontLoc->path;
+ fontType = fontLoc->fontType;
+ }
+
+ fontsrc = new SplashFontSrc;
+ if (fileName)
+ fontsrc->setFile(fileName, gFalse);
+ else
+ fontsrc->setBuf(tmpBuf, tmpBufLen, gTrue);
+
+ // load the font file
+ switch (fontType) {
+ case fontType1:
+ if (!(fontFile = m_fontEngine->loadType1Font(
+ id,
+ fontsrc,
+ (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {
+ error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
+ gfxFont->getName() ? gfxFont->getName()->getCString()
+ : "(unnamed)");
+ goto err2;
+ }
+ break;
+ case fontType1C:
+ if (!(fontFile = m_fontEngine->loadType1CFont(
+ id,
+ fontsrc,
+ (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {
+ error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
+ gfxFont->getName() ? gfxFont->getName()->getCString()
+ : "(unnamed)");
+ goto err2;
+ }
+ break;
+ case fontType1COT:
+ if (!(fontFile = m_fontEngine->loadOpenTypeT1CFont(
+ id,
+ fontsrc,
+ (const char **)((Gfx8BitFont *)gfxFont)->getEncoding()))) {
+ error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
+ gfxFont->getName() ? gfxFont->getName()->getCString()
+ : "(unnamed)");
+ goto err2;
+ }
+ break;
+ case fontTrueType:
+ case fontTrueTypeOT:
+ if (fileName)
+ ff = FoFiTrueType::load(fileName->getCString());
+ else
+ ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
+ if (ff) {
+ codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff);
+ n = 256;
+ delete ff;
+ } else {
+ codeToGID = NULL;
+ n = 0;
+ }
+ if (!(fontFile = m_fontEngine->loadTrueTypeFont(
+ id,
+ fontsrc,
+ codeToGID, n))) {
+ error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
+ gfxFont->getName() ? gfxFont->getName()->getCString()
+ : "(unnamed)");
+ goto err2;
+ }
+ break;
+ case fontCIDType0:
+ case fontCIDType0C:
+ if (!(fontFile = m_fontEngine->loadCIDFont(
+ id,
+ fontsrc))) {
+ error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
+ gfxFont->getName() ? gfxFont->getName()->getCString()
+ : "(unnamed)");
+ goto err2;
+ }
+ break;
+ case fontCIDType0COT:
+ if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
+ n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
+ codeToGID = (int *)gmallocn(n, sizeof(int));
+ memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
+ n * sizeof(int));
+ } else {
+ codeToGID = NULL;
+ n = 0;
+ }
+ if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont(
+ id,
+ fontsrc,
+ codeToGID, n))) {
+ error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
+ gfxFont->getName() ? gfxFont->getName()->getCString()
+ : "(unnamed)");
+ goto err2;
+ }
+ break;
+ case fontCIDType2:
+ case fontCIDType2OT:
+ codeToGID = NULL;
+ n = 0;
+ if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
+ n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
+ if (n) {
+ codeToGID = (int *)gmallocn(n, sizeof(int));
+ memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
+ n * sizeof(Gushort));
+ }
+ } else {
+ if (fileName)
+ ff = FoFiTrueType::load(fileName->getCString());
+ else
+ ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
+ if (! ff)
+ goto err2;
+ codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
+ delete ff;
+ }
+ if (!(fontFile = m_fontEngine->loadTrueTypeFont(
+ id,
+ fontsrc,
+ codeToGID, n, faceIndex))) {
+ error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
+ gfxFont->getName() ? gfxFont->getName()->getCString()
+ : "(unnamed)");
+ goto err2;
+ }
+ break;
+ default:
+ // this shouldn't happen
+ goto err2;
+ }
+ }
+
+ // get the font matrix
+ textMat = state->getTextMat();
+ fontSize = state->getFontSize();
+ m11 = textMat[0] * fontSize * state->getHorizScaling();
+ m12 = textMat[1] * fontSize * state->getHorizScaling();
+ m21 = textMat[2] * fontSize;
+ m22 = textMat[3] * fontSize;
+ matrix[0] = 1;
+ matrix[1] = 0;
+ matrix[2] = 0;
+ matrix[3] = 1;
+ matrix[4] = 0;
+ matrix[5] = 0;
+// create the scaled font
+ mat[0] = m11;
+ mat[1] = -m12;
+ mat[2] = m21;
+ mat[3] = -m22;
+ m_font = m_fontEngine->getFont(fontFile, mat, matrix);
+
+ delete fontLoc;
+ if (fontsrc && !fontsrc->isFile)
+ fontsrc->unref();
+ return;
+
+ err2:
+ delete id;
+ delete fontLoc;
+ err1:
+ if (fontsrc && !fontsrc->isFile)
+ fontsrc->unref();
+ return;
+}
+#else
void SlaOutputDev::updateFont(GfxState *state)
{
GfxFont *gfxFont;
@@ -1663,6 +1899,7 @@
fontsrc->unref();
return;
}
+#endif
void SlaOutputDev::drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, Unicode *u, int uLen)
{
Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17419&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h Fri Apr 6 08:47:47 2012
@@ -74,7 +74,7 @@
public:
SlaOutputDev(ScribusDoc* doc, QList<PageItem*> *Elements, QStringList *importedColors, int flags);
virtual ~SlaOutputDev();
- void startDoc(XRef *xrefA, Catalog *catA);
+ void startDoc(PDFDoc *doc, XRef *xrefA, Catalog *catA);
GBool isOk() { return gTrue; }
virtual GBool upsideDown() { return gTrue; }
@@ -223,6 +223,7 @@
int pagecount;
int updateGUICounter;
XRef *xref; // xref table for current document
+ PDFDoc *pdfDoc;
Catalog *catalog;
SplashFontEngine *m_fontEngine;
SplashFont *m_font;
More information about the scribus-commit
mailing list