summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_interform.cpp
AgeCommit message (Collapse)Author
2018-10-11Rename interform files to interactiveform.Lei Zhang
Just rename the files in this CL. Change-Id: I39f7fefa885977fffab6c909762b05484a1c923d Reviewed-on: https://pdfium-review.googlesource.com/c/43814 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-09Remove default argument to CPDF_Dictionary::GetBooleanFor().chromium/3576Lei Zhang
Change-Id: I5b64bc3af90b9557d8e0c456675afe60e463927d Reviewed-on: https://pdfium-review.googlesource.com/c/43612 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-09Do IWYU for cpdf_dictionary.h.Lei Zhang
Move some method implementations out of headers in the process. Change-Id: I8701e360d4addd9aec39fe887d932209985d2443 Reviewed-on: https://pdfium-review.googlesource.com/c/43608 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-05Add methods to read specific field flags in CPDF_FormField.Lei Zhang
Instead of reading the entire field flags value and applying bitmasks. Also read an unused setter and make a member const. Change-Id: I4ad645765ac58864b9c155ee9fe740aca4396d52 Reviewed-on: https://pdfium-review.googlesource.com/c/43532 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-08-20Simplify CPDF_InterForm::GenerateNewResourceName().Lei Zhang
It only has one caller, so remove all the checks that will never be true for this caller. Also make it an anonymous function. Change-Id: I06e6a04e2f6b8741b6beb83534502a626564b592 Reviewed-on: https://pdfium-review.googlesource.com/37410 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-16Replace optional bool bNotify with enum type.Tom Sepez
Adds clarity to the call sites. Change-Id: Id4deed9adda2ad79f0847d618792429044d4f7d6 Reviewed-on: https://pdfium-review.googlesource.com/40351 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-14Remove unused form/args of AddWindowsFont()Tom Sepez
Change-Id: I38b508b5518568ff134b70e0e494e5267571c1ca Reviewed-on: https://pdfium-review.googlesource.com/40110 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-10Remove |typedef struct| in favor of just |struct|.Tom Sepez
Because I saw one in some other code and decided to hunt them all. These are all defined in C++ context, so no chance of C compatiblity. Note that such a declaration without a struct tag will bypass the [chromium-style] out-of-line constructor/destructor warnings, so add constructors/destructors where required. Change-Id: Ib821d8bc2f68ccf7028b0f73432e8e7c93a953ba Reviewed-on: https://pdfium-review.googlesource.com/39851 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-08Move ByteString::FromUnicode() to WideString::ToDefANSI()Tom Sepez
Turns out that "FromUnicode" is misleading in that, on linux, it simply removes any characters beyond 0xFF and passes the rest unchanged, so no unicode decoding actually takes place. On Windows, it passes it into the system function specifying FX_CODEPAGE_DefANSI, converting it into the so-called "default ANSI code plane", passing some characters, converting others to '?' and still others to 'A'. Either way, nothing resembling UTF8 comes out of this, so pick a better name. These now immediately look suspicious, so a follow-up CL will see which ones should really be WideString::UTF8Encode() instead. Making this a normal method on a widestring rather than a static method on a bytestring feels more natural; this is parallel to the UTF8Encode and UTF16LE_Encode functions. Add a test that shows these conversions. Change-Id: Ia7551b47199eba61b5c328a97bfe9176ac8e583c Reviewed-on: https://pdfium-review.googlesource.com/39690 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-21Avoid const-refs to implicitly constructed strings.Tom Sepez
Because the invisible temporary goes out of scope at the next semicolon. Also avoid returning const string references since the cost is low to properly keep the string alive. Change-Id: Id283e4fd99f79a02d79d739a533a4ce05e831e2a Reviewed-on: https://pdfium-review.googlesource.com/35710 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-19Move fxcrt::{Byte,Wide}Strings with std::move().chromium/3466Tom Sepez
Remove some string copies in barcode that were noticed whilst looking for moves. Change-Id: Ieda34d00f633576ba1f0dca283dcdabfb36f236c Reviewed-on: https://pdfium-review.googlesource.com/35410 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-11Implement CPDF_Object::MakeReference method.chromium/3456Artem Strygin
Change-Id: I153747ef587a184eaef58ff09dbf8f214c9ddfb3 Reviewed-on: https://pdfium-review.googlesource.com/17230 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-06-07Rename CPDF_PageObjectHolder::GetFormDict() to GetDict().Henrique Nakashima
Renamed the underlying member m_pFormDict as well. These names are misleading, as a page also uses the same field as the page dict. Change-Id: I52e0f1864a917a1e1b863725cb0d4f22faecacb3 Reviewed-on: https://pdfium-review.googlesource.com/34450 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-31Remove uselesss code.Artem Strygin
Change-Id: Id58d10dfb2bc51d3bd8b77fd71e7728823a542cf Reviewed-on: https://pdfium-review.googlesource.com/33410 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-05-31Move codepage/charset methods into related places.Artem Strygin
Change-Id: I71417cc5b1bd00f77d42740198cc17487ebd686e Reviewed-on: https://pdfium-review.googlesource.com/33330 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-05-28Add const/non-const versions of remaining CPDF_Dictionary methods.Lei Zhang
GetObjectFor() and GetDirectObjectFor(). Change-Id: I588cd994dfccf0ffd4c8f91362a4806dc109251e Reviewed-on: https://pdfium-review.googlesource.com/32991 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-05-25Mark more CPDF_Objects as const in action and bookmark code.Lei Zhang
Change-Id: Ib5f4cdb9c7f9c33561028a85029649ba68f4a6e5 Reviewed-on: https://pdfium-review.googlesource.com/32912 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-08Make one more CPDF_PageObjectHolder member protected.Lei Zhang
Change-Id: Id9288d504f063759f69632ab59b0a21569ff76d8 Reviewed-on: https://pdfium-review.googlesource.com/32113 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-04-17Add constants for PDF 1.7 spec, table 3.4.Lei Zhang
Add constants/stream_dict_common.h. The header lists all the constants in the table in the same order. Constants that are not used at all are commented out. BUG=pdfium:1049 Change-Id: I6539090e0ad56319ea628883e388aeacef044e52 Reviewed-on: https://pdfium-review.googlesource.com/29090 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-16Put prototypes of PDF_NameEncode/Decode in fpdf_parser_utility.hTom Sepez
Because the implementations are in fpdf_parser_utility.cpp Add unit test for both. Change-Id: Ibae90ecbe625a035c450614ddbe7f5969f9f92aa Reviewed-on: https://pdfium-review.googlesource.com/30793 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-03-28Remove ByteString PDF_NameDecodeDan Sinclair
This CL removes the ByteString version of PDF_NameDecode and forces the callers to use the ByteStringView variant. Change-Id: I5a955d8e909e2045ee45843af54b23e98abe00ed Reviewed-on: https://pdfium-review.googlesource.com/29350 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-03-08CPDF_InterForm::ResetForm always returns truedan sinclair
This method always returns true, so remove the return value. Change-Id: I3da93fc5face39a53b589787873839c06c9fcfab Reviewed-on: https://pdfium-review.googlesource.com/28210 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-03-08Convert Before{Selection|Value}Change to return a boolchromium/3366dan sinclair
Both of these IPDF_FormNotify methods return {-1, 0, 1} but all callsites only care about < 0 and >= 0. Convert to return a bool that treats the 0 and 1 case as the same. This also makse sense in terms of the API because false means validation failure. The case where 0 was used was a place holder for we didn't try for this field type, which also implicitly means validation passed. Change-Id: I0950c678191b83caffd755d4a87b2f0efee71c89 Reviewed-on: https://pdfium-review.googlesource.com/28192 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-03-08Remove BeforeFormImportData and BeforeFormResetdan sinclair
Both of these IPDF_FormNotify callbacks have empty implementations which just return 0. Removed. Change-Id: I3324113222f19d2f7a2323ab5086e446d2064451 Reviewed-on: https://pdfium-review.googlesource.com/28191 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-01-12Use enum for tracking form field typesRyan Harrison
Within PDFium use enum class for better type safety when working with form field types. These values will still be converted to ints as part of the public API, since that is the existing API. This work is preperation for extending the number of form field types to have more specific entries for XFA. BUG=pdfium:952,chromium:763129,chromium:592758 Change-Id: Ie6c29f02ae22be782ff36eb87d27f1a4bf2c099e Reviewed-on: https://pdfium-review.googlesource.com/22742 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-01-05Remove unused code from CPDF_InterFormRyan Harrison
Change-Id: I8be34dc4bc5ace65f5f56eb062b53faf4c1a6986 Reviewed-on: https://pdfium-review.googlesource.com/22311 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-11-22Remove some pointless assignments to "".Lei Zhang
Or change them to clear(). Change-Id: Ia9e3e1f0d74b948cec3f8df85d205f830ac9216c Reviewed-on: https://pdfium-review.googlesource.com/19172 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-11-16Convert ByteString::{Format|FormatV} to static methodsDan Sinclair
This CL moves the Format and FormatV methods of ByteString to be static. Bug: pdfium:934 Change-Id: I9c30455a789aff9f619b9d5bf89c0712644f2d9a Reviewed-on: https://pdfium-review.googlesource.com/18650 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-09-27Remove FX_STRSIZE and replace with size_tRyan Harrison
BUG=pdfium:828 Change-Id: I5c40237433ebabaeabdb43aec9cdf783e41dfe16 Reviewed-on: https://pdfium-review.googlesource.com/13230 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-27Cleanup FX macrosDan Sinclair
This CL renames the FX_OS defines to have _OS_ in their names and drops the _DESKTOP suffix. The FXM defines have been changed to just FX. Change-Id: Iab172fba541713b5f6d14fb8098baf68e3364c74 Reviewed-on: https://pdfium-review.googlesource.com/14833 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-18Convert string class namesRyan Harrison
Automated using git grep & sed. Replace StringC classes with StringView classes. Remove the CFX_ prefix and put string classes in fxcrt namespace. Change AsStringC() to AsStringView(). Rename tests from TEST(fxcrt, *String*Foo) to TEST(*String*, Foo). Couple of tests needed to have their names regularlized. BUG=pdfium:894 Change-Id: I7ca038685c8d803795f3ed02545124f7a224c83d Reviewed-on: https://pdfium-review.googlesource.com/14151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-08-30Convert int* references to FX_STRSIZERyan Harrison
Through out the code base there are numerous places where variables are declared using a signed integer type when interacting with the string classes, since they assume that FX_STRSIZE is 'int'. As part of changing the underling type of FX_STRSIZE to be unsigned, these locations are being changed to use FX_STRSIZE. This is necessary as part of converting the type, but has been broken off into a separate CL, since it should be low risk. Some related cleanups that are low risk are included as part of this CL. BUG=pdfium:828 Change-Id: Ifaae54ad195ccde0fe8672f71271d29a6ebd65fd Reviewed-on: https://pdfium-review.googlesource.com/12210 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-05-25Mass conversion of remaining class members (non-xfa)Tom Sepez
Change-Id: I8365ba80e3395d59a3cf35dbd9d9162e86e712e3 Reviewed-on: https://pdfium-review.googlesource.com/5970 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-25Mass conversion of all const-lifetime class membersTom Sepez
Sed + minimal conversions to compile, including moving some constructors into the .cpp file. Any that caused ASAN issues during the tests were omitted rather than trying to resolve the underlying issue. Change-Id: I00a421f33b253eb4071ffd9af3f2922c7443b335 Reviewed-on: https://pdfium-review.googlesource.com/5891 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-24Convert to CFX_UnownedPtr, part 3.Tom Sepez
Remove an explicit clear to re-order the member destruction order. Change-Id: I33da3f3de4b8e8e0cfbdceaf5140e98f5d6f904a Reviewed-on: https://pdfium-review.googlesource.com/5791 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-22Convert more c-style pointers to CFX_UnownedPtrTom Sepez
Change-Id: I551b4210c95db0b916e9fe6cddf11e6c3d015c50 Reviewed-on: https://pdfium-review.googlesource.com/5790 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-18Use UnownedPtr to check CFX_*StringC lifetimeschromium/3104Tom Sepez
Change interform to avoid temp StringC with dangling ptr. Change-Id: I8d8659973bcdf2cdbcaa6efa6012e4acce5f1604 Reviewed-on: https://pdfium-review.googlesource.com/5571 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-04-28Disallow CPDF_FormField with deep node trees.Lei Zhang
Otherwise the destruction can stack overflow. BUG=pdfium:716525 Change-Id: I415176a361a0fc2310d3671c1c0e804d11a98261 Reviewed-on: https://pdfium-review.googlesource.com/4613 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-04-28Fix stack overflow in CFieldTree::Node::GetFieldInternal().Lei Zhang
Limit recursion depth, just like in CountFieldsInternal(). BUG=chromium:716523 Change-Id: I70c052347a1d8fb9a4dbc065a1c9af55c02818f2 Reviewed-on: https://pdfium-review.googlesource.com/4612 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-04-27Remove more |new|s, part 2Tom Sepez
Change-Id: I13b43ceafc6a35bcc1e366546a4a408ea01fe4ab Reviewed-on: https://pdfium-review.googlesource.com/4534 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-04-20Remove the friends of CPDF_FormFieldNicolas Pena
Added some public methods so that CPDF_FormField has no friends. Change-Id: I179537e3c6ea64cedaca5365010c34c1ad702c40 Reviewed-on: https://pdfium-review.googlesource.com/4370 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-04-19Cleanup codepage and charset definitions.Dan Sinclair
This Cl cleans up the unused defines in fx_codepage.h. The FXFONT_CHARSET_ defines are replaced with fx_codepage defines, this moves fx_codepage into core instead of xfa only. Static asserts are added to verify the public/ charsets match the fx_codepage charsets. Change-Id: Ie2f749e093de60a9a6743128a1fb087912e4cc96 Reviewed-on: https://pdfium-review.googlesource.com/4316 Commit-Queue: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-04-07Cleanup string passing in core/fpdf*Tom Sepez
Return strings where possible. Add missing consts to strings passed by ref. Convert non-const cases to pointers. Rename a few methods to be clearer. Change-Id: I86569bc1744f539e6dd67fc73649b272c016328c Reviewed-on: https://pdfium-review.googlesource.com/3951 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-04-05Use unique_ptr in the children of CFieldTree::Nodechromium/3064Nicolas Pena
Change-Id: I149718bbdb7195223012150d6162d73cbeb3b8cc Reviewed-on: https://pdfium-review.googlesource.com/3813 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-24Use unique_ptr in CFieldTree::NodeNicolas Pena
Bug: chromium:704824 Change-Id: I3de1a0bcee3317cfaa7e56578b637e427098230a Reviewed-on: https://pdfium-review.googlesource.com/3213 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-14Replace FX_CHAR and FX_WCHAR with underlying types.Dan Sinclair
Change-Id: I96e0a20d66b9184d22f64d8e4ce0dadd5a78c1e8 Reviewed-on: https://pdfium-review.googlesource.com/2967 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-02-21Convert CFWL messages to use CFX_PointFDan Sinclair
This Cl updates the various CFWL_Message classes to take CFX_PointF instead of x,y values. Change-Id: I5d9d01d68be64fc9e69c04574994c01286ad24e1 Reviewed-on: https://pdfium-review.googlesource.com/2811 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-01-24Fix CPDF_InterForm::CheckRequiredFields and its callers.Nicolas Pena
The method is used twice in fpdfsdk/cpdfsdk_interform.cpp and twice in fpdfsdk/javascript/Document.cpp, but not in a compatible way. Changed the method so that it now returns true when checks pass, which is the more natural thing to do, considering the name of the method. BUG=pdfium:659 Change-Id: Iacf3049f328df1d4db3fbfc995acf184230ebf48 Reviewed-on: https://pdfium-review.googlesource.com/2297 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-01-10Remove some CFX_ArrayTemplate in fpdfapi and fpdfdoctsepez
Also use unique_ptr in one spot while we're at it. Review-Url: https://codereview.chromium.org/2625483002
2016-12-07Fix the way to check terminal field in interactive formchromium/2945weili
Originally the key "T" was checked which was not correct since that key is optional. Now change to check "FT" as well as its parent's key since this key is also inheritable. BUG=chromium:440132 Review-Url: https://codereview.chromium.org/2554223002