I'm forwarding a patch that I got from upstream and submitted to https://bugs.launchpad.net/ubuntu/+source/calligra/+bug/1980373.
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d098c46a9e..de54f71ed20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -959,6 +959,7 @@ calligra_drop_product_on_bad_condition( FILTER_WPG_TO_ODG calligra_drop_product_on_bad_condition( FILTER_PDF_TO_SVG NOT_WIN "not supported on Windows" PopplerXPDFHeaders_FOUND "poppler xpdf headers not found" + Poppler_FOUND "poppler qt5 headers not found" ) calligra_drop_product_on_bad_condition( FILTER_HTML_TO_ODS diff --git a/filters/karbon/pdf/CMakeLists.txt b/filters/karbon/pdf/CMakeLists.txt index 94d4071da3d..849baa70f12 100644 --- a/filters/karbon/pdf/CMakeLists.txt +++ b/filters/karbon/pdf/CMakeLists.txt @@ -19,7 +19,7 @@ set(pdf2svg_PART_SRCS PdfImportDebug.cpp PdfImport.cpp SvgOutputDev.cpp ) add_library(calligra_filter_pdf2svg MODULE ${pdf2svg_PART_SRCS}) calligra_filter_desktop_to_json(calligra_filter_pdf2svg calligra_filter_pdf2svg.desktop) -target_link_libraries(calligra_filter_pdf2svg komain Poppler::Core) +target_link_libraries(calligra_filter_pdf2svg komain Poppler::Core Poppler::Qt5) install(TARGETS calligra_filter_pdf2svg DESTINATION ${PLUGIN_INSTALL_DIR}/calligra/formatfilters) @@ -29,6 +29,6 @@ set(pdf2odg_PART_SRCS PdfImportDebug.cpp Pdf2OdgImport.cpp SvgOutputDev.cpp) add_library(calligra_filter_pdf2odg MODULE ${pdf2odg_PART_SRCS}) calligra_filter_desktop_to_json(calligra_filter_pdf2odg calligra_filter_pdf2odg.desktop) -target_link_libraries(calligra_filter_pdf2odg kopageapp karbonui Poppler::Core) +target_link_libraries(calligra_filter_pdf2odg kopageapp karbonui Poppler::Core Poppler::Qt5) install(TARGETS calligra_filter_pdf2odg DESTINATION ${PLUGIN_INSTALL_DIR}/calligra/formatfilters) diff --git a/filters/karbon/pdf/Pdf2OdgImport.cpp b/filters/karbon/pdf/Pdf2OdgImport.cpp index f8a24c000b7..d23cc7ae1df 100644 --- a/filters/karbon/pdf/Pdf2OdgImport.cpp +++ b/filters/karbon/pdf/Pdf2OdgImport.cpp @@ -27,6 +27,8 @@ #include <kpluginfactory.h> +#include <poppler-version.h> + // Don't show this warning: it's an issue in poppler #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wunused-parameter" @@ -36,6 +38,8 @@ #include <PDFDoc.h> #include <GlobalParams.h> +#define POPPLER_VERSION_MACRO ((POPPLER_VERSION_MAJOR << 16) | (POPPLER_VERSION_MINOR << 8) | (POPPLER_VERSION_MICRO)) + K_PLUGIN_FACTORY_WITH_JSON(Pdf2OdgImportFactory, "calligra_filter_pdf2odg.json", registerPlugin<Pdf2OdgImport>();) @@ -73,8 +77,13 @@ KoFilter::ConversionStatus Pdf2OdgImport::convert(const QByteArray& from, const if (! globalParams) return KoFilter::NotImplemented; +#if POPPLER_VERSION_MACRO < QT_VERSION_CHECK(22, 03, 0) GooString * fname = new GooString(QFile::encodeName(m_chain->inputFile()).data()); PDFDoc * pdfDoc = new PDFDoc(fname, 0, 0, 0); +#else + std::unique_ptr<GooString> fname = std::make_unique<GooString>(QFile::encodeName(m_chain->inputFile()).data()); + PDFDoc * pdfDoc = new PDFDoc(std::move(fname)); +#endif if (! pdfDoc) { #ifdef HAVE_POPPLER_PRE_0_83 delete globalParams; diff --git a/filters/karbon/pdf/PdfImport.cpp b/filters/karbon/pdf/PdfImport.cpp index 6309caefa8e..3219527b9ef 100644 --- a/filters/karbon/pdf/PdfImport.cpp +++ b/filters/karbon/pdf/PdfImport.cpp @@ -17,6 +17,10 @@ #include <kpluginfactory.h> +#include <poppler-version.h> + +#define POPPLER_VERSION_MACRO ((POPPLER_VERSION_MAJOR << 16) | (POPPLER_VERSION_MINOR << 8) | (POPPLER_VERSION_MICRO)) + // Don't show this warning: it's an issue in poppler #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wunused-parameter" @@ -60,8 +64,13 @@ KoFilter::ConversionStatus PdfImport::convert(const QByteArray& from, const QByt if (! globalParams) return KoFilter::NotImplemented; +#if POPPLER_VERSION_MACRO < QT_VERSION_CHECK(22, 03, 0) GooString * fname = new GooString(QFile::encodeName(m_chain->inputFile()).data()); PDFDoc * pdfDoc = new PDFDoc(fname, 0, 0, 0); +#else + std::unique_ptr<GooString> fname = std::make_unique<GooString>(QFile::encodeName(m_chain->inputFile()).data()); + PDFDoc * pdfDoc = new PDFDoc(std::move(fname)); +#endif if (! pdfDoc) { #ifdef HAVE_POPPLER_PRE_0_83 delete globalParams; diff --git a/filters/karbon/pdf/SvgOutputDev.cpp b/filters/karbon/pdf/SvgOutputDev.cpp index 6c9dddfc661..3a93304c7b8 100644 --- a/filters/karbon/pdf/SvgOutputDev.cpp +++ b/filters/karbon/pdf/SvgOutputDev.cpp @@ -22,6 +22,10 @@ #include <QPen> #include <QImage> +#include <poppler-version.h> + +#define POPPLER_VERSION_MACRO ((POPPLER_VERSION_MAJOR << 16) | (POPPLER_VERSION_MINOR << 8) | (POPPLER_VERSION_MICRO)) + class SvgOutputDev::Private { public: @@ -398,7 +402,12 @@ void SvgOutputDev::drawString(GfxState * state, const GooString * s) if (s->getLength() == 0) return; +#if POPPLER_VERSION_MACRO < QT_VERSION_CHECK(22, 03, 0) GfxFont * font = state->getFont(); +#else + std::shared_ptr<GfxFont> font = state->getFont(); +#endif + QString str;