Commit Graph

112 Commits

Author SHA1 Message Date
Pratham Gandhi
1b78471a41 Made event.change evaluate to whole incoming text.
Currently event.change evaluates from first point of difference to end of the string. This MR modifies it to evaluate to whole incoming text. Now we evaluate whatever change is coming in, even if that change contains some common substring with original string (not considering only from the first point of difference).

The current definition makes it difficult to evaluate the final value from event.value and event.change within Javascript. This change is also better from compatibility POV as other readers such as Adobe and PDF.js make similar calculations.
2024-06-11 22:41:59 +00:00
Sune Vuorela
4509b7bc42 Various minor fixes
Mostly derived from cppcheck runs
2024-04-16 15:44:19 +02:00
Sune Vuorela
0c383d8cfc Random minor/pedantic fixes 2023-06-17 11:04:41 +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
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
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
Alexander Lohnau
2f193a63de Convert license headers to SPDX 2021-06-10 08:11:56 +00:00
Albert Astals Cid
19d98d6a74 Run clang-format
find . \( -name "*.cpp" -or -name "*.h"  -or -name "*.c"  -or -name "*.cc" \) -exec clang-format -i {} \;

If you reached this file doing a git blame, please see README.clang-format (added 2 commits in the future of this one)
2020-07-11 09:17:33 +02:00
Albert Astals Cid
46d1ba0e20 Enable clazy missing-qobject-macro 2020-02-21 17:09:46 +01:00
Albert Astals Cid
93540ac16d Enable most of clazy level2 2020-02-21 14:57:48 +01:00
Andi Sardina Ramos
c549d28f7f Solving the creation of an additional tab for a deleted file.
BUG: 412978
BUG: 412979
2020-02-10 23:22:06 +00:00
Albert Astals Cid
c549acaab0 Move the Q_PRIVATE_SLOTS to lambda connections
Some of the invokeMethods with a queued connection get changed with a
QTimer::SingleShot with 0 which has the same behaviour
2019-12-20 16:42:58 +01:00
Albert Astals Cid
da21543a50 Small performance improvements 2019-10-05 22:16:43 +02:00
João Netto
f31eb3cb68 Created private functions to avoid duplicated code in Document 2019-08-22 22:38:10 +00:00
João Netto
60ff2f414e Fixed indentation, bad algebra and moved display enum to KJSDisplay 2019-07-20 12:06:42 +02:00
João Netto
ad858267d1 Implemented display support and updated dependencies to Poppler > 0.79
Moved executeScript to document private and support to display options for JavaScript
2019-07-20 12:06:12 +02:00
Albert Astals Cid
a482c56ba2 Select current format on the configure backend dialog
Subscribers: sander, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D14820
2018-10-08 22:54:03 +02:00
Yuri Chornoivan
39b6e8147d Fix minor EBN issues 2018-09-01 11:25:57 +03:00
Yuri Chornoivan
c04ca1fa96 Fix minor EBN issues 2018-08-31 12:23:45 +03:00
Albert Astals Cid
739b591e25 Merge remote-tracking branch 'origin/Applications/17.12' 2018-02-15 10:14:45 +01:00
Albert Astals Cid
e8d9feed70 Fix potential crash in document saving
Probably doesn't happen very often since most of the times people don't save while rendering is still happening
but if that is the case we need to wait for all the rendering to finish otherwise we remove the document
from under the render thread feet and bad things happen
2018-02-14 17:51:01 +01:00
Albert Astals Cid
2d8b2c7e95 Add support for cancellable image rendering and text extraction
Summary:
Only supported by the pdf backend if using poppler >= 0.63

Sadly had to change the generator API

Text cancellation is a bit wobbly still since poppler has large parts
of the code where doesn't check for the cancellation flag, but that
is something that will get automagically fixed for us if the poppler
side is improved

Test Plan: Needs https://bugs.freedesktop.org/show_bug.cgi?id=104263

Reviewers: ervin, rkflx

Reviewed By: ervin, rkflx

Subscribers: #okular

Tags: #okular

Differential Revision: https://phabricator.kde.org/D9328
2018-02-01 22:53:28 +01:00
Albert Astals Cid
a93661e892 Merge remote-tracking branch 'origin/master' into dont-use-docdata-for-annots-and-forms 2017-09-27 15:01:57 +02:00
Henrik Fehlauer
bd20e48c3c Update to synctex 1.19
Summary:
This should prevent crashes when reloading some synctex-enabled pdf
files created with newer versions of TeXLive. We also gain bugfixes,
features and improved accuracy from the last 6 years of synctex
development.

