Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ project(deepin-reader
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# XPS支持选项(默认关闭)
option(XPS_SUPPORT "Enable XPS document format support" OFF)
if(XPS_SUPPORT)
message(">>> XPS support enabled")
add_compile_definitions(XPS_SUPPORT_ENABLED)
else()
message(">>> XPS support disabled")
endif()

include(GNUInstallDirs)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
Expand Down
8 changes: 8 additions & 0 deletions deepin_reader.pro
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ CONFIG += ordered

message("Build on host arch: $$QMAKE_HOST.arch")

# XPS支持配置(默认关闭)
# 使用方式:qmake CONFIG+=xps_support 来启用XPS支持
xps_support {
message(">>> XPS support enabled")
DEFINES += XPS_SUPPORT_ENABLED
} else {
message(">>> XPS support disabled")
}

SUBDIRS += htmltopdf

Expand Down
4 changes: 4 additions & 0 deletions reader/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ Application::Application(int &argc, char **argv)
setApplicationVersion(DApplication::buildVersion(APP_VERSION));
setApplicationAcknowledgementPage("https://www.deepin.org/acknowledgments/deepin_reader");
setApplicationDisplayName(tr("Document Viewer"));
#ifdef XPS_SUPPORT_ENABLED
setApplicationDescription(tr("Document Viewer is a tool for reading document files, supporting PDF, DJVU, DOCX, XPS etc."));
#else
setApplicationDescription(tr("Document Viewer is a tool for reading document files, supporting PDF, DJVU, DOCX etc."));
#endif
setProductIcon(QIcon::fromTheme("deepin-reader"));
}

Expand Down
9 changes: 9 additions & 0 deletions reader/app/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ FileType fileType(const QString &filePath)
} else if (mimeType.name() == QLatin1String("image/vnd.djvu") || mimeType.name() == QLatin1String("image/vnd.djvu+multipage")) {
qDebug() << "Matched DJVU file type";
fileType = DJVU;

#ifdef XPS_SUPPORT_ENABLED
} else if (filePath.right(4).toLower() == ".xps") {
qDebug() << "Matched XPS file type by extension";
fileType = XPS;
} else if (mimeType.name() == QLatin1String("application/vnd.ms-xpsdocument")) {
qDebug() << "Matched XPS file type by MIME type";
fileType = XPS;
#endif
} else if (mimeType.name() == QLatin1String("application/zip") && filePath.right(4) == "pptx") {
qDebug() << "Matched PPTX file type";
fileType = PPTX;
Expand Down
5 changes: 4 additions & 1 deletion reader/app/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ enum FileType {
DOCX = 3,
PS = 4,
DOC = 5,
PPTX = 6
PPTX = 6,
#ifdef XPS_SUPPORT_ENABLED
XPS = 7
#endif
};
FileType fileType(const QString &filePath);

Expand Down
8 changes: 8 additions & 0 deletions reader/document/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "Model.h"
#ifdef XPS_SUPPORT_ENABLED
#include "XpsDocument.h"
#endif
#include "PDFModel.h"
#include "DjVuModel.h"
#include "dpdfannot.h"

Check warning on line 11 in reader/document/Model.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "dpdfannot.h" not found.
#include "dpdfpage.h"
#include "dpdfdoc.h"

Expand Down Expand Up @@ -34,6 +37,11 @@
} else if (Dr::DJVU == fileType) {
qDebug() << "Handling DJVU document";
document = deepin_reader::DjVuDocument::loadDocument(filePath, error);
#ifdef XPS_SUPPORT_ENABLED
} else if (Dr::XPS == fileType) {
qDebug() << "Handling XPS document";
document = deepin_reader::XpsDocument::loadDocument(filePath, error);
#endif
} else if (Dr::DOCX == fileType) {
qDebug() << "Starting DOCX document conversion process";
if (nullptr == pprocess) {
Expand Down
Loading