summaryrefslogtreecommitdiff
path: root/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
AgeCommit message (Collapse)Author
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-06-07Return from GenerateContent() if m_pObjHolder->GetFormDict() is null.Henrique Nakashima
Currently this case will lead to a crash, as pContent will be null and pPageDict will be dereferenced. This is a theoritical case, there is no concrete test case. Change-Id: Ieedab26cd9f419ab49aa2cde15f1b8e3c230b61d Reviewed-on: https://pdfium-review.googlesource.com/34430 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@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-05-07Make more CPDF_PageObjectHolder members protected.Lei Zhang
Change-Id: Id31b9f6ac33971c47cdb378ff7f9ca7d33f899b9 Reviewed-on: https://pdfium-review.googlesource.com/32112 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@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-04-13Get rid of CPDF_Color::GetColorSpace().Lei Zhang
Replace it with more narrowly focused methods to get specific bits from the colorspace. Change-Id: Ifd2980f0fd06230d4d94d28eddf72219d2e9e6eb Reviewed-on: https://pdfium-review.googlesource.com/30590 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-02-22Add namespaces to duplicated Skia code.Jonathan Feinberg
When pdfium is imported into Google's internal repository, the recently copied Skia decimal formatting code causes only-defined-once violations because many Google internal projects depends on Skia through Google's own copy. This patch puts pdfium's private copy of the needed function into a namespace. Change-Id: Id102b17f6f4652e4a50c4ff75825468fc3d90727 Reviewed-on: https://pdfium-review.googlesource.com/27530 Reviewed-by: Hal Canary <halcanary@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-02-16Improve performance of writing path floats.Dan Sinclair
This CL copies the SkPDF code to convert floats into strings when writing back to PDF files. Change-Id: I8f8af3924a07aa67f93b9d951af1eef5d2c705db Reviewed-on: https://pdfium-review.googlesource.com/21990 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Hal Canary <halcanary@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-10-04Remove friends from CPDF_TextObjectchromium/3233Dan Sinclair
This CL removes the friends from CPDF_TextObject and adds accessor methods as needed. Change-Id: I68d18297640b46113df79f58bea50b77dac89d39 Reviewed-on: https://pdfium-review.googlesource.com/15455 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-21Rename CFX_RetainPtr to RetainPtrDan Sinclair
This CL renames CFX_RetainPtr to RetainPtr and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: I8798a9f79cb0840d3f037e8d04937cedd742914e Reviewed-on: https://pdfium-review.googlesource.com/14616 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-10Move graphic state operations outside BT/ET operationsRyan Wiley
Bug: pdfium:857 Change-Id: Ic1fb12459cad79b45466df10a24fe6743377ae14 Reviewed-on: https://pdfium-review.googlesource.com/10612 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-06-29Basic APIs and tests for extracting and setting annotation pathsJane Liu
1. Added APIs for retrieving existing annotation paths and setting annotation paths. * Added an embedder test testing all the new functions. Bug=pdfium:737 Change-Id: Ic451bcd3be488261baf2182549c4238b887b219e Reviewed-on: https://pdfium-review.googlesource.com/6676 Commit-Queue: Jane Liu <janeliulwq@google.com> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-06-29Change SetReverse to GetInverse in CFX_MatrixNicolas Pena
CFX_Matrix::GetInverse is much clearer. Change-Id: Id10ab1723735332e1a78de853f28415ec3a4d834 Reviewed-on: https://pdfium-review.googlesource.com/7090 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-06-28Set default graphics before generating page contentsNicolas Pena
In this CL, the content generator sets some default graphics states before processing the page objects. In particular, a default ExtGState is now set before processing, and the last CTM is now stored right after parsing finishes: the only command to change matrix is ctm, and it concatenates, so inverting requires knowing the current value. Bug: pdfium:779 Change-Id: I35b1c07550ce91839fb0e20fbf717e3e80c9b9d6 Reviewed-on: https://pdfium-review.googlesource.com/7070 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-06-28Use new overloads to make usages of ostringstream more readable.Henrique Nakashima
Bug: pdfium:731 Change-Id: I92077971aec6bada061ed101cb48abe1611050d7 Reviewed-on: https://pdfium-review.googlesource.com/7042 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-06-27Modified CPDF_PageContentGenerator to work with both Form and PageJane Liu
CPDF_PageContentGenerator currently only works for CPDF_Page objects. However, CPDF_Form is also a CPDF_PageObjectHolder like CPDF_Page, and content streams can be generated for form objects too. This CL modifies the content generator to work with both forms and pages. The content generator will later be used on annotation objects' CPDF_Form to simplify the code for annotation AP stream generation. Change-Id: I1c50bdf0329d1f5788db23286ac72750355a10ed Reviewed-on: https://pdfium-review.googlesource.com/6837 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-06-14Add blend to GraphicsDataNicolas Pena
CL [1] added the ability to set the blend mode for a page object. This CL adds the corresponding component to GraphicsData since the blend mode is part of ExtGSState. In addition, a test using the SetBlendMode method is added. [1] https://pdfium-review.googlesource.com/c/5953/ Bug: pdfium:720 Change-Id: I49120284345185c200a45cc3b37ec59f0658e2dc Reviewed-on: https://pdfium-review.googlesource.com/6510 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-06-13Converting CFX_ByteTextBuf to ostringstream in cpdf_pagecontentgenerator.Henrique Nakashima
Bug: pdfium:731 Change-Id: If606359bd9264a6f440871ab824ab54a4efae901 Reviewed-on: https://pdfium-review.googlesource.com/6450 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-06-07Fix EmptyCreation testNicolas Pena
The Contents stream of a page is optional per PDF spec 1.7 Table 3.27. This CL fixes the empty creation test to acknowledge that. Change-Id: I1e59a1fedbf00eafabe87962830d62d8883a5e1f Reviewed-on: https://pdfium-review.googlesource.com/6311 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-06-01Fix content generation to only generate dirty page objects.wileyrya
BUG=pdfium:717 R=dsinclair@chromium.org,thestig@chromium.org Change-Id: I7e0e6fd301d40f9b5341d40cf11167b7748af243 Reviewed-on: https://pdfium-review.googlesource.com/6071 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-26Add public API for setting the blend mode on a page object.wileyrya
BUG=pdfium:720 R=npm@chromium.org Change-Id: I2a43b34da6946265ca06502b9ff19ad352fd18cb Reviewed-on: https://pdfium-review.googlesource.com/5953 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-05-26Add public API for setting the fill color on a text objectwileyrya
BUG=pdfium:719 R=npm@chromium.org Change-Id: Ifd9330de265f8419d588b65fbd6a6187f17badd1 Reviewed-on: https://pdfium-review.googlesource.com/5950 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-26Add public API for setting LineJoin and LineCap on a pathwileyrya
BUG=pdfium:718 R=npm@chromium.org Change-Id: Icdc1546c87a676a7d05330dece2c5eacd92c0c92 Reviewed-on: https://pdfium-review.googlesource.com/5951 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-24Convert to CFX_UnownedPtr, part 8chromium/3110Tom Sepez
Change-Id: I99d6b4df72e369652301c36e4046f03ef95ed07d Reviewed-on: https://pdfium-review.googlesource.com/5837 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@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-04-07Tweak CFDF_Font::AppendChar()Tom Sepez
Pass in/out argument as a pointer. Avoid pointless malloc just to copy in multibyte case. Then we can avoid special-casing the single-byte case. Change-Id: I3dd2d57e08ef6ad7b78ea38398b228fa41a9b3e6 Reviewed-on: https://pdfium-review.googlesource.com/3950 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-04-01Refcount CPDF_Image all the time.chromium/3061chromium/3060Tom Sepez
Remove the old externally-counted CPDF_CountedImage type. Change-Id: Ia0b288586272da3f2daf7dfc153f08e62794321a Reviewed-on: https://pdfium-review.googlesource.com/3553 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-03-20Allow processing fonts with indirect dictNicolas Pena
BUG=pdfium:667 Change-Id: I6e7620948086f3f620e4cde778a4144570e1bd6d Reviewed-on: https://pdfium-review.googlesource.com/3106 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-15Refactor some CPDF_ColorSpace code.Lei Zhang
Change-Id: I1e30d68dae3bf70cf3c426f6126d593b7f1c3ba4 Reviewed-on: https://pdfium-review.googlesource.com/2991 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-03-14Replace FX_FLOAT with underlying float type.Dan Sinclair
Change-Id: I158b7d80b0ec28b742a9f2d5a96f3dde7fb3ab56 Reviewed-on: https://pdfium-review.googlesource.com/3031 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-02-23Convert point x,y into CFX_PointFdan sinclair
This Cl converts the PointX,PointY pairs into a CFX_PointF. Change-Id: I46897832077c317a5bffb4e568550705decbc40c Reviewed-on: https://pdfium-review.googlesource.com/2821 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-02-15Move generated graphics and font maps to CPDF_PageNicolas Pena
A new CPDF_PageContentGenerator is created for every call of FPDFPage_GenerateContent, so having the maps there will cause duplicated resources to be created every time this method is called. Thus it is better to move these to the page. Change-Id: I47804f79790fc5354f8a94b6387d66b65eda5a20 Reviewed-on: https://pdfium-review.googlesource.com/2717 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-02-15Cleanup CFX_PathData.Dan Sinclair
This CL replaces the array of path points with a vector. Cleaning up the usage as required. Change-Id: Ifa386a2c847005fef68af748ebe99c4e08961238 Reviewed-on: https://pdfium-review.googlesource.com/2710 Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-02-14Add ProcessText supporting standard fontsNicolas Pena
BUG=pdfium:667 Change-Id: I701719144127881ebdb5be01a51e833d1e576477 Reviewed-on: https://pdfium-review.googlesource.com/2691 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-02-10Add line width option for stroking pathschromium/3011chromium/3010chromium/3009Nicolas Pena
BUG=pdfium:661 Change-Id: Ie1dc82a1323a35ebbd63a5b7b8f8c95f9a5325fe Reviewed-on: https://pdfium-review.googlesource.com/2613 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-02-07Use enum class for PathPoint types.Nicolas Pena
This hopefully makes it less confusing what the description of a point is. Currently we have defines for the types, which is confusing because a point can only be one of the three. And it is mixed up with whether the point is closing a figure or not. Change-Id: Icd71355d69c77b3d52ca78e03bc379081ff87753 Reviewed-on: https://pdfium-review.googlesource.com/2552 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-02-06Add support for fill and stroke RGBA in CPDF_PageContentGeneratorNicolas Pena
CPDF_PageObject is a CPDF_GraphicStates, which allows us to add graphics information to the object itself. The RGB can be added easily in the stream. The alpha parameter needs to be in a dictionary contained in the ExtGState, which should be part of the page's resources. BUG=pdfium:661 Change-Id: Id99b2ece7aa201e3550c765ac2b5eeff4b43fc48 Reviewed-on: https://pdfium-review.googlesource.com/2530 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-02-02Add CPDF_PageContentGenerator::ProcessPath supporting path constructionNicolas Pena
See Table 4.9 for path construction operators. Ignoring v, y, because those can be replaced with the more powerful c operator. The code added will be called by public methods that do not exist yet. BUG=pdfium:661 Change-Id: I9a1ad3fd0a601e4e3a292b55f3e5708fe0c9c8fb Reviewed-on: https://pdfium-review.googlesource.com/2495 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2016-11-21Make CPDF_ImageObject::m_Matrix private.thestig
Review-Url: https://codereview.chromium.org/2514263003
2016-11-21Make CPDF_Stream() take unique_ptr's to its dictionary.tsepez
Review-Url: https://codereview.chromium.org/2520493002
2016-11-21Clean up CPDF_PageContentGenerator.thestig
Review-Url: https://codereview.chromium.org/2513313002
2016-11-18Make CPDF_Dictionary use unique pointers.chromium/2926tsepez
Some changes were required to match underlying ctors as invoked by the templated methods. Many release() calls go away, a few WrapUniques() are introduced to avoid going deeper into other code. Review-Url: https://codereview.chromium.org/2510223002
2016-11-16Make CPDF_Object subclass constructors intern stringstsepez
Make CDPF_Arrays intern the object they create. Allow passing nullptr as a CFX_WeakPtr shortcut as well. Review-Url: https://codereview.chromium.org/2509123002
2016-11-15Make AddIndirectObject() take a unique_ptr.tsepez
Add convenience routines to create and add object in one step. Review-Url: https://codereview.chromium.org/2489283003
2016-11-14Make CPDF_PageContentGenerator methods take object numberstsepez
This patch fixes a possibility that an owned CPDF_Stream is handed to the indirect object holder inside RealizeResource(). Its arguments are changed to take an object number, as is done elsewhere in the code, to suggest that only indirect objects are acceptable. BUG=660756 Review-Url: https://codereview.chromium.org/2489423002
2016-11-11Fix sevg above CPDF_PageContentGenerator::ProcessImage()tsepez
Adds a test to process an image for which a stream hasn't been set. BUG=660756 Review-Url: https://codereview.chromium.org/2494683007
2016-10-14Revert "Update CPDF_IndirectObjectHolder APIs for unique objects."Tom Sepez
This reverts commit 3ba098595ae56b64eacc0c25ab76b89a4d78d920. TBR=thestig@chromium.org,weili@chromium.org Review URL: https://codereview.chromium.org/2424533003 .