Procedure followed:
- svn co svn://tug.org/texlive/trunk/Build/source/texk/web2c/synctexdir
- Check out revision 45150
- Update files present in core/synctex/*
- Adapt Okular code to changes
- Review and drop or update/apply old patches using quilt
- Create missing patches for local synctex changes
- New patch: Omit warning message when opening non-synctex pdf
- Two new patches to fix more compiler warnings
- New patch: Plug multiple leaks and prevent a segfault

TODO for later:
- Move sync file detection code to Okular to never call into synctex C code for non-synctex files
- Evaluate feasibility of upstreaming all patches for TeXLive 2018 and using synctex as a library

BUG: 383915
FIXED-IN: 17.12.0

Test Plan:
- No crash in synctex on reloading empty.pdf from bugreport anymore.
- Shift-clicking on a word in a simple pdf opens Kate with the corresponding tex line.
- Forward and backward search in Kile seems to work.
- Works with synctex files from both TeXLive 2015 and 2017.
- PartTest::testForwardPDF still passes.
- No additional memory leaks in autotests and with basic synctex and non-synctex usage of Okular.

Reviewers: #okular, sander, #kile, aacid

Reviewed By: #okular, aacid

Subscribers: mludwig, aacid

Tags: #okular

Differential Revision: https://phabricator.kde.org/D7594
2017-09-12 21:56:49 +02:00
Albert Astals Cid
04ed10d3ea Merge remote-tracking branch 'origin/master' into dont-use-docdata-for-annots-and-forms 2017-09-11 19:51:51 +02:00
Kevin Funk
a53a2402ca clang-tidy: modernize-use-nullptr run
Semi-ACK'd by Albert :)
2017-09-06 00:19:48 +02:00
Tobias Deiminger
0957abc39a Add annotation resize functionality
Usage:
If you left-click an annotation, it gets selected. Resize handles appear on the selection rectangle. When cursor is moved over one of the 8 resize handles on the corners/edges, the cursor shape changes to indicate resize mode. Everywhere else on the annotation means "move", just as it was before resize feature was added. Pressing ESC or clicking an area outside the annotation cancels a selection. Pressing Del deletes a selected annotation.

Feature is only applicable for annotation types AText, AStamp and AGeom.

Implementation:
It works by eventually changing AnnotationPrivate::m_boundary and notifying generator (i.e. poppler) about that change. Annotation state handling is shifted out of PageView into a new class MouseAnnotation (ui/pageviewmouseannotation.cpp). Some functionality not related to resizing but to annotation interaction in general is also shifted to class MouseAnnotation, to build a single place of responsiblity.

Other changes:
Add method Document::adjustPageAnnotation, backed by a QUndoCommand.
class Okular::AdjustAnnotationCommand.
Add Annotation::adjust and Annotation::canBeResized methods.
Draw resize handles in PagePainter::paintCroppedPageOnPainter.

Resize and move work
-for types AText, AStamp and AGeom
-on all pages of document
-when viewport position changes
-when zoom level changes
-for all page rotations (0°, 90°, 180°, 270°)

Selection is canceled
-when currently selected annotation is deleted
-on mouse click outside of currently selected annotation
-ESC is pressed

Viewport is shifted when mouse cursor during move/resize comes close to viewport border.
Resize to negative is prevented.
Tiny annotations are still selectable.
If mouse is moved over an annotation type that we can focus, and the annotation is not yet focused, mouse cursor shape changes to arrow.
If mouse cursor rests over an annotation A, while annotation B is focused, a tooltip for annotation A is shown.
Selected Annotation is deleted when Del is pressed.

Test for regressions:
-Annotation interaction (focus, move, resize, start playback, ...) are only done in mode EnumMouseMode::Browse.
-If mouse is moved over an annotation type where we can start an action, mouse cursor shape changes to pointing hand.
-If mouse is moved over an annotation type that we can't interact with, mouse cursor shape stays a open hand.
-If mouse cursor rests over an annotation of any type, a tooltip for that annotation is shown.
-Grab/move scroll area (on left click + mouse move) is prevented, if mouse is over focused annotation, or over AMovie/AScreen/AFileAttachment annotation.
-A double click on a annotation starts the "annotator".

REVIEW: 127366
BUG: 177778
BUG: 314843
BUG: 358060
2017-03-19 23:18:17 +01:00
Albert Astals Cid
4573c7a646 Recalculate forms after other are edited
BUGS: 376958
2017-03-03 01:08:44 +01:00
Albert Astals Cid
1d2dd42c67 no need for & here 2017-03-02 22:45:45 +01:00
Albert Astals Cid
ec70995895 QString as key is evil, add a nice enum 2017-03-02 21:04:59 +01:00
Albert Astals Cid
be6b0b6f48 Fix porting bug regarding the font extraction progress
BUGS: 375782
2017-01-31 22:50:54 +01:00
Albert Astals Cid
ecf54e4203 Try other generators if opening fails with one generator
This is not very common but would happen so be a bit stubborner
2016-12-08 23:35:04 +01:00
Aleix Pol
a704fbce94 Fix porting QUrl issues
Reviewed by Albert Astals
2016-01-30 20:00:25 +01:00
Alex Richardson
2f9246ae42 Port to new JSON plugin loading system
This means Okular can now work without ksycoca and KDELibs4Support.

REVIEW: 126193
2016-01-04 15:59:07 +01:00
Montel Laurent
04943508cf Merge remote-tracking branch 'origin/master' into frameworks
Conflicts:
	core/document.cpp
	core/version.h
2015-03-04 07:55:32 +01:00
Albert Astals Cid
10a1899058 Hack to restore KWallet support
Better fix code-wise will come with an API break in master

BUGS: 339170
2015-02-09 22:03:44 +01:00
Lukáš Tinkl
e9ae1d99af port away from KLocale 2015-01-29 21:48:47 +01:00
Lukáš Tinkl
fd6a35486e port KUrl -> QUrl 2015-01-29 20:55:57 +01:00
Montel Laurent
5da7c5f77d port to qCDebug. Autogenerate export headers 2014-10-27 22:35:06 +01:00
Montel Laurent
17a55c6dab Merge remote-tracking branch 'origin/master' into frameworks
Conflicts:
	CMakeLists.txt
	core/document.cpp
	generators/poppler/CMakeLists.txt
	generators/poppler/generator_pdf.cpp
	generators/poppler/generator_pdf.h
2014-10-09 07:34:35 +02:00
Albert Astals Cid
e8fd56f3ba Fixup last commit
Somehow i ended up commiting a partial patch and not what was in reviewboard, this amends the previous commit to be what i really wanted to commit

Sorry for the mess :/
2014-10-09 00:53:54 +02:00
Albert Astals Cid
d95efa7698 Move synctex up to the core from poppler generator
This way dvi and any other potential user gets it for free

The diff is huge, but the synctex files are just moves.

And the code in core/ is also mostly just a move from the generator_pdf.cpp code

Acked by Luigi

REVIEW: 120311
2014-10-09 00:17:53 +02:00
Frederik Gladhorn
3581fb6245 Port to QTemporaryFile 2014-09-18 00:30:39 +02:00
Fabio D'Urso
e059d2652c core: support for migration of annots and forms out of docdata/ 2014-09-10 12:18:34 +02:00
Fabio D'Urso
288f87f1a5 Merge branch 'master' into dont-use-docdata-for-annots-and-forms
Conflicts:
	core/document.cpp
	core/document_p.h
	part.cpp
	part.h
2014-09-08 14:58:55 +02:00
Frederik Gladhorn
b79e706e56 Merge remote-tracking branch 'origin/master' into frameworks
Conflicts:
	generators/dvi/generator_dvi.cpp
	generators/ooo/generator_ooo.cpp
	part.cpp
	shell/main.cpp
	shell/shell.cpp
	shell/shell.h
	shell/shellutils.h
	tests/CMakeLists.txt
	ui/propertiesdialog.cpp
2014-08-14 13:35:43 +02:00
Albert Astals Cid
e9e3d4a435 Make documentInfo be Hash based instead of XML based 2014-08-10 22:38:13 +02:00
Albert Astals Cid
61c830cb7a Pass the command line options properly when using tabs or unique instances
Use a QString to serialize the command line options other than urls to open so it can be easily passed around to every place that opens a new shell or tab or overrides the content in a unique instance.

BUGS: 334100
FIXED-IN: 4.14.0
REVIEW: 119595
2014-08-08 22:35:53 +02:00
Frederik Gladhorn
75031eee7e Fix includes 2014-08-08 01:59:55 +02:00
Fabio D'Urso
859168eaa8 Update some variables properly when swapping backing file 2014-05-11 18:52:16 +02:00