Commit graph

1987 commits

Author SHA1 Message Date
Albert Astals Cid 29810ad3dd Handle absolute urls in Document::processAction
BUGS: 472440
2023-07-23 18:28:56 +02:00
Ingo Klöcker 702ddec20f Include stdarg.h for va_start and va_end
Fixes "implicit declaration of function" error with devtoolset-10
(gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11)) in centos7 Docker image
used for building an AppImage.

See also the original source code:
https://github.com/jlaurens/synctex/blob/2020/synctex_parser.c#L104
2023-07-12 08:45:43 +00:00
Max Mueggler 8308112867 Fix bug where entire next page would be preloaded when zoomed into one page
This bug would cause out-of-memory errors when zoomed in.

There's an equivalent (and therefore redundant) check for if the
normalizedRect is null, so it looks like the normalizedArea != 0 check
was an oversight, if anything.
2023-06-29 08:28:51 +00:00
Sune Vuorela d1133be5fc Allow open certificate with kleopatra
If the active backend is gnupg (e.g. if only compiled-in backend, or later when configurabitily thru okular has been merged), we can offer to view and edit certificates with Kleopatra (KDE's certificate manager)
2023-06-25 22:41:22 +00:00
Volker Krause fd459910b9 Remove the last references to kjs from the JS executor 2023-06-22 17:45:08 +02:00
Volker Krause a0af2c03cb Rename JS scripting files to no longer mention kjs 2023-06-22 17:40:50 +02:00
Volker Krause ba04a81d2b Rename HAVE_KJS
It's not KJS but QJSEngine now.
2023-06-22 17:24:36 +02:00
Yuri Chornoivan 419b10fbb5 Fix minor typo 2023-06-22 09:11:40 +03:00
Volker Krause 617ba7dd03 Port from deprecated KJS to QJSEngine 2023-06-21 15:53:51 +00:00
Sune Vuorela 03368e06f4 Make phonon optional
In certain configurations not lugging around a multimedia framework could be preferred.
2023-06-21 15:50:58 +00:00
Sune Vuorela 0c383d8cfc Random minor/pedantic fixes 2023-06-17 11:04:41 +00:00
Nate Graham 5af0560731 Add missing @since tags to new public functions in core/document
Also re-arrange the new function declarations so they're in
chronological order by date added.
2023-06-14 13:46:51 -06:00
Sune Vuorela 9f498c7f55 Allow new signatures to have image backgrounds 2023-06-14 17:47:41 +00:00
Sune Vuorela da7ca71291 Add location and reason to signing info 2023-06-14 17:47:41 +00:00
Sune Vuorela 370ace64e0 Switch optional kjs to use config.h 2023-05-25 21:43:43 +00:00
Sune Vuorela 3ff2ab5081 Switch optional kwallet to use config.h 2023-05-25 21:43:43 +00:00
Sune Vuorela ed0b1551fb Simple deprecation. SkipEmptyParts 2023-05-12 10:43:04 +00:00
Sune Vuorela 5c9e0e2585 Rename setViewportWithHistory to setViewport and remove the old setViewport 2023-05-12 10:39:41 +00:00
Sune Vuorela 763328a6ba Better dialog for selecting certificates
Instead of just a simple list of "nickname"'s which is kind of like the
signing backend's internal ID for a given certificate, provide some more
context to each key.

This is a slight improvement, not a complete overhaul.
2023-05-03 13:41:14 +00:00
Sune Vuorela b32ae775b4 Remove virtual methods from signature and certificate info
This is an abi break, but it menas we can extend signature and
certificate info in the future without breaking the abi again.

While we are at it, there is no need to hand around pointers to
certificate/signature info any longer, so clean up that. Fix memleaks as
side effect.
2023-05-03 09:15:42 +00:00
Sune Vuorela 907cc7fb80 Simple deprecation. KRandom 2023-05-03 07:34:45 +00:00
Sune Vuorela c50d6b8aee Fix a deprecation warning 2023-04-13 14:44:58 +02:00
Dr. David Alan Gilbert 24a9d097d7 JS: Implement field.valueAsString
Adobe's docs say:
  For example, for a field with a value of “020”, value returns the integer 20,
   while valueAsString returns the string “020”.

Share most of the fieldGetValue code by splitting it out into a 'Core'
variant and then using it in both GetValue and GetValueAsString.

BUGS: 468036
2023-04-09 09:21:37 +00:00
Dr. David Alan Gilbert 074c3dc3c2 debug: Log the script
Include the script in the debug.  Useful when you're dealing with
a file with lots of different scripts.
2023-04-09 09:21:37 +00:00
Dr. David Alan Gilbert 51737b24e3 JS: Add debug for field values
Add debug for field setting:

org.kde.okular.core: fieldSetValue: Field:  "Grand_Total_stock_1"  Type:  "text"  Value:  "NaN"

and getting:
org.kde.okular.core: fieldGetValue: Field:  "Market_price_1"  Type:  "text"  Value:  "1"
2023-04-09 09:21:37 +00:00
Albert Astals Cid c62dc60ead Fix crash when executing the Save action
Detecting aboutToClose is not enough because savingAs doesn't always go
through aboutToClose it can go through swapBackingFile

BUGS: 467603
2023-04-05 22:06:55 +00:00
Albert Astals Cid 09038f4fb5 JS: Make field.value return a number if possible
Quoting the Adobe documentation
 'for a field with a value of “020”, value returns the integer 20'

BUGS: 467852
2023-04-05 21:19:45 +00:00
Albert Astals Cid 052264c3e5 Use KIO::OpenUrlJob instead of KRun::runService
Works much better in Windows
2023-03-27 15:14:04 +00:00
Max Mueggler 71770ed815 Replace QTime with QDeadlineTimer in DocumentPrivate::getFreeMemory
QTime is quite inefficient and getFreeMemory sometimes gets called quite
frequently. I found that upwards of 10% of CPU time was being spent
inside of QTime in some cases. Besides being the recommended thing for
this use case, QDeadlineTimer is a lot more efficient.
2023-02-23 22:24:07 +00:00
l10n daemon script 9ef28fffec SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2023-02-20 02:01:39 +00:00
l10n daemon script bf745445bf SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2023-02-16 02:03:52 +00:00
Cimbali a33e499b40 Fix wrong interpretation of autoplay flag
BUGS: 436709
2023-02-15 23:32:49 +00:00
Willyanto Willyanto 5bb79f2cfd Add patch for call va_end() before return 2023-02-15 22:42:33 +00:00
Willyanto Willyanto 98876cf588 Replace qSwap with std::swap
Fixes obsolete function 'qSwap' called. It is recommended to use 'std::swap'
instead. (CWE-477)
2023-01-26 18:11:50 +00:00
Willyanto Willyanto 64e835103c Call va_end() before return
Fixes va_list 'arg' was opened but not closed by va_end(). (CWE-664)
2023-01-17 22:49:23 +07:00
Max Mueggler a1cf3f9e5e Don't paint a partial pixmap over a fully rendered pixmap, even if dirty
This preserves fully rendered areas when zooming in or out instead of
replacing them with partially rendered pixmaps.
2022-12-01 20:21:12 +00:00
Max Mueggler aa0386dccd Fix hasPixmap setting size of TilesManager 2022-12-01 20:21:12 +00:00
Max Mueggler 8c61b6a2b4 Fixed issue with occasional mis-sized tile
It turns out that there were two issues at play here: rounding errors
meant that pixmaps were almost never the same size as pagePainter
thought the tiles should be, and the tile-is-the-size-it-should-be code
path was broken (but only hit in rare cases, seemingly at random).

To help with rounding errors in the future, I added a geometryF function
to NormalizedRect that returns a QRectF. In general,
device-independent-pixel points/rects should be floating point, and
device-pixel rects should be integer.
2022-11-30 08:39:26 +00:00
Albert Astals Cid 91afa74342 Set minimum requirement to Ubuntu 22.04 2022-11-19 09:48:15 +00:00
l10n daemon script 9f1300c115 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2022-11-10 01:51:04 +00:00
l10n daemon script 9579a4540f SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2022-10-28 01:51:08 +00:00
Nicolas Fella 9bf396ee7e Add missing KBookmarkOwner include 2022-10-15 22:52:36 +02:00
l10n daemon script 804cadfb53 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2022-09-18 01:41:53 +00:00
Nicolas Fella 2911f7a885 Very basic implementation for AFPercent_Keystroke
This is used to filter characters that don't make sense in a percent expression

This implementation is very rudimentary
2022-09-14 19:55:18 +00:00
Nicolas Fella 80afe26873 Implement event.change
This represents the newly entered data for each keystroke. This is often a single added character, but for cases like pasting text it can be more complex.

The PDF API reference doesn't specify any algorithm to use.

The algorithm used here works by iterating through both strings from the start until the first different character is encountered. Then the rest of the new text is considered the difference.

This doesn't produce the theoretically optimal/minimal diff, but seems to work well enough for practical application.

When text is removed the diff is empty
2022-09-13 21:51:15 +00:00
Nikola Nikolic 69a2cc144f Fix viewport transition when translating/resizing annotations
Viewport isn't centered on annotations when translating/resizing.
This is best seen if the page is zoomed in and annotation is translated so that
several viewport transitions had happened.
Using undo after translation will expose error.

Function moveViewportIfBoundingRectNotFullyVisible centers viewport based on
translated/resized annotation's bounding rectangle.
For that reason functions translateBoundingRectangle/adjustBoundingRectangle need
to return the same bounding rectangle as annotation's translate/adjust functions.
2022-09-13 16:46:41 +02:00
Albert Astals Cid 656587ca63 epub: Improve TableOfContents for some files
The link can be percent encoded so try it like that if not found in the
normal way, also if the text overflows the page, it's in the next page

BUGS: 458289
2022-08-25 23:38:42 +02:00
l10n daemon script 1626b59fef SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2022-06-09 02:00:18 +00:00
l10n daemon script dfe316c6ec SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2022-06-07 02:06:15 +00:00
l10n daemon script e8d5f24ad4 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2022-05-13 01:44:03 +00:00
Albert Astals Cid 030a34f1ff Fix Windows compile with new stricter defines 2022-04-08 10:52:26 +02:00
Albert Astals Cid 0d40301d50 Add a few definitions that will come with ECM 5.85
Better enforce them now, so that the work to port doesn't increase over
time

Not a super fan of this for regular applications, but oh well the ship
has sailed
2022-04-07 23:02:12 +00:00
Albert Astals Cid 8c31962e81 Port a few QLinkedList to std::list
here we do quite a bit removals from the middle, so feels better to have
something that is cheap to do that like std::list
2022-03-31 17:27:13 +02:00
Albert Astals Cid 252236d413 Port a few more QLinkedList to QList
We don't need the special properties of QLinkedList in any of those and
QLinkedList is deprecated, so move away from it
2022-03-31 17:08:01 +02:00
l10n daemon script 5042078495 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2022-03-29 02:04:54 +00:00
Albert Astals Cid 0741ef1838 Port away from more QLinkedLists
QLinkedList is gone from Qt6

The almost 1:1 port is std::list but we don't need iterator stability on
removal/insertion so just port to QList
2022-03-22 12:58:59 +01:00
Albert Astals Cid 8941e43488 Port away from more QLinkedLists
QLinkedList is gone from Qt6

The 1:1 port is std::list but we don't need iterator stability on
removal/insertion so just port to QList (one case to std::vector since
QList needs a copy constructor)
2022-03-22 00:11:55 +01:00
Albert Astals Cid 6767b8739e Port a few QLinkedList to QList
QLinkedList is deprecated in later Qt5 and gone in Qt6

The 1:1 port is std::list but in this cases all we ever do
is create the lists, push back to them, and pass then around
to be read, for that a QList is more than enough
2022-03-19 11:22:55 +00:00
Albert Astals Cid 2d007f27d3 foreach -> for
A future ECM update is going to force that on us, so do it now anyway
2022-03-19 10:58:47 +00:00
Albert Astals Cid a2e1043149 slots -> Q_SLOTS
A future ECM update is going to force that on us, so do it now anyway
2022-03-19 10:58:47 +00:00
Albert Astals Cid ba35bbd9e6 emit -> Q_EMIT
A future ECM is going to force that on us, so do it early
2022-03-19 10:58:47 +00:00
Thiago Simão af91d33070 Create empty inline note and then open dialog to get user's input. 2022-03-12 00:57:36 +01:00
Albert Astals Cid df68aa0112 Remove extra bunch of {} added by clang-tidy ^_^ 2022-03-10 12:07:06 +01:00
Albert Astals Cid 9d3842c796 Move to clang-format 13 2022-03-10 00:23:22 +01:00
Volker Krause 50d0703ae0 Enable readability-braces-around-statements 2022-03-09 23:29:56 +01:00
Nicolas Fella d1ecad897c Implement keystroke commit events
When a form field loses focus a special keystroke event with
willCommit=true is sent.

This is based on work by Joao Netto <joaonetto901@gmail.com>
2022-03-07 22:14:26 +00:00
Albert Astals Cid 1aa175cf3f Support SaveAs action
If a new enough (unreleases as of now) poppler is available

BUGS: 451010
2022-03-06 19:16:27 +00:00
Nicolas Fella 5e8beb532a Set correct textfield value on keystroke
event.value is the old value, we need to set the new value here

Modifying event.value is not supported when not committing
2022-03-02 23:20:14 +01:00
Nicolas Fella fd1c312d57 Fix keystroke events
event.value is the value before editing, not after
2022-02-24 23:39:28 +00:00
Nicolas Fella 6c8cafbb1c Simplify keystroke event handling
Make it more similar to how we handle the format event.

We pass the new value to processKeystrokeAction, that calls the script
and sets the new value for the form object according to the result. If
needed the widget is refreshed to reflect the new text
2022-02-24 16:10:22 +01:00
Andreas Naumann 147a638619 Adds option editor-cmd to the commandline
Adds the option "editor-cmd" for the [feature request](https://bugs.kde.org/show_bug.cgi?id=263732) .

BUG: 263732
2022-02-18 13:33:28 +00:00
Albert Astals Cid 218edc6f4a Merge remote-tracking branch 'origin/release/21.12' 2022-01-29 11:47:52 +01:00
Albert Astals Cid feef900250 Make sure helper apps we start are in path
QProcess will happily start things in CWD which is not what we want
2022-01-28 22:51:20 +00:00
Albert Astals Cid 8a36e7350d Make Utils::realDpi work on QWindow not on QWidget
Small step towards the goal of okularcore not linking to QWidgets
2022-01-27 19:25:30 +01:00
Albert Astals Cid a8e5f6e9f7 PDF: Allow signing unsigned signature fields 2022-01-24 13:18:36 +01:00
Albert Astals Cid fa6743aa04 Support the PDF Print named action
Also stop casting directly from a poppler enum to an okular enum, it's
not cool

BUGS: 448791
2022-01-23 22:20:46 +00:00
Albert Astals Cid f03bbfa89d PDF: Allow signing documents that need password to open them
We need the password since in the middle of the signing process we need to reopen
the document we just created to do some final modifications
2022-01-05 13:59:37 +00:00
Albert Astals Cid df4a7ef4e9 Merge remote-tracking branch 'origin/release/21.12' 2022-01-05 14:01:09 +01:00
Albert Astals Cid e2ac1dcd1e PDF: Fix memory leak when the file has Optional Content links 2022-01-04 16:42:35 +00:00
Albert Astals Cid 44c86de7e4 Fix two Signature issues on multipage/multisignature documents
First issue:
 - The "document is totally signed" was based on the last signature of
   the last page (that had signatures) that is not correct and needs to
   be based in the last signature by date

 - The "Rev #" number was based on the signature on the page, so if we
   had two pages with one signature each the model showed "Rev 1" for
   both

It adds new API which is not awesome in a stable branch, but the first
issue is important enough that warrants this to go to the stable branch
2022-01-03 23:38:23 +01:00
Albert Astals Cid d6870ae2ff Remove deprecated Generator::documentMetaData 2021-12-29 18:49:56 +01:00
Albert Astals Cid a2576dc746 Act on core/ TODOs that are not binary compatible
I'm going to need to break binary compatibility to add a new feature
so may as well cleanup all the TODOs regarding that

Changes:
 * Moving a few destructors to the header
 * Removing a few unnecessary & in params
 * Adding a few necessary & in params
 * Making print return an enum instead of a bool and then having another
   function that returns the enum
 * Make Generator::requestFontData be a virtual
 * Remove unused enum
 * Remove a few filePrinter unneeded functions
 * Remove unused TextDocumentGenerator::addMetaData signal
2021-12-29 09:35:25 +00:00
Oliver Sander 24e48d9f5c Fix a typo in JavaScript code documentation 2021-12-14 09:37:51 +01:00
Albert Astals Cid 62eec7d5b1 Show the "No signing certs" warning earlier
No need to ask for the user to draw a rectangle for the signature
if there's no certs to sign anyway

CCBUGS: 446549
2021-12-12 23:43:37 +00:00
Albert Astals Cid 0d4f463729 Fix implementation of AFNumber_Format
We did not take sepStyle 3 into account.

Also sepStyle 1 and 0 where mixed up and it didn't work either because
replace() needs to be assigned back to the string

BUGS: 445868
2021-11-29 11:15:46 +00:00
Albert Astals Cid 810e9db2bb Merge remote-tracking branch 'origin/release/21.08' 2021-10-23 11:59:12 +02:00
Albert Astals Cid 2002f4e7e9 Relax the check for non square DPI
BUGS: 444168
2021-10-22 22:23:49 +00:00
Albert Astals Cid 7ccdd513b9 Merge remote-tracking branch 'origin/release/21.08' 2021-10-06 23:19:06 +02:00
Albert Astals Cid 913560eb78 util.printd: Don't crash if we get an unexpected oDate argument
BUGS: 443255
2021-10-05 22:55:16 +02:00
Albert Astals Cid a408499889 Make the stamps renderer as static as before
Looking for and loading the SVG file isn't cheap so cache it as we did
in the past
2021-10-01 19:31:23 +02:00
Albert Astals Cid b3379d331d Fix documentation of AnnotationUtils::loadStamp 2021-10-01 18:55:19 +02:00
Mahmoud Khalil 8b3dfcb3f4 PDF: Add Stamps to the file properly
By using Poppler 20.10 new custom image stamps APIs

Instead of the incompatible hack we used before that only worked for Okular.

This is done by modifying the update function used by PopplerAnnotationProxy in order to load the image in
the correct dimensions and send it to the poppler-Qt5 frontend.

We temporarily store the stamp annotation appearance when deleting it so that we can set it again when doing an undo undo.
2021-10-01 16:04:50 +00:00
l10n daemon script 7c87c702df SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-09-10 02:19:38 +00:00
l10n daemon script 7ae4288f35 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-09-10 01:16:35 +00:00
Albert Astals Cid 1f84075c12 Don't use KMessageBox in document class
Just use the existing signals to warn the user about it
2021-09-09 17:43:26 +02:00
Albert Astals Cid 0c659a5466 clang-tidy: Enable google-explicit-constructor 2021-08-29 08:52:35 +00:00
Albert Astals Cid eee71036a7 Fix crash in bug 400104 again
And also make clazy happier so we don't need an exclude
2021-08-27 10:45:35 +02:00
Albert Astals Cid c0de8366fc Merge remote-tracking branch 'origin/release/21.08' 2021-08-27 10:44:29 +02:00
Albert Astals Cid bed447f769 textpage: Don't use the page bounding rect as initial text rect
The bounding rect is *visual* and it can happen that we have
invisible text and thus the algorithm will get super confused
because there will be text items that are outside the text area
2021-08-27 06:52:28 +00:00
Albert Astals Cid b747f0feb1 CI: silence clazy warning now that there's a new clazy version 2021-08-27 00:15:17 +02:00