summaryrefslogtreecommitdiff
path: root/fpdfsdk
AgeCommit message (Collapse)Author
2018-08-29Remove FPDFDOC_ prefix from non-public functionsTom Sepez
Second CL for naming consistency. Bug: pdfium:1141 Change-Id: Idf0a0da52abd68648ab709997e0523ee3240c247 Reviewed-on: https://pdfium-review.googlesource.com/41531 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-29Use pdfium::span<> in fpdf_parser_decode.h helper functions.Tom Sepez
Change-Id: Ib0a2bd21fe4304163cf9c080e07475e7c033c299 Reviewed-on: https://pdfium-review.googlesource.com/41570 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-28Handle non-printing characters at beginning of extraction regionRyan Harrison
Currently if a text extraction region begins on a non-printing character then "" will be returned. This is the incorrect behaviour, instead the call should scan ahead until a printing character is found and start extracting from there. Also proactively adds a similar check and scan for the end of the extraction region. BUG=pdfium:1139 Change-Id: Ia2001ac89740f3d31d2bb69e8000773f8b01091b Reviewed-on: https://pdfium-review.googlesource.com/41532 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-08-27The final game: mark everything final.Tom Sepez
Then revert the ones that break compilation. Fix one IWYU noticed during presubmit. Change-Id: I881a8a72818e55dbc4816247e35ff5e3015194e7 Reviewed-on: https://pdfium-review.googlesource.com/41470 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-27Remove unnecessary ToArray() calls and locals in CPDF_Dest.chromium/3535Lei Zhang
Rename GetObject() to GetArray() and remove more ToArray() calls. Change-Id: I754ca72b32c085e1801d3cedcd291ce4d2682359 Reviewed-on: https://pdfium-review.googlesource.com/41353 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-08-24Rename CFX_DIBSource to CFX_DIBBase.Tom Sepez
It is not a source from which you can get CFX_DIBs, but rather a base class from which all DIBs inherit. Do the same thing for the CPDF_DIBSource wrapper class. Mechanical change apart from adding a one-line comment in cfx_dibbase.h Change-Id: Id2bde87813ca301d9fafc55ce08d703dfc6a7184 Reviewed-on: https://pdfium-review.googlesource.com/41352 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-23Use pdfium::span<> in CPDF_Stream::SetData().Tom Sepez
Conversion to span makes this more elegant in a number of places, owing to std::vector directly converting to span, and the bytestring's ToRawSpan(). Disambiguate single-argument forms to allow passing {} as an argument. Change-Id: Ibd5eaadca8d8cbbd589338f375c7ee8439fd3eb2 Reviewed-on: https://pdfium-review.googlesource.com/41272 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-23Fix shadowed variablesRyan Harrison
This CL fixes instances of variable shadowing that are discovered by turning on -Wshadow. BUG=pdfium:1137 Change-Id: I418d50de89ecbeb12e85b23a358bc61e8f16e888 Reviewed-on: https://pdfium-review.googlesource.com/41150 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-08-23Remove deprecated FPDFDest_GetPageIndex() API.Lei Zhang
Use FPDFDest_GetDestPageIndex() instead. BUG=pdfium:1041 Change-Id: I8e91ef46456a60ebd873068765b7c3ff1a991fa4 Reviewed-on: https://pdfium-review.googlesource.com/41230 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-22Properly handle language markers in decoded textRyan Harrison
In text like document title 0x001B is used as a marker for the beginning/end of a language metadata section. Currently PDFium does nothing with this data, but when returning the 'decoded' text it needs to be stripped out. The existing code assumed that the two bytes following a marker would be the data to be removed and did nothing to track if it was in/out of one of these regions. This led to a situation where it would always strip the two bytes following the region, since it assumed the end marker was the beginning of a new region. This CL corrects the detection and handling of these regions, and adds a regression test for the reported bug. BUG=pdfium:182 Change-Id: I92ddba5666274a8986fed03f502a0331f150f7ac Reviewed-on: https://pdfium-review.googlesource.com/41070 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-08-22Use UnownedPtr<> in CPDFSDK_FileWriteAdapter.Tom Sepez
Make member naming match chromium conventions. Change-Id: Iaa88d1446d445da3a059a339b35a5ef2152811ff Reviewed-on: https://pdfium-review.googlesource.com/40952 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-21Use UnownedPtr in CPDF_VariableTextTom Sepez
Re-arrange order of some variables so that the lifetime constraints are not violated, even temporarilly. Change-Id: I859f1217d5af0f4c703a3d8ed742c1f144cc1c61 Reviewed-on: https://pdfium-review.googlesource.com/40950 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-20Use more UnownedPtr<> in CPWL_Wnd::CreateParams.Tom Sepez
Move some initialization/accessors to header while at it. Remove unused GetRootWnd(). Change-Id: Icd4c77ebad0c1edf8a8443f86581e7724aa1b93b Reviewed-on: https://pdfium-review.googlesource.com/40670 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-17Add FPDFText_GetFontInfoNicolas Pena
Bug: pdfium:929 Change-Id: I9da03a1e317cff69ec4c76b69289cfa753b6bb77 Reviewed-on: https://pdfium-review.googlesource.com/40531 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-08-16Remove arguments from CPWL_Edit::SetAlignFormatV().chromium/3525Tom Sepez
There's only one caller. Rename to match its new behaviour. Change-Id: I2d5ac2017316fdf6e9533fe506f2dab14205043a Reviewed-on: https://pdfium-review.googlesource.com/40410 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-16Replace optional bool bDrawFocus with enum type.Tom Sepez
Change-Id: Ide4a972337afaf346e46edc4ede48140cd4544c1 Reviewed-on: https://pdfium-review.googlesource.com/40390 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: 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-15Make CFX_MemoryStream always consecutive.chromium/3524Lei Zhang
Non-consecutive mode has questionable correctness and is not an obvious performance win. Change-Id: Idaa66e5ee5c4604628a0f55b67d5a04ab47ea5ec Reviewed-on: https://pdfium-review.googlesource.com/40050 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-14Remove default args from CPDF_DIBSource::StartLoadDIBSource().Tom Sepez
Change-Id: I13f53f581487f643acf160f53d02e9af7d54cfd1 Reviewed-on: https://pdfium-review.googlesource.com/40151 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-14Remove unreachable vertical text code in CPDF_Document.Lei Zhang
Change-Id: I64b34da202a0f1c30a38cba2f24490aad4063828 Reviewed-on: https://pdfium-review.googlesource.com/40150 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-14Add FPDFFormObj_GetMatrix() APIMiklos Vajna
This is similar to FPDFText_GetMatrix() (wrapping CPDF_TextObject::GetTextMatrix()) and FPDFPath_GetMatrix() (wrapping CPDF_PathObject::m_Matrix), but wraps the matrix of form objects: CPDF_FormObject::form_matrix(). Change-Id: Ic4ce7ad8050012f54de356bb936263d3e4f097ca Reviewed-on: https://pdfium-review.googlesource.com/39930 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-08-14Remove more default arg = nullptr cases.Tom Sepez
Bring in line with standards. Remove argument entirely for mac code that is always nullptr. Change-Id: I0710bdbd51fc0bc2e1d428ef44976be39a631147 Reviewed-on: https://pdfium-review.googlesource.com/40091 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-13Make CFX_ReadOnlyMemoryStream take a span.Lei Zhang
Change-Id: Id097320ab2d9b5d1579582e5797e29c701499501 Reviewed-on: https://pdfium-review.googlesource.com/39991 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-08-13Change CFDF_Document::ParseMemory() to use pdfium::span.Lei Zhang
Change-Id: I1e9b02f0cb2628d41bc1c6bdcfcfa09c36faf97e Reviewed-on: https://pdfium-review.googlesource.com/39990 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-13Use std::vector in FDFToURLEncodedData().Lei Zhang
Simplify memory management. Change-Id: Ie17b96fa53dff79f6cb8131d7a8ffc6a0e3f6a34 Reviewed-on: https://pdfium-review.googlesource.com/39972 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-08-13Move FDFToURLEncodedData() into an anonymous namespace.Lei Zhang
Change-Id: Iac581765f343f464f73a892b300ae20923c3bb32 Reviewed-on: https://pdfium-review.googlesource.com/39971 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-13Move CPDFSDK_MemoryAccess to fxcrt.Lei Zhang
Rename it CFX_ReadOnlyMemoryStream and swap out one use of CFX_MemoryStream. BUG=pdfium:263 Change-Id: I15012df156a6a4d7c36f6fd58f32c355eae5fa1a Reviewed-on: https://pdfium-review.googlesource.com/39878 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-10Kill some optional parameters that are always supplied.Tom Sepez
No need to even bring any .cpp files in line with these headers. Change-Id: I934169d77ae09adc11f02e5ea92b1f8b078c9477 Reviewed-on: https://pdfium-review.googlesource.com/39876 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-10Fix sign mismatch in CPDFXFA_DocEnvironment.Lei Zhang
Fix some other nits as well. Change-Id: I837bd49526dd97ce666f8d8743fe5bd7653ae544 Reviewed-on: https://pdfium-review.googlesource.com/39410 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-08-10Remove direct calls to timechromium/3519Ryan Harrison
Replaces them with calles to the proxy function, FXSYS_time, so that tests may use a stable time value instead of the wall clock value. BUG=pdfium:1104 Change-Id: I4743c4634f56d4a6cba1f1130c4562a35cee1887 Reviewed-on: https://pdfium-review.googlesource.com/39853 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-08-10Add proxy for syscall timeRyan Harrison
This CL adds a proxy, FXSYS_time, for the time syscall, so that a testing mechanism can be implemented. Specically there is now a flag for pdfium_test, --time=, that allows setting the time since the epoch that will be returned. This plumbed all the way down into the proxy and allows for stable results for tests that depend on getting the current time. There are other places in the code base that will need to be patched like this, that will be dealt with in follow on CLs. BUG=pdfium:1104 Change-Id: I2de185f8d47abe46704dd579c13a54948b7f81e0 Reviewed-on: https://pdfium-review.googlesource.com/39750 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-08-08Remove include of <time.h> from fpdfsdk/cpdfsdk_datetime.hTom Sepez
Prevent stray calls to get time from the system without explicilty including <time.h> in some .cpp file. This helps to be able to control all the places where PDFium obtains time more carefully. Change-Id: I9d52a00b9d4413e18c98f0476fabe7c5f2cd6574 Reviewed-on: https://pdfium-review.googlesource.com/39710 Commit-Queue: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@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-08-07Make CPDF_Font::GetFontBBox() return the bounding box.Lei Zhang
Instead of using an out parameter. Fix nits in the only caller as well. Change-Id: I04eb92705b2fbda001191c36da972eee499acbc7 Reviewed-on: https://pdfium-review.googlesource.com/39490 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-07Add FPDFTextObj_GetText() APIMiklos Vajna
Generalize CPDF_TextPage::GetTextByRect(), so that it's possible to get the text from a text page using a predicate, that way we can easily get the text that belongs to single text object as well. Change-Id: Ia457af0f41184694dc1481709be72b35685bce7f Reviewed-on: https://pdfium-review.googlesource.com/39530 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-04Do more CBA_FontMap initialization in the ctor and header.Lei Zhang
Change-Id: I705a49198a91b67aa403beea4446095a6a359259 Reviewed-on: https://pdfium-review.googlesource.com/39415 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-02Handle inline font dicts in CBA_FontMap::AddFontToAnnotDict().Lei Zhang
BUG=chromium:869171 Change-Id: I0176bcafa8a63396d916916b5e10b96573085d04 Reviewed-on: https://pdfium-review.googlesource.com/39414 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-08-01Make FPDF_FormHandle be represented as an incomplete type.chromium/3510Tom Sepez
Make consistent with other public API types. Introduce CPDFSDKFormFillEnvironmentFromFPDFFormHandle() and FPDFFormHandleFromCPDFSDKFormFillEnvironment() helper functions. Use these to kill off some casts in the process. Change-Id: I6230ecdb4cecd03076f5e24c8cc49c45ad694da7 Reviewed-on: https://pdfium-review.googlesource.com/39250 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-01Fix sign mismatch in CPDFSDK_FormFillEnvironment::GetPageViewCount().Lei Zhang
Also initialize members in the header when possible. Change-Id: I458bc433f79ac2f6c04d645f44db6f460fd0bdc1 Reviewed-on: https://pdfium-review.googlesource.com/39330 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-01Add FPDFText_GetFontName() APIMiklos Vajna
This follows the same pattern as DefaultGetFaceName(), so the client has to call this function twice, but allocation of the string buffer happens outside pdfium. Change-Id: I06b7dcd00aca9b9b94799dad3f139617d7f5451e Reviewed-on: https://pdfium-review.googlesource.com/38870 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-07-28Add CPDSDK_Annot::AsBAAnnot() checked downcast methodTom Sepez
XFA introduces some additional subclasses, so it doesn't hurt to be sure in all cases before making a static cast. Change-Id: I7447ca58be0b57201b39ba40a3fc5f47505cee58 Reviewed-on: https://pdfium-review.googlesource.com/39013 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-27Make pdfium_embeddertests pass on Windows 10.Lei Zhang
BUG=chromium:828177 NOTRY=true Change-Id: I30123087bbe11aaaa6175b5f729b7ab55107a975 Reviewed-on: https://pdfium-review.googlesource.com/38902 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-07-27Fix some nits in FPDFEditEmbeddertest.Lei Zhang
Change-Id: I435ced292df79118fb65dd2922292ed29824dc1c Reviewed-on: https://pdfium-review.googlesource.com/38970 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-07-26Be more careful casting to widget subclasses.Tom Sepez
Part of the effort to reduce unchecked static casts. Change-Id: I1bff1c53aa7c5804660de4b65cf01523d70fcbb7 Reviewed-on: https://pdfium-review.googlesource.com/38896 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-25Remove some ASSERT (and cast) in favor of checked cases.Tom Sepez
Because it is a stronger pattern at runtime. These were found by essentially: grep -ni '\bassert\b.*type' Change-Id: I913d77139053e8980528597a6633e1859e5204c4 Reviewed-on: https://pdfium-review.googlesource.com/38890 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-25Disable submit in XFA forms.Henrique Nakashima
Bug: chromium:842503 Change-Id: If411815d8324929f482e3cad0fda54f24d370c2a Reviewed-on: https://pdfium-review.googlesource.com/37830 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-07-24Fix encryption dictionary owning.Artem Strygin
Return encryption dictionary as const reference from CPDF_Parser. Create a copy in CPDF_Creator if needed. Change-Id: I270f71d307d818fba7f65ebe379f5942ae816934 Reviewed-on: https://pdfium-review.googlesource.com/38390 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-07-17Add Deleter and Scoper for FPDF_PAGELINK.chromium/3495Andrew Weintraub
Change-Id: Ie997bfa5437d4222a381be3fc2b4334d6c8e2d5b Reviewed-on: https://pdfium-review.googlesource.com/38190 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-17Cleanup SetSavedCalled APIRyan Harrison
Fix a couple of post submit comments on the originally version of this API. BUG=pdfium:953 Change-Id: Id5b7480c5791821340366371b4ab861e78d47e8b Reviewed-on: https://pdfium-review.googlesource.com/38150 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-07-16Alert embedder when attempting to save XFA formRyan Harrison
This CL adds an experimental callback to the form fill API that allows PDFium to signal to the embedder that an attempt call save occurred. The embedder is responsible for showing an appropriate UI when this occurs. When PDF saving is implemented the API can be removed. BUG=pdfium:953 Change-Id: Iba30f4d0547fe773b793e499995be426626092a0 Reviewed-on: https://pdfium-review.googlesource.com/35870 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>