Commit graph

97 commits

Author SHA1 Message Date
Albert Astals Cid 532cb0cdcd Initial implementation of app.popUpMenuEx
It is defenitely not a full implementation but it's enough for the one
file we have that needs it for now

BUGS: 472764
2023-08-05 18:20:54 +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 617ba7dd03 Port from deprecated KJS to QJSEngine 2023-06-21 15:53:51 +00: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 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 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 91afa74342 Set minimum requirement to Ubuntu 22.04 2022-11-19 09:48:15 +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
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 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 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
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
Oliver Sander 24e48d9f5c Fix a typo in JavaScript code documentation 2021-12-14 09:37:51 +01: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 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 0c659a5466 clang-tidy: Enable google-explicit-constructor 2021-08-29 08:52:35 +00:00
Alexander Lohnau 2f193a63de Convert license headers to SPDX 2021-06-10 08:11:56 +00:00
Albert Astals Cid 81344f8aa8 Unbox alert() parameters when they are in an object
API let's you use both arguments or objects with named properties, so
support both.

This fixes the contents of the warning in 435833, the crash is still
there though, working on that next

CCBUGS: 435833
2021-05-24 19:53:03 +02:00
Alexander Lohnau 3c1fa441d9 Remove dead code
A lot of this code has been commented out for over
a decade and adds no value to the project.
It is only annoying when you look over it ;).

Same for the KNS2 support which was commented out.

Also some of the debug statements didn't even build
anymore, because the properties got removed/refactored.
2020-11-14 10:52:00 +01: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
Laurent Montel 516fb89d94 Use camelcase include. (scripted) 2020-07-08 13:54:37 +02:00
Albert Astals Cid a3c7d81000 Merge remote-tracking branch 'origin/release/20.04' 2020-06-30 19:37:33 +02:00
Albert Astals Cid 795c7cb01f Increase kjs requirement for using the timeout check
Unfortunately with the new timeout code but older than 5.72 will crash on appAlert

So increase the requirement to > 5.71
2020-06-24 12:06:32 +02:00
Albert Astals Cid 03cee363cd Merge remote-tracking branch 'origin/release/20.04' 2020-06-15 23:41:57 +02:00
Albert Astals Cid d78cbb79c9 Fix/Workaround file where we can't enter values in some fields
The problem was that the JS checker for the field format was using the
willCommit property of event and we don't define it so the JS
interpreter was going "ok nope, out of here" and the field didn't get edited.

I've read the willCommit definition in js_api_reference.pdf for almost
30 minutes, and even it's just 3 lines i don't think i understand it,
but i think that returning true is "safer", i.e. says that this event is
going to actually change the field, which as far as i can see it's what
we always do

BUGS: 421508
2020-06-15 20:45:21 +00:00
Albert Astals Cid d3b43b0b1e Implement AFMakeNumber
Also make stringToNumber be stubborn when converting strings to numbers

CCBUGS: 418445
2020-03-28 23:12:08 +00:00
Albert Astals Cid 9084bfaabe Fake implement AFNumber_Keystroke
Needed by the file at bug 418445, since it's a validate kind of thing we
can leave it unimplemented for now
2020-03-28 23:12:08 +00:00
Albert Astals Cid f69e2114e7 Use poppler choicesWithExportValues if available 2020-03-28 23:12:08 +00:00
Andre Heinecke ad405165b1 Add AFNumber_Format and l10n AFSimple_Calculate
This adds utility functions to util to work with QLocale
for formatting and Number handling.

At least until we support AFNumber_Keystroke to restrict
what a user enters in Number input fields it is good
behavior to expect the user to enter Numbers in the system's
Locale.

AFNumber_Format is new for formatting and uses the
Locale util functions.
2020-03-08 13:05:36 +01:00
Albert Astals Cid 3720833be4 Enable clazy qstring-allocations 2020-02-21 17:45:03 +01:00
Albert Astals Cid 93540ac16d Enable most of clazy level2 2020-02-21 14:57:48 +01:00
Albert Astals Cid 96f00a4d29 CI: Enable clazy qstring-arg check 2020-02-19 23:44:37 +01:00
Yuri Chornoivan 5c6a297feb Fix minor EBN issues 2020-02-13 11:47:51 +02:00
Harri Porten c1afa356c0 Restrict time given for JavaScript evaluation to max. 2 seconds.
Possible improvement: alert the user of the timeout and offer
the option to continue or abort execution.
2020-02-11 22:34:46 +00:00
Albert Astals Cid 2da1cd736a CI: Enable clang-tidy modernize-loop-convert 2020-01-24 17:23:39 +01: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
Yuri Chornoivan 793d06c95d Fix minor issues found by EBN 2019-10-14 12:13:33 +03:00
Laurent Montel db0f477119 Port deprecated QLayout::setMargin 2019-09-18 13:35:04 +02:00
João Netto 17814fc304 Implemented validate actions and made formwidgets leave these actions to QLineEdit::Event 2019-08-22 22:38:10 +00:00
João Netto 3081358836 Added support for Form Focus Events 2019-08-22 22:38:10 +00:00
João Netto 3eb6a91e25 Changed util.printd to use the default locale on case 2. Also made kjsfunctionstest to be in a consistent locale 2019-08-15 13:21:04 -03:00
João Netto 24fc9defe3 Changed AFTime_Format to work with user locale PM strings 2019-08-14 21:49:04 +00:00
João Netto f54d65ca86 Changed util.printd to work with the default locale set on QLocale::setDefault to allow consistent results in tests 2019-08-14 21:49:04 +00:00
João Netto c7432cdae6 Implemented support for AFSpecial_Format and AFSpecial_Keystroke 2019-08-12 12:47:56 -03:00
João Netto 052662d78d Implemented support for AFTime_Format and AFTime_Keystroke 2019-08-12 11:13:03 -03:00
João Netto 53a8acf813 Removed the use of internalText(), replacing by text() 2019-08-11 14:55:21 +00:00