diff --git a/CMakeLists.txt b/CMakeLists.txt
index e3e484596..884230760 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,470 +1,471 @@
cmake_minimum_required(VERSION 3.0)
# KDE Application Version, managed by release script
set (KDE_APPLICATIONS_VERSION_MAJOR "18")
set (KDE_APPLICATIONS_VERSION_MINOR "11")
set (KDE_APPLICATIONS_VERSION_MICRO "70")
set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}")
project(okular VERSION 1.5.${KDE_APPLICATIONS_VERSION_MICRO})
set(QT_REQUIRED_VERSION "5.8.0")
set(KF5_REQUIRED_VERSION "5.33.0")
find_package(ECM 5.33.0 CONFIG REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
include(ECMInstallIcons)
include(ECMSetupVersion)
include(ECMOptionalAddSubdirectory)
include(GenerateExportHeader)
include(FeatureSummary)
include(ECMAddAppIcon)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(ECMAddTests)
include(ECMAddAppIcon)
include(CMakePackageConfigHelpers)
ecm_setup_version(${PROJECT_VERSION}
VARIABLE_PREFIX OKULAR
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/core/version.h"
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/Okular5ConfigVersion.cmake")
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED COMPONENTS Core DBus Test Widgets PrintSupport Svg Qml Quick)
find_package(Qt5 ${QT_REQUIRED_VERSION} OPTIONAL_COMPONENTS TextToSpeech)
if (NOT Qt5TextToSpeech_FOUND)
message(STATUS "Qt5TextToSpeech not found, speech features will be disabled")
else()
add_definitions(-DHAVE_SPEECH)
endif()
if(NOT CMAKE_VERSION VERSION_LESS "3.10.0")
# CMake 3.9+ warns about automoc on files without Q_OBJECT, and doesn't know about other macros.
# 3.10+ lets us provide more macro names that require automoc.
list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "OKULAR_EXPORT_PLUGIN")
endif()
set(optionalComponents)
if (ANDROID)
# we want to make sure that generally all components are found
set(optionalComponents "OPTIONAL_COMPONENTS")
endif()
find_package(KF5 ${KF5_REQUIRED_VERSION} REQUIRED COMPONENTS
Archive
Bookmarks
Completion
Config
ConfigWidgets
CoreAddons
Crash
IconThemes
KIO
Parts
ThreadWeaver
WindowSystem
${optionalComponents}
DocTools
JS
Wallet
)
if(KF5Wallet_FOUND)
add_definitions(-DWITH_KWALLET=1)
endif()
if(KF5JS_FOUND)
add_definitions(-DWITH_KJS=1)
endif()
if(NOT WIN32 AND NOT ANDROID)
find_package(KF5 ${KF5_REQUIRED_VERSION} REQUIRED COMPONENTS
Activities
)
set_package_properties("KF5Activities" PROPERTIES
DESCRIPTION "Activities interface library"
URL "https://api.kde.org/frameworks/kactivities/html/"
TYPE RECOMMENDED
PURPOSE "Required for Activities integration.")
endif()
find_package(KF5Kirigami2)
set_package_properties(KF5Kirigami2 PROPERTIES
DESCRIPTION "A QtQuick based components set"
PURPOSE "Required at runtime by the mobile app"
TYPE RUNTIME
)
find_package(Phonon4Qt5 CONFIG REQUIRED)
find_package(KDEExperimentalPurpose)
set_package_properties(KDEExperimentalPurpose PROPERTIES
DESCRIPTION "A framework for services and actions integration"
PURPOSE "Required for enabling the share menu in Okular"
TYPE OPTIONAL
)
if (KDEExperimentalPurpose_FOUND)
set(PURPOSE_FOUND 1)
else()
set(PURPOSE_FOUND 0)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules)
find_package(ZLIB REQUIRED)
# This is here instead of in generators since we use if(Poppler_Qt5_FOUND) in autotests/
find_package(Poppler "0.12.1" COMPONENTS Qt5)
set_package_properties("Poppler" PROPERTIES
TYPE RECOMMENDED
PURPOSE "Support for PDF files in okular.")
add_definitions(-DQT_USE_FAST_OPERATOR_PLUS)
add_definitions(-DTRANSLATION_DOMAIN="okular")
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${PHONON_INCLUDES} core/synctex ${ZLIB_INCLUDE_DIR} ${CMAKE_BINARY_DIR}/core)
option(BUILD_OKULARKIRIGAMI "Builds the touch-friendly frontend" ON)
if (BUILD_OKULARKIRIGAMI)
add_subdirectory( mobile )
endif()
option(BUILD_COVERAGE "Build the project with gcov support" OFF)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0.0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override" )
endif()
endif()
if(BUILD_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov")
endif()
add_subdirectory( ui )
add_subdirectory( shell )
add_subdirectory( generators )
if(BUILD_TESTING)
add_subdirectory( autotests )
add_subdirectory( conf/autotests )
endif()
if(KF5DocTools_FOUND)
add_subdirectory(doc)
endif()
include(OkularConfigureChecks.cmake)
if(NOT WIN32)
set(MATH_LIB m)
else(NOT WIN32)
set(MATH_LIB)
endif(NOT WIN32)
# okularcore
set(okularcore_SRCS
core/action.cpp
core/annotations.cpp
core/area.cpp
core/audioplayer.cpp
core/bookmarkmanager.cpp
core/chooseenginedialog.cpp
core/document.cpp
core/documentcommands.cpp
core/fontinfo.cpp
core/form.cpp
core/generator.cpp
core/generator_p.cpp
core/misc.cpp
core/movie.cpp
core/observer.cpp
core/debug.cpp
core/page.cpp
core/pagecontroller.cpp
core/pagesize.cpp
core/pagetransition.cpp
core/rotationjob.cpp
core/scripter.cpp
core/sound.cpp
core/sourcereference.cpp
core/textdocumentgenerator.cpp
core/textdocumentsettings.cpp
core/textpage.cpp
core/tilesmanager.cpp
core/utils.cpp
core/view.cpp
core/fileprinter.cpp
+ core/signatureutils.cpp
core/script/event.cpp
core/synctex/synctex_parser.c
core/synctex/synctex_parser_utils.c
)
qt5_add_resources(okularcore_SRCS
core/script/builtin.qrc
)
ki18n_wrap_ui(okularcore_SRCS
conf/textdocumentsettings.ui
)
install( FILES
core/action.h
core/annotations.h
core/area.h
core/document.h
core/fontinfo.h
core/form.h
core/generator.h
core/global.h
core/page.h
core/pagesize.h
core/pagetransition.h
core/sound.h
core/sourcereference.h
core/textdocumentgenerator.h
core/textdocumentsettings.h
core/textpage.h
core/tile.h
core/utils.h
core/fileprinter.h
core/observer.h
${CMAKE_CURRENT_BINARY_DIR}/core/version.h
${CMAKE_CURRENT_BINARY_DIR}/core/okularcore_export.h
${CMAKE_CURRENT_BINARY_DIR}/settings_core.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR}/okular/core COMPONENT Devel)
install( FILES
interfaces/configinterface.h
interfaces/guiinterface.h
interfaces/printinterface.h
interfaces/saveinterface.h
interfaces/viewerinterface.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR}/okular/interfaces COMPONENT Devel)
ki18n_wrap_ui(okularcore_SRCS
core/chooseenginewidget.ui
)
kconfig_add_kcfg_files(okularcore_SRCS conf/settings_core.kcfgc)
add_library(okularcore SHARED ${okularcore_SRCS})
generate_export_header(okularcore BASE_NAME okularcore EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/core/okularcore_export.h")
if (ANDROID)
set(fileName ${CMAKE_BINARY_DIR}/Okular5Core-android-dependencies.xml)
file(WRITE "${fileName}" "\n"
"\n"
"\n")
install(FILES ${fileName} DESTINATION ${KDE_INSTALL_LIBDIR})
endif()
# Special handling for linking okularcore on OSX/Apple
IF(APPLE)
SET(OKULAR_IOKIT "-framework IOKit" CACHE STRING "Apple IOKit framework")
ENDIF(APPLE)
# Extra library needed by imported synctex code on Windows
if(WIN32)
set(SHLWAPI shlwapi)
endif(WIN32)
target_link_libraries(okularcore
PRIVATE
${OKULAR_IOKIT}
${SHLWAPI}
KF5::Archive
KF5::KIOCore
KF5::KIOWidgets
KF5::I18n
KF5::ThreadWeaver
KF5::Bookmarks
Phonon::phonon4qt5
${MATH_LIB}
${ZLIB_LIBRARIES}
PUBLIC # these are included from the installed headers
KF5::CoreAddons
KF5::XmlGui
KF5::ConfigGui
Qt5::PrintSupport
Qt5::Widgets
)
if (KF5Wallet_FOUND)
target_link_libraries(okularcore PRIVATE KF5::Wallet)
endif()
if (KF5JS_FOUND)
target_sources(okularcore PRIVATE
core/script/executor_kjs.cpp
core/script/kjs_app.cpp
core/script/kjs_console.cpp
core/script/kjs_data.cpp
core/script/kjs_document.cpp
core/script/kjs_field.cpp
core/script/kjs_fullscreen.cpp
core/script/kjs_field.cpp
core/script/kjs_spell.cpp
core/script/kjs_util.cpp
core/script/kjs_event.cpp
)
target_link_libraries(okularcore PRIVATE KF5::JS KF5::JSApi)
endif()
set_target_properties(okularcore PROPERTIES VERSION 9.0.0 SOVERSION 9 OUTPUT_NAME Okular5Core EXPORT_NAME Core)
install(TARGETS okularcore EXPORT Okular5Targets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES conf/okular.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
install(FILES conf/okular_core.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
install(FILES core/okularGenerator.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR})
# okularpart
set(okularpart_conf_SRCS
conf/preferencesdialog.cpp
conf/dlgaccessibility.cpp
conf/dlgdebug.cpp
conf/dlgeditor.cpp
conf/dlggeneral.cpp
conf/dlgannotations.cpp
conf/dlgperformance.cpp
conf/dlgpresentation.cpp
conf/editannottooldialog.cpp
conf/editdrawingtooldialog.cpp
conf/widgetannottools.cpp
conf/widgetconfigurationtoolsbase.cpp
conf/widgetdrawingtools.cpp
)
set(okularpart_SRCS
${okularpart_conf_SRCS}
part.cpp
extensions.cpp
ui/embeddedfilesdialog.cpp
ui/annotwindow.cpp
ui/annotationmodel.cpp
ui/annotationpopup.cpp
ui/annotationpropertiesdialog.cpp
ui/annotationproxymodels.cpp
ui/annotationtools.cpp
ui/annotationwidgets.cpp
ui/bookmarklist.cpp
ui/debug_ui.cpp
ui/drawingtoolactions.cpp
ui/fileprinterpreview.cpp
ui/findbar.cpp
ui/formwidgets.cpp
ui/guiutils.cpp
ui/ktreeviewsearchline.cpp
ui/latexrenderer.cpp
ui/minibar.cpp
ui/okmenutitle.cpp
ui/pageitemdelegate.cpp
ui/pagepainter.cpp
ui/pagesizelabel.cpp
ui/pageviewannotator.cpp
ui/pageviewmouseannotation.cpp
ui/pageview.cpp
ui/magnifierview.cpp
ui/pageviewutils.cpp
ui/presentationsearchbar.cpp
ui/presentationwidget.cpp
ui/propertiesdialog.cpp
ui/searchlineedit.cpp
ui/searchwidget.cpp
ui/sidebar.cpp
ui/side_reviews.cpp
ui/snapshottaker.cpp
ui/thumbnaillist.cpp
ui/toc.cpp
ui/tocmodel.cpp
ui/toolaction.cpp
ui/videowidget.cpp
ui/layers.cpp
)
if (Qt5TextToSpeech_FOUND)
set(okularpart_SRCS ${okularpart_SRCS}
ui/tts.cpp)
endif()
ki18n_wrap_ui(okularpart_SRCS
conf/dlgaccessibilitybase.ui
conf/dlgeditorbase.ui
conf/dlggeneralbase.ui
conf/dlgannotationsbase.ui
conf/dlgperformancebase.ui
conf/dlgpresentationbase.ui
)
kconfig_add_kcfg_files(okularpart_SRCS conf/settings.kcfgc)
add_library(okularpart SHARED ${okularpart_SRCS})
generate_export_header(okularpart BASE_NAME okularpart)
target_link_libraries(okularpart okularcore
${MATH_LIB}
Qt5::Svg
Phonon::phonon4qt5
KF5::Archive
KF5::Bookmarks
KF5::I18n
KF5::IconThemes
KF5::ItemViews
KF5::KIOCore
KF5::KIOFileWidgets
KF5::KIOWidgets
KF5::Parts
KF5::Solid
KF5::WindowSystem
)
if(KF5Wallet_FOUND)
target_link_libraries(okularpart KF5::Wallet)
endif()
if (KDEExperimentalPurpose_FOUND)
target_link_libraries(okularpart KDEExperimental::PurposeWidgets)
endif()
set_target_properties(okularpart PROPERTIES PREFIX "")
if (Qt5TextToSpeech_FOUND)
target_link_libraries(okularpart Qt5::TextToSpeech)
endif()
install(TARGETS okularpart DESTINATION ${KDE_INSTALL_PLUGINDIR})
########### install files ###############
install(FILES okular.upd DESTINATION ${KDE_INSTALL_DATADIR}/kconf_update)
install( FILES okular_part.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )
install( FILES part.rc part-viewermode.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/okular )
install( FILES okular.categories DESTINATION ${KDE_INSTALL_CONFDIR} )
########### cmake files #################
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/Okular5")
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/Okular5Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/Okular5Config.cmake"
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
PATH_VARS INCLUDE_INSTALL_DIR CMAKE_INSTALL_PREFIX
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/Okular5Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/Okular5ConfigVersion.cmake"
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
COMPONENT Devel
)
install(EXPORT Okular5Targets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE Okular5Targets.cmake NAMESPACE Okular::)
########### summary #################
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
diff --git a/core/form.cpp b/core/form.cpp
index 2071da0f2..4781c6eaa 100644
--- a/core/form.cpp
+++ b/core/form.cpp
@@ -1,296 +1,325 @@
/***************************************************************************
* Copyright (C) 2007 by Pino Toscano *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "form.h"
#include "form_p.h"
// qt includes
#include
#include "action.h"
using namespace Okular;
FormFieldPrivate::FormFieldPrivate( FormField::FieldType type )
: m_type( type ), m_activateAction( nullptr )
{
}
FormFieldPrivate::~FormFieldPrivate()
{
delete m_activateAction;
qDeleteAll( m_additionalActions.values() );
qDeleteAll( m_additionalAnnotActions.values() );
}
void FormFieldPrivate::setDefault()
{
m_default = value();
}
FormField::FormField( FormFieldPrivate &dd )
: d_ptr( &dd )
{
d_ptr->q_ptr = this;
}
FormField::~FormField()
{
delete d_ptr;
}
FormField::FieldType FormField::type() const
{
Q_D( const FormField );
return d->m_type;
}
bool FormField::isReadOnly() const
{
return false;
}
void FormField::setReadOnly( bool )
{
}
bool FormField::isVisible() const
{
return true;
}
void FormField::setVisible( bool )
{
}
Action* FormField::activationAction() const
{
Q_D( const FormField );
return d->m_activateAction;
}
void FormField::setActivationAction( Action *action )
{
Q_D( FormField );
delete d->m_activateAction;
d->m_activateAction = action;
}
Action* FormField::additionalAction( AdditionalActionType type ) const
{
Q_D( const FormField );
return d->m_additionalActions.value(type);
}
void FormField::setAdditionalAction( AdditionalActionType type, Action *action )
{
Q_D( FormField );
delete d->m_additionalActions.value(type);
d->m_additionalActions[type] = action;
}
Action* FormField::additionalAction( Annotation::AdditionalActionType type ) const
{
Q_D( const FormField );
return d->m_additionalAnnotActions.value(type);
}
void FormField::setAdditionalAction( Annotation::AdditionalActionType type, Action *action )
{
Q_D( FormField );
delete d->m_additionalAnnotActions.value(type);
d->m_additionalAnnotActions[type] = action;
}
class Okular::FormFieldButtonPrivate : public Okular::FormFieldPrivate
{
public:
FormFieldButtonPrivate()
: FormFieldPrivate( FormField::FormButton )
{
}
Q_DECLARE_PUBLIC( FormFieldButton )
void setValue( const QString& v ) override
{
Q_Q( FormFieldButton );
q->setState( QVariant( v ).toBool() );
}
QString value() const override
{
Q_Q( const FormFieldButton );
return qVariantFromValue( q->state() ).toString();
}
};
FormFieldButton::FormFieldButton()
: FormField( *new FormFieldButtonPrivate() )
{
}
FormFieldButton::~FormFieldButton()
{
}
void FormFieldButton::setState( bool )
{
}
class Okular::FormFieldTextPrivate : public Okular::FormFieldPrivate
{
public:
FormFieldTextPrivate()
: FormFieldPrivate( FormField::FormText )
{
}
Q_DECLARE_PUBLIC( FormFieldText )
void setValue( const QString& v ) override
{
Q_Q( FormFieldText );
q->setText( v );
}
QString value() const override
{
Q_Q( const FormFieldText );
return q->text();
}
};
FormFieldText::FormFieldText()
: FormField( *new FormFieldTextPrivate() )
{
}
FormFieldText::~FormFieldText()
{
}
void FormFieldText::setText( const QString& )
{
}
bool FormFieldText::isPassword() const
{
return false;
}
bool FormFieldText::isRichText() const
{
return false;
}
int FormFieldText::maximumLength() const
{
return -1;
}
Qt::Alignment FormFieldText::textAlignment() const
{
return Qt::AlignVCenter | Qt::AlignLeft;
}
bool FormFieldText::canBeSpellChecked() const
{
return false;
}
class Okular::FormFieldChoicePrivate : public Okular::FormFieldPrivate
{
public:
FormFieldChoicePrivate()
: FormFieldPrivate( FormField::FormChoice )
{
}
Q_DECLARE_PUBLIC( FormFieldChoice )
void setValue( const QString& v ) override
{
Q_Q( FormFieldChoice );
QStringList choices = v.split( QLatin1Char (';'), QString::SkipEmptyParts );
QList newchoices;
foreach ( const QString& str, choices )
{
bool ok = true;
int val = str.toInt( &ok );
if ( ok )
newchoices.append( val );
}
if ( !newchoices.isEmpty() )
q->setCurrentChoices( newchoices );
}
QString value() const override
{
Q_Q( const FormFieldChoice );
QList choices = q->currentChoices();
qSort( choices );
QStringList list;
foreach ( int c, choices )
{
list.append( QString::number( c ) );
}
return list.join( QStringLiteral( ";" ) );
}
};
FormFieldChoice::FormFieldChoice()
: FormField( *new FormFieldChoicePrivate() )
{
}
FormFieldChoice::~FormFieldChoice()
{
}
bool FormFieldChoice::isEditable() const
{
return false;
}
bool FormFieldChoice::multiSelect() const
{
return false;
}
void FormFieldChoice::setCurrentChoices( const QList< int >& )
{
}
QString FormFieldChoice::editChoice() const
{
return QString();
}
void FormFieldChoice::setEditChoice( const QString& )
{
}
Qt::Alignment FormFieldChoice::textAlignment() const
{
return Qt::AlignVCenter | Qt::AlignLeft;
}
bool FormFieldChoice::canBeSpellChecked() const
{
return false;
}
+class Okular::FormFieldSignaturePrivate : public Okular::FormFieldPrivate
+{
+ public:
+ FormFieldSignaturePrivate()
+ : FormFieldPrivate( FormField::FormSignature )
+ {
+ }
+
+ Q_DECLARE_PUBLIC( FormFieldSignature )
+
+ void setValue( const QString& v ) override
+ {
+ Q_UNUSED( v )
+ }
+
+ QString value() const override
+ {
+ return QString();
+ }
+};
+
+FormFieldSignature::FormFieldSignature()
+ : FormField( *new FormFieldSignaturePrivate() )
+{
+}
+
+FormFieldSignature::~FormFieldSignature()
+{
+}
diff --git a/core/form.h b/core/form.h
index bcc41de43..5ccbee2d4 100644
--- a/core/form.h
+++ b/core/form.h
@@ -1,392 +1,433 @@
/***************************************************************************
* Copyright (C) 2007 by Pino Toscano *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef _OKULAR_FORM_H_
#define _OKULAR_FORM_H_
#include "okularcore_export.h"
#include "area.h"
#include "annotations.h"
-
+#include "signatureutils.h"
#include
namespace Okular {
class Action;
class Page;
class PagePrivate;
class FormFieldPrivate;
class FormFieldButtonPrivate;
class FormFieldTextPrivate;
class FormFieldChoicePrivate;
+class FormFieldSignaturePrivate;
/**
* @short The base interface of a form field.
*
* This is the very basic interface to represent a field in a form.
*
* This is not meant to be used as a direct base for the form fields in a
* document, but its abstract subclasses are.
*/
class OKULARCORE_EXPORT FormField
{
/// @cond PRIVATE
friend class Page;
friend class PagePrivate;
/// @endcond
public:
/**
* The types of form field.
*/
enum FieldType
{
FormButton, ///< A "button". See @ref FormFieldButton::ButtonType.
FormText, ///< A field of variable text. See @ref FormFieldText::TextType.
FormChoice, ///< A choice field. See @ref FormFieldChoice::ChoiceType.
FormSignature ///< A signature.
};
virtual ~FormField();
/**
* The type of the field.
*/
FieldType type() const;
/**
* The bouding rect of the field, in normalized coordinates.
*/
virtual NormalizedRect rect() const = 0;
/**
* The ID of the field.
*/
virtual int id() const = 0;
/**
* The internal name of the field, to be used when referring to the
* field in eg scripts.
*/
virtual QString name() const = 0;
/**
* The visible name of the field, to be used in the user interface
* (eg in error messages, etc).
*/
virtual QString uiName() const = 0;
/**
* Whether the field is read-only.
*/
virtual bool isReadOnly() const;
/**
* Whether the field is read-only.
*
* @since 1.4
*/
virtual void setReadOnly( bool value );
/**
* Whether this form field is visible.
*/
virtual bool isVisible() const;
/**
* Whether the field is visible.
*
* @since 1.5
*/
virtual void setVisible( bool value );
Action* activationAction() const;
/**
* Describes the type of form additional action.
*
* @since 1.1
*/
enum AdditionalActionType
{
FieldModified, ///< An action to be performed when the user modifies the field
FormatField, ///< An action to be performed before the field is formatted to display its value
ValidateField, ///< An action to be performed when the field value changes
CalculateField, ///< An action to be performed when the field needs to be recalculated
};
/**
* Returns the additional action of the given @p type or @c nullptr if no action has been defined.
*
* @since 1.1
*/
Action* additionalAction( AdditionalActionType type ) const;
/* Returns the additional action of the given @p type or @c nullptr if no action has been defined.
*
* This is for actions of annotation widgets associated with the FormField
*
* @since 1.5
*/
Action* additionalAction( Annotation::AdditionalActionType type ) const;
protected:
/// @cond PRIVATE
FormField( FormFieldPrivate &dd );
Q_DECLARE_PRIVATE( FormField )
FormFieldPrivate *d_ptr;
/// @endcond
void setActivationAction( Action *action );
void setAdditionalAction( AdditionalActionType type, Action *action );
void setAdditionalAction( Annotation::AdditionalActionType type, Action *action );
private:
Q_DISABLE_COPY( FormField )
};
/**
* @short Interface of a button form field.
*
* This is the base interface to reimplement to represent a button field, like
* a push button, a check box or a radio button.
*
* @since 0.7 (KDE 4.1)
*/
class OKULARCORE_EXPORT FormFieldButton : public FormField
{
public:
/**
* The types of button field.
*/
enum ButtonType
{
Push, ///< A simple push button.
CheckBox, ///< A check box.
Radio ///< A radio button.
};
virtual ~FormFieldButton();
/**
The particular type of the button field.
*/
virtual ButtonType buttonType() const = 0;
/**
* The caption to be used for the button.
*/
virtual QString caption() const = 0;
/**
* The state of the button.
*/
virtual bool state() const = 0;
/**
* Sets the state of the button to the new \p state .
*/
virtual void setState( bool state );
/**
* The list with the IDs of siblings (ie, buttons belonging to the same
* group as the current one.
*
* Valid only for \ref Radio buttons, an empty list otherwise.
*/
virtual QList< int > siblings() const = 0;
protected:
FormFieldButton();
private:
Q_DECLARE_PRIVATE( FormFieldButton )
Q_DISABLE_COPY( FormFieldButton )
};
/**
* @short Interface of a text form field.
*
* This is the base interface to reimplement to represent a text field, ie a
* field where the user insert text.
*/
class OKULARCORE_EXPORT FormFieldText : public FormField
{
public:
/**
* The types of text field.
*/
enum TextType
{
Normal, ///< A simple singleline text field.
Multiline, ///< A multiline text field.
FileSelect ///< An input field to select the path of a file on disk.
};
virtual ~FormFieldText();
/**
* The particular type of the text field.
*/
virtual TextType textType() const = 0;
/**
* The text of text field.
*/
virtual QString text() const = 0;
/**
* Sets the new @p text in the text field.
*
* The default implementation does nothing.
*
* Reimplemented only if the setting of new text is supported.
*/
virtual void setText( const QString& text );
/**
* Whether this text field is a password input, eg its text @b must be
* replaced with asterisks.
*
* Always false for @ref FileSelect text fields.
*/
virtual bool isPassword() const;
/**
* Whether this text field should allow rich text.
*/
virtual bool isRichText() const;
/**
* The maximum length allowed for the text of text field, or -1 if
* there is no limitation for the text.
*/
virtual int maximumLength() const;
/**
* The alignment of the text within the field.
*/
virtual Qt::Alignment textAlignment() const;
/**
* Whether the text inserted manually in the field (where possible)
* can be spell-checked.
*
* @note meaningful only if the field is editable.
*/
virtual bool canBeSpellChecked() const;
protected:
FormFieldText();
private:
Q_DECLARE_PRIVATE( FormFieldText )
Q_DISABLE_COPY( FormFieldText )
};
/**
* @short Interface of a choice form field.
*
* This is the base interface to reimplement to represent a choice field, ie a
* field where the user can select one (of more) element(s) among a set of
* choices.
*/
class OKULARCORE_EXPORT FormFieldChoice : public FormField
{
public:
/**
* The types of choice field.
*/
enum ChoiceType
{
ComboBox, ///< A combo box choice field.
ListBox ///< A list box choice field.
};
virtual ~FormFieldChoice();
/**
* The particular type of the choice field.
*/
virtual ChoiceType choiceType() const = 0;
/**
* The possible choices of the choice field.
*/
virtual QStringList choices() const = 0;
/**
* Whether this ComboBox is editable, ie the user can type in a custom
* value.
*
* Always false for the other types of choices.
*/
virtual bool isEditable() const;
/**
* Whether more than one choice of this ListBox can be selected at the
* same time.
*
* Always false for the other types of choices.
*/
virtual bool multiSelect() const;
/**
* The currently selected choices.
*
* Always one element in the list in case of single choice elements.
*/
virtual QList< int > currentChoices() const = 0;
/**
* Sets the selected choices to @p choices .
*/
virtual void setCurrentChoices( const QList< int >& choices );
/**
The text entered into an editable combo box choice field
@since 0.16 (KDE 4.10)
*/
virtual QString editChoice() const;
/**
Sets the text entered into an editable combo box choice field
@since 0.16 (KDE 4.10)
*/
virtual void setEditChoice( const QString& text );
/**
* The alignment of the text within the field.
*/
virtual Qt::Alignment textAlignment() const;
/**
* Whether the text inserted manually in the field (where possible)
* can be spell-checked.
*
* @note meaningful only if the field is editable.
*/
virtual bool canBeSpellChecked() const;
protected:
FormFieldChoice();
private:
Q_DECLARE_PRIVATE( FormFieldChoice )
Q_DISABLE_COPY( FormFieldChoice )
};
+/**
+ * @short Interface of a signature form field.
+ *
+ * This is the base interface to reimplement to represent a signature field.
+ */
+class OKULARCORE_EXPORT FormFieldSignature : public FormField
+{
+ public:
+ /**
+ * The types of signature.
+ */
+ enum SignatureType {
+ AdbePkcs7sha1,
+ AdbePkcs7detached,
+ EtsiCAdESdetached,
+ UnknownType
+ };
+
+ ~FormFieldSignature();
+
+ /**
+ * The signature type
+ */
+ virtual SignatureType signatureType() const = 0;
+
+ /**
+ * Validate the signature with 'now' as validation time.
+ *
+ */
+ virtual SignatureInfo *validate() const = 0;
+
+
+ protected:
+ FormFieldSignature();
+
+ private:
+ Q_DECLARE_PRIVATE( FormFieldSignature )
+ Q_DISABLE_COPY( FormFieldSignature )
+};
+
}
#endif
diff --git a/core/signatureutils.cpp b/core/signatureutils.cpp
new file mode 100644
index 000000000..dbf925db6
--- /dev/null
+++ b/core/signatureutils.cpp
@@ -0,0 +1,157 @@
+/***************************************************************************
+ * Copyright (C) 2018 by Chinmoy Ranjan Pradhan *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+
+#include "signatureutils.h"
+
+using namespace Okular;
+
+CertificateInfo::CertificateInfo()
+{
+}
+
+CertificateInfo::~CertificateInfo()
+{
+}
+
+Q_DECLARE_OPERATORS_FOR_FLAGS( CertificateInfo::KeyUsageExtensions )
+
+bool CertificateInfo::isNull() const
+{
+ return true;
+}
+
+int CertificateInfo::version() const
+{
+ return -1;
+}
+
+QByteArray CertificateInfo::serialNumber() const
+{
+ return QByteArray();
+}
+
+QString CertificateInfo::issuerInfo(EntityInfoKey) const
+{
+ return QString();
+}
+
+QString CertificateInfo::subjectInfo(EntityInfoKey) const
+{
+ return QString();
+}
+
+QDateTime CertificateInfo::validityStart() const
+{
+ return QDateTime();
+}
+
+QDateTime CertificateInfo::validityEnd() const
+{
+ return QDateTime();
+}
+
+CertificateInfo::KeyUsageExtensions CertificateInfo::keyUsageExtensions() const
+{
+ return KuNone;
+}
+
+QByteArray CertificateInfo::publicKey() const
+{
+ return QByteArray();
+}
+
+CertificateInfo::PublicKeyType CertificateInfo::publicKeyType() const
+{
+ return OtherKey;
+}
+
+int CertificateInfo::publicKeyStrength() const
+{
+ return -1;
+}
+
+bool CertificateInfo::isSelfSigned() const
+{
+ return false;
+}
+
+QByteArray CertificateInfo::certificateData() const
+{
+ return QByteArray();
+}
+
+
+SignatureInfo::SignatureInfo()
+{
+}
+
+SignatureInfo::~SignatureInfo()
+{
+}
+
+SignatureInfo::SignatureStatus SignatureInfo::signatureStatus() const
+{
+ return SignatureStatusUnknown;
+}
+
+SignatureInfo::CertificateStatus SignatureInfo::certificateStatus() const
+{
+ return CertificateStatusUnknown;
+
+}
+
+SignatureInfo::HashAlgorithm SignatureInfo::hashAlgorithm() const
+{
+ return HashAlgorithmUnknown;
+}
+
+QString SignatureInfo::signerName() const
+{
+ return QString();
+}
+
+QString SignatureInfo::signerSubjectDN() const
+{
+ return QString();
+}
+
+QString SignatureInfo::location() const
+{
+ return QString();
+}
+
+QString SignatureInfo::reason() const
+{
+ return QString();
+}
+
+QDateTime SignatureInfo::signingTime() const
+{
+ return QDateTime();
+}
+
+QByteArray SignatureInfo::signature() const
+{
+ return QByteArray();
+}
+
+QList SignatureInfo::signedRangeBounds() const
+{
+ return QList();
+}
+
+bool SignatureInfo::signsTotalDocument() const
+{
+ return false;
+}
+
+CertificateInfo *SignatureInfo::certificateInfo() const
+{
+ return nullptr;
+}
diff --git a/core/signatureutils.h b/core/signatureutils.h
new file mode 100644
index 000000000..d3c177684
--- /dev/null
+++ b/core/signatureutils.h
@@ -0,0 +1,276 @@
+/***************************************************************************
+ * Copyright (C) 2018 by Chinmoy Ranjan Pradhan *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+
+#ifndef OKULAR_SIGNATUREINFO_H
+#define OKULAR_SIGNATUREINFO_H
+
+#include "okularcore_export.h"
+
+#include
+#include
+#include
+#include
+#include
+
+namespace Okular {
+
+class CertificateInfoPrivate;
+class SignatureInfoPrivate;
+
+/**
+ * @short A helper class to store information about x509 certificate
+ */
+class OKULARCORE_EXPORT CertificateInfo
+{
+ public:
+
+ /**
+ * The algorithm of public key.
+ */
+ enum PublicKeyType
+ {
+ RsaKey,
+ DsaKey,
+ EcKey,
+ OtherKey
+ };
+
+ /**
+ * Certificate key usage extensions.
+ */
+ enum KeyUsageExtension
+ {
+ KuDigitalSignature = 0x80,
+ KuNonRepudiation = 0x40,
+ KuKeyEncipherment = 0x20,
+ KuDataEncipherment = 0x10,
+ KuKeyAgreement = 0x08,
+ KuKeyCertSign = 0x04,
+ KuClrSign = 0x02,
+ KuEncipherOnly = 0x01,
+ KuNone = 0x00
+ };
+ Q_DECLARE_FLAGS( KeyUsageExtensions, KeyUsageExtension )
+
+ /**
+ * Predefined keys for elements in an entity's distinguished name.
+ */
+ enum EntityInfoKey
+ {
+ CommonName,
+ DistinguishedName,
+ EmailAddress,
+ Organization,
+ };
+
+ /**
+ * Destructor
+ */
+ virtual ~CertificateInfo();
+
+ /**
+ * Returns true if certificate has no contents; otherwise returns false.
+ */
+ virtual bool isNull() const;
+
+ /**
+ * The certificate version string.
+ */
+ virtual int version() const;
+
+ /**
+ * The certificate serial number.
+ */
+ virtual QByteArray serialNumber() const;
+
+ /**
+ * Information about the issuer.
+ */
+ virtual QString issuerInfo(EntityInfoKey key) const;
+
+ /**
+ * Information about the subject
+ */
+ virtual QString subjectInfo(EntityInfoKey key) const;
+
+ /**
+ * The date-time when certificate becomes valid.
+ */
+ virtual QDateTime validityStart() const;
+
+ /**
+ * The date-time when certificate expires.
+ */
+ virtual QDateTime validityEnd() const;
+
+ /**
+ * The uses allowed for the certificate.
+ */
+ virtual KeyUsageExtensions keyUsageExtensions() const;
+
+ /**
+ * The public key value.
+ */
+ virtual QByteArray publicKey() const;
+
+ /**
+ * The public key type.
+ */
+ virtual PublicKeyType publicKeyType() const;
+
+ /**
+ * The strength of public key in bits.
+ */
+ virtual int publicKeyStrength() const;
+
+ /**
+ * Returns true if certificate is self-signed otherwise returns false.
+ */
+ virtual bool isSelfSigned() const;
+
+ /**
+ * The DER encoded certificate.
+ */
+ virtual QByteArray certificateData() const;
+
+ protected:
+ CertificateInfo();
+
+ private:
+ Q_DISABLE_COPY( CertificateInfo )
+};
+
+/**
+ * @short A helper class to store information about digital signature
+ */
+class OKULARCORE_EXPORT SignatureInfo
+{
+ public:
+
+ /**
+ * The verfication result of the signature.
+ */
+ enum SignatureStatus
+ {
+ SignatureStatusUnknown, ///< The signature status is unknown for some reason.
+ SignatureValid, ///< The signature is cryptographically valid.
+ SignatureInvalid, ///< The signature is cryptographically invalid.
+ SignatureDigestMismatch, ///< The document content was changed after the signature was applied.
+ SignatureDecodingError, ///< The signature CMS/PKCS7 structure is malformed.
+ SignatureGenericError, ///< The signature could not be verified.
+ SignatureNotFound, ///< The requested signature is not present in the document.
+ SignatureNotVerified ///< The signature is not yet verified.
+ };
+
+ /**
+ * The verification result of the certificate.
+ */
+ enum CertificateStatus
+ {
+ CertificateStatusUnknown, ///< The certificate status is unknown for some reason.
+ CertificateTrusted, ///< The certificate is considered trusted.
+ CertificateUntrustedIssuer, ///< The issuer of this certificate has been marked as untrusted by the user.
+ CertificateUnknownIssuer, ///< The certificate trust chain has not finished in a trusted root certificate.
+ CertificateRevoked, ///< The certificate was revoked by the issuing certificate authority.
+ CertificateExpired, ///< The signing time is outside the validity bounds of this certificate.
+ CertificateGenericError, ///< The certificate could not be verified.
+ CertificateNotVerified ///< The certificate is not yet verified.
+ };
+
+ /**
+ * The hash algorithm of the signature
+ */
+ enum HashAlgorithm
+ {
+ HashAlgorithmUnknown,
+ HashAlgorithmMd2,
+ HashAlgorithmMd5,
+ HashAlgorithmSha1,
+ HashAlgorithmSha256,
+ HashAlgorithmSha384,
+ HashAlgorithmSha512,
+ HashAlgorithmSha224
+ };
+
+ /**
+ * Destructor.
+ */
+ virtual ~SignatureInfo();
+
+ /**
+ * The signature status of the signature.
+ */
+ virtual SignatureStatus signatureStatus() const;
+
+ /**
+ * The certificate status of the signature.
+ */
+ virtual CertificateStatus certificateStatus() const;
+
+ /**
+ * The signer subject common name associated with the signature.
+ */
+ virtual QString signerName() const;
+
+ /**
+ * The signer subject distinguished name associated with the signature.
+ */
+ virtual QString signerSubjectDN() const;
+
+ /**
+ * Get signing location.
+ */
+ virtual QString location() const;
+
+ /**
+ * Get signing reason.
+ */
+ virtual QString reason() const;
+
+ /**
+ * The the hash algorithm used for the signature.
+ */
+ virtual HashAlgorithm hashAlgorithm() const;
+
+ /**
+ * The signing time associated with the signature.
+ */
+ virtual QDateTime signingTime() const;
+
+ /**
+ * Get the signature binary data.
+ */
+ virtual QByteArray signature() const;
+
+ /**
+ * Get the bounds of the ranges of the document which are signed.
+ */
+ virtual QList signedRangeBounds() const;
+
+ /**
+ * Checks whether the signature authenticates the total document
+ * except for the signature itself.
+ */
+ virtual bool signsTotalDocument() const;
+
+ /**
+ * Get certificate details.
+ */
+ virtual CertificateInfo *certificateInfo() const;
+
+ protected:
+ SignatureInfo();
+
+ private:
+ Q_DISABLE_COPY( SignatureInfo )
+};
+
+}
+
+#endif