Index: Scribus/scribus/plugins/import/pdf/importpdf.cpp =================================================================== --- Scribus/scribus/plugins/import/pdf/importpdf.cpp (revision 27386) +++ Scribus/scribus/plugins/import/pdf/importpdf.cpp (revision 27389) @@ -79,7 +79,11 @@ bgColor[0] = 255; bgColor[1] = 255; bgColor[2] = 255; +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + SplashOutputDev dev(splashModeXBGR8, 4, bgColor, true); +#else SplashOutputDev dev(splashModeXBGR8, 4, false, bgColor, true); +#endif dev.setVectorAntialias(true); dev.setFreeTypeHinting(true, false); dev.startDoc(&pdfDoc); @@ -154,20 +158,17 @@ } double docWidth = PrefsManager::instance().appPrefs.docSetupPrefs.pageWidth; double docHeight = PrefsManager::instance().appPrefs.docSetupPrefs.pageHeight; - if (!m_interactive || (flags & LoadSavePlugin::lfInsertPage)) + if (m_Doc && (!m_interactive || (flags & LoadSavePlugin::lfInsertPage))) { m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false); m_Doc->addPage(0); m_Doc->view()->addPage(0, true); } - else + else if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc)) { - if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc)) - { - m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, 0, 0, 0, 0, 1, "Custom", true); - ScCore->primaryMainWindow()->HaveNewDoc(); - ret = true; - } + m_Doc = ScCore->primaryMainWindow()->doFileNew(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, 0, 0, 0, 0, 1, "Custom", true); + ScCore->primaryMainWindow()->HaveNewDoc(); + ret = true; } if (ret || !m_interactive) @@ -801,11 +802,15 @@ bgColor[0] = 255; bgColor[1] = 255; bgColor[2] = 255; - SplashOutputDev *dev = new SplashOutputDev(splashModeXBGR8, 4, false, bgColor, true); +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + auto dev = std::make_unique(splashModeXBGR8, 4, bgColor, true); +#else + auto dev = std::make_unique(splashModeXBGR8, 4, false, bgColor, true); +#endif dev->setVectorAntialias(true); dev->setFreeTypeHinting(true, false); dev->startDoc(m_pdfDoc); - m_pdfDoc->displayPage(dev, pgNum, hDPI, vDPI, 0, true, false, false); + m_pdfDoc->displayPage(dev.get(), pgNum, hDPI, vDPI, 0, true, false, false); SplashBitmap *bitmap = dev->getBitmap(); int bw = bitmap->getWidth(); int bh = bitmap->getHeight(); @@ -843,7 +848,6 @@ pp.drawRect(cRect); pp.end(); } - delete dev; return image; } Index: Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp =================================================================== --- Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp (revision 27386) +++ Scribus/scribus/plugins/import/pdf/pdftextrecognition.cpp (revision 27389) @@ -81,7 +81,7 @@ */ PdfGlyph PdfTextRecognition::AddCharCommon(GfxState* state, double x, double y, double dx, double dy, Unicode const* u, int uLen) { - const double * ctm = state->getCTM(); + const auto ctm = state->getCTM(); QTransform trans(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); QPointF charDelta1 = trans.map(QPointF(0.0, 0.0)); QPointF charDelta2 = trans.map(QPointF(dx, dy)); @@ -121,7 +121,7 @@ setCharMode(AddCharMode::ADDBASICCHAR); //only need to be called for the very first point - const double * ctm = state->getCTM(); + const auto ctm = state->getCTM(); QTransform trans(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); QPointF glyphPos = trans.map(QPointF(x, y)); @@ -136,7 +136,7 @@ */ PdfGlyph PdfTextRecognition::AddBasicChar(GfxState* state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, Unicode const* u, int uLen) { - const double * ctm = state->getCTM(); + const auto ctm = state->getCTM(); QTransform trans(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); PdfGlyph newGlyph = AddCharCommon(state, x, y, dx, dy, u, uLen); @@ -461,7 +461,7 @@ */ void PdfTextOutputDev::updateTextPos(GfxState* state) { - const double * ctm = state->getCTM(); + const auto ctm = state->getCTM(); QTransform trans(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); QPointF newPosition = trans.map(QPointF(state->getCurX(), state->getCurY())); Index: Scribus/scribus/plugins/import/pdf/slaoutput.cpp =================================================================== --- Scribus/scribus/plugins/import/pdf/slaoutput.cpp (revision 27386) +++ Scribus/scribus/plugins/import/pdf/slaoutput.cpp (revision 27389) @@ -1535,7 +1535,7 @@ void SlaOutputDev::adjustClip(GfxState *state, Qt::FillRule fillRule) { - const double *ctm = state->getCTM(); + const auto ctm = state->getCTM(); m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); QString output = convertPath(state->getPath()); if (output.isEmpty()) @@ -1563,7 +1563,7 @@ void SlaOutputDev::stroke(GfxState *state) { // qDebug() << "Stroke"; - const double *ctm = state->getCTM(); + const auto ctm = state->getCTM(); m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); double xCoor = m_doc->currentPage()->xOffset(); double yCoor = m_doc->currentPage()->yOffset(); @@ -1671,8 +1671,7 @@ void SlaOutputDev::createFillItem(GfxState *state, Qt::FillRule fillRule) { - const double *ctm; - ctm = state->getCTM(); + const auto ctm = state->getCTM(); m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); double xCoor = m_doc->currentPage()->xOffset(); double yCoor = m_doc->currentPage()->yOffset(); @@ -1799,7 +1798,7 @@ out = intersection(m_graphicStack.top().clipPath, out); crect = out.boundingRect(); } - const double *ctm = state->getCTM(); + const auto ctm = state->getCTM(); m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); FPointArray gr; gr.addPoint(GrStartX, GrStartY); @@ -1938,7 +1937,7 @@ double GrFocalY = y1; GrEndX = GrFocalX + r1; GrEndY = GrFocalY; - const double *ctm = state->getCTM(); + const auto ctm = state->getCTM(); m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); FPointArray gr; gr.addPoint(GrStartX, GrStartY); @@ -2023,7 +2022,7 @@ output += QString("Z"); m_pathIsClosed = true; m_coords = output; - const double *ctm = state->getCTM(); + const auto ctm = state->getCTM(); m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); const auto& graphicState = m_graphicStack.top(); int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, graphicState.fillColor, CommonStrings::None); @@ -2104,7 +2103,7 @@ output += QString("Z"); m_pathIsClosed = true; m_coords = output; - const double *ctm = state->getCTM(); + const auto ctm = state->getCTM(); m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); const auto& graphicState = m_graphicStack.top(); int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, graphicState.fillColor, CommonStrings::None); @@ -2265,7 +2264,7 @@ box.x2 = bbox[2]; box.y2 = bbox[3]; - const double *ctm = state->getCTM(); + const auto ctm = state->getCTM(); m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); QTransform mm(mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]); QTransform mmx = mm * m_ctm; @@ -2712,7 +2711,7 @@ void SlaOutputDev::createImageFrame(QImage& image, GfxState *state, int numColorComponents) { // qDebug() << "SlaOutputDev::createImageFrame"; - const double *ctm = state->getCTM(); + const auto ctm = state->getCTM(); double xCoor = m_doc->currentPage()->xOffset(); double yCoor = m_doc->currentPage()->yOffset(); @@ -3002,8 +3001,16 @@ #else SlaOutFontFileID *id; #endif - SplashFontFile *fontFile; +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + std::shared_ptr fontFile; +#else + SplashFontFile *fontFile = nullptr; +#endif +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + std::unique_ptr fontsrc; +#else SplashFontSrc *fontsrc = nullptr; +#endif Object refObj, strObj; #if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(25, 2, 0) std::vector codeToGID; @@ -3010,7 +3017,11 @@ #else int *codeToGID = nullptr; #endif +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + std::array textMat; +#else const double *textMat = nullptr; +#endif double m11, m12, m21, m22, fontSize; #if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 1, 0) std::array mat = { 1.0, 0.0, 0.0, 1.0 }; @@ -3070,16 +3081,29 @@ fontType = fontLoc->fontType; } +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + if (!fileName.empty()) + fontsrc = std::make_unique(fileName); + else + fontsrc = std::make_unique(std::move(tmpBuf.value())); +#else fontsrc = new SplashFontSrc; if (!fileName.empty()) fontsrc->setFile(fileName); else fontsrc->setBuf(std::move(tmpBuf.value())); +#endif // load the font file switch (fontType) { case fontType1: -#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 11, 0) +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + if (!(fontFile = m_fontEngine->loadType1Font(std::move(id), std::move(fontsrc), (const char**) ((Gfx8BitFont*) gfxFont)->getEncoding(), fontLoc->fontNum))) + { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); + goto err2; + } +#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 11, 0) if (!(fontFile = m_fontEngine->loadType1Font(std::move(id), fontsrc, (const char**) ((Gfx8BitFont*) gfxFont)->getEncoding(), fontLoc->fontNum))) { error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); @@ -3094,7 +3118,13 @@ #endif break; case fontType1C: -#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 11, 0) +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + if (!(fontFile = m_fontEngine->loadType1CFont(std::move(id), std::move(fontsrc), (const char**) ((Gfx8BitFont*) gfxFont)->getEncoding(), fontLoc->fontNum))) + { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); + goto err2; + } +#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 11, 0) if (!(fontFile = m_fontEngine->loadType1CFont(std::move(id), fontsrc, (const char**) ((Gfx8BitFont*) gfxFont)->getEncoding(), fontLoc->fontNum))) { error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); @@ -3109,7 +3139,13 @@ #endif break; case fontType1COT: -#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 11, 0) +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + if (!(fontFile = m_fontEngine->loadOpenTypeT1CFont(std::move(id), std::move(fontsrc), (const char**) ((Gfx8BitFont*) gfxFont)->getEncoding(), fontLoc->fontNum))) + { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); + goto err2; + } +#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 11, 0) if (!(fontFile = m_fontEngine->loadOpenTypeT1CFont(std::move(id), fontsrc, (const char **)((Gfx8BitFont *) gfxFont)->getEncoding(), fontLoc->fontNum))) { error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); @@ -3125,10 +3161,15 @@ break; case fontTrueType: case fontTrueTypeOT: -#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(25, 7, 0) +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) if (!fileName.empty()) ff = FoFiTrueType::load(fileName.c_str(), fontLoc->fontNum); else + ff = FoFiTrueType::make(fontsrc->buf(), fontLoc->fontNum); +#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(25, 7, 0) + if (!fileName.empty()) + ff = FoFiTrueType::load(fileName.c_str(), fontLoc->fontNum); + else ff = FoFiTrueType::make(fontsrc->buf, fontLoc->fontNum); #elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 11, 0) if (!fileName.empty()) @@ -3156,7 +3197,13 @@ #endif n = 0; } -#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(25, 2, 0) +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + if (!(fontFile = m_fontEngine->loadTrueTypeFont(std::move(id), std::move(fontsrc), std::move(codeToGID), fontLoc->fontNum))) + { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); + goto err2; + } +#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(25, 2, 0) if (!(fontFile = m_fontEngine->loadTrueTypeFont(std::move(id), fontsrc, std::move(codeToGID), fontLoc->fontNum))) { error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); @@ -3178,7 +3225,13 @@ break; case fontCIDType0: case fontCIDType0C: -#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 11, 0) +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + if (!(fontFile = m_fontEngine->loadCIDFont(std::move(id), std::move(fontsrc), fontLoc->fontNum))) + { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); + goto err2; + } +#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 11, 0) if (!(fontFile = m_fontEngine->loadCIDFont(std::move(id), fontsrc, fontLoc->fontNum))) { error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); @@ -3217,7 +3270,14 @@ n = 0; } #endif -#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(25, 2, 0) +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont(std::move(id), std::move(fontsrc), std::move(codeToGID), fontLoc->fontNum))) + { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", + gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); + goto err2; + } +#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(25, 2, 0) if (!(fontFile = m_fontEngine->loadOpenTypeCFFFont(std::move(id), fontsrc, std::move(codeToGID), fontLoc->fontNum))) { error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", @@ -3265,10 +3325,15 @@ #endif else { -#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(25, 7, 0) +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) if (!fileName.empty()) ff = FoFiTrueType::load(fileName.c_str(), fontLoc->fontNum); else + ff = FoFiTrueType::make(fontsrc->buf(), fontLoc->fontNum); +#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(25, 7, 0) + if (!fileName.empty()) + ff = FoFiTrueType::load(fileName.c_str(), fontLoc->fontNum); + else ff = FoFiTrueType::make(fontsrc->buf, fontLoc->fontNum); #elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(24, 11, 0) if (!fileName.empty()) @@ -3290,7 +3355,13 @@ #endif ff.reset(); } -#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(25, 2, 0) +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + if (!(fontFile = m_fontEngine->loadTrueTypeFont(std::move(id), std::move(fontsrc), std::move(codeToGID), fontLoc->fontNum))) + { + error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); + goto err2; + } +#elif POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(25, 2, 0) if (!(fontFile = m_fontEngine->loadTrueTypeFont(std::move(id), fontsrc, std::move(codeToGID), fontLoc->fontNum))) { error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'", gfxFont->getName() ? gfxFont->getName()->c_str() : "(unnamed)"); @@ -3335,8 +3406,10 @@ mat[3] = -m22; m_font = m_fontEngine->getFont(fontFile, mat, matrix); +#if POPPLER_ENCODED_VERSION < POPPLER_VERSION_ENCODE(26, 2, 0) if (fontsrc && !fontsrc->isFile) fontsrc->unref(); +#endif return; err2: @@ -3347,8 +3420,12 @@ #endif err1: +#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(26, 2, 0) + fontsrc.reset(); +#else if (fontsrc && !fontsrc->isFile) fontsrc->unref(); +#endif } void SlaOutputDev::drawChar(GfxState* state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, const Unicode* u, int uLen) @@ -3402,7 +3479,7 @@ if (f & splashPathLast) qPath.closeSubpath(); } - const double * ctm = state->getCTM(); + const auto ctm = state->getCTM(); m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]); double xCoor = m_doc->currentPage()->xOffset(); double yCoor = m_doc->currentPage()->yOffset();