Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ source_set("pdfium_public_headers_impl") {
"public/epdf_pieceinfo.h",
# EmbedPDF: PNG encoding of RGBA bitmaps.
"public/epdf_png.h",
# EmbedPDF: what we add to public/fpdf_ppo.h.
"public/epdf_ppo.h",
# EmbedPDF: what we add to public/fpdf_progressive.h.
"public/epdf_progressive.h",
# EmbedPDF: typed measurement, viewport and caption API.
Expand Down
5 changes: 5 additions & 0 deletions core/fpdfapi/edit/cpdf_pageorganizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ bool CPDF_PageOrganizer::UpdateReference(RetainPtr<CPDF_Object> obj) {
}
}

// EmbedPDF(epdf-api): see the header.
bool CPDF_PageOrganizer::RetargetReferences(RetainPtr<CPDF_Object> obj) {
return UpdateReference(std::move(obj));
}

uint32_t CPDF_PageOrganizer::GetNewObjId(CPDF_Reference* ref) {
if (!ref) {
return 0;
Expand Down
13 changes: 13 additions & 0 deletions core/fpdfapi/edit/cpdf_pageorganizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ class CPDF_Object;
class CPDF_Reference;

class CPDF_PageOrganizer {
public:
// EmbedPDF(epdf-api): EPDFDoc_ImportPages() (fpdfsdk/epdf_ppo.cpp) copies
// the form fields above the copied widgets: it names its copies before the
// pages are copied, finds the copies the pages made, and points the
// references in its own copies at the destination.
void MapObjectNumber(uint32_t src_obj_num, uint32_t dest_obj_num) {
AddObjectMapping(src_obj_num, dest_obj_num);
}
const std::map<uint32_t, uint32_t>& object_number_map() const {
return object_number_map_;
}
bool RetargetReferences(RetainPtr<CPDF_Object> obj);

protected:
CPDF_PageOrganizer(CPDF_Document* dest_doc, CPDF_Document* src_doc);
~CPDF_PageOrganizer();
Expand Down
4 changes: 4 additions & 0 deletions fpdfsdk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ source_set("fpdfsdk") {
# EmbedPDF: what a parsed page costs, and whether it is still current.
"epdf_page_residency.cpp",
"epdf_png_shim.cpp",
# EmbedPDF: pages copied with their form fields (public/epdf_ppo.h).
"epdf_ppo.cpp",
"epdf_redact.cpp",
"epdf_threading.cpp",
"epdf_wrapped_appearance.cpp",
Expand Down Expand Up @@ -274,6 +276,8 @@ pdfium_embeddertest_source_set("embeddertests") {
"epdf_sliced_load_embeddertest.cpp",
# EmbedPDF: covers the /Names /Pages and /Templates name-tree APIs.
"epdf_named_pages_embeddertest.cpp",
# EmbedPDF: covers pages copied with their form fields (public/epdf_ppo.h).
"epdf_ppo_embeddertest.cpp",
# EmbedPDF: a content rewrite keeps what it did not change.
"epdf_content_rewrite_embeddertest.cpp",
"epdf_redact_embeddertest.cpp",
Expand Down
6 changes: 6 additions & 0 deletions fpdfsdk/epdf_c_api_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "public/epdf_outline.h"
#include "public/epdf_pieceinfo.h"
#include "public/epdf_png.h"
#include "public/epdf_ppo.h"
#include "public/epdf_progressive.h"
#include "public/epdf_redact.h"
#include "public/epdf_save.h"
Expand Down Expand Up @@ -329,6 +330,7 @@ int CheckEmbedPDFCApi(void) {
CHK(EPDFForm_GetFieldOptionLabel);
CHK(EPDFForm_GetFieldOptionValue);
CHK(EPDFForm_GetFieldOrigin);
CHK(EPDFForm_GetFieldPartialName);
CHK(EPDFForm_GetFieldTopIndex);
CHK(EPDFForm_GetFieldValueAt);
CHK(EPDFForm_GetFieldValueKind);
Expand Down Expand Up @@ -502,6 +504,10 @@ int CheckEmbedPDFCApi(void) {
// epdf_png.h
CHK(EPDF_PNG_EncodeRGBA);

// epdf_ppo.h
CHK(EPDFDoc_GetImportFieldRoots);
CHK(EPDFDoc_ImportPages);

// epdf_progressive.h
CHK(EPDF_RenderPageBitmapWithMatrix_Start);
CHK(EPDF_RenderPage_Continue);
Expand Down
16 changes: 16 additions & 0 deletions fpdfsdk/epdf_form.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2973,6 +2973,22 @@ EPDFForm_SetFieldName(FPDF_DOCUMENT document,
return true;
}

FPDF_EXPORT unsigned long FPDF_CALLCONV
EPDFForm_GetFieldPartialName(FPDF_DOCUMENT document,
uint32_t field_objnum,
FPDF_WCHAR* buffer,
unsigned long buflen) {
ScopedFPDFDocumentView document_view(document);
RetainPtr<const CPDF_Dictionary> field =
ResolveFieldDict(document_view.Get(), field_objnum);
if (!field || !field->KeyExist(pdfium::form_fields::kT)) {
return 0;
}
return Utf16EncodeMaybeCopyAndReturnLength(
field->GetUnicodeTextFor(pdfium::form_fields::kT),
UNSAFE_BUFFERS(SpanFromFPDFApiArgs(buffer, buflen)));
}

FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
EPDFForm_SetFieldFlags(FPDF_DOCUMENT document,
uint32_t field_objnum,
Expand Down
Loading