Skip to content

Commit

Permalink
Remove old PDF Export, clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Butti committed Dec 22, 2018
1 parent f8e1a8c commit 609e096
Show file tree
Hide file tree
Showing 43 changed files with 10 additions and 3,946 deletions.
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ ppa-build
build/
desktop/desktop_install.sh

# Poppler binaries
src/pdf/popplerdirect/libpoppler-glib.a
src/pdf/popplerdirect/libpoppler.a
src/pdf/popplerdirect/poppler-0.24.1_build/
src/pdf/popplerdirect/poppler-config.h
src/pdf/popplerdirect/workaround/workaround.sh

# NetBeans
nbproject/

Expand Down
137 changes: 3 additions & 134 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ endif ()

## Libraries ##

option (ADVANCED_PDF_EXPORT_POPPLER "Export PDF with private Poppler API" OFF)

macro (add_includes_ldflags LDFLAGS INCLUDES)
set (xournalpp_LDFLAGS ${xournalpp_LDFLAGS} ${LDFLAGS})
set (xournalpp_INCLUDE_DIRS ${xournalpp_INCLUDE_DIRS} ${INCLUDES})
Expand Down Expand Up @@ -137,136 +135,9 @@ execute_process(COMMAND ${LSB_RELEASE_EXEC} -rs
# Poppler
option (BUILD_POPPLER "Build Poppler from git or other source" DEFAULT_BUILD_POPPLER)

## Ubuntu 16.04 need a poppler build
if (ADVANCED_PDF_EXPORT_POPPLER AND LSB_RELEASE_ID_SHORT STREQUAL "Ubuntu" AND LSB_RELEASE_NUMBER_SHORT STREQUAL "16.04")
set(BUILD_POPPLER ON)
message ("Automatically set BUILD_POPPLER ON on Ubuntu 16.04")
endif()
## Mac OS X too
if (ADVANCED_PDF_EXPORT_POPPLER AND CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(BUILD_POPPLER ON)
message ("Automatically set BUILD_POPPLER ON on Mac OS")
endif ()

set (POPPLER_MIN_VER "0.58")
set (POPPLER_MAX_VER "0.69")
set (POPPLER_BUILD_FROM "git" CACHE STRING "Source to build poppler from: git (default), tarball, sourcefolder")
set (POPPLER_GIT_VER "0.61.1" CACHE STRING "Version of Poppler to build")
set (POPPLER_SRC_DIR "/path/to/poppler/source" CACHE STRING "Directory with poppler source")
set (POPPLER_SRC_TARXZ "/path/to/poppler.tar.xz" CACHE STRING "Tarball file location")

if (ADVANCED_PDF_EXPORT_POPPLER)
if (BUILD_POPPLER)
# For documentation see https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
set(POPPLER_LIB_DIR ${CMAKE_INSTALL_PREFIX}/bin/xournalpplib)
# RPATH needs to be set *here*, it's set later in the script, it is not used!
SET(CMAKE_INSTALL_RPATH "${POPPLER_LIB_DIR}")

include (ExternalProject)
set (POPPLER_PREFIX "${CMAKE_BINARY_DIR}/poppler-prefix")
set (POPPLER_CMAKE_ARGS "-DBUILD_QT5_TESTS=OFF -DENABLE_UTILS=OFF -DENABLE_QT5=OFF -DENABLE_QT4=OFF -DBUILD_QT4_TESTS=OFF")
if (POPPLER_BUILD_FROM STREQUAL "git")
ExternalProject_Add (poppler
GIT_REPOSITORY "git://git.freedesktop.org/git/poppler/poppler"
GIT_TAG "poppler-${POPPLER_GIT_VER}"
PREFIX "${POPPLER_PREFIX}"

CMAKE_ARGS ${POPPLER_CMAKE_ARGS}
INSTALL_COMMAND ""
)
elseif (POPPLER_BUILD_FROM STREQUAL "sourcefolder")
ExternalProject_Add (poppler
SOURCE_DIR "${POPPLER_SRC_DIR}"
PREFIX "${POPPLER_PREFIX}"

CMAKE_ARGS ${POPPLER_CMAKE_ARGS}
INSTALL_COMMAND ""
)
elseif (POPPLER_BUILD_FROM STREQUAL "tarball")
ExternalProject_Add (poppler
URL "${POPPLER_SRC_TARXZ}"
PREFIX "${POPPLER_PREFIX}"

CMAKE_ARGS ${POPPLER_CMAKE_ARGS}
INSTALL_COMMAND ""
)
else ()
message (FATAL_ERROR "Source to build poppler from must be: git (default), sourcefolder or tarball")
endif()

# Additional packages required by Poppler
find_package (OpenJPEG REQUIRED)
find_package (JPEG REQUIRED)
pkg_check_modules (PopplerLibs REQUIRED "librsvg-2.0 >= 2.14.0" fontconfig)

pkg_check_modules (lcms2 lcms2)
if (lcms2_FOUND)
set (lcms_VERSION 2)
else ()
pkg_check_modules (lcms1 lcms)
if (lcms1_FOUND)
set (lcms_VERSION 1)
else ()
message (FATAL_ERROR "Neither first nor second version of lcms (needed to link with poppler) was found!")
endif ()
endif ()

set (lcms_FOUND ON)
set (lcms_LDFLAGS "${lcms${lcms_VERSION}_LDFLAGS}")
set (lcms_INCLUDE_DIRS "${lcms${lcms_VERSION}_INCLUDE_DIRS}")

link_directories (
"${POPPLER_PREFIX}/src/poppler-build"
"${POPPLER_PREFIX}/src/poppler-build/glib"
"${POPPLER_PREFIX}/src/poppler-build/cpp"
"${POPPLER_PREFIX}/src/poppler-build/utils"
)
set (POPPLER_LIBRARIES
"libpoppler.${LIB_ENDING}"
"libpoppler-cpp.${LIB_ENDING}"
"libpoppler-glib.${LIB_ENDING}"

${OPENJPEG_LIBRARIES}
# Comment out, seems to be a problem on Debian...
# Do we need to detect something to enable / disable?
# -lopenjpeg
${JPEG_LIBRARIES}
${PopplerLibs_LDFLAGS}
${lcms_LDFLAGS}
)
# -lopenjpeg added as fallback

set (POPPLER_INCLUDE_DIRS
"${POPPLER_PREFIX}/src/poppler-build"
"${POPPLER_PREFIX}/src/poppler-build/poppler"
"${POPPLER_PREFIX}/src/poppler-build/glib"
"${POPPLER_PREFIX}/src/poppler-build/cpp"

"${POPPLER_PREFIX}/src/poppler"

${OPENJPEG_INCLUDE_DIRS}
${JPEG_INCLUDE_DIRS}
${PopplerLibs_INCLUDE_DIRS}
${lcms_INCLUDE_DIRS}
)

else ()
find_package (Poppler)
if (NOT POPPLER_FOUND)
message (FATAL_ERROR "Poppler not found – you should enable BUILD_POPPLER CMake flag")
elseif (POPPLER_VERSION VERSION_LESS ${POPPLER_MIN_VER})
message (FATAL_ERROR "Poppler too old - you should enable BUILD_POPPLER CMake flag")
elseif (POPPLER_VERSION VERSION_GREATER ${POPPLER_MAX_VER})
message (FATAL_ERROR "Poppler too new, Xournalpp has not been adapted jet - you should enable BUILD_POPPLER CMake flag")
endif ()
endif ()

add_includes_ldflags ("${POPPLER_LIBRARIES}" "${POPPLER_INCLUDE_DIRS}")
else ()
pkg_check_modules (PopplerGlib REQUIRED "poppler-glib >= 0.41.0")
add_includes_ldflags ("${PopplerGlib_LDFLAGS}" "${PopplerGlib_INCLUDE_DIRS}")
set(POPPLER_INCLUDE_DIR, "${PopplerGlib_INCLUDE_DIRS}")
endif ()
pkg_check_modules (PopplerGlib REQUIRED "poppler-glib >= 0.41.0")
add_includes_ldflags ("${PopplerGlib_LDFLAGS}" "${PopplerGlib_INCLUDE_DIRS}")
set(POPPLER_INCLUDE_DIR, "${PopplerGlib_INCLUDE_DIRS}")

# zlib
find_package (ZLIB REQUIRED)
Expand Down Expand Up @@ -458,8 +329,6 @@ Configuration:
Compiler: ${CMAKE_CXX_COMPILER}
Mathtex enabled: ${ENABLE_MATHTEX}
CppUnit enabled: ${ENABLE_CPPUNIT}
Advanced PDF Export ${ADVANCED_PDF_EXPORT_POPPLER}
(private Poppler API)
Unstable features:
Layers sidebar: ${UNSTABLE_LAYERS_SIDEBAR}
Expand Down
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.

EXCLUDE = src/pdf/popplerdirect/
EXCLUDE =

# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
Expand Down
88 changes: 0 additions & 88 deletions cmake/find/FindPoppler.cmake

This file was deleted.

5 changes: 0 additions & 5 deletions readme/LinuxBuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ make

Use `cmake-gui ..` to see graphically all available options.

With `-DADVANCED_PDF_EXPORT_POPPLER=ON` the internal Poppler API is used, and
PDFs are exported with Bookmarks, but this is only working with some Poppler
Versions.
If not working, add `-DBUILD_POPPLER=ON` to build Poppler manually.

With Cairo 1.16 PDF Bookmarks will be possible, but this Version is not yet
common available, therefore the Cairo PDF Export is without PDF Bookmarks.

Expand Down
28 changes: 6 additions & 22 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
## Build poppler ##

if (ADVANCED_PDF_EXPORT_POPPLER)
add_subdirectory ("pdf/popplerdirect/workaround")
endif ()

## Basic variables ##

include_directories (
Expand Down Expand Up @@ -69,25 +65,13 @@ file (GLOB xournalpp_SOURCES
set (xournalpp_SOURCES ${xournalpp_SOURCES_RECURSE} ${xournalpp_SOURCES})
unset (xournalpp_SOURCES_RECURSE)

if (ADVANCED_PDF_EXPORT_POPPLER)
file (GLOB xournalpp_SOURCES_RECURSE
pdf/popplerdirect/*.cpp
pdf/popplerdirect/cairo/*.cpp
pdf/popplerdirect/poppler/*.cpp
)

# Concatenate SOURCES lists
set (xournalpp_SOURCES ${xournalpp_SOURCES_RECURSE} ${xournalpp_SOURCES})
unset (xournalpp_SOURCES_RECURSE)
else ()
file (GLOB xournalpp_SOURCES_RECURSE
pdf/popplerapi/*.cpp
)
file (GLOB xournalpp_SOURCES_RECURSE
pdf/popplerapi/*.cpp
)

# Concatenate SOURCES lists
set (xournalpp_SOURCES ${xournalpp_SOURCES_RECURSE} ${xournalpp_SOURCES})
unset (xournalpp_SOURCES_RECURSE)
endif ()
# Concatenate SOURCES lists
set (xournalpp_SOURCES ${xournalpp_SOURCES_RECURSE} ${xournalpp_SOURCES})
unset (xournalpp_SOURCES_RECURSE)

list (REMOVE_ITEM xournalpp_SOURCES ${PROJECT_SOURCE_DIR}/src/model/LayerListener.cpp) # TOCHECK

Expand Down
4 changes: 0 additions & 4 deletions src/config-features.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@

/* --- Stable features --- */

/**
* Export PDF with private Poppler API
*/
#cmakedefine ADVANCED_PDF_EXPORT_POPPLER

/**
* Enable Mathtex support
Expand Down
5 changes: 0 additions & 5 deletions src/control/jobs/CustomExportJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,7 @@ void CustomExportJob::run()
pdfe->setNoBackgroundExport(true);
}

#ifdef ADVANCED_PDF_EXPORT_POPPLER
// Not working with ADVANCED_PDF_EXPORT_POPPLER
if (!pdfe->createPdf(this->filename))
#else
if (!pdfe->createPdf(this->filename, exportRange))
#endif
{
this->errorMsg = pdfe->getLastError();
}
Expand Down
13 changes: 0 additions & 13 deletions src/pdf/base/XojPdfDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,16 @@

#include <config-features.h>


#ifdef ADVANCED_PDF_EXPORT_POPPLER
#include "pdf/popplerdirect/poppler/XojPopplerIter.h"
#else
#include "pdf/popplerapi/PopplerGlibDocument.h"
#endif

XojPdfDocument::XojPdfDocument()
#ifdef ADVANCED_PDF_EXPORT_POPPLER
: doc(new XojPopplerDocument())
#else
: doc(new PopplerGlibDocument())
#endif
{
XOJ_INIT_TYPE(XojPdfDocument);
}

XojPdfDocument::XojPdfDocument(const XojPdfDocument& doc)
#ifdef ADVANCED_PDF_EXPORT_POPPLER
: doc(new XojPopplerDocument())
#else
: doc(new PopplerGlibDocument())
#endif
{
XOJ_INIT_TYPE(XojPdfDocument);
}
Expand Down
Loading

0 comments on commit 609e096

Please sign in to comment.